[tarantool-patches] Re: [PATCH v1 04/12] sql: make SQL_TARANTOOL_ERROR the only errcode of OP_Halt
Imeev Mergen
imeevma at tarantool.org
Sat May 25 12:18:11 MSK 2019
On 5/15/19 4:18 PM, n.pettik wrote:
>
>> On 5 May 2019, at 15:17, imeevma at tarantool.org wrote:
>>
>> 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.
>>
>> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
>> index 9f0d760..85cec85 100644
>> --- a/src/box/sql/vdbe.c
>> +++ b/src/box/sql/vdbe.c
>> @@ -1031,25 +1031,10 @@ case OP_Halt: {
>> p->errorAction = (u8)pOp->p2;
>> p->pc = pcx;
>> if (p->rc) {
>> - if (p->rc == SQL_TARANTOOL_ERROR) {
>> - if (pOp->p4.z != NULL)
>> - diag_set(ClientError, pOp->p5, pOp->p4.z);
>> - assert(! diag_is_empty(diag_get()));
>> - } else if (pOp->p5 != 0) {
>> - static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK",
>> - "FOREIGN KEY" };
>> - testcase( pOp->p5==1);
>> - testcase( pOp->p5==2);
>> - testcase( pOp->p5==3);
>> - testcase( pOp->p5==4);
>> - sqlVdbeError(p, "%s constraint failed", azType[pOp->p5-1]);
>> - if (pOp->p4.z) {
>> - p->zErrMsg = sqlMPrintf(db, "%z: %s", p->zErrMsg, pOp->p4.z);
>> - }
>> - } else {
>> - sqlVdbeError(p, "%s", pOp->p4.z);
>> - }
>> - sql_log(pOp->p1, "abort at %d in [%s]: %s", pcx, p->zSql, p->zErrMsg);
>> + assert(p->rc == SQL_TARANTOOL_ERROR);
> Still don’t understand why can’t we use only 0/-1 for rc.
This is done in one of the following patches.
More information about the Tarantool-patches
mailing list