Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use diag_set() to describe VDBE errors in SQL. #4074

Closed
ImeevMA opened this issue Mar 23, 2019 · 5 comments
Closed

Use diag_set() to describe VDBE errors in SQL. #4074

ImeevMA opened this issue Mar 23, 2019 · 5 comments
Assignees
Labels
feature A new functionality refactoring Code refactoring sql
Milestone

Comments

@ImeevMA
Copy link
Collaborator

ImeevMA commented Mar 23, 2019

Currently there are two ways to describe errors in SQL - diag_set() and sqlVdbeError(). This leads to incorrect error descriptions due to possible changes in the error code. It also complicates the work with errors.

This issue continues issues #3965 and #3036.

@kyukhin kyukhin added feature A new functionality refactoring Code refactoring sql labels Mar 25, 2019
@kyukhin kyukhin added this to the 2.2.0 milestone Mar 25, 2019
ImeevMA added a commit that referenced this issue Apr 9, 2019
The module legacy.c is not used and should be removed.

Needed for #4074
ImeevMA added a commit that referenced this issue Apr 9, 2019
Thise macros unused and should be removed.

Needed for #4074
ImeevMA added a commit that referenced this issue Apr 9, 2019
These functions unused and should be removed.

Needed for #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
Errors SQL_TARANTOOL_DELETE_FAIL, SQL_TARANTOOL_ITERATOR_FAIL and
SQL_TARANTOOL_INSERT_FAIL have almost no functionality, but can
lead to incorrect behavior. This patch replaces them with
SQL_TARANTOOL_ERROR.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
Currently, the mayAbort field is used only in one place in debug
mode and is not used in non-debug mode. This patch removes this
field.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
Before this patch it was possible to have an error code with wrong
error description. This patch fixes it.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
After this patch, the only error code that the OP_Halt opcode
will work with is SQL_TARANTOOL_ERROR.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
Currently, the mayAbort field is used only in one place in debug
mode and is not used in non-debug mode. This patch removes this
field.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
Before this patch it was possible to have an error code with wrong
error description. This patch fixes it.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
After this patch, the only error code that the OP_Halt opcode
will work with is SQL_TARANTOOL_ERROR.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 12, 2019
This patch removes part of unused functions and macros from
main.c. This will facilitate the work of removing SQL error/status
codes.

Needed for #4074
ImeevMA added a commit that referenced this issue Apr 13, 2019
This patch removes part of unused functions and macros from
main.c. This will facilitate the work of removing SQL error/status
codes.

Needed for #4074
kyukhin pushed a commit that referenced this issue Apr 23, 2019
This patch removes part of unused functions and macros from
main.c. This will facilitate the work of removing SQL error/status
codes.

Needed for #4074
ImeevMA added a commit that referenced this issue Apr 24, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 26, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 26, 2019
Since the interrupt system is no longer used in SQL, the
SQL_INTERRUPT error is out of date and should be removed. Also
this patch removes currently unused progress callback system.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 26, 2019
This patch replaces SQL error SQL_MISMATCH by Tarantool error
ER_SQL_TYPE_MISMATCH.

Part of #4074
ImeevMA added a commit that referenced this issue Apr 26, 2019
After this patch, all errors in VDBE will be set using diag_set().

Part of #4074
ImeevMA added a commit that referenced this issue Apr 27, 2019
This field become unused and should be removed.

Part of #4074
ImeevMA added a commit that referenced this issue May 5, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
ImeevMA added a commit that referenced this issue May 5, 2019
After this patch, all errors in VDBE will be set using diag_set().

Part of #4074
ImeevMA added a commit that referenced this issue May 5, 2019
After this patch, all errors in the SQL functions will be set
using diag_set().

Closes #4074
ImeevMA added a commit that referenced this issue May 5, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
ImeevMA added a commit that referenced this issue May 5, 2019
After this patch, all errors in VDBE will be set using diag_set().

Part of #4074
ImeevMA added a commit that referenced this issue May 5, 2019
After this patch, all errors in the SQL functions will be set
using diag_set().

Closes #4074
ImeevMA added a commit that referenced this issue May 28, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
ImeevMA added a commit that referenced this issue May 28, 2019
After this patch, all errors in the SQL functions will be set
using diag_set().

Part of #4074
ImeevMA added a commit that referenced this issue May 28, 2019
After this patch, all errors in VDBE will be set using diag_set().

