1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

A new implementation of sqlite3VdbeMakeLabel() is faster and makes fewer

memory allocations by deferring memory allocation until 
sqlite3VdbeResolveLabel() is called, at which point the code generator has
a better idea of how big the relocation table needs to be.
The sqlite3VdbeMakeLabel() routine now takes a Parse* parameter instead of
Vdbe*.

FossilOrigin-Name: 4a0929ac76d8aa5dd65eac3b83d6bbf41e505e01d175ca0fb2b19ba02d439415
This commit is contained in:
drh
2018-12-29 02:26:59 +00:00
parent 81f9159b5e
commit ec4ccdbcb1
17 changed files with 112 additions and 104 deletions

View File

@@ -1,5 +1,5 @@
C Faster\sallocation\sof\snew\ssqlite3_stmt\sobjects. C A\snew\simplementation\sof\ssqlite3VdbeMakeLabel()\sis\sfaster\sand\smakes\sfewer\nmemory\sallocations\sby\sdeferring\smemory\sallocation\suntil\s\nsqlite3VdbeResolveLabel()\sis\scalled,\sat\swhich\spoint\sthe\scode\sgenerator\shas\na\sbetter\sidea\sof\show\sbig\sthe\srelocation\stable\sneeds\sto\sbe.\nThe\ssqlite3VdbeMakeLabel()\sroutine\snow\stakes\sa\sParse*\sparameter\sinstead\sof\nVdbe*.
D 2018-12-28T20:48:07.501 D 2018-12-29T02:26:59.013
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in d8b254f8bb81bab43c340d70d17dc3babab40fcc8a348c8255881f780a45fee6 F Makefile.in d8b254f8bb81bab43c340d70d17dc3babab40fcc8a348c8255881f780a45fee6
@@ -445,7 +445,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c 082286f89160ca2302d51650e173b745ef78c42b6a7ebc3262d9cb166596c7ca F src/alter.c 082286f89160ca2302d51650e173b745ef78c42b6a7ebc3262d9cb166596c7ca
F src/analyze.c 3dc6b98cf007b005af89df165c966baaa48e8124f38c87b4d2b276fe7f0b9eb9 F src/analyze.c 58db66344a5c58dcabb57f26696f6f2993956c830446da40b444051d2fdaf644
F src/attach.c 92b51739a885da8bd84bc9a05485f1e48148bce5c15432f059b45af98fff75cd F src/attach.c 92b51739a885da8bd84bc9a05485f1e48148bce5c15432f059b45af98fff75cd
F src/auth.c 0fac71038875693a937e506bceb492c5f136dd7b1249fbd4ae70b4e8da14f9df F src/auth.c 0fac71038875693a937e506bceb492c5f136dd7b1249fbd4ae70b4e8da14f9df
F src/backup.c 78d3cecfbe28230a3a9a1793e2ead609f469be43e8f486ca996006be551857ab F src/backup.c 78d3cecfbe28230a3a9a1793e2ead609f469be43e8f486ca996006be551857ab
@@ -461,17 +461,17 @@ F src/ctime.c 109e58d00f62e8e71ee1eb5944ac18b90171c928ab2e082e058056e1137cc20b
F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957 F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7 F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
F src/dbstat.c 3c8bd4e77f0244fd2bd7cc90acf116ad2f8e82d70e536637f35ac2bc99b726f9 F src/dbstat.c 3c8bd4e77f0244fd2bd7cc90acf116ad2f8e82d70e536637f35ac2bc99b726f9
F src/delete.c f7938125847e8ef485448db5fbad29acb2991381a02887dd854c1617315ab9fb F src/delete.c 209cd8345b15d1843abeff2d91a6d9c765cf32ff4abcb24411c38fe08e18baab
F src/expr.c 3f398a6698da6fccff353c09d5fc86e7e815386eeeaa9343360c6ef66167dcc6 F src/expr.c 2c28e3bcb8de699e5e0da2efcae50aed2a64d02b50ecf9920d27393f3eef4629
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 012dd7dba1a62fda6b76e633ab303b2232ee2874a685c915065227ab20ad6ae0 F src/fkey.c aaf28be73ab21e1e8bf4ac6b94269ebc8c93238d1e6997cb44b527b622e8ae6f
F src/func.c 7c288b4ce309b5a8b8473514b88e1f8e69a80134509a8c0db8e39c858e367e7f F src/func.c 7c288b4ce309b5a8b8473514b88e1f8e69a80134509a8c0db8e39c858e367e7f
F src/global.c 8291eee0782b83124de14ec0389ec9fd6ae1873358a6b0d9469fe17a46ad803b F src/global.c 8291eee0782b83124de14ec0389ec9fd6ae1873358a6b0d9469fe17a46ad803b
F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 2b5d4e52fdcf1b9e8a5fe88bb2a5f1c58338062145b95683c2e98467633620e8 F src/insert.c 1e0001758cd174177886cdfe23d69c6d6775f1c4e7fe946a041f1ef56ae85bc5
F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e
F src/loadext.c e6f10875d52aca3b7e57ce1ec174aeafc9b6c00b43000cd30d791f9cb490b7a6 F src/loadext.c e6f10875d52aca3b7e57ce1ec174aeafc9b6c00b43000cd30d791f9cb490b7a6
F src/main.c 008f45dd39cdc7fb9e7e1f61d75a5c97397f8e07427a8879be23e27747d5f948 F src/main.c 008f45dd39cdc7fb9e7e1f61d75a5c97397f8e07427a8879be23e27747d5f948
@@ -503,19 +503,19 @@ F src/parse.y a3c0db595bc642c6ee1d72869842f7f5b0b6ebeb91c21d0a7cba631d27e7afbd
F src/pcache.c 696a01f1a6370c1b50a09c15972bc3bee3333f8fcd1f2da8e9a76b1b062c59ee F src/pcache.c 696a01f1a6370c1b50a09c15972bc3bee3333f8fcd1f2da8e9a76b1b062c59ee
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
F src/pcache1.c ddc9fc7d9861cf3a1f30660264b76b1ae9e1dce5dbba085cf001d5cb6b41cf8c F src/pcache1.c ddc9fc7d9861cf3a1f30660264b76b1ae9e1dce5dbba085cf001d5cb6b41cf8c
F src/pragma.c 96ce7dce4dc9cb2b7aa0e1b2ce7536870bdc00b10becc278245e775489447ea0 F src/pragma.c 20811b404b6d302a1bedd4b8af8aab2794c5e87ba1f5cb6b42dbc3266ad9c603
F src/pragma.h fdd03d78a7497f74a3f652909f945328480089189526841ae829ce7313d98d13 F src/pragma.h fdd03d78a7497f74a3f652909f945328480089189526841ae829ce7313d98d13
F src/prepare.c d0918fb8d00b1ebf19655e7f3d28464b3fc3c43c16d36dd06092de02244a5180 F src/prepare.c d0918fb8d00b1ebf19655e7f3d28464b3fc3c43c16d36dd06092de02244a5180
F src/printf.c 0f1177cf1dd4d7827bf64d840768514ec76409abecaca9e8b577dbd065150381 F src/printf.c 0f1177cf1dd4d7827bf64d840768514ec76409abecaca9e8b577dbd065150381
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 72fe8cae7326b979e7258ab4c531956951e1a5f3fe8644c646abaec1b2eb6d95 F src/resolve.c 72fe8cae7326b979e7258ab4c531956951e1a5f3fe8644c646abaec1b2eb6d95
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93 F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
F src/select.c c6a71c619db529e1af6b30d9ff59ec75dac2511f155e45bb6e49c07d9d5e79c0 F src/select.c 2493d09401fdd3c0b9a8d5b15486876f9167f87ef8013d58be9730f4c83bdb0c
F src/shell.c.in 207da30342db0b6fac8b2487abd60b059a5ea80cc9494bd1db76a1dd4aae7cca F src/shell.c.in 207da30342db0b6fac8b2487abd60b059a5ea80cc9494bd1db76a1dd4aae7cca
F src/sqlite.h.in b54cd42d2f3b739a00de540cafe2dcd0de3b8e1748a2db33a68def487e9e602f F src/sqlite.h.in b54cd42d2f3b739a00de540cafe2dcd0de3b8e1748a2db33a68def487e9e602f
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 960f1b86c3610fa23cb6a267572a97dcf286e77aa0dd3b9b23292ffaa1ea8683 F src/sqlite3ext.h 960f1b86c3610fa23cb6a267572a97dcf286e77aa0dd3b9b23292ffaa1ea8683
F src/sqliteInt.h 00590d0d0b1befd7bd19969f8a3c73b2378c4880634c6e5a0b01891e29cff2f9 F src/sqliteInt.h c2ac6a115b0cba20d9152fc5ae3f20067d56ea0e410f710fc46501071faca1e8
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
@@ -575,17 +575,17 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
F src/tokenize.c c8af4feebd8bf5a4d60a14018d91f61013f658ec864dfce7661bae73d86b3191 F src/tokenize.c c8af4feebd8bf5a4d60a14018d91f61013f658ec864dfce7661bae73d86b3191
F src/treeview.c c6ff90da4cc1813ff2d9bb11f17d4d927db62c47e552faa1835edc47269d753d F src/treeview.c c6ff90da4cc1813ff2d9bb11f17d4d927db62c47e552faa1835edc47269d753d
F src/trigger.c 252b650375dd1f47e787fddf5fc0ad14bc298c7af7e6e1b70748df604f2ccb37 F src/trigger.c 77546bf525854aa4dc09f3a0450fa801c3e99d5f13a3eb2efd07bfe521e3b5d6
F src/update.c 1816d56c1bca1ba4e0ef98cac2f49be62858e9df1dc08844c7067eb41cc44274 F src/update.c 4e630e47852e206d0b29ec63ea0402e0b7ba328a1c19dd645ae8ac7bd0a378cf
F src/upsert.c 0dd81b40206841814d46942a7337786932475f085716042d0cb2fc7791bf8ca4 F src/upsert.c 0dd81b40206841814d46942a7337786932475f085716042d0cb2fc7791bf8ca4
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157 F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157
F src/vacuum.c 3ffe64ecfc94b7528c5d7bdb1c3a19d72fec63f2aa846e3b90f8de5dbbddf5aa F src/vacuum.c 3ffe64ecfc94b7528c5d7bdb1c3a19d72fec63f2aa846e3b90f8de5dbbddf5aa
F src/vdbe.c 8869a60f4b910c0f6d4ae0f0e23b7a835cae7ed67aa0ce2053d1bbe3e9facc53 F src/vdbe.c 8869a60f4b910c0f6d4ae0f0e23b7a835cae7ed67aa0ce2053d1bbe3e9facc53
F src/vdbe.h 8990d668a89890a33326b0a29b992c4014b72f3b6cdcd9ee0e190593c247f9b0 F src/vdbe.h 21725193a09f5144ec0f60fa0b303a7c81524677afa03b4ceb36481556732fb8
F src/vdbeInt.h a76d5eed62c76bcd8de7afd3147fac1bc40c5a870582664bcd7d071ef437c37f F src/vdbeInt.h a76d5eed62c76bcd8de7afd3147fac1bc40c5a870582664bcd7d071ef437c37f
F src/vdbeapi.c 57a2d794a8833f269b878dbc24e955369bdb379af6c4e93ebc5ce1a20fa3daf4 F src/vdbeapi.c 57a2d794a8833f269b878dbc24e955369bdb379af6c4e93ebc5ce1a20fa3daf4
F src/vdbeaux.c c5d6c0afa98dbc42eac7f74da9f126fe33ec38fa13fec0790b268547f3d96ff2 F src/vdbeaux.c 3fe9349afcf32215c61a6f0884d1f4201180e096dfa38806023a5ad8d036e658
F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191
F src/vdbemem.c 7b3305bc4a5139f4536ac9b5f61da0f915e49d2e3fdfa87dfdfa9d7aba8bc1e9 F src/vdbemem.c 7b3305bc4a5139f4536ac9b5f61da0f915e49d2e3fdfa87dfdfa9d7aba8bc1e9
F src/vdbesort.c 90aad5a92608f2dd771c96749beabdb562c9d881131a860a7a5bccf66dc3be7f F src/vdbesort.c 90aad5a92608f2dd771c96749beabdb562c9d881131a860a7a5bccf66dc3be7f
@@ -595,11 +595,11 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 3f4f653daf234fe713edbcbca3fec2350417d159d28801feabc702a22c4e213f F src/wal.c 3f4f653daf234fe713edbcbca3fec2350417d159d28801feabc702a22c4e213f
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66 F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66
F src/where.c 3818e8a736a05d2cb194e64399af707e367fbcc5c251d785804d02eaf121288e F src/where.c ebdd593773608097a2ef55c061247b4ccd00aab177d2de9693069bbf1a6e6c84
F src/whereInt.h f125f29fca80890768e0b2caa14f95db74b2dacd3a122a168f97aa7b64d6968f F src/whereInt.h f125f29fca80890768e0b2caa14f95db74b2dacd3a122a168f97aa7b64d6968f
F src/wherecode.c 1945ccec1bdcc783a4a1f810b26c33a0845d0ff44478094c82057bd03a527d39 F src/wherecode.c f9f790fc1c7775447949ca8182a9e142d9f5b3428bf0610774fab672083d7c23
F src/whereexpr.c 36b47f7261d6b6f1a72d774c113b74beddf6745aba1018e64b196e29db233442 F src/whereexpr.c 36b47f7261d6b6f1a72d774c113b74beddf6745aba1018e64b196e29db233442
F src/window.c ea81ecd031ed2cbc14b7db6fd7f4bee2471b894feae5fea0547b15b1e2dd8fb2 F src/window.c f4a9ac8396395a9e281e182dd32fc9b3b19f6762a9eef468137369def3ad9a2c
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
@@ -1795,7 +1795,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 8f10efc29dea7b816b1ba401726c268950d6671d890f686911269082a241d8d9 P 891f1f72187f0f9ec0d24fda98cc08be3ae3c3ff8b27c4e409ee7135c3106398
R 7062d8a270754e07b86fa92b28527403 R 50db16867c109bc4608830ffa30de27c
U drh U drh
Z 74c93f83e36562633bb10d90f0e5b0ee Z 2c5a869d2906a2afa3ddf3f6aaade805

