From 349e853e77cefe4c59f195046d2628c6b850dd71 Mon Sep 17 00:00:00 2001 From: Oleg Jukovec Date: Tue, 11 Apr 2023 10:14:46 +0300 Subject: [PATCH] api: add initial implementation The package parses constants from: - tarantool/src/box/errcode.h - tarantool/src/box/iproto_constants.h - tarantool/src/box/iproto_features.h You could to generate the code with the command: TT_TAG=master make Closes https://github.com/tarantool/go-tarantool/issues/267 --- .github/workflows/test.yml | 91 +++++++ Makefile | 23 ++ README.md | 78 ++++++ doc.go | 10 + error.go | 544 +++++++++++++++++++++++++++++++++++++ error_string.go | 289 ++++++++++++++++++++ error_test.go | 295 ++++++++++++++++++++ example_test.go | 21 ++ feature.go | 32 +++ feature_string.go | 27 ++ feature_test.go | 35 +++ flag.go | 16 ++ flag_string.go | 35 +++ flag_test.go | 33 +++ generate.go | 9 + generate.sh | 314 +++++++++++++++++++++ go.mod | 3 + keys.go | 152 +++++++++++ keys_string.go | 174 ++++++++++++ keys_test.go | 170 ++++++++++++ type.go | 104 +++++++ type_string.go | 96 +++++++ type_test.go | 71 +++++ 23 files changed, 2622 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 Makefile create mode 100644 README.md create mode 100644 doc.go create mode 100644 error.go create mode 100644 error_string.go create mode 100644 error_test.go create mode 100644 example_test.go create mode 100644 feature.go create mode 100644 feature_string.go create mode 100644 feature_test.go create mode 100644 flag.go create mode 100644 flag_string.go create mode 100644 flag_test.go create mode 100644 generate.go create mode 100755 generate.sh create mode 100644 go.mod create mode 100644 keys.go create mode 100644 keys_string.go create mode 100644 keys_test.go create mode 100644 type.go create mode 100644 type_string.go create mode 100644 type_test.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ec411a2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,91 @@ +name: testing + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + tests: + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + # + # Also we want to run it always for manually triggered workflows. + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) || + (github.event_name == 'workflow_dispatch') + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + golang: + - '1.13' + - '1.20' + + steps: + - uses: actions/checkout@v3 + + - name: Setup golang ${{ matrix.golang }} + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.golang }} + + - run: make test + + master-build: + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) || + (github.event_name == 'workflow_dispatch') + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v3 + + - run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + + - run: make deps + + - run: TT_TAG=master make + + golangci-lint: + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) || + (github.event_name == 'workflow_dispatch') + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v3 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + continue-on-error: true + with: + # The first run is for GitHub Actions error format. + args: -E goimports + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # The second run is for human-readable error format with a file name + # and a line number. + args: --out-${NO_FUTURE}format colored-line-number -E goimports diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..708511d --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +SHELL := /bin/bash + +.PHONY: all +all: generate test + +.PHONY: deps +deps: + go install golang.org/x/tools/cmd/goimports@latest + go install golang.org/x/tools/cmd/stringer@latest + +.PHONY: format +format: + goimports -l -w . + +.PHONY: generate +generate: + go generate ./... + +.PHONY: test +test: + @echo "Running all packages tests" + go clean -testcache + go test -tags ./... -v -p 1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..92d5363 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +[![Go Reference][godoc-badge]][godoc-url] +[![Actions Status][actions-badge]][actions-url] +[![Telegram][telegram-badge]][telegram-url] +[![Telegram Russian][telegram-badge]][telegramru-url] + +# iproto + +## Import + +```go +import "github.com/tarantool/go-iproto" +``` + +## Overview + +Package `iproto` contains IPROTO constants. + +The code generated from Tarantool code. Code generation is only supported for +an actual commit/release. We do not have a goal to support all versions of +Tarantool with a code generator. + +## Example + +```go +package main + +import ( + "fmt" + + "github.com/tarantool/go-iproto" +) + +func main() { + fmt.Printf("%s=%d\n", iproto.ER_READONLY, iproto.ER_READONLY) + fmt.Printf("%s=%d\n", iproto.IPROTO_FEATURE_WATCHERS, iproto.IPROTO_FEATURE_WATCHERS) + fmt.Printf("%s=%d\n", iproto.IPROTO_FLAG_COMMIT, iproto.IPROTO_FLAG_COMMIT) + fmt.Printf("%s=%d\n", iproto.IPROTO_SYNC, iproto.IPROTO_SYNC) + fmt.Printf("%s=%d\n", iproto.IPROTO_SELECT, iproto.IPROTO_SELECT) +} +``` + +## Development + +You need to install `git` and `go1.13+` first. After that, you need to install +additional dependencies into `$GOBIN`: + +```bash +make deps +``` + +You can generate the code with commands: + +```bash +TT_TAG=master make +TT_TAG=2.10.6 make +TT_TAG=master TT_REPO=https://github.com/my/tarantool.git make +``` + +You need to specify a target branch/tag with the environment variable `TT_TAG` +and you could to specify a repository with the `TT_REPO`. + +Makefile has additional targets that can be useful: + +```bash +make format +TT_TAG=master make generate +make test +``` + +A good starting point is [generate.go](./generate.go). + +[actions-badge]: https://github.com/tarantool/go-iproto/actions/workflows/test.yml/badge.svg +[actions-url]: https://github.com/tarantool/go-iproto/actions/workflows/test.yml +[godoc-badge]: https://pkg.go.dev/badge/github.com/tarantool/go-iproto.svg +[godoc-url]: https://pkg.go.dev/github.com/tarantool/go-iproto +[telegram-badge]: https://img.shields.io/badge/Telegram-join%20chat-blue.svg +[telegram-url]: http://telegram.me/tarantool +[telegramru-url]: http://telegram.me/tarantoolru diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..30e4f55 --- /dev/null +++ b/doc.go @@ -0,0 +1,10 @@ +// Package iproto contains IPROTO constants. +// +// The package code generated from: +// +// Repository: https://github.com/tarantool/tarantool.git +// Tag or branch: master +// Commit: 22d7636b521fd2e18104852ba1e0c206825f92a5 +package iproto + +// Code generated by generate.sh; DO NOT EDIT. diff --git a/error.go b/error.go new file mode 100644 index 0000000..ee194b2 --- /dev/null +++ b/error.go @@ -0,0 +1,544 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto + +// IPROTO error code constants, generated from +// tarantool/src/box/errcode.h +type Error int + +const ( + // "Unknown error" + ER_UNKNOWN Error = 0 + // "Illegal parameters, %s" + ER_ILLEGAL_PARAMS Error = 1 + // "Failed to allocate %u bytes in %s for %s" + ER_MEMORY_ISSUE Error = 2 + // "Duplicate key exists in unique index \"%s\" in space \"%s\" with old tuple - %s and new tuple - %s" + ER_TUPLE_FOUND Error = 3 + // "Tuple doesn't exist in index '%s' in space '%s'" + ER_TUPLE_NOT_FOUND Error = 4 + // "%s does not support %s" + ER_UNSUPPORTED Error = 5 + // "Can't modify data on a replication slave. My master is: %s" + ER_NONMASTER Error = 6 + // "Can't modify data on a read-only instance" + ER_READONLY Error = 7 + // "Error injection '%s'" + ER_INJECTION Error = 8 + // "Failed to create space '%s': %s" + ER_CREATE_SPACE Error = 9 + // "Space '%s' already exists" + ER_SPACE_EXISTS Error = 10 + // "Can't drop space '%s': %s" + ER_DROP_SPACE Error = 11 + // "Can't modify space '%s': %s" + ER_ALTER_SPACE Error = 12 + // "Unsupported index type supplied for index '%s' in space '%s'" + ER_INDEX_TYPE Error = 13 + // "Can't create or modify index '%s' in space '%s': %s" + ER_MODIFY_INDEX Error = 14 + // "Can't drop the primary key in a system space, space '%s'" + ER_LAST_DROP Error = 15 + // "Tuple format limit reached: %u" + ER_TUPLE_FORMAT_LIMIT Error = 16 + // "Can't drop primary key in space '%s' while secondary keys exist" + ER_DROP_PRIMARY_KEY Error = 17 + // "Supplied key type of part %u does not match index part type: expected %s" + ER_KEY_PART_TYPE Error = 18 + // "Invalid key part count in an exact match (expected %u, got %u)" + ER_EXACT_MATCH Error = 19 + // "Invalid MsgPack - %s" + ER_INVALID_MSGPACK Error = 20 + // "msgpack.encode: can not encode Lua type '%s'" + ER_PROC_RET Error = 21 + // "Tuple/Key must be MsgPack array" + ER_TUPLE_NOT_ARRAY Error = 22 + // "Tuple field %s type does not match one required by operation: expected %s, got %s" + ER_FIELD_TYPE Error = 23 + // "Field %s has type '%s' in one index, but type '%s' in another" + ER_INDEX_PART_TYPE_MISMATCH Error = 24 + // "SPLICE error on field %s: %s" + ER_UPDATE_SPLICE Error = 25 + // "Argument type in operation '%c' on field %s does not match field type: expected %s" + ER_UPDATE_ARG_TYPE Error = 26 + // "Field %s has type '%s' in space format, but type '%s' in index definition" + ER_FORMAT_MISMATCH_INDEX_PART Error = 27 + // "Unknown UPDATE operation #%d: %s" + ER_UNKNOWN_UPDATE_OP Error = 28 + // "Field %s UPDATE error: %s" + ER_UPDATE_FIELD Error = 29 + // "Transaction is active at return from function" + ER_FUNCTION_TX_ACTIVE Error = 30 + // "Invalid key part count (expected [0..%u], got %u)" + ER_KEY_PART_COUNT Error = 31 + // "%s" + ER_PROC_LUA Error = 32 + // "Procedure '%.*s' is not defined" + ER_NO_SUCH_PROC Error = 33 + // "Trigger '%s' doesn't exist" + ER_NO_SUCH_TRIGGER Error = 34 + // "No index #%u is defined in space '%s'" + ER_NO_SUCH_INDEX_ID Error = 35 + // "Space '%s' does not exist" + ER_NO_SUCH_SPACE Error = 36 + // "Field %d was not found in the tuple" + ER_NO_SUCH_FIELD_NO Error = 37 + // "Tuple field count %u does not match space field count %u" + ER_EXACT_FIELD_COUNT Error = 38 + // "Tuple field %s required by space format is missing" + ER_FIELD_MISSING Error = 39 + // "Failed to write to disk" + ER_WAL_IO Error = 40 + // "Get() doesn't support partial keys and non-unique indexes" + ER_MORE_THAN_ONE_TUPLE Error = 41 + // "%s access to %s '%s' is denied for user '%s'" + ER_ACCESS_DENIED Error = 42 + // "Failed to create user '%s': %s" + ER_CREATE_USER Error = 43 + // "Failed to drop user or role '%s': %s" + ER_DROP_USER Error = 44 + // "User '%s' is not found" + ER_NO_SUCH_USER Error = 45 + // "User '%s' already exists" + ER_USER_EXISTS Error = 46 + // "User not found or supplied credentials are invalid" + ER_CREDS_MISMATCH Error = 47 + // "Unknown request type %u" + ER_UNKNOWN_REQUEST_TYPE Error = 48 + // "Unknown object type '%s'" + ER_UNKNOWN_SCHEMA_OBJECT Error = 49 + // "Failed to create function '%s': %s" + ER_CREATE_FUNCTION Error = 50 + // "Function '%s' does not exist" + 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" + ER_BEFORE_REPLACE_RET Error = 53 + // "Can not perform %s in a multi-statement transaction" + ER_MULTISTATEMENT_TRANSACTION Error = 54 + // "Trigger '%s' already exists" + ER_TRIGGER_EXISTS Error = 55 + // "A limit on the total number of users has been reached: %u" + ER_USER_MAX Error = 56 + // "Space engine '%s' does not exist" + ER_NO_SUCH_ENGINE Error = 57 + // "Can't set option '%s' dynamically" + ER_RELOAD_CFG Error = 58 + // "Incorrect value for option '%s': %s" + ER_CFG Error = 59 + // "Can not set a savepoint in an empty transaction" + ER_SAVEPOINT_EMPTY_TX Error = 60 + // "Can not rollback to savepoint: the savepoint does not exist" + ER_NO_SUCH_SAVEPOINT Error = 61 + // "Replica %s is not registered with replica set %s" + ER_UNKNOWN_REPLICA Error = 62 + // "Replica set UUID mismatch: expected %s, got %s" + ER_REPLICASET_UUID_MISMATCH Error = 63 + // "Invalid UUID: %s" + ER_INVALID_UUID Error = 64 + // "Can't reset replica set UUID: it is already assigned" + ER_REPLICASET_UUID_IS_RO Error = 65 + // "Instance UUID mismatch: expected %s, got %s" + ER_INSTANCE_UUID_MISMATCH Error = 66 + // "Can't initialize replica id with a reserved value %u" + ER_REPLICA_ID_IS_RESERVED Error = 67 + // "Invalid LSN order for instance %u: previous LSN = %llu, new lsn = %llu" + ER_INVALID_ORDER Error = 68 + // "Missing mandatory field '%s' in request" + ER_MISSING_REQUEST_FIELD Error = 69 + // "Invalid identifier '%s' (expected printable symbols only or it is too long)" + ER_IDENTIFIER Error = 70 + // "Can't drop function %u: %s" + ER_DROP_FUNCTION Error = 71 + // "Unknown iterator type '%s'" + ER_ITERATOR_TYPE Error = 72 + // "Replica count limit reached: %u" + ER_REPLICA_MAX Error = 73 + // "Failed to read xlog: %lld" + ER_INVALID_XLOG Error = 74 + // "Invalid xlog name: expected %lld got %lld" + ER_INVALID_XLOG_NAME Error = 75 + // "Invalid xlog order: %lld and %lld" + ER_INVALID_XLOG_ORDER Error = 76 + // "Connection is not established" + ER_NO_CONNECTION Error = 77 + // "Timeout exceeded" + ER_TIMEOUT Error = 78 + // "Operation is not permitted when there is an active transaction " + ER_ACTIVE_TRANSACTION Error = 79 + // "The transaction the cursor belongs to has ended" + ER_CURSOR_NO_TRANSACTION Error = 80 + // "A multi-statement transaction can not use multiple storage engines" + ER_CROSS_ENGINE_TRANSACTION Error = 81 + // "Role '%s' is not found" + ER_NO_SUCH_ROLE Error = 82 + // "Role '%s' already exists" + ER_ROLE_EXISTS Error = 83 + // "Failed to create role '%s': %s" + ER_CREATE_ROLE Error = 84 + // "Index '%s' already exists" + ER_INDEX_EXISTS Error = 85 + // "Session is closed" + ER_SESSION_CLOSED Error = 86 + // "Granting role '%s' to role '%s' would create a loop" + ER_ROLE_LOOP Error = 87 + // "Incorrect grant arguments: %s" + ER_GRANT Error = 88 + // "User '%s' already has %s access on %s%s" + ER_PRIV_GRANTED Error = 89 + // "User '%s' already has role '%s'" + ER_ROLE_GRANTED Error = 90 + // "User '%s' does not have %s access on %s '%s'" + ER_PRIV_NOT_GRANTED Error = 91 + // "User '%s' does not have role '%s'" + ER_ROLE_NOT_GRANTED Error = 92 + // "Can't find snapshot" + ER_MISSING_SNAPSHOT Error = 93 + // "Attempt to modify a tuple field which is part of primary index in space '%s'" + ER_CANT_UPDATE_PRIMARY_KEY Error = 94 + // "Integer overflow when performing '%c' operation on field %s" + ER_UPDATE_INTEGER_OVERFLOW Error = 95 + // "Setting password for guest user has no effect" + ER_GUEST_USER_PASSWORD Error = 96 + // "Transaction has been aborted by conflict" + ER_TRANSACTION_CONFLICT Error = 97 + // "Unsupported %s privilege '%s'" + ER_UNSUPPORTED_PRIV Error = 98 + // "Failed to dynamically load function '%s': %s" + ER_LOAD_FUNCTION Error = 99 + // "Unsupported language '%s' specified for function '%s'" + ER_FUNCTION_LANGUAGE Error = 100 + // "RTree: %s must be an array with %u (point) or %u (rectangle/box) numeric coordinates" + ER_RTREE_RECT Error = 101 + // "%s" + ER_PROC_C Error = 102 + // "Unknown RTREE index distance type %s" + ER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPE Error = 103 + // "%s" + ER_PROTOCOL Error = 104 + // "Space %s has a unique secondary index and does not support UPSERT" + ER_UPSERT_UNIQUE_SECONDARY_KEY Error = 105 + // "Wrong record in _index space: got {%s}, expected {%s}" + ER_WRONG_INDEX_RECORD Error = 106 + // "Wrong index part %u: %s" + ER_WRONG_INDEX_PARTS Error = 107 + // "Wrong index options: %s" + ER_WRONG_INDEX_OPTIONS Error = 108 + // "Wrong schema version, current: %d, in request: %llu" + ER_WRONG_SCHEMA_VERSION Error = 109 + // "Failed to allocate %u bytes for tuple: tuple is too large. Check 'memtx_max_tuple_size' configuration option." + ER_MEMTX_MAX_TUPLE_SIZE Error = 110 + // "Wrong space options: %s" + ER_WRONG_SPACE_OPTIONS Error = 111 + // "Index '%s' (%s) of space '%s' (%s) does not support %s" + ER_UNSUPPORTED_INDEX_FEATURE Error = 112 + // "View '%s' is read-only" + ER_VIEW_IS_RO Error = 113 + // "No active transaction" + ER_NO_TRANSACTION Error = 114 + // "%s" + ER_SYSTEM Error = 115 + // "Instance bootstrap hasn't finished yet" + ER_LOADING Error = 116 + // "Connection to self" + ER_CONNECTION_TO_SELF Error = 117 + // "Key part is too long: %u of %u bytes" + ER_KEY_PART_IS_TOO_LONG Error = 118 + // "Compression error: %s" + ER_COMPRESSION Error = 119 + // "Snapshot is already in progress" + ER_CHECKPOINT_IN_PROGRESS Error = 120 + // "Can not execute a nested statement: nesting limit reached" + ER_SUB_STMT_MAX Error = 121 + // "Can not commit transaction in a nested statement" + ER_COMMIT_IN_SUB_STMT Error = 122 + // "Rollback called in a nested statement" + ER_ROLLBACK_IN_SUB_STMT Error = 123 + // "Decompression error: %s" + ER_DECOMPRESSION Error = 124 + // "Invalid xlog type: expected %s, got %s" + ER_INVALID_XLOG_TYPE Error = 125 + // "Failed to lock WAL directory %s and hot_standby mode is off" + ER_ALREADY_RUNNING Error = 126 + // "Indexed field count limit reached: %d indexed fields" + ER_INDEX_FIELD_COUNT_LIMIT Error = 127 + // "The local instance id %u is read-only" + ER_LOCAL_INSTANCE_ID_IS_READ_ONLY Error = 128 + // "Backup is already in progress" + ER_BACKUP_IN_PROGRESS Error = 129 + // "The read view is aborted" + ER_READ_VIEW_ABORTED Error = 130 + // "Invalid INDEX file %s: %s" + ER_INVALID_INDEX_FILE Error = 131 + // "Invalid RUN file: %s" + ER_INVALID_RUN_FILE Error = 132 + // "Invalid VYLOG file: %s" + ER_INVALID_VYLOG_FILE Error = 133 + // "WAL has a rollback in progress" + ER_CASCADE_ROLLBACK Error = 134 + // "Timed out waiting for Vinyl memory quota" + ER_VY_QUOTA_TIMEOUT Error = 135 + // "%s index does not support selects via a partial key (expected %u parts, got %u). Please Consider changing index type to TREE." + ER_PARTIAL_KEY Error = 136 + // "Can't truncate a system space, space '%s'" + ER_TRUNCATE_SYSTEM_SPACE Error = 137 + // "Failed to dynamically load module '%.*s': %s" + ER_LOAD_MODULE Error = 138 + // "Failed to allocate %u bytes for tuple: tuple is too large. Check 'vinyl_max_tuple_size' configuration option." + ER_VINYL_MAX_TUPLE_SIZE Error = 139 + // "Wrong _schema version: expected 'major.minor[.patch]'" + ER_WRONG_DD_VERSION Error = 140 + // "Wrong space format field %u: %s" + ER_WRONG_SPACE_FORMAT Error = 141 + // "Failed to create sequence '%s': %s" + ER_CREATE_SEQUENCE Error = 142 + // "Can't modify sequence '%s': %s" + ER_ALTER_SEQUENCE Error = 143 + // "Can't drop sequence '%s': %s" + ER_DROP_SEQUENCE Error = 144 + // "Sequence '%s' does not exist" + ER_NO_SUCH_SEQUENCE Error = 145 + // "Sequence '%s' already exists" + ER_SEQUENCE_EXISTS Error = 146 + // "Sequence '%s' has overflowed" + ER_SEQUENCE_OVERFLOW Error = 147 + // "No index '%s' is defined in space '%s'" + ER_NO_SUCH_INDEX_NAME Error = 148 + // "Space field '%s' is duplicate" + ER_SPACE_FIELD_IS_DUPLICATE Error = 149 + // "Failed to initialize collation: %s." + ER_CANT_CREATE_COLLATION Error = 150 + // "Wrong collation options: %s" + ER_WRONG_COLLATION_OPTIONS Error = 151 + // "Primary index of space '%s' can not contain nullable parts" + ER_NULLABLE_PRIMARY Error = 152 + // "Field '%s' was not found in space '%s' format" + ER_NO_SUCH_FIELD_NAME_IN_SPACE Error = 153 + // "Transaction has been aborted by a fiber yield" + ER_TRANSACTION_YIELD Error = 154 + // "Replication group '%s' does not exist" + ER_NO_SUCH_GROUP Error = 155 + // "Bind value for parameter %s is out of range for type %s" + ER_SQL_BIND_VALUE Error = 156 + // "Bind value type %s for parameter %s is not supported" + ER_SQL_BIND_TYPE Error = 157 + // "SQL bind parameter limit reached: %d" + ER_SQL_BIND_PARAMETER_MAX Error = 158 + // "Failed to execute SQL statement: %s" + ER_SQL_EXECUTE Error = 159 + // "Decimal overflow when performing operation '%c' on field %s" + ER_UPDATE_DECIMAL_OVERFLOW Error = 160 + // "Parameter %s was not found in the statement" + ER_SQL_BIND_NOT_FOUND Error = 161 + // "Field %s contains %s on conflict action, but %s in index parts" + ER_ACTION_MISMATCH Error = 162 + // "Space declared as a view must have SQL statement" + ER_VIEW_MISSING_SQL Error = 163 + // "Can not commit transaction: deferred foreign keys violations are not resolved" + ER_FOREIGN_KEY_CONSTRAINT Error = 164 + // "Module '%s' does not exist" + ER_NO_SUCH_MODULE Error = 165 + // "Collation '%s' does not exist" + ER_NO_SUCH_COLLATION Error = 166 + // "Failed to create foreign key constraint '%s': %s" + ER_CREATE_FK_CONSTRAINT Error = 167 + // "Failed to drop foreign key constraint '%s': %s" + ER_DROP_FK_CONSTRAINT Error = 168 + // "Constraint '%s' does not exist in space '%s'" + ER_NO_SUCH_CONSTRAINT Error = 169 + // "%s constraint '%s' already exists in space '%s'" + ER_CONSTRAINT_EXISTS Error = 170 + // "Type mismatch: can not convert %s to %s" + 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" + ER_DROP_COLLATION Error = 173 + // "Illegal mix of collations" + ER_ILLEGAL_COLLATION_MIX Error = 174 + // "Pragma '%s' does not exist" + ER_SQL_NO_SUCH_PRAGMA Error = 175 + // "Can’t resolve field '%s'" + ER_SQL_CANT_RESOLVE_FIELD Error = 176 + // "Index '%s' already exists in space '%s'" + ER_INDEX_EXISTS_IN_SPACE Error = 177 + // "Inconsistent types: expected %s got %s" + ER_INCONSISTENT_TYPES Error = 178 + // "Syntax error at line %d at or near position %d: %s" + ER_SQL_SYNTAX_WITH_POS Error = 179 + // "Failed to parse SQL statement: parser stack limit reached" + ER_SQL_STACK_OVERFLOW Error = 180 + // "Failed to expand '*' in SELECT statement without FROM clause" + ER_SQL_SELECT_WILDCARD Error = 181 + // "Failed to execute an empty SQL statement" + ER_SQL_STATEMENT_EMPTY Error = 182 + // "At line %d at or near position %d: keyword '%.*s' is reserved. Please use double quotes if '%.*s' is an identifier." + ER_SQL_KEYWORD_IS_RESERVED Error = 183 + // "Syntax error at line %d near '%.*s'" + ER_SQL_SYNTAX_NEAR_TOKEN Error = 184 + // "At line %d at or near position %d: unrecognized token '%.*s'" + ER_SQL_UNKNOWN_TOKEN Error = 185 + // "%s" + ER_SQL_PARSER_GENERIC Error = 186 + // "ANALYZE statement argument %s is not a base table" + ER_SQL_ANALYZE_ARGUMENT Error = 187 + // "Failed to create space '%s': space column count %d exceeds the limit (%d)" + ER_SQL_COLUMN_COUNT_MAX Error = 188 + // "Hex literal %s%s length %d exceeds the supported limit (%d)" + ER_HEX_LITERAL_MAX Error = 189 + // "Integer literal %s%s exceeds the supported range [-9223372036854775808, 18446744073709551615]" + ER_INT_LITERAL_MAX Error = 190 + // "%s %d exceeds the limit (%d)" + ER_SQL_PARSER_LIMIT Error = 191 + // "%s are prohibited in an index definition" + ER_INDEX_DEF_UNSUPPORTED Error = 192 + // "%s are prohibited in a ck constraint definition" + ER_CK_DEF_UNSUPPORTED Error = 193 + // "Field %s is used as multikey in one index and as single key in another" + ER_MULTIKEY_INDEX_MISMATCH Error = 194 + // "Failed to create check constraint '%s': %s" + ER_CREATE_CK_CONSTRAINT Error = 195 + // "Check constraint failed '%s': %s" + ER_CK_CONSTRAINT_FAILED Error = 196 + // "Unequal number of entries in row expression: left side has %u, but right side - %u" + ER_SQL_COLUMN_COUNT Error = 197 + // "Failed to build a key for functional index '%s' of space '%s': %s" + ER_FUNC_INDEX_FUNC Error = 198 + // "Key format doesn't match one defined in functional index '%s' of space '%s': %s" + ER_FUNC_INDEX_FORMAT Error = 199 + // "Wrong functional index definition: %s" + ER_FUNC_INDEX_PARTS Error = 200 + // "Field '%s' was not found in the tuple" + ER_NO_SUCH_FIELD_NAME Error = 201 + // "Wrong number of arguments is passed to %s(): expected %s, got %d" + ER_FUNC_WRONG_ARG_COUNT Error = 202 + // "Trying to bootstrap a local read-only instance as master" + ER_BOOTSTRAP_READONLY Error = 203 + // "SQL expects exactly one argument returned from %s, got %d" + ER_SQL_FUNC_WRONG_RET_COUNT Error = 204 + // "Function '%s' returned value of invalid type: expected %s got %s" + ER_FUNC_INVALID_RETURN_TYPE Error = 205 + // "At line %d at or near position %d: %s" + ER_SQL_PARSER_GENERIC_WITH_POS Error = 206 + // "Replica '%s' is not anonymous and cannot register." + ER_REPLICA_NOT_ANON Error = 207 + // "Couldn't find an instance to register this replica on." + ER_CANNOT_REGISTER Error = 208 + // "Session setting %s expected a value of type %s" + ER_SESSION_SETTING_INVALID_VALUE Error = 209 + // "Failed to prepare SQL statement: %s" + ER_SQL_PREPARE Error = 210 + // "Prepared statement with id %u does not exist" + ER_WRONG_QUERY_ID Error = 211 + // "Sequence '%s' is not started" + ER_SEQUENCE_NOT_STARTED Error = 212 + // "Session setting %s doesn't exist" + ER_NO_SUCH_SESSION_SETTING Error = 213 + // "Found uncommitted sync transactions from other instance with id %u" + ER_UNCOMMITTED_FOREIGN_SYNC_TXNS Error = 214 + // "CONFIRM message arrived for an unknown master id %d, expected %d" + ER_SYNC_MASTER_MISMATCH Error = 215 + // "Quorum collection for a synchronous transaction is timed out" + ER_SYNC_QUORUM_TIMEOUT Error = 216 + // "A rollback for a synchronous transaction is received" + ER_SYNC_ROLLBACK Error = 217 + // "Can't create tuple: metadata size %u is too big" + ER_TUPLE_METADATA_IS_TOO_BIG Error = 218 + // "%s" + ER_XLOG_GAP Error = 219 + // "Can't subscribe non-anonymous replica %s until join is done" + ER_TOO_EARLY_SUBSCRIBE Error = 220 + // "Can't add AUTOINCREMENT: space %s can't feature more than one AUTOINCREMENT field" + ER_SQL_CANT_ADD_AUTOINC Error = 221 + // "Couldn't wait for quorum %d: %s" + ER_QUORUM_WAIT Error = 222 + // "Instance with replica id %u was promoted first" + ER_INTERFERING_PROMOTE Error = 223 + // "Elections were turned off" + ER_ELECTION_DISABLED Error = 224 + // "Transaction was rolled back" + ER_TXN_ROLLBACK Error = 225 + // "The instance is not a leader. New leader is %u" + ER_NOT_LEADER Error = 226 + // "The synchronous transaction queue doesn't belong to any instance" + ER_SYNC_QUEUE_UNCLAIMED Error = 227 + // "The synchronous transaction queue belongs to other instance with id %u" + ER_SYNC_QUEUE_FOREIGN Error = 228 + // "Unable to process %s request in stream" + ER_UNABLE_TO_PROCESS_IN_STREAM Error = 229 + // "Unable to process %s request out of stream" + ER_UNABLE_TO_PROCESS_OUT_OF_STREAM Error = 230 + // "Transaction has been aborted by timeout" + ER_TRANSACTION_TIMEOUT Error = 231 + // "Operation is not permitted if timer is already running" + ER_ACTIVE_TIMER Error = 232 + // "Tuple field count limit reached: see box.schema.FIELD_MAX" + ER_TUPLE_FIELD_COUNT_LIMIT Error = 233 + // "Failed to create constraint '%s' in space '%s': %s" + ER_CREATE_CONSTRAINT Error = 234 + // "Check constraint '%s' failed for field '%s'" + ER_FIELD_CONSTRAINT_FAILED Error = 235 + // "Check constraint '%s' failed for tuple" + ER_TUPLE_CONSTRAINT_FAILED Error = 236 + // "Failed to create foreign key '%s' in space '%s': %s" + ER_CREATE_FOREIGN_KEY Error = 237 + // "Foreign key '%s' integrity check failed: %s" + ER_FOREIGN_KEY_INTEGRITY Error = 238 + // "Foreign key constraint '%s' failed for field '%s': %s" + ER_FIELD_FOREIGN_KEY_FAILED Error = 239 + // "Foreign key constraint '%s' failed: %s" + ER_COMPLEX_FOREIGN_KEY_FAILED Error = 240 + // "Wrong space upgrade options: %s" + ER_WRONG_SPACE_UPGRADE_OPTIONS Error = 241 + // "Not enough peers connected to start elections: %d out of minimal required %d" + ER_NO_ELECTION_QUORUM Error = 242 + // "%s" + ER_SSL Error = 243 + // "Split-Brain discovered: %s" + ER_SPLIT_BRAIN Error = 244 + // "The term is outdated: old - %llu, new - %llu" + ER_OLD_TERM Error = 245 + // "Interfering elections started" + ER_INTERFERING_ELECTIONS Error = 246 + // "Iterator position is invalid" + ER_ITERATOR_POSITION Error = 247 + // "" + ER_UNUSED Error = 248 + // "Unknown authentication method '%s'" + ER_UNKNOWN_AUTH_METHOD Error = 249 + // "Invalid '%s' data: %s" + ER_INVALID_AUTH_DATA Error = 250 + // "Invalid '%s' request: %s" + ER_INVALID_AUTH_REQUEST Error = 251 + // "Password doesn't meet security requirements: %s" + ER_WEAK_PASSWORD Error = 252 + // "Password must differ from last %d passwords" + ER_OLD_PASSWORD Error = 253 + // "Session %llu does not exist" + ER_NO_SUCH_SESSION Error = 254 + // "Session '%s' is not supported" + ER_WRONG_SESSION_TYPE Error = 255 + // "Password expired" + ER_PASSWORD_EXPIRED Error = 256 + // "Too many authentication attempts" + ER_AUTH_DELAY Error = 257 + // "Authentication required" + ER_AUTH_REQUIRED Error = 258 + // "Scanning is not allowed for %s" + ER_SQL_SEQ_SCAN Error = 259 + // "Unknown event %s" + ER_NO_SUCH_EVENT Error = 260 + // "Replica %s chose a different bootstrap leader %s" + ER_BOOTSTRAP_NOT_UNANIMOUS Error = 261 + // "Can't check who replica %s chose its bootstrap leader" + ER_CANT_CHECK_BOOTSTRAP_LEADER Error = 262 + // "Some replica set members were not specified in box.cfg.replication" + ER_BOOTSTRAP_CONNECTION_NOT_TO_ALL Error = 263 + // "Nil UUID is reserved and can't be used in replication" + ER_NIL_UUID Error = 264 + // "Wrong function options: %s" + ER_WRONG_FUNCTION_OPTIONS Error = 265 + // "Snapshot has no system spaces" + ER_MISSING_SYSTEM_SPACES Error = 266 +) diff --git a/error_string.go b/error_string.go new file mode 100644 index 0000000..6a4c3b7 --- /dev/null +++ b/error_string.go @@ -0,0 +1,289 @@ +// Code generated by "stringer -type=Error"; DO NOT EDIT. + +package iproto + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[ER_UNKNOWN-0] + _ = x[ER_ILLEGAL_PARAMS-1] + _ = x[ER_MEMORY_ISSUE-2] + _ = x[ER_TUPLE_FOUND-3] + _ = x[ER_TUPLE_NOT_FOUND-4] + _ = x[ER_UNSUPPORTED-5] + _ = x[ER_NONMASTER-6] + _ = x[ER_READONLY-7] + _ = x[ER_INJECTION-8] + _ = x[ER_CREATE_SPACE-9] + _ = x[ER_SPACE_EXISTS-10] + _ = x[ER_DROP_SPACE-11] + _ = x[ER_ALTER_SPACE-12] + _ = x[ER_INDEX_TYPE-13] + _ = x[ER_MODIFY_INDEX-14] + _ = x[ER_LAST_DROP-15] + _ = x[ER_TUPLE_FORMAT_LIMIT-16] + _ = x[ER_DROP_PRIMARY_KEY-17] + _ = x[ER_KEY_PART_TYPE-18] + _ = x[ER_EXACT_MATCH-19] + _ = x[ER_INVALID_MSGPACK-20] + _ = x[ER_PROC_RET-21] + _ = x[ER_TUPLE_NOT_ARRAY-22] + _ = x[ER_FIELD_TYPE-23] + _ = x[ER_INDEX_PART_TYPE_MISMATCH-24] + _ = x[ER_UPDATE_SPLICE-25] + _ = x[ER_UPDATE_ARG_TYPE-26] + _ = x[ER_FORMAT_MISMATCH_INDEX_PART-27] + _ = x[ER_UNKNOWN_UPDATE_OP-28] + _ = x[ER_UPDATE_FIELD-29] + _ = x[ER_FUNCTION_TX_ACTIVE-30] + _ = x[ER_KEY_PART_COUNT-31] + _ = x[ER_PROC_LUA-32] + _ = x[ER_NO_SUCH_PROC-33] + _ = x[ER_NO_SUCH_TRIGGER-34] + _ = x[ER_NO_SUCH_INDEX_ID-35] + _ = x[ER_NO_SUCH_SPACE-36] + _ = x[ER_NO_SUCH_FIELD_NO-37] + _ = x[ER_EXACT_FIELD_COUNT-38] + _ = x[ER_FIELD_MISSING-39] + _ = x[ER_WAL_IO-40] + _ = x[ER_MORE_THAN_ONE_TUPLE-41] + _ = x[ER_ACCESS_DENIED-42] + _ = x[ER_CREATE_USER-43] + _ = x[ER_DROP_USER-44] + _ = x[ER_NO_SUCH_USER-45] + _ = x[ER_USER_EXISTS-46] + _ = x[ER_CREDS_MISMATCH-47] + _ = x[ER_UNKNOWN_REQUEST_TYPE-48] + _ = x[ER_UNKNOWN_SCHEMA_OBJECT-49] + _ = x[ER_CREATE_FUNCTION-50] + _ = x[ER_NO_SUCH_FUNCTION-51] + _ = x[ER_FUNCTION_EXISTS-52] + _ = x[ER_BEFORE_REPLACE_RET-53] + _ = x[ER_MULTISTATEMENT_TRANSACTION-54] + _ = x[ER_TRIGGER_EXISTS-55] + _ = x[ER_USER_MAX-56] + _ = x[ER_NO_SUCH_ENGINE-57] + _ = x[ER_RELOAD_CFG-58] + _ = x[ER_CFG-59] + _ = x[ER_SAVEPOINT_EMPTY_TX-60] + _ = x[ER_NO_SUCH_SAVEPOINT-61] + _ = x[ER_UNKNOWN_REPLICA-62] + _ = x[ER_REPLICASET_UUID_MISMATCH-63] + _ = x[ER_INVALID_UUID-64] + _ = x[ER_REPLICASET_UUID_IS_RO-65] + _ = x[ER_INSTANCE_UUID_MISMATCH-66] + _ = x[ER_REPLICA_ID_IS_RESERVED-67] + _ = x[ER_INVALID_ORDER-68] + _ = x[ER_MISSING_REQUEST_FIELD-69] + _ = x[ER_IDENTIFIER-70] + _ = x[ER_DROP_FUNCTION-71] + _ = x[ER_ITERATOR_TYPE-72] + _ = x[ER_REPLICA_MAX-73] + _ = x[ER_INVALID_XLOG-74] + _ = x[ER_INVALID_XLOG_NAME-75] + _ = x[ER_INVALID_XLOG_ORDER-76] + _ = x[ER_NO_CONNECTION-77] + _ = x[ER_TIMEOUT-78] + _ = x[ER_ACTIVE_TRANSACTION-79] + _ = x[ER_CURSOR_NO_TRANSACTION-80] + _ = x[ER_CROSS_ENGINE_TRANSACTION-81] + _ = x[ER_NO_SUCH_ROLE-82] + _ = x[ER_ROLE_EXISTS-83] + _ = x[ER_CREATE_ROLE-84] + _ = x[ER_INDEX_EXISTS-85] + _ = x[ER_SESSION_CLOSED-86] + _ = x[ER_ROLE_LOOP-87] + _ = x[ER_GRANT-88] + _ = x[ER_PRIV_GRANTED-89] + _ = x[ER_ROLE_GRANTED-90] + _ = x[ER_PRIV_NOT_GRANTED-91] + _ = x[ER_ROLE_NOT_GRANTED-92] + _ = x[ER_MISSING_SNAPSHOT-93] + _ = x[ER_CANT_UPDATE_PRIMARY_KEY-94] + _ = x[ER_UPDATE_INTEGER_OVERFLOW-95] + _ = x[ER_GUEST_USER_PASSWORD-96] + _ = x[ER_TRANSACTION_CONFLICT-97] + _ = x[ER_UNSUPPORTED_PRIV-98] + _ = x[ER_LOAD_FUNCTION-99] + _ = x[ER_FUNCTION_LANGUAGE-100] + _ = x[ER_RTREE_RECT-101] + _ = x[ER_PROC_C-102] + _ = x[ER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPE-103] + _ = x[ER_PROTOCOL-104] + _ = x[ER_UPSERT_UNIQUE_SECONDARY_KEY-105] + _ = x[ER_WRONG_INDEX_RECORD-106] + _ = x[ER_WRONG_INDEX_PARTS-107] + _ = x[ER_WRONG_INDEX_OPTIONS-108] + _ = x[ER_WRONG_SCHEMA_VERSION-109] + _ = x[ER_MEMTX_MAX_TUPLE_SIZE-110] + _ = x[ER_WRONG_SPACE_OPTIONS-111] + _ = x[ER_UNSUPPORTED_INDEX_FEATURE-112] + _ = x[ER_VIEW_IS_RO-113] + _ = x[ER_NO_TRANSACTION-114] + _ = x[ER_SYSTEM-115] + _ = x[ER_LOADING-116] + _ = x[ER_CONNECTION_TO_SELF-117] + _ = x[ER_KEY_PART_IS_TOO_LONG-118] + _ = x[ER_COMPRESSION-119] + _ = x[ER_CHECKPOINT_IN_PROGRESS-120] + _ = x[ER_SUB_STMT_MAX-121] + _ = x[ER_COMMIT_IN_SUB_STMT-122] + _ = x[ER_ROLLBACK_IN_SUB_STMT-123] + _ = x[ER_DECOMPRESSION-124] + _ = x[ER_INVALID_XLOG_TYPE-125] + _ = x[ER_ALREADY_RUNNING-126] + _ = x[ER_INDEX_FIELD_COUNT_LIMIT-127] + _ = x[ER_LOCAL_INSTANCE_ID_IS_READ_ONLY-128] + _ = x[ER_BACKUP_IN_PROGRESS-129] + _ = x[ER_READ_VIEW_ABORTED-130] + _ = x[ER_INVALID_INDEX_FILE-131] + _ = x[ER_INVALID_RUN_FILE-132] + _ = x[ER_INVALID_VYLOG_FILE-133] + _ = x[ER_CASCADE_ROLLBACK-134] + _ = x[ER_VY_QUOTA_TIMEOUT-135] + _ = x[ER_PARTIAL_KEY-136] + _ = x[ER_TRUNCATE_SYSTEM_SPACE-137] + _ = x[ER_LOAD_MODULE-138] + _ = x[ER_VINYL_MAX_TUPLE_SIZE-139] + _ = x[ER_WRONG_DD_VERSION-140] + _ = x[ER_WRONG_SPACE_FORMAT-141] + _ = x[ER_CREATE_SEQUENCE-142] + _ = x[ER_ALTER_SEQUENCE-143] + _ = x[ER_DROP_SEQUENCE-144] + _ = x[ER_NO_SUCH_SEQUENCE-145] + _ = x[ER_SEQUENCE_EXISTS-146] + _ = x[ER_SEQUENCE_OVERFLOW-147] + _ = x[ER_NO_SUCH_INDEX_NAME-148] + _ = x[ER_SPACE_FIELD_IS_DUPLICATE-149] + _ = x[ER_CANT_CREATE_COLLATION-150] + _ = x[ER_WRONG_COLLATION_OPTIONS-151] + _ = x[ER_NULLABLE_PRIMARY-152] + _ = x[ER_NO_SUCH_FIELD_NAME_IN_SPACE-153] + _ = x[ER_TRANSACTION_YIELD-154] + _ = x[ER_NO_SUCH_GROUP-155] + _ = x[ER_SQL_BIND_VALUE-156] + _ = x[ER_SQL_BIND_TYPE-157] + _ = x[ER_SQL_BIND_PARAMETER_MAX-158] + _ = x[ER_SQL_EXECUTE-159] + _ = x[ER_UPDATE_DECIMAL_OVERFLOW-160] + _ = x[ER_SQL_BIND_NOT_FOUND-161] + _ = x[ER_ACTION_MISMATCH-162] + _ = x[ER_VIEW_MISSING_SQL-163] + _ = x[ER_FOREIGN_KEY_CONSTRAINT-164] + _ = x[ER_NO_SUCH_MODULE-165] + _ = x[ER_NO_SUCH_COLLATION-166] + _ = x[ER_CREATE_FK_CONSTRAINT-167] + _ = x[ER_DROP_FK_CONSTRAINT-168] + _ = x[ER_NO_SUCH_CONSTRAINT-169] + _ = x[ER_CONSTRAINT_EXISTS-170] + _ = x[ER_SQL_TYPE_MISMATCH-171] + _ = x[ER_ROWID_OVERFLOW-172] + _ = x[ER_DROP_COLLATION-173] + _ = x[ER_ILLEGAL_COLLATION_MIX-174] + _ = x[ER_SQL_NO_SUCH_PRAGMA-175] + _ = x[ER_SQL_CANT_RESOLVE_FIELD-176] + _ = x[ER_INDEX_EXISTS_IN_SPACE-177] + _ = x[ER_INCONSISTENT_TYPES-178] + _ = x[ER_SQL_SYNTAX_WITH_POS-179] + _ = x[ER_SQL_STACK_OVERFLOW-180] + _ = x[ER_SQL_SELECT_WILDCARD-181] + _ = x[ER_SQL_STATEMENT_EMPTY-182] + _ = x[ER_SQL_KEYWORD_IS_RESERVED-183] + _ = x[ER_SQL_SYNTAX_NEAR_TOKEN-184] + _ = x[ER_SQL_UNKNOWN_TOKEN-185] + _ = x[ER_SQL_PARSER_GENERIC-186] + _ = x[ER_SQL_ANALYZE_ARGUMENT-187] + _ = x[ER_SQL_COLUMN_COUNT_MAX-188] + _ = x[ER_HEX_LITERAL_MAX-189] + _ = x[ER_INT_LITERAL_MAX-190] + _ = x[ER_SQL_PARSER_LIMIT-191] + _ = x[ER_INDEX_DEF_UNSUPPORTED-192] + _ = x[ER_CK_DEF_UNSUPPORTED-193] + _ = x[ER_MULTIKEY_INDEX_MISMATCH-194] + _ = x[ER_CREATE_CK_CONSTRAINT-195] + _ = x[ER_CK_CONSTRAINT_FAILED-196] + _ = x[ER_SQL_COLUMN_COUNT-197] + _ = x[ER_FUNC_INDEX_FUNC-198] + _ = x[ER_FUNC_INDEX_FORMAT-199] + _ = x[ER_FUNC_INDEX_PARTS-200] + _ = x[ER_NO_SUCH_FIELD_NAME-201] + _ = x[ER_FUNC_WRONG_ARG_COUNT-202] + _ = x[ER_BOOTSTRAP_READONLY-203] + _ = x[ER_SQL_FUNC_WRONG_RET_COUNT-204] + _ = x[ER_FUNC_INVALID_RETURN_TYPE-205] + _ = x[ER_SQL_PARSER_GENERIC_WITH_POS-206] + _ = x[ER_REPLICA_NOT_ANON-207] + _ = x[ER_CANNOT_REGISTER-208] + _ = x[ER_SESSION_SETTING_INVALID_VALUE-209] + _ = x[ER_SQL_PREPARE-210] + _ = x[ER_WRONG_QUERY_ID-211] + _ = x[ER_SEQUENCE_NOT_STARTED-212] + _ = x[ER_NO_SUCH_SESSION_SETTING-213] + _ = x[ER_UNCOMMITTED_FOREIGN_SYNC_TXNS-214] + _ = x[ER_SYNC_MASTER_MISMATCH-215] + _ = x[ER_SYNC_QUORUM_TIMEOUT-216] + _ = x[ER_SYNC_ROLLBACK-217] + _ = x[ER_TUPLE_METADATA_IS_TOO_BIG-218] + _ = x[ER_XLOG_GAP-219] + _ = x[ER_TOO_EARLY_SUBSCRIBE-220] + _ = x[ER_SQL_CANT_ADD_AUTOINC-221] + _ = x[ER_QUORUM_WAIT-222] + _ = x[ER_INTERFERING_PROMOTE-223] + _ = x[ER_ELECTION_DISABLED-224] + _ = x[ER_TXN_ROLLBACK-225] + _ = x[ER_NOT_LEADER-226] + _ = x[ER_SYNC_QUEUE_UNCLAIMED-227] + _ = x[ER_SYNC_QUEUE_FOREIGN-228] + _ = x[ER_UNABLE_TO_PROCESS_IN_STREAM-229] + _ = x[ER_UNABLE_TO_PROCESS_OUT_OF_STREAM-230] + _ = x[ER_TRANSACTION_TIMEOUT-231] + _ = x[ER_ACTIVE_TIMER-232] + _ = x[ER_TUPLE_FIELD_COUNT_LIMIT-233] + _ = x[ER_CREATE_CONSTRAINT-234] + _ = x[ER_FIELD_CONSTRAINT_FAILED-235] + _ = x[ER_TUPLE_CONSTRAINT_FAILED-236] + _ = x[ER_CREATE_FOREIGN_KEY-237] + _ = x[ER_FOREIGN_KEY_INTEGRITY-238] + _ = x[ER_FIELD_FOREIGN_KEY_FAILED-239] + _ = x[ER_COMPLEX_FOREIGN_KEY_FAILED-240] + _ = x[ER_WRONG_SPACE_UPGRADE_OPTIONS-241] + _ = x[ER_NO_ELECTION_QUORUM-242] + _ = x[ER_SSL-243] + _ = x[ER_SPLIT_BRAIN-244] + _ = x[ER_OLD_TERM-245] + _ = x[ER_INTERFERING_ELECTIONS-246] + _ = x[ER_ITERATOR_POSITION-247] + _ = x[ER_UNUSED-248] + _ = x[ER_UNKNOWN_AUTH_METHOD-249] + _ = x[ER_INVALID_AUTH_DATA-250] + _ = x[ER_INVALID_AUTH_REQUEST-251] + _ = x[ER_WEAK_PASSWORD-252] + _ = x[ER_OLD_PASSWORD-253] + _ = x[ER_NO_SUCH_SESSION-254] + _ = x[ER_WRONG_SESSION_TYPE-255] + _ = x[ER_PASSWORD_EXPIRED-256] + _ = x[ER_AUTH_DELAY-257] + _ = x[ER_AUTH_REQUIRED-258] + _ = x[ER_SQL_SEQ_SCAN-259] + _ = x[ER_NO_SUCH_EVENT-260] + _ = x[ER_BOOTSTRAP_NOT_UNANIMOUS-261] + _ = x[ER_CANT_CHECK_BOOTSTRAP_LEADER-262] + _ = x[ER_BOOTSTRAP_CONNECTION_NOT_TO_ALL-263] + _ = x[ER_NIL_UUID-264] + _ = x[ER_WRONG_FUNCTION_OPTIONS-265] + _ = x[ER_MISSING_SYSTEM_SPACES-266] +} + +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" + +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} + +func (i Error) String() string { + if i < 0 || i >= Error(len(_Error_index)-1) { + return "Error(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Error_name[_Error_index[i]:_Error_index[i+1]] +} diff --git a/error_test.go b/error_test.go new file mode 100644 index 0000000..f974e94 --- /dev/null +++ b/error_test.go @@ -0,0 +1,295 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto_test + +import ( + "testing" + + "github.com/tarantool/go-iproto" +) + +func TestError(t *testing.T) { + cases := []struct { + Err iproto.Error + Str string + }{ + {iproto.ER_UNKNOWN, "ER_UNKNOWN"}, + {iproto.ER_ILLEGAL_PARAMS, "ER_ILLEGAL_PARAMS"}, + {iproto.ER_MEMORY_ISSUE, "ER_MEMORY_ISSUE"}, + {iproto.ER_TUPLE_FOUND, "ER_TUPLE_FOUND"}, + {iproto.ER_TUPLE_NOT_FOUND, "ER_TUPLE_NOT_FOUND"}, + {iproto.ER_UNSUPPORTED, "ER_UNSUPPORTED"}, + {iproto.ER_NONMASTER, "ER_NONMASTER"}, + {iproto.ER_READONLY, "ER_READONLY"}, + {iproto.ER_INJECTION, "ER_INJECTION"}, + {iproto.ER_CREATE_SPACE, "ER_CREATE_SPACE"}, + {iproto.ER_SPACE_EXISTS, "ER_SPACE_EXISTS"}, + {iproto.ER_DROP_SPACE, "ER_DROP_SPACE"}, + {iproto.ER_ALTER_SPACE, "ER_ALTER_SPACE"}, + {iproto.ER_INDEX_TYPE, "ER_INDEX_TYPE"}, + {iproto.ER_MODIFY_INDEX, "ER_MODIFY_INDEX"}, + {iproto.ER_LAST_DROP, "ER_LAST_DROP"}, + {iproto.ER_TUPLE_FORMAT_LIMIT, "ER_TUPLE_FORMAT_LIMIT"}, + {iproto.ER_DROP_PRIMARY_KEY, "ER_DROP_PRIMARY_KEY"}, + {iproto.ER_KEY_PART_TYPE, "ER_KEY_PART_TYPE"}, + {iproto.ER_EXACT_MATCH, "ER_EXACT_MATCH"}, + {iproto.ER_INVALID_MSGPACK, "ER_INVALID_MSGPACK"}, + {iproto.ER_PROC_RET, "ER_PROC_RET"}, + {iproto.ER_TUPLE_NOT_ARRAY, "ER_TUPLE_NOT_ARRAY"}, + {iproto.ER_FIELD_TYPE, "ER_FIELD_TYPE"}, + {iproto.ER_INDEX_PART_TYPE_MISMATCH, "ER_INDEX_PART_TYPE_MISMATCH"}, + {iproto.ER_UPDATE_SPLICE, "ER_UPDATE_SPLICE"}, + {iproto.ER_UPDATE_ARG_TYPE, "ER_UPDATE_ARG_TYPE"}, + {iproto.ER_FORMAT_MISMATCH_INDEX_PART, "ER_FORMAT_MISMATCH_INDEX_PART"}, + {iproto.ER_UNKNOWN_UPDATE_OP, "ER_UNKNOWN_UPDATE_OP"}, + {iproto.ER_UPDATE_FIELD, "ER_UPDATE_FIELD"}, + {iproto.ER_FUNCTION_TX_ACTIVE, "ER_FUNCTION_TX_ACTIVE"}, + {iproto.ER_KEY_PART_COUNT, "ER_KEY_PART_COUNT"}, + {iproto.ER_PROC_LUA, "ER_PROC_LUA"}, + {iproto.ER_NO_SUCH_PROC, "ER_NO_SUCH_PROC"}, + {iproto.ER_NO_SUCH_TRIGGER, "ER_NO_SUCH_TRIGGER"}, + {iproto.ER_NO_SUCH_INDEX_ID, "ER_NO_SUCH_INDEX_ID"}, + {iproto.ER_NO_SUCH_SPACE, "ER_NO_SUCH_SPACE"}, + {iproto.ER_NO_SUCH_FIELD_NO, "ER_NO_SUCH_FIELD_NO"}, + {iproto.ER_EXACT_FIELD_COUNT, "ER_EXACT_FIELD_COUNT"}, + {iproto.ER_FIELD_MISSING, "ER_FIELD_MISSING"}, + {iproto.ER_WAL_IO, "ER_WAL_IO"}, + {iproto.ER_MORE_THAN_ONE_TUPLE, "ER_MORE_THAN_ONE_TUPLE"}, + {iproto.ER_ACCESS_DENIED, "ER_ACCESS_DENIED"}, + {iproto.ER_CREATE_USER, "ER_CREATE_USER"}, + {iproto.ER_DROP_USER, "ER_DROP_USER"}, + {iproto.ER_NO_SUCH_USER, "ER_NO_SUCH_USER"}, + {iproto.ER_USER_EXISTS, "ER_USER_EXISTS"}, + {iproto.ER_CREDS_MISMATCH, "ER_CREDS_MISMATCH"}, + {iproto.ER_UNKNOWN_REQUEST_TYPE, "ER_UNKNOWN_REQUEST_TYPE"}, + {iproto.ER_UNKNOWN_SCHEMA_OBJECT, "ER_UNKNOWN_SCHEMA_OBJECT"}, + {iproto.ER_CREATE_FUNCTION, "ER_CREATE_FUNCTION"}, + {iproto.ER_NO_SUCH_FUNCTION, "ER_NO_SUCH_FUNCTION"}, + {iproto.ER_FUNCTION_EXISTS, "ER_FUNCTION_EXISTS"}, + {iproto.ER_BEFORE_REPLACE_RET, "ER_BEFORE_REPLACE_RET"}, + {iproto.ER_MULTISTATEMENT_TRANSACTION, "ER_MULTISTATEMENT_TRANSACTION"}, + {iproto.ER_TRIGGER_EXISTS, "ER_TRIGGER_EXISTS"}, + {iproto.ER_USER_MAX, "ER_USER_MAX"}, + {iproto.ER_NO_SUCH_ENGINE, "ER_NO_SUCH_ENGINE"}, + {iproto.ER_RELOAD_CFG, "ER_RELOAD_CFG"}, + {iproto.ER_CFG, "ER_CFG"}, + {iproto.ER_SAVEPOINT_EMPTY_TX, "ER_SAVEPOINT_EMPTY_TX"}, + {iproto.ER_NO_SUCH_SAVEPOINT, "ER_NO_SUCH_SAVEPOINT"}, + {iproto.ER_UNKNOWN_REPLICA, "ER_UNKNOWN_REPLICA"}, + {iproto.ER_REPLICASET_UUID_MISMATCH, "ER_REPLICASET_UUID_MISMATCH"}, + {iproto.ER_INVALID_UUID, "ER_INVALID_UUID"}, + {iproto.ER_REPLICASET_UUID_IS_RO, "ER_REPLICASET_UUID_IS_RO"}, + {iproto.ER_INSTANCE_UUID_MISMATCH, "ER_INSTANCE_UUID_MISMATCH"}, + {iproto.ER_REPLICA_ID_IS_RESERVED, "ER_REPLICA_ID_IS_RESERVED"}, + {iproto.ER_INVALID_ORDER, "ER_INVALID_ORDER"}, + {iproto.ER_MISSING_REQUEST_FIELD, "ER_MISSING_REQUEST_FIELD"}, + {iproto.ER_IDENTIFIER, "ER_IDENTIFIER"}, + {iproto.ER_DROP_FUNCTION, "ER_DROP_FUNCTION"}, + {iproto.ER_ITERATOR_TYPE, "ER_ITERATOR_TYPE"}, + {iproto.ER_REPLICA_MAX, "ER_REPLICA_MAX"}, + {iproto.ER_INVALID_XLOG, "ER_INVALID_XLOG"}, + {iproto.ER_INVALID_XLOG_NAME, "ER_INVALID_XLOG_NAME"}, + {iproto.ER_INVALID_XLOG_ORDER, "ER_INVALID_XLOG_ORDER"}, + {iproto.ER_NO_CONNECTION, "ER_NO_CONNECTION"}, + {iproto.ER_TIMEOUT, "ER_TIMEOUT"}, + {iproto.ER_ACTIVE_TRANSACTION, "ER_ACTIVE_TRANSACTION"}, + {iproto.ER_CURSOR_NO_TRANSACTION, "ER_CURSOR_NO_TRANSACTION"}, + {iproto.ER_CROSS_ENGINE_TRANSACTION, "ER_CROSS_ENGINE_TRANSACTION"}, + {iproto.ER_NO_SUCH_ROLE, "ER_NO_SUCH_ROLE"}, + {iproto.ER_ROLE_EXISTS, "ER_ROLE_EXISTS"}, + {iproto.ER_CREATE_ROLE, "ER_CREATE_ROLE"}, + {iproto.ER_INDEX_EXISTS, "ER_INDEX_EXISTS"}, + {iproto.ER_SESSION_CLOSED, "ER_SESSION_CLOSED"}, + {iproto.ER_ROLE_LOOP, "ER_ROLE_LOOP"}, + {iproto.ER_GRANT, "ER_GRANT"}, + {iproto.ER_PRIV_GRANTED, "ER_PRIV_GRANTED"}, + {iproto.ER_ROLE_GRANTED, "ER_ROLE_GRANTED"}, + {iproto.ER_PRIV_NOT_GRANTED, "ER_PRIV_NOT_GRANTED"}, + {iproto.ER_ROLE_NOT_GRANTED, "ER_ROLE_NOT_GRANTED"}, + {iproto.ER_MISSING_SNAPSHOT, "ER_MISSING_SNAPSHOT"}, + {iproto.ER_CANT_UPDATE_PRIMARY_KEY, "ER_CANT_UPDATE_PRIMARY_KEY"}, + {iproto.ER_UPDATE_INTEGER_OVERFLOW, "ER_UPDATE_INTEGER_OVERFLOW"}, + {iproto.ER_GUEST_USER_PASSWORD, "ER_GUEST_USER_PASSWORD"}, + {iproto.ER_TRANSACTION_CONFLICT, "ER_TRANSACTION_CONFLICT"}, + {iproto.ER_UNSUPPORTED_PRIV, "ER_UNSUPPORTED_PRIV"}, + {iproto.ER_LOAD_FUNCTION, "ER_LOAD_FUNCTION"}, + {iproto.ER_FUNCTION_LANGUAGE, "ER_FUNCTION_LANGUAGE"}, + {iproto.ER_RTREE_RECT, "ER_RTREE_RECT"}, + {iproto.ER_PROC_C, "ER_PROC_C"}, + {iproto.ER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPE, "ER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPE"}, + {iproto.ER_PROTOCOL, "ER_PROTOCOL"}, + {iproto.ER_UPSERT_UNIQUE_SECONDARY_KEY, "ER_UPSERT_UNIQUE_SECONDARY_KEY"}, + {iproto.ER_WRONG_INDEX_RECORD, "ER_WRONG_INDEX_RECORD"}, + {iproto.ER_WRONG_INDEX_PARTS, "ER_WRONG_INDEX_PARTS"}, + {iproto.ER_WRONG_INDEX_OPTIONS, "ER_WRONG_INDEX_OPTIONS"}, + {iproto.ER_WRONG_SCHEMA_VERSION, "ER_WRONG_SCHEMA_VERSION"}, + {iproto.ER_MEMTX_MAX_TUPLE_SIZE, "ER_MEMTX_MAX_TUPLE_SIZE"}, + {iproto.ER_WRONG_SPACE_OPTIONS, "ER_WRONG_SPACE_OPTIONS"}, + {iproto.ER_UNSUPPORTED_INDEX_FEATURE, "ER_UNSUPPORTED_INDEX_FEATURE"}, + {iproto.ER_VIEW_IS_RO, "ER_VIEW_IS_RO"}, + {iproto.ER_NO_TRANSACTION, "ER_NO_TRANSACTION"}, + {iproto.ER_SYSTEM, "ER_SYSTEM"}, + {iproto.ER_LOADING, "ER_LOADING"}, + {iproto.ER_CONNECTION_TO_SELF, "ER_CONNECTION_TO_SELF"}, + {iproto.ER_KEY_PART_IS_TOO_LONG, "ER_KEY_PART_IS_TOO_LONG"}, + {iproto.ER_COMPRESSION, "ER_COMPRESSION"}, + {iproto.ER_CHECKPOINT_IN_PROGRESS, "ER_CHECKPOINT_IN_PROGRESS"}, + {iproto.ER_SUB_STMT_MAX, "ER_SUB_STMT_MAX"}, + {iproto.ER_COMMIT_IN_SUB_STMT, "ER_COMMIT_IN_SUB_STMT"}, + {iproto.ER_ROLLBACK_IN_SUB_STMT, "ER_ROLLBACK_IN_SUB_STMT"}, + {iproto.ER_DECOMPRESSION, "ER_DECOMPRESSION"}, + {iproto.ER_INVALID_XLOG_TYPE, "ER_INVALID_XLOG_TYPE"}, + {iproto.ER_ALREADY_RUNNING, "ER_ALREADY_RUNNING"}, + {iproto.ER_INDEX_FIELD_COUNT_LIMIT, "ER_INDEX_FIELD_COUNT_LIMIT"}, + {iproto.ER_LOCAL_INSTANCE_ID_IS_READ_ONLY, "ER_LOCAL_INSTANCE_ID_IS_READ_ONLY"}, + {iproto.ER_BACKUP_IN_PROGRESS, "ER_BACKUP_IN_PROGRESS"}, + {iproto.ER_READ_VIEW_ABORTED, "ER_READ_VIEW_ABORTED"}, + {iproto.ER_INVALID_INDEX_FILE, "ER_INVALID_INDEX_FILE"}, + {iproto.ER_INVALID_RUN_FILE, "ER_INVALID_RUN_FILE"}, + {iproto.ER_INVALID_VYLOG_FILE, "ER_INVALID_VYLOG_FILE"}, + {iproto.ER_CASCADE_ROLLBACK, "ER_CASCADE_ROLLBACK"}, + {iproto.ER_VY_QUOTA_TIMEOUT, "ER_VY_QUOTA_TIMEOUT"}, + {iproto.ER_PARTIAL_KEY, "ER_PARTIAL_KEY"}, + {iproto.ER_TRUNCATE_SYSTEM_SPACE, "ER_TRUNCATE_SYSTEM_SPACE"}, + {iproto.ER_LOAD_MODULE, "ER_LOAD_MODULE"}, + {iproto.ER_VINYL_MAX_TUPLE_SIZE, "ER_VINYL_MAX_TUPLE_SIZE"}, + {iproto.ER_WRONG_DD_VERSION, "ER_WRONG_DD_VERSION"}, + {iproto.ER_WRONG_SPACE_FORMAT, "ER_WRONG_SPACE_FORMAT"}, + {iproto.ER_CREATE_SEQUENCE, "ER_CREATE_SEQUENCE"}, + {iproto.ER_ALTER_SEQUENCE, "ER_ALTER_SEQUENCE"}, + {iproto.ER_DROP_SEQUENCE, "ER_DROP_SEQUENCE"}, + {iproto.ER_NO_SUCH_SEQUENCE, "ER_NO_SUCH_SEQUENCE"}, + {iproto.ER_SEQUENCE_EXISTS, "ER_SEQUENCE_EXISTS"}, + {iproto.ER_SEQUENCE_OVERFLOW, "ER_SEQUENCE_OVERFLOW"}, + {iproto.ER_NO_SUCH_INDEX_NAME, "ER_NO_SUCH_INDEX_NAME"}, + {iproto.ER_SPACE_FIELD_IS_DUPLICATE, "ER_SPACE_FIELD_IS_DUPLICATE"}, + {iproto.ER_CANT_CREATE_COLLATION, "ER_CANT_CREATE_COLLATION"}, + {iproto.ER_WRONG_COLLATION_OPTIONS, "ER_WRONG_COLLATION_OPTIONS"}, + {iproto.ER_NULLABLE_PRIMARY, "ER_NULLABLE_PRIMARY"}, + {iproto.ER_NO_SUCH_FIELD_NAME_IN_SPACE, "ER_NO_SUCH_FIELD_NAME_IN_SPACE"}, + {iproto.ER_TRANSACTION_YIELD, "ER_TRANSACTION_YIELD"}, + {iproto.ER_NO_SUCH_GROUP, "ER_NO_SUCH_GROUP"}, + {iproto.ER_SQL_BIND_VALUE, "ER_SQL_BIND_VALUE"}, + {iproto.ER_SQL_BIND_TYPE, "ER_SQL_BIND_TYPE"}, + {iproto.ER_SQL_BIND_PARAMETER_MAX, "ER_SQL_BIND_PARAMETER_MAX"}, + {iproto.ER_SQL_EXECUTE, "ER_SQL_EXECUTE"}, + {iproto.ER_UPDATE_DECIMAL_OVERFLOW, "ER_UPDATE_DECIMAL_OVERFLOW"}, + {iproto.ER_SQL_BIND_NOT_FOUND, "ER_SQL_BIND_NOT_FOUND"}, + {iproto.ER_ACTION_MISMATCH, "ER_ACTION_MISMATCH"}, + {iproto.ER_VIEW_MISSING_SQL, "ER_VIEW_MISSING_SQL"}, + {iproto.ER_FOREIGN_KEY_CONSTRAINT, "ER_FOREIGN_KEY_CONSTRAINT"}, + {iproto.ER_NO_SUCH_MODULE, "ER_NO_SUCH_MODULE"}, + {iproto.ER_NO_SUCH_COLLATION, "ER_NO_SUCH_COLLATION"}, + {iproto.ER_CREATE_FK_CONSTRAINT, "ER_CREATE_FK_CONSTRAINT"}, + {iproto.ER_DROP_FK_CONSTRAINT, "ER_DROP_FK_CONSTRAINT"}, + {iproto.ER_NO_SUCH_CONSTRAINT, "ER_NO_SUCH_CONSTRAINT"}, + {iproto.ER_CONSTRAINT_EXISTS, "ER_CONSTRAINT_EXISTS"}, + {iproto.ER_SQL_TYPE_MISMATCH, "ER_SQL_TYPE_MISMATCH"}, + {iproto.ER_ROWID_OVERFLOW, "ER_ROWID_OVERFLOW"}, + {iproto.ER_DROP_COLLATION, "ER_DROP_COLLATION"}, + {iproto.ER_ILLEGAL_COLLATION_MIX, "ER_ILLEGAL_COLLATION_MIX"}, + {iproto.ER_SQL_NO_SUCH_PRAGMA, "ER_SQL_NO_SUCH_PRAGMA"}, + {iproto.ER_SQL_CANT_RESOLVE_FIELD, "ER_SQL_CANT_RESOLVE_FIELD"}, + {iproto.ER_INDEX_EXISTS_IN_SPACE, "ER_INDEX_EXISTS_IN_SPACE"}, + {iproto.ER_INCONSISTENT_TYPES, "ER_INCONSISTENT_TYPES"}, + {iproto.ER_SQL_SYNTAX_WITH_POS, "ER_SQL_SYNTAX_WITH_POS"}, + {iproto.ER_SQL_STACK_OVERFLOW, "ER_SQL_STACK_OVERFLOW"}, + {iproto.ER_SQL_SELECT_WILDCARD, "ER_SQL_SELECT_WILDCARD"}, + {iproto.ER_SQL_STATEMENT_EMPTY, "ER_SQL_STATEMENT_EMPTY"}, + {iproto.ER_SQL_KEYWORD_IS_RESERVED, "ER_SQL_KEYWORD_IS_RESERVED"}, + {iproto.ER_SQL_SYNTAX_NEAR_TOKEN, "ER_SQL_SYNTAX_NEAR_TOKEN"}, + {iproto.ER_SQL_UNKNOWN_TOKEN, "ER_SQL_UNKNOWN_TOKEN"}, + {iproto.ER_SQL_PARSER_GENERIC, "ER_SQL_PARSER_GENERIC"}, + {iproto.ER_SQL_ANALYZE_ARGUMENT, "ER_SQL_ANALYZE_ARGUMENT"}, + {iproto.ER_SQL_COLUMN_COUNT_MAX, "ER_SQL_COLUMN_COUNT_MAX"}, + {iproto.ER_HEX_LITERAL_MAX, "ER_HEX_LITERAL_MAX"}, + {iproto.ER_INT_LITERAL_MAX, "ER_INT_LITERAL_MAX"}, + {iproto.ER_SQL_PARSER_LIMIT, "ER_SQL_PARSER_LIMIT"}, + {iproto.ER_INDEX_DEF_UNSUPPORTED, "ER_INDEX_DEF_UNSUPPORTED"}, + {iproto.ER_CK_DEF_UNSUPPORTED, "ER_CK_DEF_UNSUPPORTED"}, + {iproto.ER_MULTIKEY_INDEX_MISMATCH, "ER_MULTIKEY_INDEX_MISMATCH"}, + {iproto.ER_CREATE_CK_CONSTRAINT, "ER_CREATE_CK_CONSTRAINT"}, + {iproto.ER_CK_CONSTRAINT_FAILED, "ER_CK_CONSTRAINT_FAILED"}, + {iproto.ER_SQL_COLUMN_COUNT, "ER_SQL_COLUMN_COUNT"}, + {iproto.ER_FUNC_INDEX_FUNC, "ER_FUNC_INDEX_FUNC"}, + {iproto.ER_FUNC_INDEX_FORMAT, "ER_FUNC_INDEX_FORMAT"}, + {iproto.ER_FUNC_INDEX_PARTS, "ER_FUNC_INDEX_PARTS"}, + {iproto.ER_NO_SUCH_FIELD_NAME, "ER_NO_SUCH_FIELD_NAME"}, + {iproto.ER_FUNC_WRONG_ARG_COUNT, "ER_FUNC_WRONG_ARG_COUNT"}, + {iproto.ER_BOOTSTRAP_READONLY, "ER_BOOTSTRAP_READONLY"}, + {iproto.ER_SQL_FUNC_WRONG_RET_COUNT, "ER_SQL_FUNC_WRONG_RET_COUNT"}, + {iproto.ER_FUNC_INVALID_RETURN_TYPE, "ER_FUNC_INVALID_RETURN_TYPE"}, + {iproto.ER_SQL_PARSER_GENERIC_WITH_POS, "ER_SQL_PARSER_GENERIC_WITH_POS"}, + {iproto.ER_REPLICA_NOT_ANON, "ER_REPLICA_NOT_ANON"}, + {iproto.ER_CANNOT_REGISTER, "ER_CANNOT_REGISTER"}, + {iproto.ER_SESSION_SETTING_INVALID_VALUE, "ER_SESSION_SETTING_INVALID_VALUE"}, + {iproto.ER_SQL_PREPARE, "ER_SQL_PREPARE"}, + {iproto.ER_WRONG_QUERY_ID, "ER_WRONG_QUERY_ID"}, + {iproto.ER_SEQUENCE_NOT_STARTED, "ER_SEQUENCE_NOT_STARTED"}, + {iproto.ER_NO_SUCH_SESSION_SETTING, "ER_NO_SUCH_SESSION_SETTING"}, + {iproto.ER_UNCOMMITTED_FOREIGN_SYNC_TXNS, "ER_UNCOMMITTED_FOREIGN_SYNC_TXNS"}, + {iproto.ER_SYNC_MASTER_MISMATCH, "ER_SYNC_MASTER_MISMATCH"}, + {iproto.ER_SYNC_QUORUM_TIMEOUT, "ER_SYNC_QUORUM_TIMEOUT"}, + {iproto.ER_SYNC_ROLLBACK, "ER_SYNC_ROLLBACK"}, + {iproto.ER_TUPLE_METADATA_IS_TOO_BIG, "ER_TUPLE_METADATA_IS_TOO_BIG"}, + {iproto.ER_XLOG_GAP, "ER_XLOG_GAP"}, + {iproto.ER_TOO_EARLY_SUBSCRIBE, "ER_TOO_EARLY_SUBSCRIBE"}, + {iproto.ER_SQL_CANT_ADD_AUTOINC, "ER_SQL_CANT_ADD_AUTOINC"}, + {iproto.ER_QUORUM_WAIT, "ER_QUORUM_WAIT"}, + {iproto.ER_INTERFERING_PROMOTE, "ER_INTERFERING_PROMOTE"}, + {iproto.ER_ELECTION_DISABLED, "ER_ELECTION_DISABLED"}, + {iproto.ER_TXN_ROLLBACK, "ER_TXN_ROLLBACK"}, + {iproto.ER_NOT_LEADER, "ER_NOT_LEADER"}, + {iproto.ER_SYNC_QUEUE_UNCLAIMED, "ER_SYNC_QUEUE_UNCLAIMED"}, + {iproto.ER_SYNC_QUEUE_FOREIGN, "ER_SYNC_QUEUE_FOREIGN"}, + {iproto.ER_UNABLE_TO_PROCESS_IN_STREAM, "ER_UNABLE_TO_PROCESS_IN_STREAM"}, + {iproto.ER_UNABLE_TO_PROCESS_OUT_OF_STREAM, "ER_UNABLE_TO_PROCESS_OUT_OF_STREAM"}, + {iproto.ER_TRANSACTION_TIMEOUT, "ER_TRANSACTION_TIMEOUT"}, + {iproto.ER_ACTIVE_TIMER, "ER_ACTIVE_TIMER"}, + {iproto.ER_TUPLE_FIELD_COUNT_LIMIT, "ER_TUPLE_FIELD_COUNT_LIMIT"}, + {iproto.ER_CREATE_CONSTRAINT, "ER_CREATE_CONSTRAINT"}, + {iproto.ER_FIELD_CONSTRAINT_FAILED, "ER_FIELD_CONSTRAINT_FAILED"}, + {iproto.ER_TUPLE_CONSTRAINT_FAILED, "ER_TUPLE_CONSTRAINT_FAILED"}, + {iproto.ER_CREATE_FOREIGN_KEY, "ER_CREATE_FOREIGN_KEY"}, + {iproto.ER_FOREIGN_KEY_INTEGRITY, "ER_FOREIGN_KEY_INTEGRITY"}, + {iproto.ER_FIELD_FOREIGN_KEY_FAILED, "ER_FIELD_FOREIGN_KEY_FAILED"}, + {iproto.ER_COMPLEX_FOREIGN_KEY_FAILED, "ER_COMPLEX_FOREIGN_KEY_FAILED"}, + {iproto.ER_WRONG_SPACE_UPGRADE_OPTIONS, "ER_WRONG_SPACE_UPGRADE_OPTIONS"}, + {iproto.ER_NO_ELECTION_QUORUM, "ER_NO_ELECTION_QUORUM"}, + {iproto.ER_SSL, "ER_SSL"}, + {iproto.ER_SPLIT_BRAIN, "ER_SPLIT_BRAIN"}, + {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_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"}, + {iproto.ER_WEAK_PASSWORD, "ER_WEAK_PASSWORD"}, + {iproto.ER_OLD_PASSWORD, "ER_OLD_PASSWORD"}, + {iproto.ER_NO_SUCH_SESSION, "ER_NO_SUCH_SESSION"}, + {iproto.ER_WRONG_SESSION_TYPE, "ER_WRONG_SESSION_TYPE"}, + {iproto.ER_PASSWORD_EXPIRED, "ER_PASSWORD_EXPIRED"}, + {iproto.ER_AUTH_DELAY, "ER_AUTH_DELAY"}, + {iproto.ER_AUTH_REQUIRED, "ER_AUTH_REQUIRED"}, + {iproto.ER_SQL_SEQ_SCAN, "ER_SQL_SEQ_SCAN"}, + {iproto.ER_NO_SUCH_EVENT, "ER_NO_SUCH_EVENT"}, + {iproto.ER_BOOTSTRAP_NOT_UNANIMOUS, "ER_BOOTSTRAP_NOT_UNANIMOUS"}, + {iproto.ER_CANT_CHECK_BOOTSTRAP_LEADER, "ER_CANT_CHECK_BOOTSTRAP_LEADER"}, + {iproto.ER_BOOTSTRAP_CONNECTION_NOT_TO_ALL, "ER_BOOTSTRAP_CONNECTION_NOT_TO_ALL"}, + {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"}, + } + + for i, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.Err.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.Err.String(), tc.Str) + } + if int(tc.Err) != i { + t.Errorf("Got %d, expected %d", tc.Err, i) + } + }) + } +} diff --git a/example_test.go b/example_test.go new file mode 100644 index 0000000..5adf8cf --- /dev/null +++ b/example_test.go @@ -0,0 +1,21 @@ +package iproto_test + +import ( + "fmt" + + "github.com/tarantool/go-iproto" +) + +func Example() { + fmt.Printf("%s=%d\n", iproto.ER_READONLY, iproto.ER_READONLY) + fmt.Printf("%s=%d\n", iproto.IPROTO_FEATURE_WATCHERS, iproto.IPROTO_FEATURE_WATCHERS) + fmt.Printf("%s=%d\n", iproto.IPROTO_FLAG_COMMIT, iproto.IPROTO_FLAG_COMMIT) + fmt.Printf("%s=%d\n", iproto.IPROTO_SYNC, iproto.IPROTO_SYNC) + fmt.Printf("%s=%d\n", iproto.IPROTO_SELECT, iproto.IPROTO_SELECT) + // Output: + // ER_READONLY=7 + // IPROTO_FEATURE_WATCHERS=3 + // IPROTO_FLAG_COMMIT=1 + // IPROTO_SYNC=1 + // IPROTO_SELECT=1 +} diff --git a/feature.go b/feature.go new file mode 100644 index 0000000..aba2b03 --- /dev/null +++ b/feature.go @@ -0,0 +1,32 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto + +// IPROTO feature constants, generated from +// tarantool/src/box/iproto_features.h +type Feature int + +const ( + // Streams support: IPROTO_STREAM_ID header key. + IPROTO_FEATURE_STREAMS Feature = 0 + // Transactions in the protocol: + // IPROTO_BEGIN, IPROTO_COMMIT, IPROTO_ROLLBACK commands. + IPROTO_FEATURE_TRANSACTIONS Feature = 1 + // MP_ERROR MsgPack extension support. + // + // If a client doesn't set this feature bit, then errors returned by + // CALL/EVAL commands will be encoded according to the serialization + // rules for generic cdata/userdata Lua objects irrespective of the + // value of the msgpack.cfg.encode_errors_as_ext flag (by default + // converted to a string error message). If the feature bit is set and + // encode_errors_as_ext is true, errors will be encoded as MP_ERROR + // MsgPack extension. + IPROTO_FEATURE_ERROR_EXTENSION Feature = 2 + // Remote watchers support: + // IPROTO_WATCH, IPROTO_UNWATCH, IPROTO_EVENT commands. + IPROTO_FEATURE_WATCHERS Feature = 3 + // Pagination support: + // IPROTO_AFTER_POSITION, IPROTO_AFTER_TUPLE, IPROTO_FETCH_POSITION + // request fields and IPROTO_POSITION response field. + IPROTO_FEATURE_PAGINATION Feature = 4 +) diff --git a/feature_string.go b/feature_string.go new file mode 100644 index 0000000..e844fd7 --- /dev/null +++ b/feature_string.go @@ -0,0 +1,27 @@ +// Code generated by "stringer -type=Feature"; DO NOT EDIT. + +package iproto + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[IPROTO_FEATURE_STREAMS-0] + _ = x[IPROTO_FEATURE_TRANSACTIONS-1] + _ = x[IPROTO_FEATURE_ERROR_EXTENSION-2] + _ = x[IPROTO_FEATURE_WATCHERS-3] + _ = x[IPROTO_FEATURE_PAGINATION-4] +} + +const _Feature_name = "IPROTO_FEATURE_STREAMSIPROTO_FEATURE_TRANSACTIONSIPROTO_FEATURE_ERROR_EXTENSIONIPROTO_FEATURE_WATCHERSIPROTO_FEATURE_PAGINATION" + +var _Feature_index = [...]uint8{0, 22, 49, 79, 102, 127} + +func (i Feature) String() string { + if i < 0 || i >= Feature(len(_Feature_index)-1) { + return "Feature(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Feature_name[_Feature_index[i]:_Feature_index[i+1]] +} diff --git a/feature_test.go b/feature_test.go new file mode 100644 index 0000000..c136a88 --- /dev/null +++ b/feature_test.go @@ -0,0 +1,35 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto_test + +import ( + "testing" + + "github.com/tarantool/go-iproto" +) + +func TestFeature(t *testing.T) { + cases := []struct { + Feature iproto.Feature + Str string + Val int + }{ + + {iproto.IPROTO_FEATURE_STREAMS, "IPROTO_FEATURE_STREAMS", 0}, + {iproto.IPROTO_FEATURE_TRANSACTIONS, "IPROTO_FEATURE_TRANSACTIONS", 1}, + {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}, + } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.Feature.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.Feature.String(), tc.Str) + } + if int(tc.Feature) != tc.Val { + t.Errorf("Got %d, expected %d", tc.Feature, tc.Val) + } + }) + } +} diff --git a/flag.go b/flag.go new file mode 100644 index 0000000..b071a38 --- /dev/null +++ b/flag.go @@ -0,0 +1,16 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto + +// IPROTO flag constants, generated from +// tarantool/src/box/iproto_constants.h +type Flag int + +const ( + // Set for the last xrow in a transaction. + IPROTO_FLAG_COMMIT Flag = 0x01 + // Set for the last row of a tx residing in limbo. + IPROTO_FLAG_WAIT_SYNC Flag = 0x02 + // Set for the last row of a synchronous tx. + IPROTO_FLAG_WAIT_ACK Flag = 0x04 +) diff --git a/flag_string.go b/flag_string.go new file mode 100644 index 0000000..0a51eb6 --- /dev/null +++ b/flag_string.go @@ -0,0 +1,35 @@ +// Code generated by "stringer -type=Flag"; DO NOT EDIT. + +package iproto + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[IPROTO_FLAG_COMMIT-1] + _ = x[IPROTO_FLAG_WAIT_SYNC-2] + _ = x[IPROTO_FLAG_WAIT_ACK-4] +} + +const ( + _Flag_name_0 = "IPROTO_FLAG_COMMITIPROTO_FLAG_WAIT_SYNC" + _Flag_name_1 = "IPROTO_FLAG_WAIT_ACK" +) + +var ( + _Flag_index_0 = [...]uint8{0, 18, 39} +) + +func (i Flag) String() string { + switch { + case 1 <= i && i <= 2: + i -= 1 + return _Flag_name_0[_Flag_index_0[i]:_Flag_index_0[i+1]] + case i == 4: + return _Flag_name_1 + default: + return "Flag(" + strconv.FormatInt(int64(i), 10) + ")" + } +} diff --git a/flag_test.go b/flag_test.go new file mode 100644 index 0000000..2feafa4 --- /dev/null +++ b/flag_test.go @@ -0,0 +1,33 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto_test + +import ( + "testing" + + "github.com/tarantool/go-iproto" +) + +func TestFlag(t *testing.T) { + cases := []struct { + Flag iproto.Flag + Str string + 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}, + } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.Flag.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.Flag.String(), tc.Str) + } + if int(tc.Flag) != tc.Val { + t.Errorf("Got %d, expected %d", tc.Flag, tc.Val) + } + }) + } +} diff --git a/generate.go b/generate.go new file mode 100644 index 0000000..112912a --- /dev/null +++ b/generate.go @@ -0,0 +1,9 @@ +package iproto + +//go:generate ./generate.sh +//go:generate stringer -type=Error +//go:generate stringer -type=Feature +//go:generate stringer -type=Flag +//go:generate stringer -type=Type +//go:generate stringer -type=Key,MetadataKey,BallotKey,RaftKey -output=keys_string.go +//go:generate goimports -w . diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..fc2e34f --- /dev/null +++ b/generate.sh @@ -0,0 +1,314 @@ +#!/usr/bin/env bash + +set -xeo pipefail + +if [[ -z "$TT_TAG" ]]; then + echo "Environment variable TT_TAG is not set." + exit 1 +fi + +if [[ -z "${TT_REPO}" ]]; then + TT_REPO="https://github.com/tarantool/tarantool.git" +fi + +TT_DIR=tarantool + +# Cleanup. +rm -rf ${TT_DIR} + +git clone --depth 1 --branch ${TT_TAG} ${TT_REPO} -o ${TT_DIR} +cd ${TT_DIR} +TT_COMMIT=$(git log -n 1 | head -n 1 | sed "s/commit //") +cd .. + +SRC_CONST=${TT_DIR}/src/box/iproto_constants.h +SRC_ERRORS=${TT_DIR}/src/box/errcode.h +SRC_FEATURES=${TT_DIR}/src/box/iproto_features.h +DST_DOC=doc.go +DST_ERRORS=error.go +DST_ERRORS_TEST=error_test.go +DST_FEATURES=feature.go +DST_FEATURES_TEST=feature_test.go +DST_FLAGS=flag.go +DST_FLAGS_TEST=flag_test.go +DST_TYPES=type.go +DST_TYPES_TEST=type_test.go +DST_KEYS=keys.go +DST_KEYS_TEST=keys_test.go + +# Cleanup. +rm -rf ${DST_DOC} \ + ${DST_ERRORS} ${DST_ERRORS_TEST} \ + ${DST_FEATURES} ${DST_FEATURES_TEST} \ + ${DST_FLAGS} ${DST_FLAGS_TEST} \ + ${DST_TYPES} ${DST_TYPES_TEST} \ + ${DST_KEYS} ${DST_KEYS_TEST} + +FOOTER="// Code generated by generate.sh; DO NOT EDIT. + +package iproto +" + +FOOTER_TEST="// Code generated by generate.sh; DO NOT EDIT. + +package iproto_test + +import ( + \"testing\" + + \"github.com/tarantool/go-iproto\" +) + +" + +# read_enum read 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" +} + +# generate_enum generates a Golang style enum from a C enum. +# arg1 - enum name in Golang. +function generate_enum { + echo "type ${1} int + +const (" + # Remove a constant without value. + sed "/^[\t ]*[a-zA-Z_]\+,\?$/d" | \ + # Remove a begin comment line. + sed "/^[\t ]*\/\*\+[\t ]*$/d" | \ + # Remove an end comment line. + sed "/^[\t ]*\*\+\/[\t ]*$/d" | \ + # Remove an end of a comment. + sed "s/[\t ]*\*\+\///" | \ + # Transform comments into a Golang style from at a start of a line. + sed "s/^[\t ]*[ \/]\*\+/\t\/\//" | \ + # Transform comments into a Golang style in a middle of a line. + sed "s/\/\*/\/\//" | \ + # Remove a coma from an end of a value. + sed "/^[\t ]*[A-Z0-9_]\+[\t ]\+=/s/,//" | \ + # Insert type. + sed "/^[\t ]*[A-Z0-9_]\+[\t ]\+=/s/ = / ${1} = /" + echo ")" +} + +# generate_test generates a Golang test for a Golang enum from a C enum. +# arg1 - enum name in Golang. +function generate_test { +echo "func Test${1}(t *testing.T) { + cases := []struct{ + ${1} iproto.${1} + Str string + Val int + } { +" + +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)}' + +echo " } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.${1}.String() != tc.Str { + t.Errorf(\"Got %s, expected %s\", tc.${1}.String(), tc.Str) + } + if int(tc.${1}) != tc.Val { + t.Errorf(\"Got %d, expected %d\", tc.${1}, tc.Val) + } + }) + } +} +" +} + +# +# Doc. +# + +cat << EOF > ${DST_DOC} +// Package iproto contains IPROTO constants. +// +// The package code generated from: +// +// Repository: ${TT_REPO} +// Tag or branch: ${TT_TAG} +// Commit: ${TT_COMMIT} +package iproto + +// Code generated by generate.sh; DO NOT EDIT. +EOF + +# +# Errors. +# + +echo "${FOOTER}" > ${DST_ERRORS} +cat << EOF >> ${DST_ERRORS} +// IPROTO error code constants, generated from +// ${SRC_ERRORS} +type Error int + +const ( +EOF + +grep "(ER_" ${SRC_ERRORS} | \ + # Remove comments symbols. + sed "s/\/\*//" | \ + sed "s/\*\/_(//" | \ + # Remove and of values. + sed "s/) *\\\//" | \ + # Remove comma at an end of a value. + sed "s/,/ /" | \ + # Finally print parsed values in Golang format. + awk '{ + com=""; + for(i=3;i<=NF;i++){com=com" "$i}; + printf("\t//%s\n\t%s Error = %s\n", com, $2, $1) + }' >> ${DST_ERRORS} + +echo ")" >> ${DST_ERRORS} + +echo "${FOOTER_TEST}" > ${DST_ERRORS_TEST} +cat << EOF >> ${DST_ERRORS_TEST} +func TestError(t *testing.T) { + cases := []struct{ + Err iproto.Error + Str string + } { +EOF + +grep -o "ER_[A-Z0-9_]\+," ${SRC_ERRORS} | \ + sed "s/,$//" | \ + awk '{printf("\t\t{iproto.%s, \"%s\"},\n", $1, $1)}' >> ${DST_ERRORS_TEST} + +cat << EOF >> ${DST_ERRORS_TEST} + } + + for i, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.Err.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.Err.String(), tc.Str) + } + if int(tc.Err) != i { + t.Errorf("Got %d, expected %d", tc.Err, i) + } + }) + } +} +EOF + +# +# Features. +# + +echo "${FOOTER}" > ${DST_FEATURES} +cat << EOF >> ${DST_FEATURES} +// IPROTO feature constants, generated from +// ${SRC_FEATURES} +EOF + +read_enum iproto_feature_id ${SRC_FEATURES} | \ + generate_enum Feature >> ${DST_FEATURES} + +echo "${FOOTER_TEST}" > ${DST_FEATURES_TEST} + +read_enum iproto_feature_id ${SRC_FEATURES} | \ + generate_test Feature >> ${DST_FEATURES_TEST} + +# +# Flags. +# + +echo "${FOOTER}" > ${DST_FLAGS} +cat << EOF >> ${DST_FLAGS} +// IPROTO flag constants, generated from +// ${SRC_CONST} +EOF + +grep -PB 1 "[\t ]*IPROTO_FLAG_[A-Z_]+ =" ${SRC_CONST} | \ + generate_enum Flag >> ${DST_FLAGS} + +echo "${FOOTER_TEST}" > ${DST_FLAGS_TEST} + +grep -PB 1 "[\t ]*IPROTO_FLAG_[A-Z_]+ =" ${SRC_CONST} | \ + generate_test Flag >> ${DST_FLAGS_TEST} + +# +# Types. +# + +echo "${FOOTER}" > ${DST_TYPES} +cat << EOF >> ${DST_TYPES} +// IPROTO type constants, generated from +// ${SRC_CONST} +EOF + +read_enum iproto_type ${SRC_CONST} | \ + generate_enum Type >> ${DST_TYPES} + +echo "${FOOTER_TEST}" > ${DST_TYPES_TEST} + +read_enum iproto_type ${SRC_CONST} | \ + generate_test Type >> ${DST_TYPES_TEST} + +# +# Keys. +# + +echo "${FOOTER}" > ${DST_KEYS} +cat << EOF >> ${DST_KEYS} +// IPROTO key constants, generated from +// ${SRC_CONST} +EOF + +read_enum iproto_key ${SRC_CONST} | \ + generate_enum Key >> ${DST_KEYS} + +cat << EOF >> ${DST_KEYS} + +// IPROTO metadata key constants, generated from +// ${SRC_CONST} +EOF + +read_enum iproto_metadata_key ${SRC_CONST} | \ + generate_enum MetadataKey >> ${DST_KEYS} + +cat << EOF >> ${DST_KEYS} + +// IPROTO ballot key constants, generated from +// ${SRC_CONST} +EOF + +read_enum iproto_ballot_key ${SRC_CONST} | \ + generate_enum BallotKey >> ${DST_KEYS} + +cat << EOF >> ${DST_KEYS} + +// IPROTO raft key constants, generated from +// ${SRC_CONST} +EOF + +read_enum iproto_raft_keys ${SRC_CONST} | \ + generate_enum RaftKey >> ${DST_KEYS} + +echo "${FOOTER_TEST}" > ${DST_KEYS_TEST} + +read_enum iproto_key ${SRC_CONST} | \ + generate_test Key >> ${DST_KEYS_TEST} + +read_enum iproto_metadata_key ${SRC_CONST} | \ + generate_test MetadataKey >> ${DST_KEYS_TEST} + +read_enum iproto_ballot_key ${SRC_CONST} | \ + generate_test BallotKey >> ${DST_KEYS_TEST} + +read_enum iproto_raft_keys ${SRC_CONST} | \ + generate_test RaftKey >> ${DST_KEYS_TEST} + +# +# Cleanup. +# + +rm -rf ${TT_DIR} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5aa46d3 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/tarantool/go-iproto + +go 1.13 diff --git a/keys.go b/keys.go new file mode 100644 index 0000000..debdc36 --- /dev/null +++ b/keys.go @@ -0,0 +1,152 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto + +// IPROTO key constants, generated from +// tarantool/src/box/iproto_constants.h +type Key int + +const ( + IPROTO_REQUEST_TYPE Key = 0x00 + IPROTO_SYNC Key = 0x01 + // Replication keys (header) + IPROTO_REPLICA_ID Key = 0x02 + IPROTO_LSN Key = 0x03 + IPROTO_TIMESTAMP Key = 0x04 + IPROTO_SCHEMA_VERSION Key = 0x05 + IPROTO_SERVER_VERSION Key = 0x06 + IPROTO_GROUP_ID Key = 0x07 + IPROTO_TSN Key = 0x08 + IPROTO_FLAGS Key = 0x09 + IPROTO_STREAM_ID Key = 0x0a + // Leave a gap for other keys in the header. + IPROTO_SPACE_ID Key = 0x10 + IPROTO_INDEX_ID Key = 0x11 + IPROTO_LIMIT Key = 0x12 + IPROTO_OFFSET Key = 0x13 + IPROTO_ITERATOR Key = 0x14 + IPROTO_INDEX_BASE Key = 0x15 + // Leave a gap between integer values and other keys + // Flag indicating the need to send position of + // last selected tuple in response. + IPROTO_FETCH_POSITION Key = 0x1f + IPROTO_KEY Key = 0x20 + IPROTO_TUPLE Key = 0x21 + IPROTO_FUNCTION_NAME Key = 0x22 + IPROTO_USER_NAME Key = 0x23 + // Replication keys (body). + // Unfortunately, there is no gap between request and + // replication keys (between USER_NAME and INSTANCE_UUID). + // So imagine, that OPS, EXPR and FIELD_NAME keys follows + // the USER_NAME key. + IPROTO_INSTANCE_UUID Key = 0x24 + 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_BALLOT Key = 0x29 + IPROTO_TUPLE_META Key = 0x2a + IPROTO_OPTIONS Key = 0x2b + // Old tuple (i.e. before DML request is applied). + IPROTO_OLD_TUPLE Key = 0x2c + // New tuple (i.e. result of DML request). + IPROTO_NEW_TUPLE Key = 0x2d + // Position of last selected tuple to start iteration after it. + IPROTO_AFTER_POSITION Key = 0x2e + // Last selected tuple to start iteration after it. + IPROTO_AFTER_TUPLE Key = 0x2f + // Response keys. + IPROTO_DATA Key = 0x30 + IPROTO_ERROR_24 Key = 0x31 + // IPROTO_METADATA: [ + // { IPROTO_FIELD_NAME: name }, + // { ... }, + // ... + // ] + IPROTO_METADATA Key = 0x32 + IPROTO_BIND_METADATA Key = 0x33 + IPROTO_BIND_COUNT Key = 0x34 + // Position of last selected tuple in response. + IPROTO_POSITION Key = 0x35 + // Leave a gap between response keys and SQL keys. + IPROTO_SQL_TEXT Key = 0x40 + IPROTO_SQL_BIND Key = 0x41 + // IPROTO_SQL_INFO: { + // SQL_INFO_ROW_COUNT: number + // } + IPROTO_SQL_INFO Key = 0x42 + IPROTO_STMT_ID Key = 0x43 + // Leave a gap between SQL keys and additional request keys + IPROTO_REPLICA_ANON Key = 0x50 + IPROTO_ID_FILTER Key = 0x51 + IPROTO_ERROR Key = 0x52 + // Term. Has the same meaning as IPROTO_RAFT_TERM, but is an iproto + // key, rather than a raft key. Used for PROMOTE request, which needs + // both iproto (e.g. REPLICA_ID) and raft (RAFT_TERM) keys. + IPROTO_TERM Key = 0x53 + // Protocol version. + IPROTO_VERSION Key = 0x54 + // Protocol features. + IPROTO_FEATURES Key = 0x55 + // Operation timeout. Specific to request type. + IPROTO_TIMEOUT Key = 0x56 + // Key name and data sent to a remote watcher. + IPROTO_EVENT_KEY Key = 0x57 + IPROTO_EVENT_DATA Key = 0x58 + // Isolation level, is used only by IPROTO_BEGIN request. + IPROTO_TXN_ISOLATION Key = 0x59 + // A vclock synchronisation request identifier. + IPROTO_VCLOCK_SYNC Key = 0x5a + // Name of the authentication method that is currently used on + // 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 metadata key constants, generated from +// tarantool/src/box/iproto_constants.h +type MetadataKey int + +const ( + IPROTO_FIELD_NAME MetadataKey = 0 + IPROTO_FIELD_TYPE MetadataKey = 1 + IPROTO_FIELD_COLL MetadataKey = 2 + IPROTO_FIELD_IS_NULLABLE MetadataKey = 3 + IPROTO_FIELD_IS_AUTOINCREMENT MetadataKey = 4 + IPROTO_FIELD_SPAN MetadataKey = 5 +) + +// IPROTO ballot key constants, generated from +// tarantool/src/box/iproto_constants.h +type BallotKey int + +const ( + IPROTO_BALLOT_IS_RO_CFG BallotKey = 0x01 + IPROTO_BALLOT_VCLOCK BallotKey = 0x02 + IPROTO_BALLOT_GC_VCLOCK BallotKey = 0x03 + IPROTO_BALLOT_IS_RO BallotKey = 0x04 + IPROTO_BALLOT_IS_ANON BallotKey = 0x05 + IPROTO_BALLOT_IS_BOOTED BallotKey = 0x06 + IPROTO_BALLOT_CAN_LEAD BallotKey = 0x07 + IPROTO_BALLOT_BOOTSTRAP_LEADER_UUID BallotKey = 0x08 + IPROTO_BALLOT_REGISTERED_REPLICA_UUIDS BallotKey = 0x09 +) + +// IPROTO raft key constants, generated from +// tarantool/src/box/iproto_constants.h +type RaftKey int + +const ( + IPROTO_RAFT_TERM RaftKey = 0 + IPROTO_RAFT_VOTE RaftKey = 1 + IPROTO_RAFT_STATE RaftKey = 2 + IPROTO_RAFT_VCLOCK RaftKey = 3 + IPROTO_RAFT_LEADER_ID RaftKey = 4 + IPROTO_RAFT_IS_LEADER_SEEN RaftKey = 5 +) diff --git a/keys_string.go b/keys_string.go new file mode 100644 index 0000000..2d0269c --- /dev/null +++ b/keys_string.go @@ -0,0 +1,174 @@ +// Code generated by "stringer -type=Key,MetadataKey,BallotKey,RaftKey -output=keys_string.go"; DO NOT EDIT. + +package iproto + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[IPROTO_REQUEST_TYPE-0] + _ = x[IPROTO_SYNC-1] + _ = x[IPROTO_REPLICA_ID-2] + _ = x[IPROTO_LSN-3] + _ = x[IPROTO_TIMESTAMP-4] + _ = x[IPROTO_SCHEMA_VERSION-5] + _ = x[IPROTO_SERVER_VERSION-6] + _ = x[IPROTO_GROUP_ID-7] + _ = x[IPROTO_TSN-8] + _ = x[IPROTO_FLAGS-9] + _ = x[IPROTO_STREAM_ID-10] + _ = x[IPROTO_SPACE_ID-16] + _ = x[IPROTO_INDEX_ID-17] + _ = x[IPROTO_LIMIT-18] + _ = x[IPROTO_OFFSET-19] + _ = x[IPROTO_ITERATOR-20] + _ = x[IPROTO_INDEX_BASE-21] + _ = x[IPROTO_FETCH_POSITION-31] + _ = x[IPROTO_KEY-32] + _ = x[IPROTO_TUPLE-33] + _ = x[IPROTO_FUNCTION_NAME-34] + _ = x[IPROTO_USER_NAME-35] + _ = x[IPROTO_INSTANCE_UUID-36] + _ = x[IPROTO_REPLICASET_UUID-37] + _ = x[IPROTO_VCLOCK-38] + _ = x[IPROTO_EXPR-39] + _ = x[IPROTO_OPS-40] + _ = x[IPROTO_BALLOT-41] + _ = x[IPROTO_TUPLE_META-42] + _ = x[IPROTO_OPTIONS-43] + _ = x[IPROTO_OLD_TUPLE-44] + _ = x[IPROTO_NEW_TUPLE-45] + _ = x[IPROTO_AFTER_POSITION-46] + _ = x[IPROTO_AFTER_TUPLE-47] + _ = x[IPROTO_DATA-48] + _ = x[IPROTO_ERROR_24-49] + _ = x[IPROTO_METADATA-50] + _ = x[IPROTO_BIND_METADATA-51] + _ = x[IPROTO_BIND_COUNT-52] + _ = x[IPROTO_POSITION-53] + _ = x[IPROTO_SQL_TEXT-64] + _ = x[IPROTO_SQL_BIND-65] + _ = x[IPROTO_SQL_INFO-66] + _ = x[IPROTO_STMT_ID-67] + _ = x[IPROTO_REPLICA_ANON-80] + _ = x[IPROTO_ID_FILTER-81] + _ = x[IPROTO_ERROR-82] + _ = x[IPROTO_TERM-83] + _ = x[IPROTO_VERSION-84] + _ = x[IPROTO_FEATURES-85] + _ = x[IPROTO_TIMEOUT-86] + _ = x[IPROTO_EVENT_KEY-87] + _ = x[IPROTO_EVENT_DATA-88] + _ = x[IPROTO_TXN_ISOLATION-89] + _ = x[IPROTO_VCLOCK_SYNC-90] + _ = x[IPROTO_AUTH_TYPE-91] +} + +const ( + _Key_name_0 = "IPROTO_REQUEST_TYPEIPROTO_SYNCIPROTO_REPLICA_IDIPROTO_LSNIPROTO_TIMESTAMPIPROTO_SCHEMA_VERSIONIPROTO_SERVER_VERSIONIPROTO_GROUP_IDIPROTO_TSNIPROTO_FLAGSIPROTO_STREAM_ID" + _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" +) + +var ( + _Key_index_0 = [...]uint8{0, 19, 30, 47, 57, 73, 94, 115, 130, 140, 152, 168} + _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} +) + +func (i Key) String() string { + switch { + case 0 <= i && i <= 10: + return _Key_name_0[_Key_index_0[i]:_Key_index_0[i+1]] + case 16 <= i && i <= 21: + i -= 16 + return _Key_name_1[_Key_index_1[i]:_Key_index_1[i+1]] + case 31 <= i && i <= 53: + i -= 31 + return _Key_name_2[_Key_index_2[i]:_Key_index_2[i+1]] + 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: + i -= 80 + return _Key_name_4[_Key_index_4[i]:_Key_index_4[i+1]] + default: + return "Key(" + strconv.FormatInt(int64(i), 10) + ")" + } +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[IPROTO_FIELD_NAME-0] + _ = x[IPROTO_FIELD_TYPE-1] + _ = x[IPROTO_FIELD_COLL-2] + _ = x[IPROTO_FIELD_IS_NULLABLE-3] + _ = x[IPROTO_FIELD_IS_AUTOINCREMENT-4] + _ = x[IPROTO_FIELD_SPAN-5] +} + +const _MetadataKey_name = "IPROTO_FIELD_NAMEIPROTO_FIELD_TYPEIPROTO_FIELD_COLLIPROTO_FIELD_IS_NULLABLEIPROTO_FIELD_IS_AUTOINCREMENTIPROTO_FIELD_SPAN" + +var _MetadataKey_index = [...]uint8{0, 17, 34, 51, 75, 104, 121} + +func (i MetadataKey) String() string { + if i < 0 || i >= MetadataKey(len(_MetadataKey_index)-1) { + return "MetadataKey(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _MetadataKey_name[_MetadataKey_index[i]:_MetadataKey_index[i+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[IPROTO_BALLOT_IS_RO_CFG-1] + _ = x[IPROTO_BALLOT_VCLOCK-2] + _ = x[IPROTO_BALLOT_GC_VCLOCK-3] + _ = x[IPROTO_BALLOT_IS_RO-4] + _ = x[IPROTO_BALLOT_IS_ANON-5] + _ = x[IPROTO_BALLOT_IS_BOOTED-6] + _ = x[IPROTO_BALLOT_CAN_LEAD-7] + _ = x[IPROTO_BALLOT_BOOTSTRAP_LEADER_UUID-8] + _ = x[IPROTO_BALLOT_REGISTERED_REPLICA_UUIDS-9] +} + +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" + +var _BallotKey_index = [...]uint8{0, 23, 43, 66, 85, 106, 129, 151, 186, 224} + +func (i BallotKey) String() string { + i -= 1 + if i < 0 || i >= BallotKey(len(_BallotKey_index)-1) { + return "BallotKey(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _BallotKey_name[_BallotKey_index[i]:_BallotKey_index[i+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[IPROTO_RAFT_TERM-0] + _ = x[IPROTO_RAFT_VOTE-1] + _ = x[IPROTO_RAFT_STATE-2] + _ = x[IPROTO_RAFT_VCLOCK-3] + _ = x[IPROTO_RAFT_LEADER_ID-4] + _ = x[IPROTO_RAFT_IS_LEADER_SEEN-5] +} + +const _RaftKey_name = "IPROTO_RAFT_TERMIPROTO_RAFT_VOTEIPROTO_RAFT_STATEIPROTO_RAFT_VCLOCKIPROTO_RAFT_LEADER_IDIPROTO_RAFT_IS_LEADER_SEEN" + +var _RaftKey_index = [...]uint8{0, 16, 32, 49, 67, 88, 114} + +func (i RaftKey) String() string { + if i < 0 || i >= RaftKey(len(_RaftKey_index)-1) { + return "RaftKey(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _RaftKey_name[_RaftKey_index[i]:_RaftKey_index[i+1]] +} diff --git a/keys_test.go b/keys_test.go new file mode 100644 index 0000000..0717527 --- /dev/null +++ b/keys_test.go @@ -0,0 +1,170 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto_test + +import ( + "testing" + + "github.com/tarantool/go-iproto" +) + +func TestKey(t *testing.T) { + cases := []struct { + Key iproto.Key + Str string + Val int + }{ + + {iproto.IPROTO_REQUEST_TYPE, "IPROTO_REQUEST_TYPE", 0x00}, + {iproto.IPROTO_SYNC, "IPROTO_SYNC", 0x01}, + {iproto.IPROTO_REPLICA_ID, "IPROTO_REPLICA_ID", 0x02}, + {iproto.IPROTO_LSN, "IPROTO_LSN", 0x03}, + {iproto.IPROTO_TIMESTAMP, "IPROTO_TIMESTAMP", 0x04}, + {iproto.IPROTO_SCHEMA_VERSION, "IPROTO_SCHEMA_VERSION", 0x05}, + {iproto.IPROTO_SERVER_VERSION, "IPROTO_SERVER_VERSION", 0x06}, + {iproto.IPROTO_GROUP_ID, "IPROTO_GROUP_ID", 0x07}, + {iproto.IPROTO_TSN, "IPROTO_TSN", 0x08}, + {iproto.IPROTO_FLAGS, "IPROTO_FLAGS", 0x09}, + {iproto.IPROTO_STREAM_ID, "IPROTO_STREAM_ID", 0x0a}, + {iproto.IPROTO_SPACE_ID, "IPROTO_SPACE_ID", 0x10}, + {iproto.IPROTO_INDEX_ID, "IPROTO_INDEX_ID", 0x11}, + {iproto.IPROTO_LIMIT, "IPROTO_LIMIT", 0x12}, + {iproto.IPROTO_OFFSET, "IPROTO_OFFSET", 0x13}, + {iproto.IPROTO_ITERATOR, "IPROTO_ITERATOR", 0x14}, + {iproto.IPROTO_INDEX_BASE, "IPROTO_INDEX_BASE", 0x15}, + {iproto.IPROTO_FETCH_POSITION, "IPROTO_FETCH_POSITION", 0x1f}, + {iproto.IPROTO_KEY, "IPROTO_KEY", 0x20}, + {iproto.IPROTO_TUPLE, "IPROTO_TUPLE", 0x21}, + {iproto.IPROTO_FUNCTION_NAME, "IPROTO_FUNCTION_NAME", 0x22}, + {iproto.IPROTO_USER_NAME, "IPROTO_USER_NAME", 0x23}, + {iproto.IPROTO_INSTANCE_UUID, "IPROTO_INSTANCE_UUID", 0x24}, + {iproto.IPROTO_REPLICASET_UUID, "IPROTO_REPLICASET_UUID", 0x25}, + {iproto.IPROTO_VCLOCK, "IPROTO_VCLOCK", 0x26}, + {iproto.IPROTO_EXPR, "IPROTO_EXPR", 0x27}, + {iproto.IPROTO_OPS, "IPROTO_OPS", 0x28}, + {iproto.IPROTO_BALLOT, "IPROTO_BALLOT", 0x29}, + {iproto.IPROTO_TUPLE_META, "IPROTO_TUPLE_META", 0x2a}, + {iproto.IPROTO_OPTIONS, "IPROTO_OPTIONS", 0x2b}, + {iproto.IPROTO_OLD_TUPLE, "IPROTO_OLD_TUPLE", 0x2c}, + {iproto.IPROTO_NEW_TUPLE, "IPROTO_NEW_TUPLE", 0x2d}, + {iproto.IPROTO_AFTER_POSITION, "IPROTO_AFTER_POSITION", 0x2e}, + {iproto.IPROTO_AFTER_TUPLE, "IPROTO_AFTER_TUPLE", 0x2f}, + {iproto.IPROTO_DATA, "IPROTO_DATA", 0x30}, + {iproto.IPROTO_ERROR_24, "IPROTO_ERROR_24", 0x31}, + {iproto.IPROTO_METADATA, "IPROTO_METADATA", 0x32}, + {iproto.IPROTO_BIND_METADATA, "IPROTO_BIND_METADATA", 0x33}, + {iproto.IPROTO_BIND_COUNT, "IPROTO_BIND_COUNT", 0x34}, + {iproto.IPROTO_POSITION, "IPROTO_POSITION", 0x35}, + {iproto.IPROTO_SQL_TEXT, "IPROTO_SQL_TEXT", 0x40}, + {iproto.IPROTO_SQL_BIND, "IPROTO_SQL_BIND", 0x41}, + {iproto.IPROTO_SQL_INFO, "IPROTO_SQL_INFO", 0x42}, + {iproto.IPROTO_STMT_ID, "IPROTO_STMT_ID", 0x43}, + {iproto.IPROTO_REPLICA_ANON, "IPROTO_REPLICA_ANON", 0x50}, + {iproto.IPROTO_ID_FILTER, "IPROTO_ID_FILTER", 0x51}, + {iproto.IPROTO_ERROR, "IPROTO_ERROR", 0x52}, + {iproto.IPROTO_TERM, "IPROTO_TERM", 0x53}, + {iproto.IPROTO_VERSION, "IPROTO_VERSION", 0x54}, + {iproto.IPROTO_FEATURES, "IPROTO_FEATURES", 0x55}, + {iproto.IPROTO_TIMEOUT, "IPROTO_TIMEOUT", 0x56}, + {iproto.IPROTO_EVENT_KEY, "IPROTO_EVENT_KEY", 0x57}, + {iproto.IPROTO_EVENT_DATA, "IPROTO_EVENT_DATA", 0x58}, + {iproto.IPROTO_TXN_ISOLATION, "IPROTO_TXN_ISOLATION", 0x59}, + {iproto.IPROTO_VCLOCK_SYNC, "IPROTO_VCLOCK_SYNC", 0x5a}, + {iproto.IPROTO_AUTH_TYPE, "IPROTO_AUTH_TYPE", 0x5b}, + } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.Key.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.Key.String(), tc.Str) + } + if int(tc.Key) != tc.Val { + t.Errorf("Got %d, expected %d", tc.Key, tc.Val) + } + }) + } +} + +func TestMetadataKey(t *testing.T) { + cases := []struct { + MetadataKey iproto.MetadataKey + Str string + Val int + }{ + + {iproto.IPROTO_FIELD_NAME, "IPROTO_FIELD_NAME", 0}, + {iproto.IPROTO_FIELD_TYPE, "IPROTO_FIELD_TYPE", 1}, + {iproto.IPROTO_FIELD_COLL, "IPROTO_FIELD_COLL", 2}, + {iproto.IPROTO_FIELD_IS_NULLABLE, "IPROTO_FIELD_IS_NULLABLE", 3}, + {iproto.IPROTO_FIELD_IS_AUTOINCREMENT, "IPROTO_FIELD_IS_AUTOINCREMENT", 4}, + {iproto.IPROTO_FIELD_SPAN, "IPROTO_FIELD_SPAN", 5}, + } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.MetadataKey.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.MetadataKey.String(), tc.Str) + } + if int(tc.MetadataKey) != tc.Val { + t.Errorf("Got %d, expected %d", tc.MetadataKey, tc.Val) + } + }) + } +} + +func TestBallotKey(t *testing.T) { + cases := []struct { + BallotKey iproto.BallotKey + Str string + Val int + }{ + + {iproto.IPROTO_BALLOT_IS_RO_CFG, "IPROTO_BALLOT_IS_RO_CFG", 0x01}, + {iproto.IPROTO_BALLOT_VCLOCK, "IPROTO_BALLOT_VCLOCK", 0x02}, + {iproto.IPROTO_BALLOT_GC_VCLOCK, "IPROTO_BALLOT_GC_VCLOCK", 0x03}, + {iproto.IPROTO_BALLOT_IS_RO, "IPROTO_BALLOT_IS_RO", 0x04}, + {iproto.IPROTO_BALLOT_IS_ANON, "IPROTO_BALLOT_IS_ANON", 0x05}, + {iproto.IPROTO_BALLOT_IS_BOOTED, "IPROTO_BALLOT_IS_BOOTED", 0x06}, + {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}, + } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.BallotKey.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.BallotKey.String(), tc.Str) + } + if int(tc.BallotKey) != tc.Val { + t.Errorf("Got %d, expected %d", tc.BallotKey, tc.Val) + } + }) + } +} + +func TestRaftKey(t *testing.T) { + cases := []struct { + RaftKey iproto.RaftKey + Str string + Val int + }{ + + {iproto.IPROTO_RAFT_TERM, "IPROTO_RAFT_TERM", 0}, + {iproto.IPROTO_RAFT_VOTE, "IPROTO_RAFT_VOTE", 1}, + {iproto.IPROTO_RAFT_STATE, "IPROTO_RAFT_STATE", 2}, + {iproto.IPROTO_RAFT_VCLOCK, "IPROTO_RAFT_VCLOCK", 3}, + {iproto.IPROTO_RAFT_LEADER_ID, "IPROTO_RAFT_LEADER_ID", 4}, + {iproto.IPROTO_RAFT_IS_LEADER_SEEN, "IPROTO_RAFT_IS_LEADER_SEEN", 5}, + } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.RaftKey.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.RaftKey.String(), tc.Str) + } + if int(tc.RaftKey) != tc.Val { + t.Errorf("Got %d, expected %d", tc.RaftKey, tc.Val) + } + }) + } +} diff --git a/type.go b/type.go new file mode 100644 index 0000000..ff2c9b8 --- /dev/null +++ b/type.go @@ -0,0 +1,104 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto + +// IPROTO type constants, generated from +// tarantool/src/box/iproto_constants.h +type Type int + +const ( + // Acknowledgement that request or command is successful + IPROTO_OK Type = 0 + // SELECT request + IPROTO_SELECT Type = 1 + // INSERT request + IPROTO_INSERT Type = 2 + // REPLACE request + IPROTO_REPLACE Type = 3 + // UPDATE request + IPROTO_UPDATE Type = 4 + // DELETE request + IPROTO_DELETE Type = 5 + // CALL request - wraps result into [tuple, tuple, ...] format + IPROTO_CALL_16 Type = 6 + // AUTH request + IPROTO_AUTH Type = 7 + // EVAL request + IPROTO_EVAL Type = 8 + // UPSERT request + IPROTO_UPSERT Type = 9 + // CALL request - returns arbitrary MessagePack + IPROTO_CALL Type = 10 + // Execute an SQL statement. + IPROTO_EXECUTE Type = 11 + // No operation. Treated as DML, used to bump LSN. + IPROTO_NOP Type = 12 + // Prepare SQL statement. + IPROTO_PREPARE Type = 13 + // Begin transaction + IPROTO_BEGIN Type = 14 + // Commit transaction + IPROTO_COMMIT Type = 15 + // Rollback transaction + IPROTO_ROLLBACK Type = 16 + // The maximum typecode used for box.stat() + IPROTO_RAFT Type = 30 + // PROMOTE request. + IPROTO_RAFT_PROMOTE Type = 31 + // DEMOTE request. + IPROTO_RAFT_DEMOTE Type = 32 + // A confirmation message for synchronous transactions. + IPROTO_RAFT_CONFIRM Type = 40 + // A rollback message for synchronous transactions. + IPROTO_RAFT_ROLLBACK Type = 41 + // PING request + IPROTO_PING Type = 64 + // Replication JOIN command + IPROTO_JOIN Type = 65 + // Replication SUBSCRIBE command + IPROTO_SUBSCRIBE Type = 66 + // DEPRECATED: use IPROTO_VOTE instead + IPROTO_VOTE_DEPRECATED Type = 67 + // Vote request command for master election + IPROTO_VOTE Type = 68 + // Anonymous replication FETCH SNAPSHOT. + IPROTO_FETCH_SNAPSHOT Type = 69 + // REGISTER request to leave anonymous replication. + IPROTO_REGISTER Type = 70 + IPROTO_JOIN_META Type = 71 + IPROTO_JOIN_SNAPSHOT Type = 72 + // Protocol features request. + IPROTO_ID Type = 73 + // The following three request types are used by the remote watcher + // protocol (box.watch over network), which operates as follows: + // + // 1. The client sends an IPROTO_WATCH packet to subscribe to changes + // of a specified key defined on the server. + // 2. The server sends an IPROTO_EVENT packet to the subscribed client + // with the key name and its current value unconditionally after + // registration and then every time the key value is updated + // provided the last notification was acknowledged (see below). + // 3. Upon receiving a notification, the client sends an IPROTO_WATCH + // packet to acknowledge the notification. + // 4. When the client doesn't want to receive any more notifications, + // 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). + IPROTO_WATCH Type = 74 + IPROTO_UNWATCH Type = 75 + IPROTO_EVENT Type = 76 + // 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 new file mode 100644 index 0000000..4949a5a --- /dev/null +++ b/type_string.go @@ -0,0 +1,96 @@ +// Code generated by "stringer -type=Type"; DO NOT EDIT. + +package iproto + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[IPROTO_OK-0] + _ = x[IPROTO_SELECT-1] + _ = x[IPROTO_INSERT-2] + _ = x[IPROTO_REPLACE-3] + _ = x[IPROTO_UPDATE-4] + _ = x[IPROTO_DELETE-5] + _ = x[IPROTO_CALL_16-6] + _ = x[IPROTO_AUTH-7] + _ = x[IPROTO_EVAL-8] + _ = x[IPROTO_UPSERT-9] + _ = x[IPROTO_CALL-10] + _ = x[IPROTO_EXECUTE-11] + _ = x[IPROTO_NOP-12] + _ = x[IPROTO_PREPARE-13] + _ = x[IPROTO_BEGIN-14] + _ = x[IPROTO_COMMIT-15] + _ = x[IPROTO_ROLLBACK-16] + _ = x[IPROTO_RAFT-30] + _ = x[IPROTO_RAFT_PROMOTE-31] + _ = x[IPROTO_RAFT_DEMOTE-32] + _ = x[IPROTO_RAFT_CONFIRM-40] + _ = x[IPROTO_RAFT_ROLLBACK-41] + _ = x[IPROTO_PING-64] + _ = x[IPROTO_JOIN-65] + _ = x[IPROTO_SUBSCRIBE-66] + _ = x[IPROTO_VOTE_DEPRECATED-67] + _ = x[IPROTO_VOTE-68] + _ = x[IPROTO_FETCH_SNAPSHOT-69] + _ = x[IPROTO_REGISTER-70] + _ = x[IPROTO_JOIN_META-71] + _ = x[IPROTO_JOIN_SNAPSHOT-72] + _ = x[IPROTO_ID-73] + _ = 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_CHUNK-128] + _ = x[IPROTO_TYPE_ERROR-32768] + _ = x[IPROTO_UNKNOWN - -1] +} + +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_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_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_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_4 = [...]uint8{0, 17, 35, 51} +) + +func (i Type) String() string { + switch { + case -1 <= i && i <= 16: + i -= -1 + return _Type_name_0[_Type_index_0[i]:_Type_index_0[i+1]] + case 30 <= i && i <= 32: + i -= 30 + return _Type_name_1[_Type_index_1[i]:_Type_index_1[i+1]] + 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: + i -= 64 + return _Type_name_3[_Type_index_3[i]:_Type_index_3[i+1]] + case 100 <= i && i <= 102: + i -= 100 + return _Type_name_4[_Type_index_4[i]:_Type_index_4[i+1]] + case i == 128: + return _Type_name_5 + case i == 32768: + return _Type_name_6 + default: + return "Type(" + strconv.FormatInt(int64(i), 10) + ")" + } +} diff --git a/type_test.go b/type_test.go new file mode 100644 index 0000000..ece13f3 --- /dev/null +++ b/type_test.go @@ -0,0 +1,71 @@ +// Code generated by generate.sh; DO NOT EDIT. + +package iproto_test + +import ( + "testing" + + "github.com/tarantool/go-iproto" +) + +func TestType(t *testing.T) { + cases := []struct { + Type iproto.Type + Str string + Val int + }{ + + {iproto.IPROTO_OK, "IPROTO_OK", 0}, + {iproto.IPROTO_SELECT, "IPROTO_SELECT", 1}, + {iproto.IPROTO_INSERT, "IPROTO_INSERT", 2}, + {iproto.IPROTO_REPLACE, "IPROTO_REPLACE", 3}, + {iproto.IPROTO_UPDATE, "IPROTO_UPDATE", 4}, + {iproto.IPROTO_DELETE, "IPROTO_DELETE", 5}, + {iproto.IPROTO_CALL_16, "IPROTO_CALL_16", 6}, + {iproto.IPROTO_AUTH, "IPROTO_AUTH", 7}, + {iproto.IPROTO_EVAL, "IPROTO_EVAL", 8}, + {iproto.IPROTO_UPSERT, "IPROTO_UPSERT", 9}, + {iproto.IPROTO_CALL, "IPROTO_CALL", 10}, + {iproto.IPROTO_EXECUTE, "IPROTO_EXECUTE", 11}, + {iproto.IPROTO_NOP, "IPROTO_NOP", 12}, + {iproto.IPROTO_PREPARE, "IPROTO_PREPARE", 13}, + {iproto.IPROTO_BEGIN, "IPROTO_BEGIN", 14}, + {iproto.IPROTO_COMMIT, "IPROTO_COMMIT", 15}, + {iproto.IPROTO_ROLLBACK, "IPROTO_ROLLBACK", 16}, + {iproto.IPROTO_RAFT, "IPROTO_RAFT", 30}, + {iproto.IPROTO_RAFT_PROMOTE, "IPROTO_RAFT_PROMOTE", 31}, + {iproto.IPROTO_RAFT_DEMOTE, "IPROTO_RAFT_DEMOTE", 32}, + {iproto.IPROTO_RAFT_CONFIRM, "IPROTO_RAFT_CONFIRM", 40}, + {iproto.IPROTO_RAFT_ROLLBACK, "IPROTO_RAFT_ROLLBACK", 41}, + {iproto.IPROTO_PING, "IPROTO_PING", 64}, + {iproto.IPROTO_JOIN, "IPROTO_JOIN", 65}, + {iproto.IPROTO_SUBSCRIBE, "IPROTO_SUBSCRIBE", 66}, + {iproto.IPROTO_VOTE_DEPRECATED, "IPROTO_VOTE_DEPRECATED", 67}, + {iproto.IPROTO_VOTE, "IPROTO_VOTE", 68}, + {iproto.IPROTO_FETCH_SNAPSHOT, "IPROTO_FETCH_SNAPSHOT", 69}, + {iproto.IPROTO_REGISTER, "IPROTO_REGISTER", 70}, + {iproto.IPROTO_JOIN_META, "IPROTO_JOIN_META", 71}, + {iproto.IPROTO_JOIN_SNAPSHOT, "IPROTO_JOIN_SNAPSHOT", 72}, + {iproto.IPROTO_ID, "IPROTO_ID", 73}, + {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_CHUNK, "IPROTO_CHUNK", 128}, + {iproto.IPROTO_TYPE_ERROR, "IPROTO_TYPE_ERROR", 1 << 15}, + {iproto.IPROTO_UNKNOWN, "IPROTO_UNKNOWN", -1}, + } + + for _, tc := range cases { + t.Run(tc.Str, func(t *testing.T) { + if tc.Type.String() != tc.Str { + t.Errorf("Got %s, expected %s", tc.Type.String(), tc.Str) + } + if int(tc.Type) != tc.Val { + t.Errorf("Got %d, expected %d", tc.Type, tc.Val) + } + }) + } +}