[patches] [PATCH 8/8] sql: remove backend authorization, OP_Transaction
Bulat Niatshin
niatshin at tarantool.org
Wed Feb 21 15:33:21 MSK 2018
Remove every code used for sqlite backend authorization, because it is
completely unnecessary now. Also remove OP_Transaction, modify
OP_TTransaction, regenerate opcodes.
For #3119
---
extra/mkopcodeh.tcl | 2 +-
src/box/sql/alter.c | 14 -----
src/box/sql/build.c | 148 ++----------------------------------------------
src/box/sql/delete.c | 19 +------
src/box/sql/fkey.c | 20 +------
src/box/sql/func.c | 3 -
src/box/sql/insert.c | 3 -
src/box/sql/opcodes.c | 93 +++++++++++++++---------------
src/box/sql/opcodes.h | 105 +++++++++++++++++-----------------
src/box/sql/pragma.c | 2 -
src/box/sql/prepare.c | 11 ----
src/box/sql/resolve.c | 25 +-------
src/box/sql/select.c | 13 -----
src/box/sql/sqliteInt.h | 73 ------------------------
src/box/sql/trigger.c | 28 ---------
src/box/sql/update.c | 29 +---------
src/box/sql/vdbe.c | 68 ++++------------------
src/box/sql/vdbeaux.c | 2 +-
18 files changed, 122 insertions(+), 536 deletions(-)
diff --git a/extra/mkopcodeh.tcl b/extra/mkopcodeh.tcl
index bd86ac69a..e8b625910 100644
--- a/extra/mkopcodeh.tcl
+++ b/extra/mkopcodeh.tcl
@@ -128,7 +128,7 @@ foreach name {OP_Noop OP_Explain} {
# The following are the opcodes that are processed by resolveP2Values()
#
set rp2v_ops {
- OP_Transaction
+ OP_TTransaction
OP_AutoCommit
OP_Savepoint
OP_Checkpoint
diff --git a/src/box/sql/alter.c b/src/box/sql/alter.c
index 33194c98e..c8dda9633 100644
--- a/src/box/sql/alter.c
+++ b/src/box/sql/alter.c
@@ -114,13 +114,6 @@ sqlite3AlterRenameTable(Parse * pParse, /* Parser context. */
}
#endif
-#ifndef SQLITE_OMIT_AUTHORIZATION
- /* Invoke the authorization callback. */
- if (sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0)) {
- goto exit_rename_table;
- }
-#endif
-
/* Begin a transaction for database.
* Then modify the schema cookie (since the ALTER TABLE modifies the
* schema).
@@ -173,13 +166,6 @@ sqlite3AlterFinishAddColumn(Parse * pParse, Token * pColDef)
pTab = sqlite3FindTable(db, zTab);
assert(pTab);
-#ifndef SQLITE_OMIT_AUTHORIZATION
- /* Invoke the authorization callback. */
- if (sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0)) {
- return;
- }
-#endif
-
/* If the default value for the new column was specified with a
* literal NULL, then set pDflt to 0. This simplifies checking
* for an SQL NULL default below.
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index e63572865..37ea3151e 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -84,18 +84,6 @@ sqlite3FinishCoding(Parse * pParse)
if (v) {
sqlite3VdbeAddOp0(v, OP_Halt);
-#if SQLITE_USER_AUTHENTICATION
- if (pParse->nTableLock > 0 && db->init.busy == 0) {
- sqlite3UserAuthInit(db);
- if (db->auth.authLevel < UAUTH_User) {
- sqlite3ErrorMsg(pParse,
- "user not authenticated");
- pParse->rc = SQLITE_AUTH_USER;
- return;
- }
- }
-#endif
-
/* The cookie mask contains one bit for each database file open.
* (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are
* set for each database that is used. Generate code to start a
@@ -111,12 +99,9 @@ sqlite3FinishCoding(Parse * pParse)
Schema *pSchema;
if (DbMaskTest(pParse->cookieMask, 0) != 0) {
pSchema = db->pSchema;
- sqlite3VdbeAddOp2(v, OP_Transaction, /* Opcode */
- 0, /* P1 */
- DbMaskTest(pParse->writeMask, 0) /* P2 */
- );
- if (pParse->initiateTTrans)
- sqlite3VdbeAddOp0(v, OP_TTransaction);
+ sqlite3VdbeAddOp2(v, OP_TTransaction,
+ pParse->initiateTTrans ? 1 : 0,
+ DbMaskTest(pParse->writeMask, 0));
if (db->init.busy == 0)
sqlite3VdbeChangeP5(v, 1);
@@ -198,17 +183,6 @@ sqlite3NestedParse(Parse * pParse, const char *zFormat, ...)
pParse->nested--;
}
-#if SQLITE_USER_AUTHENTICATION
-/*
- * Return TRUE if zTable is the name of the system table that stores the
- * list of users and their access credentials.
- */
-int
-sqlite3UserAuthTable(const char *zTable)
-{
- return sqlite3_stricmp(zTable, "sqlite_user") == 0;
-}
-#endif
/*
* Locate the in-memory structure that describes a particular database
@@ -225,16 +199,6 @@ sqlite3UserAuthTable(const char *zTable)
Table *
sqlite3FindTable(sqlite3 * db, const char *zName)
{
-#if SQLITE_USER_AUTHENTICATION
- /* Only the admin user is allowed to know that the sqlite_user table
- * exists
- */
- if (db->auth.authLevel < UAUTH_Admin
- && sqlite3UserAuthTable(zName) != 0) {
- return 0;
- }
-#endif
-
return sqlite3HashFind(&db->pSchema->tblHash, zName);
}
@@ -663,26 +627,6 @@ sqlite3StartTable(Parse *pParse, Token *pName, int noErr)
pParse->sNameToken = *pName;
if (zName == 0)
return;
-#ifndef SQLITE_OMIT_AUTHORIZATION
- assert(isTemp == 0 || isTemp == 1);
- assert(isView == 0 || (isView == 1 && isTemp == 0));
- {
- static const u8 aCode[] = {
- SQLITE_CREATE_TABLE,
- SQLITE_CREATE_TEMP_TABLE,
- SQLITE_CREATE_VIEW
- };
- char *zDb = db->mdb.zDbSName;
- if (sqlite3AuthCheck
- (pParse, SQLITE_INSERT, MASTER_NAME, 0, zDb)) {
- goto begin_table_error;
- }
- if (sqlite3AuthCheck(pParse, (int)aCode[isTemp + 2 * isView],
- zName, 0, zDb)) {
- goto begin_table_error;
- }
- }
-#endif
/*
* Make sure the new table name does not collide with an
@@ -2133,9 +2077,6 @@ sqlite3ViewGetColumnNames(Parse * pParse, Table * pTable)
int nErr = 0; /* Number of errors encountered */
int n; /* Temporarily holds the number of cursors assigned */
sqlite3 *db = pParse->db; /* Database connection for malloc errors */
-#ifndef SQLITE_OMIT_AUTHORIZATION
- sqlite3_xauth xAuth; /* Saved xAuth pointer */
-#endif
assert(pTable);
@@ -2182,14 +2123,7 @@ sqlite3ViewGetColumnNames(Parse * pParse, Table * pTable)
sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
pTable->nCol = -1;
db->lookaside.bDisable++;
-#ifndef SQLITE_OMIT_AUTHORIZATION
- xAuth = db->xAuth;
- db->xAuth = 0;
pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
- db->xAuth = xAuth;
-#else
- pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
-#endif
pParse->nTab = n;
if (pTable->pCheck) {
/* CREATE VIEW name(arglist) AS ...
@@ -2401,27 +2335,6 @@ sqlite3DropTable(Parse * pParse, SrcList * pName, int isView, int noErr)
sqlite3CodeVerifySchema(pParse);
goto exit_drop_table;
}
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- int code;
- const char *zTab = MASTER_NAME;
- char *zDb = db->mdb.zDbSName;
- if (sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)) {
- goto exit_drop_table;
- }
- if (isView)
- code = SQLITE_DROP_VIEW;
- else
- code = SQLITE_DROP_TABLE;
- if (sqlite3AuthCheck(pParse, code, pTab->zName, NULL, zDb)) {
- goto exit_drop_table;
- }
- if (sqlite3AuthCheck
- (pParse, SQLITE_DELETE, pTab->zName, 0, zDb)) {
- goto exit_drop_table;
- }
- }
-#endif
#ifndef SQLITE_OMIT_VIEW
/* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used
* on a table.
@@ -2640,12 +2553,6 @@ sqlite3RefillIndex(Parse * pParse, Index * pIndex, int memRootPage)
KeyInfo *pKey; /* KeyInfo for index */
int regRecord; /* Register holding assembled index record */
sqlite3 *db = pParse->db; /* The database connection */
-#ifndef SQLITE_OMIT_AUTHORIZATION
- if (sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,
- db->mdb.zDbSName)) {
- return;
- }
-#endif
v = sqlite3GetVdbe(pParse);
if (v == 0)
return;
@@ -2986,22 +2893,6 @@ sqlite3CreateIndex(Parse * pParse, /* All information about this parse */
}
}
- /* Check for authorization to create an index.
- */
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- const char *zDb = pDb->zDbSName;
- if (sqlite3AuthCheck
- (pParse, SQLITE_INSERT, MASTER_NAME, 0, zDb)) {
- goto exit_create_index;
- }
- i = SQLITE_CREATE_INDEX;
- if (sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb)) {
- goto exit_create_index;
- }
- }
-#endif
-
/* If pList==0, it means this routine was called to make a primary
* key out of the last column added to the table under construction.
* So create a fake list to simulate this.
@@ -3409,20 +3300,6 @@ sqlite3DropIndex(Parse * pParse, SrcList * pName, Token * pName2, int ifExists)
0);
goto exit_drop_index;
}
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- int code = SQLITE_DROP_INDEX;
- const char *zDb = db->mdb.zDbSName;
- const char *zTab = MASTER_NAME;
- if (sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)) {
- goto exit_drop_index;
- }
- if (sqlite3AuthCheck(pParse, code, pIndex->zName,
- pIndex->pTable->zName, zDb)) {
- goto exit_drop_index;
- }
- }
-#endif
/* Generate code to remove the index and from the master table */
sqlite3BeginWriteOperation(pParse, 1);
@@ -3880,9 +3757,6 @@ sqlite3BeginTransaction(Parse * pParse, int MAYBE_UNUSED type)
assert(pParse != 0);
db = pParse->db;
assert(db != 0);
- if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0)) {
- return;
- }
v = sqlite3GetVdbe(pParse);
if (!v)
return;
@@ -3899,9 +3773,6 @@ sqlite3CommitTransaction(Parse * pParse)
assert(pParse != 0);
assert(pParse->db != 0);
- if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0)) {
- return;
- }
v = sqlite3GetVdbe(pParse);
if (v) {
sqlite3VdbeAddOp1(v, OP_AutoCommit, 1);
@@ -3918,9 +3789,6 @@ sqlite3RollbackTransaction(Parse * pParse)
assert(pParse != 0);
assert(pParse->db != 0);
- if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0)) {
- return;
- }
v = sqlite3GetVdbe(pParse);
if (v) {
sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 1);
@@ -3937,15 +3805,7 @@ sqlite3Savepoint(Parse * pParse, int op, Token * pName)
char *zName = sqlite3NameFromToken(pParse->db, pName);
if (zName) {
Vdbe *v = sqlite3GetVdbe(pParse);
- static const char *const az[] =
- { "BEGIN", "RELEASE", "ROLLBACK" };
-#ifndef SQLITE_OMIT_AUTHORIZATION
- assert(!SAVEPOINT_BEGIN && SAVEPOINT_RELEASE == 1
- && SAVEPOINT_ROLLBACK == 2);
-#endif
- if (!v
- || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName,
- 0)) {
+ if (!v) {
sqlite3DbFree(pParse->db, zName);
return;
}
diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c
index 33c11c956..06b0424dc 100644
--- a/src/box/sql/delete.c
+++ b/src/box/sql/delete.c
@@ -243,10 +243,8 @@ sqlite3DeleteFrom(Parse * pParse, /* The parser context */
int iIdxCur = 0; /* Cursor number of the first index */
int nIdx; /* Number of indices */
sqlite3 *db; /* Main database structure */
- AuthContext sContext; /* Authorization context */
NameContext sNC; /* Name context to resolve expressions in */
int memCnt = -1; /* Memory cell used for change counting */
- int rcauth; /* Value returned by authorization callback */
int eOnePass; /* ONEPASS_OFF or _SINGLE or _MULTI */
int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */
u8 *aToOpen = 0; /* Open cursor iTabCur+j if aToOpen[j] is true */
@@ -269,7 +267,6 @@ sqlite3DeleteFrom(Parse * pParse, /* The parser context */
Trigger *pTrigger; /* List of table triggers, if required */
#endif
- memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
if (pParse->nErr || db->mallocFailed) {
goto delete_from_cleanup;
@@ -310,13 +307,6 @@ sqlite3DeleteFrom(Parse * pParse, /* The parser context */
if (sqlite3IsReadOnly(pParse, pTab, (pTrigger ? 1 : 0))) {
goto delete_from_cleanup;
}
- rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0,
- "main");
- assert(rcauth == SQLITE_OK || rcauth == SQLITE_DENY
- || rcauth == SQLITE_IGNORE);
- if (rcauth == SQLITE_DENY) {
- goto delete_from_cleanup;
- }
assert(!isView || pTrigger);
/* Assign cursor numbers to the table and all its indices.
@@ -327,12 +317,6 @@ sqlite3DeleteFrom(Parse * pParse, /* The parser context */
pParse->nTab++;
}
- /* Start the view context
- */
- if (isView) {
- sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
- }
-
/* Begin generating code.
*/
v = sqlite3GetVdbe(pParse);
@@ -375,7 +359,7 @@ sqlite3DeleteFrom(Parse * pParse, /* The parser context */
* this optimization caused the row change count (the value returned by
* API function sqlite3_count_changes) to be set incorrectly.
*/
- if (rcauth == SQLITE_OK && pWhere == 0 && !bComplex
+ if (pWhere == 0 && !bComplex
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
&& db->xPreUpdateCallback == 0
#endif
@@ -586,7 +570,6 @@ sqlite3DeleteFrom(Parse * pParse, /* The parser context */
}
delete_from_cleanup:
- sqlite3AuthContextPop(&sContext);
sqlite3SrcListDelete(db, pTabList);
sqlite3ExprDelete(db, pWhere);
sqlite3DbFree(db, aToOpen);
diff --git a/src/box/sql/fkey.c b/src/box/sql/fkey.c
index 088d84e27..410bfed9e 100644
--- a/src/box/sql/fkey.c
+++ b/src/box/sql/fkey.c
@@ -797,7 +797,9 @@ sqlite3FkDropTable(Parse * pParse, SrcList * pName, Table * pTab)
pParse->disableTriggers = 1;
/* Staring new transaction before DELETE FROM <tbl> */
- sqlite3VdbeAddOp0(v, OP_TTransaction);
+ sqlite3VdbeAddOp2(v, OP_TTransaction,
+ 1,
+ DbMaskTest(pParse->writeMask, 0));
sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);
pParse->disableTriggers = 0;
@@ -1008,22 +1010,6 @@ sqlite3FkCheck(Parse * pParse, /* Parse context */
aiCol[i] = -1;
}
assert(pIdx == 0 || pIdx->aiColumn[i] >= 0);
-#ifndef SQLITE_OMIT_AUTHORIZATION
- /* Request permission to read the parent key columns. If the
- * authorization callback returns SQLITE_IGNORE, behave as if any
- * values read from the parent table are NULL.
- */
- if (db->xAuth) {
- int rcauth;
- char *zCol =
- pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->
- iPKey].zName;
- rcauth =
- sqlite3AuthReadCol(pParse, pTo->zName,
- zCol);
- bIgnore = (rcauth == SQLITE_IGNORE);
- }
-#endif
}
pParse->nTab++;
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index f60cbee31..d8d39a225 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -1843,9 +1843,6 @@ sqlite3RegisterBuiltinFunctions(void)
static FuncDef aBuiltinFunc[] = {
#ifdef SQLITE_SOUNDEX
FUNCTION(soundex, 1, 0, 0, soundexFunc),
-#endif
-#if SQLITE_USER_AUTHENTICATION
- FUNCTION(sqlite_crypt, 2, 0, 0, sqlite3CryptFunc),
#endif
FUNCTION2(unlikely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY),
FUNCTION2(likelihood, 2, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY),
diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index b20a47970..2844b5e6a 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -375,9 +375,6 @@ sqlite3Insert(Parse * pParse, /* Parser context */
if (pTab == 0) {
goto insert_cleanup;
}
- if (sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, "")) {
- goto insert_cleanup;
- }
/* Figure out if we have any triggers and if the table being
* inserted into is a view
diff --git a/src/box/sql/opcodes.c b/src/box/sql/opcodes.c
index 2d5dc62ef..4d5a9770f 100644
--- a/src/box/sql/opcodes.c
+++ b/src/box/sql/opcodes.c
@@ -13,7 +13,7 @@ const char *sqlite3OpcodeName(int i){
static const char *const azName[] = {
/* 0 */ "Savepoint" OpHelp(""),
/* 1 */ "AutoCommit" OpHelp(""),
- /* 2 */ "Transaction" OpHelp(""),
+ /* 2 */ "TTransaction" OpHelp(""),
/* 3 */ "SorterNext" OpHelp(""),
/* 4 */ "PrevIfOpen" OpHelp(""),
/* 5 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
@@ -103,53 +103,52 @@ const char *sqlite3OpcodeName(int i){
/* 89 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1 at P2])"),
/* 90 */ "Count" OpHelp("r[P2]=count()"),
/* 91 */ "FkCheckCommit" OpHelp(""),
- /* 92 */ "TTransaction" OpHelp(""),
- /* 93 */ "ReadCookie" OpHelp(""),
- /* 94 */ "SetCookie" OpHelp(""),
- /* 95 */ "ReopenIdx" OpHelp("root=P2"),
- /* 96 */ "OpenRead" OpHelp("root=P2"),
- /* 97 */ "OpenWrite" OpHelp("root=P2"),
- /* 98 */ "OpenTEphemeral" OpHelp("nColumn = P2"),
- /* 99 */ "SorterOpen" OpHelp(""),
- /* 100 */ "SequenceTest" OpHelp("if (cursor[P1].ctr++) pc = P2"),
- /* 101 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
- /* 102 */ "Close" OpHelp(""),
- /* 103 */ "ColumnsUsed" OpHelp(""),
- /* 104 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
- /* 105 */ "NextId" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
- /* 106 */ "NextIdEphemeral" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
- /* 107 */ "FCopy" OpHelp("reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)]"),
- /* 108 */ "Delete" OpHelp(""),
- /* 109 */ "ResetCount" OpHelp(""),
- /* 110 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
- /* 111 */ "SorterData" OpHelp("r[P2]=data"),
- /* 112 */ "RowData" OpHelp("r[P2]=data"),
- /* 113 */ "NullRow" OpHelp(""),
- /* 114 */ "SorterInsert" OpHelp("key=r[P2]"),
+ /* 92 */ "ReadCookie" OpHelp(""),
+ /* 93 */ "SetCookie" OpHelp(""),
+ /* 94 */ "ReopenIdx" OpHelp("root=P2"),
+ /* 95 */ "OpenRead" OpHelp("root=P2"),
+ /* 96 */ "OpenWrite" OpHelp("root=P2"),
+ /* 97 */ "OpenTEphemeral" OpHelp("nColumn = P2"),
+ /* 98 */ "SorterOpen" OpHelp(""),
+ /* 99 */ "SequenceTest" OpHelp("if (cursor[P1].ctr++) pc = P2"),
+ /* 100 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
+ /* 101 */ "Close" OpHelp(""),
+ /* 102 */ "ColumnsUsed" OpHelp(""),
+ /* 103 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
+ /* 104 */ "NextId" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
+ /* 105 */ "NextIdEphemeral" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
+ /* 106 */ "FCopy" OpHelp("reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)]"),
+ /* 107 */ "Delete" OpHelp(""),
+ /* 108 */ "ResetCount" OpHelp(""),
+ /* 109 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
+ /* 110 */ "SorterData" OpHelp("r[P2]=data"),
+ /* 111 */ "RowData" OpHelp("r[P2]=data"),
+ /* 112 */ "NullRow" OpHelp(""),
+ /* 113 */ "SorterInsert" OpHelp("key=r[P2]"),
+ /* 114 */ "IdxReplace" OpHelp("key=r[P2]"),
/* 115 */ "Real" OpHelp("r[P2]=P4"),
- /* 116 */ "IdxReplace" OpHelp("key=r[P2]"),
- /* 117 */ "IdxInsert" OpHelp("key=r[P2]"),
- /* 118 */ "IdxDelete" OpHelp("key=r[P2 at P3]"),
- /* 119 */ "Destroy" OpHelp(""),
- /* 120 */ "Clear" OpHelp(""),
- /* 121 */ "ResetSorter" OpHelp(""),
- /* 122 */ "ParseSchema2" OpHelp("rows=r[P1 at P2]"),
- /* 123 */ "ParseSchema3" OpHelp("name=r[P1] sql=r[P1+1]"),
- /* 124 */ "RenameTable" OpHelp("P1 = root, P4 = name"),
- /* 125 */ "LoadAnalysis" OpHelp(""),
- /* 126 */ "DropTable" OpHelp(""),
- /* 127 */ "DropIndex" OpHelp(""),
- /* 128 */ "DropTrigger" OpHelp(""),
- /* 129 */ "Param" OpHelp(""),
- /* 130 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
- /* 131 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
- /* 132 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2 at P5])"),
- /* 133 */ "AggStep" OpHelp("accum=r[P3] step(r[P2 at P5])"),
- /* 134 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
- /* 135 */ "Expire" OpHelp(""),
- /* 136 */ "IncMaxid" OpHelp(""),
- /* 137 */ "Noop" OpHelp(""),
- /* 138 */ "Explain" OpHelp(""),
+ /* 116 */ "IdxInsert" OpHelp("key=r[P2]"),
+ /* 117 */ "IdxDelete" OpHelp("key=r[P2 at P3]"),
+ /* 118 */ "Destroy" OpHelp(""),
+ /* 119 */ "Clear" OpHelp(""),
+ /* 120 */ "ResetSorter" OpHelp(""),
+ /* 121 */ "ParseSchema2" OpHelp("rows=r[P1 at P2]"),
+ /* 122 */ "ParseSchema3" OpHelp("name=r[P1] sql=r[P1+1]"),
+ /* 123 */ "RenameTable" OpHelp("P1 = root, P4 = name"),
+ /* 124 */ "LoadAnalysis" OpHelp(""),
+ /* 125 */ "DropTable" OpHelp(""),
+ /* 126 */ "DropIndex" OpHelp(""),
+ /* 127 */ "DropTrigger" OpHelp(""),
+ /* 128 */ "Param" OpHelp(""),
+ /* 129 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
+ /* 130 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
+ /* 131 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2 at P5])"),
+ /* 132 */ "AggStep" OpHelp("accum=r[P3] step(r[P2 at P5])"),
+ /* 133 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
+ /* 134 */ "Expire" OpHelp(""),
+ /* 135 */ "IncMaxid" OpHelp(""),
+ /* 136 */ "Noop" OpHelp(""),
+ /* 137 */ "Explain" OpHelp(""),
};
return azName[i];
}
diff --git a/src/box/sql/opcodes.h b/src/box/sql/opcodes.h
index 3f60e4066..791f6478d 100644
--- a/src/box/sql/opcodes.h
+++ b/src/box/sql/opcodes.h
@@ -2,7 +2,7 @@
/* See the tool/mkopcodeh.tcl script for details */
#define OP_Savepoint 0
#define OP_AutoCommit 1
-#define OP_Transaction 2
+#define OP_TTransaction 2
#define OP_SorterNext 3
#define OP_PrevIfOpen 4
#define OP_Or 5 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
@@ -92,53 +92,52 @@
#define OP_MakeRecord 89 /* synopsis: r[P3]=mkrec(r[P1 at P2]) */
#define OP_Count 90 /* synopsis: r[P2]=count() */
#define OP_FkCheckCommit 91
-#define OP_TTransaction 92
-#define OP_ReadCookie 93
-#define OP_SetCookie 94
-#define OP_ReopenIdx 95 /* synopsis: root=P2 */
-#define OP_OpenRead 96 /* synopsis: root=P2 */
-#define OP_OpenWrite 97 /* synopsis: root=P2 */
-#define OP_OpenTEphemeral 98 /* synopsis: nColumn = P2 */
-#define OP_SorterOpen 99
-#define OP_SequenceTest 100 /* synopsis: if (cursor[P1].ctr++) pc = P2 */
-#define OP_OpenPseudo 101 /* synopsis: P3 columns in r[P2] */
-#define OP_Close 102
-#define OP_ColumnsUsed 103
-#define OP_Sequence 104 /* synopsis: r[P2]=cursor[P1].ctr++ */
-#define OP_NextId 105 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
-#define OP_NextIdEphemeral 106 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
-#define OP_FCopy 107 /* synopsis: reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)] */
-#define OP_Delete 108
-#define OP_ResetCount 109
-#define OP_SorterCompare 110 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
-#define OP_SorterData 111 /* synopsis: r[P2]=data */
-#define OP_RowData 112 /* synopsis: r[P2]=data */
-#define OP_NullRow 113
-#define OP_SorterInsert 114 /* synopsis: key=r[P2] */
+#define OP_ReadCookie 92
+#define OP_SetCookie 93
+#define OP_ReopenIdx 94 /* synopsis: root=P2 */
+#define OP_OpenRead 95 /* synopsis: root=P2 */
+#define OP_OpenWrite 96 /* synopsis: root=P2 */
+#define OP_OpenTEphemeral 97 /* synopsis: nColumn = P2 */
+#define OP_SorterOpen 98
+#define OP_SequenceTest 99 /* synopsis: if (cursor[P1].ctr++) pc = P2 */
+#define OP_OpenPseudo 100 /* synopsis: P3 columns in r[P2] */
+#define OP_Close 101
+#define OP_ColumnsUsed 102
+#define OP_Sequence 103 /* synopsis: r[P2]=cursor[P1].ctr++ */
+#define OP_NextId 104 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
+#define OP_NextIdEphemeral 105 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
+#define OP_FCopy 106 /* synopsis: reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)] */
+#define OP_Delete 107
+#define OP_ResetCount 108
+#define OP_SorterCompare 109 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
+#define OP_SorterData 110 /* synopsis: r[P2]=data */
+#define OP_RowData 111 /* synopsis: r[P2]=data */
+#define OP_NullRow 112
+#define OP_SorterInsert 113 /* synopsis: key=r[P2] */
+#define OP_IdxReplace 114 /* synopsis: key=r[P2] */
#define OP_Real 115 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
-#define OP_IdxReplace 116 /* synopsis: key=r[P2] */
-#define OP_IdxInsert 117 /* synopsis: key=r[P2] */
-#define OP_IdxDelete 118 /* synopsis: key=r[P2 at P3] */
-#define OP_Destroy 119
-#define OP_Clear 120
-#define OP_ResetSorter 121
-#define OP_ParseSchema2 122 /* synopsis: rows=r[P1 at P2] */
-#define OP_ParseSchema3 123 /* synopsis: name=r[P1] sql=r[P1+1] */
-#define OP_RenameTable 124 /* synopsis: P1 = root, P4 = name */
-#define OP_LoadAnalysis 125
-#define OP_DropTable 126
-#define OP_DropIndex 127
-#define OP_DropTrigger 128
-#define OP_Param 129
-#define OP_FkCounter 130 /* synopsis: fkctr[P1]+=P2 */
-#define OP_OffsetLimit 131 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
-#define OP_AggStep0 132 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
-#define OP_AggStep 133 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
-#define OP_AggFinal 134 /* synopsis: accum=r[P1] N=P2 */
-#define OP_Expire 135
-#define OP_IncMaxid 136
-#define OP_Noop 137
-#define OP_Explain 138
+#define OP_IdxInsert 116 /* synopsis: key=r[P2] */
+#define OP_IdxDelete 117 /* synopsis: key=r[P2 at P3] */
+#define OP_Destroy 118
+#define OP_Clear 119
+#define OP_ResetSorter 120
+#define OP_ParseSchema2 121 /* synopsis: rows=r[P1 at P2] */
+#define OP_ParseSchema3 122 /* synopsis: name=r[P1] sql=r[P1+1] */
+#define OP_RenameTable 123 /* synopsis: P1 = root, P4 = name */
+#define OP_LoadAnalysis 124
+#define OP_DropTable 125
+#define OP_DropIndex 126
+#define OP_DropTrigger 127
+#define OP_Param 128
+#define OP_FkCounter 129 /* synopsis: fkctr[P1]+=P2 */
+#define OP_OffsetLimit 130 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
+#define OP_AggStep0 131 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
+#define OP_AggStep 132 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
+#define OP_AggFinal 133 /* synopsis: accum=r[P1] N=P2 */
+#define OP_Expire 134
+#define OP_IncMaxid 135
+#define OP_Noop 136
+#define OP_Explain 137
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
@@ -162,13 +161,13 @@
/* 64 */ 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
/* 72 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\
/* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
-/* 88 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00,\
-/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 104 */ 0x10, 0x20, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
-/* 112 */ 0x00, 0x00, 0x04, 0x10, 0x00, 0x04, 0x00, 0x10,\
+/* 88 */ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00,\
+/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
+/* 104 */ 0x20, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 112 */ 0x00, 0x04, 0x00, 0x10, 0x04, 0x00, 0x10, 0x00,\
/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 128 */ 0x00, 0x10, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00,\
-/* 136 */ 0x00, 0x00, 0x00,}
+/* 128 */ 0x10, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 136 */ 0x00, 0x00,}
/* The sqlite3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
index 1e4c426c0..19223d14f 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -800,7 +800,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */
&& (pPragma->mPragFlg & PragFlg_ReadOnly) == 0) {
/* Write the specified cookie value */
static const VdbeOpList setCookie[] = {
- {OP_Transaction, 0, 1, 0}, /* 0 */
{OP_SetCookie, 0, 0, 0}, /* 1 */
};
VdbeOp *aOp;
@@ -820,7 +819,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */
} else {
/* Read the specified cookie value */
static const VdbeOpList readCookie[] = {
- {OP_Transaction, 0, 0, 0}, /* 0 */
{OP_ReadCookie, 0, 1, 0}, /* 1 */
{OP_ResultRow, 1, 1, 0}
};
diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c
index c1193805f..b775c361f 100644
--- a/src/box/sql/prepare.c
+++ b/src/box/sql/prepare.c
@@ -185,17 +185,6 @@ sqlite3InitDatabase(sqlite3 * db)
*/
assert(db->init.busy);
{
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- sqlite3_xauth xAuth;
- xAuth = db->xAuth;
- db->xAuth = 0;
-#endif
- rc = SQLITE_OK;
-#ifndef SQLITE_OMIT_AUTHORIZATION
- db->xAuth = xAuth;
- }
-#endif
rc = initData.rc;
#ifndef SQLITE_OMIT_ANALYZE
if (rc == SQLITE_OK) {
diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c
index 5548def3b..385e64c9b 100644
--- a/src/box/sql/resolve.c
+++ b/src/box/sql/resolve.c
@@ -696,25 +696,6 @@ resolveExprStep(Walker * pWalker, Expr * pExpr)
'u' ? 8388608 : 125829120;
}
}
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- int auth =
- sqlite3AuthCheck(pParse,
- SQLITE_FUNCTION, 0,
- pDef->zName, 0);
- if (auth != SQLITE_OK) {
- if (auth == SQLITE_DENY) {
- sqlite3ErrorMsg(pParse,
- "not authorized to use function: %s",
- pDef->
- zName);
- pNC->nErr++;
- }
- pExpr->op = TK_NULL;
- return WRC_Prune;
- }
- }
-#endif
if (pDef->
funcFlags & (SQLITE_FUNC_CONSTANT |
SQLITE_FUNC_SLOCHNG)) {
@@ -1295,8 +1276,6 @@ resolveSelectStep(Walker * pWalker, Select * p)
if (pItem->pSelect) {
NameContext *pNC; /* Used to iterate name contexts */
int nRef = 0; /* Refcount for pOuterNC and outer contexts */
- const char *zSavedContext =
- pParse->zAuthContext;
/* Count the total number of references to pOuterNC and all of its
* parent contexts. After resolving references to expressions in
@@ -1307,12 +1286,10 @@ resolveSelectStep(Walker * pWalker, Select * p)
for (pNC = pOuterNC; pNC; pNC = pNC->pNext)
nRef += pNC->nRef;
- if (pItem->zName)
- pParse->zAuthContext = pItem->zName;
sqlite3ResolveSelectNames(pParse,
pItem->pSelect,
pOuterNC);
- pParse->zAuthContext = zSavedContext;
+
if (pParse->nErr || db->mallocFailed)
return WRC_Abort;
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index 041e6ca87..57a5c4999 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -2306,10 +2306,6 @@ generateWithRecursiveQuery(Parse * pParse, /* Parsing context */
Expr *pLimit, *pOffset; /* Saved LIMIT and OFFSET */
int regLimit, regOffset; /* Registers used by LIMIT and OFFSET */
- /* Obtain authorization to do a recursive query */
- if (sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0))
- return;
-
/* Process the LIMIT and OFFSET clauses, if they exist */
addrBreak = sqlite3VdbeMakeLabel(v);
p->nSelectRow = 320; /* 4 billion rows */
@@ -3782,7 +3778,6 @@ flattenSubquery(Parse * pParse, /* Parsing context */
int isAgg, /* True if outer SELECT uses aggregate functions */
int subqueryIsAgg) /* True if the subquery uses aggregate functions */
{
- const char *zSavedAuthContext = pParse->zAuthContext;
Select *pParent; /* Current UNION ALL term of the other query */
Select *pSub; /* The inner query or "subquery" */
Select *pSub1; /* Pointer to the rightmost select in sub-query */
@@ -3943,12 +3938,6 @@ flattenSubquery(Parse * pParse, /* Parsing context */
SELECTTRACE(1, pParse, p, ("flatten %s.%p from term %d\n",
pSub->zSelName, pSub, iFrom));
- /* Authorize the subquery */
- pParse->zAuthContext = pSubitem->zName;
- TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
- testcase(i == SQLITE_DENY);
- pParse->zAuthContext = zSavedAuthContext;
-
/* If the sub-query is a compound SELECT statement, then (by restrictions
* 17 and 18 above) it must be a UNION ALL and the parent query must
* be of the form:
@@ -5447,8 +5436,6 @@ sqlite3Select(Parse * pParse, /* The parser context */
if (p == 0 || db->mallocFailed || pParse->nErr) {
return 1;
}
- if (sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0))
- return 1;
memset(&sAggInfo, 0, sizeof(sAggInfo));
#ifdef SELECTTRACE_ENABLED
pParse->nSelectIndent++;
diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h
index ac18c3b98..9f1bb42eb 100644
--- a/src/box/sql/sqliteInt.h
+++ b/src/box/sql/sqliteInt.h
@@ -829,7 +829,6 @@ void *sqlite3_wsd_find(void *K, int L);
* Forward references to structures
*/
typedef struct AggInfo AggInfo;
-typedef struct AuthContext AuthContext;
typedef struct AutoincInfo AutoincInfo;
typedef struct Bitvec Bitvec;
typedef struct Column Column;
@@ -950,44 +949,6 @@ struct FuncDefHash {
FuncDef *a[SQLITE_FUNC_HASH_SZ]; /* Hash table for functions */
};
-#ifdef SQLITE_USER_AUTHENTICATION
-/*
- * Information held in the "sqlite3" database connection object and used
- * to manage user authentication.
- */
-typedef struct sqlite3_userauth sqlite3_userauth;
-struct sqlite3_userauth {
- u8 authLevel; /* Current authentication level */
- int nAuthPW; /* Size of the zAuthPW in bytes */
- char *zAuthPW; /* Password used to authenticate */
- char *zAuthUser; /* User name used to authenticate */
-};
-
-/* Allowed values for sqlite3_userauth.authLevel */
-#define UAUTH_Unknown 0 /* Authentication not yet checked */
-#define UAUTH_Fail 1 /* User authentication failed */
-#define UAUTH_User 2 /* Authenticated as a normal user */
-#define UAUTH_Admin 3 /* Authenticated as an administrator */
-
-/* Functions used only by user authorization logic */
-int sqlite3UserAuthTable(const char *);
-int sqlite3UserAuthCheckLogin(sqlite3 *, const char *, u8 *);
-void sqlite3UserAuthInit(sqlite3 *);
-void sqlite3CryptFunc(sqlite3_context *, int, sqlite3_value **);
-
-#endif /* SQLITE_USER_AUTHENTICATION */
-
-/*
- * typedef for the authorization callback function.
- */
-#ifdef SQLITE_USER_AUTHENTICATION
-typedef int (*sqlite3_xauth) (void *, int, const char *, const char *,
- const char *, const char *, const char *);
-#else
-typedef int (*sqlite3_xauth) (void *, int, const char *, const char *,
- const char *, const char *);
-#endif
-
/*
* Each database connection is an instance of the following structure.
*/
@@ -1052,10 +1013,6 @@ struct sqlite3 {
double notUsed1; /* Spacer */
} u1;
Lookaside lookaside; /* Lookaside malloc configuration */
-#ifndef SQLITE_OMIT_AUTHORIZATION
- sqlite3_xauth xAuth; /* Access authorization function */
- void *pAuthArg; /* 1st argument to the access auth function */
-#endif
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
int (*xProgress) (void *); /* The progress callback */
void *pProgressArg; /* Argument to the progress callback */
@@ -1065,9 +1022,6 @@ struct sqlite3 {
BusyHandler busyHandler; /* Busy callback */
int busyTimeout; /* Busy handler timeout, in msec */
int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
-#ifdef SQLITE_USER_AUTHENTICATION
- sqlite3_userauth auth; /* User authentication information */
-#endif
};
/*
@@ -2472,7 +2426,6 @@ struct Parse {
const char *zTail; /* All SQL text past the last semicolon parsed */
Table *pNewTable; /* A table being constructed by CREATE TABLE */
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
- const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
Table *pZombieTab; /* List of Table objects to delete after code gen */
TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
With *pWith; /* Current WITH clause, or NULL */
@@ -2489,15 +2442,6 @@ struct Parse {
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ) /* Pointer to tail */
-/*
- * An instance of the following structure can be declared on a stack and used
- * to save the Parse.zAuthContext value so that it can be restored later.
- */
-struct AuthContext {
- const char *zAuthContext; /* Put saved Parse.zAuthContext here */
- Parse *pParse; /* The Parse structure */
-};
-
/*
* Bitfield flags for P5 value in various opcodes.
*
@@ -3286,23 +3230,6 @@ u32 sqlite3TriggerColmask(Parse *, Trigger *, ExprList *, int, int, Table *,
int sqlite3JoinType(Parse *, Token *, Token *, Token *);
void sqlite3CreateForeignKey(Parse *, ExprList *, Token *, ExprList *, int);
void sqlite3DeferForeignKey(Parse *, int);
-#ifndef SQLITE_OMIT_AUTHORIZATION
-void sqlite3AuthRead(Parse *, Expr *, Schema *, SrcList *);
-int sqlite3AuthCheck(Parse *, int, const char *, const char *, const char *);
-void sqlite3AuthContextPush(Parse *, AuthContext *, const char *);
-void sqlite3AuthContextPop(AuthContext *);
-int sqlite3AuthReadCol(Parse *, const char *, const char *);
-#else
-#define sqlite3AuthRead(a,b,c,d)
-static inline
-int sqlite3AuthCheck(MAYBE_UNUSED Parse *a,
- MAYBE_UNUSED int b,
- MAYBE_UNUSED const char *c,
- MAYBE_UNUSED const char *d,
- MAYBE_UNUSED const char *e) { return SQLITE_OK; }
-#define sqlite3AuthContextPush(a,b,c)
-#define sqlite3AuthContextPop(a) ((void)(a))
-#endif
void sqlite3Detach(Parse *, Expr *);
void sqlite3FixInit(DbFixer *, Parse *, const char *, const Token *);
int sqlite3FixSrcList(DbFixer *, SrcList *);
diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c
index def724ae6..a2827c882 100644
--- a/src/box/sql/trigger.c
+++ b/src/box/sql/trigger.c
@@ -155,21 +155,6 @@ sqlite3BeginTrigger(Parse * pParse, /* The parse context of the CREATE TRIGGER s
" trigger on table: %S", pTableName, 0);
goto trigger_cleanup;
}
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- assert(sqlite3SchemaToIndex(db, pTab->pSchema) == 0);
- int code = SQLITE_CREATE_TRIGGER;
- const char *zDb = db->mdb.zDbSName;
- const char *zDbTrig = zDb;
- if (sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig)) {
- goto trigger_cleanup;
- }
- if (sqlite3AuthCheck
- (pParse, SQLITE_INSERT, MASTER_NAME, 0, zDb)) {
- goto trigger_cleanup;
- }
- }
-#endif
/* INSTEAD OF triggers can only appear on views and BEFORE triggers
* cannot appear on views. So we might as well translate every
@@ -580,18 +565,6 @@ sqlite3DropTriggerPtr(Parse * pParse, Trigger * pTrigger)
pTable = tableOfTrigger(pTrigger);
assert(pTable);
assert(pTable->pSchema == pTrigger->pSchema);
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- int code = SQLITE_DROP_TRIGGER;
- const char *zDb = db->mdb.zDbSName;
- const char *zTab = MASTER_NAME;
- if (sqlite3AuthCheck
- (pParse, code, pTrigger->zName, pTable->zName, zDb)
- || sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)) {
- return;
- }
- }
-#endif
/* Generate code to destroy the database record of the trigger.
*/
@@ -906,7 +879,6 @@ codeRowTrigger(Parse * pParse, /* Current parse context */
pSubParse->db = db;
pSubParse->pTriggerTab = pTab;
pSubParse->pToplevel = pTop;
- pSubParse->zAuthContext = pTrigger->zName;
pSubParse->eTriggerOp = pTrigger->op;
pSubParse->nQueryLoop = pParse->nQueryLoop;
diff --git a/src/box/sql/update.c b/src/box/sql/update.c
index 329e6d980..900bef85c 100644
--- a/src/box/sql/update.c
+++ b/src/box/sql/update.c
@@ -121,7 +121,6 @@ sqlite3Update(Parse * pParse, /* The parser context */
*/
u8 *aToOpen; /* 1 for tables and indices to be opened */
u8 chngPk; /* PRIMARY KEY changed */
- AuthContext sContext; /* The authorization context */
NameContext sNC; /* The name-context to resolve expressions in */
int okOnePass; /* True for one-pass algorithm without the FIFO */
int hasFK; /* True if foreign key processing is required */
@@ -147,7 +146,6 @@ sqlite3Update(Parse * pParse, /* The parser context */
int regOld = 0; /* Content of OLD.* table in triggers */
int regKey = 0; /* composite PRIMARY KEY value */
- memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
if (pParse->nErr || db->mallocFailed) {
goto update_cleanup;
@@ -222,10 +220,8 @@ sqlite3Update(Parse * pParse, /* The parser context */
/* Resolve the column names in all the expressions of the
* of the UPDATE statement. Also find the column index
- * for each column to be updated in the pChanges array. For each
- * column to be updated, make sure we have authorization to change
- * that column.
- */
+ * for each column to be updated in the pChanges array.
+ */
chngPk = 0;
for (i = 0; i < pChanges->nExpr; i++) {
if (sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr)) {
@@ -250,21 +246,6 @@ sqlite3Update(Parse * pParse, /* The parser context */
pParse->checkSchema = 1;
goto update_cleanup;
}
-#ifndef SQLITE_OMIT_AUTHORIZATION
- {
- int rc;
- rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE,
- pTab->zName,
- j <
- 0 ? "ROWID" : pTab->aCol[j].zName,
- db->mdb.zDbSName);
- if (rc == SQLITE_DENY) {
- goto update_cleanup;
- } else if (rc == SQLITE_IGNORE) {
- aXRef[j] = -1;
- }
- }
-#endif
}
assert(chngPk == 0 || chngPk == 1);
@@ -324,11 +305,6 @@ sqlite3Update(Parse * pParse, /* The parser context */
regNew = pParse->nMem + 1;
pParse->nMem += pTab->nCol;
- /* Start the view context. */
- if (isView) {
- sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
- }
-
/* If we are trying to update a view, realize that view into
* an ephemeral table.
*/
@@ -693,7 +669,6 @@ sqlite3Update(Parse * pParse, /* The parser context */
}
update_cleanup:
- sqlite3AuthContextPop(&sContext);
sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */
sqlite3SrcListDelete(db, pTabList);
sqlite3ExprListDelete(db, pChanges);
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index d0ccf746c..a6180fda2 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -3016,69 +3016,24 @@ case OP_AutoCommit: {
break;
}
-/* Opcode: Transaction P1 P2 * * *
- *
- * Begin a transaction on database P1 if a transaction is not already
- * active.
- * If P2 is non-zero, then a write-transaction is started, or if a
- * read-transaction is already active, it is upgraded to a write-transaction.
- * If P2 is zero, then a read-transaction is started.
- *
- * P1 is the index of the database file on which the transaction is
- * started. Index 0 is the main database file and index 1 is the
- * file used for temporary tables. Indices of 2 or more are used for
- * attached databases.
- *
- * If a write-transaction is started and the Vdbe.usesStmtJournal flag is
- * true (this flag is set if the Vdbe may modify more than one row and may
- * throw an ABORT exception), a statement transaction may also be opened.
- * More specifically, a statement transaction is opened if the database
- * connection is currently not in autocommit mode, or if there are other
- * active statements. A statement transaction allows the changes made by this
- * VDBE to be rolled back after an error without having to roll back the
- * entire transaction. If no error is encountered, the statement transaction
- * will automatically commit when the VDBE halts.
- *
- */
-case OP_Transaction: {
- assert(p->bIsReader);
- assert(p->readOnly==0 || pOp->p2==0);
- assert(pOp->p1==0);
- if (pOp->p2 && (user_session->sql_flags & SQLITE_QueryOnly)!=0) {
- rc = SQLITE_READONLY;
- goto abort_due_to_error;
- }
-
- testcase(rc == SQLITE_BUSY_SNAPSHOT);
- testcase(rc == SQLITE_BUSY_RECOVERY);
- if (rc != SQLITE_OK) {
- if ((rc&0xff) == SQLITE_BUSY) {
- p->pc = (int)(pOp - aOp);
- p->rc = rc;
- goto vdbe_return;
- }
- goto abort_due_to_error;
- }
-
- if (rc) goto abort_due_to_error;
- break;
-}
-
-/* Opcode: TTransaction * * * * *
+/* Opcode: TTransaction P1 P2 * * *
*
* Start Tarantool's transaction.
* Only do that if auto commit mode is on. This should be no-op
* if this opcode was emitted inside a transaction.
- * Auto commit mode is disabled by OP_Transaction.
*/
case OP_TTransaction: {
- if (p->autoCommit) {
- rc = box_txn_begin() == 0 ? SQLITE_OK : SQL_TARANTOOL_ERROR;
- }
- if (box_txn()
- && p->autoCommit == 0){
- p->anonymous_savepoint = sql_savepoint(p, NULL);
+ assert(pOp->p1 == 1 || pOp->p1 == 0);
+ assert(p->readOnly==0 || pOp->p2==0);
+ if (pOp->p1) {
+ if (p->autoCommit) {
+ rc = box_txn_begin() == 0 ? SQLITE_OK : SQL_TARANTOOL_ERROR;
+ }
+ if (box_txn()
+ && p->autoCommit == 0){
+ p->anonymous_savepoint = sql_savepoint(p, NULL);
+ }
}
break;
}
@@ -3209,7 +3164,6 @@ case OP_ReopenIdx: {
*/
case OP_OpenRead:
case OP_OpenWrite:
-
assert(pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ);
assert(p->bIsReader);
assert(pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 6622a11a8..845937874 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -673,7 +673,7 @@ resolveP2Values(Vdbe * p, int *pMaxFuncArgs)
* cases from this switch!
*/
switch (pOp->opcode) {
- case OP_Transaction:{
+ case OP_TTransaction: {
if (pOp->p2 != 0)
p->readOnly = 0;
/* fall thru */
--
2.14.1
More information about the Tarantool-patches
mailing list