Closes #4074
ImeevMA pushed a commit that referenced this issue May 28, 2019
@Totktonada
Copy link
Member

I'm a bit late, but it worth to have SQLSTATE errors in a mind when designing the error codes: ODBC and JDBC connectors will need to map tarantool's error codes into SQLSTATE (until we'll support them natively). I found it helpful to have meaningful SQLSTATE codes in a connector, at least because some tools (that are use an ODBC API) show you just code w/o a message when something went wrong. See https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/appendix-a-odbc-error-codes?view=sql-server-2017 for the list of SQLSTATE codes.

@kostja
Copy link
Contributor

kostja commented May 31, 2019

diag_set() was designed with sqlstate codes in mind. Just go ahead and augment errcode.h/c with sqlstates. The sqlstate should be chosen by diag_set() automatically, based on the error code, and sent to the client in an extra field. Or you could make sqlstate table an additional piece of metadata available in box.error, so that you can download it on the client and do the mapping on the client. This way you don't even need to change the protocol.

@kostja
Copy link
Contributor

kostja commented May 31, 2019

sqlstate works is clearly outside the scope of this patch, though.

@Totktonada
Copy link
Member

Now we support mapping in tarantool-c (in WIP ODBC implementation), this is okay. If we'll decide to add these codes to the protocol in the future it would be convenient for connectors, but of course it is not a blocker and not the scope of this issue.

Don't get the idea about placing sqlstate in box.error w/o touching protocol. It'll not help ODBC/JDBC, because a separate call to catch a last error can show an error from another request. It can help cases when we're able to define a custom function in tarantool.

@kostja
Copy link
Contributor

kostja commented May 31, 2019

I meant this:

---
- NO_SUCH_FIELD_NAME: 153
  UNKNOWN_REPLICA: 62
  WRONG_INDEX_RECORD: 106
  NO_SUCH_TRIGGER: 34
  SEQUENCE_EXISTS: 146
  CHECKPOINT_IN_PROGRESS: 120
  CONSTRAINT_EXISTS: 170
  FIELD_TYPE: 23
  SQL_BIND_PARAMETER_MAX: 158
  WRONG_SPACE_FORMAT: 141

Today it shows a list of all available errors with all their codes. Tomorrow it could list their SQLSTATES as well, not just the codes.
The client could load this data along with the schema.

ImeevMA added a commit that referenced this issue Jun 3, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
ImeevMA added a commit that referenced this issue Jun 3, 2019
After this patch, all errors in the SQL functions will be set
using diag_set().

Part of #4074
ImeevMA added a commit that referenced this issue Jun 3, 2019
After this patch, all errors in VDBE will be set using diag_set().

Closes #4074
Gerold103 pushed a commit that referenced this issue Jun 4, 2019
After this patch, all errors in the SQL functions will be set
using diag_set().

Part of #4074
Gerold103 pushed a commit that referenced this issue Jun 4, 2019
After this patch, all errors in VDBE will be set using diag_set().

Closes #4074
ImeevMA added a commit that referenced this issue Jun 8, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
ImeevMA added a commit that referenced this issue Jun 8, 2019
After this patch, all errors in the SQL functions will be set
using diag_set().

Part of #4074
ImeevMA added a commit that referenced this issue Jun 8, 2019
After this patch, all errors in VDBE will be set using diag_set().

Closes #4074
ImeevMA pushed a commit that referenced this issue Jun 10, 2019
kyukhin pushed a commit that referenced this issue Jun 13, 2019
Currently, in OP_Halt, you can get a SQL error other than
SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After
this patch, all errors going through OP_Halt will have SQL error
code SQL_TARANTOOL_ERROR and have diag set.

Part of #4074
kyukhin pushed a commit that referenced this issue Jun 13, 2019
After this patch, all errors in the SQL functions will be set
using diag_set().

Part of #4074
Gerold103 pushed a commit that referenced this issue Jun 13, 2019
ImeevMA pushed a commit that referenced this issue Jun 14, 2019
ImeevMA pushed a commit that referenced this issue Jun 15, 2019
ImeevMA pushed a commit that referenced this issue Jun 19, 2019
ImeevMA pushed a commit that referenced this issue Jun 19, 2019
kyukhin pushed a commit that referenced this issue Jun 20, 2019
@kyukhin kyukhin added the tmp label Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality refactoring Code refactoring sql
Projects
None yet
Development

No branches or pull requests

4 participants