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 D2DBD27361 for ; Thu, 12 Jul 2018 22:04:33 -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 pDtJw-aM589W for ; Thu, 12 Jul 2018 22:04:33 -0400 (EDT) Received: from smtp42.i.mail.ru (smtp42.i.mail.ru [94.100.177.102]) (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 8F63727352 for ; Thu, 12 Jul 2018 22:04:33 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 5/5] sql: remove SQLITE_OMIT_FOREIGN_KEY define guard Date: Fri, 13 Jul 2018 05:04:21 +0300 Message-Id: <4cd7a6c2178c64a73744f5b7040f4c5c9c63fe78.1531443603.git.korablev@tarantool.org> In-Reply-To: References: 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: v.shpilevoy@tarantool.org, Nikita Pettik We always compile with enabled foreign keys constraints. They still can be turned off by in runtime. Follow-up #3271 --- extra/mkkeywordhash.c | 6 +----- src/box/sql/insert.c | 2 -- src/box/sql/pragma.c | 2 -- src/box/sql/pragma.h | 6 ------ src/box/sql/sqliteInt.h | 7 ------- src/box/sql/vdbe.c | 2 -- src/box/sql/vdbeInt.h | 4 ---- src/box/sql/vdbeaux.c | 4 ---- 8 files changed, 1 insertion(+), 32 deletions(-) diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c index 6ba872acc..f8e6636f6 100644 --- a/extra/mkkeywordhash.c +++ b/extra/mkkeywordhash.c @@ -80,11 +80,7 @@ struct Keyword { # define CONFLICT 0x00000080 #endif #define EXPLAIN 0x00000100 -#ifdef SQLITE_OMIT_FOREIGN_KEY -# define FKEY 0 -#else -# define FKEY 0x00000200 -#endif +#define FKEY 0x00000200 #ifdef SQLITE_OMIT_PRAGMA # define PRAGMA 0 #else diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c index f7bee1a66..890a251b5 100644 --- a/src/box/sql/insert.c +++ b/src/box/sql/insert.c @@ -1877,7 +1877,6 @@ xferOptimization(Parse * pParse, /* Parser context */ /* Tables have different CHECK constraints. Ticket #2252 */ return 0; } -#ifndef SQLITE_OMIT_FOREIGN_KEY /* Disallow the transfer optimization if the destination table constains * any foreign key constraints. This is more restrictive than necessary. * So the extra complication to make this rule less restrictive is probably @@ -1888,7 +1887,6 @@ xferOptimization(Parse * pParse, /* Parser context */ if ((user_session->sql_flags & SQLITE_ForeignKeys) != 0 && dest->child_fkey != NULL) return 0; -#endif if ((user_session->sql_flags & SQLITE_CountRows) != 0) { return 0; /* xfer opt does not play well with PRAGMA count_changes */ } diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 8a736859a..50f1ff894 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -561,7 +561,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ } #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */ -#ifndef SQLITE_OMIT_FOREIGN_KEY case PragTyp_FOREIGN_KEY_LIST:{ if (zRight == NULL) break; @@ -599,7 +598,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ } break; } -#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ #ifndef NDEBUG case PragTyp_PARSER_TRACE:{ if (zRight) { diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h index b1a169ed1..68bc0d9c3 100644 --- a/src/box/sql/pragma.h +++ b/src/box/sql/pragma.h @@ -127,31 +127,25 @@ static const PragmaName aPragmaName[] = { /* iArg: */ SQLITE_CountRows}, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) -#if !defined(SQLITE_OMIT_FOREIGN_KEY) { /* zName: */ "defer_foreign_keys", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_DeferFKs}, #endif -#endif -#if !defined(SQLITE_OMIT_FOREIGN_KEY) { /* zName: */ "foreign_key_list", /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST, /* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt, /* ColNames: */ 29, 8, /* iArg: */ 0}, -#endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) -#if !defined(SQLITE_OMIT_FOREIGN_KEY) { /* zName: */ "foreign_keys", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_ForeignKeys}, #endif -#endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) { /* zName: */ "full_column_names", /* ePragTyp: */ PragTyp_FLAG, diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index f882d747d..36a2feaa5 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -4701,13 +4701,6 @@ void sqlite3WithPush(Parse *, With *, u8); #define sqlite3WithDelete(x,y) #endif -/* Declarations for functions in fkey.c. All of these are replaced by - * no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign - * key functionality is available. If OMIT_TRIGGER is defined but - * OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In - * this case foreign keys are parsed, but no other functionality is - * provided (enforcement of FK constraints requires the triggers sub-system). - */ void sqlite3FkCheck(Parse *, Table *, int, int, int *); void sqlite3FkDropTable(Parse *, SrcList *, Table *); void sqlite3FkActions(Parse *, Table *, ExprList *, int, int *); diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 0f227e637..c2dd5f093 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -4967,7 +4967,6 @@ case OP_Param: { /* out2 */ break; } -#ifndef SQLITE_OMIT_FOREIGN_KEY /* Opcode: FkCounter P1 P2 * * * * Synopsis: fkctr[P1]+=P2 * @@ -5011,7 +5010,6 @@ case OP_FkIfZero: { /* jump */ } break; } -#endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */ /* Opcode: IfPos P1 P2 P3 * * * Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index e5ed94cea..8d4fa9bb7 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -511,11 +511,7 @@ void sqlite3VdbeMemAboutToChange(Vdbe *, Mem *); int sqlite3VdbeCheckMemInvariants(Mem *); #endif -#ifndef SQLITE_OMIT_FOREIGN_KEY int sqlite3VdbeCheckFk(Vdbe *, int); -#else -#define sqlite3VdbeCheckFk(p,i) 0 -#endif int sqlite3VdbeMemTranslate(Mem *, u8); #ifdef SQLITE_DEBUG diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index cec0ed647..2a551e09b 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -631,11 +631,9 @@ sqlite3VdbeAssertMayAbort(Vdbe * v, int mayAbort) hasAbort = 1; break; } -#ifndef SQLITE_OMIT_FOREIGN_KEY if (opcode == OP_FkCounter && pOp->p1 == 0 && pOp->p2 == 1) { hasFkCounter = 1; } -#endif } sqlite3DbFree(v->db, sIter.apSub); @@ -2333,7 +2331,6 @@ sqlite3VdbeCloseStatement(Vdbe * p, int eOp) * SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY * and write an error message to it. Then return SQLITE_ERROR. */ -#ifndef SQLITE_OMIT_FOREIGN_KEY int sqlite3VdbeCheckFk(Vdbe * p, int deferred) { @@ -2347,7 +2344,6 @@ sqlite3VdbeCheckFk(Vdbe * p, int deferred) } return SQLITE_OK; } -#endif int sql_txn_begin(Vdbe *p) -- 2.15.1