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 4D3BE2C0FD for ; Wed, 4 Apr 2018 14:09:32 -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 fgHMAEZHXvQP for ; Wed, 4 Apr 2018 14:09:32 -0400 (EDT) Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [94.100.177.101]) (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 167A32B7FD for ; Wed, 4 Apr 2018 14:09:30 -0400 (EDT) From: "n.pettik" Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_7312F9B8-5FE0-4CE1-884D-A02AC2DB9A88" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH 1/2] sql: remove obsolete SQLite routine Date: Wed, 4 Apr 2018 21:09:26 +0300 In-Reply-To: <7a18a3e7-9076-087e-df93-dde6955adc70@tarantool.org> References: <0e28c9181b19643504f335a164f8d098fdab6614.1522769126.git.korablev@tarantool.org> <7a18a3e7-9076-087e-df93-dde6955adc70@tarantool.org> 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: Vladislav Shpilevoy --Apple-Mail=_7312F9B8-5FE0-4CE1-884D-A02AC2DB9A88 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 3 Apr 2018, at 20:54, Vladislav Shpilevoy = wrote: >=20 > Hello. See 7 comments below. >=20 > 03.04.2018 19:14, Nikita Pettik =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> Some of legacy functions seem to be useless, since they serve as >> wrappers around others; the rest rely on capabilities which are no >> longer relevant. This patch provides slight refactoring of such >> functions. >>=20 >> Removed entities: >> - sqlite3LocateTableItem() - replaced with sqlite3LocateTable(); >> - sqlite3FindTable() - replaced with sqlite3HashFind(); >> - sqlite3ColumnOfIndex() - in Tarantool order of columns always the = same; >> - sqlite3FindIndex() - replaced with sqlite3LocateIndex(); >> - sqlite3CodeVerifySchema(); >> - sqlite3SchemaToIndex(); >> - sqlite3MultiWrite(); >> - Parse->cookieMast; >> - Vdbe->usesStmtJournal; >> --- >> src/box/sql/alter.c | 13 ++- >> src/box/sql/analyze.c | 25 +++--- >> src/box/sql/build.c | 213 = ++++++++++-------------------------------------- >> src/box/sql/delete.c | 5 +- >> src/box/sql/expr.c | 9 +- >> src/box/sql/fkey.c | 3 +- >> src/box/sql/insert.c | 10 +-- >> src/box/sql/pragma.c | 18 ++-- >> src/box/sql/prepare.c | 29 ------- >> src/box/sql/select.c | 4 +- >> src/box/sql/sqliteInt.h | 11 +-- >> src/box/sql/trigger.c | 7 +- >> src/box/sql/update.c | 2 +- >> src/box/sql/vdbe.c | 1 - >> src/box/sql/vdbeInt.h | 1 - >> src/box/sql/vdbeaux.c | 1 - >> src/box/sql/where.c | 2 - >> src/box/sql/wherecode.c | 7 +- >> 18 files changed, 83 insertions(+), 278 deletions(-) >>=20 >> diff --git a/src/box/sql/alter.c b/src/box/sql/alter.c >> index 054c0856c..a19324ed2 100644 >> --- a/src/box/sql/alter.c >> +++ b/src/box/sql/alter.c >> @@ -122,7 +121,7 @@ sqlite3AlterRenameTable(Parse * pParse, /* = Parser context. */ >> if (v =3D=3D 0) { >> goto exit_rename_table; >> } >> - sqlite3BeginWriteOperation(pParse, false); >> + sql_set_multi_write(pParse, false); > 1. Can you please alongside with this patch make sql_set_multi_write = take boolean as the last > argument? Now it sometimes gets true/false, sometimes 1/0. It is = strange. Done. >> /* Drop and reload the internal table schema. */ >> reloadTableSchema(pParse, pTab, zName); >>=20 >> diff --git a/src/box/sql/build.c b/src/box/sql/build.c >> index 5e3ed0f39..61194e06b 100644 >> --- a/src/box/sql/build.c >> +++ b/src/box/sql/build.c >> @@ -93,23 +93,16 @@ sqlite3FinishCoding(Parse * pParse) >> * transaction on each used database and to verify the = schema cookie >> * on each used database. >> */ >> - if (db->mallocFailed =3D=3D 0 >> - && (DbMaskNonZero(pParse->cookieMask) || = pParse->pConstExpr) >> - ) { >> + if (db->mallocFailed =3D=3D 0 || pParse->pConstExpr) { > 2. Please, together with cookie mask checking remove or refactor a = comment above. Fixed. >> @@ -2240,7 +2164,6 @@ sqlite3CodeDropTable(Parse * pParse, Table * = pTab, int isView) >> v =3D sqlite3GetVdbe(pParse); >> assert(v !=3D 0); >> - sqlite3BeginWriteOperation(pParse, 1); > 3. Why did you delete it with no replacement by = sql_set_multi_write(false) ? Because in this particular case is is completely useless: table dropping is implemented as hardcoded opcodes sequences. AFAIK this mask is used to provide kind of optimisation/checks during query compilation.=20 Also, removed: @@ -2414,8 +2326,7 @@ sqlite3DropTable(Parse * pParse, SrcList * pName, = int isView, int noErr) * space_id from _space. */ =20 - sqlite3BeginWriteOperation(pParse, 1); sql_clear_stat_spaces(pParse, "tbl", pTab->zName); sqlite3FkDropTable(pParse, pName, pTab); sqlite3CodeDropTable(pParse, pTab, isView); >> @@ -2376,15 +2299,12 @@ sqlite3DropTable(Parse * pParse, SrcList * = pName, int isView, int noErr) >> if (noErr) >> db->suppressErr++; >> assert(isView =3D=3D 0 || isView =3D=3D LOCATE_VIEW); >> - pTab =3D sqlite3LocateTableItem(pParse, isView, &pName->a[0]); >> + pTab =3D sqlite3LocateTable(pParse, isView, pName->a[0].zName); >> if (noErr) >> db->suppressErr--; >> - if (pTab =3D=3D 0) { >> - if (noErr) >> - sqlite3CodeVerifySchema(pParse); >> + if (pTab =3D=3D 0) > 4. Lets use =3D=3D/!=3D NULL in all new code. Done. > Same about checking sqlite3HashFind results. And if it is > possible with not huge diff, can you please rename sqlite3HashFind to = sql_hash_find ? Is it worth doing? It is going to disappear soon. >=20 > 5. sqlite3MultiWrite in commit message is listed among deleted = functions, but its declaration still exists. Fixed: @@ -3718,8 +3689,8 @@ void sqlite3GenerateConstraintChecks(Parse *, = Table *, int *, int, int, int, void sqlite3CompleteInsertion(Parse *, Table *, int, int *, int, u8); int sqlite3OpenTableAndIndices(Parse *, Table *, int, u8, int, u8 *, = int *, int *, u8, u8); -void sqlite3BeginWriteOperation(Parse *, int); -void sqlite3MultiWrite(Parse *); +void +sql_set_multi_write(Parse *, bool); >=20 > 6. cookieMast - typo in commit message. And how about do not list = deleted functions in a commit body? > I can not imagine, that somebody except me will search for any of = these functions. And the list is deprecated - > for example, sqlite3BeginWriteOperation is deleted too, but does not = presence in the list. Ok, fixed commit message. Left only description. >=20 > 7. How about remove DbMaskTest, DbMaskZero and other dbmask shit? As you wish. Done. Diff is below: diff --git a/src/box/sql/alter.c b/src/box/sql/alter.c index a19324ed2..129ef823c 100644 --- a/src/box/sql/alter.c +++ b/src/box/sql/alter.c @@ -85,7 +85,7 @@ sqlite3AlterRenameTable(Parse * pParse, /* = Parser context. */ assert(pSrc->nSrc =3D=3D 1); =20 pTab =3D sqlite3LocateTable(pParse, 0, pSrc->a[0].zName); - if (!pTab) + if (pTab =3D=3D NULL) goto exit_rename_table; =20 user_session->sql_flags |=3D SQLITE_PreferBuiltin; @@ -257,7 +257,7 @@ sqlite3AlterBeginAddColumn(Parse * pParse, SrcList * = pSrc) if (db->mallocFailed) goto exit_begin_add_column; pTab =3D sqlite3LocateTable(pParse, 0, pSrc->a[0].zName); - if (!pTab) + if (pTab =3D=3D NULL) goto exit_begin_add_column; =20 /* Make sure this is not an attempt to ALTER a view. */ @@ -304,7 +304,7 @@ sqlite3AlterBeginAddColumn(Parse * pParse, SrcList * = pSrc) pNew->nTabRef =3D 1; =20 /* Begin a transaction and increment the schema cookie. */ - sql_set_multi_write(pParse, 0); + sql_set_multi_write(pParse, false); v =3D sqlite3GetVdbe(pParse); if (!v) goto exit_begin_add_column; diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c index 25e93aa15..60f4eaac4 100644 --- a/src/box/sql/analyze.c +++ b/src/box/sql/analyze.c @@ -157,6 +157,7 @@ openStatTable(Parse * pParse, /* Parsing = context */ Table *pStat; /* The table already exists, because it is a system = space */ pStat =3D sqlite3HashFind(&db->pSchema->tblHash, zTab); + assert(pStat !=3D NULL); aRoot[i] =3D pStat->tnum; aCreateTbl[i] =3D 0; if (zWhere) { @@ -1122,7 +1123,7 @@ analyzeDatabase(Parse * pParse) int iMem; int iTab; =20 - sql_set_multi_write(pParse, 0); + sql_set_multi_write(pParse, false); iStatCur =3D pParse->nTab; pParse->nTab +=3D 3; openStatTable(pParse, iStatCur, 0, 0); @@ -1146,7 +1147,7 @@ analyzeTable(Parse * pParse, Table * pTab, Index * = pOnlyIdx) int iStatCur; =20 assert(pTab !=3D 0); - sql_set_multi_write(pParse, 0); + sql_set_multi_write(pParse, true); iStatCur =3D pParse->nTab; pParse->nTab +=3D 3; if (pOnlyIdx) { @@ -1294,9 +1295,8 @@ analysisLoader(void *pData, int argc, char **argv, = char **NotUsed) return 0; } pTable =3D sqlite3HashFind(&pInfo->db->pSchema->tblHash, = argv[0]); - if (pTable =3D=3D 0) { + if (pTable =3D=3D NULL) return 0; - } if (argv[1] =3D=3D 0) { pIndex =3D 0; } else if (sqlite3_stricmp(argv[0], argv[1]) =3D=3D 0) { @@ -1631,19 +1631,17 @@ loadStatTbl(sqlite3 * db, /* Database = handle */ static int loadStat4(sqlite3 * db) { - int rc =3D SQLITE_OK; /* Result codes from subroutines */ Table *pTab =3D 0; /* Pointer to stat table */ =20 assert(db->lookaside.bDisable); pTab =3D sqlite3HashFind(&db->pSchema->tblHash, "_sql_stat4"); - if (pTab) { - rc =3D loadStatTbl(db, - pTab, - "SELECT \"tbl\",\"idx\",count(*) FROM = \"_sql_stat4\" GROUP BY \"tbl\",\"idx\"", - "SELECT = \"tbl\",\"idx\",\"neq\",\"nlt\",\"ndlt\",\"sample\" FROM = \"_sql_stat4\""); - } - - return rc; + /* _slq_stat4 is a system space, so it always exists. */ + assert(pTab !=3D NULL); + return loadStatTbl(db, pTab, + "SELECT \"tbl\",\"idx\",count(*) FROM = \"_sql_stat4\"" + " GROUP BY \"tbl\",\"idx\"", + "SELECT = \"tbl\",\"idx\",\"neq\",\"nlt\",\"ndlt\"," + "\"sample\" FROM \"_sql_stat4\""); } =20 /* diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 61194e06b..c50847a02 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -86,13 +86,6 @@ sqlite3FinishCoding(Parse * pParse) || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort)); if (v) { sqlite3VdbeAddOp0(v, OP_Halt); - - /* 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 - * transaction on each used database and to verify the = schema cookie - * on each used database. - */ if (db->mallocFailed =3D=3D 0 || pParse->pConstExpr) { int i; assert(sqlite3VdbeGetOp(v, 0)->opcode =3D=3D = OP_Init); @@ -192,7 +185,7 @@ sqlite3LocateTable(Parse * pParse, /* context in = which to report errors */ assert(pParse->db->pSchema !=3D NULL); =20 p =3D sqlite3HashFind(&pParse->db->pSchema->tblHash, zName); - if (p =3D=3D 0) { + if (p =3D=3D NULL) { const char *zMsg =3D flags & LOCATE_VIEW ? "no such view" : "no such = table"; if ((flags & LOCATE_NOERR) =3D=3D 0) { @@ -212,9 +205,8 @@ sqlite3LocateIndex(sqlite3 * db, const char *zName, = const char *zTable) =20 Table *pTab =3D sqlite3HashFind(&db->pSchema->tblHash, zTable); =20 - if (pTab =3D=3D 0) { - return 0; - } + if (pTab =3D=3D NULL) + return NULL; =20 return sqlite3HashFind(&pTab->idxHash, zName); } @@ -545,7 +537,7 @@ sqlite3StartTable(Parse *pParse, Token *pName, int = noErr) =20 assert(db->pSchema !=3D NULL); pTable =3D sqlite3HashFind(&db->pSchema->tblHash, zName); - if (pTable) { + if (pTable !=3D NULL) { if (!noErr) { sqlite3ErrorMsg(pParse, "table %s already exists", @@ -583,7 +575,7 @@ sqlite3StartTable(Parse *pParse, Token *pName, int = noErr) * now. */ if (!db->init.busy && (v =3D sqlite3GetVdbe(pParse)) !=3D 0) - sql_set_multi_write(pParse, 1); + sql_set_multi_write(pParse, true); =20 /* Normal (non-error) return. */ return; @@ -2303,7 +2295,7 @@ sqlite3DropTable(Parse * pParse, SrcList * pName, = int isView, int noErr) if (noErr) db->suppressErr--; =20 - if (pTab =3D=3D 0) + if (pTab =3D=3D NULL) goto exit_drop_table; #ifndef SQLITE_OMIT_VIEW /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not = used @@ -2334,7 +2326,7 @@ sqlite3DropTable(Parse * pParse, SrcList * pName, = int isView, int noErr) * space_id from _space. */ =20 - sql_set_multi_write(pParse, 1); + sql_set_multi_write(pParse, true); sql_clear_stat_spaces(pParse, "tbl", pTab->zName); sqlite3FkDropTable(pParse, pName, pTab); sqlite3CodeDropTable(pParse, pTab, isView); @@ -2841,14 +2833,15 @@ sqlite3CreateIndex(Parse * pParse, /* All = information about this parse */ goto exit_create_index; assert(pName->z !=3D 0); if (!db->init.busy) { - if (sqlite3HashFind(&db->pSchema->tblHash, = zName) !=3D 0) { + if (sqlite3HashFind(&db->pSchema->tblHash, = zName) !=3D + NULL) { sqlite3ErrorMsg(pParse, "there is already a = table named %s", zName); goto exit_create_index; } } - if (sqlite3HashFind(&pTab->idxHash, zName) !=3D 0) { + if (sqlite3HashFind(&pTab->idxHash, zName) !=3D NULL) { if (!ifNotExist) { sqlite3ErrorMsg(pParse, "index %s.%s already = exists", @@ -3107,7 +3100,7 @@ sqlite3CreateIndex(Parse * pParse, /* All = information about this parse */ if (v =3D=3D 0) goto exit_create_index; =20 - sql_set_multi_write(pParse, 1); + sql_set_multi_write(pParse, true); =20 =20 sqlite3VdbeAddOp2(v, OP_SIDtoPtr, BOX_INDEX_ID, @@ -3853,11 +3846,10 @@ sqlite3Savepoint(Parse * pParse, int op, Token * = pName) * execution multiple insertion/updates may occur. */ void -sql_set_multi_write(Parse *pParse, int setStatement) +sql_set_multi_write(struct Parse *parse_context, bool is_set) { - Parse *pToplevel =3D sqlite3ParseToplevel(pParse); - DbMaskSet(pToplevel->writeMask, 0); - pToplevel->isMultiWrite |=3D setStatement; + Parse *pToplevel =3D sqlite3ParseToplevel(parse_context); + pToplevel->isMultiWrite |=3D is_set; } =20 /* @@ -3974,7 +3966,7 @@ reindexTable(Parse * pParse, Table * pTab, char = const *zColl) =20 for (pIndex =3D pTab->pIndex; pIndex; pIndex =3D pIndex->pNext) = { if (zColl =3D=3D 0 || collationMatch(zColl, pIndex)) { - sql_set_multi_write(pParse, 0); + sql_set_multi_write(pParse, false); sqlite3RefillIndex(pParse, pIndex, -1); } } @@ -4050,7 +4042,7 @@ sqlite3Reindex(Parse * pParse, Token * pName1, = Token * pName2) if (z =3D=3D 0) return; pTab =3D sqlite3HashFind(&db->pSchema->tblHash, z); - if (pTab) { + if (pTab !=3D NULL) { reindexTable(pParse, pTab, 0); sqlite3DbFree(db, z); return; @@ -4066,8 +4058,8 @@ sqlite3Reindex(Parse * pParse, Token * pName1, = Token * pName2) } =20 pIndex =3D sqlite3HashFind(&pTab->idxHash, z); - if (pIndex) { - sql_set_multi_write(pParse, 0); + if (pIndex !=3D NULL) { + sql_set_multi_write(pParse, false); sqlite3RefillIndex(pParse, pIndex, -1); return; } diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c index a07ef1980..9f4ce1026 100644 --- a/src/box/sql/delete.c +++ b/src/box/sql/delete.c @@ -59,12 +59,10 @@ sqlite3SrcListLookup(Parse * pParse, SrcList * pSrc) pTab =3D sqlite3LocateTable(pParse, 0, pItem->zName); sqlite3DeleteTable(pParse->db, pItem->pTab); pItem->pTab =3D pTab; - if (pTab) { + if (pTab !=3D NULL) pTab->nTabRef++; - } - if (sqlite3IndexedByLookup(pParse, pItem)) { - pTab =3D 0; - } + if (sqlite3IndexedByLookup(pParse, pItem)) + pTab =3D NULL; return pTab; } =20 @@ -324,7 +322,7 @@ sqlite3DeleteFrom(Parse * pParse, /* The parser = context */ } if (pParse->nested =3D=3D 0) sqlite3VdbeCountChanges(v); - sql_set_multi_write(pParse, 1); + sql_set_multi_write(pParse, true); =20 /* If we are trying to delete from a view, realize that view = into * an ephemeral table. diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c index 2719bbaf4..704e48d9c 100644 --- a/src/box/sql/insert.c +++ b/src/box/sql/insert.c @@ -1461,7 +1461,7 @@ sqlite3GenerateConstraintChecks(Parse * pParse, = /* The parser context */ default: { Trigger *pTrigger =3D 0; assert(onError =3D=3D = ON_CONFLICT_ACTION_REPLACE); - sql_set_multi_write(pParse, 1); + sql_set_multi_write(pParse, true); if (user_session-> sql_flags & SQLITE_RecTriggers) { pTrigger =3D @@ -1769,9 +1769,8 @@ xferOptimization(Parse * pParse, /* Parser = context */ int regData, regTupleid; /* Registers holding data and = tupleid */ struct session *user_session =3D current_session(); =20 - if (pSelect =3D=3D 0) { + if (pSelect =3D=3D 0) return 0; /* Must be of the form INSERT INTO ... = SELECT ... */ - } if (pParse->pWith || pSelect->pWith) { /* Do not attempt to process this query if there are an = WITH clauses * attached to it. Proceeding may generate a false "no = such table: xxx" @@ -1833,7 +1832,7 @@ xferOptimization(Parse * pParse, /* Parser = context */ */ pItem =3D pSelect->pSrc->a; pSrc =3D sqlite3LocateTable(pParse, 0, pItem->zName); - if (pSrc =3D=3D 0) { + if (pSrc =3D=3D NULL) { return 0; /* FROM clause does not contain a real = table */ } if (pSrc =3D=3D pDest) { diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 04b4020dd..c19a811ff 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -480,7 +480,7 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First = part of [schema.]id field */ int i; pTab =3D = sqlite3HashFind(&db->pSchema->tblHash, zRight); - if (pTab) { + if (pTab !=3D NULL) { pParse->nMem =3D 5; for (pIdx =3D pTab->pIndex, i =3D = 0; pIdx; pIdx =3D pIdx->pNext, i++) = { @@ -540,7 +540,7 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First = part of [schema.]id field */ Table *pTab; pTab =3D = sqlite3HashFind(&db->pSchema->tblHash, zRight); - if (pTab) { + if (pTab !=3D NULL) { pFK =3D pTab->pFKey; if (pFK) { int i =3D 0; @@ -617,7 +617,7 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First = part of [schema.]id field */ pParent =3D = sqlite3HashFind(&db->pSchema->tblHash, = pFK->zTo); - if (pParent =3D=3D 0) + if (pParent =3D=3D NULL) continue; pIdx =3D 0; x =3D = sqlite3FkLocateIndex(pParse, diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 6ff8dc25e..679aa2246 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -4746,7 +4746,7 @@ selectExpander(Walker * pWalker, Select * p) assert(pFrom->pTab =3D=3D 0); pFrom->pTab =3D pTab =3D sqlite3LocateTable(pParse, 0, pFrom->zName); - if (pTab =3D=3D 0) + if (pTab =3D=3D NULL) return WRC_Abort; if (pTab->nTabRef >=3D 0xffff) { sqlite3ErrorMsg(pParse, diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index 3234f992b..6d78f791d 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -2887,25 +2887,6 @@ struct TriggerPrg { u32 aColmask[2]; /* Masks of old.*, new.* columns = accessed */ }; =20 -/* - * The yDbMask datatype for the bitmask of all attached databases. - */ -#if SQLITE_MAX_ATTACHED>30 -typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED + 9) / 8]; -#define DbMaskTest(M,I) (((M)[(I)/8]&(1<<((I)&7)))!=3D0) -#define DbMaskZero(M) memset((M),0,sizeof(M)) -#define DbMaskSet(M,I) (M)[(I)/8]|=3D(1<<((I)&7)) -#define DbMaskAllZero(M) sqlite3DbMaskAllZero(M) -#define DbMaskNonZero(M) (sqlite3DbMaskAllZero(M)=3D=3D0) -#else -typedef unsigned int yDbMask; -#define DbMaskTest(M,I) (((M)&(((yDbMask)1)<<(I)))!=3D0) -#define DbMaskZero(M) (M)=3D0 -#define DbMaskSet(M,I) (M)|=3D(((yDbMask)1)<<(I)) -#define DbMaskAllZero(M) (M)=3D=3D0 -#define DbMaskNonZero(M) (M)!=3D0 -#endif - /* * An SQL parser context. A copy of this structure is passed through * the parser and down into all the parser action routine in order to @@ -2946,7 +2927,6 @@ struct Parse { int *aLabel; /* Space to hold the labels */ ExprList *pConstExpr; /* Constant expressions */ Token constraintName; /* Name of the constraint currently = being parsed */ - yDbMask writeMask; /* Start a write transaction on these = databases */ int regRoot; /* Register holding root page number for = new objects */ int nMaxArg; /* Max args passed to user function by = sub-program */ #ifdef SELECTTRACE_ENABLED @@ -3585,9 +3565,6 @@ int sqlite3ViewGetColumnNames(Parse *, Table *); #define sqlite3ViewGetColumnNames(A,B) 0 #endif =20 -#if SQLITE_MAX_ATTACHED>30 -int sqlite3DbMaskAllZero(yDbMask); -#endif void sqlite3DropTable(Parse *, SrcList *, int, int); void sqlite3DeleteTable(sqlite3 *, Table *); void sqlite3Insert(Parse *, SrcList *, Select *, IdList *, int); diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c index decbc8c21..a102c32b6 100644 --- a/src/box/sql/trigger.c +++ b/src/box/sql/trigger.c @@ -293,7 +293,7 @@ sqlite3FinishTrigger(Parse * pParse, /* = Parser context */ iFirstCol =3D pParse->nMem + 1; pParse->nMem +=3D 2; =20 - sql_set_multi_write(pParse, 0); + sql_set_multi_write(pParse, false); sqlite3VdbeAddOp4(v, OP_String8, 0, iFirstCol, 0, zName, P4_STATIC); diff --git a/src/box/sql/update.c b/src/box/sql/update.c index ad6aad5e6..778519bd6 100644 --- a/src/box/sql/update.c +++ b/src/box/sql/update.c @@ -288,7 +288,7 @@ sqlite3Update(Parse * pParse, /* The = parser context */ goto update_cleanup; if (pParse->nested =3D=3D 0) sqlite3VdbeCountChanges(v); - sql_set_multi_write(pParse, 1); + sql_set_multi_write(pParse, true); =20 /* Allocate required registers. */ regOldPk =3D regNewPk =3D ++pParse->nMem; --Apple-Mail=_7312F9B8-5FE0-4CE1-884D-A02AC2DB9A88 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On 3 Apr 2018, at 20:54, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> wrote:

Hello. See 7 comments = below.

03.04.2018 19:14, Nikita Pettik = =D0=BF=D0=B8=D1=88=D0=B5=D1=82:
Some of legacy functions = seem to be useless, since they serve as
wrappers around = others; the rest rely on capabilities which are no
longer = relevant. This patch provides slight refactoring of such
functions.

Removed entities:
 - sqlite3LocateTableItem() - replaced with = sqlite3LocateTable();
 - sqlite3FindTable() - = replaced with sqlite3HashFind();
 - = sqlite3ColumnOfIndex() - in Tarantool order of columns always the = same;
 - sqlite3FindIndex() - replaced with = sqlite3LocateIndex();
 - = sqlite3CodeVerifySchema();
 - = sqlite3SchemaToIndex();
 - sqlite3MultiWrite();
 - Parse->cookieMast;
 - = Vdbe->usesStmtJournal;
---
 src/box/sql/alter.c     |  13 = ++-
 src/box/sql/analyze.c   |  25 = +++---
 src/box/sql/build.c     | = 213 ++++++++++--------------------------------------
 src/box/sql/delete.c    |   5 = +-
 src/box/sql/expr.c =      |   9 +-
 src/box/sql/fkey.c      | =   3 +-
 src/box/sql/insert.c =    |  10 +--
 src/box/sql/pragma.c =    |  18 ++--
 src/box/sql/prepare.c   |  29 -------
 src/box/sql/select.c    |   4 = +-
 src/box/sql/sqliteInt.h |  11 +--
 src/box/sql/trigger.c   |   7 +-
 src/box/sql/update.c    |   2 = +-
 src/box/sql/vdbe.c =      |   1 -
 src/box/sql/vdbeInt.h   |   1 -
 src/box/sql/vdbeaux.c   |   1 -
 src/box/sql/where.c     | =   2 -
 src/box/sql/wherecode.c | =   7 +-
 18 files changed, 83 insertions(+), = 278 deletions(-)

diff --git = a/src/box/sql/alter.c b/src/box/sql/alter.c
index = 054c0856c..a19324ed2 100644
--- a/src/box/sql/alter.c
+++ b/src/box/sql/alter.c
@@ -122,7 +121,7 @@ = sqlite3AlterRenameTable(Parse * pParse, /* Parser context. */
  if (v =3D=3D 0) {
  goto = exit_rename_table;
  }
- = sqlite3BeginWriteOperation(pParse, false);
+ = sql_set_multi_write(pParse, false);
1. Can you please alongside with this = patch make sql_set_multi_write take boolean as the last
argument? Now it sometimes gets true/false, = sometimes 1/0. It is strange.

Done.

    /* Drop = and reload the internal table schema. */
  = reloadTableSchema(pParse, pTab, zName);

diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index 5e3ed0f39..61194e06b 100644
--- = a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -93,23 +93,16 @@ sqlite3FinishCoding(Parse * pParse)
   * = transaction on each used database and to verify the schema cookie
   * on = each used database.
   */
- if = (db->mallocFailed =3D=3D 0
-     && = (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr)
- = =     ) {
+ = = if (db->mallocFailed =3D=3D 0 || pParse->pConstExpr) {
2. Please, together with cookie mask = checking remove or refactor a comment above.

Fixed.

@@ -2240,7 +2164,6 @@ sqlite3CodeDropTable(Parse * pParse, = Table * pTab, int isView)
    v =3D = sqlite3GetVdbe(pParse);
  assert(v !=3D 0);
- = sqlite3BeginWriteOperation(pParse, 1);
3. Why did you delete it with no = replacement by sql_set_multi_write(false) ?

Because in = this particular case is is completely useless:
table dropping = is implemented as hardcoded opcodes sequences.
AFAIK this mask = is used to provide kind of optimisation/checks during
query = compilation. 

Also, = removed:

@@ -2414,8 +2326,7 @@ = sqlite3DropTable(Parse * pParse, SrcList * pName, int isView, int = noErr)
 = *    space_id from = _space.
 = */
 
- = sqlite3BeginWriteOperation(pParse, 1);
sql_clear_stat_spaces(pParse, = "tbl", pTab->zName);
  sqlite3FkDropTable(pParse, pName, = pTab);
 = sqlite3CodeDropTable(pParse, pTab, = isView);

@@ -2376,15 +2299,12 @@ sqlite3DropTable(Parse * pParse, = SrcList * pName, int isView, int noErr)
  if = (noErr)
  db->suppressErr++;
  assert(isView =3D=3D 0 || isView =3D=3D LOCATE_VIEW);
- = pTab =3D sqlite3LocateTableItem(pParse, isView, = &pName->a[0]);
+ pTab =3D = sqlite3LocateTable(pParse, isView, pName->a[0].zName);
  if (noErr)
  = db->suppressErr--;
 - if (pTab = =3D=3D 0) {
- if (noErr)
- = sqlite3CodeVerifySchema(pParse);
+ if (pTab = =3D=3D 0)
4. Lets use =3D=3D/!=3D NULL in all new = code.

Done.

Same about checking sqlite3HashFind = results. And if it is
possible with not huge diff, can = you please rename sqlite3HashFind to sql_hash_find ?

Is it worth = doing? It is going to disappear soon.


5. sqlite3MultiWrite in commit = message is listed among deleted functions, but its declaration still = exists.

Fixed:

@@ = -3718,8 +3689,8 @@ void sqlite3GenerateConstraintChecks(Parse *, Table = *, int *, int, int, int,
 void = sqlite3CompleteInsertion(Parse *, Table *, int, int *, int, = u8);
 int sqlite3OpenTableAndIndices(Parse *, Table *, = int, u8, int, u8 *, int *,
          =                     =  int *, u8, u8);
-void sqlite3BeginWriteOperation(Parse = *, int);
-void sqlite3MultiWrite(Parse = *);
+void
+sql_set_multi_write(Parse *, = bool);


6. cookieMast - typo in commit message. = And how about do not list deleted functions in a commit body?
I can not imagine, that somebody except me will = search for any of these functions. And the list is deprecated = -
for example, sqlite3BeginWriteOperation = is deleted too, but does not presence in the list.

Ok, fixed = commit message. Left only description.


7. How about remove DbMaskTest, = DbMaskZero and other dbmask shit?

As you wish. Done.

Diff is below:

diff --git a/src/box/sql/alter.c = b/src/box/sql/alter.c
index a19324ed2..129ef823c = 100644
--- a/src/box/sql/alter.c
+++ = b/src/box/sql/alter.c
@@ -85,7 +85,7 @@ = sqlite3AlterRenameTable(Parse * pParse, /* Parser context. = */
  assert(pSrc->nSrc =3D=3D = 1);
 
  pTab =3D = sqlite3LocateTable(pParse, 0, pSrc->a[0].zName);
- if = (!pTab)
+ if (pTab =3D=3D = NULL)
  goto = exit_rename_table;
 
  = user_session->sql_flags |=3D = SQLITE_PreferBuiltin;
@@ -257,7 +257,7 @@ = sqlite3AlterBeginAddColumn(Parse * pParse, SrcList * = pSrc)
  if = (db->mallocFailed)
  goto = exit_begin_add_column;
  pTab =3D = sqlite3LocateTable(pParse, 0, pSrc->a[0].zName);
- if = (!pTab)
+ if (pTab =3D=3D = NULL)
  goto = exit_begin_add_column;
 
  /* Make = sure this is not an attempt to ALTER a view. */
@@ -304,7 = +304,7 @@ sqlite3AlterBeginAddColumn(Parse * pParse, SrcList * = pSrc)
  pNew->nTabRef =3D = 1;
 
  /* Begin a transaction and = increment the schema cookie.  */
- = sql_set_multi_write(pParse, 0);
+ = sql_set_multi_write(pParse, false);
  v =3D = sqlite3GetVdbe(pParse);
  if (!v)
  = goto exit_begin_add_column;
diff --git = a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index = 25e93aa15..60f4eaac4 100644
--- = a/src/box/sql/analyze.c
+++ = b/src/box/sql/analyze.c
@@ -157,6 +157,7 @@ = openStatTable(Parse * pParse, /* Parsing context = */
  Table = *pStat;
  /* The table already = exists, because it is a system space */
  = pStat =3D sqlite3HashFind(&db->pSchema->tblHash, = zTab);
+ assert(pStat !=3D = NULL);
  aRoot[i] =3D = pStat->tnum;
  aCreateTbl[i] =3D = 0;
  if (zWhere) = {
@@ -1122,7 +1123,7 @@ analyzeDatabase(Parse * = pParse)
  int iMem;
  int = iTab;
 
- sql_set_multi_write(pParse, = 0);
+ = sql_set_multi_write(pParse, false);
  iStatCur = =3D pParse->nTab;
  pParse->nTab +=3D = 3;
  openStatTable(pParse, iStatCur, = 0, 0);
@@ -1146,7 +1147,7 @@ analyzeTable(Parse * pParse, = Table * pTab, Index * pOnlyIdx)
  int = iStatCur;
 
  assert(pTab !=3D = 0);
- = sql_set_multi_write(pParse, 0);
+ = sql_set_multi_write(pParse, true);
  iStatCur = =3D pParse->nTab;
  pParse->nTab +=3D = 3;
  if (pOnlyIdx) {
@@ = -1294,9 +1295,8 @@ analysisLoader(void *pData, int argc, char **argv, = char **NotUsed)
  return = 0;
  }
  pTable =3D = sqlite3HashFind(&pInfo->db->pSchema->tblHash, = argv[0]);
- if (pTable =3D=3D 0) = {
+ = if (pTable =3D=3D NULL)
  = return 0;
- }
  if = (argv[1] =3D=3D 0) {
  pIndex =3D = 0;
  } else if = (sqlite3_stricmp(argv[0], argv[1]) =3D=3D 0) {
@@ -1631,19 = +1631,17 @@ loadStatTbl(sqlite3 * db, /* Database handle = */
 static int
 loadStat4(sqlite3 * = db)
 {
- int rc =3D SQLITE_OK; /* Result = codes from subroutines */
  Table *pTab =3D 0; /* = Pointer to stat table */
 
  = assert(db->lookaside.bDisable);
  pTab =3D = sqlite3HashFind(&db->pSchema->tblHash, = "_sql_stat4");
- if (pTab) {
- = rc =3D loadStatTbl(db,
- = pTab,
-= "SELECT \"tbl\",\"idx\",count(*) = FROM \"_sql_stat4\" GROUP BY \"tbl\",\"idx\"",
- = "SELECT \"tbl\",\"idx\",\"neq\",\"nlt\",\"ndlt\",\"sample\" FROM = \"_sql_stat4\"");
- }
-
- return = rc;
+ = /* _slq_stat4 is a system space, so it always exists. = */
+ = assert(pTab !=3D NULL);
+ return loadStatTbl(db, = pTab,
+=   "SELECT \"tbl\",\"idx\",count(*) = FROM \"_sql_stat4\""
+   " GROUP = BY \"tbl\",\"idx\"",
+   "SELECT = \"tbl\",\"idx\",\"neq\",\"nlt\",\"ndlt\","
+ =   "\"sample\" FROM = \"_sql_stat4\"");
 }
 
 /*
diff --git a/src/box/sql/build.c = b/src/box/sql/build.c
index 61194e06b..c50847a02 = 100644
--- a/src/box/sql/build.c
+++ = b/src/box/sql/build.c
@@ -86,13 +86,6 @@ = sqlite3FinishCoding(Parse * pParse)
    =     || sqlite3VdbeAssertMayAbort(v, = pParse->mayAbort));
  if (v) {
  = sqlite3VdbeAddOp0(v, OP_Halt);
-
- = /* 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
- = * transaction on each used database and to verify the schema = cookie
- * on each used = database.
- */
  = if (db->mallocFailed =3D=3D 0 || pParse->pConstExpr) = {
  int = i;
  = assert(sqlite3VdbeGetOp(v, 0)->opcode =3D=3D = OP_Init);
@@ -192,7 +185,7 @@ sqlite3LocateTable(Parse * = pParse, = /* context in which to report errors */
  = assert(pParse->db->pSchema !=3D = NULL);
 
  p =3D = sqlite3HashFind(&pParse->db->pSchema->tblHash, = zName);
- if (p =3D=3D 0) = {
+ = if (p =3D=3D NULL) {
  const char *zMsg = =3D
     flags & = LOCATE_VIEW ? "no such view" : "no such table";
  = if ((flags & LOCATE_NOERR) =3D=3D 0) {
@@ -212,9 = +205,8 @@ sqlite3LocateIndex(sqlite3 * db, const char *zName, const char = *zTable)
 
  Table *pTab =3D = sqlite3HashFind(&db->pSchema->tblHash, = zTable);
 
- if (pTab =3D=3D 0) = {
- = return 0;
- }
+ if (pTab = =3D=3D NULL)
+ return = NULL;
 
  return = sqlite3HashFind(&pTab->idxHash, = zName);
 }
@@ -545,7 +537,7 @@ = sqlite3StartTable(Parse *pParse, Token *pName, int = noErr)
 
  assert(db->pSchema !=3D = NULL);
  pTable =3D = sqlite3HashFind(&db->pSchema->tblHash, = zName);
- if (pTable) {
+ if = (pTable !=3D NULL) {
  if (!noErr) = {
  = sqlite3ErrorMsg(pParse,
  = "table %s already exists",
@@ -583,7 +575,7 @@ = sqlite3StartTable(Parse *pParse, Token *pName, int = noErr)
  * now.
  = */
  if (!db->init.busy && = (v =3D sqlite3GetVdbe(pParse)) !=3D 0)
- = sql_set_multi_write(pParse, 1);
+ = sql_set_multi_write(pParse, = true);
 
  /* Normal (non-error) return. = */
  return;
@@ -2303,7 = +2295,7 @@ sqlite3DropTable(Parse * pParse, SrcList * pName, int isView, = int noErr)
  if (noErr)
  = db->suppressErr--;
 
- if (pTab = =3D=3D 0)
+ if (pTab =3D=3D = NULL)
  goto = exit_drop_table;
 #ifndef = SQLITE_OMIT_VIEW
  /* Ensure DROP TABLE is not used = on a view, and DROP VIEW is not used
@@ -2334,7 +2326,7 @@ = sqlite3DropTable(Parse * pParse, SrcList * pName, int isView, int = noErr)
  *    space_id from = _space.
  = */
 
- sql_set_multi_write(pParse, = 1);
+ = sql_set_multi_write(pParse, true);
  = sql_clear_stat_spaces(pParse, "tbl", = pTab->zName);
  sqlite3FkDropTable(pParse, pName, = pTab);
  sqlite3CodeDropTable(pParse, = pTab, isView);
@@ -2841,14 +2833,15 @@ = sqlite3CreateIndex(Parse * pParse, /* All information about this = parse */
  goto = exit_create_index;
  assert(pName->z !=3D = 0);
  if (!db->init.busy) = {
- = if (sqlite3HashFind(&db->pSchema->tblHash, = zName) !=3D 0) {
+ if = (sqlite3HashFind(&db->pSchema->tblHash, zName) = !=3D
+ =    NULL) {
  = sqlite3ErrorMsg(pParse,
  = "there is already a table named = %s",
  = zName);
  goto = exit_create_index;
  = }
  }
- = if (sqlite3HashFind(&pTab->idxHash, zName) !=3D 0) = {
+ = if (sqlite3HashFind(&pTab->idxHash, zName) !=3D NULL) = {
  if (!ifNotExist) = {
  = sqlite3ErrorMsg(pParse,
  = "index %s.%s already exists",
@@ = -3107,7 +3100,7 @@ sqlite3CreateIndex(Parse * pParse, /* All = information about this parse */
  = if (v =3D=3D 0)
  goto = exit_create_index;
 
- = sql_set_multi_write(pParse, 1);
+ = sql_set_multi_write(pParse, = true);
 
 
  = sqlite3VdbeAddOp2(v, OP_SIDtoPtr, BOX_INDEX_ID,
@@ = -3853,11 +3846,10 @@ sqlite3Savepoint(Parse * pParse, int op, Token * = pName)
  * execution multiple insertion/updates may = occur.
  = */
 void
-sql_set_multi_write(Parse *pParse, = int setStatement)
+sql_set_multi_write(struct Parse = *parse_context, bool is_set)
 {
- Parse = *pToplevel =3D sqlite3ParseToplevel(pParse);
- = DbMaskSet(pToplevel->writeMask, 0);
- = pToplevel->isMultiWrite |=3D setStatement;
+ Parse = *pToplevel =3D sqlite3ParseToplevel(parse_context);
+ = pToplevel->isMultiWrite |=3D = is_set;
 }
 
 /*
@@= -3974,7 +3966,7 @@ reindexTable(Parse * pParse, Table * pTab, char = const *zColl)
 
  for = (pIndex =3D pTab->pIndex; pIndex; pIndex =3D pIndex->pNext) = {
  if (zColl =3D=3D 0 || = collationMatch(zColl, pIndex)) {
- = sql_set_multi_write(pParse, 0);
+ = sql_set_multi_write(pParse, false);
  = sqlite3RefillIndex(pParse, pIndex, -1);
  = }
  }
@@ -4050,7 +4042,7 @@ = sqlite3Reindex(Parse * pParse, Token * pName1, Token * = pName2)
  if (z =3D=3D = 0)
  = return;
  pTab =3D = sqlite3HashFind(&db->pSchema->tblHash, z);
- if (pTab) = {
+ = if (pTab !=3D NULL) {
  = reindexTable(pParse, pTab, 0);
  = sqlite3DbFree(db, z);
  = return;
@@ -4066,8 +4058,8 @@ sqlite3Reindex(Parse * = pParse, Token * pName1, Token * pName2)
  = }
 
  pIndex =3D = sqlite3HashFind(&pTab->idxHash, z);
- if = (pIndex) {
- = sql_set_multi_write(pParse, 0);
+ if = (pIndex !=3D NULL) {
+ = sql_set_multi_write(pParse, false);
  = sqlite3RefillIndex(pParse, pIndex, -1);
  = return;
  }
diff --git = a/src/box/sql/delete.c b/src/box/sql/delete.c
index = a07ef1980..9f4ce1026 100644
--- = a/src/box/sql/delete.c
+++ b/src/box/sql/delete.c
@@ = -59,12 +59,10 @@ sqlite3SrcListLookup(Parse * pParse, SrcList * = pSrc)
  pTab =3D = sqlite3LocateTable(pParse, 0, pItem->zName);
  = sqlite3DeleteTable(pParse->db, = pItem->pTab);
  pItem->pTab =3D = pTab;
-= if (pTab) {
+ if (pTab !=3D = NULL)
  = pTab->nTabRef++;
- }
- if = (sqlite3IndexedByLookup(pParse, pItem)) {
- = pTab =3D 0;
- }
+ if = (sqlite3IndexedByLookup(pParse, pItem))
+ = pTab =3D NULL;
  return = pTab;
 }
 
@@ -324,7 +322,7 @@ = sqlite3DeleteFrom(Parse * pParse, /* The parser context = */
  }
  if = (pParse->nested =3D=3D 0)
  = sqlite3VdbeCountChanges(v);
- = sql_set_multi_write(pParse, 1);
+ = sql_set_multi_write(pParse, = true);
 
  /* If we are trying to delete = from a view, realize that view into
  * an = ephemeral table.
diff --git a/src/box/sql/insert.c = b/src/box/sql/insert.c
index 2719bbaf4..704e48d9c = 100644
--- a/src/box/sql/insert.c
+++ = b/src/box/sql/insert.c
@@ -1461,7 +1461,7 @@ = sqlite3GenerateConstraintChecks(Parse * pParse, = /* The parser context */
  = default: {
  Trigger = *pTrigger =3D 0;
  = assert(onError =3D=3D = ON_CONFLICT_ACTION_REPLACE);
- = sql_set_multi_write(pParse, 1);
+ = sql_set_multi_write(pParse, true);
  = if (user_session->
  =    sql_flags & SQLITE_RecTriggers) = {
  = pTrigger =3D
@@ -1769,9 +1769,8 @@ = xferOptimization(Parse * pParse, /* Parser context = */
  int regData, regTupleid; /* = Registers holding data and tupleid */
  struct = session *user_session =3D = current_session();
 
- if = (pSelect =3D=3D 0) {
+ if (pSelect =3D=3D = 0)
  return 0; /* Must = be of the form  INSERT INTO ... SELECT ... */
- = }
  if (pParse->pWith || = pSelect->pWith) {
  /* Do not attempt to = process this query if there are an WITH clauses
  = * attached to it. Proceeding may generate a false "no such table: = xxx"
@@ -1833,7 +1832,7 @@ xferOptimization(Parse * = pParse, = /* Parser context */
  */
  pItem =3D = pSelect->pSrc->a;
  pSrc =3D = sqlite3LocateTable(pParse, 0, pItem->zName);
- if (pSrc = =3D=3D 0) {
+ if (pSrc =3D=3D NULL) = {
  return 0; /* FROM = clause does not contain a real table */
  = }
  if (pSrc =3D=3D pDest) = {
diff --git a/src/box/sql/pragma.c = b/src/box/sql/pragma.c
index 04b4020dd..c19a811ff = 100644
--- a/src/box/sql/pragma.c
+++ = b/src/box/sql/pragma.c
@@ -480,7 +480,7 @@ sqlite3Pragma(Parse = * pParse, Token * pId, /* First part of [schema.]id = field */
  int = i;
  pTab =3D = sqlite3HashFind(&db->pSchema->tblHash,
  =       zRight);
- = if (pTab) {
+ if (pTab = !=3D NULL) {
  = pParse->nMem =3D 5;
  = for (pIdx =3D pTab->pIndex, i =3D 0; = pIdx;
  =     pIdx =3D pIdx->pNext, i++) {
@@ -540,7 +540,7 = @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First = part of [schema.]id field */
  = Table *pTab;
  pTab =3D = sqlite3HashFind(&db->pSchema->tblHash,
  =       zRight);
- = if (pTab) {
+ if (pTab = !=3D NULL) {
  = pFK =3D pTab->pFKey;
  = if (pFK) {
  = int i =3D 0;
@@ -617,7 +617,7 @@ sqlite3Pragma(Parse * = pParse, Token * pId, /* First part of [schema.]id = field */
  = pParent =3D
  = sqlite3HashFind(&db->pSchema->tblHash,
  = pFK->zTo);
- = if (pParent =3D=3D 0)
+ = if (pParent =3D=3D NULL)
  = continue;
  = pIdx =3D 0;
  x = =3D sqlite3FkLocateIndex(pParse,
diff --git = a/src/box/sql/select.c b/src/box/sql/select.c
index = 6ff8dc25e..679aa2246 100644
--- = a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ = -4746,7 +4746,7 @@ selectExpander(Walker * pWalker, Select * = p)
  = assert(pFrom->pTab =3D=3D 0);
  = pFrom->pTab =3D pTab =3D
  =    sqlite3LocateTable(pParse, 0, = pFrom->zName);
- if (pTab =3D=3D = 0)
+ = if (pTab =3D=3D NULL)
  = return WRC_Abort;
  if = (pTab->nTabRef >=3D 0xffff) {
  = sqlite3ErrorMsg(pParse,
diff --git = a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h
index = 3234f992b..6d78f791d 100644
--- = a/src/box/sql/sqliteInt.h
+++ = b/src/box/sql/sqliteInt.h
@@ -2887,25 +2887,6 @@ struct = TriggerPrg {
  u32 aColmask[2]; /* Masks = of old.*, new.* columns accessed = */
 };
 
-/*
- * The = yDbMask datatype for the bitmask of all attached databases.
- = */
-#if SQLITE_MAX_ATTACHED>30
-typedef unsigned = char yDbMask[(SQLITE_MAX_ATTACHED + 9) / 8];
-#define = DbMaskTest(M,I)   =  (((M)[(I)/8]&(1<<((I)&7)))!=3D0)
-#define = DbMaskZero(M)     =  memset((M),0,sizeof(M))
-#define DbMaskSet(M,I)   =   (M)[(I)/8]|=3D(1<<((I)&7))
-#define = DbMaskAllZero(M)   sqlite3DbMaskAllZero(M)
-#define = DbMaskNonZero(M)   = (sqlite3DbMaskAllZero(M)=3D=3D0)
-#else
-typedef = unsigned int yDbMask;
-#define DbMaskTest(M,I)   =  (((M)&(((yDbMask)1)<<(I)))!=3D0)
-#define = DbMaskZero(M)      (M)=3D0
-#define = DbMaskSet(M,I)     = (M)|=3D(((yDbMask)1)<<(I))
-#define DbMaskAllZero(M) =   (M)=3D=3D0
-#define DbMaskNonZero(M)   = (M)!=3D0
-#endif
-
 /*
 = * An SQL parser context.  A copy of this structure is passed = through
  * the parser and down into all the parser = action routine in order to
@@ -2946,7 +2927,6 @@ struct Parse = {
  int *aLabel; = /* Space to hold the labels */
  ExprList = *pConstExpr; = /* Constant expressions */
  Token = constraintName; = /* Name of the constraint currently being parsed = */
- = yDbMask writeMask; /* Start a write transaction on = these databases */
  int regRoot; = /* Register holding root page number for new objects = */
  int nMaxArg; = /* Max args passed to user function by sub-program = */
 #ifdef SELECTTRACE_ENABLED
@@ -3585,9 = +3565,6 @@ int sqlite3ViewGetColumnNames(Parse *, Table = *);
 #define sqlite3ViewGetColumnNames(A,B) = 0
 #endif
 
-#if = SQLITE_MAX_ATTACHED>30
-int = sqlite3DbMaskAllZero(yDbMask);
-#endif
 void = sqlite3DropTable(Parse *, SrcList *, int, int);
 void = sqlite3DeleteTable(sqlite3 *, Table *);
 void = sqlite3Insert(Parse *, SrcList *, Select *, IdList *, = int);
diff --git a/src/box/sql/trigger.c = b/src/box/sql/trigger.c
index decbc8c21..a102c32b6 = 100644
--- a/src/box/sql/trigger.c
+++ = b/src/box/sql/trigger.c
@@ -293,7 +293,7 @@ = sqlite3FinishTrigger(Parse * pParse, /* Parser context = */
  iFirstCol =3D = pParse->nMem + 1;
  pParse->nMem +=3D = 2;
 
- = sql_set_multi_write(pParse, 0);
+ = sql_set_multi_write(pParse, false);
  = sqlite3VdbeAddOp4(v,
  =  OP_String8, 0, iFirstCol, 0,
  =  zName, P4_STATIC);
diff --git = a/src/box/sql/update.c b/src/box/sql/update.c
index = ad6aad5e6..778519bd6 100644
--- = a/src/box/sql/update.c
+++ b/src/box/sql/update.c
@@ = -288,7 +288,7 @@ sqlite3Update(Parse * pParse, = /* The parser context */
  = goto update_cleanup;
  if (pParse->nested =3D=3D = 0)
  = sqlite3VdbeCountChanges(v);
- = sql_set_multi_write(pParse, 1);
+ = sql_set_multi_write(pParse, = true);
 
  /* Allocate required registers. = */
  regOldPk =3D regNewPk =3D = ++pParse->nMem;



= --Apple-Mail=_7312F9B8-5FE0-4CE1-884D-A02AC2DB9A88--