From cb78944739315ca92d64bddf64689e82df4b3cc5 Mon Sep 17 00:00:00 2001 From: DerekBum Date: Thu, 19 Oct 2023 13:39:18 +0300 Subject: [PATCH] api: update generator for Tarantool `v3` Updated generation of constants (and tests) for Tarantool `v3`. Unfortunately, new generator does not support Tarantool version < `v3`, due to some naming differences for enums. Part of https://github.com/tarantool/go-tarantool/issues/337 --- .github/workflows/test.yml | 2 +- CHANGELOG.md | 2 + README.md | 2 +- doc.go | 4 +- error.go | 30 ++++++++-- error_string.go | 16 +++++- error_test.go | 12 +++- feature.go | 8 +++ feature_string.go | 6 +- feature_test.go | 2 + flag.go | 6 +- flag_test.go | 6 +- generate.sh | 110 +++++++++++++++++++++++++++++++------ keys.go | 24 +++++--- keys_string.go | 15 +++-- keys_test.go | 5 ++ type.go | 30 ++++++---- type_string.go | 20 ++++--- type_test.go | 8 ++- 19 files changed, 235 insertions(+), 73 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f298cea..946e815 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,7 +58,7 @@ jobs: - run: make deps - - run: TT_TAG=2.11.0 make + - run: TT_TAG=master make golangci-lint: if: (github.event_name == 'push') || diff --git a/CHANGELOG.md b/CHANGELOG.md index 36f41b5..9e486c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,10 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release. ## [Unreleased] ### Added +- Constants from Tarantool `v3` (#6). ### Changed +- `ER_UNUSED` with error code 248 renamed to `ER_DEFAULT_VALUE_TYPE` (#6). ### Fixed diff --git a/README.md b/README.md index c73f860..2ecf672 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ You can generate the code with commands: ```bash TT_TAG=master make -TT_TAG=2.11.0 make +TT_TAG=3.0.0-alpha1 make TT_TAG=master TT_REPO=https://github.com/my/tarantool.git make ``` diff --git a/doc.go b/doc.go index 19e53ba..78ce358 100644 --- a/doc.go +++ b/doc.go @@ -3,8 +3,8 @@ // The package code generated from: // // Repository: https://github.com/tarantool/tarantool.git -// Tag or branch: 2.11.0 -// Commit: 247a9a418338b2d150ab648c54169ec1f1af2d76 +// Tag or branch: master +// Commit: ddaa5a320ee8d8d1009e07bbf6b8fe5cb4acbb45 package iproto // Code generated by generate.sh; DO NOT EDIT. diff --git a/error.go b/error.go index ee194b2..f74e244 100644 --- a/error.go +++ b/error.go @@ -113,7 +113,7 @@ const ( ER_NO_SUCH_FUNCTION Error = 51 // "Function '%s' already exists" ER_FUNCTION_EXISTS Error = 52 - // "Invalid return value of space:before_replace trigger: expected tuple or nil, got %s" + // "Invalid return value of space:before_replace trigger: expected tuple or nil" ER_BEFORE_REPLACE_RET Error = 53 // "Can not perform %s in a multi-statement transaction" ER_MULTISTATEMENT_TRANSACTION Error = 54 @@ -353,7 +353,7 @@ const ( ER_SQL_TYPE_MISMATCH Error = 171 // "Rowid is overflowed: too many entries in ephemeral space" ER_ROWID_OVERFLOW Error = 172 - // "Can't drop collation %s : %s" + // "Can't drop collation '%s': %s" ER_DROP_COLLATION Error = 173 // "Illegal mix of collations" ER_ILLEGAL_COLLATION_MIX Error = 174 @@ -479,7 +479,7 @@ const ( ER_CREATE_CONSTRAINT Error = 234 // "Check constraint '%s' failed for field '%s'" ER_FIELD_CONSTRAINT_FAILED Error = 235 - // "Check constraint '%s' failed for tuple" + // "Check constraint '%s' failed for a tuple" ER_TUPLE_CONSTRAINT_FAILED Error = 236 // "Failed to create foreign key '%s' in space '%s': %s" ER_CREATE_FOREIGN_KEY Error = 237 @@ -503,8 +503,8 @@ const ( ER_INTERFERING_ELECTIONS Error = 246 // "Iterator position is invalid" ER_ITERATOR_POSITION Error = 247 - // "" - ER_UNUSED Error = 248 + // "Type of the default value does not match tuple field %s type: expected %s, got %s" + ER_DEFAULT_VALUE_TYPE Error = 248 // "Unknown authentication method '%s'" ER_UNKNOWN_AUTH_METHOD Error = 249 // "Invalid '%s' data: %s" @@ -541,4 +541,24 @@ const ( ER_WRONG_FUNCTION_OPTIONS Error = 265 // "Snapshot has no system spaces" ER_MISSING_SYSTEM_SPACES Error = 266 + // "Cluster name mismatch: name '%s' provided in config confilcts with the instance one '%s'" + ER_CLUSTER_NAME_MISMATCH Error = 267 + // "Replicaset name mismatch: name '%s' provided in config confilcts with the instance one '%s'" + ER_REPLICASET_NAME_MISMATCH Error = 268 + // "Duplicate replica name %s, already occupied by %s" + ER_INSTANCE_NAME_DUPLICATE Error = 269 + // "Instance name mismatch: name '%s' provided in config confilcts with the instance one '%s'" + ER_INSTANCE_NAME_MISMATCH Error = 270 + // "Your schema version is %u.%u.%u while Tarantool %s requires a more recent schema version. Please, consider using box.schema.upgrade()." + ER_SCHEMA_NEEDS_UPGRADE Error = 271 + // "Schema upgrade is already in progress" + ER_SCHEMA_UPGRADE_IN_PROGRESS Error = 272 + // "%s is deprecated" + ER_DEPRECATED Error = 273 + // "Please call box.cfg{} first" + ER_UNCONFIGURED Error = 274 + // "Failed to create field default function '%s': %s" + ER_CREATE_DEFAULT_FUNC Error = 275 + // "Error calling field default function '%s': %s" + ER_DEFAULT_FUNC_FAILED Error = 276 ) diff --git a/error_string.go b/error_string.go index 6a4c3b7..a3d813d 100644 --- a/error_string.go +++ b/error_string.go @@ -256,7 +256,7 @@ func _() { _ = x[ER_OLD_TERM-245] _ = x[ER_INTERFERING_ELECTIONS-246] _ = x[ER_ITERATOR_POSITION-247] - _ = x[ER_UNUSED-248] + _ = x[ER_DEFAULT_VALUE_TYPE-248] _ = x[ER_UNKNOWN_AUTH_METHOD-249] _ = x[ER_INVALID_AUTH_DATA-250] _ = x[ER_INVALID_AUTH_REQUEST-251] @@ -275,11 +275,21 @@ func _() { _ = x[ER_NIL_UUID-264] _ = x[ER_WRONG_FUNCTION_OPTIONS-265] _ = x[ER_MISSING_SYSTEM_SPACES-266] + _ = x[ER_CLUSTER_NAME_MISMATCH-267] + _ = x[ER_REPLICASET_NAME_MISMATCH-268] + _ = x[ER_INSTANCE_NAME_DUPLICATE-269] + _ = x[ER_INSTANCE_NAME_MISMATCH-270] + _ = x[ER_SCHEMA_NEEDS_UPGRADE-271] + _ = x[ER_SCHEMA_UPGRADE_IN_PROGRESS-272] + _ = x[ER_DEPRECATED-273] + _ = x[ER_UNCONFIGURED-274] + _ = x[ER_CREATE_DEFAULT_FUNC-275] + _ = x[ER_DEFAULT_FUNC_FAILED-276] } -const _Error_name = "ER_UNKNOWNER_ILLEGAL_PARAMSER_MEMORY_ISSUEER_TUPLE_FOUNDER_TUPLE_NOT_FOUNDER_UNSUPPORTEDER_NONMASTERER_READONLYER_INJECTIONER_CREATE_SPACEER_SPACE_EXISTSER_DROP_SPACEER_ALTER_SPACEER_INDEX_TYPEER_MODIFY_INDEXER_LAST_DROPER_TUPLE_FORMAT_LIMITER_DROP_PRIMARY_KEYER_KEY_PART_TYPEER_EXACT_MATCHER_INVALID_MSGPACKER_PROC_RETER_TUPLE_NOT_ARRAYER_FIELD_TYPEER_INDEX_PART_TYPE_MISMATCHER_UPDATE_SPLICEER_UPDATE_ARG_TYPEER_FORMAT_MISMATCH_INDEX_PARTER_UNKNOWN_UPDATE_OPER_UPDATE_FIELDER_FUNCTION_TX_ACTIVEER_KEY_PART_COUNTER_PROC_LUAER_NO_SUCH_PROCER_NO_SUCH_TRIGGERER_NO_SUCH_INDEX_IDER_NO_SUCH_SPACEER_NO_SUCH_FIELD_NOER_EXACT_FIELD_COUNTER_FIELD_MISSINGER_WAL_IOER_MORE_THAN_ONE_TUPLEER_ACCESS_DENIEDER_CREATE_USERER_DROP_USERER_NO_SUCH_USERER_USER_EXISTSER_CREDS_MISMATCHER_UNKNOWN_REQUEST_TYPEER_UNKNOWN_SCHEMA_OBJECTER_CREATE_FUNCTIONER_NO_SUCH_FUNCTIONER_FUNCTION_EXISTSER_BEFORE_REPLACE_RETER_MULTISTATEMENT_TRANSACTIONER_TRIGGER_EXISTSER_USER_MAXER_NO_SUCH_ENGINEER_RELOAD_CFGER_CFGER_SAVEPOINT_EMPTY_TXER_NO_SUCH_SAVEPOINTER_UNKNOWN_REPLICAER_REPLICASET_UUID_MISMATCHER_INVALID_UUIDER_REPLICASET_UUID_IS_ROER_INSTANCE_UUID_MISMATCHER_REPLICA_ID_IS_RESERVEDER_INVALID_ORDERER_MISSING_REQUEST_FIELDER_IDENTIFIERER_DROP_FUNCTIONER_ITERATOR_TYPEER_REPLICA_MAXER_INVALID_XLOGER_INVALID_XLOG_NAMEER_INVALID_XLOG_ORDERER_NO_CONNECTIONER_TIMEOUTER_ACTIVE_TRANSACTIONER_CURSOR_NO_TRANSACTIONER_CROSS_ENGINE_TRANSACTIONER_NO_SUCH_ROLEER_ROLE_EXISTSER_CREATE_ROLEER_INDEX_EXISTSER_SESSION_CLOSEDER_ROLE_LOOPER_GRANTER_PRIV_GRANTEDER_ROLE_GRANTEDER_PRIV_NOT_GRANTEDER_ROLE_NOT_GRANTEDER_MISSING_SNAPSHOTER_CANT_UPDATE_PRIMARY_KEYER_UPDATE_INTEGER_OVERFLOWER_GUEST_USER_PASSWORDER_TRANSACTION_CONFLICTER_UNSUPPORTED_PRIVER_LOAD_FUNCTIONER_FUNCTION_LANGUAGEER_RTREE_RECTER_PROC_CER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPEER_PROTOCOLER_UPSERT_UNIQUE_SECONDARY_KEYER_WRONG_INDEX_RECORDER_WRONG_INDEX_PARTSER_WRONG_INDEX_OPTIONSER_WRONG_SCHEMA_VERSIONER_MEMTX_MAX_TUPLE_SIZEER_WRONG_SPACE_OPTIONSER_UNSUPPORTED_INDEX_FEATUREER_VIEW_IS_ROER_NO_TRANSACTIONER_SYSTEMER_LOADINGER_CONNECTION_TO_SELFER_KEY_PART_IS_TOO_LONGER_COMPRESSIONER_CHECKPOINT_IN_PROGRESSER_SUB_STMT_MAXER_COMMIT_IN_SUB_STMTER_ROLLBACK_IN_SUB_STMTER_DECOMPRESSIONER_INVALID_XLOG_TYPEER_ALREADY_RUNNINGER_INDEX_FIELD_COUNT_LIMITER_LOCAL_INSTANCE_ID_IS_READ_ONLYER_BACKUP_IN_PROGRESSER_READ_VIEW_ABORTEDER_INVALID_INDEX_FILEER_INVALID_RUN_FILEER_INVALID_VYLOG_FILEER_CASCADE_ROLLBACKER_VY_QUOTA_TIMEOUTER_PARTIAL_KEYER_TRUNCATE_SYSTEM_SPACEER_LOAD_MODULEER_VINYL_MAX_TUPLE_SIZEER_WRONG_DD_VERSIONER_WRONG_SPACE_FORMATER_CREATE_SEQUENCEER_ALTER_SEQUENCEER_DROP_SEQUENCEER_NO_SUCH_SEQUENCEER_SEQUENCE_EXISTSER_SEQUENCE_OVERFLOWER_NO_SUCH_INDEX_NAMEER_SPACE_FIELD_IS_DUPLICATEER_CANT_CREATE_COLLATIONER_WRONG_COLLATION_OPTIONSER_NULLABLE_PRIMARYER_NO_SUCH_FIELD_NAME_IN_SPACEER_TRANSACTION_YIELDER_NO_SUCH_GROUPER_SQL_BIND_VALUEER_SQL_BIND_TYPEER_SQL_BIND_PARAMETER_MAXER_SQL_EXECUTEER_UPDATE_DECIMAL_OVERFLOWER_SQL_BIND_NOT_FOUNDER_ACTION_MISMATCHER_VIEW_MISSING_SQLER_FOREIGN_KEY_CONSTRAINTER_NO_SUCH_MODULEER_NO_SUCH_COLLATIONER_CREATE_FK_CONSTRAINTER_DROP_FK_CONSTRAINTER_NO_SUCH_CONSTRAINTER_CONSTRAINT_EXISTSER_SQL_TYPE_MISMATCHER_ROWID_OVERFLOWER_DROP_COLLATIONER_ILLEGAL_COLLATION_MIXER_SQL_NO_SUCH_PRAGMAER_SQL_CANT_RESOLVE_FIELDER_INDEX_EXISTS_IN_SPACEER_INCONSISTENT_TYPESER_SQL_SYNTAX_WITH_POSER_SQL_STACK_OVERFLOWER_SQL_SELECT_WILDCARDER_SQL_STATEMENT_EMPTYER_SQL_KEYWORD_IS_RESERVEDER_SQL_SYNTAX_NEAR_TOKENER_SQL_UNKNOWN_TOKENER_SQL_PARSER_GENERICER_SQL_ANALYZE_ARGUMENTER_SQL_COLUMN_COUNT_MAXER_HEX_LITERAL_MAXER_INT_LITERAL_MAXER_SQL_PARSER_LIMITER_INDEX_DEF_UNSUPPORTEDER_CK_DEF_UNSUPPORTEDER_MULTIKEY_INDEX_MISMATCHER_CREATE_CK_CONSTRAINTER_CK_CONSTRAINT_FAILEDER_SQL_COLUMN_COUNTER_FUNC_INDEX_FUNCER_FUNC_INDEX_FORMATER_FUNC_INDEX_PARTSER_NO_SUCH_FIELD_NAMEER_FUNC_WRONG_ARG_COUNTER_BOOTSTRAP_READONLYER_SQL_FUNC_WRONG_RET_COUNTER_FUNC_INVALID_RETURN_TYPEER_SQL_PARSER_GENERIC_WITH_POSER_REPLICA_NOT_ANONER_CANNOT_REGISTERER_SESSION_SETTING_INVALID_VALUEER_SQL_PREPAREER_WRONG_QUERY_IDER_SEQUENCE_NOT_STARTEDER_NO_SUCH_SESSION_SETTINGER_UNCOMMITTED_FOREIGN_SYNC_TXNSER_SYNC_MASTER_MISMATCHER_SYNC_QUORUM_TIMEOUTER_SYNC_ROLLBACKER_TUPLE_METADATA_IS_TOO_BIGER_XLOG_GAPER_TOO_EARLY_SUBSCRIBEER_SQL_CANT_ADD_AUTOINCER_QUORUM_WAITER_INTERFERING_PROMOTEER_ELECTION_DISABLEDER_TXN_ROLLBACKER_NOT_LEADERER_SYNC_QUEUE_UNCLAIMEDER_SYNC_QUEUE_FOREIGNER_UNABLE_TO_PROCESS_IN_STREAMER_UNABLE_TO_PROCESS_OUT_OF_STREAMER_TRANSACTION_TIMEOUTER_ACTIVE_TIMERER_TUPLE_FIELD_COUNT_LIMITER_CREATE_CONSTRAINTER_FIELD_CONSTRAINT_FAILEDER_TUPLE_CONSTRAINT_FAILEDER_CREATE_FOREIGN_KEYER_FOREIGN_KEY_INTEGRITYER_FIELD_FOREIGN_KEY_FAILEDER_COMPLEX_FOREIGN_KEY_FAILEDER_WRONG_SPACE_UPGRADE_OPTIONSER_NO_ELECTION_QUORUMER_SSLER_SPLIT_BRAINER_OLD_TERMER_INTERFERING_ELECTIONSER_ITERATOR_POSITIONER_UNUSEDER_UNKNOWN_AUTH_METHODER_INVALID_AUTH_DATAER_INVALID_AUTH_REQUESTER_WEAK_PASSWORDER_OLD_PASSWORDER_NO_SUCH_SESSIONER_WRONG_SESSION_TYPEER_PASSWORD_EXPIREDER_AUTH_DELAYER_AUTH_REQUIREDER_SQL_SEQ_SCANER_NO_SUCH_EVENTER_BOOTSTRAP_NOT_UNANIMOUSER_CANT_CHECK_BOOTSTRAP_LEADERER_BOOTSTRAP_CONNECTION_NOT_TO_ALLER_NIL_UUIDER_WRONG_FUNCTION_OPTIONSER_MISSING_SYSTEM_SPACES" +const _Error_name = "ER_UNKNOWNER_ILLEGAL_PARAMSER_MEMORY_ISSUEER_TUPLE_FOUNDER_TUPLE_NOT_FOUNDER_UNSUPPORTEDER_NONMASTERER_READONLYER_INJECTIONER_CREATE_SPACEER_SPACE_EXISTSER_DROP_SPACEER_ALTER_SPACEER_INDEX_TYPEER_MODIFY_INDEXER_LAST_DROPER_TUPLE_FORMAT_LIMITER_DROP_PRIMARY_KEYER_KEY_PART_TYPEER_EXACT_MATCHER_INVALID_MSGPACKER_PROC_RETER_TUPLE_NOT_ARRAYER_FIELD_TYPEER_INDEX_PART_TYPE_MISMATCHER_UPDATE_SPLICEER_UPDATE_ARG_TYPEER_FORMAT_MISMATCH_INDEX_PARTER_UNKNOWN_UPDATE_OPER_UPDATE_FIELDER_FUNCTION_TX_ACTIVEER_KEY_PART_COUNTER_PROC_LUAER_NO_SUCH_PROCER_NO_SUCH_TRIGGERER_NO_SUCH_INDEX_IDER_NO_SUCH_SPACEER_NO_SUCH_FIELD_NOER_EXACT_FIELD_COUNTER_FIELD_MISSINGER_WAL_IOER_MORE_THAN_ONE_TUPLEER_ACCESS_DENIEDER_CREATE_USERER_DROP_USERER_NO_SUCH_USERER_USER_EXISTSER_CREDS_MISMATCHER_UNKNOWN_REQUEST_TYPEER_UNKNOWN_SCHEMA_OBJECTER_CREATE_FUNCTIONER_NO_SUCH_FUNCTIONER_FUNCTION_EXISTSER_BEFORE_REPLACE_RETER_MULTISTATEMENT_TRANSACTIONER_TRIGGER_EXISTSER_USER_MAXER_NO_SUCH_ENGINEER_RELOAD_CFGER_CFGER_SAVEPOINT_EMPTY_TXER_NO_SUCH_SAVEPOINTER_UNKNOWN_REPLICAER_REPLICASET_UUID_MISMATCHER_INVALID_UUIDER_REPLICASET_UUID_IS_ROER_INSTANCE_UUID_MISMATCHER_REPLICA_ID_IS_RESERVEDER_INVALID_ORDERER_MISSING_REQUEST_FIELDER_IDENTIFIERER_DROP_FUNCTIONER_ITERATOR_TYPEER_REPLICA_MAXER_INVALID_XLOGER_INVALID_XLOG_NAMEER_INVALID_XLOG_ORDERER_NO_CONNECTIONER_TIMEOUTER_ACTIVE_TRANSACTIONER_CURSOR_NO_TRANSACTIONER_CROSS_ENGINE_TRANSACTIONER_NO_SUCH_ROLEER_ROLE_EXISTSER_CREATE_ROLEER_INDEX_EXISTSER_SESSION_CLOSEDER_ROLE_LOOPER_GRANTER_PRIV_GRANTEDER_ROLE_GRANTEDER_PRIV_NOT_GRANTEDER_ROLE_NOT_GRANTEDER_MISSING_SNAPSHOTER_CANT_UPDATE_PRIMARY_KEYER_UPDATE_INTEGER_OVERFLOWER_GUEST_USER_PASSWORDER_TRANSACTION_CONFLICTER_UNSUPPORTED_PRIVER_LOAD_FUNCTIONER_FUNCTION_LANGUAGEER_RTREE_RECTER_PROC_CER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPEER_PROTOCOLER_UPSERT_UNIQUE_SECONDARY_KEYER_WRONG_INDEX_RECORDER_WRONG_INDEX_PARTSER_WRONG_INDEX_OPTIONSER_WRONG_SCHEMA_VERSIONER_MEMTX_MAX_TUPLE_SIZEER_WRONG_SPACE_OPTIONSER_UNSUPPORTED_INDEX_FEATUREER_VIEW_IS_ROER_NO_TRANSACTIONER_SYSTEMER_LOADINGER_CONNECTION_TO_SELFER_KEY_PART_IS_TOO_LONGER_COMPRESSIONER_CHECKPOINT_IN_PROGRESSER_SUB_STMT_MAXER_COMMIT_IN_SUB_STMTER_ROLLBACK_IN_SUB_STMTER_DECOMPRESSIONER_INVALID_XLOG_TYPEER_ALREADY_RUNNINGER_INDEX_FIELD_COUNT_LIMITER_LOCAL_INSTANCE_ID_IS_READ_ONLYER_BACKUP_IN_PROGRESSER_READ_VIEW_ABORTEDER_INVALID_INDEX_FILEER_INVALID_RUN_FILEER_INVALID_VYLOG_FILEER_CASCADE_ROLLBACKER_VY_QUOTA_TIMEOUTER_PARTIAL_KEYER_TRUNCATE_SYSTEM_SPACEER_LOAD_MODULEER_VINYL_MAX_TUPLE_SIZEER_WRONG_DD_VERSIONER_WRONG_SPACE_FORMATER_CREATE_SEQUENCEER_ALTER_SEQUENCEER_DROP_SEQUENCEER_NO_SUCH_SEQUENCEER_SEQUENCE_EXISTSER_SEQUENCE_OVERFLOWER_NO_SUCH_INDEX_NAMEER_SPACE_FIELD_IS_DUPLICATEER_CANT_CREATE_COLLATIONER_WRONG_COLLATION_OPTIONSER_NULLABLE_PRIMARYER_NO_SUCH_FIELD_NAME_IN_SPACEER_TRANSACTION_YIELDER_NO_SUCH_GROUPER_SQL_BIND_VALUEER_SQL_BIND_TYPEER_SQL_BIND_PARAMETER_MAXER_SQL_EXECUTEER_UPDATE_DECIMAL_OVERFLOWER_SQL_BIND_NOT_FOUNDER_ACTION_MISMATCHER_VIEW_MISSING_SQLER_FOREIGN_KEY_CONSTRAINTER_NO_SUCH_MODULEER_NO_SUCH_COLLATIONER_CREATE_FK_CONSTRAINTER_DROP_FK_CONSTRAINTER_NO_SUCH_CONSTRAINTER_CONSTRAINT_EXISTSER_SQL_TYPE_MISMATCHER_ROWID_OVERFLOWER_DROP_COLLATIONER_ILLEGAL_COLLATION_MIXER_SQL_NO_SUCH_PRAGMAER_SQL_CANT_RESOLVE_FIELDER_INDEX_EXISTS_IN_SPACEER_INCONSISTENT_TYPESER_SQL_SYNTAX_WITH_POSER_SQL_STACK_OVERFLOWER_SQL_SELECT_WILDCARDER_SQL_STATEMENT_EMPTYER_SQL_KEYWORD_IS_RESERVEDER_SQL_SYNTAX_NEAR_TOKENER_SQL_UNKNOWN_TOKENER_SQL_PARSER_GENERICER_SQL_ANALYZE_ARGUMENTER_SQL_COLUMN_COUNT_MAXER_HEX_LITERAL_MAXER_INT_LITERAL_MAXER_SQL_PARSER_LIMITER_INDEX_DEF_UNSUPPORTEDER_CK_DEF_UNSUPPORTEDER_MULTIKEY_INDEX_MISMATCHER_CREATE_CK_CONSTRAINTER_CK_CONSTRAINT_FAILEDER_SQL_COLUMN_COUNTER_FUNC_INDEX_FUNCER_FUNC_INDEX_FORMATER_FUNC_INDEX_PARTSER_NO_SUCH_FIELD_NAMEER_FUNC_WRONG_ARG_COUNTER_BOOTSTRAP_READONLYER_SQL_FUNC_WRONG_RET_COUNTER_FUNC_INVALID_RETURN_TYPEER_SQL_PARSER_GENERIC_WITH_POSER_REPLICA_NOT_ANONER_CANNOT_REGISTERER_SESSION_SETTING_INVALID_VALUEER_SQL_PREPAREER_WRONG_QUERY_IDER_SEQUENCE_NOT_STARTEDER_NO_SUCH_SESSION_SETTINGER_UNCOMMITTED_FOREIGN_SYNC_TXNSER_SYNC_MASTER_MISMATCHER_SYNC_QUORUM_TIMEOUTER_SYNC_ROLLBACKER_TUPLE_METADATA_IS_TOO_BIGER_XLOG_GAPER_TOO_EARLY_SUBSCRIBEER_SQL_CANT_ADD_AUTOINCER_QUORUM_WAITER_INTERFERING_PROMOTEER_ELECTION_DISABLEDER_TXN_ROLLBACKER_NOT_LEADERER_SYNC_QUEUE_UNCLAIMEDER_SYNC_QUEUE_FOREIGNER_UNABLE_TO_PROCESS_IN_STREAMER_UNABLE_TO_PROCESS_OUT_OF_STREAMER_TRANSACTION_TIMEOUTER_ACTIVE_TIMERER_TUPLE_FIELD_COUNT_LIMITER_CREATE_CONSTRAINTER_FIELD_CONSTRAINT_FAILEDER_TUPLE_CONSTRAINT_FAILEDER_CREATE_FOREIGN_KEYER_FOREIGN_KEY_INTEGRITYER_FIELD_FOREIGN_KEY_FAILEDER_COMPLEX_FOREIGN_KEY_FAILEDER_WRONG_SPACE_UPGRADE_OPTIONSER_NO_ELECTION_QUORUMER_SSLER_SPLIT_BRAINER_OLD_TERMER_INTERFERING_ELECTIONSER_ITERATOR_POSITIONER_DEFAULT_VALUE_TYPEER_UNKNOWN_AUTH_METHODER_INVALID_AUTH_DATAER_INVALID_AUTH_REQUESTER_WEAK_PASSWORDER_OLD_PASSWORDER_NO_SUCH_SESSIONER_WRONG_SESSION_TYPEER_PASSWORD_EXPIREDER_AUTH_DELAYER_AUTH_REQUIREDER_SQL_SEQ_SCANER_NO_SUCH_EVENTER_BOOTSTRAP_NOT_UNANIMOUSER_CANT_CHECK_BOOTSTRAP_LEADERER_BOOTSTRAP_CONNECTION_NOT_TO_ALLER_NIL_UUIDER_WRONG_FUNCTION_OPTIONSER_MISSING_SYSTEM_SPACESER_CLUSTER_NAME_MISMATCHER_REPLICASET_NAME_MISMATCHER_INSTANCE_NAME_DUPLICATEER_INSTANCE_NAME_MISMATCHER_SCHEMA_NEEDS_UPGRADEER_SCHEMA_UPGRADE_IN_PROGRESSER_DEPRECATEDER_UNCONFIGUREDER_CREATE_DEFAULT_FUNCER_DEFAULT_FUNC_FAILED" -var _Error_index = [...]uint16{0, 10, 27, 42, 56, 74, 88, 100, 111, 123, 138, 153, 166, 180, 193, 208, 220, 241, 260, 276, 290, 308, 319, 337, 350, 377, 393, 411, 440, 460, 475, 496, 513, 524, 539, 557, 576, 592, 611, 631, 647, 656, 678, 694, 708, 720, 735, 749, 766, 789, 813, 831, 850, 868, 889, 918, 935, 946, 963, 976, 982, 1003, 1023, 1041, 1068, 1083, 1107, 1132, 1157, 1173, 1197, 1210, 1226, 1242, 1256, 1271, 1291, 1312, 1328, 1338, 1359, 1383, 1410, 1425, 1439, 1453, 1468, 1485, 1497, 1505, 1520, 1535, 1554, 1573, 1592, 1618, 1644, 1666, 1689, 1708, 1724, 1744, 1757, 1766, 1802, 1813, 1843, 1864, 1884, 1906, 1929, 1952, 1974, 2002, 2015, 2032, 2041, 2051, 2072, 2095, 2109, 2134, 2149, 2170, 2193, 2209, 2229, 2247, 2273, 2306, 2327, 2347, 2368, 2387, 2408, 2427, 2446, 2460, 2484, 2498, 2521, 2540, 2561, 2579, 2596, 2612, 2631, 2649, 2669, 2690, 2717, 2741, 2767, 2786, 2816, 2836, 2852, 2869, 2885, 2910, 2924, 2950, 2971, 2989, 3008, 3033, 3050, 3070, 3093, 3114, 3135, 3155, 3175, 3192, 3209, 3233, 3254, 3279, 3303, 3324, 3346, 3367, 3389, 3411, 3437, 3461, 3481, 3502, 3525, 3548, 3566, 3584, 3603, 3627, 3648, 3674, 3697, 3720, 3739, 3757, 3777, 3796, 3817, 3840, 3861, 3888, 3915, 3945, 3964, 3982, 4014, 4028, 4045, 4068, 4094, 4126, 4149, 4171, 4187, 4215, 4226, 4248, 4271, 4285, 4307, 4327, 4342, 4355, 4378, 4399, 4429, 4463, 4485, 4500, 4526, 4546, 4572, 4598, 4619, 4643, 4670, 4699, 4729, 4750, 4756, 4770, 4781, 4805, 4825, 4834, 4856, 4876, 4899, 4915, 4930, 4948, 4969, 4988, 5001, 5017, 5032, 5048, 5074, 5104, 5138, 5149, 5174, 5198} +var _Error_index = [...]uint16{0, 10, 27, 42, 56, 74, 88, 100, 111, 123, 138, 153, 166, 180, 193, 208, 220, 241, 260, 276, 290, 308, 319, 337, 350, 377, 393, 411, 440, 460, 475, 496, 513, 524, 539, 557, 576, 592, 611, 631, 647, 656, 678, 694, 708, 720, 735, 749, 766, 789, 813, 831, 850, 868, 889, 918, 935, 946, 963, 976, 982, 1003, 1023, 1041, 1068, 1083, 1107, 1132, 1157, 1173, 1197, 1210, 1226, 1242, 1256, 1271, 1291, 1312, 1328, 1338, 1359, 1383, 1410, 1425, 1439, 1453, 1468, 1485, 1497, 1505, 1520, 1535, 1554, 1573, 1592, 1618, 1644, 1666, 1689, 1708, 1724, 1744, 1757, 1766, 1802, 1813, 1843, 1864, 1884, 1906, 1929, 1952, 1974, 2002, 2015, 2032, 2041, 2051, 2072, 2095, 2109, 2134, 2149, 2170, 2193, 2209, 2229, 2247, 2273, 2306, 2327, 2347, 2368, 2387, 2408, 2427, 2446, 2460, 2484, 2498, 2521, 2540, 2561, 2579, 2596, 2612, 2631, 2649, 2669, 2690, 2717, 2741, 2767, 2786, 2816, 2836, 2852, 2869, 2885, 2910, 2924, 2950, 2971, 2989, 3008, 3033, 3050, 3070, 3093, 3114, 3135, 3155, 3175, 3192, 3209, 3233, 3254, 3279, 3303, 3324, 3346, 3367, 3389, 3411, 3437, 3461, 3481, 3502, 3525, 3548, 3566, 3584, 3603, 3627, 3648, 3674, 3697, 3720, 3739, 3757, 3777, 3796, 3817, 3840, 3861, 3888, 3915, 3945, 3964, 3982, 4014, 4028, 4045, 4068, 4094, 4126, 4149, 4171, 4187, 4215, 4226, 4248, 4271, 4285, 4307, 4327, 4342, 4355, 4378, 4399, 4429, 4463, 4485, 4500, 4526, 4546, 4572, 4598, 4619, 4643, 4670, 4699, 4729, 4750, 4756, 4770, 4781, 4805, 4825, 4846, 4868, 4888, 4911, 4927, 4942, 4960, 4981, 5000, 5013, 5029, 5044, 5060, 5086, 5116, 5150, 5161, 5186, 5210, 5234, 5261, 5287, 5312, 5335, 5364, 5377, 5392, 5414, 5436} func (i Error) String() string { if i < 0 || i >= Error(len(_Error_index)-1) { diff --git a/error_test.go b/error_test.go index f974e94..718d541 100644 --- a/error_test.go +++ b/error_test.go @@ -261,7 +261,7 @@ func TestError(t *testing.T) { {iproto.ER_OLD_TERM, "ER_OLD_TERM"}, {iproto.ER_INTERFERING_ELECTIONS, "ER_INTERFERING_ELECTIONS"}, {iproto.ER_ITERATOR_POSITION, "ER_ITERATOR_POSITION"}, - {iproto.ER_UNUSED, "ER_UNUSED"}, + {iproto.ER_DEFAULT_VALUE_TYPE, "ER_DEFAULT_VALUE_TYPE"}, {iproto.ER_UNKNOWN_AUTH_METHOD, "ER_UNKNOWN_AUTH_METHOD"}, {iproto.ER_INVALID_AUTH_DATA, "ER_INVALID_AUTH_DATA"}, {iproto.ER_INVALID_AUTH_REQUEST, "ER_INVALID_AUTH_REQUEST"}, @@ -280,6 +280,16 @@ func TestError(t *testing.T) { {iproto.ER_NIL_UUID, "ER_NIL_UUID"}, {iproto.ER_WRONG_FUNCTION_OPTIONS, "ER_WRONG_FUNCTION_OPTIONS"}, {iproto.ER_MISSING_SYSTEM_SPACES, "ER_MISSING_SYSTEM_SPACES"}, + {iproto.ER_CLUSTER_NAME_MISMATCH, "ER_CLUSTER_NAME_MISMATCH"}, + {iproto.ER_REPLICASET_NAME_MISMATCH, "ER_REPLICASET_NAME_MISMATCH"}, + {iproto.ER_INSTANCE_NAME_DUPLICATE, "ER_INSTANCE_NAME_DUPLICATE"}, + {iproto.ER_INSTANCE_NAME_MISMATCH, "ER_INSTANCE_NAME_MISMATCH"}, + {iproto.ER_SCHEMA_NEEDS_UPGRADE, "ER_SCHEMA_NEEDS_UPGRADE"}, + {iproto.ER_SCHEMA_UPGRADE_IN_PROGRESS, "ER_SCHEMA_UPGRADE_IN_PROGRESS"}, + {iproto.ER_DEPRECATED, "ER_DEPRECATED"}, + {iproto.ER_UNCONFIGURED, "ER_UNCONFIGURED"}, + {iproto.ER_CREATE_DEFAULT_FUNC, "ER_CREATE_DEFAULT_FUNC"}, + {iproto.ER_DEFAULT_FUNC_FAILED, "ER_DEFAULT_FUNC_FAILED"}, } for i, tc := range cases { diff --git a/feature.go b/feature.go index aba2b03..d845459 100644 --- a/feature.go +++ b/feature.go @@ -29,4 +29,12 @@ const ( // IPROTO_AFTER_POSITION, IPROTO_AFTER_TUPLE, IPROTO_FETCH_POSITION // request fields and IPROTO_POSITION response field. IPROTO_FEATURE_PAGINATION Feature = 4 + // Using space [index] names instead of identifiers support: + // IPROTO_SPACE_NAME and IPROTO_INDEX_NAME fields in IPROTO_SELECT, + // IPROTO_UPDATE and IPROTO_DELETE request body; + // IPROTO_SPACE_NAME field in IPROTO_INSERT, IPROTO_REPLACE, + // IPROTO_UPDATE and IPROTO_UPSERT request body. + IPROTO_FEATURE_SPACE_AND_INDEX_NAMES Feature = 5 + // IPROTO_WATCH_ONCE request support. + IPROTO_FEATURE_WATCH_ONCE Feature = 6 ) diff --git a/feature_string.go b/feature_string.go index e844fd7..cde1359 100644 --- a/feature_string.go +++ b/feature_string.go @@ -13,11 +13,13 @@ func _() { _ = x[IPROTO_FEATURE_ERROR_EXTENSION-2] _ = x[IPROTO_FEATURE_WATCHERS-3] _ = x[IPROTO_FEATURE_PAGINATION-4] + _ = x[IPROTO_FEATURE_SPACE_AND_INDEX_NAMES-5] + _ = x[IPROTO_FEATURE_WATCH_ONCE-6] } -const _Feature_name = "IPROTO_FEATURE_STREAMSIPROTO_FEATURE_TRANSACTIONSIPROTO_FEATURE_ERROR_EXTENSIONIPROTO_FEATURE_WATCHERSIPROTO_FEATURE_PAGINATION" +const _Feature_name = "IPROTO_FEATURE_STREAMSIPROTO_FEATURE_TRANSACTIONSIPROTO_FEATURE_ERROR_EXTENSIONIPROTO_FEATURE_WATCHERSIPROTO_FEATURE_PAGINATIONIPROTO_FEATURE_SPACE_AND_INDEX_NAMESIPROTO_FEATURE_WATCH_ONCE" -var _Feature_index = [...]uint8{0, 22, 49, 79, 102, 127} +var _Feature_index = [...]uint8{0, 22, 49, 79, 102, 127, 163, 188} func (i Feature) String() string { if i < 0 || i >= Feature(len(_Feature_index)-1) { diff --git a/feature_test.go b/feature_test.go index c136a88..a6d03a6 100644 --- a/feature_test.go +++ b/feature_test.go @@ -20,6 +20,8 @@ func TestFeature(t *testing.T) { {iproto.IPROTO_FEATURE_ERROR_EXTENSION, "IPROTO_FEATURE_ERROR_EXTENSION", 2}, {iproto.IPROTO_FEATURE_WATCHERS, "IPROTO_FEATURE_WATCHERS", 3}, {iproto.IPROTO_FEATURE_PAGINATION, "IPROTO_FEATURE_PAGINATION", 4}, + {iproto.IPROTO_FEATURE_SPACE_AND_INDEX_NAMES, "IPROTO_FEATURE_SPACE_AND_INDEX_NAMES", 5}, + {iproto.IPROTO_FEATURE_WATCH_ONCE, "IPROTO_FEATURE_WATCH_ONCE", 6}, } for _, tc := range cases { diff --git a/flag.go b/flag.go index b071a38..46a7ee9 100644 --- a/flag.go +++ b/flag.go @@ -8,9 +8,9 @@ type Flag int const ( // Set for the last xrow in a transaction. - IPROTO_FLAG_COMMIT Flag = 0x01 + IPROTO_FLAG_COMMIT Flag = 1 << 0 // Set for the last row of a tx residing in limbo. - IPROTO_FLAG_WAIT_SYNC Flag = 0x02 + IPROTO_FLAG_WAIT_SYNC Flag = 1 << 1 // Set for the last row of a synchronous tx. - IPROTO_FLAG_WAIT_ACK Flag = 0x04 + IPROTO_FLAG_WAIT_ACK Flag = 1 << 2 ) diff --git a/flag_test.go b/flag_test.go index 2feafa4..207dc8e 100644 --- a/flag_test.go +++ b/flag_test.go @@ -15,9 +15,9 @@ func TestFlag(t *testing.T) { Val int }{ - {iproto.IPROTO_FLAG_COMMIT, "IPROTO_FLAG_COMMIT", 0x01}, - {iproto.IPROTO_FLAG_WAIT_SYNC, "IPROTO_FLAG_WAIT_SYNC", 0x02}, - {iproto.IPROTO_FLAG_WAIT_ACK, "IPROTO_FLAG_WAIT_ACK", 0x04}, + {iproto.IPROTO_FLAG_COMMIT, "IPROTO_FLAG_COMMIT", 1 << 0}, + {iproto.IPROTO_FLAG_WAIT_SYNC, "IPROTO_FLAG_WAIT_SYNC", 1 << 1}, + {iproto.IPROTO_FLAG_WAIT_ACK, "IPROTO_FLAG_WAIT_ACK", 1 << 2}, } for _, tc := range cases { diff --git a/generate.sh b/generate.sh index 061b3f6..7625848 100755 --- a/generate.sh +++ b/generate.sh @@ -65,13 +65,88 @@ import ( " -# read_enum read C enum values. +# read_enum reads C enum values. # arg1 - enum name in C code. # arg2 - path to a C code. function read_enum { grep -Pzo "(?s)enum ${1} \{.+?\};" "${2}" | grep -aP "^\t" } +# read_define_prefix_name reads C name of the prefix for constants. +# arg1 - name of the define with constants. +# arg2 - enum name in C code. +# arg3 - path to a C code. +function read_define_prefix_name { + read_enum $2 $3 | grep -oP "${1}\(.+?\)" | grep -oP "\(.+?\)" | \ + # Delete first and last symbols from the string ("(" and ")" respectively). + sed "s/^.//;s/.$//" +} + +# read_define reads C constants from define. +# arg1 - name of the define with constants. +# arg2 - path to a C code. +function read_define { + sed -n "/#define ${1}/,/^$/p" "${2}" +} + +# read_prefix reads prefix for constants from define. +# arg1 - name of the define, containing the prefix. +# arg2 - path to a C code. +function read_prefix { + read_define $1 $2 | grep -oP "\) .+?#" | \ + # Delete first and last symbols from string (")" and "#" respectively). + # Trim spaces. + awk '{$0=substr($0, 2, length($0) - 2); $1=$1};1' +} + +# read_define_with_prefix reads all constants from enum (including the ones, that +# will be generated by macros). Also reads comments. +# arg1 - name of the define with constants. +# arg2 - enum name in C code. +# arg3 - path to a C code. +function read_define_with_prefix { + prefix_define_name=$(read_define_prefix_name $1 $2 $3) + full_prefix_define=$(read_define $prefix_define_name $3) + prefix=$(read_prefix $prefix_define_name $3) + double_value_string=$(echo $full_prefix_define | \ + # If there is a raising 2 to the power of each constant (that specified in + # the define), we need to place a "1 << " string before each constant + # value. Otherwise, we will place nothing. + grep -oP "<<" | sed 's/^/ 1 /' || echo "") + enum_constants=$(read_enum $2 $3 | \ + # Get all constants from the enum (they are not in define) with + # their comments. + grep -Pzo "[\n]?[\t ]*(\/\*)((.|\n)+?)(\*\/)\n[\t ]*[A-Z0-9_]+[\t ]+=[\t ]+[\-0-9 <]+[\-xa-f]*," | \ + # If there are no such comments, that means grep returned error. + # Otherwise, we need to delete extra backslash from the end of each line. + sed '$!s/$/\\/' || echo "\\") + + read_define $1 $3 | grep -aP "^\t" | \ + # Mark the start of each constant (to replace extra "_(" with the prefix). + # Mark the end of each constants value (to delete anything after it). + sed -r "s/(_\()[A-Z0-9_]+[\t ,]+[\t ]+([0-9]+[\-xa-f]*)*/#&#/g" | \ + # Mark a comma between constant and its assigned value + # (to replace it with the "="). + sed -r "s/(_\()[A-Z0-9_]+,/&#/g" | \ + # Replace marked start with the prefix. + sed -r "s/#_\(/$prefix/g" | \ + # Delete anything after a constant value (there are two cases). + sed -r "s/#,.*$//g" | \ + sed -r "s/#\).*$//g" | \ + # Replace marked comma with the "=". + sed -r "s/,#/ =/g" | \ + # Delete backslash at the end of each line. + sed -r 's/\\//g' | \ + # Change constants value to the power of two if needed. + sed -r "s/[ ]+[0-9]+/$double_value_string&/g" | \ + # Add the remaining constants from the enum. + sed "\$a$enum_constants" | \ + # Trim trailing whitespaces. + sed "s/[ \t]*$//g" | \ + # Delete empty lines. + sed -r '/^\s*$/d' +} + # generate_enum generates a Golang style enum from a C enum. # arg1 - enum name in Golang. function generate_enum { @@ -108,8 +183,9 @@ echo "func Test${1}(t *testing.T) { } { " -grep -oP "[\t ]+[A-Z0-9_]+[\t ]+=[\t ]+[\-0-9xa-f <]+" | \ - awk '{val=$1;$1=$2="";printf("\t\t{iproto.%s, \"%s\",%s},\n", val, val, $0)}' +grep -oP "^[\t ]*[A-Z0-9_]+[\t ]+=[\t ]+[A-Z_]*[\-0-9xa-f <\+]+" | \ + awk '{val=$1;$1=$2="";gsub(/[A-Z][A-Z0-9_]+/,"int(iproto.&)",$0); + printf("\t\t{iproto.%s, \"%s\",%s},\n", val, val, $0)}' echo " } @@ -213,12 +289,12 @@ cat << EOF >> ${DST_FEATURES} // ${SRC_FEATURES} EOF -read_enum iproto_feature_id ${SRC_FEATURES} | \ +read_define_with_prefix IPROTO_FEATURES iproto_feature_id ${SRC_FEATURES} | \ generate_enum Feature >> ${DST_FEATURES} echo "${FOOTER_TEST}" > ${DST_FEATURES_TEST} -read_enum iproto_feature_id ${SRC_FEATURES} | \ +read_define_with_prefix IPROTO_FEATURES iproto_feature_id ${SRC_FEATURES} | \ generate_test Feature >> ${DST_FEATURES_TEST} # @@ -231,12 +307,12 @@ cat << EOF >> ${DST_FLAGS} // ${SRC_CONST} EOF -grep -PB 1 "[\t ]*IPROTO_FLAG_[A-Z_]+ =" ${SRC_CONST} | \ +read_define_with_prefix IPROTO_FLAGS iproto_flag ${SRC_CONST} | \ generate_enum Flag >> ${DST_FLAGS} echo "${FOOTER_TEST}" > ${DST_FLAGS_TEST} -grep -PB 1 "[\t ]*IPROTO_FLAG_[A-Z_]+ =" ${SRC_CONST} | \ +read_define_with_prefix IPROTO_FLAGS iproto_flag ${SRC_CONST} | \ generate_test Flag >> ${DST_FLAGS_TEST} # @@ -267,12 +343,12 @@ cat << EOF >> ${DST_TYPES} // ${SRC_CONST} EOF -read_enum iproto_type ${SRC_CONST} | \ +read_define_with_prefix IPROTO_TYPES iproto_type ${SRC_CONST} | \ generate_enum Type >> ${DST_TYPES} echo "${FOOTER_TEST}" > ${DST_TYPES_TEST} -read_enum iproto_type ${SRC_CONST} | \ +read_define_with_prefix IPROTO_TYPES iproto_type ${SRC_CONST} | \ generate_test Type >> ${DST_TYPES_TEST} # @@ -285,7 +361,7 @@ cat << EOF >> ${DST_KEYS} // ${SRC_CONST} EOF -read_enum iproto_key ${SRC_CONST} | \ +read_define_with_prefix IPROTO_KEYS iproto_key ${SRC_CONST} | \ generate_enum Key >> ${DST_KEYS} cat << EOF >> ${DST_KEYS} @@ -294,7 +370,7 @@ cat << EOF >> ${DST_KEYS} // ${SRC_CONST} EOF -read_enum iproto_metadata_key ${SRC_CONST} | \ +read_define_with_prefix IPROTO_METADATA_KEYS iproto_metadata_key ${SRC_CONST} | \ generate_enum MetadataKey >> ${DST_KEYS} cat << EOF >> ${DST_KEYS} @@ -303,7 +379,7 @@ cat << EOF >> ${DST_KEYS} // ${SRC_CONST} EOF -read_enum iproto_ballot_key ${SRC_CONST} | \ +read_define_with_prefix IPROTO_BALLOT_KEYS iproto_ballot_key ${SRC_CONST} | \ generate_enum BallotKey >> ${DST_KEYS} cat << EOF >> ${DST_KEYS} @@ -312,7 +388,7 @@ cat << EOF >> ${DST_KEYS} // ${SRC_CONST} EOF -read_enum iproto_raft_keys ${SRC_CONST} | \ +read_define_with_prefix IPROTO_RAFT_KEYS iproto_raft_key ${SRC_CONST} | \ generate_enum RaftKey >> ${DST_KEYS} cat << EOF >> ${DST_KEYS} @@ -326,16 +402,16 @@ read_enum sql_info_key ${SRC_EXECUTE} | \ echo "${FOOTER_TEST}" > ${DST_KEYS_TEST} -read_enum iproto_key ${SRC_CONST} | \ +read_define_with_prefix IPROTO_KEYS iproto_key ${SRC_CONST} | \ generate_test Key >> ${DST_KEYS_TEST} -read_enum iproto_metadata_key ${SRC_CONST} | \ +read_define_with_prefix IPROTO_METADATA_KEYS iproto_metadata_key ${SRC_CONST} | \ generate_test MetadataKey >> ${DST_KEYS_TEST} -read_enum iproto_ballot_key ${SRC_CONST} | \ +read_define_with_prefix IPROTO_BALLOT_KEYS iproto_ballot_key ${SRC_CONST} | \ generate_test BallotKey >> ${DST_KEYS_TEST} -read_enum iproto_raft_keys ${SRC_CONST} | \ +read_define_with_prefix IPROTO_RAFT_KEYS iproto_raft_key ${SRC_CONST} | \ generate_test RaftKey >> ${DST_KEYS_TEST} read_enum sql_info_key ${SRC_EXECUTE} | \ diff --git a/keys.go b/keys.go index a23faf8..ab2be70 100644 --- a/keys.go +++ b/keys.go @@ -43,8 +43,9 @@ const ( IPROTO_REPLICASET_UUID Key = 0x25 IPROTO_VCLOCK Key = 0x26 // Also request keys. See the comment above. - IPROTO_EXPR Key = 0x27 // EVAL - IPROTO_OPS Key = 0x28 // UPSERT but not UPDATE ops, because of legacy + IPROTO_EXPR Key = 0x27 + // UPSERT but not UPDATE ops, because of legacy + IPROTO_OPS Key = 0x28 IPROTO_BALLOT Key = 0x29 IPROTO_TUPLE_META Key = 0x2a IPROTO_OPTIONS Key = 0x2b @@ -73,7 +74,7 @@ const ( IPROTO_SQL_TEXT Key = 0x40 IPROTO_SQL_BIND Key = 0x41 // IPROTO_SQL_INFO: { - // SQL_INFO_ROW_COUNT: number + // SQL_INFO_ROW_COUNT: number // } IPROTO_SQL_INFO Key = 0x42 IPROTO_STMT_ID Key = 0x43 @@ -102,11 +103,17 @@ const ( // the server (value of box.cfg.auth_type). It's sent in reply // to IPROTO_ID request. A client can use it as the default // authentication method. - IPROTO_AUTH_TYPE Key = 0x5b - // Be careful to not extend iproto_key values over 0x7f. - // iproto_keys are encoded in msgpack as positive fixnum, which ends at - // 0x7f, and we rely on this in some places by allocating a uint8_t to - // hold a msgpack-encoded key value. + IPROTO_AUTH_TYPE Key = 0x5b + IPROTO_REPLICASET_NAME Key = 0x5c + IPROTO_INSTANCE_NAME Key = 0x5d + // Space name used instead of identifier (IPROTO_SPACE_ID) in DML + // requests. Preferred when identifier is present (i.e., the identifier + // is ignored). + IPROTO_SPACE_NAME Key = 0x5e + // Index name used instead of identifier (IPROTO_INDEX_ID) in + // IPROTO_SELECT, IPROTO_UPDATE, and IPROTO_DELETE requests. Preferred + // when identifier is present (i.e., the identifier is ignored). + IPROTO_INDEX_NAME Key = 0x5f ) // IPROTO metadata key constants, generated from @@ -136,6 +143,7 @@ const ( IPROTO_BALLOT_CAN_LEAD BallotKey = 0x07 IPROTO_BALLOT_BOOTSTRAP_LEADER_UUID BallotKey = 0x08 IPROTO_BALLOT_REGISTERED_REPLICA_UUIDS BallotKey = 0x09 + IPROTO_BALLOT_INSTANCE_NAME BallotKey = 0x0a ) // IPROTO raft key constants, generated from diff --git a/keys_string.go b/keys_string.go index 08fb31c..b69601c 100644 --- a/keys_string.go +++ b/keys_string.go @@ -64,6 +64,10 @@ func _() { _ = x[IPROTO_TXN_ISOLATION-89] _ = x[IPROTO_VCLOCK_SYNC-90] _ = x[IPROTO_AUTH_TYPE-91] + _ = x[IPROTO_REPLICASET_NAME-92] + _ = x[IPROTO_INSTANCE_NAME-93] + _ = x[IPROTO_SPACE_NAME-94] + _ = x[IPROTO_INDEX_NAME-95] } const ( @@ -71,7 +75,7 @@ const ( _Key_name_1 = "IPROTO_SPACE_IDIPROTO_INDEX_IDIPROTO_LIMITIPROTO_OFFSETIPROTO_ITERATORIPROTO_INDEX_BASE" _Key_name_2 = "IPROTO_FETCH_POSITIONIPROTO_KEYIPROTO_TUPLEIPROTO_FUNCTION_NAMEIPROTO_USER_NAMEIPROTO_INSTANCE_UUIDIPROTO_REPLICASET_UUIDIPROTO_VCLOCKIPROTO_EXPRIPROTO_OPSIPROTO_BALLOTIPROTO_TUPLE_METAIPROTO_OPTIONSIPROTO_OLD_TUPLEIPROTO_NEW_TUPLEIPROTO_AFTER_POSITIONIPROTO_AFTER_TUPLEIPROTO_DATAIPROTO_ERROR_24IPROTO_METADATAIPROTO_BIND_METADATAIPROTO_BIND_COUNTIPROTO_POSITION" _Key_name_3 = "IPROTO_SQL_TEXTIPROTO_SQL_BINDIPROTO_SQL_INFOIPROTO_STMT_ID" - _Key_name_4 = "IPROTO_REPLICA_ANONIPROTO_ID_FILTERIPROTO_ERRORIPROTO_TERMIPROTO_VERSIONIPROTO_FEATURESIPROTO_TIMEOUTIPROTO_EVENT_KEYIPROTO_EVENT_DATAIPROTO_TXN_ISOLATIONIPROTO_VCLOCK_SYNCIPROTO_AUTH_TYPE" + _Key_name_4 = "IPROTO_REPLICA_ANONIPROTO_ID_FILTERIPROTO_ERRORIPROTO_TERMIPROTO_VERSIONIPROTO_FEATURESIPROTO_TIMEOUTIPROTO_EVENT_KEYIPROTO_EVENT_DATAIPROTO_TXN_ISOLATIONIPROTO_VCLOCK_SYNCIPROTO_AUTH_TYPEIPROTO_REPLICASET_NAMEIPROTO_INSTANCE_NAMEIPROTO_SPACE_NAMEIPROTO_INDEX_NAME" ) var ( @@ -79,7 +83,7 @@ var ( _Key_index_1 = [...]uint8{0, 15, 30, 42, 55, 70, 87} _Key_index_2 = [...]uint16{0, 21, 31, 43, 63, 79, 99, 121, 134, 145, 155, 168, 185, 199, 215, 231, 252, 270, 281, 296, 311, 331, 348, 363} _Key_index_3 = [...]uint8{0, 15, 30, 45, 59} - _Key_index_4 = [...]uint8{0, 19, 35, 47, 58, 72, 87, 101, 117, 134, 154, 172, 188} + _Key_index_4 = [...]uint16{0, 19, 35, 47, 58, 72, 87, 101, 117, 134, 154, 172, 188, 210, 230, 247, 264} ) func (i Key) String() string { @@ -95,7 +99,7 @@ func (i Key) String() string { case 64 <= i && i <= 67: i -= 64 return _Key_name_3[_Key_index_3[i]:_Key_index_3[i+1]] - case 80 <= i && i <= 91: + case 80 <= i && i <= 95: i -= 80 return _Key_name_4[_Key_index_4[i]:_Key_index_4[i+1]] default: @@ -137,11 +141,12 @@ func _() { _ = x[IPROTO_BALLOT_CAN_LEAD-7] _ = x[IPROTO_BALLOT_BOOTSTRAP_LEADER_UUID-8] _ = x[IPROTO_BALLOT_REGISTERED_REPLICA_UUIDS-9] + _ = x[IPROTO_BALLOT_INSTANCE_NAME-10] } -const _BallotKey_name = "IPROTO_BALLOT_IS_RO_CFGIPROTO_BALLOT_VCLOCKIPROTO_BALLOT_GC_VCLOCKIPROTO_BALLOT_IS_ROIPROTO_BALLOT_IS_ANONIPROTO_BALLOT_IS_BOOTEDIPROTO_BALLOT_CAN_LEADIPROTO_BALLOT_BOOTSTRAP_LEADER_UUIDIPROTO_BALLOT_REGISTERED_REPLICA_UUIDS" +const _BallotKey_name = "IPROTO_BALLOT_IS_RO_CFGIPROTO_BALLOT_VCLOCKIPROTO_BALLOT_GC_VCLOCKIPROTO_BALLOT_IS_ROIPROTO_BALLOT_IS_ANONIPROTO_BALLOT_IS_BOOTEDIPROTO_BALLOT_CAN_LEADIPROTO_BALLOT_BOOTSTRAP_LEADER_UUIDIPROTO_BALLOT_REGISTERED_REPLICA_UUIDSIPROTO_BALLOT_INSTANCE_NAME" -var _BallotKey_index = [...]uint8{0, 23, 43, 66, 85, 106, 129, 151, 186, 224} +var _BallotKey_index = [...]uint8{0, 23, 43, 66, 85, 106, 129, 151, 186, 224, 251} func (i BallotKey) String() string { i -= 1 diff --git a/keys_test.go b/keys_test.go index 1c253a6..bd48a30 100644 --- a/keys_test.go +++ b/keys_test.go @@ -71,6 +71,10 @@ func TestKey(t *testing.T) { {iproto.IPROTO_TXN_ISOLATION, "IPROTO_TXN_ISOLATION", 0x59}, {iproto.IPROTO_VCLOCK_SYNC, "IPROTO_VCLOCK_SYNC", 0x5a}, {iproto.IPROTO_AUTH_TYPE, "IPROTO_AUTH_TYPE", 0x5b}, + {iproto.IPROTO_REPLICASET_NAME, "IPROTO_REPLICASET_NAME", 0x5c}, + {iproto.IPROTO_INSTANCE_NAME, "IPROTO_INSTANCE_NAME", 0x5d}, + {iproto.IPROTO_SPACE_NAME, "IPROTO_SPACE_NAME", 0x5e}, + {iproto.IPROTO_INDEX_NAME, "IPROTO_INDEX_NAME", 0x5f}, } for _, tc := range cases { @@ -128,6 +132,7 @@ func TestBallotKey(t *testing.T) { {iproto.IPROTO_BALLOT_CAN_LEAD, "IPROTO_BALLOT_CAN_LEAD", 0x07}, {iproto.IPROTO_BALLOT_BOOTSTRAP_LEADER_UUID, "IPROTO_BALLOT_BOOTSTRAP_LEADER_UUID", 0x08}, {iproto.IPROTO_BALLOT_REGISTERED_REPLICA_UUIDS, "IPROTO_BALLOT_REGISTERED_REPLICA_UUIDS", 0x09}, + {iproto.IPROTO_BALLOT_INSTANCE_NAME, "IPROTO_BALLOT_INSTANCE_NAME", 0x0a}, } for _, tc := range cases { diff --git a/type.go b/type.go index ff2c9b8..b676d5d 100644 --- a/type.go +++ b/type.go @@ -41,8 +41,7 @@ const ( IPROTO_COMMIT Type = 15 // Rollback transaction IPROTO_ROLLBACK Type = 16 - // The maximum typecode used for box.stat() - IPROTO_RAFT Type = 30 + IPROTO_RAFT Type = 30 // PROMOTE request. IPROTO_RAFT_PROMOTE Type = 31 // DEMOTE request. @@ -84,21 +83,32 @@ const ( // it unsubscribes by sending an IPROTO_UNWATCH packet. // // All the three request types are fully asynchronous - a receiving end - // doesn't send a packet in reply to any of them (therefore neither of - // them has a sync number). + // doesn't send a packet in reply to any of them. Still, the server + // sends the same sync number in an IPROTO_EVENT packet as the one sent + // by the client in the last corresponding IPROTO_WATCH request. IPROTO_WATCH Type = 74 IPROTO_UNWATCH Type = 75 IPROTO_EVENT Type = 76 + // Synchronous request to fetch the data that is currently attached to + // a notification key without subscribing to changes. + IPROTO_WATCH_ONCE Type = 77 + // The following three requests are reserved for vinyl types. + // + // VY_INDEX_RUN_INFO = 100 + // VY_INDEX_PAGE_INFO = 101 + // VY_RUN_ROW_INDEX = 102 + // Non-final response type. + IPROTO_CHUNK Type = 128 + // Error codes = (IPROTO_TYPE_ERROR | ER_XXX from errcode.h) + IPROTO_TYPE_ERROR Type = 1 << 15 + // Used for overriding the unknown request handler + IPROTO_UNKNOWN Type = -1 + // The maximum typecode used for box.stat() + IPROTO_TYPE_STAT_MAX Type = IPROTO_ROLLBACK + 1 // Vinyl run info stored in .index file VY_INDEX_RUN_INFO Type = 100 // Vinyl page info stored in .index file VY_INDEX_PAGE_INFO Type = 101 // Vinyl row index stored in .run file VY_RUN_ROW_INDEX Type = 102 - // Non-final response type. - IPROTO_CHUNK Type = 128 - // Error codes = (IPROTO_TYPE_ERROR | ER_XXX from errcode.h) - IPROTO_TYPE_ERROR Type = 1 << 15 - // Used for overriding the unknown request handler. - IPROTO_UNKNOWN Type = -1 ) diff --git a/type_string.go b/type_string.go index 4949a5a..b863c12 100644 --- a/type_string.go +++ b/type_string.go @@ -43,35 +43,37 @@ func _() { _ = x[IPROTO_WATCH-74] _ = x[IPROTO_UNWATCH-75] _ = x[IPROTO_EVENT-76] - _ = x[VY_INDEX_RUN_INFO-100] - _ = x[VY_INDEX_PAGE_INFO-101] - _ = x[VY_RUN_ROW_INDEX-102] + _ = x[IPROTO_WATCH_ONCE-77] _ = x[IPROTO_CHUNK-128] _ = x[IPROTO_TYPE_ERROR-32768] _ = x[IPROTO_UNKNOWN - -1] + _ = x[IPROTO_TYPE_STAT_MAX-17] + _ = x[VY_INDEX_RUN_INFO-100] + _ = x[VY_INDEX_PAGE_INFO-101] + _ = x[VY_RUN_ROW_INDEX-102] } const ( - _Type_name_0 = "IPROTO_UNKNOWNIPROTO_OKIPROTO_SELECTIPROTO_INSERTIPROTO_REPLACEIPROTO_UPDATEIPROTO_DELETEIPROTO_CALL_16IPROTO_AUTHIPROTO_EVALIPROTO_UPSERTIPROTO_CALLIPROTO_EXECUTEIPROTO_NOPIPROTO_PREPAREIPROTO_BEGINIPROTO_COMMITIPROTO_ROLLBACK" + _Type_name_0 = "IPROTO_UNKNOWNIPROTO_OKIPROTO_SELECTIPROTO_INSERTIPROTO_REPLACEIPROTO_UPDATEIPROTO_DELETEIPROTO_CALL_16IPROTO_AUTHIPROTO_EVALIPROTO_UPSERTIPROTO_CALLIPROTO_EXECUTEIPROTO_NOPIPROTO_PREPAREIPROTO_BEGINIPROTO_COMMITIPROTO_ROLLBACKIPROTO_TYPE_STAT_MAX" _Type_name_1 = "IPROTO_RAFTIPROTO_RAFT_PROMOTEIPROTO_RAFT_DEMOTE" _Type_name_2 = "IPROTO_RAFT_CONFIRMIPROTO_RAFT_ROLLBACK" - _Type_name_3 = "IPROTO_PINGIPROTO_JOINIPROTO_SUBSCRIBEIPROTO_VOTE_DEPRECATEDIPROTO_VOTEIPROTO_FETCH_SNAPSHOTIPROTO_REGISTERIPROTO_JOIN_METAIPROTO_JOIN_SNAPSHOTIPROTO_IDIPROTO_WATCHIPROTO_UNWATCHIPROTO_EVENT" + _Type_name_3 = "IPROTO_PINGIPROTO_JOINIPROTO_SUBSCRIBEIPROTO_VOTE_DEPRECATEDIPROTO_VOTEIPROTO_FETCH_SNAPSHOTIPROTO_REGISTERIPROTO_JOIN_METAIPROTO_JOIN_SNAPSHOTIPROTO_IDIPROTO_WATCHIPROTO_UNWATCHIPROTO_EVENTIPROTO_WATCH_ONCE" _Type_name_4 = "VY_INDEX_RUN_INFOVY_INDEX_PAGE_INFOVY_RUN_ROW_INDEX" _Type_name_5 = "IPROTO_CHUNK" _Type_name_6 = "IPROTO_TYPE_ERROR" ) var ( - _Type_index_0 = [...]uint8{0, 14, 23, 36, 49, 63, 76, 89, 103, 114, 125, 138, 149, 163, 173, 187, 199, 212, 227} + _Type_index_0 = [...]uint8{0, 14, 23, 36, 49, 63, 76, 89, 103, 114, 125, 138, 149, 163, 173, 187, 199, 212, 227, 247} _Type_index_1 = [...]uint8{0, 11, 30, 48} _Type_index_2 = [...]uint8{0, 19, 39} - _Type_index_3 = [...]uint8{0, 11, 22, 38, 60, 71, 92, 107, 123, 143, 152, 164, 178, 190} + _Type_index_3 = [...]uint8{0, 11, 22, 38, 60, 71, 92, 107, 123, 143, 152, 164, 178, 190, 207} _Type_index_4 = [...]uint8{0, 17, 35, 51} ) func (i Type) String() string { switch { - case -1 <= i && i <= 16: + case -1 <= i && i <= 17: i -= -1 return _Type_name_0[_Type_index_0[i]:_Type_index_0[i+1]] case 30 <= i && i <= 32: @@ -80,7 +82,7 @@ func (i Type) String() string { case 40 <= i && i <= 41: i -= 40 return _Type_name_2[_Type_index_2[i]:_Type_index_2[i+1]] - case 64 <= i && i <= 76: + case 64 <= i && i <= 77: i -= 64 return _Type_name_3[_Type_index_3[i]:_Type_index_3[i+1]] case 100 <= i && i <= 102: diff --git a/type_test.go b/type_test.go index ece13f3..5796239 100644 --- a/type_test.go +++ b/type_test.go @@ -50,12 +50,14 @@ func TestType(t *testing.T) { {iproto.IPROTO_WATCH, "IPROTO_WATCH", 74}, {iproto.IPROTO_UNWATCH, "IPROTO_UNWATCH", 75}, {iproto.IPROTO_EVENT, "IPROTO_EVENT", 76}, - {iproto.VY_INDEX_RUN_INFO, "VY_INDEX_RUN_INFO", 100}, - {iproto.VY_INDEX_PAGE_INFO, "VY_INDEX_PAGE_INFO", 101}, - {iproto.VY_RUN_ROW_INDEX, "VY_RUN_ROW_INDEX", 102}, + {iproto.IPROTO_WATCH_ONCE, "IPROTO_WATCH_ONCE", 77}, {iproto.IPROTO_CHUNK, "IPROTO_CHUNK", 128}, {iproto.IPROTO_TYPE_ERROR, "IPROTO_TYPE_ERROR", 1 << 15}, {iproto.IPROTO_UNKNOWN, "IPROTO_UNKNOWN", -1}, + {iproto.IPROTO_TYPE_STAT_MAX, "IPROTO_TYPE_STAT_MAX", int(iproto.IPROTO_ROLLBACK) + 1}, + {iproto.VY_INDEX_RUN_INFO, "VY_INDEX_RUN_INFO", 100}, + {iproto.VY_INDEX_PAGE_INFO, "VY_INDEX_PAGE_INFO", 101}, + {iproto.VY_RUN_ROW_INDEX, "VY_RUN_ROW_INDEX", 102}, } for _, tc := range cases {