From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id DC0FD266A7 for ; Sun, 15 Jul 2018 16:44:56 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DTtbDSNWSW8A for ; Sun, 15 Jul 2018 16:44:56 -0400 (EDT) Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 9AD5026494 for ; Sun, 15 Jul 2018 16:44:56 -0400 (EDT) From: Georgy Kirichenko Subject: [tarantool-patches] [PATCH 2/5] Split on_conflict_action and affinity Date: Sun, 15 Jul 2018 23:44:47 +0300 Message-Id: <5900e289bcef0f9657f082c6d99e8d76efa8aef1.1531686753.git.georgy@tarantool.org> In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Georgy Kirichenko --- src/box/sql/expr.c | 14 +++++++------- src/box/sql/fkey.c | 2 +- src/box/sql/parse.y | 4 ++-- src/box/sql/sqliteInt.h | 3 ++- src/box/sql/treeview.c | 6 ++++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index 3183e3dc7..29970da59 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -4297,20 +4297,20 @@ sqlite3ExprCodeTarget(Parse * pParse, Expr * pExpr, int target) break; } case TK_RAISE:{ - assert(pExpr->affinity == ON_CONFLICT_ACTION_ROLLBACK - || pExpr->affinity == ON_CONFLICT_ACTION_ABORT - || pExpr->affinity == ON_CONFLICT_ACTION_FAIL - || pExpr->affinity == ON_CONFLICT_ACTION_IGNORE); + assert(pExpr->on_conflict_action == ON_CONFLICT_ACTION_ROLLBACK + || pExpr->on_conflict_action == ON_CONFLICT_ACTION_ABORT + || pExpr->on_conflict_action == ON_CONFLICT_ACTION_FAIL + || pExpr->on_conflict_action == ON_CONFLICT_ACTION_IGNORE); if (!pParse->pTriggerTab) { sqlite3ErrorMsg(pParse, "RAISE() may only be used within a trigger-program"); return 0; } - if (pExpr->affinity == ON_CONFLICT_ACTION_ABORT) { + if (pExpr->on_conflict_action == ON_CONFLICT_ACTION_ABORT) { sqlite3MayAbort(pParse); } assert(!ExprHasProperty(pExpr, EP_IntValue)); - if (pExpr->affinity == ON_CONFLICT_ACTION_IGNORE) { + if (pExpr->on_conflict_action == ON_CONFLICT_ACTION_IGNORE) { sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_OK, ON_CONFLICT_ACTION_IGNORE, 0, pExpr->u.zToken, @@ -4319,7 +4319,7 @@ sqlite3ExprCodeTarget(Parse * pParse, Expr * pExpr, int target) } else { sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER, - pExpr->affinity, + pExpr->on_conflict_action, pExpr->u.zToken, 0, 0); } diff --git a/src/box/sql/fkey.c b/src/box/sql/fkey.c index 6c75c4772..16c8b8edd 100644 --- a/src/box/sql/fkey.c +++ b/src/box/sql/fkey.c @@ -1374,7 +1374,7 @@ fkActionTrigger(struct Parse *pParse, struct Table *pTab, struct FKey *pFKey, sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed"); if (pRaise) { - pRaise->affinity = ON_CONFLICT_ACTION_ABORT; + pRaise->on_conflict_action = ON_CONFLICT_ACTION_ABORT; } pSelect = sqlite3SelectNew(pParse, sql_expr_list_append(pParse->db, diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index b2940b7c4..4b5893152 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -1402,14 +1402,14 @@ expr(A) ::= RAISE(X) LP IGNORE RP(Y). { spanSet(&A,&X,&Y); /*A-overwrites-X*/ A.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0); if( A.pExpr ){ - A.pExpr->affinity = ON_CONFLICT_ACTION_IGNORE; + A.pExpr->on_conflict_action = ON_CONFLICT_ACTION_IGNORE; } } expr(A) ::= RAISE(X) LP raisetype(T) COMMA STRING(Z) RP(Y). { spanSet(&A,&X,&Y); /*A-overwrites-X*/ A.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &Z, 1); if( A.pExpr ) { - A.pExpr->affinity = (char)T; + A.pExpr->on_conflict_action = (char)T; } } diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index 8b75ae888..2b3d6a35d 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -2294,7 +2294,8 @@ typedef int ynVar; */ struct Expr { u8 op; /* Operation performed by this node */ - char affinity; /* The affinity of the column or 0 if not a column */ + enum affinity_type affinity; /* The affinity of the column or 0 if not a column */ + enum on_conflict_action on_conflict_action; u32 flags; /* Various flags. EP_* See below */ union { char *zToken; /* Token value. Zero terminated and dequoted */ diff --git a/src/box/sql/treeview.c b/src/box/sql/treeview.c index 4261e733e..90f5c466b 100644 --- a/src/box/sql/treeview.c +++ b/src/box/sql/treeview.c @@ -566,8 +566,8 @@ sqlite3TreeViewExpr(TreeView * pView, const Expr * pExpr, u8 moreToFollow) break; } case TK_RAISE:{ - const char *zType = "unk"; - switch (pExpr->affinity) { + const char *zType; + switch (pExpr->on_conflict_action) { case ON_CONFLICT_ACTION_ROLLBACK: zType = "rollback"; break; @@ -580,6 +580,8 @@ sqlite3TreeViewExpr(TreeView * pView, const Expr * pExpr, u8 moreToFollow) case ON_CONFLICT_ACTION_IGNORE: zType = "ignore"; break; + default: + zType = "unk"; } sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken); -- 2.18.0