View File

@@ -1 +1 @@
891f1f72187f0f9ec0d24fda98cc08be3ae3c3ff8b27c4e409ee7135c3106398 4a0929ac76d8aa5dd65eac3b83d6bbf41e505e01d175ca0fb2b19ba02d439415

View File

@@ -1156,7 +1156,7 @@ static void analyzeOneTable(
addrNextRow = sqlite3VdbeCurrentAddr(v); addrNextRow = sqlite3VdbeCurrentAddr(v);
if( nColTest>0 ){ if( nColTest>0 ){
int endDistinctTest = sqlite3VdbeMakeLabel(v); int endDistinctTest = sqlite3VdbeMakeLabel(pParse);
int *aGotoChng; /* Array of jump instruction addresses */ int *aGotoChng; /* Array of jump instruction addresses */
aGotoChng = sqlite3DbMallocRawNN(db, sizeof(int)*nColTest); aGotoChng = sqlite3DbMallocRawNN(db, sizeof(int)*nColTest);
if( aGotoChng==0 ) continue; if( aGotoChng==0 ) continue;

View File

@@ -517,7 +517,7 @@ void sqlite3DeleteFrom(
/* If this DELETE cannot use the ONEPASS strategy, this is the /* If this DELETE cannot use the ONEPASS strategy, this is the
** end of the WHERE loop */ ** end of the WHERE loop */
if( eOnePass!=ONEPASS_OFF ){ if( eOnePass!=ONEPASS_OFF ){
addrBypass = sqlite3VdbeMakeLabel(v); addrBypass = sqlite3VdbeMakeLabel(pParse);
}else{ }else{
sqlite3WhereEnd(pWInfo); sqlite3WhereEnd(pWInfo);
} }
@@ -706,7 +706,7 @@ void sqlite3GenerateRowDelete(
/* Seek cursor iCur to the row to delete. If this row no longer exists /* Seek cursor iCur to the row to delete. If this row no longer exists
** (this can happen if a trigger program has already deleted it), do ** (this can happen if a trigger program has already deleted it), do
** not attempt to delete it or fire any DELETE triggers. */ ** not attempt to delete it or fire any DELETE triggers. */
iLabel = sqlite3VdbeMakeLabel(v); iLabel = sqlite3VdbeMakeLabel(pParse);
opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound; opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
if( eMode==ONEPASS_OFF ){ if( eMode==ONEPASS_OFF ){
sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk); sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
@@ -912,7 +912,7 @@ int sqlite3GenerateIndexKey(
if( piPartIdxLabel ){ if( piPartIdxLabel ){
if( pIdx->pPartIdxWhere ){ if( pIdx->pPartIdxWhere ){
*piPartIdxLabel = sqlite3VdbeMakeLabel(v); *piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);
pParse->iSelfTab = iDataCur + 1; pParse->iSelfTab = iDataCur + 1;
sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
SQLITE_JUMPIFNULL); SQLITE_JUMPIFNULL);

View File

@@ -553,7 +553,7 @@ static void codeVectorCompare(
int regLeft = 0; int regLeft = 0;
int regRight = 0; int regRight = 0;
u8 opx = op; u8 opx = op;
int addrDone = sqlite3VdbeMakeLabel(v); int addrDone = sqlite3VdbeMakeLabel(pParse);
if( nLeft!=sqlite3ExprVectorSize(pRight) ){ if( nLeft!=sqlite3ExprVectorSize(pRight) ){
sqlite3ErrorMsg(pParse, "row value misused"); sqlite3ErrorMsg(pParse, "row value misused");
@@ -3033,7 +3033,7 @@ static void sqlite3ExprCodeIN(
if( eType==IN_INDEX_NOOP ){ if( eType==IN_INDEX_NOOP ){
ExprList *pList = pExpr->x.pList; ExprList *pList = pExpr->x.pList;
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft); CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
int labelOk = sqlite3VdbeMakeLabel(v); int labelOk = sqlite3VdbeMakeLabel(pParse);
int r2, regToFree; int r2, regToFree;
int regCkNull = 0; int regCkNull = 0;
int ii; int ii;
@@ -3077,7 +3077,7 @@ static void sqlite3ExprCodeIN(
if( destIfNull==destIfFalse ){ if( destIfNull==destIfFalse ){
destStep2 = destIfFalse; destStep2 = destIfFalse;
}else{ }else{
destStep2 = destStep6 = sqlite3VdbeMakeLabel(v); destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
} }
for(i=0; i<nVector; i++){ for(i=0; i<nVector; i++){
Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i); Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
@@ -3135,7 +3135,7 @@ static void sqlite3ExprCodeIN(
addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse); addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
VdbeCoverage(v); VdbeCoverage(v);
if( nVector>1 ){ if( nVector>1 ){
destNotNull = sqlite3VdbeMakeLabel(v); destNotNull = sqlite3VdbeMakeLabel(pParse);
}else{ }else{
/* For nVector==1, combine steps 6 and 7 by immediately returning /* For nVector==1, combine steps 6 and 7 by immediately returning
** FALSE if the first comparison is not NULL */ ** FALSE if the first comparison is not NULL */
@@ -3700,7 +3700,7 @@ expr_code_doover:
** arguments past the first non-NULL argument. ** arguments past the first non-NULL argument.
*/ */
if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){ if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){
int endCoalesce = sqlite3VdbeMakeLabel(v); int endCoalesce = sqlite3VdbeMakeLabel(pParse);
assert( nFarg>=2 ); assert( nFarg>=2 );
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target); sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
for(i=1; i<nFarg; i++){ for(i=1; i<nFarg; i++){
@@ -3848,8 +3848,8 @@ expr_code_doover:
return pExpr->pLeft->iTable + pExpr->iColumn; return pExpr->pLeft->iTable + pExpr->iColumn;
} }
case TK_IN: { case TK_IN: {
int destIfFalse = sqlite3VdbeMakeLabel(v); int destIfFalse = sqlite3VdbeMakeLabel(pParse);
int destIfNull = sqlite3VdbeMakeLabel(v); int destIfNull = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_Null, 0, target); sqlite3VdbeAddOp2(v, OP_Null, 0, target);
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull); sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
sqlite3VdbeAddOp2(v, OP_Integer, 1, target); sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
@@ -3989,7 +3989,7 @@ expr_code_doover:
pEList = pExpr->x.pList; pEList = pExpr->x.pList;
aListelem = pEList->a; aListelem = pEList->a;
nExpr = pEList->nExpr; nExpr = pEList->nExpr;
endLabel = sqlite3VdbeMakeLabel(v); endLabel = sqlite3VdbeMakeLabel(pParse);
if( (pX = pExpr->pLeft)!=0 ){ if( (pX = pExpr->pLeft)!=0 ){
tempX = *pX; tempX = *pX;
testcase( pX->op==TK_COLUMN ); testcase( pX->op==TK_COLUMN );
@@ -4012,7 +4012,7 @@ expr_code_doover:
}else{ }else{
pTest = aListelem[i].pExpr; pTest = aListelem[i].pExpr;
} }
nextCase = sqlite3VdbeMakeLabel(v); nextCase = sqlite3VdbeMakeLabel(pParse);
testcase( pTest->op==TK_COLUMN ); testcase( pTest->op==TK_COLUMN );
sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL); sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);
testcase( aListelem[i+1].pExpr->op==TK_COLUMN ); testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
@@ -4381,7 +4381,7 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
op = pExpr->op; op = pExpr->op;
switch( op ){ switch( op ){
case TK_AND: { case TK_AND: {
int d2 = sqlite3VdbeMakeLabel(v); int d2 = sqlite3VdbeMakeLabel(pParse);
testcase( jumpIfNull==0 ); testcase( jumpIfNull==0 );
sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL); sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);
sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull); sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
@@ -4467,7 +4467,7 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
} }
#ifndef SQLITE_OMIT_SUBQUERY #ifndef SQLITE_OMIT_SUBQUERY
case TK_IN: { case TK_IN: {
int destIfFalse = sqlite3VdbeMakeLabel(v); int destIfFalse = sqlite3VdbeMakeLabel(pParse);
int destIfNull = jumpIfNull ? dest : destIfFalse; int destIfNull = jumpIfNull ? dest : destIfFalse;
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull); sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
sqlite3VdbeGoto(v, dest); sqlite3VdbeGoto(v, dest);
@@ -4554,7 +4554,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
break; break;
} }
case TK_OR: { case TK_OR: {
int d2 = sqlite3VdbeMakeLabel(v); int d2 = sqlite3VdbeMakeLabel(pParse);
testcase( jumpIfNull==0 ); testcase( jumpIfNull==0 );
sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL); sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);
sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull); sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
@@ -4638,7 +4638,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
if( jumpIfNull ){ if( jumpIfNull ){
sqlite3ExprCodeIN(pParse, pExpr, dest, dest); sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
}else{ }else{
int destIfNull = sqlite3VdbeMakeLabel(v); int destIfNull = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull); sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
sqlite3VdbeResolveLabel(v, destIfNull); sqlite3VdbeResolveLabel(v, destIfNull);
} }

View File

@@ -329,7 +329,7 @@ static void fkLookupParent(
int i; /* Iterator variable */ int i; /* Iterator variable */
Vdbe *v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */ Vdbe *v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */
int iCur = pParse->nTab - 1; /* Cursor number to use */ int iCur = pParse->nTab - 1; /* Cursor number to use */
int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */ int iOk = sqlite3VdbeMakeLabel(pParse); /* jump here if parent key found */
sqlite3VdbeVerifyAbortable(v, sqlite3VdbeVerifyAbortable(v,
(!pFKey->isDeferred (!pFKey->isDeferred
@@ -729,7 +729,7 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break; if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
} }
if( !p ) return; if( !p ) return;
iSkip = sqlite3VdbeMakeLabel(v); iSkip = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); VdbeCoverage(v);
} }

View File

@@ -866,7 +866,7 @@ void sqlite3Insert(
/* Run the BEFORE and INSTEAD OF triggers, if there are any /* Run the BEFORE and INSTEAD OF triggers, if there are any
*/ */
endOfLoop = sqlite3VdbeMakeLabel(v); endOfLoop = sqlite3VdbeMakeLabel(pParse);
if( tmask & TRIGGER_BEFORE ){ if( tmask & TRIGGER_BEFORE ){
int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1); int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);
@@ -1356,7 +1356,7 @@ void sqlite3GenerateConstraintChecks(
switch( onError ){ switch( onError ){
case OE_Replace: { case OE_Replace: {
assert( onError==OE_Replace ); assert( onError==OE_Replace );
addr1 = sqlite3VdbeMakeLabel(v); addr1 = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1); sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
VdbeCoverage(v); VdbeCoverage(v);
sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i); sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
@@ -1407,7 +1407,7 @@ void sqlite3GenerateConstraintChecks(
** updated so there is no point it verifying the check constraint */ ** updated so there is no point it verifying the check constraint */
continue; continue;
} }
allOk = sqlite3VdbeMakeLabel(v); allOk = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeVerifyAbortable(v, onError); sqlite3VdbeVerifyAbortable(v, onError);
sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL); sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
if( onError==OE_Ignore ){ if( onError==OE_Ignore ){
@@ -1474,7 +1474,7 @@ void sqlite3GenerateConstraintChecks(
** exist in the table. ** exist in the table.
*/ */
if( pkChng && pPk==0 ){ if( pkChng && pPk==0 ){
int addrRowidOk = sqlite3VdbeMakeLabel(v); int addrRowidOk = sqlite3VdbeMakeLabel(pParse);
/* Figure out what action to take in case of a rowid collision */ /* Figure out what action to take in case of a rowid collision */
onError = pTab->keyConf; onError = pTab->keyConf;
@@ -1624,7 +1624,7 @@ void sqlite3GenerateConstraintChecks(
VdbeComment((v, "Skip upsert subroutine")); VdbeComment((v, "Skip upsert subroutine"));
sqlite3VdbeJumpHere(v, upsertJump); sqlite3VdbeJumpHere(v, upsertJump);
}else{ }else{
addrUniqueOk = sqlite3VdbeMakeLabel(v); addrUniqueOk = sqlite3VdbeMakeLabel(pParse);
} }
if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){ if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){
sqlite3TableAffinity(v, pTab, regNewData+1); sqlite3TableAffinity(v, pTab, regNewData+1);

View File

@@ -1376,7 +1376,7 @@ void sqlite3Pragma(
x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
assert( x==0 ); assert( x==0 );
} }
addrOk = sqlite3VdbeMakeLabel(v); addrOk = sqlite3VdbeMakeLabel(pParse);
/* Generate code to read the child key values into registers /* Generate code to read the child key values into registers
** regRow..regRow+n. If any of the child key values are NULL, this ** regRow..regRow+n. If any of the child key values are NULL, this
@@ -1596,8 +1596,8 @@ void sqlite3Pragma(
if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0); ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);
if( db->mallocFailed==0 ){ if( db->mallocFailed==0 ){
int addrCkFault = sqlite3VdbeMakeLabel(v); int addrCkFault = sqlite3VdbeMakeLabel(pParse);
int addrCkOk = sqlite3VdbeMakeLabel(v); int addrCkOk = sqlite3VdbeMakeLabel(pParse);
char *zErr; char *zErr;
int k; int k;
pParse->iSelfTab = iDataCur + 1; pParse->iSelfTab = iDataCur + 1;
@@ -1620,7 +1620,7 @@ void sqlite3Pragma(
/* Validate index entries for the current row */ /* Validate index entries for the current row */
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int jmp2, jmp3, jmp4, jmp5; int jmp2, jmp3, jmp4, jmp5;
int ckUniq = sqlite3VdbeMakeLabel(v); int ckUniq = sqlite3VdbeMakeLabel(pParse);
if( pPk==pIdx ) continue; if( pPk==pIdx ) continue;
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3, r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
pPrior, r1); pPrior, r1);
@@ -1641,7 +1641,7 @@ void sqlite3Pragma(
** current key. The entry is unique if (1) any column is NULL ** current key. The entry is unique if (1) any column is NULL
** or (2) the next entry has a different key */ ** or (2) the next entry has a different key */
if( IsUniqueIndex(pIdx) ){ if( IsUniqueIndex(pIdx) ){
int uniqOk = sqlite3VdbeMakeLabel(v); int uniqOk = sqlite3VdbeMakeLabel(pParse);
int jmp6; int jmp6;
int kk; int kk;
for(kk=0; kk<pIdx->nKeyCol; kk++){ for(kk=0; kk<pIdx->nKeyCol; kk++){

View File

@@ -631,7 +631,7 @@ static void pushOntoSorter(
} }
assert( pSelect->iOffset==0 || pSelect->iLimit!=0 ); assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );
iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit; iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;
pSort->labelDone = sqlite3VdbeMakeLabel(v); pSort->labelDone = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData, sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,
SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0)); SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0));
if( bSeq ){ if( bSeq ){
@@ -670,7 +670,7 @@ static void pushOntoSorter(
pKI->nAllField-pKI->nKeyField-1); pKI->nAllField-pKI->nKeyField-1);
addrJmp = sqlite3VdbeCurrentAddr(v); addrJmp = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
pSort->labelBkOut = sqlite3VdbeMakeLabel(v); pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse);
pSort->regReturn = ++pParse->nMem; pSort->regReturn = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut); sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor); sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor);
@@ -1417,7 +1417,7 @@ static void generateSortTail(
){ ){
Vdbe *v = pParse->pVdbe; /* The prepared statement */ Vdbe *v = pParse->pVdbe; /* The prepared statement */
int addrBreak = pSort->labelDone; /* Jump here to exit loop */ int addrBreak = pSort->labelDone; /* Jump here to exit loop */
int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */ int addrContinue = sqlite3VdbeMakeLabel(pParse);/* Jump here for next cycle */
int addr; /* Top of output loop. Jump for Next. */ int addr; /* Top of output loop. Jump for Next. */
int addrOnce = 0; int addrOnce = 0;
int iTab; int iTab;
@@ -2329,7 +2329,7 @@ static void generateWithRecursiveQuery(
if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return; if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
/* Process the LIMIT and OFFSET clauses, if they exist */ /* Process the LIMIT and OFFSET clauses, if they exist */
addrBreak = sqlite3VdbeMakeLabel(v); addrBreak = sqlite3VdbeMakeLabel(pParse);
p->nSelectRow = 320; /* 4 billion rows */ p->nSelectRow = 320; /* 4 billion rows */
computeLimitRegisters(pParse, p, addrBreak); computeLimitRegisters(pParse, p, addrBreak);
pLimit = p->pLimit; pLimit = p->pLimit;
@@ -2399,7 +2399,7 @@ static void generateWithRecursiveQuery(
sqlite3VdbeAddOp1(v, OP_Delete, iQueue); sqlite3VdbeAddOp1(v, OP_Delete, iQueue);
/* Output the single row in Current */ /* Output the single row in Current */
addrCont = sqlite3VdbeMakeLabel(v); addrCont = sqlite3VdbeMakeLabel(pParse);
codeOffset(v, regOffset, addrCont); codeOffset(v, regOffset, addrCont);
selectInnerLoop(pParse, p, iCurrent, selectInnerLoop(pParse, p, iCurrent,
0, 0, pDest, addrCont, addrBreak); 0, 0, pDest, addrCont, addrBreak);
@@ -2707,8 +2707,8 @@ static int multiSelect(
if( dest.eDest!=priorOp ){ if( dest.eDest!=priorOp ){
int iCont, iBreak, iStart; int iCont, iBreak, iStart;
assert( p->pEList ); assert( p->pEList );
iBreak = sqlite3VdbeMakeLabel(v); iBreak = sqlite3VdbeMakeLabel(pParse);
iCont = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak); computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
iStart = sqlite3VdbeCurrentAddr(v); iStart = sqlite3VdbeCurrentAddr(v);
@@ -2776,8 +2776,8 @@ static int multiSelect(
** tables. ** tables.
*/ */
assert( p->pEList ); assert( p->pEList );
iBreak = sqlite3VdbeMakeLabel(v); iBreak = sqlite3VdbeMakeLabel(pParse);
iCont = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak); computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
r1 = sqlite3GetTempReg(pParse); r1 = sqlite3GetTempReg(pParse);
@@ -2907,7 +2907,7 @@ static int generateOutputSubroutine(
int addr; int addr;
addr = sqlite3VdbeCurrentAddr(v); addr = sqlite3VdbeCurrentAddr(v);
iContinue = sqlite3VdbeMakeLabel(v); iContinue = sqlite3VdbeMakeLabel(pParse);
/* Suppress duplicates for UNION, EXCEPT, and INTERSECT /* Suppress duplicates for UNION, EXCEPT, and INTERSECT
*/ */
@@ -3144,8 +3144,8 @@ static int multiSelectOrderBy(
db = pParse->db; db = pParse->db;
v = pParse->pVdbe; v = pParse->pVdbe;
assert( v!=0 ); /* Already thrown the error if VDBE alloc failed */ assert( v!=0 ); /* Already thrown the error if VDBE alloc failed */
labelEnd = sqlite3VdbeMakeLabel(v); labelEnd = sqlite3VdbeMakeLabel(pParse);
labelCmpr = sqlite3VdbeMakeLabel(v); labelCmpr = sqlite3VdbeMakeLabel(pParse);
/* Patch up the ORDER BY clause /* Patch up the ORDER BY clause
@@ -5330,7 +5330,7 @@ static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){
regAgg = 0; regAgg = 0;
} }
if( pF->iDistinct>=0 ){ if( pF->iDistinct>=0 ){
addrNext = sqlite3VdbeMakeLabel(v); addrNext = sqlite3VdbeMakeLabel(pParse);
testcase( nArg==0 ); /* Error condition */ testcase( nArg==0 ); /* Error condition */
testcase( nArg>1 ); /* Also an error */ testcase( nArg>1 ); /* Also an error */
codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg); codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
@@ -6038,7 +6038,7 @@ int sqlite3Select(
/* Set the limiter. /* Set the limiter.
*/ */
iEnd = sqlite3VdbeMakeLabel(v); iEnd = sqlite3VdbeMakeLabel(pParse);
if( (p->selFlags & SF_FixedLimit)==0 ){ if( (p->selFlags & SF_FixedLimit)==0 ){
p->nSelectRow = 320; /* 4 billion rows */ p->nSelectRow = 320; /* 4 billion rows */
} }
@@ -6105,9 +6105,9 @@ int sqlite3Select(
assert( p->pEList==pEList ); assert( p->pEList==pEList );
#ifndef SQLITE_OMIT_WINDOWFUNC #ifndef SQLITE_OMIT_WINDOWFUNC
if( pWin ){ if( pWin ){
int addrGosub = sqlite3VdbeMakeLabel(v); int addrGosub = sqlite3VdbeMakeLabel(pParse);
int iCont = sqlite3VdbeMakeLabel(v); int iCont = sqlite3VdbeMakeLabel(pParse);
int iBreak = sqlite3VdbeMakeLabel(v); int iBreak = sqlite3VdbeMakeLabel(pParse);
int regGosub = ++pParse->nMem; int regGosub = ++pParse->nMem;
sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub); sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
@@ -6182,7 +6182,7 @@ int sqlite3Select(
} }
/* Create a label to jump to when we want to abort the query */ /* Create a label to jump to when we want to abort the query */
addrEnd = sqlite3VdbeMakeLabel(v); addrEnd = sqlite3VdbeMakeLabel(pParse);
/* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in
** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the
@@ -6271,9 +6271,9 @@ int sqlite3Select(
iUseFlag = ++pParse->nMem; iUseFlag = ++pParse->nMem;
iAbortFlag = ++pParse->nMem; iAbortFlag = ++pParse->nMem;
regOutputRow = ++pParse->nMem; regOutputRow = ++pParse->nMem;
addrOutputRow = sqlite3VdbeMakeLabel(v); addrOutputRow = sqlite3VdbeMakeLabel(pParse);
regReset = ++pParse->nMem; regReset = ++pParse->nMem;
addrReset = sqlite3VdbeMakeLabel(v); addrReset = sqlite3VdbeMakeLabel(pParse);
iAMem = pParse->nMem + 1; iAMem = pParse->nMem + 1;
pParse->nMem += pGroupBy->nExpr; pParse->nMem += pGroupBy->nExpr;
iBMem = pParse->nMem + 1; iBMem = pParse->nMem + 1;

View File

@@ -3069,6 +3069,7 @@ struct Parse {
int iSelfTab; /* Table associated with an index on expr, or negative int iSelfTab; /* Table associated with an index on expr, or negative
** of the base register during check-constraint eval */ ** of the base register during check-constraint eval */
int nLabel; /* Number of labels used */ int nLabel; /* Number of labels used */
int nLabelAlloc; /* Number of slots in aLabel */
int *aLabel; /* Space to hold the labels */ int *aLabel; /* Space to hold the labels */
ExprList *pConstExpr;/* Constant expressions */ ExprList *pConstExpr;/* Constant expressions */
Token constraintName;/* Name of the constraint currently being parsed */ Token constraintName;/* Name of the constraint currently being parsed */

View File

@@ -944,7 +944,7 @@ static TriggerPrg *codeRowTrigger(
if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
&& db->mallocFailed==0 && db->mallocFailed==0
){ ){
iEndTrigger = sqlite3VdbeMakeLabel(v); iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);
sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
} }
sqlite3ExprDelete(db, pWhen); sqlite3ExprDelete(db, pWhen);

View File

@@ -441,7 +441,7 @@ void sqlite3Update(
#endif #endif
/* Jump to labelBreak to abandon further processing of this UPDATE */ /* Jump to labelBreak to abandon further processing of this UPDATE */
labelContinue = labelBreak = sqlite3VdbeMakeLabel(v); labelContinue = labelBreak = sqlite3VdbeMakeLabel(pParse);
/* Not an UPSERT. Normal processing. Begin by /* Not an UPSERT. Normal processing. Begin by
** initialize the count of updated rows */ ** initialize the count of updated rows */
@@ -576,13 +576,13 @@ void sqlite3Update(
VdbeCoverage(v); VdbeCoverage(v);
} }
if( eOnePass!=ONEPASS_SINGLE ){ if( eOnePass!=ONEPASS_SINGLE ){
labelContinue = sqlite3VdbeMakeLabel(v); labelContinue = sqlite3VdbeMakeLabel(pParse);
} }
sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak); sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
VdbeCoverageIf(v, pPk==0); VdbeCoverageIf(v, pPk==0);
VdbeCoverageIf(v, pPk!=0); VdbeCoverageIf(v, pPk!=0);
}else if( pPk ){ }else if( pPk ){
labelContinue = sqlite3VdbeMakeLabel(v); labelContinue = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey); addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0); sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);

View File

@@ -230,7 +230,7 @@ void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);
void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
void sqlite3VdbeUsesBtree(Vdbe*, int); void sqlite3VdbeUsesBtree(Vdbe*, int);
VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
int sqlite3VdbeMakeLabel(Vdbe*); int sqlite3VdbeMakeLabel(Parse*);
void sqlite3VdbeRunOnlyOnce(Vdbe*); void sqlite3VdbeRunOnlyOnce(Vdbe*);
void sqlite3VdbeReusable(Vdbe*); void sqlite3VdbeReusable(Vdbe*);
void sqlite3VdbeDelete(Vdbe*); void sqlite3VdbeDelete(Vdbe*);

View File

@@ -448,18 +448,8 @@ void sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){
** **
** Zero is returned if a malloc() fails. ** Zero is returned if a malloc() fails.
*/ */
int sqlite3VdbeMakeLabel(Vdbe *v){ int sqlite3VdbeMakeLabel(Parse *pParse){
Parse *p = v->pParse; return ADDR(pParse->nLabel++);
int i = p->nLabel++;
assert( v->magic==VDBE_MAGIC_INIT );
if( (i & (i-1))==0 ){
p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel,
(i*2+1)*sizeof(p->aLabel[0]));
}
if( p->aLabel ){
p->aLabel[i] = -1;
}
return ADDR(i);
} }
/* /*
@@ -467,18 +457,35 @@ int sqlite3VdbeMakeLabel(Vdbe *v){
** be inserted. The parameter "x" must have been obtained from ** be inserted. The parameter "x" must have been obtained from
** a prior call to sqlite3VdbeMakeLabel(). ** a prior call to sqlite3VdbeMakeLabel().
*/ */
static SQLITE_NOINLINE void resizeResolveLabel(Parse *p, Vdbe *v, int j){
int nNewSize = p->nLabel+10;
p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel,
nNewSize*sizeof(p->aLabel[0]));
if( p->aLabel==0 ){
p->nLabelAlloc = 0;
}else{
#ifdef SQLITE_DEBUG
int i;
for(i=p->nLabelAlloc; i<nNewSize; i++) p->aLabel[i] = -1;
#endif
p->nLabelAlloc = nNewSize;
p->aLabel[j] = v->nOp;
}
}
void sqlite3VdbeResolveLabel(Vdbe *v, int x){ void sqlite3VdbeResolveLabel(Vdbe *v, int x){
Parse *p = v->pParse; Parse *p = v->pParse;
int j = ADDR(x); int j = ADDR(x);
assert( v->magic==VDBE_MAGIC_INIT ); assert( v->magic==VDBE_MAGIC_INIT );
assert( j<p->nLabel ); assert( j<p->nLabel );
assert( j>=0 ); assert( j>=0 );
if( p->aLabel ){
#ifdef SQLITE_DEBUG #ifdef SQLITE_DEBUG
if( p->db->flags & SQLITE_VdbeAddopTrace ){ if( p->db->flags & SQLITE_VdbeAddopTrace ){
printf("RESOLVE LABEL %d to %d\n", x, v->nOp); printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
} }
#endif #endif
if( p->nLabelAlloc < p->nLabel ){
resizeResolveLabel(p,v,j);
}else{
assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */ assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
p->aLabel[j] = v->nOp; p->aLabel[j] = v->nOp;
} }

View File

@@ -837,7 +837,7 @@ static void constructAutomaticIndex(
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v); addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
} }
if( pPartial ){ if( pPartial ){
iContinue = sqlite3VdbeMakeLabel(v); iContinue = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL); sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
pLoop->wsFlags |= WHERE_PARTIALIDX; pLoop->wsFlags |= WHERE_PARTIALIDX;
} }
@@ -4643,7 +4643,7 @@ WhereInfo *sqlite3WhereBegin(
pWInfo->pResultSet = pResultSet; pWInfo->pResultSet = pResultSet;
pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
pWInfo->nLevel = nTabList; pWInfo->nLevel = nTabList;
pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v); pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(pParse);
pWInfo->wctrlFlags = wctrlFlags; pWInfo->wctrlFlags = wctrlFlags;
pWInfo->iLimit = iAuxArg; pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop; pWInfo->savedNQueryLoop = pParse->nQueryLoop;

View File

@@ -565,7 +565,7 @@ static int codeEqualityTerm(
pLoop->wsFlags |= WHERE_IN_ABLE; pLoop->wsFlags |= WHERE_IN_ABLE;
if( pLevel->u.in.nIn==0 ){ if( pLevel->u.in.nIn==0 ){
pLevel->addrNxt = sqlite3VdbeMakeLabel(v); pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
} }
i = pLevel->u.in.nIn; i = pLevel->u.in.nIn;
@@ -1213,8 +1213,8 @@ Bitmask sqlite3WhereCodeOneLoopStart(
** there are no IN operators in the constraints, the "addrNxt" label ** there are no IN operators in the constraints, the "addrNxt" label
** is the same as "addrBrk". ** is the same as "addrBrk".
*/ */
addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v); addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v); addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);
/* If this is the right table of a LEFT OUTER JOIN, allocate and /* If this is the right table of a LEFT OUTER JOIN, allocate and
** initialize a memory cell that records if this table matches any ** initialize a memory cell that records if this table matches any
@@ -1835,7 +1835,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */ int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */
int regRowset = 0; /* Register for RowSet object */ int regRowset = 0; /* Register for RowSet object */
int regRowid = 0; /* Register holding rowid */ int regRowid = 0; /* Register holding rowid */
int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */ int iLoopBody = sqlite3VdbeMakeLabel(pParse);/* Start of loop body */
int iRetInit; /* Address of regReturn init */ int iRetInit; /* Address of regReturn init */
int untestedTerms = 0; /* Some terms not completely tested */ int untestedTerms = 0; /* Some terms not completely tested */
int ii; /* Loop counter */ int ii; /* Loop counter */

View File

@@ -1330,7 +1330,7 @@ static void windowReturnOneRow(
|| pFunc->zName==first_valueName || pFunc->zName==first_valueName
){ ){
int csr = pWin->csrApp; int csr = pWin->csrApp;
int lbl = sqlite3VdbeMakeLabel(v); int lbl = sqlite3VdbeMakeLabel(pParse);
int tmpReg = sqlite3GetTempReg(pParse); int tmpReg = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult); sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
@@ -1353,7 +1353,7 @@ static void windowReturnOneRow(
int nArg = pWin->pOwner->x.pList->nExpr; int nArg = pWin->pOwner->x.pList->nExpr;
int iEph = pMWin->iEphCsr; int iEph = pMWin->iEphCsr;
int csr = pWin->csrApp; int csr = pWin->csrApp;
int lbl = sqlite3VdbeMakeLabel(v); int lbl = sqlite3VdbeMakeLabel(pParse);
int tmpReg = sqlite3GetTempReg(pParse); int tmpReg = sqlite3GetTempReg(pParse);
if( nArg<3 ){ if( nArg<3 ){
@@ -1614,8 +1614,8 @@ static void windowCodeRowExprStep(
/* Allocate register and label for the "flush_partition" sub-routine. */ /* Allocate register and label for the "flush_partition" sub-routine. */
regFlushPart = ++pParse->nMem; regFlushPart = ++pParse->nMem;
lblFlushPart = sqlite3VdbeMakeLabel(v); lblFlushPart = sqlite3VdbeMakeLabel(pParse);
lblFlushDone = sqlite3VdbeMakeLabel(v); lblFlushDone = sqlite3VdbeMakeLabel(pParse);
regStart = ++pParse->nMem; regStart = ++pParse->nMem;
regEnd = ++pParse->nMem; regEnd = ++pParse->nMem;
@@ -1725,7 +1725,7 @@ static void windowCodeRowExprStep(
|| pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_PRECEDING
|| pMWin->eStart==TK_FOLLOWING || pMWin->eStart==TK_FOLLOWING
){ ){
int lblSkipInverse = sqlite3VdbeMakeLabel(v);; int lblSkipInverse = sqlite3VdbeMakeLabel(pParse);;
if( pMWin->eStart==TK_PRECEDING ){ if( pMWin->eStart==TK_PRECEDING ){
sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1); sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
VdbeCoverage(v); VdbeCoverage(v);
@@ -1890,13 +1890,13 @@ static void windowCodeCacheStep(
|| (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED) || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
); );
lblEmpty = sqlite3VdbeMakeLabel(v); lblEmpty = sqlite3VdbeMakeLabel(pParse);
regNewPeer = pParse->nMem+1; regNewPeer = pParse->nMem+1;
pParse->nMem += nPeer; pParse->nMem += nPeer;
/* Allocate register and label for the "flush_partition" sub-routine. */ /* Allocate register and label for the "flush_partition" sub-routine. */
regFlushPart = ++pParse->nMem; regFlushPart = ++pParse->nMem;
lblFlushPart = sqlite3VdbeMakeLabel(v); lblFlushPart = sqlite3VdbeMakeLabel(pParse);
csrLead = pParse->nTab++; csrLead = pParse->nTab++;
regCtr = ++pParse->nMem; regCtr = ++pParse->nMem;