mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Refactor the name resolution procedures in the code generator. (CVS 5569)
FossilOrigin-Name: daf730d1defa78fb8b80a78f9108ac35a13e09f6
This commit is contained in:
13
Makefile.in
13
Makefile.in
@ -163,10 +163,11 @@ OBJS0 = alter.lo analyze.lo attach.lo auth.lo bitvec.lo btmutex.lo \
|
||||
mutex.lo mutex_os2.lo mutex_unix.lo mutex_w32.lo \
|
||||
opcodes.lo os.lo os_unix.lo os_win.lo os_os2.lo \
|
||||
pager.lo parse.lo pcache.lo pragma.lo prepare.lo printf.lo random.lo \
|
||||
select.lo status.lo table.lo tokenize.lo trigger.lo update.lo \
|
||||
resolve.lo select.lo status.lo \
|
||||
table.lo tokenize.lo trigger.lo update.lo \
|
||||
util.lo vacuum.lo \
|
||||
vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbefifo.lo vdbemem.lo \
|
||||
where.lo utf.lo legacy.lo vtab.lo
|
||||
walker.lo where.lo utf.lo vtab.lo
|
||||
|
||||
# Object files for the amalgamation.
|
||||
#
|
||||
@ -233,6 +234,7 @@ SRC = \
|
||||
$(TOP)/src/prepare.c \
|
||||
$(TOP)/src/printf.c \
|
||||
$(TOP)/src/random.c \
|
||||
$(TOP)/src/resolve.c \
|
||||
$(TOP)/src/select.c \
|
||||
$(TOP)/src/status.c \
|
||||
$(TOP)/src/shell.c \
|
||||
@ -257,6 +259,7 @@ SRC = \
|
||||
$(TOP)/src/vdbemem.c \
|
||||
$(TOP)/src/vdbeInt.h \
|
||||
$(TOP)/src/vtab.c \
|
||||
$(TOP)/src/walker.c \
|
||||
$(TOP)/src/where.c
|
||||
|
||||
# Generated source code files
|
||||
@ -630,6 +633,9 @@ printf.lo: $(TOP)/src/printf.c $(HDR)
|
||||
random.lo: $(TOP)/src/random.c $(HDR)
|
||||
$(LTCOMPILE) -c $(TOP)/src/random.c
|
||||
|
||||
resolve.lo: $(TOP)/src/resolve.c $(HDR)
|
||||
$(LTCOMPILE) -c $(TOP)/src/resolve.c
|
||||
|
||||
select.lo: $(TOP)/src/select.c $(HDR)
|
||||
$(LTCOMPILE) -c $(TOP)/src/select.c
|
||||
|
||||
@ -689,6 +695,9 @@ vdbemem.lo: $(TOP)/src/vdbemem.c $(HDR)
|
||||
vtab.lo: $(TOP)/src/vtab.c $(HDR)
|
||||
$(LTCOMPILE) -c $(TOP)/src/vtab.c
|
||||
|
||||
walker.lo: $(TOP)/src/walker.c $(HDR)
|
||||
$(LTCOMPILE) -c $(TOP)/src/walker.c
|
||||
|
||||
where.lo: $(TOP)/src/where.c $(HDR)
|
||||
$(LTCOMPILE) -c $(TOP)/src/where.c
|
||||
|
||||
|
@ -14,18 +14,18 @@ BEGIN {
|
||||
if( max<$3 ) max = $3
|
||||
}
|
||||
END {
|
||||
printf "#define TK_%-29s %4d\n", "TO_TEXT", max+1
|
||||
printf "#define TK_%-29s %4d\n", "TO_BLOB", max+2
|
||||
printf "#define TK_%-29s %4d\n", "TO_NUMERIC", max+3
|
||||
printf "#define TK_%-29s %4d\n", "TO_INT", max+4
|
||||
printf "#define TK_%-29s %4d\n", "TO_REAL", max+5
|
||||
printf "#define TK_%-29s %4d\n", "END_OF_FILE", max+6
|
||||
printf "#define TK_%-29s %4d\n", "ILLEGAL", max+7
|
||||
printf "#define TK_%-29s %4d\n", "SPACE", max+8
|
||||
printf "#define TK_%-29s %4d\n", "UNCLOSED_STRING", max+9
|
||||
printf "#define TK_%-29s %4d\n", "FUNCTION", max+10
|
||||
printf "#define TK_%-29s %4d\n", "COLUMN", max+11
|
||||
printf "#define TK_%-29s %4d\n", "AGG_FUNCTION", max+12
|
||||
printf "#define TK_%-29s %4d\n", "AGG_COLUMN", max+13
|
||||
printf "#define TK_%-29s %4d\n", "CONST_FUNC", max+14
|
||||
printf "#define TK_%-29s %4d\n", "TO_TEXT", ++max
|
||||
printf "#define TK_%-29s %4d\n", "TO_BLOB", ++max
|
||||
printf "#define TK_%-29s %4d\n", "TO_NUMERIC", ++max
|
||||
printf "#define TK_%-29s %4d\n", "TO_INT", ++max
|
||||
printf "#define TK_%-29s %4d\n", "TO_REAL", ++max
|
||||
printf "#define TK_%-29s %4d\n", "END_OF_FILE", ++max
|
||||
printf "#define TK_%-29s %4d\n", "ILLEGAL", ++max
|
||||
printf "#define TK_%-29s %4d\n", "SPACE", ++max
|
||||
printf "#define TK_%-29s %4d\n", "UNCLOSED_STRING", ++max
|
||||
printf "#define TK_%-29s %4d\n", "FUNCTION", ++max
|
||||
printf "#define TK_%-29s %4d\n", "COLUMN", ++max
|
||||
printf "#define TK_%-29s %4d\n", "AGG_FUNCTION", ++max
|
||||
printf "#define TK_%-29s %4d\n", "AGG_COLUMN", ++max
|
||||
printf "#define TK_%-29s %4d\n", "CONST_FUNC", ++max
|
||||
}
|
||||
|
35
main.mk
35
main.mk
@ -48,36 +48,21 @@ TCCX = $(TCC) $(OPTS) -I. -I$(TOP)/src -I$(TOP) -I$(TOP)/ext/rtree
|
||||
|
||||
# Object files for the SQLite library.
|
||||
#
|
||||
LIBOBJ+= alter.o analyze.o attach.o auth.o bitvec.o btmutex.o btree.o build.o \
|
||||
LIBOBJ+= alter.o analyze.o attach.o auth.o \
|
||||
bitvec.o btmutex.o btree.o build.o \
|
||||
callback.o complete.o date.o delete.o \
|
||||
expr.o fault.o func2.o global.o hash.o insert.o journal.o loadext.o \
|
||||
expr.o fault.o func2.o global.o hash.o \
|
||||
icu.o insert.o journal.o legacy.o loadext.o \
|
||||
main.o malloc.o mem1.o mem2.o mem3.o mem4.o mem5.o mem6.o \
|
||||
mutex.o mutex_os2.o mutex_unix.o mutex_w32.o \
|
||||
opcodes.o os.o os_os2.o os_unix.o os_win.o \
|
||||
pager.o parse.o pragma.o prepare.o printf.o random.o \
|
||||
select.o status.o table.o $(TCLOBJ) tokenize.o trigger.o \
|
||||
pager.o parse.o pcache.o pragma.o prepare.o printf.o \
|
||||
random.o resolve.o rtree.o select.o status.o \
|
||||
table.o tokenize.o trigger.o \
|
||||
update.o util.o vacuum.o \
|
||||
vdbe.o vdbeapi.o vdbeaux.o vdbeblob.o vdbefifo.o vdbemem.o \
|
||||
where.o utf.o legacy.o vtab.o rtree.o icu.o pcache.o
|
||||
walker.o where.o utf.o vtab.o
|
||||
|
||||
EXTOBJ = icu.o
|
||||
EXTOBJ += fts1.o \
|
||||
fts1_hash.o \
|
||||
fts1_tokenizer1.o \
|
||||
fts1_porter.o
|
||||
EXTOBJ += fts2.o \
|
||||
fts2_hash.o \
|
||||
fts2_icu.o \
|
||||
fts2_porter.o \
|
||||
fts2_tokenizer.o \
|
||||
fts2_tokenizer1.o
|
||||
EXTOBJ += fts3.o \
|
||||
fts3_hash.o \
|
||||
fts3_icu.o \
|
||||
fts3_porter.o \
|
||||
fts3_tokenizer.o \
|
||||
fts3_tokenizer1.o
|
||||
EXTOBJ += rtree.o
|
||||
|
||||
# All of the source code files.
|
||||
#
|
||||
@ -128,10 +113,13 @@ SRC = \
|
||||
$(TOP)/src/pager.c \
|
||||
$(TOP)/src/pager.h \
|
||||
$(TOP)/src/parse.y \
|
||||
$(TOP)/src/pcache.c \
|
||||
$(TOP)/src/pcache.h \
|
||||
$(TOP)/src/pragma.c \
|
||||
$(TOP)/src/prepare.c \
|
||||
$(TOP)/src/printf.c \
|
||||
$(TOP)/src/random.c \
|
||||
$(TOP)/src/resolve.c \
|
||||
$(TOP)/src/select.c \
|
||||
$(TOP)/src/status.c \
|
||||
$(TOP)/src/shell.c \
|
||||
@ -157,6 +145,7 @@ SRC = \
|
||||
$(TOP)/src/pcache.c \
|
||||
$(TOP)/src/vdbeInt.h \
|
||||
$(TOP)/src/vtab.c \
|
||||
$(TOP)/src/walker.c \
|
||||
$(TOP)/src/where.c
|
||||
|
||||
# Source code for extensions
|
||||
|
64
manifest
64
manifest
@ -1,12 +1,12 @@
|
||||
C When\sa\s"pragma\smain.table_info(...)"\sis\sissued,\sconsider\sonly\stables\sfrom\sthe\smain\sdatabase,\snot\sthe\stemp\sdb.\sTicket\s#3320.\s(CVS\s5568)
|
||||
D 2008-08-20T16:34:24
|
||||
C Refactor\sthe\sname\sresolution\sprocedures\sin\sthe\scode\sgenerator.\s(CVS\s5569)
|
||||
D 2008-08-20T16:35:10
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in e277c1f6dee97c18ef2f64db608da63eea4cc933
|
||||
F Makefile.in 6682017e315b9c518b5c49dbe8bd19164146abe6
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
F README b974cdc3f9f12b87e851b04e75996d720ebf81ac
|
||||
F VERSION 1d5b2c9192236ed2c6bad659a7c2d1662e39e7b9
|
||||
F aclocal.m4 7d02b11fed45174e11156144227278deb6236eea
|
||||
F addopcodes.awk 48a2ffae0a6fb191ae9e42e69a90b15d973e0339
|
||||
F addopcodes.awk 215333be9d99c260e076c3080a81dba3ae928c45
|
||||
F art/2005osaward.gif 0d1851b2a7c1c9d0ccce545f3e14bca42d7fd248
|
||||
F art/SQLite.eps 9b43cc99cfd2be687d386faea6862ea68d6a72b2
|
||||
F art/SQLite.gif 1bbb94484963f1382e27e1c5e86dd0c1061eba2b
|
||||
@ -76,7 +76,7 @@ F ext/rtree/rtree_util.tcl ee0a0311eb12175319d78bfb37302320496cee6e
|
||||
F ext/rtree/viewrtree.tcl 09526398dae87a5a87c5aac2b3854dbaf8376869
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
||||
F ltmain.sh 09fe5815427dc7d0abb188bbcdf0e34896577210
|
||||
F main.mk ec8a5d47c4cb447dc666472528a7e8da91384a57
|
||||
F main.mk 4bb354f1e952a13ee8a02b42837b37c4b198d9a7
|
||||
F mkdll.sh 79d1ed6ae221c10589dd969f130f8a3cccfffbb7
|
||||
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
|
||||
F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac
|
||||
@ -92,30 +92,30 @@ F sqlite3.def a1be7b9a4b8b51ac41c6ff6e8e44a14ef66b338b
|
||||
F sqlite3.pc.in 32b8a014799c2028c8e0c9cc5659718262fc493f
|
||||
F src/alter.c f462b637bac6c6576a9b7bc6da59c7a82ed5aab2
|
||||
F src/analyze.c 747ce8cb6b318bb0d0576cfb5277aed98cbbeb5c
|
||||
F src/attach.c a85c14612e7e3410e0c3d2e0241832fa9688bd14
|
||||
F src/attach.c db3f4a60538733c1e4dcb9d0217a6e0d6ccd615b
|
||||
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
||||
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
||||
F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
|
||||
F src/btree.c c536edea3dd8a9f5f56101ca66cd5dfe699a5d7b
|
||||
F src/btree.h 6371c5e599fab391a150c96afbc10062b276d107
|
||||
F src/btreeInt.h ab18c7b4980314e9e4b402e5dcde09f3c2545576
|
||||
F src/build.c 931ed94fd3bbd67b6ac9d5ac6a45dc01e9f01726
|
||||
F src/build.c 160c71acca8f643f436ed6c1ee2f684c88df4dfe
|
||||
F src/callback.c 1b1a5c580cdf7d83db24001bf8e5c09e2b08658f
|
||||
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
||||
F src/date.c 52a54811218a76da6235420f532ece841159a96d
|
||||
F src/delete.c 0d115c173863b3c688c3083ef7857c7f2e9f7a18
|
||||
F src/expr.c 278d3950f55e04a2486e7b8dede3713a2ed6c0e1
|
||||
F src/delete.c 5105c67c741f934379722de5e11fdd73ea4d82b5
|
||||
F src/expr.c 4651d08422474f7e4bcb9a35da00c33ebe719a2d
|
||||
F src/fault.c 3638519d1e0b82bccfafcb9f5ff491918b28f8e1
|
||||
F src/func.c d97ff7b72f3ddcd88970048e2894954a3f5b01d8
|
||||
F src/global.c b9c96ee2317a6e1391763c7db1098a6473a91863
|
||||
F src/hash.c eb64e48f3781100e5934f759fbe72a63a8fe78cb
|
||||
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
|
||||
F src/hwtime.h 4a1d45f4cae1f402ea19686acf24acf4f0cb53cb
|
||||
F src/insert.c 89cd9af52a5ea6fb7d0cfc9c3b935d6406c360c4
|
||||
F src/insert.c 110cca7845ed5a66c08fdd413b02e706ae34455f
|
||||
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
|
||||
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
|
||||
F src/loadext.c eb1fe4f44d7c8ff53fc0c6a4388ab79fbd34cd64
|
||||
F src/main.c 64df39151a77bf521cee8ef54efc3c71328d8bb4
|
||||
F src/main.c aaf5af6ffe2c05f8ea4d75a850581a68ac529fa0
|
||||
F src/malloc.c 56918cddc4da7a0590eef4a2497e97b781f5c25f
|
||||
F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
|
||||
F src/mem1.c 3a7fe31d8290baa3bb203af72f7dfd6323966bcd
|
||||
@ -137,18 +137,19 @@ F src/os_unix.c fe0dbc35bcd3de49e46b132abfc0f45d6dd6a864
|
||||
F src/os_win.c aefe9ee26430678a19a058a874e4e2bd91398142
|
||||
F src/pager.c 9f813a8f26680ff510335e2bbd01910b2a77277b
|
||||
F src/pager.h fb9376af5ba8e1eb78ee3b4f15eb0f60658ffd65
|
||||
F src/parse.y 84003422b2862f82bd187dfa2399557fd1f4ecbe
|
||||
F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
|
||||
F src/pcache.c c1a9abb5e2aa3d1d52a2995c8e0a36535d4d1bc2
|
||||
F src/pcache.h 71ade7a84ed87d9d20507315260b1d91808d7c9a
|
||||
F src/pragma.c f5b271b090af7fcedd308d7c5807a5503f7a853d
|
||||
F src/prepare.c fceb567b359daaa6c6e2a4d04a01dec01ac0c907
|
||||
F src/prepare.c c197041e0c4770672cda75e6bfe10242f885e510
|
||||
F src/printf.c 2e984b2507291a7e16d89dc9bb60582904f6247d
|
||||
F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a
|
||||
F src/select.c defdb8cdf7d2d8e1e0df117e50af6378fdaf1329
|
||||
F src/resolve.c e688f240bdacf4003047c2b023c3a4ee3a3eca98
|
||||
F src/select.c 0a0ed2d14bfa216c1584fa8516e8820115b1047b
|
||||
F src/shell.c d83b578a8ccdd3e0e7fef4388a0887ce9f810967
|
||||
F src/sqlite.h.in 54e51c22e2294c5989156b0aec87aa44168ac1f0
|
||||
F src/sqlite3ext.h 1e3887c9bd3ae66cb599e922824b04cd0d0f2c3e
|
||||
F src/sqliteInt.h e49782bc45092732795297d83331b1855eb234b3
|
||||
F src/sqliteInt.h d1ddf30df8d7eb3e15e7d70ebe347e0c17255165
|
||||
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
|
||||
F src/status.c 8caa772cd9310bc297280f7cf0ede4d69ed5b801
|
||||
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
|
||||
@ -180,8 +181,8 @@ F src/test_server.c f0a403b5f699c09bd2b1236b6f69830fd6221f6b
|
||||
F src/test_tclvar.c 9e42fa59d3d2f064b7ab8628e7ab2dc8a9fe93d4
|
||||
F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
|
||||
F src/tokenize.c d16ca0e9944161c76d2e4c11dc379ec88189b93b
|
||||
F src/trigger.c b61aaf7bff8e3763b234dbf46a1a64fb88a34e64
|
||||
F src/update.c 79b77a3cc8ed5f8903a7f37055fcedd69388dcae
|
||||
F src/trigger.c 649940b5bf5838a33721fb72372e7c9d1faf56a9
|
||||
F src/update.c 9e3786e76825bd7fa22528556cc1c467cd428075
|
||||
F src/utf.c c63e6f69082f85c19ab88d62dedaf91d71ac1a50
|
||||
F src/util.c afe659ccc05d1f8af9e8631dabfec3ee3a7144af
|
||||
F src/vacuum.c ef342828002debc97514617af3424aea8ef8522c
|
||||
@ -189,12 +190,13 @@ F src/vdbe.c e2dd0c78c5579e23db49ed8265f0b44d7b22c51d
|
||||
F src/vdbe.h 17bcc2b41082f9b99718b3757cbf97145a72023a
|
||||
F src/vdbeInt.h b48c74d86a9fb62b707a3186ccca76bb32f1c6be
|
||||
F src/vdbeapi.c f21971516880fd3a10821b2cdd0e64a5a63952c9
|
||||
F src/vdbeaux.c 3e2e1f36c25eae32bdd605456c8be99f73e71eaf
|
||||
F src/vdbeaux.c ba13cc1e663d3dd12a720d108eac14d792ad7680
|
||||
F src/vdbeblob.c f93110888ddc246215e9ba1f831d3d375bfd8355
|
||||
F src/vdbefifo.c 20fda2a7c4c0bcee1b90eb7e545fefcdbf2e1de7
|
||||
F src/vdbemem.c c37b2a266a49eaf0c0f5080157f9f1a908fdaac3
|
||||
F src/vtab.c edf8edb55dc93ec4bfe8b3f10213cf6c025edb9c
|
||||
F src/where.c a800184a2d023b15d6f2758b7a6c7ab011258fee
|
||||
F src/vtab.c 527c180e9c5fca417c9167d02af4b5039f892b4b
|
||||
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
|
||||
F src/where.c b156f2785538ed1783dbdd1f714d00ba21c1d5b1
|
||||
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
F test/all.test 89e09ed0074083ac6f208dc3243429e8f89efb69
|
||||
@ -234,8 +236,8 @@ F test/capi3d.test 57d83b690d7364bde02cddbf8339a4b50d80ce23
|
||||
F test/cast.test ce8f14fc80f70b30ed984480cc0d8914a459e8f9
|
||||
F test/check.test 024ed399600b799160378cf9d9f436bdf5dfd184
|
||||
F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04
|
||||
F test/collate2.test 701d9651c5707024fd86a20649af9ea55e2c0eb8
|
||||
F test/collate3.test 9ac82f7a3a7e839a245fc341ff1b7803d56cd41a
|
||||
F test/collate2.test 04cebe4a033be319d6ddbb3bbc69464e01700b49
|
||||
F test/collate3.test d28d2cfab2c3a3d4628ae4b2b7afc9965daa3b4c
|
||||
F test/collate4.test 4545554388daaa604e5b3def3aa2f7ed6d56e8da
|
||||
F test/collate5.test e54df13eb9e1140273680b3153c6e19b39e59888
|
||||
F test/collate6.test 8be65a182abaac8011a622131486dafb8076e907
|
||||
@ -348,7 +350,7 @@ F test/func.test 628dc9b321fc66dd6d055fca6525e157004744e1
|
||||
F test/fuzz.test 62fc19dd36a427777fd671b569df07166548628a
|
||||
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
|
||||
F test/fuzz_common.tcl ff4bc2dfc465f6878f8e2d819620914365382731
|
||||
F test/fuzz_malloc.test 166b58dfd77cc04f6afeeaef0cfc1087abf134d1
|
||||
F test/fuzz_malloc.test 4eca9d345f06d5b0b0105f7a2ef9e7f22658827b
|
||||
F test/hook.test e17d4ed2843ba4ef9b234aa63e6f056bf88f9a19
|
||||
F test/icu.test f51d0f4407ff8bb1e872f51a0e8b08fdc5a6897e
|
||||
F test/in.test d49419c6df515852f477fa513f3317181d46bc92
|
||||
@ -463,8 +465,8 @@ F test/select1.test d0a4cad954fd41c030ec16ffbd2d08a4c0548742
|
||||
F test/select2.test 272a3d3e35b1d3a0760168ababf555e656357fc4
|
||||
F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054
|
||||
F test/select4.test b64d5d248d008e1dc365f451c76090bde907e665
|
||||
F test/select5.test 1bddfe92ae0b00ca53dc2735d5d23ce6b9723c26
|
||||
F test/select6.test 1131113eb6ae398069a8bc2173eb6c9a2d8ff1cd
|
||||
F test/select5.test 2c5464283438e06531a1e8801c674279dd01dd04
|
||||
F test/select6.test faad87c6e691bf69a822b69cd6808137a34d19e8
|
||||
F test/select7.test 7906735805cfbee4dddc0bed4c14e68d7f5f9c5f
|
||||
F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d
|
||||
F test/select9.test b4007b15396cb7ba2615cab31e1973b572e43210
|
||||
@ -537,7 +539,7 @@ F test/tkt2686.test 08f0f584461bc4990376936daa0a9bd3e6e81671
|
||||
F test/tkt2767.test 2607e36e5577c699221b964e7bbc06dd794dd738
|
||||
F test/tkt2817.test 94646b604c7dbae7058782f6582c05e200700aa9
|
||||
F test/tkt2820.test 017fdee33aaef7abc092beab6088816f1942304b
|
||||
F test/tkt2822.test 202c169952e6cf285c45c1315b4cf4f30b845c69
|
||||
F test/tkt2822.test a2b27a58df62d1b2e712f91dbe42ad3b7e0e77cc
|
||||
F test/tkt2832.test 85cf382ff406de9de35534b86bc7227d609140c0
|
||||
F test/tkt2854.test a2bc584ac26bcebe174229e7a1ad4e6d43c3d569
|
||||
F test/tkt2920.test a8737380e4ae6424e00c0273dc12775704efbebf
|
||||
@ -606,7 +608,7 @@ F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf
|
||||
F tool/mkfunction.c a785a1970027bc7a833aa8afb43d6786a33c11ae
|
||||
F tool/mkkeywordhash.c ef93810fc41fb3d3dbacf9a33a29be88ea99ffa9
|
||||
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
|
||||
F tool/mksqlite3c.tcl 5b4b6f974d9d761477dfb24e2a0c578b27419ef5
|
||||
F tool/mksqlite3c.tcl f5645b2e7ee71fa9633ca5c90ada3ae9120b4a3c
|
||||
F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
|
||||
F tool/omittest.tcl 5a25ea687df5da8dd9b94bf1683f5cf2c210e51d
|
||||
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
|
||||
@ -621,7 +623,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 66ff55efd688703fe99143e4c17e8d5f119d0690
|
||||
R 0d247ce1493fb2ede2a50a5e354297e6
|
||||
U danielk1977
|
||||
Z 33cfa9a4ef54e991c9419dcc5b206894
|
||||
P d0cfbbbaeef7b8ce9f73c6cd58888989a2df5b1f
|
||||
R fc873a52e1600a91cb8096b210a57fcf
|
||||
U drh
|
||||
Z 6f25e8fa0d3669556e1fb27761e93a30
|
||||
|
@ -1 +1 @@
|
||||
d0cfbbbaeef7b8ce9f73c6cd58888989a2df5b1f
|
||||
daf730d1defa78fb8b80a78f9108ac35a13e09f6
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to implement the ATTACH and DETACH commands.
|
||||
**
|
||||
** $Id: attach.c,v 1.77 2008/07/28 19:34:53 drh Exp $
|
||||
** $Id: attach.c,v 1.78 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -39,7 +39,7 @@ static int resolveAttachExpr(NameContext *pName, Expr *pExpr)
|
||||
int rc = SQLITE_OK;
|
||||
if( pExpr ){
|
||||
if( pExpr->op!=TK_ID ){
|
||||
rc = sqlite3ExprResolveNames(pName, pExpr);
|
||||
rc = sqlite3ResolveExprNames(pName, pExpr);
|
||||
if( rc==SQLITE_OK && !sqlite3ExprIsConstant(pExpr) ){
|
||||
sqlite3ErrorMsg(pName->pParse, "invalid name: \"%T\"", &pExpr->span);
|
||||
return SQLITE_ERROR;
|
||||
|
32
src/build.c
32
src/build.c
@ -22,7 +22,7 @@
|
||||
** COMMIT
|
||||
** ROLLBACK
|
||||
**
|
||||
** $Id: build.c,v 1.495 2008/08/11 18:44:58 drh Exp $
|
||||
** $Id: build.c,v 1.496 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -1140,12 +1140,12 @@ void sqlite3AddPrimaryKey(
|
||||
char *zType = 0;
|
||||
int iCol = -1, i;
|
||||
if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit;
|
||||
if( pTab->hasPrimKey ){
|
||||
if( pTab->tabFlags & TF_HasPrimaryKey ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"table \"%s\" has more than one primary key", pTab->zName);
|
||||
goto primary_key_exit;
|
||||
}
|
||||
pTab->hasPrimKey = 1;
|
||||
pTab->tabFlags |= TF_HasPrimaryKey;
|
||||
if( pList==0 ){
|
||||
iCol = pTab->nCol - 1;
|
||||
pTab->aCol[iCol].isPrimKey = 1;
|
||||
@ -1169,7 +1169,8 @@ void sqlite3AddPrimaryKey(
|
||||
&& sortOrder==SQLITE_SO_ASC ){
|
||||
pTab->iPKey = iCol;
|
||||
pTab->keyConf = onError;
|
||||
pTab->autoInc = autoInc;
|
||||
assert( autoInc==0 || autoInc==1 );
|
||||
pTab->tabFlags |= autoInc*TF_Autoincrement;
|
||||
}else if( autoInc ){
|
||||
#ifndef SQLITE_OMIT_AUTOINCREMENT
|
||||
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
|
||||
@ -1456,7 +1457,7 @@ void sqlite3EndTable(
|
||||
sNC.pParse = pParse;
|
||||
sNC.pSrcList = &sSrc;
|
||||
sNC.isCheck = 1;
|
||||
if( sqlite3ExprResolveNames(&sNC, p->pCheck) ){
|
||||
if( sqlite3ResolveExprNames(&sNC, p->pCheck) ){
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1529,10 +1530,10 @@ void sqlite3EndTable(
|
||||
sqlite3VdbeChangeP5(v, 1);
|
||||
pParse->nTab = 2;
|
||||
sqlite3SelectDestInit(&dest, SRT_Table, 1);
|
||||
sqlite3Select(pParse, pSelect, &dest, 0, 0, 0);
|
||||
sqlite3Select(pParse, pSelect, &dest);
|
||||
sqlite3VdbeAddOp1(v, OP_Close, 1);
|
||||
if( pParse->nErr==0 ){
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, 0, pSelect);
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);
|
||||
if( pSelTab==0 ) return;
|
||||
assert( p->aCol==0 );
|
||||
p->nCol = pSelTab->nCol;
|
||||
@ -1578,7 +1579,7 @@ void sqlite3EndTable(
|
||||
/* Check to see if we need to create an sqlite_sequence table for
|
||||
** keeping track of autoincrement keys.
|
||||
*/
|
||||
if( p->autoInc ){
|
||||
if( p->tabFlags & TF_Autoincrement ){
|
||||
Db *pDb = &db->aDb[iDb];
|
||||
if( pDb->pSchema->pSeqTab==0 ){
|
||||
sqlite3NestedParse(pParse,
|
||||
@ -1774,10 +1775,10 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
|
||||
#ifndef SQLITE_OMIT_AUTHORIZATION
|
||||
xAuth = db->xAuth;
|
||||
db->xAuth = 0;
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, 0, pSel);
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
|
||||
db->xAuth = xAuth;
|
||||
#else
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, 0, pSel);
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
|
||||
#endif
|
||||
pParse->nTab = n;
|
||||
if( pSelTab ){
|
||||
@ -2066,7 +2067,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){
|
||||
** at the btree level, in case the sqlite_sequence table needs to
|
||||
** move as a result of the drop (can happen in auto-vacuum mode).
|
||||
*/
|
||||
if( pTab->autoInc ){
|
||||
if( pTab->tabFlags & TF_Autoincrement ){
|
||||
sqlite3NestedParse(pParse,
|
||||
"DELETE FROM %s.sqlite_sequence WHERE name=%Q",
|
||||
pDb->zName, pTab->zName
|
||||
@ -2503,9 +2504,10 @@ void sqlite3CreateIndex(
|
||||
** specified collation sequence names.
|
||||
*/
|
||||
for(i=0; i<pList->nExpr; i++){
|
||||
Expr *pExpr = pList->a[i].pExpr;
|
||||
if( pExpr ){
|
||||
nExtra += (1 + strlen(pExpr->pColl->zName));
|
||||
Expr *pExpr;
|
||||
CollSeq *pColl;
|
||||
if( (pExpr = pList->a[i].pExpr)!=0 && (pColl = pExpr->pColl)!=0 ){
|
||||
nExtra += (1 + strlen(pColl->zName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2572,7 +2574,7 @@ void sqlite3CreateIndex(
|
||||
** break backwards compatibility - it needs to be a warning.
|
||||
*/
|
||||
pIndex->aiColumn[i] = j;
|
||||
if( pListItem->pExpr ){
|
||||
if( pListItem->pExpr && pListItem->pExpr->pColl ){
|
||||
assert( pListItem->pExpr->pColl );
|
||||
zColl = zExtra;
|
||||
sqlite3_snprintf(nExtra, zExtra, "%s", pListItem->pExpr->pColl->zName);
|
||||
|
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** in order to generate code for DELETE FROM statements.
|
||||
**
|
||||
** $Id: delete.c,v 1.171 2008/07/28 19:34:53 drh Exp $
|
||||
** $Id: delete.c,v 1.172 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -42,7 +42,8 @@ Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
|
||||
** writable return 0;
|
||||
*/
|
||||
int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
|
||||
if( (pTab->readOnly && (pParse->db->flags & SQLITE_WriteSchema)==0
|
||||
if( ((pTab->tabFlags & TF_Readonly)!=0
|
||||
&& (pParse->db->flags & SQLITE_WriteSchema)==0
|
||||
&& pParse->nested==0)
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
|| (pTab->pMod && pTab->pMod->pModule->xUpdate==0)
|
||||
@ -106,7 +107,7 @@ void sqlite3MaterializeView(
|
||||
pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);
|
||||
sqlite3Select(pParse, pDup, &dest, 0, 0, 0);
|
||||
sqlite3Select(pParse, pDup, &dest);
|
||||
sqlite3SelectDelete(db, pDup);
|
||||
}
|
||||
#endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */
|
||||
@ -254,7 +255,7 @@ void sqlite3DeleteFrom(
|
||||
memset(&sNC, 0, sizeof(sNC));
|
||||
sNC.pParse = pParse;
|
||||
sNC.pSrcList = pTabList;
|
||||
if( sqlite3ExprResolveNames(&sNC, pWhere) ){
|
||||
if( sqlite3ResolveExprNames(&sNC, pWhere) ){
|
||||
goto delete_from_cleanup;
|
||||
}
|
||||
|
||||
|
787
src/expr.c
787
src/expr.c
File diff suppressed because it is too large
Load Diff
18
src/insert.c
18
src/insert.c
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle INSERT statements in SQLite.
|
||||
**
|
||||
** $Id: insert.c,v 1.248 2008/07/28 19:34:53 drh Exp $
|
||||
** $Id: insert.c,v 1.249 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -165,7 +165,7 @@ static int autoIncBegin(
|
||||
Table *pTab /* The table we are writing to */
|
||||
){
|
||||
int memId = 0; /* Register holding maximum rowid */
|
||||
if( pTab->autoInc ){
|
||||
if( pTab->tabFlags & TF_Autoincrement ){
|
||||
Vdbe *v = pParse->pVdbe;
|
||||
Db *pDb = &pParse->db->aDb[iDb];
|
||||
int iCur = pParse->nTab;
|
||||
@ -216,7 +216,7 @@ static void autoIncEnd(
|
||||
Table *pTab, /* Table we are inserting into */
|
||||
int memId /* Memory cell holding the maximum rowid */
|
||||
){
|
||||
if( pTab->autoInc ){
|
||||
if( pTab->tabFlags & TF_Autoincrement ){
|
||||
int iCur = pParse->nTab;
|
||||
Vdbe *v = pParse->pVdbe;
|
||||
Db *pDb = &pParse->db->aDb[iDb];
|
||||
@ -532,7 +532,7 @@ void sqlite3Insert(
|
||||
VdbeComment((v, "Jump over SELECT coroutine"));
|
||||
|
||||
/* Resolve the expressions in the SELECT statement and execute it. */
|
||||
rc = sqlite3Select(pParse, pSelect, &dest, 0, 0, 0);
|
||||
rc = sqlite3Select(pParse, pSelect, &dest);
|
||||
if( rc || pParse->nErr || db->mallocFailed ){
|
||||
goto insert_cleanup;
|
||||
}
|
||||
@ -602,7 +602,7 @@ void sqlite3Insert(
|
||||
assert( useTempTable==0 );
|
||||
nColumn = pList ? pList->nExpr : 0;
|
||||
for(i=0; i<nColumn; i++){
|
||||
if( sqlite3ExprResolveNames(&sNC, pList->a[i].pExpr) ){
|
||||
if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
|
||||
goto insert_cleanup;
|
||||
}
|
||||
}
|
||||
@ -1535,7 +1535,7 @@ static int xferOptimization(
|
||||
return 0; /* tab1 must not have triggers */
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
if( pDest->isVirtual ){
|
||||
if( pDest->tabFlags & TF_Virtual ){
|
||||
return 0; /* tab1 must not be a virtual table */
|
||||
}
|
||||
#endif
|
||||
@ -1570,7 +1570,7 @@ static int xferOptimization(
|
||||
if( pSelect->pPrior ){
|
||||
return 0; /* SELECT may not be a compound query */
|
||||
}
|
||||
if( pSelect->isDistinct ){
|
||||
if( pSelect->selFlags & SF_Distinct ){
|
||||
return 0; /* SELECT may not be DISTINCT */
|
||||
}
|
||||
pEList = pSelect->pEList;
|
||||
@ -1596,7 +1596,7 @@ static int xferOptimization(
|
||||
return 0; /* tab1 and tab2 may not be the same table */
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
if( pSrc->isVirtual ){
|
||||
if( pSrc->tabFlags & TF_Virtual ){
|
||||
return 0; /* tab2 must not be a virtual table */
|
||||
}
|
||||
#endif
|
||||
@ -1687,7 +1687,7 @@ static int xferOptimization(
|
||||
addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);
|
||||
}else{
|
||||
addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
|
||||
assert( pDest->autoInc==0 );
|
||||
assert( (pDest->tabFlags & TF_Autoincrement)==0 );
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData);
|
||||
sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid);
|
||||
|
@ -14,7 +14,7 @@
|
||||
** other files are for internal use by SQLite and should not be
|
||||
** accessed by users of the library.
|
||||
**
|
||||
** $Id: main.c,v 1.490 2008/08/20 16:21:12 danielk1977 Exp $
|
||||
** $Id: main.c,v 1.491 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -1890,7 +1890,7 @@ int sqlite3_table_column_metadata(
|
||||
zCollSeq = pCol->zColl;
|
||||
notnull = pCol->notNull!=0;
|
||||
primarykey = pCol->isPrimKey!=0;
|
||||
autoinc = pTab->iPKey==iCol && pTab->autoInc;
|
||||
autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0;
|
||||
}else{
|
||||
zDataType = "INTEGER";
|
||||
primarykey = 1;
|
||||
|
@ -14,7 +14,7 @@
|
||||
** the parser. Lemon will also generate a header file containing
|
||||
** numeric codes for all of the tokens.
|
||||
**
|
||||
** @(#) $Id: parse.y,v 1.251 2008/08/11 14:26:35 drh Exp $
|
||||
** @(#) $Id: parse.y,v 1.252 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
|
||||
// All token codes are small integers with #defines that begin with "TK_"
|
||||
@ -360,8 +360,8 @@ cmd ::= DROP VIEW ifexists(E) fullname(X). {
|
||||
//////////////////////// The SELECT statement /////////////////////////////////
|
||||
//
|
||||
cmd ::= select(X). {
|
||||
SelectDest dest = {SRT_Callback, 0, 0, 0, 0};
|
||||
sqlite3Select(pParse, X, &dest, 0, 0, 0);
|
||||
SelectDest dest = {SRT_Output, 0, 0, 0, 0};
|
||||
sqlite3Select(pParse, X, &dest);
|
||||
sqlite3SelectDelete(pParse->db, X);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
** interface, and routines that contribute to loading the database schema
|
||||
** from disk.
|
||||
**
|
||||
** $Id: prepare.c,v 1.92 2008/08/11 18:44:58 drh Exp $
|
||||
** $Id: prepare.c,v 1.93 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -203,7 +203,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
|
||||
}
|
||||
pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);
|
||||
if( pTab ){
|
||||
pTab->readOnly = 1;
|
||||
pTab->tabFlags |= TF_Readonly;
|
||||
}
|
||||
|
||||
/* Create a cursor to hold the database open
|
||||
|
1125
src/resolve.c
Normal file
1125
src/resolve.c
Normal file
File diff suppressed because it is too large
Load Diff
1370
src/select.c
1370
src/select.c
File diff suppressed because it is too large
Load Diff
131
src/sqliteInt.h
131
src/sqliteInt.h
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.756 2008/08/20 14:49:25 danielk1977 Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.757 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITEINT_H_
|
||||
#define _SQLITEINT_H_
|
||||
@ -208,6 +208,9 @@
|
||||
# define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The TCL headers are only needed when compiling the TCL bindings.
|
||||
*/
|
||||
#if defined(SQLITE_TCL) || defined(TCLSH)
|
||||
# include <tcl.h>
|
||||
#endif
|
||||
@ -471,6 +474,7 @@ typedef struct TriggerStack TriggerStack;
|
||||
typedef struct TriggerStep TriggerStep;
|
||||
typedef struct Trigger Trigger;
|
||||
typedef struct UnpackedRecord UnpackedRecord;
|
||||
typedef struct Walker Walker;
|
||||
typedef struct WhereInfo WhereInfo;
|
||||
typedef struct WhereLevel WhereLevel;
|
||||
|
||||
@ -580,7 +584,7 @@ struct Lookaside {
|
||||
u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */
|
||||
int nOut; /* Number of buffers currently checked out */
|
||||
int mxOut; /* Highwater mark for nOut */
|
||||
LookasideSlot *pFree; /* List if available buffers */
|
||||
LookasideSlot *pFree; /* List of available buffers */
|
||||
void *pStart; /* First byte of available memory space */
|
||||
void *pEnd; /* First byte past end of available space */
|
||||
};
|
||||
@ -761,6 +765,13 @@ struct FuncDef {
|
||||
char *zName; /* SQL name of the function. */
|
||||
};
|
||||
|
||||
/*
|
||||
** Possible values for FuncDef.flags
|
||||
*/
|
||||
#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
|
||||
#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
|
||||
#define SQLITE_FUNC_EPHEM 0x04 /* Ephermeral. Delete with VDBE */
|
||||
|
||||
/*
|
||||
** Each SQLite module (virtual table definition) is defined by an
|
||||
** instance of the following structure, stored in the sqlite3.aModule
|
||||
@ -773,13 +784,6 @@ struct Module {
|
||||
void (*xDestroy)(void *); /* Module destructor function */
|
||||
};
|
||||
|
||||
/*
|
||||
** Possible values for FuncDef.flags
|
||||
*/
|
||||
#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
|
||||
#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
|
||||
#define SQLITE_FUNC_EPHEM 0x04 /* Ephermeral. Delete with VDBE */
|
||||
|
||||
/*
|
||||
** information about each column of an SQL table is held in an instance
|
||||
** of this structure.
|
||||
@ -828,7 +832,7 @@ struct CollSeq {
|
||||
};
|
||||
|
||||
/*
|
||||
** Allowed values of CollSeq flags:
|
||||
** Allowed values of CollSeq.type:
|
||||
*/
|
||||
#define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */
|
||||
#define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */
|
||||
@ -846,7 +850,7 @@ struct CollSeq {
|
||||
**
|
||||
** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and
|
||||
** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve
|
||||
** the speed a little by number the values consecutively.
|
||||
** the speed a little by numbering the values consecutively.
|
||||
**
|
||||
** But rather than start with 0 or 1, we begin with 'a'. That way,
|
||||
** when multiple affinity types are concatenated into a string and
|
||||
@ -892,14 +896,14 @@ struct CollSeq {
|
||||
** that the datatype of the PRIMARY KEY must be INTEGER for this field to
|
||||
** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of
|
||||
** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid
|
||||
** is generated for each row of the table. Table.hasPrimKey is true if
|
||||
** is generated for each row of the table. TF_HasPrimaryKey is set if
|
||||
** the table has any PRIMARY KEY, INTEGER or otherwise.
|
||||
**
|
||||
** Table.tnum is the page number for the root BTree page of the table in the
|
||||
** database file. If Table.iDb is the index of the database table backend
|
||||
** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that
|
||||
** holds temporary tables and indices. If Table.isEphem
|
||||
** is true, then the table is stored in a file that is automatically deleted
|
||||
** holds temporary tables and indices. If TF_Ephemeral is set
|
||||
** then the table is stored in a file that is automatically deleted
|
||||
** when the VDBE cursor to the table is closed. In this case Table.tnum
|
||||
** refers VDBE cursor number that holds the table open, not to the root
|
||||
** page number. Transient tables are used to hold the results of a
|
||||
@ -908,14 +912,16 @@ struct CollSeq {
|
||||
*/
|
||||
struct Table {
|
||||
sqlite3 *db; /* Associated database connection. Might be NULL. */
|
||||
char *zName; /* Name of the table */
|
||||
char *zName; /* Name of the table or view */
|
||||
int iPKey; /* If not negative, use aCol[iPKey] as the primary key */
|
||||
int nCol; /* Number of columns in this table */
|
||||
Column *aCol; /* Information about each column */
|
||||
int iPKey; /* If not less then 0, use aCol[iPKey] as the primary key */
|
||||
Index *pIndex; /* List of SQL indexes on this table. */
|
||||
int tnum; /* Root BTree node for this table (see note above) */
|
||||
Select *pSelect; /* NULL for tables. Points to definition if a view. */
|
||||
int nRef; /* Number of pointers to this Table */
|
||||
u16 nRef; /* Number of pointers to this Table */
|
||||
u8 tabFlags; /* Mask of TF_* values */
|
||||
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
|
||||
Trigger *pTrigger; /* List of SQL triggers on this table */
|
||||
FKey *pFKey; /* Linked list of all foreign keys in this table */
|
||||
char *zColAff; /* String defining the affinity of each column */
|
||||
@ -923,16 +929,9 @@ struct Table {
|
||||
Expr *pCheck; /* The AND of all CHECK constraints */
|
||||
#endif
|
||||
#ifndef SQLITE_OMIT_ALTERTABLE
|
||||
int addColOffset; /* Offset in CREATE TABLE statement to add a new column */
|
||||
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
|
||||
#endif
|
||||
u8 readOnly; /* True if this table should not be written by the user */
|
||||
u8 isEphem; /* True if created using OP_OpenEphermeral */
|
||||
u8 hasPrimKey; /* True if there exists a primary key */
|
||||
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
|
||||
u8 autoInc; /* True if the integer primary key is autoincrement */
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
u8 isVirtual; /* True if this is a virtual table */
|
||||
u8 isCommit; /* True once the CREATE TABLE has been committed */
|
||||
Module *pMod; /* Pointer to the implementation of the module */
|
||||
sqlite3_vtab *pVtab; /* Pointer to the module instance */
|
||||
int nModuleArg; /* Number of arguments to the module */
|
||||
@ -941,13 +940,25 @@ struct Table {
|
||||
Schema *pSchema; /* Schema that contains this table */
|
||||
};
|
||||
|
||||
/*
|
||||
** Allowed values for Tabe.tabFlags.
|
||||
*/
|
||||
#define TF_Readonly 0x01 /* Read-only system table */
|
||||
#define TF_Ephemeral 0x02 /* An emphermal table */
|
||||
#define TF_HasPrimaryKey 0x04 /* Table has a primary key */
|
||||
#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */
|
||||
#define TF_Virtual 0x10 /* Is a virtual table */
|
||||
#define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Test to see whether or not a table is a virtual table. This is
|
||||
** done as a macro so that it will be optimized out when virtual
|
||||
** table support is omitted from the build.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
# define IsVirtual(X) ((X)->isVirtual)
|
||||
# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0)
|
||||
# define IsHiddenColumn(X) ((X)->isHidden)
|
||||
#else
|
||||
# define IsVirtual(X) 0
|
||||
@ -1241,7 +1252,7 @@ struct Expr {
|
||||
int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
|
||||
Select *pSelect; /* When the expression is a sub-select. Also the
|
||||
** right side of "<expr> IN (<select>)" */
|
||||
Table *pTab; /* Table for OP_Column expressions. */
|
||||
Table *pTab; /* Table for TK_COLUMN expressions. */
|
||||
#if SQLITE_MAX_EXPR_DEPTH>0
|
||||
int nHeight; /* Height of the tree headed by this node */
|
||||
#endif
|
||||
@ -1287,8 +1298,8 @@ struct ExprList {
|
||||
Expr *pExpr; /* The list of expressions */
|
||||
char *zName; /* Token associated with this expression */
|
||||
u8 sortOrder; /* 1 for DESC or 0 for ASC */
|
||||
u8 isAgg; /* True if this is an aggregate like count(*) */
|
||||
u8 done; /* A flag to indicate when processing is finished */
|
||||
u16 iCol; /* For ORDER BY, column number in result set */
|
||||
} *a; /* One entry for each expression */
|
||||
};
|
||||
|
||||
@ -1502,12 +1513,8 @@ struct NameContext {
|
||||
struct Select {
|
||||
ExprList *pEList; /* The fields of the result */
|
||||
u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
|
||||
u8 isDistinct; /* True if the DISTINCT keyword is present */
|
||||
u8 isResolved; /* True once sqlite3SelectResolve() has run. */
|
||||
u8 isAgg; /* True if this is an aggregate query */
|
||||
u8 usesEphm; /* True if uses an OpenEphemeral opcode */
|
||||
u8 disallowOrderBy; /* Do not allow an ORDER BY to be attached if TRUE */
|
||||
char affinity; /* MakeRecord with this affinity for SRT_Set */
|
||||
u16 selFlags; /* Various SF_* values */
|
||||
SrcList *pSrc; /* The FROM clause */
|
||||
Expr *pWhere; /* The WHERE clause */
|
||||
ExprList *pGroupBy; /* The GROUP BY clause */
|
||||
@ -1523,7 +1530,20 @@ struct Select {
|
||||
};
|
||||
|
||||
/*
|
||||
** The results of a select can be distributed in several ways.
|
||||
** Allowed values for Select.selFlags. The "SF" prefix stands for
|
||||
** "Select Flag".
|
||||
*/
|
||||
#define SF_Distinct 0x0001 /* Output should be DISTINCT */
|
||||
#define SF_Resolved 0x0002 /* Identifiers have been resolved */
|
||||
#define SF_Aggregate 0x0004 /* Contains aggregate functions */
|
||||
#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */
|
||||
#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */
|
||||
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
|
||||
|
||||
|
||||
/*
|
||||
** The results of a select can be distributed in several ways. The
|
||||
** "SRT" prefix means "SELECT Result Type".
|
||||
*/
|
||||
#define SRT_Union 1 /* Store result as keys in an index */
|
||||
#define SRT_Except 2 /* Remove result from a UNION index */
|
||||
@ -1533,7 +1553,7 @@ struct Select {
|
||||
/* The ORDER BY clause is ignored for all of the above */
|
||||
#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard)
|
||||
|
||||
#define SRT_Callback 5 /* Invoke a callback with each row of result */
|
||||
#define SRT_Output 5 /* Output each row of result */
|
||||
#define SRT_Mem 6 /* Store result in a memory cell */
|
||||
#define SRT_Set 7 /* Store results as keys in an index */
|
||||
#define SRT_Table 8 /* Store result as data with an automatic rowid */
|
||||
@ -1862,6 +1882,34 @@ struct Sqlite3Config {
|
||||
int mxParserStack; /* maximum depth of the parser stack */
|
||||
};
|
||||
|
||||
/*
|
||||
** Context pointer passed down through the tree-walk.
|
||||
*/
|
||||
struct Walker {
|
||||
int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */
|
||||
int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
|
||||
Parse *pParse; /* Parser context. */
|
||||
union { /* Extra data for callback */
|
||||
NameContext *pNC; /* Naming context */
|
||||
int i; /* Integer value */
|
||||
} u;
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int sqlite3WalkExpr(Walker*, Expr*);
|
||||
int sqlite3WalkExprList(Walker*, ExprList*);
|
||||
int sqlite3WalkSelect(Walker*, Select*);
|
||||
int sqlite3WalkSelectExpr(Walker*, Select*);
|
||||
int sqlite3WalkSelectFrom(Walker*, Select*);
|
||||
|
||||
/*
|
||||
** Return code from the parse-tree walking primitives and their
|
||||
** callbacks.
|
||||
*/
|
||||
#define WRC_Continue 0
|
||||
#define WRC_Prune 1
|
||||
#define WRC_Abort 2
|
||||
|
||||
/*
|
||||
** Assuming zIn points to the first byte of a UTF-8 character,
|
||||
** advance zIn to point to the first byte of the next UTF-8 character.
|
||||
@ -1970,7 +2018,7 @@ void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
|
||||
void sqlite3ResetInternalSchema(sqlite3*, int);
|
||||
void sqlite3BeginParse(Parse*,int);
|
||||
void sqlite3CommitInternalChanges(sqlite3*);
|
||||
Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*);
|
||||
Table *sqlite3ResultSetOfSelect(Parse*,Select*);
|
||||
void sqlite3OpenMasterTable(Parse *, int);
|
||||
void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
|
||||
void sqlite3AddColumn(Parse*,Token*);
|
||||
@ -2013,7 +2061,7 @@ void sqlite3SrcListDelete(sqlite3*, SrcList*);
|
||||
void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
|
||||
Token*, int, int);
|
||||
void sqlite3DropIndex(Parse*, SrcList*, int);
|
||||
int sqlite3Select(Parse*, Select*, SelectDest*, Select*, int, int*);
|
||||
int sqlite3Select(Parse*, Select*, SelectDest*);
|
||||
Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
|
||||
Expr*,ExprList*,int,Expr*,Expr*);
|
||||
void sqlite3SelectDelete(sqlite3*, Select*);
|
||||
@ -2048,7 +2096,6 @@ void sqlite3Vacuum(Parse*);
|
||||
int sqlite3RunVacuum(char**, sqlite3*);
|
||||
char *sqlite3NameFromToken(sqlite3*, Token*);
|
||||
int sqlite3ExprCompare(Expr*, Expr*);
|
||||
int sqlite3ExprResolveNames(NameContext *, Expr *);
|
||||
void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
|
||||
void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
|
||||
Vdbe *sqlite3GetVdbe(Parse*);
|
||||
@ -2230,7 +2277,11 @@ int sqlite3GetToken(const unsigned char *, int *);
|
||||
void sqlite3NestedParse(Parse*, const char*, ...);
|
||||
void sqlite3ExpirePreparedStatements(sqlite3*);
|
||||
void sqlite3CodeSubselect(Parse *, Expr *, int);
|
||||
int sqlite3SelectResolve(Parse *, Select *, NameContext *);
|
||||
void sqlite3SelectPrep(Parse*, Select*, NameContext*);
|
||||
int sqlite3ResolveExprNames(NameContext*, Expr*);
|
||||
int sqlite3ResolveExprListNames(NameContext*, ExprList*);
|
||||
void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
|
||||
int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
|
||||
void sqlite3ColumnDefault(Vdbe *, Table *, int);
|
||||
void sqlite3AlterFinishAddColumn(Parse *, Token *);
|
||||
void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
|
||||
@ -2352,9 +2403,11 @@ int sqlite3FindInIndex(Parse *, Expr *, int*);
|
||||
#if SQLITE_MAX_EXPR_DEPTH>0
|
||||
void sqlite3ExprSetHeight(Parse *pParse, Expr *p);
|
||||
int sqlite3SelectExprHeight(Select *);
|
||||
int sqlite3ExprCheckHeight(Parse*, int);
|
||||
#else
|
||||
#define sqlite3ExprSetHeight(x,y)
|
||||
#define sqlite3SelectExprHeight(x) 0
|
||||
#define sqlite3ExprCheckHeight(x,y)
|
||||
#endif
|
||||
|
||||
u32 sqlite3Get4byte(const u8*);
|
||||
|
@ -10,7 +10,7 @@
|
||||
*************************************************************************
|
||||
**
|
||||
**
|
||||
** $Id: trigger.c,v 1.128 2008/07/28 19:34:54 drh Exp $
|
||||
** $Id: trigger.c,v 1.129 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -679,8 +679,7 @@ static int codeTriggerProgram(
|
||||
SelectDest dest;
|
||||
|
||||
sqlite3SelectDestInit(&dest, SRT_Discard, 0);
|
||||
sqlite3SelectResolve(pParse, ss, 0);
|
||||
sqlite3Select(pParse, ss, &dest, 0, 0, 0);
|
||||
sqlite3Select(pParse, ss, &dest);
|
||||
sqlite3SelectDelete(db, ss);
|
||||
}
|
||||
break;
|
||||
@ -829,7 +828,7 @@ int sqlite3CodeRowTrigger(
|
||||
/* code the WHEN clause */
|
||||
endTrigger = sqlite3VdbeMakeLabel(pParse->pVdbe);
|
||||
whenExpr = sqlite3ExprDup(db, p->pWhen);
|
||||
if( db->mallocFailed || sqlite3ExprResolveNames(&sNC, whenExpr) ){
|
||||
if( db->mallocFailed || sqlite3ResolveExprNames(&sNC, whenExpr) ){
|
||||
pParse->trigStack = trigStackEntry.pNext;
|
||||
sqlite3ExprDelete(db, whenExpr);
|
||||
return 1;
|
||||
|
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle UPDATE statements.
|
||||
**
|
||||
** $Id: update.c,v 1.181 2008/07/28 19:34:54 drh Exp $
|
||||
** $Id: update.c,v 1.182 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -194,7 +194,7 @@ void sqlite3Update(
|
||||
*/
|
||||
chngRowid = 0;
|
||||
for(i=0; i<pChanges->nExpr; i++){
|
||||
if( sqlite3ExprResolveNames(&sNC, pChanges->a[i].pExpr) ){
|
||||
if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
|
||||
goto update_cleanup;
|
||||
}
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
@ -335,7 +335,7 @@ void sqlite3Update(
|
||||
/* Resolve the column names in all the expressions in the
|
||||
** WHERE clause.
|
||||
*/
|
||||
if( sqlite3ExprResolveNames(&sNC, pWhere) ){
|
||||
if( sqlite3ResolveExprNames(&sNC, pWhere) ){
|
||||
goto update_cleanup;
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ static void updateVirtualTable(
|
||||
/* fill the ephemeral table
|
||||
*/
|
||||
sqlite3SelectDestInit(&dest, SRT_Table, ephemTab);
|
||||
sqlite3Select(pParse, pSelect, &dest, 0, 0, 0);
|
||||
sqlite3Select(pParse, pSelect, &dest);
|
||||
|
||||
/* Generate code to scan the ephemeral table and call VUpdate. */
|
||||
iReg = ++pParse->nMem;
|
||||
|
@ -14,7 +14,7 @@
|
||||
** to version 2.8.7, all this code was combined into the vdbe.c source file.
|
||||
** But that file was getting too big so this subroutines were split out.
|
||||
**
|
||||
** $Id: vdbeaux.c,v 1.407 2008/08/13 19:11:48 drh Exp $
|
||||
** $Id: vdbeaux.c,v 1.408 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -2238,6 +2238,7 @@ UnpackedRecord *sqlite3VdbeRecordUnpack(
|
||||
pMem++;
|
||||
u++;
|
||||
}
|
||||
assert( u<=pKeyInfo->nField + 1 );
|
||||
p->nField = u;
|
||||
return (void*)p;
|
||||
}
|
||||
|
14
src/vtab.c
14
src/vtab.c
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to help implement virtual tables.
|
||||
**
|
||||
** $Id: vtab.c,v 1.75 2008/08/20 14:49:25 danielk1977 Exp $
|
||||
** $Id: vtab.c,v 1.76 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
#include "sqliteInt.h"
|
||||
@ -186,7 +186,7 @@ void sqlite3VtabBeginParse(
|
||||
iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
|
||||
assert( iDb>=0 );
|
||||
|
||||
pTable->isVirtual = 1;
|
||||
pTable->tabFlags |= TF_Virtual;
|
||||
pTable->nModuleArg = 0;
|
||||
addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
|
||||
addModuleArgument(db, pTable, sqlite3DbStrDup(db, db->aDb[iDb].zName));
|
||||
@ -442,7 +442,7 @@ int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
|
||||
Module *pMod;
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
if( !pTab || !pTab->isVirtual || pTab->pVtab ){
|
||||
if( !pTab || (pTab->tabFlags & TF_Virtual)==0 || pTab->pVtab ){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@ -503,7 +503,7 @@ int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
|
||||
const char *zModule;
|
||||
|
||||
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
|
||||
assert(pTab && pTab->isVirtual && !pTab->pVtab);
|
||||
assert(pTab && (pTab->tabFlags & TF_Virtual)!=0 && !pTab->pVtab);
|
||||
pMod = pTab->pMod;
|
||||
zModule = pTab->azModuleArg[0];
|
||||
|
||||
@ -544,7 +544,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return SQLITE_MISUSE;
|
||||
}
|
||||
assert(pTab->isVirtual && pTab->nCol==0 && pTab->aCol==0);
|
||||
assert((pTab->tabFlags & TF_Virtual)!=0 && pTab->nCol==0 && pTab->aCol==0);
|
||||
|
||||
memset(&sParse, 0, sizeof(Parse));
|
||||
sParse.declareVtab = 1;
|
||||
@ -554,7 +554,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
|
||||
SQLITE_OK == sqlite3RunParser(&sParse, zCreateTable, &zErr) &&
|
||||
sParse.pNewTable &&
|
||||
!sParse.pNewTable->pSelect &&
|
||||
!sParse.pNewTable->isVirtual
|
||||
(sParse.pNewTable->tabFlags & TF_Virtual)==0
|
||||
){
|
||||
pTab->aCol = sParse.pNewTable->aCol;
|
||||
pTab->nCol = sParse.pNewTable->nCol;
|
||||
@ -773,7 +773,7 @@ FuncDef *sqlite3VtabOverloadFunction(
|
||||
if( pExpr->op!=TK_COLUMN ) return pDef;
|
||||
pTab = pExpr->pTab;
|
||||
if( pTab==0 ) return pDef;
|
||||
if( !pTab->isVirtual ) return pDef;
|
||||
if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef;
|
||||
pVtab = pTab->pVtab;
|
||||
assert( pVtab!=0 );
|
||||
assert( pVtab->pModule!=0 );
|
||||
|
134
src/walker.c
Normal file
134
src/walker.c
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
** 2008 August 16
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file contains routines used for walking the parser tree for
|
||||
** an SQL statement.
|
||||
**
|
||||
** $Id: walker.c,v 1.1 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*
|
||||
** Walk an expression tree. Invoke the callback once for each node
|
||||
** of the expression, while decending. (In other words, the callback
|
||||
** is invoked before visiting children.)
|
||||
**
|
||||
** The return value from the callback should be one of the WRC_*
|
||||
** constants to specify how to proceed with the walk.
|
||||
**
|
||||
** WRC_Continue Continue descending down the tree.
|
||||
**
|
||||
** WRC_Prune Do not descend into child nodes. But allow
|
||||
** the walk to continue with sibling nodes.
|
||||
**
|
||||
** WRC_Abort Do no more callbacks. Unwind the stack and
|
||||
** return the top-level walk call.
|
||||
**
|
||||
** The return value from this routine is WRC_Abort to abandon the tree walk
|
||||
** and WRC_Continue to continue.
|
||||
*/
|
||||
int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
|
||||
int rc;
|
||||
if( pExpr==0 ) return WRC_Continue;
|
||||
rc = pWalker->xExprCallback(pWalker, pExpr);
|
||||
if( rc==WRC_Continue ){
|
||||
if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
|
||||
if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
|
||||
if( sqlite3WalkExprList(pWalker, pExpr->pList) ) return WRC_Abort;
|
||||
if( sqlite3WalkSelect(pWalker, pExpr->pSelect) ){
|
||||
return WRC_Abort;
|
||||
}
|
||||
}
|
||||
return rc & WRC_Abort;
|
||||
}
|
||||
|
||||
/*
|
||||
** Call sqlite3WalkExpr() for every expression in list p or until
|
||||
** an abort request is seen.
|
||||
*/
|
||||
int sqlite3WalkExprList(Walker *pWalker, ExprList *p){
|
||||
int i, rc = WRC_Continue;
|
||||
struct ExprList_item *pItem;
|
||||
if( p ){
|
||||
for(i=p->nExpr, pItem=p->a; i>0; i--, pItem++){
|
||||
if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;
|
||||
}
|
||||
}
|
||||
return rc & WRC_Continue;
|
||||
}
|
||||
|
||||
/*
|
||||
** Walk all expressions associated with SELECT statement p. Do
|
||||
** not invoke the SELECT callback on p, but do (of course) invoke
|
||||
** any expr callbacks and SELECT callbacks that come from subqueries.
|
||||
** Return WRC_Abort or WRC_Continue.
|
||||
*/
|
||||
int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){
|
||||
if( sqlite3WalkExprList(pWalker, p->pEList) ) return WRC_Abort;
|
||||
if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;
|
||||
if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;
|
||||
if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;
|
||||
if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;
|
||||
if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
|
||||
if( sqlite3WalkExpr(pWalker, p->pOffset) ) return WRC_Abort;
|
||||
return WRC_Continue;
|
||||
}
|
||||
|
||||
/*
|
||||
** Walk the parse trees associated with all subqueries in the
|
||||
** FROM clause of SELECT statement p. Do not invoke the select
|
||||
** callback on p, but do invoke it on each FROM clause subquery
|
||||
** and on any subqueries further down in the tree. Return
|
||||
** WRC_Abort or WRC_Continue;
|
||||
*/
|
||||
int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){
|
||||
SrcList *pSrc;
|
||||
int i;
|
||||
struct SrcList_item *pItem;
|
||||
|
||||
pSrc = p->pSrc;
|
||||
if( pSrc ){
|
||||
for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
|
||||
if( sqlite3WalkSelect(pWalker, pItem->pSelect) ){
|
||||
return WRC_Abort;
|
||||
}
|
||||
}
|
||||
}
|
||||
return WRC_Continue;
|
||||
}
|
||||
|
||||
/*
|
||||
** Call sqlite3WalkExpr() for every expression in Select statement p.
|
||||
** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
|
||||
** on the compound select chain, p->pPrior.
|
||||
**
|
||||
** Return WRC_Continue under normal conditions. Return WRC_Abort if
|
||||
** there is an abort request.
|
||||
**
|
||||
** If the Walker does not have an xSelectCallback() then this routine
|
||||
** is a no-op returning WRC_Continue.
|
||||
*/
|
||||
int sqlite3WalkSelect(Walker *pWalker, Select *p){
|
||||
int rc;
|
||||
if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue;
|
||||
rc = WRC_Continue;
|
||||
while( p ){
|
||||
rc = pWalker->xSelectCallback(pWalker, p);
|
||||
if( rc ) break;
|
||||
if( sqlite3WalkSelectExpr(pWalker, p) ) return WRC_Abort;
|
||||
if( sqlite3WalkSelectFrom(pWalker, p) ) return WRC_Abort;
|
||||
p = p->pPrior;
|
||||
}
|
||||
return rc & WRC_Abort;
|
||||
}
|
23
src/where.c
23
src/where.c
@ -16,7 +16,7 @@
|
||||
** so is applicable. Because this module is responsible for selecting
|
||||
** indices, you might also think of this module as the "query optimizer".
|
||||
**
|
||||
** $Id: where.c,v 1.319 2008/08/01 17:37:41 danielk1977 Exp $
|
||||
** $Id: where.c,v 1.320 2008/08/20 16:35:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -320,9 +320,9 @@ static void createMask(ExprMaskSet *pMaskSet, int iCursor){
|
||||
** tree.
|
||||
**
|
||||
** In order for this routine to work, the calling function must have
|
||||
** previously invoked sqlite3ExprResolveNames() on the expression. See
|
||||
** previously invoked sqlite3ResolveExprNames() on the expression. See
|
||||
** the header comment on that routine for additional information.
|
||||
** The sqlite3ExprResolveNames() routines looks for column names and
|
||||
** The sqlite3ResolveExprNames() routines looks for column names and
|
||||
** sets their opcodes to TK_COLUMN and their Expr.iTable fields to
|
||||
** the VDBE cursor number of the table. This routine just has to
|
||||
** translate the cursor numbers into bitmask values and OR all
|
||||
@ -396,10 +396,12 @@ static int allowedOp(int op){
|
||||
** attached to the right. For the same reason the EP_ExpCollate flag
|
||||
** is not commuted.
|
||||
*/
|
||||
static void exprCommute(Expr *pExpr){
|
||||
static void exprCommute(Parse *pParse, Expr *pExpr){
|
||||
u16 expRight = (pExpr->pRight->flags & EP_ExpCollate);
|
||||
u16 expLeft = (pExpr->pLeft->flags & EP_ExpCollate);
|
||||
assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
|
||||
pExpr->pRight->pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
|
||||
pExpr->pLeft->pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
|
||||
SWAP(CollSeq*,pExpr->pRight->pColl,pExpr->pLeft->pColl);
|
||||
pExpr->pRight->flags = (pExpr->pRight->flags & ~EP_ExpCollate) | expLeft;
|
||||
pExpr->pLeft->flags = (pExpr->pLeft->flags & ~EP_ExpCollate) | expRight;
|
||||
@ -519,7 +521,7 @@ static void exprAnalyzeAll(
|
||||
** literal that does not begin with a wildcard.
|
||||
*/
|
||||
static int isLikeOrGlob(
|
||||
sqlite3 *db, /* The database */
|
||||
Parse *pParse, /* Parsing and code generating context */
|
||||
Expr *pExpr, /* Test this expression */
|
||||
int *pnPattern, /* Number of non-wildcard prefix characters */
|
||||
int *pisComplete, /* True if the only wildcard is % in the last character */
|
||||
@ -531,6 +533,7 @@ static int isLikeOrGlob(
|
||||
int c, cnt;
|
||||
char wc[3];
|
||||
CollSeq *pColl;
|
||||
sqlite3 *db = pParse->db;
|
||||
|
||||
if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){
|
||||
return 0;
|
||||
@ -548,7 +551,7 @@ static int isLikeOrGlob(
|
||||
if( pLeft->op!=TK_COLUMN ){
|
||||
return 0;
|
||||
}
|
||||
pColl = pLeft->pColl;
|
||||
pColl = sqlite3ExprCollSeq(pParse, pLeft);
|
||||
assert( pColl!=0 || pLeft->iColumn==-1 );
|
||||
if( pColl==0 ){
|
||||
/* No collation is defined for the ROWID. Use the default. */
|
||||
@ -788,7 +791,7 @@ static void exprAnalyze(
|
||||
pDup = pExpr;
|
||||
pNew = pTerm;
|
||||
}
|
||||
exprCommute(pDup);
|
||||
exprCommute(pParse, pDup);
|
||||
pLeft = pDup->pLeft;
|
||||
pNew->leftCursor = pLeft->iTable;
|
||||
pNew->leftColumn = pLeft->iColumn;
|
||||
@ -909,7 +912,7 @@ or_not_possible:
|
||||
** The last character of the prefix "abc" is incremented to form the
|
||||
** termination condition "abd".
|
||||
*/
|
||||
if( isLikeOrGlob(db, pExpr, &nPattern, &isComplete, &noCase) ){
|
||||
if( isLikeOrGlob(pParse, pExpr, &nPattern, &isComplete, &noCase) ){
|
||||
Expr *pLeft, *pRight;
|
||||
Expr *pStr1, *pStr2;
|
||||
Expr *pNewExpr1, *pNewExpr2;
|
||||
@ -2278,7 +2281,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
pTabItem = &pTabList->a[pLevel->iFrom];
|
||||
pTab = pTabItem->pTab;
|
||||
iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
|
||||
if( pTab->isEphem || pTab->pSelect ) continue;
|
||||
if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue;
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
if( pLevel->pBestIdx ){
|
||||
int iCur = pTabItem->iCursor;
|
||||
@ -2837,7 +2840,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];
|
||||
Table *pTab = pTabItem->pTab;
|
||||
assert( pTab!=0 );
|
||||
if( pTab->isEphem || pTab->pSelect ) continue;
|
||||
if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue;
|
||||
if( !pWInfo->okOnePass && (pLevel->flags & WHERE_IDX_ONLY)==0 ){
|
||||
sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is page cache subsystem.
|
||||
#
|
||||
# $Id: collate2.test,v 1.5 2007/02/01 23:02:46 drh Exp $
|
||||
# $Id: collate2.test,v 1.6 2008/08/20 16:35:10 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -136,6 +136,26 @@ do_test collate2-1.2.3 {
|
||||
ORDER BY 1, oid;
|
||||
}
|
||||
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
||||
do_test collate2-1.2.4 {
|
||||
execsql {
|
||||
SELECT b FROM collate2t1 WHERE b > 'aa' ORDER BY +b;
|
||||
}
|
||||
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
||||
do_test collate2-1.2.5 {
|
||||
execsql {
|
||||
SELECT b FROM collate2t1 WHERE a COLLATE nocase > 'aa' ORDER BY +b;
|
||||
}
|
||||
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
||||
do_test collate2-1.2.6 {
|
||||
execsql {
|
||||
SELECT b FROM collate2t1 WHERE b COLLATE nocase > 'aa' ORDER BY +b;
|
||||
}
|
||||
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
||||
do_test collate2-1.2.7 {
|
||||
execsql {
|
||||
SELECT b FROM collate2t1 WHERE c COLLATE nocase > 'aa' ORDER BY +b;
|
||||
}
|
||||
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
||||
do_test collate2-1.3 {
|
||||
execsql {
|
||||
SELECT c FROM collate2t1 WHERE c > 'aa' ORDER BY 1;
|
||||
@ -169,6 +189,11 @@ do_test collate2-1.5 {
|
||||
SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY 1, oid;
|
||||
}
|
||||
} {}
|
||||
do_test collate2-1.5.1 {
|
||||
execsql {
|
||||
SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY +b;
|
||||
}
|
||||
} {}
|
||||
do_test collate2-1.6 {
|
||||
execsql {
|
||||
SELECT c FROM collate2t1 WHERE c < 'aa' ORDER BY 1;
|
||||
@ -229,6 +254,11 @@ do_test collate2-1.17 {
|
||||
SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY 1, oid;
|
||||
}
|
||||
} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
||||
do_test collate2-1.17.1 {
|
||||
execsql {
|
||||
SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY +b;
|
||||
}
|
||||
} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
||||
do_test collate2-1.18 {
|
||||
execsql {
|
||||
SELECT c FROM collate2t1 WHERE c BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is page cache subsystem.
|
||||
#
|
||||
# $Id: collate3.test,v 1.12 2008/07/12 14:52:20 drh Exp $
|
||||
# $Id: collate3.test,v 1.13 2008/08/20 16:35:10 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -292,19 +292,19 @@ do_test collate3-4.7 {
|
||||
SELECT * FROM collate3t1 ORDER BY a COLLATE user_defined;
|
||||
}
|
||||
} {1 {no such collation sequence: user_defined}}
|
||||
do_test collate3-4.8 {
|
||||
do_test collate3-4.8.1 {
|
||||
db collate user_defined "string compare"
|
||||
catchsql {
|
||||
SELECT * FROM collate3t1 ORDER BY a COLLATE user_defined;
|
||||
}
|
||||
} {0 {hello {}}}
|
||||
do_test collate3-4.8 {
|
||||
do_test collate3-4.8.2 {
|
||||
db close
|
||||
lindex [catch {
|
||||
sqlite3 db test.db
|
||||
}] 0
|
||||
} {0}
|
||||
do_test collate3-4.8 {
|
||||
do_test collate3-4.8.3 {
|
||||
execsql {
|
||||
DROP TABLE collate3t1;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#
|
||||
# This file tests malloc failures in concert with fuzzy SQL generation.
|
||||
#
|
||||
# $Id: fuzz_malloc.test,v 1.9 2007/09/03 15:42:48 drh Exp $
|
||||
# $Id: fuzz_malloc.test,v 1.10 2008/08/20 16:35:10 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -56,6 +56,7 @@ proc do_fuzzy_malloc_test {testname args} {
|
||||
expr srand($jj)
|
||||
incr jj
|
||||
set ::sql [subst $::fuzzyopts(-template)]
|
||||
# puts fuzyy-sql=\[$::sql\]; flush stdout
|
||||
foreach {rc res} [catchsql "$::sql"] {}
|
||||
if {$rc==0} {
|
||||
do_malloc_test $testname-$ii -sqlbody $::sql -sqlprep $::prep
|
||||
|
@ -12,7 +12,7 @@
|
||||
# focus of this file is testing aggregate functions and the
|
||||
# GROUP BY and HAVING clauses of SELECT statements.
|
||||
#
|
||||
# $Id: select5.test,v 1.18 2008/08/02 03:50:40 drh Exp $
|
||||
# $Id: select5.test,v 1.19 2008/08/20 16:35:10 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -159,7 +159,6 @@ do_test select5-5.5 {
|
||||
# Test rendering of columns for the GROUP BY clause.
|
||||
#
|
||||
do_test select5-5.11 {
|
||||
breakpoint
|
||||
execsql {
|
||||
SELECT max(c), b*a, b, a FROM t2 GROUP BY b*a, b, a
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
# focus of this file is testing SELECT statements that contain
|
||||
# subqueries in their FROM clause.
|
||||
#
|
||||
# $Id: select6.test,v 1.27 2008/07/12 14:52:20 drh Exp $
|
||||
# $Id: select6.test,v 1.28 2008/08/20 16:35:10 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -300,7 +300,7 @@ do_test select6-5.2 {
|
||||
|
||||
# Tests of compound sub-selects
|
||||
#
|
||||
do_test select5-6.1 {
|
||||
do_test select6-6.1 {
|
||||
execsql {
|
||||
DELETE FROM t1 WHERE x>4;
|
||||
SELECT * FROM t1
|
||||
|
@ -13,7 +13,7 @@
|
||||
# ORDER BY clauses on compound SELECT statements raised by ticket
|
||||
# #2822 have been dealt with.
|
||||
#
|
||||
# $Id: tkt2822.test,v 1.5 2008/08/04 03:51:24 danielk1977 Exp $
|
||||
# $Id: tkt2822.test,v 1.6 2008/08/20 16:35:10 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -134,12 +134,12 @@ do_test tkt2822-3.2 {
|
||||
# Test that if a match cannot be found in the leftmost SELECT, an
|
||||
# attempt is made to find a match in subsequent SELECT statements.
|
||||
#
|
||||
do_test tkt2822-3.1 {
|
||||
do_test tkt2822-3.3 {
|
||||
execsql {
|
||||
SELECT a, b, c FROM t1 UNION ALL SELECT a AS x, b, c FROM t2 ORDER BY x;
|
||||
}
|
||||
} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}
|
||||
do_test tkt2822-3.2 {
|
||||
do_test tkt2822-3.4 {
|
||||
# But the leftmost SELECT takes precedence.
|
||||
execsql {
|
||||
SELECT a AS b, CAST (b AS TEXT) AS a, c FROM t1
|
||||
@ -148,7 +148,7 @@ do_test tkt2822-3.2 {
|
||||
ORDER BY a;
|
||||
}
|
||||
} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}
|
||||
do_test tkt2822-3.3 {
|
||||
do_test tkt2822-3.5 {
|
||||
execsql {
|
||||
SELECT a, b, c FROM t2
|
||||
UNION ALL
|
||||
|
@ -246,6 +246,8 @@ foreach file {
|
||||
vdbeblob.c
|
||||
journal.c
|
||||
|
||||
walker.c
|
||||
resolve.c
|
||||
expr.c
|
||||
alter.c
|
||||
analyze.c
|
||||
|
Reference in New Issue
Block a user