From: AKhatskevich <avkhatskevich@tarantool.org> To: korablev@tarantool.org, tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH 2/3] sql: delete foreign_keys pragma Date: Tue, 2 Oct 2018 13:48:35 +0300 [thread overview] Message-ID: <df0aa200035d6e192abcaa65fdb47195eee8c41c.1538476785.git.avkhatskevich@tarantool.org> (raw) In-Reply-To: <cover.1538476785.git.avkhatskevich@tarantool.org> In-Reply-To: <cover.1538476785.git.avkhatskevich@tarantool.org> Part of #3696 --- src/box/sql.c | 3 +-- src/box/sql/CMakeLists.txt | 1 - src/box/sql/fkey.c | 21 ++++----------------- src/box/sql/insert.c | 3 +-- src/box/sql/pragma.h | 7 ------- src/box/sql/sqliteInt.h | 2 +- test/sql-tap/tkt-b1d3a2e531.test.lua | 8 +------- test/sql-tap/triggerC.test.lua | 5 +---- test/sql/transitive-transactions.result | 3 --- test/sql/transitive-transactions.test.lua | 1 - 10 files changed, 9 insertions(+), 45 deletions(-) diff --git a/src/box/sql.c b/src/box/sql.c index ab4a587a5..a9077dd32 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -59,8 +59,7 @@ static const char nil_key[] = { 0x90 }; /* Empty MsgPack array. */ static const uint32_t default_sql_flags = SQLITE_ShortColNames | SQLITE_EnableTrigger | SQLITE_AutoIndex - | SQLITE_RecTriggers - | SQLITE_ForeignKeys; + | SQLITE_RecTriggers; void sql_init() diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt index 1f852424a..aa57add59 100644 --- a/src/box/sql/CMakeLists.txt +++ b/src/box/sql/CMakeLists.txt @@ -16,7 +16,6 @@ include_directories(${SQL_SRC_DIR}) include_directories(${SQL_BIN_DIR}) add_definitions(-DSQLITE_MAX_WORKER_THREADS=0) -add_definitions(-DSQLITE_DEFAULT_FOREIGN_KEYS=1) add_definitions(-DSQLITE_OMIT_AUTOMATIC_INDEX) set(TEST_DEFINITIONS diff --git a/src/box/sql/fkey.c b/src/box/sql/fkey.c index b2d2a19e7..091778fc8 100644 --- a/src/box/sql/fkey.c +++ b/src/box/sql/fkey.c @@ -527,12 +527,6 @@ fkey_emit_check(struct Parse *parser, struct Table *tab, int reg_old, */ assert((reg_old == 0) != (reg_new == 0)); - /* - * If foreign-keys are disabled, this function is a no-op. - */ - if ((user_session->sql_flags & SQLITE_ForeignKeys) == 0) - return; - /* * Loop through all the foreign key constraints for which * tab is the child table. @@ -674,9 +668,6 @@ fkey_emit_check(struct Parse *parser, struct Table *tab, int reg_old, bool fkey_is_required(uint32_t space_id, const int *changes) { - struct session *user_session = current_session(); - if ((user_session->sql_flags & SQLITE_ForeignKeys) == 0) - return false; struct space *space = space_by_id(space_id); if (changes == NULL) { /* @@ -919,16 +910,12 @@ void fkey_emit_actions(struct Parse *parser, struct Table *tab, int reg_old, const int *changes) { - struct session *user_session = current_session(); /* - * If foreign-key support is enabled, iterate through all - * FKs that refer to table tab. If there is an action - * associated with the FK for this operation (either - * update or delete), invoke the associated trigger - * sub-program. + * Iterate through all FKs that refer to table tab. + * If there is an action associated with the FK for + * this operation (either update or delete), + * invoke the associated trigger sub-program. */ - if ((user_session->sql_flags & SQLITE_ForeignKeys) == 0) - return; struct space *space = space_by_id(tab->def->id); assert(space != NULL); struct fkey *fk; diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c index 03f4e1b14..c696f39f1 100644 --- a/src/box/sql/insert.c +++ b/src/box/sql/insert.c @@ -1278,8 +1278,7 @@ xferOptimization(Parse * pParse, /* Parser context */ * So the extra complication to make this rule less restrictive is probably * not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] */ - if ((user_session->sql_flags & SQLITE_ForeignKeys) != 0 && - !rlist_empty(&dest->child_fkey)) + if (!rlist_empty(&dest->child_fkey)) return 0; 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.h b/src/box/sql/pragma.h index ecc9ee879..c135202d4 100644 --- a/src/box/sql/pragma.h +++ b/src/box/sql/pragma.h @@ -135,13 +135,6 @@ static const PragmaName aPragmaName[] = { PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt, /* ColNames: */ 29, 8, /* iArg: */ 0}, -#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) - { /* zName: */ "foreign_keys", - /* ePragTyp: */ PragTyp_FLAG, - /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1, - /* ColNames: */ 0, 0, - /* iArg: */ SQLITE_ForeignKeys}, -#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 e9c15dbb3..b2d527834 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -1562,7 +1562,7 @@ struct sqlite3 { #define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */ #define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */ #define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */ -#define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */ +/* 0x00080000 Free bit */ #define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */ #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */ #define SQLITE_EnableTrigger 0x01000000 /* True to enable triggers */ diff --git a/test/sql-tap/tkt-b1d3a2e531.test.lua b/test/sql-tap/tkt-b1d3a2e531.test.lua index 85b0f46d7..324ffa0c8 100755 --- a/test/sql-tap/tkt-b1d3a2e531.test.lua +++ b/test/sql-tap/tkt-b1d3a2e531.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(12) +test:plan(11) --!./tcltestrunner.lua -- 2011 August 22 @@ -24,12 +24,6 @@ test:plan(12) testprefix = "tkt-b1d3a2e531" -test:do_execsql_test( - 1.0, - [[ - PRAGMA foreign_keys = 'ON' - ]]) - test:do_execsql_test( 1.1, [[ diff --git a/test/sql-tap/triggerC.test.lua b/test/sql-tap/triggerC.test.lua index 06e6e5bd2..d5fdc1470 100755 --- a/test/sql-tap/triggerC.test.lua +++ b/test/sql-tap/triggerC.test.lua @@ -1146,12 +1146,10 @@ test:do_execsql_test( test:do_execsql_test( "triggerC-15.1.1", [[ - -- test is not respects fk - PRAGMA foreign_keys='false'; PRAGMA recursive_triggers = 1; CREATE TABLE node( id not null primary key, - pid int not null default 0 references node, + pid int not null default 0, key varchar not null, path varchar default '', unique(pid, key) @@ -1170,7 +1168,6 @@ test:do_execsql_test( INSERT INTO node(id, pid, key) VALUES(900, 90, 'test2'); DELETE FROM node WHERE id=9; SELECT * FROM node; - PRAGMA foreign_keys='true'; ]]) -- Tarantool: such indentifiers are not working diff --git a/test/sql/transitive-transactions.result b/test/sql/transitive-transactions.result index a01b1d0b0..88685b4c1 100644 --- a/test/sql/transitive-transactions.result +++ b/test/sql/transitive-transactions.result @@ -27,9 +27,6 @@ box.sql.execute('START TRANSACTION;') box.commit(); box.sql.execute('START TRANSACTION;') box.rollback(); --- ... -box.sql.execute('pragma foreign_keys = 1;'); ---- -... box.sql.execute('CREATE TABLE parent(id INT PRIMARY KEY, y INT UNIQUE);'); --- ... diff --git a/test/sql/transitive-transactions.test.lua b/test/sql/transitive-transactions.test.lua index 1ac2b8d64..5127202e3 100644 --- a/test/sql/transitive-transactions.test.lua +++ b/test/sql/transitive-transactions.test.lua @@ -13,7 +13,6 @@ box.begin() box.sql.execute('ROLLBACK'); box.sql.execute('START TRANSACTION;') box.commit(); box.sql.execute('START TRANSACTION;') box.rollback(); -box.sql.execute('pragma foreign_keys = 1;'); box.sql.execute('CREATE TABLE parent(id INT PRIMARY KEY, y INT UNIQUE);'); box.sql.execute('CREATE TABLE child(id INT PRIMARY KEY, x INT REFERENCES parent(y) DEFERRABLE INITIALLY DEFERRED);'); -- 2.14.1
next prev parent reply other threads:[~2018-10-02 10:49 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-02 10:48 [tarantool-patches] [PATCH 0/3] Delete foreign_keys and ignore_check_constraints pragmas AKhatskevich 2018-10-02 10:48 ` [tarantool-patches] [PATCH 1/3] sql: delete unused code AKhatskevich 2018-10-02 13:36 ` [tarantool-patches] " n.pettik 2018-10-04 15:16 ` Alex Khatskevich 2018-10-02 10:48 ` AKhatskevich [this message] 2018-10-02 13:36 ` [tarantool-patches] Re: [PATCH 2/3] sql: delete foreign_keys pragma n.pettik 2018-10-04 15:16 ` Alex Khatskevich 2018-10-02 10:48 ` [tarantool-patches] [PATCH 3/3] sql: delete ignore_check_constraints pragma AKhatskevich 2018-10-02 13:36 ` [tarantool-patches] " n.pettik 2018-10-04 15:16 ` Alex Khatskevich 2018-10-04 16:27 ` [tarantool-patches] Re: [PATCH 0/3] Delete foreign_keys and ignore_check_constraints pragmas n.pettik 2018-10-05 7:15 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=df0aa200035d6e192abcaa65fdb47195eee8c41c.1538476785.git.avkhatskevich@tarantool.org \ --to=avkhatskevich@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH 2/3] sql: delete foreign_keys pragma' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox