From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH 5/5] sql: remove SQLITE_OMIT_FOREIGN_KEY define guard
Date: Fri, 13 Jul 2018 05:04:21 +0300 [thread overview]
Message-ID: <4cd7a6c2178c64a73744f5b7040f4c5c9c63fe78.1531443603.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1531443603.git.korablev@tarantool.org>
In-Reply-To: <cover.1531443603.git.korablev@tarantool.org>
We always compile with enabled foreign keys constraints. They still can
be turned off by <pragma foreign_keys = false> in runtime.
Follow-up #3271
---
| 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(-)
--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
next prev parent reply other threads:[~2018-07-13 2:04 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-13 2:04 [tarantool-patches] [PATCH 0/5] Move FK constraints to server Nikita Pettik
2018-07-13 2:04 ` [tarantool-patches] [PATCH 1/5] sql: prohibit creation of FK on unexisting tables Nikita Pettik
2018-07-17 21:05 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-25 10:03 ` n.pettik
2018-07-26 20:12 ` Vladislav Shpilevoy
2018-08-01 20:54 ` n.pettik
2018-08-02 22:15 ` Vladislav Shpilevoy
2018-08-06 0:27 ` n.pettik
2018-07-13 2:04 ` [tarantool-patches] [PATCH 2/5] schema: add new system space for FK constraints Nikita Pettik
2018-07-17 21:05 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-25 10:03 ` n.pettik
2018-07-26 20:12 ` Vladislav Shpilevoy
2018-08-01 20:54 ` n.pettik
2018-08-02 22:15 ` Vladislav Shpilevoy
2018-08-06 0:28 ` n.pettik
2018-08-06 18:24 ` Vladislav Shpilevoy
2018-07-13 2:04 ` [tarantool-patches] [PATCH 3/5] sql: introduce ADD CONSTRAINT statement Nikita Pettik
2018-07-17 21:05 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-25 10:03 ` n.pettik
2018-07-26 20:12 ` Vladislav Shpilevoy
2018-08-01 20:54 ` n.pettik
2018-08-02 22:15 ` Vladislav Shpilevoy
2018-08-06 0:28 ` n.pettik
2018-08-06 18:24 ` Vladislav Shpilevoy
2018-08-06 23:43 ` n.pettik
2018-07-13 2:04 ` [tarantool-patches] [PATCH 4/5] sql: display error on FK creation and drop failure Nikita Pettik
2018-07-17 21:04 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-25 10:03 ` n.pettik
2018-07-26 20:11 ` Vladislav Shpilevoy
2018-07-13 2:04 ` Nikita Pettik [this message]
2018-07-17 21:04 ` [tarantool-patches] Re: [PATCH 0/5] Move FK constraints to server Vladislav Shpilevoy
2018-08-07 14:57 ` 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=4cd7a6c2178c64a73744f5b7040f4c5c9c63fe78.1531443603.git.korablev@tarantool.org \
--to=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [tarantool-patches] [PATCH 5/5] sql: remove SQLITE_OMIT_FOREIGN_KEY define guard' \
/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