Compare commits

..

1026 Commits

Author SHA1 Message Date
drh 9b9a61f715 Version 2.8.16 (CVS 2336)
FossilOrigin-Name: 2efbbba55a851a5b83726720aaa9e59b8387556c
2005-02-15 13:07:51 +00:00
drh fb7b4f204b Modifications to the publish.sh script prior to 2.8.16. (CVS 2328)
FossilOrigin-Name: affde4431749e0c57e786cec926895b3c0f8a04f
2005-02-14 05:47:33 +00:00
drh b3dc0431c7 Cleanup the vacuum bug fixes in version 2.8. (CVS 2327)
FossilOrigin-Name: 5658da7e5ae2ee4dc7ec45a1914f766dfb4be323
2005-02-14 00:25:48 +00:00
drh 66a01c4554 Fix the vacuum bug in version 2.8. Also prepare for release 2.8.16. (CVS 2326)
FossilOrigin-Name: 0eaebad5a0242bbdc9c205bf9efeda93bb0a2de9
2005-02-14 00:21:38 +00:00
drh 6f65beb084 Avoid excess heap usage when copying expressions. Ticket #979. (CVS 2126)
FossilOrigin-Name: 0f444c032dded0ea4c5bf47516f37cbd44767689
2004-11-20 20:42:10 +00:00
drh 7a5b729aa7 Preserve the default_temp_store pragma across VACUUM in version 2.8.
(Version 3.0 already does this.)  Ticket #1008. (CVS 2120)

FossilOrigin-Name: 7fa623f24a6c566cb149cfb6515faf489280db97
2004-11-20 19:01:44 +00:00
drh ec88191019 Disable trigger tests that use ATTACH in version 2.8 when there is a
codec enabled. (CVS 2042)

FossilOrigin-Name: f77f7753aaca0b4a147f91e538691cb4ee8995a8
2004-11-02 18:30:44 +00:00
drh e1b6c821d6 Fix naming conflict between sqlite.h and sqlite3.h. Ticket #946. (CVS 2008)
FossilOrigin-Name: e750ae5ab8ed9a2cd38548c63008cc7d2576e26d
2004-10-06 15:52:35 +00:00
drh b2292faf9c Fix for ticket #905. (CVS 1995)
FossilOrigin-Name: bf90799d889ccc88ed7e3635b041d5f38865d447
2004-10-01 15:11:13 +00:00
drh 5cfe9a78f9 Fix a segfault in the authorizer when it is given a SELECT statement with
no FROM clause.  Ticket #896. (CVS 1953)

FossilOrigin-Name: 205d85d77e8f0c9a1d841129601847235052d59f
2004-09-09 13:54:29 +00:00
drh 19aca9eddb Correct handling of quoted names in CREATE INDEX. Ticket #869. (CVS 1907)
FossilOrigin-Name: b01d566580b151db0e1c95d124f20ea0bc889250
2004-08-28 14:53:34 +00:00
drh 85a5dfef26 More fixes to the publish.sh script. (CVS 1863)
FossilOrigin-Name: 022e3f56ac5a29f8449d98630c673edda372d221
2004-07-23 01:10:57 +00:00
drh 82ab315f73 Version 2.8.15 (CVS 1859)
FossilOrigin-Name: 102ab94167448e062333e15159d8199d08ac2677
2004-07-22 18:53:52 +00:00
drh 3ec28d5d81 Fix the publish.sh script so that it builds and packages windows DLLs
correctly. (CVS 1856)

FossilOrigin-Name: 81aa41e7d4e36ba3ecc5ce66c73dae5a607a3963
2004-07-22 18:08:33 +00:00
drh e1175bd650 Another attempt at fixing the memory allocation problem in sqliteExprListDup(). (CVS 1855)
FossilOrigin-Name: 49c2ad8a754daebfdad230dc84e417e3d728c083
2004-07-22 17:10:10 +00:00
drh 0c3ab2d6ac Bug fix in allocation of expression lists after a malloc() failure. (CVS 1854)
FossilOrigin-Name: 09494cab4f53a90e0d84abfec6806b4b2b3e118b
2004-07-22 16:32:13 +00:00
drh 73003316a2 Add join tests to the 2.8 branch. (CVS 1850)
FossilOrigin-Name: e5546f49c79155ed2695a1d58ca8044e79d60802
2004-07-22 16:08:38 +00:00
drh bde845ce70 Update the version number for release 2.8.15. (CVS 1849)
FossilOrigin-Name: 9b3c3ca4aff10c7e395d195cd76a1f3c038cb066
2004-07-22 15:53:37 +00:00
drh 4cf73f61fb Fix an obscure memory leak in the expression list allocator. (CVS 1835)
FossilOrigin-Name: 5c77b332bd7704b754edf6876ae668136b05876f
2004-07-20 02:05:11 +00:00
drh 5d7f6e84f1 Handle quotes on table names in TABLE.* terms in SELECT. Ticket #680. (CVS 1834)
FossilOrigin-Name: 9937ffb08e6eb3a11344d880cade9975e8dc9d5b
2004-07-20 01:45:49 +00:00
drh 8c8ec4fd3e Fix the handling of indices with quoted names. Ticket #695. (CVS 1830)
FossilOrigin-Name: 467309975f40bdc1ac0ed1c9c34d187e91217e12
2004-07-20 00:50:29 +00:00
drh 2d97242175 Comment out all of date/time functions with SQLITE_OMIT_DATETIME_FUNCS.
Ticket #784. (CVS 1829)

FossilOrigin-Name: 28c01d2ac705923d3210ec2b8906541f42ec6f25
2004-07-20 00:40:01 +00:00
drh 0e93442494 Correct handling of views on tables with quoted column names. Ticket #756. (CVS 1827)
FossilOrigin-Name: ef0d5ebe96b9babe275d62ed6abe95652838de5f
2004-07-20 00:20:46 +00:00
drh 9c46d69216 Limit occurs after DISTINCT. Ticket #749. (CVS 1824)
FossilOrigin-Name: db5ae13db3edec82dd2ead3b76fc9f89f33b2dc2
2004-07-19 23:33:02 +00:00
drh a8734da09b Fix for ticket #813. (CVS 1820)
FossilOrigin-Name: 0cc612f8aa458034d3dc246861c529c57ac5b2b1
2004-07-19 19:30:50 +00:00
drh 90ddc11b77 Correctly handle joins of move than 32 tables. Ticket #806. (CVS 1813)
FossilOrigin-Name: 5ba0acd6c788b6ec07b29dc40c17265f8fb8a337
2004-07-19 02:24:02 +00:00
drh 0aaa1c038e Use only unsigned characters in upper() and lower(). Ticket #708. (CVS 1807)
FossilOrigin-Name: f9b2aa8f8a6c0a7f74af2844a80fe14b85d05a45
2004-07-18 23:03:10 +00:00
drh 6951f39c72 The %W date specifier in strftime should be measured from the first Monday
of the year.  Ticket #758. (CVS 1806)

FossilOrigin-Name: 135e5447f66fcd8ec4350c81707a2e8d3c9fd31c
2004-07-18 22:25:15 +00:00
drh 805e7d5b42 Min() and max() ignore NULL values. Ticket #800. (CVS 1803)
FossilOrigin-Name: 223521c04e8ad39e06fee455f7dbb31ace2d3800
2004-07-18 21:14:05 +00:00
drh 06d55ce8f3 Fix for ticket #812 in the 2.8 branch. (CVS 1801)
FossilOrigin-Name: ea364dffc7dfe7533d6916d63db0a79181440e64
2004-07-17 21:59:18 +00:00
drh 24b8cb36bc Make SrcList.nSrc a signed quantity to avoid problems on AIX. (CVS 1795)
FossilOrigin-Name: 41526d098dcae6def4940cd464d0e1e673c6abb5
2004-07-15 13:37:04 +00:00
drh afcfc0eecb Correct return type on sqliteStrICmp() when argument strings differ.
Ticket #804. (CVS 1793)

FossilOrigin-Name: 296528b281025d86650cf0e4c17e75c296e03310
2004-07-15 13:08:41 +00:00
drh ea024eee62 Fold in changes submitted by the PHP developers. (CVS 1742)
FossilOrigin-Name: a4a2570822f13ece2174438ef8f8a6175aaa4a6b
2004-06-26 14:40:05 +00:00
drh ca69323478 The MIN() aggregate function returns NULL if any element in the result
was NULL.  This makes MIN() consistent with ORDER BY which sorts NULL first.
Ticket #777. (CVS 1679)

FossilOrigin-Name: 78ced6e3092d69e7cb77c5c2acff70f3c92e6523
2004-06-23 21:16:51 +00:00
drh 52e50d6aaa Add the source code to the sqlite_analyzer utility. (CVS 1637)
FossilOrigin-Name: 06bf4c7e41839eb003f3df05a80789a1f2b21b8f
2004-06-19 11:57:39 +00:00
drh 0f156745bd Fix a compiler warning in os.c. (CVS 1636)
FossilOrigin-Name: 28b737b5a0e07a142396809f8a7dbd985d433c0d
2004-06-19 11:57:08 +00:00
danielk1977 f4ed02a34f Backport of (1628) to version 2. (CVS 1631)
FossilOrigin-Name: cce250eaee59eac2d15437b564f049c5b241317c
2004-06-19 04:23:25 +00:00
drh 463ff298d6 Update the publish.sh script so that it no longer generates documentation
pages (that is handled by the version 3.0.0 publish.sh).  Also insert
version numbers in the filenames of all build products. (CVS 1601)

FossilOrigin-Name: f2b8d35825a2137e83419e9aebc9619a9db2ada8
2004-06-16 01:21:00 +00:00
drh 5d5398b089 Do not authenticate statements when reading the schema. Backport of bug
fix in (1588) to version 2. (CVS 1591)

FossilOrigin-Name: 24adf9ed5988d6e110a750f75b767fad163689c6
2004-06-14 11:58:37 +00:00
drh f3a5a57ddb Version 2.8.14 (CVS 1554)
FossilOrigin-Name: 7d3937743f88acad8859fbbbb1c03271a939bc0b
2004-06-09 23:20:05 +00:00
drh 1832890357 Update the version number to 2.8.14. For whatever reason, the version at
the tip of the 2.8 branch fixes ticket #757. (CVS 1552)

FossilOrigin-Name: 7538d2e5297bdeaf07c6d6e37053c654501ef286
2004-06-09 22:49:56 +00:00
drh 97117601d2 Calling sqlite_interrupt() while VACUUM is running should not cause an error. (CVS 1529)
FossilOrigin-Name: 1cf94a7c41b56506251a9964f133e179bd06825f
2004-06-04 19:07:53 +00:00
drh f9ec81c84d Improvements to testing of sqlite_interrupt. More checking for interrupt
inside of VACUUM. (CVS 1344)

FossilOrigin-Name: d596f513c3acfe0d297dc3f5c66f4b0ea2d12a34
2004-05-10 20:27:41 +00:00
drh 45041e263a Fix a memory leak in DETACH when using the codec. (CVS 1317)
FossilOrigin-Name: c4bd99b79c66217140781309ed06e1ff3ef4a206
2004-05-07 01:46:01 +00:00
drh 3e5c826219 Add the sqlite_temp_directory global variable which, if set, defines the
directory in which temporary files are created. (CVS 1316)

FossilOrigin-Name: c90ed20dc4f95eb06a5259578597593f5968bfb7
2004-05-07 00:57:06 +00:00
drh 4e0e4d7a9e Fix a stack overflow problem with INSTEAD OF triggers. (CVS 1310)
FossilOrigin-Name: 5a33e0b06f495628704d0881940a792f342facc7
2004-04-29 16:16:29 +00:00
drh 064cf76bb1 Changes to lemon.c so that it compiles on OpenWatcom 1.3. Ticket #665. (CVS 1307)
FossilOrigin-Name: b8b8ce5c81ef614d488e0f79df8935ef609dc4f2
2004-04-24 12:59:13 +00:00
drh a38518d673 Add some extra debugging logic to lemon.c. Ticket #692. (CVS 1304)
FossilOrigin-Name: 635f674d20ca3e0b534eba54313004e859de16e9
2004-04-23 23:37:56 +00:00
drh 1bdd9b5787 Get the temp_store and default_temp_store pragmas working. Update the
documentation.  Also fix a malloc problem that popped up during the regression
testing. (CVS 1302)

FossilOrigin-Name: 7ace576215367101904677bd69951755ee9cb1a1
2004-04-23 17:04:44 +00:00
rdc 932ee8f4bb Fix windows DLL section of Makefile.in for use with build dir. (CVS 1301)
FossilOrigin-Name: 1e84f70fb98755651e0c04dc2cf0114e2e6fe39c
2004-03-26 23:16:31 +00:00
drh d888544275 Change the ".database" command in the shell to allocate more characters to
the database name and filename. (CVS 1300)

FossilOrigin-Name: 85238f06902851dd5085395501a0ab2d6a2b9814
2004-03-17 23:42:12 +00:00
drh 8b8891bf0a Fix a VDBE stack overflow that occurs when the left-hand side of an IN
expression is NULL and the result is stored on the stack rather than used
to control a jump.  Ticket #668. (CVS 1299)

FossilOrigin-Name: fc7a7975b03c144c2db3566facd008d3701c735e
2004-03-17 23:32:08 +00:00
drh 276fd588d8 The sqlite_trace() API only works for commands started by the user, not for
SQL commands run during initialization. (CVS 1298)

FossilOrigin-Name: 0a12473c4ae370ec34f1f431dd6d7d6ffa25d41a
2004-03-17 18:44:45 +00:00
dougcurrie a8804c82b8 Makefile.in and sqlite.def changes for encode and non-toplevel build; ticket #667 (CVS 1297)
FossilOrigin-Name: 72205a371ce5be4eac0a77d5d2fa8ccb23bb988f
2004-03-16 21:49:49 +00:00
drh 6ff15d0c49 Prototypes for sqlite_encode_binary() and sqlite_decode_binary() added
to sqlite.h. (CVS 1296)

FossilOrigin-Name: 359f0e787ff2d4d10fd23059e2ce99670e93f66a
2004-03-14 22:12:34 +00:00
drh 6da834a8b4 Make sqlite_encode_binary() and sqlite_decode_binary() an official part of
the library. (CVS 1295)

FossilOrigin-Name: 786fe545560ec6c42bb0e344345031f425bf177a
2004-03-14 22:11:59 +00:00
drh 371cb93a2a Updates to the architecture document. (CVS 1294)
FossilOrigin-Name: c661cc81b6981c536c107f40525ad9783b11ea82
2004-03-14 11:57:58 +00:00
drh 6e17529e97 Fix the min/max optimizer so that it works when the FROM clause is a
subquery.  Ticket #658. (CVS 1293)

FossilOrigin-Name: 31c94acc72d318b5dec0fef1485621943add45c8
2004-03-13 14:00:36 +00:00
drh 1a72d72a7f Typecast to work around a bug in {quote: CodeWarrior} Studio v9.1.
Ticket #654. (CVS 1292)

FossilOrigin-Name: 5864fc6937b933b7da0c00e6c4c2ee1b9b939cff
2004-03-10 18:57:31 +00:00
a.rottmann 7972e32a9e Fixed default target. (CVS 1291)
FossilOrigin-Name: af19ab32c5b329b053f3daf3c812eb593b89cd7f
2004-03-10 18:53:09 +00:00
a.rottmann 66eb270d6b * Added rule for rebuilding Makefile from Makefile.in.
* Fixed double-slash problem induced by adding DESTDIR support. (CVS 1290)

FossilOrigin-Name: 957827e35cca65de11894eb2dfc78327f4034dfc
2004-03-10 16:32:03 +00:00
drh a0c9a112de The BTree layer now returns SQLITE_READONLY on an attempt to open a write
cursor on a read-only database.  Previously, the failure would not occur
until there was an attempt to write to the cursor. (CVS 1289)

FossilOrigin-Name: 8a8be4687bf9fd88952b303f30f93aa6fed75b60
2004-03-10 13:42:37 +00:00
drh 06333689a7 The shell program now ignores extra whitespace at the end of dot-commands. (CVS 1288)
FossilOrigin-Name: b6817e99bd97f427b1cfd16328d612e1a7d70d0a
2004-03-09 13:37:45 +00:00
drh a2cfd57491 Version 2.8.13 (CVS 1287)
FossilOrigin-Name: 4d5bbb3dc32412ee7fa5dec42d3278836a362e8c
2004-03-08 13:57:54 +00:00
drh e3f25eb91e Update change log for version 2.8.13. (CVS 1286)
FossilOrigin-Name: 4431e63746311d2e3429203656f8168c227ecb6e
2004-03-08 13:45:24 +00:00
drh 489c4677a0 Bump the version number to 2.8.13. Patch up the limit test so that it works
in spite of ticket #521 - we don't want any tests failing in an official
release even if there are bugs. :-D (CVS 1285)

FossilOrigin-Name: 2c6bd21ed0e212109cfb4a37cfac2a10ab58a024
2004-03-08 13:26:17 +00:00
rdc aa5707cd5e Correct duplicate tracing of SQL statements. (CVS 1284)
FossilOrigin-Name: bb67311b3db49ce772533da14f62497c55432fae
2004-03-04 19:09:20 +00:00
drh 79f14b7240 A vdbe stack element might have a string value even after a call to
Integerify().  Ticket #641. (CVS 1283)

FossilOrigin-Name: 3cac4b7b526d6c5dbf394009b534707bcb65b0da
2004-03-03 01:51:24 +00:00
drh b1aa04fccc Make sure a LIMIT clause on a SELECT cleans up the vdbe stack so that if it
occurs inside a trigger, it won't cause a stack overflow.  Ticket #640. (CVS 1282)

FossilOrigin-Name: 5aaa2939baa972231def086ed5f9d9ba63302532
2004-03-02 18:37:41 +00:00
a.rottmann 9bc8b93f41 Updated aclocal.m4 and configure. (CVS 1281)
FossilOrigin-Name: 76d42921a475c531a77677c3fe73b6da265a878d
2004-02-29 15:18:31 +00:00
drh 0d131ab716 One more fix to the new HH:MM:SS modifier. This time add some test
procedures too. (CVS 1280)

FossilOrigin-Name: 7b3b8968ee9a5349dd6e9ae1e7a311bf8906607c
2004-02-29 01:08:17 +00:00
drh b6829e94bd Try again to get the HH:MM:SS modifier change right... (CVS 1279)
FossilOrigin-Name: e20d51f94ed67b8864a435e5735f61f396662c21
2004-02-29 00:50:33 +00:00
drh 446536a089 Fix a bug in the HH:MM:SS modifier change that was just checked in. (CVS 1278)
FossilOrigin-Name: 248b5500900bc8f401006aaa9b7dac090ae419fa
2004-02-29 00:48:08 +00:00
drh 33a9ad2f8c Allow time modifiers of the form HH:MM:SS.SSS with an option "+" or "-"
prefix.  The specified amount of time is added into the date-time begin
modified. (CVS 1277)

FossilOrigin-Name: 559002a52fe3c42fe71ffce364eff4a036ae6b83
2004-02-29 00:40:32 +00:00
drh 3039c0a896 Fix some compiler warnings in LCC. The warnings did not indicate real
problems.  Ticket #634.  Not all warnings in ticket #634 were fixed. (CVS 1276)

FossilOrigin-Name: e97089b7df3e2fbfcf36062099d02ecb75e9a870
2004-02-29 00:11:30 +00:00
a.rottmann 1d78a38f51 Make Windows .dll build use the real .o files, not the libtool-faked .lo
ones. (CVS 1275)

FossilOrigin-Name: cce5bbf49b0a30c40d24a559bc6cb4585dd9aea5
2004-02-28 18:02:20 +00:00
a.rottmann 964dbb1e6c Build system update:
* Update of generated/libtoolized files: config.guess, config.sub,
   configure, ltmain.sh
* Removal of libtool, which is generated by configure
* Changes to Makefile.in, adding better support for newer libtools (CVS 1274)

FossilOrigin-Name: 22d63bbf78997f0b31bb39054fbcfccf9d974bd6
2004-02-26 19:47:42 +00:00
rdc f146a77677 Add comments and prototype for experimental sqlite_last_statement_changes() API function. Also, allow function to be called from tcl. (CVS 1273)
FossilOrigin-Name: ca99920b0dbf773962b47766d690154fd1276513
2004-02-25 22:51:06 +00:00
drh 268380ca9e Min() and max() functions honor the distinction between TEXT and NUMERIC
data.  Ticket #623.  typeof() is now a user function.  Some tests are
now failing due to ticket #521. (CVS 1272)

FossilOrigin-Name: adbe31adf1ad0ca723203ca3d7dc480324c60d43
2004-02-25 13:47:31 +00:00
drh d41d73d556 Fix the return type of sqliteRunVacuum. Ticket #627. (CVS 1271)
FossilOrigin-Name: 9c9f4a867a4ea708847cbb0839b7279eb33ecd7c
2004-02-25 02:33:34 +00:00
drh f73287ceb0 Shell program saves command-line history on a ".quit". Ticket #614. (CVS 1270)
FossilOrigin-Name: 114b72f8608b8e08fad863a1446fb1ef59610efd
2004-02-25 02:25:37 +00:00
drh 946966f2a1 Disable an assert which (as it turns out) is not always true. Ticket #615. (CVS 1269)
FossilOrigin-Name: 2773c1d384b750eee037e6ccc61bc56b5204d690
2004-02-25 02:20:41 +00:00
drh cd44690ad0 Refactor parts of write operations. (CVS 1268)
FossilOrigin-Name: 5b0147aece7785373e6f7439c32e5f58c6b12562
2004-02-24 01:05:31 +00:00
drh 02f75f19e5 Make sure BEGIN, COMMIT, and ROLLBACK are really no-ops when preceded
by EXPLAIN.  Ticket #626. (CVS 1267)

FossilOrigin-Name: 2af1f065b5eb39fd3ecac00f8a66d1b4186aead5
2004-02-24 01:04:11 +00:00
drh 701a0aebe2 Use sqliteVdbeOp3 instead of sqliteVdbeChangeP3 where applicable. (CVS 1266)
FossilOrigin-Name: 51f1e8f7539596b33bc3365ec8f34041602d049c
2004-02-22 20:05:00 +00:00
drh d383401c6a Code cleanup in build.c. (CVS 1265)
FossilOrigin-Name: 9211e14cf81f4de125bad246d8a289786f2854aa
2004-02-22 18:56:49 +00:00
drh f7a9e1ac87 Use sqliteErrorMsg instead of sqliteSetString whereever practical. (CVS 1264)
FossilOrigin-Name: 69aac043af7f93e7b3f036622c0ac9261cae1839
2004-02-22 18:40:56 +00:00
drh eb9a9e8888 Code cleanup in the date and time functions. (CVS 1263)
FossilOrigin-Name: 9b3bcde1530091602e551435ffd7820eb79727d5
2004-02-22 17:49:32 +00:00
drh 2d3917da29 Rearrange the grammar some so that tokens that are used together appear
together in the grammar file.  This reduces the size of the parser tables
and some of the jump tables in switch statements. (CVS 1262)

FossilOrigin-Name: d372c16ec6621dbab371bff7f1803ca096862984
2004-02-22 16:27:00 +00:00
drh 60d316542f Do not sort terminal symbols by name. The terminals remain in the same order
that they are encountered in the grammar file.  This results in parse tables
that are 25% smaller. (CVS 1261)

FossilOrigin-Name: f36b122d9767fa9e6dc5bcce04b5606d67cad3d9
2004-02-22 00:08:04 +00:00
drh b621c23775 Test cases for printf of double overflows. (CVS 1260)
FossilOrigin-Name: 96a6d2d3ff5bd0aaff188ee1c5e2f02cbea435b2
2004-02-21 19:41:04 +00:00
drh 3e7bc9ca1c Fix a long-standing memory leak that the new last_insert_rowid() tests
brought to light. (CVS 1259)

FossilOrigin-Name: 7d5ede5b6ef515808995d4631f8d19aca95a9105
2004-02-21 19:17:17 +00:00
drh 5f968436e6 Cleanup the printf code to make it smaller and more modular.
Fix a memory leak in the new OP_ContextPush opcode. (CVS 1258)

FossilOrigin-Name: 2756f7af3382fa9d186ab99cf76f469fb891a3c3
2004-02-21 19:02:30 +00:00
drh 8722318f3c Flag pragmas like vdbe_trace now return their current setting if they
are called with no arguments. (CVS 1257)

FossilOrigin-Name: 6a5fb5b89a98307060bb4a92a499b5d3dba74553
2004-02-21 14:00:29 +00:00
drh 905793e249 More code cleanup and size reduction. (CVS 1256)
FossilOrigin-Name: 8e3eda2a909bd80b2b14ace36ab44303750a4409
2004-02-21 13:31:09 +00:00
drh 8eb2cce55c Enhance date/time functions to work with negative years. Ticket #617. (CVS 1255)
FossilOrigin-Name: ffa971934867b6bbe943c004154d5f161e0ea697
2004-02-21 03:28:18 +00:00
drh 8307ac7521 Turn the short_column_names pragma off by default - for the time being. (CVS 1254)
FossilOrigin-Name: 6954d2c3240459842be655b600c6b160e918e74a
2004-02-20 23:34:07 +00:00
rdc 9d524f6b9c Add sqlite.def file required for correct operation of "make implib" option in Makefile.in (CVS 1253)
FossilOrigin-Name: b1b23c410260293f57614f32232cf1276f41c16b
2004-02-20 22:55:41 +00:00
rdc a503d7312a Fixed behaviour of last_insert_rowid() with triggers and add last_statement_change_count() function that works correctly with triggers. (CVS 1252)
FossilOrigin-Name: 6734c923395ca41ce453f56dd7d6e7794fbb3bb5
2004-02-20 22:54:25 +00:00
rdc b0c374ffbb Fixed behaviour of last_insert_rowid() with triggers and add last_statement_change_count() function that works correctly with triggers. (CVS 1251)
FossilOrigin-Name: 3383413a53bff0fef0765144de3bb9a298a5bb5c
2004-02-20 22:53:38 +00:00
drh fcabd4641e The name of a result column is now the name of column it originated from, by
default.  This can be turned off with PRAGMA short_column_names=OFF.  This
is to be more like PostgreSQL.  More testing needed. (CVS 1250)

FossilOrigin-Name: 574dd444e7ff00e0fccc3436fe617ad832daae40
2004-02-20 14:50:58 +00:00
drh 784d86f716 Fix a bug in the parser table compression algorithm of lemon. (CVS 1249)
FossilOrigin-Name: 8d3e924975681a871e0eeac3b6a62cffdb947ac7
2004-02-19 18:41:53 +00:00
drh 9cbe7ca7db Fix a memory leak that occurs if you call sqlite_interrupt() on a query
using aggregate functions where the aggregate function returns a string
longer than 32 characters. (CVS 1248)

FossilOrigin-Name: 2c1e74e58a702fd2be954467a12e69a33b252831
2004-02-18 16:57:23 +00:00
drh fef9765507 Begin updating the architecture description to better describe how things
are currently put together. (CVS 1247)

FossilOrigin-Name: 062ecc1368d6bb6d15da31e8d6f5953e8f5628b9
2004-02-18 16:56:32 +00:00
drh 230680276c Add more tests of the sqlite_interrupt() logic - looking for a reported
memory leak.  (Didn't find it.) (CVS 1246)

FossilOrigin-Name: e4c8b1c3aa9d288f518c6394187354e6fa18978e
2004-02-18 01:31:53 +00:00
dougcurrie 960ac04f4f Avoid line endings munging by Cygwin; ticket #370 (CVS 1245)
FossilOrigin-Name: 50e67948f89380f2f4b536add0b8179e6db960a5
2004-02-17 18:26:57 +00:00
drh d6502758b4 Remove the NullCallback opcode. Handle the empty_result_set pragma inside
the sqlite_exec() function. (CVS 1244)

FossilOrigin-Name: f72134852bf33d13fd2bc6f35251e4b33bc10fac
2004-02-16 03:44:01 +00:00
drh 826fb5a3f8 Eliminate obsolete code associated with the older callback functionality. (CVS 1243)
FossilOrigin-Name: 2dbc4593ca5c1cf75039c8b4471b1e47faa849f0
2004-02-14 23:59:57 +00:00
drh 1d85d93158 Eliminate the use of callbacks during schema initialization. (CVS 1242)
FossilOrigin-Name: af5c2be4aed1c50f69eb9634cf051a26263dcf51
2004-02-14 23:05:52 +00:00
drh 8a6ac0adbc Fix problems with malloc-failure handling. (CVS 1241)
FossilOrigin-Name: 398bc294c839368e7fa75a97ba8cc8d1639f9436
2004-02-14 17:35:07 +00:00
drh a1f9b5ee0b The sqlite_exec() function is now implemented using sqlite_compile() and
sqlite_step().  This opens up lots of opportunity to remove old code. (CVS 1240)

FossilOrigin-Name: 9771ad1e811e02e10bb738550fbea447749083c5
2004-02-14 16:31:02 +00:00
drh b5f70c2ef1 Disable the malloc.test tests if not compiled with -DMEMORY_DEBUG (CVS 1239)
FossilOrigin-Name: 41b6ad78a6097f35bfac6ff40d2e5d6071a1c4cd
2004-02-14 01:39:50 +00:00
drh eceae45cb5 Fix an uninitialized variable in shell.c that would cause a crash if you
specified SQL on the command-line. (CVS 1238)

FossilOrigin-Name: 5a56090dde10ee29863021356d21c3f8c86e3f46
2004-02-13 20:09:41 +00:00
drh e72daeb0ac Begin the process over converting sqlite_exec() over to use sqlite_compile()
and sqlite_step().  The new sqlite_exec() is still commented out. (CVS 1237)

FossilOrigin-Name: b8f2ba7880b761e380b95ae63d8ab721f018443e
2004-02-13 16:30:09 +00:00
drh 50350a15c4 Fix a bug in the query flattener when trying to find the datatype of the
rowid of a view.  Also fix a problem with sqlite_compile() and authorization
failures. (CVS 1236)

FossilOrigin-Name: aa0490ccd4a820a707dfb4905e67c01ffb4f758b
2004-02-13 16:22:22 +00:00
drh 78a7583828 Fix an uninitialized variable introduced by check-in (1202). (CVS 1235)
FossilOrigin-Name: 9f149fdc1c6af1c663b91c878ed1903f82f80245
2004-02-13 14:07:12 +00:00
drh e384a4ed4e Add a new parameter to the (unimplemented) encryption API. (CVS 1234)
FossilOrigin-Name: 5fe8f02306cf1c0af2148835cee0df3003ad0874
2004-02-12 20:49:36 +00:00
drh c602f9ae01 Add the SQLITE_NOTADB return code for cases when you try to open a file
that does not even remotely resemble an SQLite database file. (CVS 1233)

FossilOrigin-Name: 0c77cee70f078152969933c1d340cea1c86286b0
2004-02-12 19:01:04 +00:00
drh 4d189ca48f Add hooks on each attached database connection for storing auxiliary
information.  Add the USING clause to ATTACH. (CVS 1232)

FossilOrigin-Name: 800c11f4bce014a07110eb539992a609e6418406
2004-02-12 18:46:38 +00:00
drh 3054efee07 All REPLACE INTO syntax inside of triggers. Ticket #610. (CVS 1231)
FossilOrigin-Name: a6b862a9db6d409a53cc13e7008b27d4848b5509
2004-02-12 17:28:13 +00:00
drh 70a931c2ac Remove unused variable. (CVS 1230)
FossilOrigin-Name: 74b234264ba2910ebd38e7b7ebbc369108a235cb
2004-02-12 15:32:53 +00:00
drh 8ef83ffed8 Always reload the schema after a rollback. Ticket #594. (CVS 1229)
FossilOrigin-Name: 12c7a83f8e4055c4590983ef212648c781ebd963
2004-02-12 15:31:21 +00:00
drh 93581642d2 VACUUM returns SQLITE_INTERRUPT when interrupted. Ticket #593. (CVS 1228)
FossilOrigin-Name: 2fe9f5101cb0f743532912ece3d37f6c873e7025
2004-02-12 13:02:55 +00:00
drh ab9426e242 Only define _FILE_OFFSET_BITS if it is not already defined. Ticket #605. (CVS 1227)
FossilOrigin-Name: 300c5543dc83c6b7eacb0c81ed06f95004c0f6d8
2004-02-11 16:38:06 +00:00
drh eb8ed70db5 Fix the shells so that they always enable the codec if it is available,
even if no key is supplied. (CVS 1226)

FossilOrigin-Name: 95989717e17d52b2306374f5cf7613c3bd4e7801
2004-02-11 10:37:23 +00:00
drh 7e26d75094 Fix an uninitialized variable in expr.c. Ticket #604. (CVS 1225)
FossilOrigin-Name: 1673bf7c7b64542530ee03328186be33cb88c98d
2004-02-11 10:35:29 +00:00
drh bbd82df617 Refactor the interface to the randomness generator. (CVS 1224)
FossilOrigin-Name: f2bdccf4bb2f796aafb64c33e55f62a1794d750c
2004-02-11 09:46:30 +00:00
drh 9eb9e26b82 Pass all (relevant) regression tests when using the codec. (CVS 1223)
FossilOrigin-Name: 5200e9edc5fdba0285a3cb1cd808cbf66d7a349e
2004-02-11 02:18:05 +00:00
drh d86a39c866 Adjustments to the codec in the pager. (CVS 1222)
FossilOrigin-Name: be5122e99caacbeb5e568a2782fe2faf634ad355
2004-02-10 23:51:05 +00:00
drh fb044c1d1c Perform updates in search order. Ticket #602. (CVS 1221)
FossilOrigin-Name: cf1cec74ae039cd7cbc8a1032d29f067dedb4210
2004-02-10 13:41:52 +00:00
drh 4bc058593b Fix for ticket #603. (CVS 1220)
FossilOrigin-Name: d0624d257789ac3f4cd3a7473bb741030c999b65
2004-02-10 13:19:35 +00:00
drh 57ced9186a Make the pager accessible from the btree structure always, not just during
debugging. (CVS 1219)

FossilOrigin-Name: 9c6b4758a4b13a91f71be17751a76c0c14b4d4c3
2004-02-10 02:57:59 +00:00
drh 2d71ca94a9 Move the file-format-2 to file-format-3 conversion into sqliteInit(). (CVS 1218)
FossilOrigin-Name: dcbe2800be2f805818724a7b9e468c4fd4f02529
2004-02-10 02:27:04 +00:00
drh d0ba193dc7 Allow SQLITE_PAGE_SIZE to be redefined on the compiler command-line. (CVS 1217)
FossilOrigin-Name: 4c7bf714b5f3d2bb7366367ddf906141a7e36407
2004-02-10 01:54:28 +00:00
drh f620b4e2cb After code is generated for a subquery, delete the Select structure in order
to force the temporary table to be used and to prevent the subquery from
being evaluated a second time.  Ticket #601. (CVS 1216)

FossilOrigin-Name: 1cff18868dab5f8ead8ed8d07e088d7fdda04569
2004-02-09 14:37:50 +00:00
drh e2201971ac Add test case for ticket #601. (CVS 1215)
FossilOrigin-Name: 096312dacb9eb2f8da3cec1504aef8629b505e7f
2004-02-09 14:35:28 +00:00
drh b20ea9d225 Add an optional codec to the pager layer. (CVS 1214)
FossilOrigin-Name: 2f0c122cfb84dea58d112324a0bdd8b85552a9fa
2004-02-09 01:20:36 +00:00
drh 8e6283155e Version 2.8.12 (CVS 1213)
FossilOrigin-Name: 1736d415d776aa1cbdd33d987d21365ebf260f11
2004-02-08 18:10:50 +00:00
drh f603871326 Perpare for the 2.8.12 release. (CVS 1212)
FossilOrigin-Name: 93ccd1b1d63b5b914b84b0463f2267bcfaadafa3
2004-02-08 18:07:34 +00:00
drh f1b07b0ca2 Fix a bug in the VDBE that occurs when a CreateTable or CreateIndex fails. (CVS 1211)
FossilOrigin-Name: 42cfd541dcc31d1ef92387e3fd2346db61d0ecbd
2004-02-08 06:17:19 +00:00
drh 585a3d7c22 Add the crashtest1.c program used to test the ability of the database to
survive a program crash or power failure.  Ticket #599. (CVS 1210)

FossilOrigin-Name: 597a59a72d662b291fb09a069547efd08aa5adb1
2004-02-08 06:06:37 +00:00
drh 34e79ceeb6 Fix inaccuracies and add details to comments in the pager. Change the name
of one function to make its purpose clearer.  Ticket #599. (CVS 1209)

FossilOrigin-Name: 48832d35ed0d5ba02908822c749591e76b790c48
2004-02-08 06:05:46 +00:00
drh 240c5795d5 Preliminary fix for ticket #599. More testing and analysis needed. (CVS 1208)
FossilOrigin-Name: dc5be2c82b591a385adf02863d89e113272e2ebd
2004-02-08 00:40:52 +00:00
drh e84a306b91 Remove undocumented extensions from sqlite_mprintf() and friends in order to
make it about 10% smaller. (CVS 1207)

FossilOrigin-Name: 0b3f552b986fd89c48c350b0746be93b9d276ecc
2004-02-02 12:29:25 +00:00
drh 22fbcb8ddd Fix the handling of -init option to the sqlite shell. Ticket #568.
Also add hooks for encrypting the database. (CVS 1206)

FossilOrigin-Name: 3c796de8d1af55944f396f08feaa9e69c1652896
2004-02-01 01:22:50 +00:00
drh 3914aed1de Fix a bug introduced by the previous check-in. (CVS 1205)
FossilOrigin-Name: 04cf22785e68fcd4098e6c10a89386108cd0bf07
2004-01-31 20:40:42 +00:00
drh 2c79c67fcb A few more optimizations to the VDBE. (CVS 1204)
FossilOrigin-Name: 06e7ff4cb8c73fd690c6d5b5f530a30d83f4f10c
2004-01-31 20:20:29 +00:00
drh 6810ce677d Rework internal data structures to make the VDBE about 15% smaller. (CVS 1203)
FossilOrigin-Name: 8273c74bd09d1a044cb5154498b0a39939f6e3ed
2004-01-31 19:22:56 +00:00
drh 00706be366 Rework the VDBE data structures to combine string representations into the
same structure with integer and floating point.  This opens the door to
significant optimizations. (CVS 1202)

FossilOrigin-Name: c0faa1c67a967f028cd018e58988fb08bc814d3d
2004-01-30 14:49:16 +00:00
drh 0c37e6309b Make sure min() and max() optimizations work for subqueries. Ticket #587. (CVS 1201)
FossilOrigin-Name: af73fbca839f8cbe39c21f1f9e439fe9b79005c8
2004-01-30 02:01:03 +00:00
drh e8a63423da Change permissions on the install-sh file to be executable. Ticket #582. (CVS 1200)
FossilOrigin-Name: eafa714d1f0abe7e4822a6d137c2a7c6179ffab3
2004-01-27 17:46:55 +00:00
drh 11437fa6b1 Add a web page describing when it is appropriate to use SQLite and when it
is not. (CVS 1199)

FossilOrigin-Name: d77e47764818ef495894013fb26b1a510f2f1a7e
2004-01-27 15:58:37 +00:00
drh 8141f61ef2 Modularize the column name resolution code so that it is smaller, faster,
and ready for some enhancements that will fix long-standing name
resolutions problems. (CVS 1198)

FossilOrigin-Name: d3648034b409822909d79eb5aa4e64cafa986541
2004-01-25 22:44:58 +00:00
drh b733d03749 Add the ability to group FROM terms using parentheses. Names of columns in
a join no longer include the table name. (CVS 1197)

FossilOrigin-Name: 3626f6d4a1adb4209d5bd9e6477343b52bddbdf2
2004-01-24 20:18:12 +00:00
drh a8d6243bc7 Fix typo. Ticket #577. (CVS 1196)
FossilOrigin-Name: 3dc951951947a9188ecba1b84e48c65e34c4df16
2004-01-22 23:38:21 +00:00
drh 30c84bfd5f In test programs, an SQLITE_SCHEMA return is retried repeatedly, not just once. (CVS 1195)
FossilOrigin-Name: df3509e13dc05751b7a5af07b57bca449fe5244c
2004-01-21 13:35:13 +00:00
drh 0bca353087 Make ATTACH and DETACH work with the non-callback API. Ticket #574. (CVS 1194)
FossilOrigin-Name: c32a80fe3cd6dda5238e59bd48d9dd22b4856304
2004-01-20 11:54:03 +00:00
jplyon a8fbdd36f8 documented pragma foreign_key_list().
updated docs for removed behavior: Oracle join syntax and temp indexes. (CVS 1193)

FossilOrigin-Name: 06bd5070966b59730a91bc4d384df4f8abaadd37
2004-01-19 05:09:24 +00:00
jplyon 4b11c6d3f4 comment typos (CVS 1192)
FossilOrigin-Name: 7972ee321974380a59fef752f5643d98f9df38cc
2004-01-19 04:57:53 +00:00
jplyon cfa5684d47 comment typos (CVS 1191)
FossilOrigin-Name: de35c36ed7657903ebba0c5acff75baaa0453f87
2004-01-19 04:55:56 +00:00
jplyon 8bc03a7acd coment typo (CVS 1190)
FossilOrigin-Name: 0d2683dc5ecb886ae9625484b51e65df49b3235d
2004-01-19 04:54:28 +00:00
jplyon b6c9e6e6c1 coment typo (CVS 1189)
FossilOrigin-Name: 8210b2d818ab83a97b3b71b432770436116f4770
2004-01-19 04:53:24 +00:00
jplyon b1639ffeb5 comment (CVS 1188)
FossilOrigin-Name: fa55c9861e1cc372a36958383a86895dc311bb4b
2004-01-19 04:52:29 +00:00
drh 4d5b836545 Do not use strcpy() on overlapping buffers. (CVS 1187)
FossilOrigin-Name: ed6bd2eb39a0940c4f41d365ddc81ecc7066cf4e
2004-01-17 01:16:21 +00:00
drh 606c369847 Access to free()ed memory problem fixed. Found by electric fence.
Only an issue when doing an EXPLAIN of a CREATE INDEX. (CVS 1186)

FossilOrigin-Name: 6604e5f7d332b484e84d177f93c9d9f2ab54a32b
2004-01-16 20:01:31 +00:00
dougcurrie a70f2d8d72 See ticket #569; eliminates warnings for Cygwin v1.5 and above. (CVS 1185)
FossilOrigin-Name: a0f8b1f3cea9a0542f8d36898bf98df3c59f12e0
2004-01-16 19:11:28 +00:00
drh 51e9a44592 More compaction of expr.c. (CVS 1184)
FossilOrigin-Name: 92e7f78057c4e8f6214b6e0a2d80c3ffcbfdf68e
2004-01-16 16:42:53 +00:00
drh 4efc4754f3 Incremental code compaction in expr.c. Now about 4% smaller.
Lots more work to do. (CVS 1183)

FossilOrigin-Name: d292ba5148059dce3893b80eabdca4af9f75194e
2004-01-16 15:55:37 +00:00
drh 1dba727946 Fix a buffer-overflow problem in the randStr function (used only for testing). (CVS 1182)
FossilOrigin-Name: 42c79edc2e8d1051b3bca915b4b205c601b8077f
2004-01-16 13:58:18 +00:00
drh d1bec47a3d More aggressive retry schedule in sqlite_busy_timeout(). (CVS 1181)
FossilOrigin-Name: 5e85025be7aa4a03b0cfb4d0f28a2e44653b9d3f
2004-01-15 13:29:31 +00:00
drh 23b2db23b4 Allow "<expr> IN <table>" as a shorthand for
"<expr> IN (SELECT * FROM <table>)" (CVS 1180)

FossilOrigin-Name: 01874d252ac44861e927dea3f5534f67e19b1fa8
2004-01-15 03:30:24 +00:00
drh aa940eacfe Reinsert the experimental sqlite_commit_hook() API. (CVS 1179)
FossilOrigin-Name: 72bc84f2f18f6eeb279a4ad670310e85d154f663
2004-01-15 02:44:03 +00:00
drh 751f41217e Fix comparisons of ROWID against floating point numbers so that they work
correctly.  Ticket #377 and #567. (CVS 1178)

FossilOrigin-Name: c9ac3db8e08403398ec344757385334601a59374
2004-01-14 21:59:22 +00:00
drh d43ce86fa7 Version 2.8.11 (CVS 1177)
FossilOrigin-Name: a9f25347de6d2bf843a8aebf7935e9c8a1f2319c
2004-01-14 13:50:59 +00:00
drh 0ee7ae0f0d Bump the version number for the next release. (CVS 1176)
FossilOrigin-Name: 2812dd5fc99c959f41b24b0f6b280b67b06fe9d9
2004-01-14 13:43:43 +00:00
drh 52b36cabe0 Ignore NULLs in a subquery as the right operand of IN. Ticket #565. (CVS 1175)
FossilOrigin-Name: c9e7996fb9080b715e9b273a3ac3ed3744e10a77
2004-01-14 13:38:54 +00:00
drh f6a7ade6b6 Version 2.8.10 (CVS 1174)
FossilOrigin-Name: 8bef75ab85197d926d924ae689769207df9a12f8
2004-01-14 03:49:43 +00:00
drh c713bdc778 Move some files around and bump the version number in preparation for the
release of 2.8.10. (CVS 1173)

FossilOrigin-Name: 74c661850e1899c457d4e822d8284bb66e1dc651
2004-01-14 03:32:37 +00:00
drh 7bdeb312ed Remove an incomplete comment that somehow snuck into the sources. (CVS 1172)
FossilOrigin-Name: ea1ad4653e6248f112d5516a0dcf3a72aa9b60d7
2004-01-14 03:12:42 +00:00
drh 31e95bcc5d On unix, embargo close() operations until all locks have cleared from the
file.  Ticket #561. (CVS 1171)

FossilOrigin-Name: 1ebe5fc7b03a6b070a5d52ffedb95f0d519ab068
2004-01-12 00:39:05 +00:00
drh 7b40e60800 Previous commit of changes to the in-memory backend was not quite right.
This check-in should square things away. (CVS 1170)

FossilOrigin-Name: 75d91e3bca44787768b1970203878dd4b1e31e55
2004-01-12 00:38:18 +00:00
drh 572b6f5614 Make sure the in-memory database can handle malloc failures. (CVS 1169)
FossilOrigin-Name: ba92af182c6c9c6b2e3816006191eedd424cdf1a
2004-01-12 00:21:52 +00:00
drh ba21256f98 Remove unused code and tighten existing code to make the library a little
smaller. (CVS 1168)

FossilOrigin-Name: 34a6b7416c6c9bcdf301f5e7b072a0362a746105
2004-01-08 02:17:31 +00:00
drh 143f3c45a7 Rework the fix to ticket #461 so that we do not have to do redundant tests
of WHERE clause terms looking for NULLs.  See also check-in (1103). (CVS 1167)

FossilOrigin-Name: 5fd581787e88173f0303f870fc956ec9285cca4e
2004-01-07 20:37:52 +00:00
drh d1d9fc3397 Permit sqlite_exec() to be called from within user-defined functions. (CVS 1166)
FossilOrigin-Name: 03636c94a542b1f90a3acfbe65a9c2976872073f
2004-01-07 19:24:48 +00:00
drh a11846b77a Defer the {quote: MoveTo}
opcode in VDBE until the data is actually needed.  Sometimes
the data is never needed, resulting in a performance increase.  On an indexed
order search with a large OFFSET, queries times can be an order of magnitude
faster. (CVS 1165)

FossilOrigin-Name: d3e96da20d269a068188915b3cc0eb02d330d316
2004-01-07 18:52:56 +00:00
drh 912184b0cf Make it safe to call sqliteMalloc() with a request for 0 bytes. Ticket #534. (CVS 1164)
FossilOrigin-Name: 6c858db2c099c7ba73d72e02b19bf6173620db13
2004-01-07 03:41:03 +00:00
drh c5dd9fa8ab Preserve the HH:MM:SS for most date/time modifiers. Ticket #551. (CVS 1163)
FossilOrigin-Name: 70df32b716b0d6a4f72bb3ae6496431e53733b6a
2004-01-07 03:29:16 +00:00
drh 384eef32fd Use "long double" to hold intermediate values when doing ascii to binary
and binary to ascii conversions of floating point numbers. (CVS 1162)

FossilOrigin-Name: 8371f662d22be0a3c58e0503c7511faea1640955
2004-01-07 03:04:27 +00:00
drh 133cdf6eba Add a typecast to work around a bug in the Metrowerks Code Warrior compiler.
Ticket #553. (CVS 1161)

FossilOrigin-Name: 4146f8cc3ff5339b5685e9c5121888ae08ee0807
2004-01-07 02:52:07 +00:00
drh 3a4e19be6b Version 2.8.9 (CVS 1160)
FossilOrigin-Name: d8ae6bddeb70f1450ccd3a4735ccf6fe3a042a07
2004-01-06 02:23:46 +00:00
drh 9d4280d53f Additional integer overflow boundary case tests. (CVS 1159)
FossilOrigin-Name: 532170d4b8fc7a4e596a817257e9e1f81d364940
2004-01-06 01:52:34 +00:00
drh e8e3920a2e Increase the version number and update the change log prior to the next
release. (CVS 1158)

FossilOrigin-Name: b99b68d026a0d58338a1d578e15a40dcdcdb47a9
2004-01-06 01:27:00 +00:00
drh 202b2df74a Fix problem in the code generator were incorrect code was being created if
the SQL source contained a negative integer that was too large to fit in
a 32-bit signed integer variable.  Ticket #552. (CVS 1157)

FossilOrigin-Name: b8381d9fe99273507e8626638110646801afef06
2004-01-06 01:13:46 +00:00
drh e807febbc2 Add the sqlite_current_time variable for testing purposes. (CVS 1156)
FossilOrigin-Name: 23fa407d50741bc0719259792398f28c1d0f12c2
2004-01-06 00:44:24 +00:00
drh b46d162d8d The "EST" timezone designation is ambiguous. Do not use it in the test
scripts. (CVS 1155)

FossilOrigin-Name: 720b565e2d02344e4d38263f4995dfabc60c0860
2004-01-02 15:08:43 +00:00
drh 7739630451 Avoid an assertion fault that can occur with invalid UTF8 on the LENGTH()
function.  Ticket #548. (CVS 1154)

FossilOrigin-Name: 7080fc39eaf98ef7a7d1c1819603f67841f35c72
2004-01-02 13:17:48 +00:00
drh 4ec2e9612f Remove unused code from the integrity_check logic. Ticket #545. (CVS 1153)
FossilOrigin-Name: ee51e205fb6ef412db6a46077e8bc1554aadcca1
2004-01-01 12:33:43 +00:00
drh cf64d8b820 Fix a bug in the SQLITE_PROFILE conditional compilation. (CVS 1152)
FossilOrigin-Name: 597b33f696c0cde84529cd06a8f95a8ccc8f1e8e
2003-12-31 17:57:10 +00:00
drh 89ef0eeb9b Fix for ticket #542. (CVS 1151)
FossilOrigin-Name: 458cfa5ba82f2d676e398437a4b1d26d77582d10
2003-12-31 17:25:47 +00:00
drh 07fa2a60ea Fix a bug (ticket #541) introduced by the previous check-in ((1149)). (CVS 1150)
FossilOrigin-Name: 646244008fb8a6eef4169291d75da59fa1ab26f9
2003-12-31 16:00:19 +00:00
drh dff7ec2cbd Reduce the randomness in the sqliteRandomSeed() routine in order to silence
bogus errors from valgrind.  Tickets #535 and #536. (CVS 1149)

FossilOrigin-Name: cfe0acf9ec6c89f1e77b8be7dcc23029984de1ce
2003-12-31 13:21:18 +00:00
dougcurrie ae53418df4 minor edits for new date.c with mingw/msys on Windows (CVS 1148)
FossilOrigin-Name: 9392c514501be333a3c22b552dc036e083eb22b4
2003-12-24 01:41:19 +00:00
drh f586aa8b96 Update date/time functions so that they correctly handle NULL arguments. (CVS 1147)
FossilOrigin-Name: a5a5fbd60153dd068ec2559455146e84da075b90
2003-12-23 16:34:12 +00:00
drh 7091cb0566 Add localtime<-->UTC conversions to the date functions. (CVS 1146)
FossilOrigin-Name: 8482b8c44766e7f80fc449b3dbdd3f37396c332b
2003-12-23 16:22:18 +00:00
drh 90f405e3ba Test functions tolerate an "0x" before a pointer value. Ticket #452. (CVS 1145)
FossilOrigin-Name: c6c5e07b65ae1c30117f0276a1002d5036697cf1
2003-12-23 03:06:23 +00:00
drh 93a5c6bdf4 Use a built-in atof() function instead of the one from the library to
avoid problems with locale.  Ticket #305. (CVS 1144)

FossilOrigin-Name: 4d9edbc50f7dee64edbadad2e2dc4f93d8248b3b
2003-12-23 02:17:35 +00:00
drh 3ddfdf7ac6 Optimizations to the LEMON parser template. (CVS 1143)
FossilOrigin-Name: 06db29df8f0c1cd29e696537e622f0c5456056f5
2003-12-22 14:53:19 +00:00
drh 2fd2fa0851 Fix some minor problems with the new test4.c module used for doing thread
testing. (CVS 1142)

FossilOrigin-Name: 952924084aac4a7fa84a7cb7aaac869d35db1896
2003-12-20 04:00:52 +00:00
dougcurrie 6194a5fb75 Update configuration and make files for mingw/msys on Windows (CVS 1141)
FossilOrigin-Name: 1e9689672c94e5ab89f07099c1402e157c8b02c1
2003-12-19 20:09:51 +00:00
drh f93e41442e Remove a comma at the end of an enum definition. Some compilers could not
deal with it. (CVS 1140)

FossilOrigin-Name: b1890a5b9c1222086b3aae92e49eb090a17a6492
2003-12-19 12:32:45 +00:00
drh 5202560ee5 Makefile updates for the new "test4.c" module. Also disable large file
tests for archic TCL versions. (CVS 1139)

FossilOrigin-Name: 55e2488912871381959326ab7fa89123ab30d659
2003-12-19 12:31:19 +00:00
drh acf01e7ddd A better fix for ticket #530 - one that is likely to work on unix
implementations in addition to linux.  Also more tests for multi-thread
locking added. (CVS 1138)

FossilOrigin-Name: 7dddbeb586504de30c64a1e61614da447f18c8ba
2003-12-19 08:40:22 +00:00
drh a6064dcf3b Add new thread-testing code and fix locking under Linux threads. Ticket #530. (CVS 1137)
FossilOrigin-Name: b36a4bb61094d539273c21a9e4042384f10a7806
2003-12-19 02:52:05 +00:00
drh 9c4dcca89e Typo on the "datatypes.html" document. (CVS 1136)
FossilOrigin-Name: 80b1e277123c07b2db7441a9e600dd69ef55a0da
2003-12-18 14:19:41 +00:00
drh 0f5c27a168 Version 2.8.8 (CVS 1135)
FossilOrigin-Name: a0451ccf2d0377536073ecaa2d6b70d05f5a5734
2003-12-18 01:22:54 +00:00
drh 0c9c3d06d4 Bump the version number and update the change log in preparation for the
next release. (CVS 1134)

FossilOrigin-Name: 9ad0bdf624e7dba448587c58eacd1e9cd2784316
2003-12-18 00:02:43 +00:00
drh acf4ac96e3 Make sure the pagers in-memory cache states in sync with the disk file.
Ticket #529. (CVS 1133)

FossilOrigin-Name: da00efb13fe8ccf1c27e4e1193df6b53de9463f4
2003-12-17 23:57:34 +00:00
drh 4be295be07 Improvements to the way PRAGMA integrity_check works. More likely to output
userful information when given a corrupt database. (CVS 1132)

FossilOrigin-Name: b92c31d6c138f9462730cecfe14f7dde19778e79
2003-12-16 03:44:47 +00:00
drh 1285a76973 Updates to the homepage - fix the CVS access instructions. (CVS 1131)
FossilOrigin-Name: 653a7dd97ed95e66bd2973169735ee73ee348576
2003-12-15 17:51:19 +00:00
drh 256ada0fda Fix a bulk-memory initialization problem in the expression list logic. (CVS 1130)
FossilOrigin-Name: d6549954408b01e5eaf865b9100739c94de28f16
2003-12-10 03:13:43 +00:00
drh 0f18bfa789 Fix the code generator to a void a VDBE stack overflow on 3-way joins.
Ticket #519. (CVS 1129)

FossilOrigin-Name: 230a4ff2c8a3927533baf5b22edc9f25490d5443
2003-12-10 01:31:21 +00:00
drh 6f8c91caa0 Make the VACUUM command run out of the VDBE like all other commands.
(Ticket #464).  Make the VACUUM command work even if there are VIEWs
in the SQLITE_MASTER table that come before tables they reference.
(Ticket #515) (CVS 1128)

FossilOrigin-Name: 614cbbafa180469744421f8fbe56cb392f48d05f
2003-12-07 00:24:35 +00:00
drh 447623d9aa Fail an ATTACH if the auxiliary database is locked. Ticket #514. (CVS 1127)
FossilOrigin-Name: ac428c8d4a731678cc26cf198689814a8a56d141
2003-12-06 22:22:35 +00:00
drh 41743984bf Always use "(char*)0" to terminate the argument list of sqliteSetString().
This is needed for 64-bit systems that use a 32-bit integer by default. (CVS 1126)

FossilOrigin-Name: 656c90387a4a714b4f31040ece9b0e15e30934af
2003-12-06 21:43:55 +00:00
drh 3a6629d27e Use sqlite_freemem() instead of free() in the shell. Windows needs this.
(Unix does not care.)  Ticket #444. (CVS 1125)

FossilOrigin-Name: e5e6a8481b2225e826c8e890ddc44f06759fe72b
2003-12-04 20:51:41 +00:00
drh 96e9f565ad Version 2.8.7 (CVS 1124)
FossilOrigin-Name: d48b0b018d47470689cc49f3be4cde50db165454
2003-12-04 13:47:04 +00:00
drh 27ff9f87b8 Update change log and version in preparation for the 2.8.7 release. (CVS 1123)
FossilOrigin-Name: 9e79ab6ce06d68fcd7efa207d0ffcd1c51c13d58
2003-12-04 13:44:32 +00:00
drh 4925ca00a3 Disallow temporary indices on persistent tables. (CVS 1122)
FossilOrigin-Name: 72bf73b2c1e3594aa85920e47fc345bba56c80d0
2003-11-27 00:48:57 +00:00
drh 0802fd836d Fix typos in file format documentation. Ticket #505. (CVS 1121)
FossilOrigin-Name: 4eef93814f4a26de4a088c464545443547281abd
2003-11-25 23:48:57 +00:00
drh b3549d43e2 Fix typo in file format documentation. Ticket #502. (CVS 1120)
FossilOrigin-Name: 72f3e7c2b0258271956ed7a43b3388bb74bf62ec
2003-11-24 23:11:08 +00:00
drh 0a5294bc06 Fix a typo in a #define that was commented out. No impact to working code.
Ticket #476. (CVS 1119)

FossilOrigin-Name: 21c2f96e814004d00691e3d7a632f193b0e49ee5
2003-11-11 23:30:35 +00:00
drh 000ca2b208 Added information on MySQL 4.0.16 to the NULL-handling survey. (CVS 1117)
FossilOrigin-Name: e22e3ab53a841b26984240760b0438efc83661d7
2003-11-08 12:07:01 +00:00
drh 7014aff37d Revised date/time functions - now broken out into a separate source file.
See the DateAndTimeFunctions wiki page for additional information. (CVS 1116)

FossilOrigin-Name: 68ef9b45bd3abdedf3721011ad0fb22e8735e721
2003-11-01 01:53:53 +00:00
drh b48484a6d7 Fork the tree for project "shrike" (CVS 1118)
FossilOrigin-Name: 181260c0aa7837feca9e415225ece0e9c4032c7a
2003-10-30 06:59:59 +00:00
peter 63a1e49859 Fix progress test error 1-2 (CVS 1115)
FossilOrigin-Name: c3a495026c7eafd576042a05a9a5f585ba8ba9b9
2003-10-23 15:27:11 +00:00
drh 8548a059ff Comment changes to the lemon parser template. Change some sqliteMalloc() calls
to sqliteMallocRaw() for speed.  Update the website template. (CVS 1114)

FossilOrigin-Name: c637caf13f579959ecdb6b134d0114e8efbcac60
2003-10-22 22:15:27 +00:00
drh fdbf928b08 Fix bugs in lemon associated with the change to a perfect hash table. (CVS 1113)
FossilOrigin-Name: c0d1b26966aeb445fea5792e5a9e93632e758c2a
2003-10-21 16:34:41 +00:00
drh 8b582012de Convert lemon to use a single perfect hash table for storing the actions.
This should make the resulting parser both smaller and faster. (CVS 1112)

FossilOrigin-Name: 4f955c00076b16166ff837749efb84201eab3c3a
2003-10-21 13:16:03 +00:00
danielk1977 348bb5d6c8 Add sqlite_progress_handler() API for specifying an progress callback (CVS 1111)
FossilOrigin-Name: ddb364635a207658664ea92fc677cf16a143a938
2003-10-18 09:37:26 +00:00
drh 4df92bbd44 Update to the date functions. (CVS 1110)
FossilOrigin-Name: 06d4e88394217fb1390b069bad82d6ac71981f72
2003-10-10 02:09:56 +00:00
drh 191c0323c0 Allow quoted trigger names. Ticket #468. (CVS 1109)
FossilOrigin-Name: 54aa0fb236d17b53b194a667d68c71007c8e7687
2003-10-03 00:13:38 +00:00
drh 319e4e7484 All LIKE and GLOB operators to use function notation. "A LIKE B" can be
expressed as "LIKE(B,A)". (CVS 1108)

FossilOrigin-Name: 95b27ebd1322a877112dee514dffddb0937e45fa
2003-09-30 01:54:13 +00:00
drh 4f88c849f3 Patch the spec.template file (for generating RPMs) as suggested by
Jeremy Hinegardner.  Untested. (CVS 1107)

FossilOrigin-Name: 703741ca1e2b0bf79a4e3cda3cf3c6862d7263eb
2003-09-29 12:20:51 +00:00
drh dab3518880 Remove support for the Oracle8 outer join syntax. (CVS 1106)
FossilOrigin-Name: 824430b3ce435386b83ceb882f1510ac9f27d8fa
2003-09-27 13:39:38 +00:00
drh 5b8424b9e4 Add a test case for ticket #464 but leave it commented out for now. We
will fix this problem when VACUUM is rewritten. (CVS 1105)

FossilOrigin-Name: 7ba8dc9b1e5c788f2c0ab32314754324c86aaa49
2003-09-27 01:08:37 +00:00
drh 3775084a75 Add additional backslash escapes to the COPY command for compatibility
with PostgreSQL.  Ticket #460. (CVS 1104)

FossilOrigin-Name: 70a50bdda318f353c8be1ba200f9aedc34642c93
2003-09-27 00:56:31 +00:00
drh 562528c480 Do all WHERE clauses tests, even if an index is used for lookup so that
we know the test cannot be FALSE.  The test might end up being NULL in which
case it would need to be treated as false.  Ticket #461. (CVS 1103)

FossilOrigin-Name: 5aea81488b2d3bcdc009ccf0f0ffcda046e38d79
2003-09-27 00:41:27 +00:00
drh f911221a1e A failed malloc() could have resulted in a segfault. Fixed by this check-in. (CVS 1102)
FossilOrigin-Name: 4bb256ee3ecd44d71d90556e16bb56c0389fd5b5
2003-09-23 10:25:32 +00:00
xdong 3b5543c46d allow -enable-releasemode as an option and allow Makefile to produce version
independent binary like libsqlite-2.8.6.so instead of libsqlite.so.0.0.0 (CVS 1101)

FossilOrigin-Name: 4fdd44a5ee5f7beb3cff11bc54fd3022b975b9e6
2003-09-23 00:36:50 +00:00
xdong 28f79f7bda regenerate configure to take -enalbe-releasemode as an option (CVS 1100)
FossilOrigin-Name: b85847b8f28f8f4be9e7f3d8674ecf42e1c5db38
2003-09-23 00:35:21 +00:00
xdong 225656c50a modify the configure file to allow cross-compile to work at arm and xscale (CVS 1099)
FossilOrigin-Name: 760f2fa2e5db102b970687f59b79bfb6f4d35b32
2003-09-18 21:59:45 +00:00
drh 61b487d02a The tokenizer should never return a negative size of the next token.
Ticket #453. (CVS 1098)

FossilOrigin-Name: 4fbca3ab09596c530da7c50657f3bc9140178dd5
2003-09-12 02:08:14 +00:00
drh 9faae94118 Add test cases that check out sqlite_get_table() on queries with results sets
containing 100 columns. (CVS 1097)

FossilOrigin-Name: f9feedec32c975235c0d0996962033f6a63312ba
2003-09-09 00:47:47 +00:00
drh 82a4851a4b Add initial test cases for the new sqlite_bind() API. Fix bugs that the new
test cases found. (CVS 1096)

FossilOrigin-Name: f6c4908e9b5b6ac9adc4af50dc5110dbb655dae3
2003-09-06 22:45:20 +00:00
drh 7c972dec5c Update Makefile.in for the new vdbeaux.c file. Remove the experimental
"sqlite_instantiate()" routine and replace it with "sqlite_bind()" which
is more like ODBC and JDBC. (CVS 1095)

FossilOrigin-Name: 990bb11898a539bb0795a4a216fcd989943a0fb2
2003-09-06 22:18:07 +00:00
drh 9a32464b54 Split almost 1300 lines of code out of vdbe.c into separate files
vdbeInt.h and vdbeaux.c. (CVS 1094)

FossilOrigin-Name: bfd69391d3d63675f206ffd8ff0401ea1cbcc073
2003-09-06 20:12:01 +00:00
drh 5045789694 The beginnings of changes to support pre-compiled SQL. Mostly untested,
though all regression tests to pass. (CVS 1093)

FossilOrigin-Name: 912f47c72d3597c6d5acff765d94922bd660339a
2003-09-06 01:10:47 +00:00
drh c023e03ea5 Add a logo from Rasmus Schultz. (CVS 1092)
FossilOrigin-Name: aaa84c6202f6e16828bcd6aff2e424f3dba1f82b
2003-09-02 15:26:33 +00:00
drh 1dcafe1ad8 CVS missed a commit (because I pressed Ctrl-C in the middle). This
extra commit will hopefully help clear things up. (CVS 1091)

FossilOrigin-Name: 522c2efeb5bdccadf3306234d458425b94cdbbe3
2003-08-27 22:57:07 +00:00
drh e4c616931d Add locks to the in-memory backend so that recursive writes will be detected
and rejected.  Ticket #436. (CVS 1089)

FossilOrigin-Name: 3403d28a49b27d3059d3d399ca057e8d33eb857a
2003-08-27 22:54:31 +00:00
drh 0d4f801c28 Add locks to the in-memory database so that recursive writes will be detected
and rejected.  Ticket #436. (CVS 1090)

FossilOrigin-Name: 966b1a16f6687df08f8c21787c1c8b1af1d79e1e
2003-08-27 22:52:34 +00:00
drh ec1bd0bd72 Fix compiler warnings under OpenVMS. Ticket #357. (CVS 1088)
FossilOrigin-Name: c95f347cac27732533a2f6fd4ba50bf00eef59f3
2003-08-26 11:41:27 +00:00
drh 8460ea0652 Try to work around a bug in VC++ by only passing unsigned characters to
the isspace() routine.  Bug reported on the mailing list. (CVS 1087)

FossilOrigin-Name: cbe32216966c987902ceb4d85332fc95801dbda2
2003-08-26 11:35:00 +00:00
drh 03ab7336cd Fix a bug in sqliteRealloc() that only occurs if there is memory corruption
and debugging is enabled.  Ticket #421. (CVS 1086)

FossilOrigin-Name: eebc82b77dbf35a18d2eae47336038d4b67806c6
2003-08-26 11:29:07 +00:00
drh 901afd4341 If the database filename is an empty string, open a temporary file to hold
the database.  Ticket #432. (CVS 1085)

FossilOrigin-Name: da53369f0bf133b89b213bbb1ccea13eb93ab6ed
2003-08-26 11:25:58 +00:00
drh 263659be4d Close files before deleting them on test scripts under Win2k.
Ticket #434. (CVS 1084)

FossilOrigin-Name: 2a40b46140720783cf4002fb9993f7f6766dbf5f
2003-08-26 11:18:19 +00:00
drh 6ab95d3e85 Remove extra backslashes from end of lines in the install target of the
Makefile.  Ticket #435. (CVS 1083)

FossilOrigin-Name: 1aa3658ef54fad7f2b7f61d91641472551468cdc
2003-08-26 10:38:58 +00:00
drh 3ca65151d5 Fix a bug in the new "pk" column of the table_info pragma that was added
by check-in (1081). (CVS 1082)

FossilOrigin-Name: ad7b017a1277c00b356343b36ade565baf404d6a
2003-08-24 16:38:17 +00:00
drh 78100cc928 Add a "pk" column to the table_info pragma which is true for each column
that is part of the primary key.  Add a "foreign_key_list" pragma that gives
information about all foreign keys for a table.  Both changes are experimental. (CVS 1081)

FossilOrigin-Name: 5232b0665b84a9339a85918570093a376a0ea91f
2003-08-23 22:40:53 +00:00
drh 73d3667ef2 Version 2.8.6 (CVS 1080)
FossilOrigin-Name: 0bde7ae2ba57de554c3531f3cb7e36bf56d3b12c
2003-08-22 03:00:00 +00:00
drh a866b82244 Change the CVSTrac website to www.sqlite.org. Update change summary for
the 2.8.6 release. (CVS 1079)

FossilOrigin-Name: a4e3e075e3b36e0f5f692067c5bf5e1b660d893d
2003-08-22 02:34:30 +00:00
drh 02b2011cb3 Update the -version-info number on libtool in Makefile.in. (CVS 1078)
FossilOrigin-Name: dc36365eea7d0c8767d8947393a8d2746c02b220
2003-08-21 14:36:38 +00:00
drh 4739470341 Add the experimental "quote()" function to the set of build-in functions. (CVS 1077)
FossilOrigin-Name: 9699c68508db5da6238904e518835a629d430db6
2003-08-20 01:03:33 +00:00
drh 5d9d757626 Add the "onecolumn" method to the TCL language bindings. (CVS 1076)
FossilOrigin-Name: c7b4c28fbc0bca5645af5750fd353f4eca400b40
2003-08-19 14:31:01 +00:00
drh e5e3760e1c Make the compile work under cygwin.
Tickets #327, #213, #316, #322, #349, #373, and #429. (CVS 1075)

FossilOrigin-Name: 7d8d3252df1e9f6bec5e105b6eca3313cb7e226a
2003-08-16 13:10:51 +00:00
drh 9b1b01bb76 Do not delete tables with the same name when dropping triggers.
Ticket #430. (CVS 1074)

FossilOrigin-Name: ef58f163b08d13f8e9b69459bd83e0bf9d5b404b
2003-08-16 12:37:51 +00:00
drh 8e18bac793 Fix a segfault that occurs in the VACUUM command if run on an empty database
with the EMPTY_RESULT_CALLBACKS pragma enabled.  Ticket #427. (CVS 1073)

FossilOrigin-Name: 3563e9cf9d6b20f09e92deb21fdda93bcd8fb583
2003-08-15 13:24:51 +00:00
drh b2446f9bbf Update the NULL-handling chart with new information about Firebird. (CVS 1072)
FossilOrigin-Name: 17bdfeb284880d82cd546e6c191c3a37121ec861
2003-08-13 11:29:23 +00:00
drh 41a8230fef Make the sqliteOsCurrentTime() function work for Windows. Code contributed
by "e4liberty" on the mailing list. (CVS 1071)

FossilOrigin-Name: 02fac304c9ec9012f3cc4f04d2c4cac5e37b0024
2003-08-10 16:16:22 +00:00
drh 87adaa9a99 tighter coding of the date and time functions. Better comments. A bug fix. (CVS 1070)
FossilOrigin-Name: 94243edac14b90ef898093b85e1959c20fa23ae9
2003-08-10 01:50:54 +00:00
drh 771d8c3bae Add experimental date and time functions based on julian day number. (CVS 1069)
FossilOrigin-Name: a6197e2075fdf9db862484255ac16b2855bbef0a
2003-08-09 21:32:28 +00:00
drh 37ed48ed2f Provide a more informative error message when a uniqueness constraint
fails.  Ticket #419. (CVS 1068)

FossilOrigin-Name: 086aa1c9922b7bf399b3ee8b73ba7353d126b119
2003-08-05 13:13:38 +00:00
drh 4305d10360 The {quote: SrcList} object was not being expanded correctly by a call to
sqliteSrcListAppend() if the {quote: SrcList} had previously been duplicated by
a call to sqliteSrcListDup().  Ticket #416. This check-in fixes that problem
by keeping a separate nAlloc field on {quote: SrcList}.  A similar change is made
to {quote: IdList} and {quote: ExprList} to avoid future problems. (CVS 1067)

FossilOrigin-Name: da6273255471673841fdcadc688aeac80722e130
2003-07-30 12:34:12 +00:00
drh a76c82eb0d When creating a new journal file, open a (read-only) file descriptor on the
directory containing the journal and sync that directory once to make sure
that the journal filename entry gets into the directory.  Ticket #410. (CVS 1066)

FossilOrigin-Name: 09c10fe3c99cffc64ed02c2929f206d99c8e3309
2003-07-27 18:59:42 +00:00
drh 98e3e60012 Make sure the schema loader callback can handle EMPTY_RESULT_CALLBACKS being
on.  Ticket #406. (CVS 1065)

FossilOrigin-Name: 8c163fc0c7c721b7a5fa6727b0e90bff4484c782
2003-07-27 17:26:22 +00:00
drh dc2d94de56 In the VDBE, when an integer value will not fit into a 32-bit int, store it
in a double instead.  Ticket #408. (CVS 1064)

FossilOrigin-Name: 7514c3db165e8cc5c696b2b345844949a0e45a61
2003-07-27 17:16:06 +00:00
drh 48647b390b Version 2.8.5 (CVS 1063)
FossilOrigin-Name: 95fba440e79c066c0d6f6205a3d7dcb6c870b1c9
2003-07-22 13:20:28 +00:00
drh 8dd5a314eb Fix a typo in the index.html homepage. (CVS 1062)
FossilOrigin-Name: 510761cf505222c68ce3404aad94e1cc28b703ed
2003-07-22 12:44:53 +00:00
drh ee513831a7 Increment the version number and update the documentation in preparation
for the 2.8.5 release. (CVS 1061)

FossilOrigin-Name: c2115335de4abc25cbc1664d718dc3a6f70ebe6c
2003-07-22 12:41:59 +00:00
danielk1977 999af643a0 Add experimental sqlite_reset() API (allows pre-compiled queries) (CVS 1060)
FossilOrigin-Name: 1d2fcb017811db90e85d63f2ca76867c00ab8f1b
2003-07-22 09:24:43 +00:00
drh 4d87325d61 Make sure temporary file names in windows have a full 15 characters of
random text at the end. (CVS 1059)

FossilOrigin-Name: 6ccb92b14f2e6e01bb60dac10331fa7be0b4525e
2003-07-22 00:39:13 +00:00
drh 7b58daeafe Fix the LIMIT clause so that it applies to the entire query in a compound
query.  Prior to this change LIMITs on compound queries did not work at
all.  Ticket #393. (CVS 1058)

FossilOrigin-Name: 543479e3aed77976a0c689cf40811bf88353f706
2003-07-20 01:16:46 +00:00
drh e5f50722b4 Make sure the min() and max() optimizer works correctly when there
is a LIMIT clause.  Ticket #396. (CVS 1057)

FossilOrigin-Name: c35e50717678703763c696e3e9b265add2ca6454
2003-07-19 00:44:14 +00:00
drh 9347b20050 In the sqlite shell, change the name of function getline() to local_getline()
to avoid a clash with a library function.  Ticket #400. (CVS 1056)

FossilOrigin-Name: 558969ee8697180c74308f3f880d3240eb575af1
2003-07-18 01:30:59 +00:00
drh 9cb733c39d In the test scripts, do not try to delete files that are still open.
Windows does not like it when you do.  Ticket #397. (CVS 1055)

FossilOrigin-Name: 93a2c961b17d2459272e2d8654bd4b972f52fbe1
2003-07-18 01:25:34 +00:00
drh a3b6cfa6cf Fix typo on the homepage. (CVS 1054)
FossilOrigin-Name: c74107d63ace3d0e51da3b7bd7ee250c2a39205b
2003-07-16 17:10:45 +00:00
drh a88dc3f629 Make LIMIT 0 return no rows. LIMIT -1 still returns all rows. Ticket #346. (CVS 1053)
FossilOrigin-Name: a31d0bd90af7cc95f8e36ca8ece21515f872235e
2003-07-16 11:51:35 +00:00
drh ef0cae500d Allow negative values for LIMIT and OFFSET. Add tests for negative LIMITs
and OFFSETs.  Make the OFFSET work even if LIMIT is 0 or negative. (CVS 1052)

FossilOrigin-Name: e6a752bfef24f773973c151c6262ff331a9dc57a
2003-07-16 02:19:37 +00:00
drh d4f5ee2805 Initialize a variable to prevent an MSVC compiler warning. Ticket #394. (CVS 1051)
FossilOrigin-Name: 96e3c539586bf86c4fe8de0ac25de6655f704035
2003-07-16 00:54:31 +00:00
drh da808d56dc An an extra test associated with ticket #387. (CVS 1050)
FossilOrigin-Name: 6a07ac3782bc18f907ffcf66d908ddaa82ab9293
2003-07-09 16:34:56 +00:00
drh 073e5a7751 Allow the output arguments in sqlite_compile and sqlite_step to be NULL
pointers.  Tickets #384 and #385. (CVS 1049)

FossilOrigin-Name: dd84f88f6c4012e4a093a4881f6fe50527bb2006
2003-07-09 00:28:13 +00:00
drh 23af2f6eb2 Enhance the C/C++ documentation to clarify the meaning of the return value
from sqlite_changes().  Ticket #383. (CVS 1048)

FossilOrigin-Name: 303b2da1acd4b7b9d89dec0653e5f88fc10d56b8
2003-07-08 23:42:25 +00:00
drh 3e4c852889 A proported fix for ticket #374. (CVS 1047)
FossilOrigin-Name: a49ee69e98df80b479aa6bb97a9af9c6abf04e3f
2003-07-07 10:47:10 +00:00
drh d0cc954fa1 Update the NULL-handling document to show current behavior of OCELOT. (CVS 1046)
FossilOrigin-Name: 1d4c92c7325f69ee84b901a2de74a306ace134b6
2003-07-07 00:10:39 +00:00
drh 1dd59e0f94 Correctly handle comparing an INTEGER PRIMARY KEY against a floating point
number.  Ticket #377. (CVS 1045)

FossilOrigin-Name: 982aa3356bcc217003cd9e6a829619219c334797
2003-07-06 17:22:25 +00:00
drh 3c8bf55a04 Make sure indices in ATTACH-ed databases are put into the right hash table.
Ticket #354. (CVS 1044)

FossilOrigin-Name: eb4582831d536cd26a1738f9ad197e40486d0958
2003-07-01 18:13:14 +00:00
drh c5aceb33cb Update the null-handling document to show how SQL Anywhere and Borland
Interbase deal with NULLs. (CVS 1043)

FossilOrigin-Name: 9a87f2f326d7fc8bb9f832d0e3fd31141e14e08f
2003-07-01 01:16:30 +00:00
drh ef2d1b100c Documentation change: refer users to the wiki for additional unsupported
features rather than have them send me e-mail. (CVS 1042)

FossilOrigin-Name: a3920b0804e9993bb21e6c46c612e72bd03178a2
2003-06-30 10:36:23 +00:00
drh 631e276202 Version 2.8.4 (CVS 1041)
FossilOrigin-Name: 7f5e8894ae37761d1015c426b5d383d3deef3e25
2003-06-29 20:45:29 +00:00
drh dc339ee29c The prior fix of ticket #360 was incorrect and caused a memory leak. This
check-in plugs the memory leak and correctly fixes ticket #360. (CVS 1040)

FossilOrigin-Name: fc490f677b89e623b41f9e7f5f3bade9b981562c
2003-06-29 20:25:08 +00:00
drh d6ae597393 Fix a bad memory leak in the in-memory database module. (CVS 1039)
FossilOrigin-Name: 9cca95937837333c91f5dee8c48178cf7e06d59f
2003-06-29 18:29:47 +00:00
drh 27fb6f6a99 Bump the version number in preparation for the next release. (CVS 1038)
FossilOrigin-Name: 0532e1a8f5a310bb19b55dc29aa5b1f1172a14da
2003-06-29 16:16:40 +00:00
drh 88c0df2a84 Documentation updates. (CVS 1037)
FossilOrigin-Name: ab21de5fdd8e45be19411cdba647eada0bc9a9f1
2003-06-29 16:11:12 +00:00
drh 82f725df08 Minor change to a comment in encode.c. (CVS 1036)
FossilOrigin-Name: 3f252b72c9d9ea586161a1b2c5ae297594a1cd4a
2003-06-28 16:25:33 +00:00
drh 937dd84de8 Fix a bug in the soundex() code. Ticket #367. Add tests for ticket #261
even thought the problem could not be reproduced. (CVS 1035)

FossilOrigin-Name: e2ca936feee35b3fce99c95c2cf8c0ad05cd9c3b
2003-06-28 16:20:22 +00:00
drh d60ccc6a75 In a SELECT, the rowid of a view or subquery which is really a join is
set to NULL if the join is flattened.  Ticket #364. (CVS 1034)

FossilOrigin-Name: bad8b55833f5120003a19883154dac5146cc36a3
2003-06-24 10:39:46 +00:00
drh 18706c08cb Remove a surplus "return" statement accidentaly left in check-in (1032). (CVS 1033)
FossilOrigin-Name: c697410af4a61d2037e7e319efe8dd78d7b83365
2003-06-23 15:15:03 +00:00
drh 6cb2c52d96 Remove all references to SQLITE_OMIT_TRACE. Tracing is always enabled.
Ticket #361. (CVS 1032)

FossilOrigin-Name: ec31a5292cbc5d2fb68449838b929638f48e31a7
2003-06-23 11:06:01 +00:00
drh 8ce10ba65e Make sure the source of a PULL opcode is not an ephemeral string. Ticket #360. (CVS 1031)
FossilOrigin-Name: cb70ee67ea9f5a47d58820e0e8b28c8f945217ed
2003-06-22 01:41:49 +00:00
drh 44ce7e20f8 Remove unused variable. Ticket #355. (CVS 1030)
FossilOrigin-Name: 5228cecdb84a665b96750fc0dc7c81e3f50a3ce8
2003-06-17 02:57:17 +00:00
drh 7a73eb48f8 Fix compiler errors and warnings win SQLITE_OMIT_AUTHORIZATION is defined.
Ticket #353. (CVS 1029)

FossilOrigin-Name: 6920b633c2e4a94ee5de7d2db3933a873ee3513b
2003-06-16 19:18:12 +00:00
drh d93d8a812e Add the %z format to the sqlite_mprintf() and related functions. (CVS 1028)
FossilOrigin-Name: eca1398eaac67d772aff2676a470d9a6d96a93ca
2003-06-16 03:08:18 +00:00
drh 3fc673e622 Do not flatten a subquery which is the right term of a LEFT OUTER JOIN
if the subquery contains a WHERE clause.  Ticket #350. (CVS 1027)

FossilOrigin-Name: dd8943e8583cf7ed3b662570a5607856fd246dac
2003-06-16 00:40:34 +00:00
drh f817b6be7f Preserve blank lines in the middle of SQL statements in the shell.
Ticket #352 (CVS 1026)

FossilOrigin-Name: bcf5eeecdfd9897bc7c257119d7515fd34d222c1
2003-06-16 00:16:41 +00:00
drh 4d9fc3231b Update the documentation to reflect the new capabilities of PRAGMA
integrity_check.  Rewording in the VACUUM documentation. (CVS 1025)

FossilOrigin-Name: 38461a7acb5281edd7078b1b3f227bb45f281757
2003-06-15 23:49:38 +00:00
drh ed717fe3b2 Enhance the "PRAGMA integrity_check" command to verify that all indices are
correctly constructed.  New calls to integrity_check are made in the test
suite. These changes are intended to prevent any future problems such
as seen in ticket #334. (CVS 1024)

FossilOrigin-Name: c9734c27074d2039a1896a8c6965c08d03711b13
2003-06-15 23:42:24 +00:00
jplyon 3ca691106b Updated sqlite_encode_binary() comments with tighter bounds on output length. (CVS 1023)
FossilOrigin-Name: 826aab43d5967ece2a272c49ce62021fa4a2ceb3
2003-06-15 10:35:04 +00:00
jplyon 1420010fa4 Documented integer values used by PRAGMAs.
Fixed missing end tags in generated anchors. (CVS 1022)

FossilOrigin-Name: 6c24dfbae56a16dd736de5297c1796818773df80
2003-06-15 10:29:24 +00:00
a.rottmann 831961217d * Added -version-info to shared libraries
* Remove config.h and libtool in the distclean target (CVS 1021)

FossilOrigin-Name: e13e8b05b4d146aa4ca9ed06e414e0c6a4fba4e4
2003-06-14 19:29:08 +00:00
drh c45d95f9de Bug fix: sqliteFree() called twice on the same allocation during error
handling in attach.c. (CVS 1020)

FossilOrigin-Name: 9ec40935b9435ddc3749cab517387477e4045f6b
2003-06-14 12:04:07 +00:00
drh e2227f0092 Open the journal file for read-only when doing a playback. Ticket #351. (CVS 1019)
FossilOrigin-Name: 66ac7aea3df8533a49c8c05ba57c5a7015626828
2003-06-14 11:42:57 +00:00
jplyon 892f671cf3 Added missing error string to sqlite_error_string(). (CVS 1018)
FossilOrigin-Name: 3afb7b3586be81202c76692afea9d2b7a63b4b93
2003-06-12 08:59:00 +00:00
drh 2e0d738b60 Suppress the warning message about print_node() being unused in btree_rb.c.
Ticket #347. (CVS 1017)

FossilOrigin-Name: b52f07e1c894a52bb12459d03fd0efcee05dd08c
2003-06-10 02:46:15 +00:00
drh 7571c96c4c Remove redundant "return" statement from btree_rb.c. (CVS 1016)
FossilOrigin-Name: 373d077173f1b31896dc0e0d724371dd506d52f3
2003-06-09 11:53:12 +00:00
jplyon 05e45910ca Documented SQL fns IFNULL() and NULLIF(). (CVS 1015)
FossilOrigin-Name: 190252fee0a86eb6f8c24a2402e36482e3bd514c
2003-06-08 08:36:33 +00:00
drh 6f8fd3c171 Use sqliteOsFileExists() in the debugging hook in vdbe.c, instead of access().
Ticket #341. (CVS 1014)

FossilOrigin-Name: 7d3405b95bae74e0c476a7bdf708ca518723eaf7
2003-06-07 11:33:45 +00:00
drh 94ce4c1e3b Do not assume that a pointer can fit in a long inside the printf() code.
Ticket #342. (CVS 1013)

FossilOrigin-Name: 5dad7c05e9789e101d5ce75a6f3ea2ffb278b29d
2003-06-07 11:29:50 +00:00
jplyon 048aa234ef Major update of vdbe tutorial to 2.8.0 engine. (CVS 1012)
FossilOrigin-Name: 787d986d0f391d26eef7a2639594c465f9599f5b
2003-06-07 08:57:58 +00:00
jplyon 5fa7eb0dd9 Hyperlinks and minor additions/corrections for lang.tcl (CVS 1011)
FossilOrigin-Name: 685a179aae535431ec46922f1aff50a54112e959
2003-06-07 08:56:09 +00:00
drh 81e293b4b2 Extend the authorization mechanism to disallow the ATTACH and DETACH commands.
Ticket #340. (CVS 1010)

FossilOrigin-Name: a97dca73aed0b42d8dcf944360667ae93c5324fd
2003-06-06 19:00:42 +00:00
drh 70dc85a4c2 Add btree_rb.c and opcodes.c to the source built by the "target_source" target
of the main makefile. (CVS 1009)

FossilOrigin-Name: 09546972991601697925c10b6ef31694b0be2385
2003-06-06 16:13:40 +00:00
drh d36a483704 Add a prototype for the sqlite_vmprintf() function to sqlite.h. (CVS 1008)
FossilOrigin-Name: 048cf55c7da92e363f6a2ab594e17280c9573410
2003-06-06 15:44:00 +00:00
drh b5333fa6e4 Fix a typo in speed.html. (CVS 1007)
FossilOrigin-Name: d01e6fbdde314f2edfcd43fcda3dc8bedb6bf2ba
2003-06-05 15:05:34 +00:00
drh 8649d6a1a8 Remove unused code from util.c. (CVS 1006)
FossilOrigin-Name: 1bcaa841a396e4d592de30d10846f7cefbbdcd0e
2003-06-05 14:27:56 +00:00
drh 7d02cb73ca Fix a bug in UPDATE OR REPLACE that was introduced by check-in (999).
Also clean up some compiler warnings for VC++. (CVS 1005)

FossilOrigin-Name: af6f2bdf59fb621ff3e1d061e429f01ebd7d0b42
2003-06-04 16:24:39 +00:00
drh b8ec20925d Adjust test cases to cope with the extra column returned by the database_list
pragma. (CVS 1004)

FossilOrigin-Name: fa10c6df5a80127508fb198c21ef93acfc93ebe2
2003-06-04 15:53:02 +00:00
drh 5e8e1981dc Change the "database_list" pragma to return a third column containing the
filename of the underlying database file.  Always use an in-memory TEMP
database with an in-memory main database. (CVS 1003)

FossilOrigin-Name: f39100f5759d0d8b9c71e18d38a148dee4643020
2003-06-04 15:48:33 +00:00
drh ca3bdaca19 Version 2.8.3 (CVS 1002)
FossilOrigin-Name: 433570e3e6caa52b9e480a22529dde6385a3c7d3
2003-06-04 12:44:27 +00:00
drh b6ec9fed20 Update the version number to 2.8.3. (CVS 1001)
FossilOrigin-Name: c96f5bf0d7b75c8091f78dc2b9e3937949642ce5
2003-06-04 12:40:43 +00:00
drh bc2bca0843 Disable the unreadable file test (attach-6.2) under windows because of
problems in the OS. (CVS 1000)

FossilOrigin-Name: 4bfb30d20bdd33c6e26c8fb8392a75d3cf2ee4bd
2003-06-04 12:31:53 +00:00
drh 5383ae5c12 Avoid corrupting indices when doing a REPLACE on a table with an
INTEGER PRIMARY KEY that also has another index.  Ticket #334. (CVS 999)

FossilOrigin-Name: e813faae0e4086571d13c769f793add7f1f979af
2003-06-04 12:23:30 +00:00
drh 4312db55d9 Additional testing of the ATTACH command with bug fixes for the new problems
that the tests found. (CVS 998)

FossilOrigin-Name: 3e8889d7ce5e99fc855526fc1bb62ddbe282bfc5
2003-06-03 01:47:11 +00:00
drh 1aa4965ae3 The OP_Checkpoint opcode is now a no-op if invoked on a database that already
has an active checkpoint journal.  Ticket #333. (CVS 997)

FossilOrigin-Name: daf7b94017f03638da1ef65830f3762be030b93c
2003-06-02 23:14:13 +00:00
drh 2394e376d6 Fix a bug in the COPY command introduced by check-in (991). (CVS 996)
FossilOrigin-Name: 77ec13dab85b70795ef06ff2c714cca0cd496837
2003-06-02 22:50:25 +00:00
drh ade106c14a Fix an initialized variable in sqliteInitOne. (CVS 995)
FossilOrigin-Name: 89957b09ce746cf98d5d75cab2a23994e27c4937
2003-06-02 18:17:33 +00:00
jplyon 5959abd5d0 Generate anchors in opcode table html for use by new vdbe tutorial. (CVS 994)
FossilOrigin-Name: 3ae36cf158e1878a66ce9302eae4e62f8a88333f
2003-06-02 06:29:31 +00:00
jplyon 02be20d4f5 Added comments. (CVS 993)
FossilOrigin-Name: 1276ddb3074b74e22c579bad6951ea52384c08dd
2003-06-02 06:17:10 +00:00
jplyon 5a56422a29 Additions and corrections to vdbe documentation comments. (CVS 992)
FossilOrigin-Name: b648987de3383d6835df58aa0efee54fa8f10d26
2003-06-02 06:15:58 +00:00
drh a0217ba720 Add the ability to INSERT or UPDATE using the "rowid" column even on tables
that lack an integer primary key. (CVS 991)

FossilOrigin-Name: 903adbe802ca0e987b867e5ad33aae02ad2a43d4
2003-06-01 01:10:33 +00:00
drh f26e09c87f Tighter binding of views, triggers, and indices to their respective
databases.  Ticket #323.  Much more testing needs to be done to the
sqliteFix...() routines in attach.c. (CVS 990)

FossilOrigin-Name: 7202d4f1a8853368954a967b7ccca9d8a6645a2e
2003-05-31 16:21:12 +00:00
drh 8372b8d134 Change the row-size limit back to 1MB. It was temporarily raised to 16MB.
We'll probably move it to 16MB eventually, but not just yet. (CVS 989)

FossilOrigin-Name: b84c4035c6b06469055798cf412fa4da8b50fa17
2003-05-29 17:50:55 +00:00
drh 9ac717d7f6 Modify the windows locking code so that it works correctly for a database
being shared between Win95/98/ME and WinNT/2K/XP systems.  Ticket #310. (CVS 988)

FossilOrigin-Name: 8c402db7e0745622d9950e5ca5d4d8e933da436c
2003-05-29 17:43:08 +00:00
jplyon 124e74e685 Added typeof() operator.
Minor additions for ATTACH/DETACH. (CVS 987)

FossilOrigin-Name: 8b8fa0fff26107912f0bec4e44df207c7885e273
2003-05-29 04:21:38 +00:00
drh 6e1d288a9f Fix segfault that occurs when opening a non-existing database in the shell
then immediately doing ".q". (CVS 986)

FossilOrigin-Name: e8566cf5a381fa7655caacbc0fe95091e1137fea
2003-05-19 23:55:30 +00:00
drh 6b8611126b Additional attach testing. I now believe that ticket #317 was fixed
by check-in (981). (CVS 985)

FossilOrigin-Name: 24191373796b7fd6255ef9b70ce2344326308113
2003-05-17 19:23:51 +00:00
drh 79a519c047 Prevent an infinite loop when deleting a table that has a TEMP trigger. (CVS 984)
FossilOrigin-Name: c8c823b068916711857fa67db10fb479999b55c2
2003-05-17 19:04:03 +00:00
drh 24f1eb74c8 Version 2.8.2 (CVS 983)
FossilOrigin-Name: f542e5fc8896111e5165cc625607f95e4993bb16
2003-05-17 17:52:34 +00:00
drh 369986a75f Bump the version number and update the change log. We are rushing out
release 2.8.2 because of the database corruption problem fixed by
the previous check-in. (CVS 982)

FossilOrigin-Name: e134459d653b03bfacb98eec2c5d91eef7e4ed24
2003-05-17 17:38:37 +00:00
drh 8bf8dc9208 Fix problems with TEMP indices that lead to corrupt databases. These
problems were discovered while working on ticket #317.  No sure yet if
that ticket is fixed. (CVS 981)

FossilOrigin-Name: 01398fb78bab7e5c6f439f2b743f26e82118468a
2003-05-17 17:35:10 +00:00
drh 0594f5b97e Version 2.8.1 (CVS 980)
FossilOrigin-Name: 590f963b6599e4e235d7369f19c63cece4b2ad95
2003-05-17 02:44:32 +00:00
drh 8971527208 Fix the fix for newlines in echo commands. Tickets #311, #282, #256. (CVS 979)
FossilOrigin-Name: baea7aca10e30f30b874e1e8b6cd3b05954ba83c
2003-05-17 02:27:21 +00:00
drh 8625f9fe38 Bump the version number to 2.8.1. Update documentation prior to release. (CVS 978)
FossilOrigin-Name: 0874814ab01ffc0acffec8e6cec34eaab3428d36
2003-05-17 01:39:39 +00:00
drh 299fa266df Escape backslashes in echo commands in the makefiles. Tickets #311, #282, #256. (CVS 977)
FossilOrigin-Name: d614861b8ad9e661b8f08131b95d730e2c2c35c2
2003-05-17 00:24:21 +00:00
drh 9335247003 Fix memory allocation problem in the sqlite_get_table() API. Ticket #315. (CVS 976)
FossilOrigin-Name: f1d955efd91093994db43a1540080d32442d5ac0
2003-05-17 00:05:49 +00:00
drh a996e477d0 Make sure the ON CONFLICT clause on a BEGIN overrides the conflict resolution
specified by an index.  This fixes a bug reported on the newsgroup. (CVS 975)

FossilOrigin-Name: 0f92736d1fbe3b587592fe1f26dfb3558cc49727
2003-05-16 02:30:27 +00:00
jplyon 931634915d Removed 3rd (file) column from PRAGMA database_list until tests are fixed. (CVS 974)
FossilOrigin-Name: 4183cf97676e64d19978941a7c4a3fe521fcb1fb
2003-05-13 08:01:33 +00:00
drh 39581966a0 Fix another twos-complement negation error. Ticket #313. (CVS 973)
FossilOrigin-Name: f267a8a4ff52eb7ee3ac20a8e3a8ab5fe19e445d
2003-05-13 01:52:31 +00:00
drh 3b2129cf77 A change to lemon related to ticket #313. (CVS 972)
FossilOrigin-Name: b59d9033d5556015543ac5ca23110ccbeb4391f0
2003-05-13 00:34:21 +00:00
drh fe4184f8d1 Remove unnecessary "#include <sqliteInt.h>" from the shell code. (CVS 971)
FossilOrigin-Name: 6e5c497a42e52236edae8d99b4892d4b93db43f5
2003-05-13 00:24:41 +00:00
drh e62720d1f1 Fix a #ifdefs that are used to comment-out the VACUUM command. (CVS 970)
FossilOrigin-Name: 22d5324073a727627d4294870a441fa2316fb049
2003-05-13 00:21:59 +00:00
drh 5364f60302 Make sure hash functions always return non-negative. (CVS 969)
FossilOrigin-Name: 39a3e403f0440acb2f85a064ec23d404f9cdfbc4
2003-05-12 23:06:52 +00:00
jplyon 5ca89c3d28 Changed PRAGMA database_list to show the filename. (CVS 968)
FossilOrigin-Name: 3da10d2d02e331f136fcf857dc4c435c67ee7196
2003-05-11 20:09:19 +00:00
jplyon 672a1edfc8 Changed ".databases" command to use PRAGMA database_list. (CVS 967)
FossilOrigin-Name: bad2065337d8dcaacd519b8f1730a90f1c933c3e
2003-05-11 20:07:05 +00:00
drh 5fe2d8c913 Changes to comments. In particular, a lengthy comment was added to encode.c
that explains how the encoder algorithm works. (CVS 966)

FossilOrigin-Name: 8b388b2f690dbfd50eefc0fdede1c7785f78afa1
2003-05-10 03:36:53 +00:00
jplyon a3643a2697 Removed never-used symbol SQLITE_ResultDetails. (CVS 965)
FossilOrigin-Name: 26bd7bb1779e14f19c00e450aaa9529f2aabf131
2003-05-10 03:04:34 +00:00
jplyon f60482044d Removed never-used pragma "result_set_details". (CVS 964)
FossilOrigin-Name: bf558e79524c04339f1174dc935e39d47cb33457
2003-05-10 03:03:34 +00:00
jplyon 9098056e6f Documented the "GO" and "\" command terminators. (CVS 963)
FossilOrigin-Name: 6a76bd9590f372411e697f002285fe36ff3787ee
2003-05-10 02:54:56 +00:00
jplyon df2245df05 Fixed metacharacter coloring with LP, RP, PLUS.
Added more links. (CVS 962)

FossilOrigin-Name: 2bbb08049508829419dd9a3729241b97b017cf36
2003-05-10 02:54:02 +00:00
drh f94e371bbf Format keyword lists in lang.html using a TCL proc. (CVS 961)
FossilOrigin-Name: ca75f1ca12cd88dce688e272d73c3c2282079547
2003-05-07 13:37:31 +00:00
jplyon 3aacc84e45 - Added entries for PRAGMAs database_list, temp_store and default_temp_store.
- Fixed missing end tags. (CVS 960)

FossilOrigin-Name: 55ae7b35ee2dcebc99256d4b1e22a87ea75e3d03
2003-05-07 04:04:17 +00:00
jplyon b2ca13ed4d Cleaned up keywords section. (CVS 959)
FossilOrigin-Name: bb609f96e00fd62d932601c4aa37bc17baa82257
2003-05-07 03:59:10 +00:00
drh 8af4d3ace6 Restrain the flattener in the presence of outer joins. Ticket #306. (CVS 958)
FossilOrigin-Name: 6d4b6597e560578253960d9876dc8c8657f41fef
2003-05-06 20:35:16 +00:00
drh 66b4ebafb2 Added tests trying (unsuccessfully) to reproduce ticket #304. (CVS 957)
FossilOrigin-Name: fda637f453d35b74f676997fcf056a948ccd771b
2003-05-04 20:42:56 +00:00
drh e1e38c4d7d Shell command-line parsing enhancements suggested by Mike Hall. (CVS 956)
FossilOrigin-Name: 5656fe48b192dc84cb5977f826ff99d81684791f
2003-05-04 18:30:59 +00:00
drh 7ad4334add Fix deficiencies in sqlite_complete() pointed out by R. Dennis Cote. (CVS 955)
FossilOrigin-Name: 54b33a5ed9f7a89435c2f1395a3177e8c778bb8a
2003-05-04 17:58:25 +00:00
jplyon 5640433e48 Added shell command ".databases" to list name and file of open ones.
Added several missing shell commands. (CVS 954)

FossilOrigin-Name: dd57d6ae6a247824e44a6073bc7e73ecb3c500fd
2003-05-04 07:31:09 +00:00
jplyon 6a65bb3c06 added shell command ".databases" to list name and file of open ones. (CVS 953)
FossilOrigin-Name: 741a5a8d3975fb5db18914b7879b12aead59279b
2003-05-04 07:25:57 +00:00
jplyon b24fe71970 new section for keywords, more docs for attached databases , links, cleanup (CVS 952)
FossilOrigin-Name: 87e1b6a936972670771cf90670aeb4308ba0a30a
2003-05-04 07:02:55 +00:00
drh e96fa95e8a More documentation updates. (CVS 951)
FossilOrigin-Name: 24b9b569240d2108b17420d85cafdc718c67269f
2003-05-03 19:04:03 +00:00
jplyon 2bfc9dbdcf - added entry for ATTACH DATABASE.
- added entry for DETACH DATABASE.
- added soundex() function.
- added some new TEMP modifiers.
- added new VACUUM behavior.
- added the Oracle8 outer join "(+)" syntax.
- documented the modulus/remainder operator %.
- added ALL as alternative to DISTINCT in SELECT.
- fixed assignment list in UPDATE to use * metacharacter.
- fixed value in PRAGMA to be optional.
- added link from INSERT topic to REPLACE.
- added optional CONSTRAINT <name> before column constraints.
- skip 2 lines before each Section in the TCL source. (CVS 950)

FossilOrigin-Name: fd28c5229ece1d90e24d0ecaa518d8df5a4f55f0
2003-05-03 04:55:19 +00:00
drh e9ffc168d8 Additional tests of the new flattener added. Ticket #272. (CVS 949)
FossilOrigin-Name: 8d9ee45ab487614191e8d6aef845141fdddf832a
2003-05-02 16:44:25 +00:00
drh c31c2eb82c Enhance the query flattener to handle subqueries that are joins.
All regressions pass but new tests need to be added before release.
Ticket #272. (CVS 948)

FossilOrigin-Name: ad57693e9f1b83a8cc4d028264b35018a9a4a701
2003-05-02 16:04:17 +00:00
drh 6a3ea0e6ef VDBE cursors numbers for tables in a join do not have to be consecutive.
This is one step on the road to fixing ticket #272. (CVS 947)

FossilOrigin-Name: be7aed2011b4af868b6a0c370c3d41354ae0cdf4
2003-05-02 14:32:12 +00:00
drh 56e452cf3a Correctly create an index that uses an INTEGER PRIMARY KEY as one of columns
to be indexed. (CVS 946)

FossilOrigin-Name: 6d019e0baa3219614a9bc5b550a0f9fe3f7e731a
2003-05-01 16:56:03 +00:00
drh 44c2eb128d In the shell tool, delay opening the database until it is needed but also
make sure it is opened before trying to use the "db" pointer.  Ticket #302. (CVS 945)

FossilOrigin-Name: 20fcead42bc875f13eec52971530342ff00c5eda
2003-04-30 11:38:26 +00:00
drh a9b1716296 Accept a "/" or "go" on a line by itself as an SQL statement terminator
in the command-line shell.  This allows SQL Server and Oracle scripts to
be played into SQLite without change. (CVS 944)

FossilOrigin-Name: 8211f57b38b87a42c856e267bd243984b5abf9cc
2003-04-29 18:01:28 +00:00
drh 86e5cc058d Allow the ASC or DESC keyword to appear after a column name in a CREATE INDEX
statement.  SQLite indices are aways ASC (ascending) regardless of which
keyword is used. (CVS 943)

FossilOrigin-Name: 1a0c542088618ba24d1efae9b13a8eca104d6cc8
2003-04-29 17:19:18 +00:00
drh 63eb5f294c The sqlite_complete() function should ignore carriage-return characters.
(Oops - some unrelated edits also made it into this check-in.) (CVS 942)

FossilOrigin-Name: c6bf62e41cf44e8ebf740b103204b00e8b826c90
2003-04-29 16:20:44 +00:00
drh 7d8085a8e4 In the test code, make several attempts to convert a pointer to a string
and test each attempt to make sure it works before returnning, in order to
work around incompatibilities between various systems.  Ticket #284. (CVS 941)

FossilOrigin-Name: 333011ffddc0be91f76811458f03ad1ec0331b51
2003-04-26 13:19:38 +00:00
drh 70c7a4b1da Fix the shell tool to do a better job of ignoring whitespace. Ticket #234. (CVS 940)
FossilOrigin-Name: 639957e9f793eddce027050d2655863d82fe8ac9
2003-04-26 03:03:06 +00:00
drh 4328c8b7c7 Only print the "Loading resources from..." line when the output is a TTY.
Ticket #168. (CVS 939)

FossilOrigin-Name: 92ded93376635f37e2f5a7a8f4077c85d5bce735
2003-04-26 02:50:11 +00:00
drh aba46b19f5 Do not use the return value of fcntl() to find the reason that it failed.
Use errno instead.  Tickets #240 and #270. (CVS 938)

FossilOrigin-Name: acf9e9802fa6396df5653ca4e72ab4ec2333509d
2003-04-26 02:40:45 +00:00
drh 524a5bf5f6 Fix the sqlite_complete() routine so that it recognizes /*...*/ comments.
Ticket #277. (CVS 937)

FossilOrigin-Name: ef8eb580fc6c40264219c2ae77a9c4f8a5803c8b
2003-04-26 02:31:54 +00:00
drh 85e2096fb6 Report the correct authorization context in the authorization callback
when coding an INSTEAD OF trigger on an update or delete. (CVS 936)

FossilOrigin-Name: 67746833fc8de3afff80db413bd63a362bb28218
2003-04-25 17:52:11 +00:00
drh 2e6d11bc07 Add tests to insure VACUUM works in the presence of I/O errors. Fix some
problems that came to light by these tests. (CVS 935)

FossilOrigin-Name: 8d3e879349fc9523c72cb46111e0058b57ce9341
2003-04-25 15:37:57 +00:00
drh 9c05dc6298 Work around a name collision problem on windows. (CVS 934)
FossilOrigin-Name: c3b1f84dfce13b2523c9923e4270577862ca0595
2003-04-25 13:28:02 +00:00
drh f7c5753174 Make VACUUM work even if multiple processes have the database open at once. (CVS 933)
FossilOrigin-Name: caa960289f3d1f5e8f35a94e9e4321996c211ed2
2003-04-25 13:22:51 +00:00
drh fd9903de51 Explicit casts to squelch bogus warnings for vc++. Ticket #194. (CVS 932)
FossilOrigin-Name: cb808c14bc14e7bd1cfff134ae5206ace451f2df
2003-04-25 03:13:25 +00:00
drh 45a304ee8c Get VACUUM working again - with test cases. Some other minor cleanups. (CVS 931)
FossilOrigin-Name: 5afb88008fed253e6d1fc0ed5172370b61d3727b
2003-04-25 02:43:08 +00:00
drh 5cf590c128 Fix some issues with INSTEAD OF triggers. (CVS 930)
FossilOrigin-Name: 206b17397b1d2b55179c935927ff1d8215728c32
2003-04-24 01:45:04 +00:00
drh b5a20d3ceb Remove the begin_hook and commit_hook APIs. They were a bad idea. Add a
"trace" method to the TCL interface. (CVS 929)

FossilOrigin-Name: 6289b863590ecc5de3d1efaaa60aa6f3f64fefb3
2003-04-23 12:25:23 +00:00
drh e22a334b78 Update the authorizer API so that it reports the database that table and
indices belong to and so that it reports when actions are taken in response
to a trigger. (CVS 928)

FossilOrigin-Name: c675a5504138f34cae6def782b5d3add2c67d2bc
2003-04-22 20:30:37 +00:00
paul 3837237959 Check for readline libs now adds appropriate curses or termcap lib when needed (CVS 927)
FossilOrigin-Name: 393dd91c252531bb5abfe424b86a5f7eb20edcfc
2003-04-22 08:04:49 +00:00
drh f0f258b11b Add support for TEMPORARY triggers. Such triggers can write temporary or
permanent tables. (CVS 926)

FossilOrigin-Name: 58ddd587b0f5d565ae3b0ba3a1fa5c20d459f3fc
2003-04-21 18:48:45 +00:00
drh 881b890af4 Add more tests for the in-memory database. (CVS 925)
FossilOrigin-Name: 11cab41c4f02cdddc4fd3f57555573ac2814a81b
2003-04-20 23:45:23 +00:00
drh b2fe7d8cb7 Added tests for the in-memory database backend. Also updated some comments
in other modules. (CVS 924)

FossilOrigin-Name: fb89adf4d1325c5ea471759ebfd8df7faa4f9a80
2003-04-20 17:29:23 +00:00
paul 2dc96f9eb8 Align config vars controlling in-memory DB with code (CVS 923)
FossilOrigin-Name: 921656db9e3df865aea6b1abe1bc40b1acbeeb47
2003-04-20 11:46:34 +00:00
paul f00993a30a Reset pCur->eSkip on a MoveTo (CVS 922)
FossilOrigin-Name: d983accf4a702158f03742fb11959d0fd035a4b4
2003-04-20 11:41:04 +00:00
drh ea1ba17cda Update comments. Remove unused field from the Index structure. (CVS 921)
FossilOrigin-Name: 7084e05093e72f6e5b65ff0b574336898396826f
2003-04-20 00:00:23 +00:00
drh 7bdc0c1def Modify the optimizer so that it does not assume that functions are
constant. (CVS 920)

FossilOrigin-Name: 767f1af236d115e8388e1dcc28a4df1be48d6c85
2003-04-19 17:27:24 +00:00
drh 37ea94b8c9 Bug in WHERE clause processing fixed. Ticket #298. (CVS 919)
FossilOrigin-Name: 9b619c98b586a207a87942640d3a94220ff8ab02
2003-04-19 16:34:04 +00:00
drh 9d10f1d0f6 fix a memory leak in btree_rb.c. (CVS 918)
FossilOrigin-Name: 1e3d0d094776c2a429fa2a3eebc036a0b6374862
2003-04-18 22:52:38 +00:00
drh cab20050bb Fix for ticket #297 - bug in sqliteSortCompare(). (CVS 917)
FossilOrigin-Name: 4ded1965eb83dee0f28c27ba935d615c77331571
2003-04-18 17:45:14 +00:00
drh a5f668327b The VACUUM command is now functioning (again). Need to do more testing. (CVS 916)
FossilOrigin-Name: 6e948d9aaea109c683ac4fcc4714e335b545d22b
2003-04-18 02:31:04 +00:00
drh a69d91681d Fix triggers to work in an ATTACHed database. Ticket #295. (CVS 915)
FossilOrigin-Name: 1e5e00fb73c308378efd034cb291caf338c9fe84
2003-04-17 22:57:53 +00:00
drh d4d595f94c Make sure the min() and max() optimizations work on empty indexed tables.
Ticket #296. (CVS 914)

FossilOrigin-Name: 98ef6110068e5ed3cd77a14b004f890b79b731f7
2003-04-17 12:44:23 +00:00
drh 8396566204 Change the shell to use the sqliteIsNumber() routine for determining if
values are numeric.  Modified os.c so that it should now work with DJGPP -
though I have no way of testing this. (CVS 913)

FossilOrigin-Name: 35caefe31750fd103b5f0231ad36f375771063eb
2003-04-17 02:54:13 +00:00
drh 95b5084409 Rollback if a commit hook fails. (CVS 912)
FossilOrigin-Name: 5cea7554ae9d36434cd7261b5b40f3d467b836f1
2003-04-16 21:03:13 +00:00
drh 027850b676 Fix the authorizer so that it correctly interprets attempts to read the
OLD and NEW pseudo-tables of a trigger. (CVS 911)

FossilOrigin-Name: f04bd43254b3ba3fccc842214115d4c298e28138
2003-04-16 20:24:52 +00:00
drh bb07e9a34f Simplify the number processing code. Fix for ticket #281. (CVS 910)
FossilOrigin-Name: 4326b52a39cad4632dc2db37aa53a285a31af138
2003-04-16 02:17:35 +00:00
drh 144f9eadf6 Remove some unnecessary code and complication from the btree interface. (CVS 909)
FossilOrigin-Name: 35cc7c7d37d9ca486e7f300efe80a78a7f1064e2
2003-04-16 01:28:16 +00:00
drh 70ce3f0c58 Get triggers working on tables with INTEGER PRIMARY KEYs. Ticket #291.
This may also fix #159.  Still need to add tests so both bugs remain open
for the time being. (CVS 908)

FossilOrigin-Name: 0b996959b8d8bc2c82eab9cccc190befd0056505
2003-04-15 19:22:22 +00:00
paul 048bd5937b Added btree_rb.c (CVS 907)
FossilOrigin-Name: 93eb6c52aca8de15a88247ec986c36245527ec7b
2003-04-15 17:22:30 +00:00
drh 49449834fc Do not record the inserted rowid on when doing an INSERT within a trigger.
Ticket #290. (CVS 906)

FossilOrigin-Name: 96a717661a3b7108fe0cacb588d81fd8e91eb640
2003-04-15 14:01:43 +00:00
drh f9a2e7bb8d Change lemon to use <stdarg.h> instead of <varargs.h> because GCC no longer
supports varargs.h.  Tickets #288 and #280.  Ironically, lemon originally
used varargs.h because stdarg.h was not supported by the compiler I was
using in 1989 (which was gcc if I recall correctly.) (CVS 905)

FossilOrigin-Name: 7902e4778ec86e25ad949ae7a6d55b63ac0e85f3
2003-04-15 01:49:48 +00:00
drh 13bff81537 Change some variable names and comments in the new in-memory database file
implementation.  Partial (non-working) implementation of the VACUUM command. (CVS 904)

FossilOrigin-Name: e76787f877c456abdc8bc88bfefc50eaeed68744
2003-04-15 01:19:47 +00:00
paul b0208ccaa3 Support in-memory databases for temp tables (CVS 903)
FossilOrigin-Name: 96336bffde6c441af197a521ee9e56fdfd7efff8
2003-04-13 18:26:49 +00:00
drh c11d4f9360 Split the implementation of COPY, PRAGMA, and ATTACH into separate
source code files. (CVS 902)

FossilOrigin-Name: 73359037ea639abb066c74db9c19e84bf1104006
2003-04-06 21:08:24 +00:00
drh e1051c653e Move the implementation of VACUUM into a separate source file. (CVS 901)
FossilOrigin-Name: b123c165fd3d0a5a86ee8a7baa669105dafb481a
2003-04-06 20:52:32 +00:00
drh 73509eee84 Simplify the BTree interface by shortening names. Added two new methods
for accessing the current filename and for changing the name of the
database file. (CVS 900)

FossilOrigin-Name: 185d8dc8d0c26cef36aeba6992823e5124af4056
2003-04-06 20:44:45 +00:00
drh a73af533de More testing of ATTACH and DETACH. (CVS 899)
FossilOrigin-Name: 51f515f28cb1cc3e8f0c3531724dc8876b25f18e
2003-04-05 16:56:28 +00:00
drh 2d4583473b Begin testing the new ATTACH and DETACH commands. (CVS 898)
FossilOrigin-Name: 7a0f8024a1323a15d0c83afe9302400736f01fe8
2003-04-05 03:42:26 +00:00
drh f539f6a7e9 Fix for ticket #276. (CVS 897)
FossilOrigin-Name: 452128c6fd9a0d82bfab21374fc2041638d264db
2003-04-03 19:35:02 +00:00
drh 0d1a643aea Added experimental APIs: sqlite_begin_hook() and sqlite_commit_hook(). (CVS 896)
FossilOrigin-Name: 5efbf62313519d0a6e8b8f5dbb29d3ef428d73e8
2003-04-03 15:46:04 +00:00
drh 048c530c01 Use a intermediate table when inserting a TEMP table from a SELECT that
reads from that same TEMP table.  Ticket #275. (CVS 895)

FossilOrigin-Name: 087d1e83af12b3a9aedd4945f02774a1043b1eb4
2003-04-03 01:50:44 +00:00
paul b95a8864c9 Add infrastructure to suport multiple btree implementations (CVS 894)
FossilOrigin-Name: 79b3aed2a74a67cbad631c4e2e4a43469d80c162
2003-04-01 21:16:41 +00:00
drh 738a68b250 Minor follow-on changes to the recent ATTACH patch. (CVS 893)
FossilOrigin-Name: 11378c5bf988412f8564cdc0314fc241793b292e
2003-03-31 13:36:09 +00:00
drh 665de47ac3 Minor follow-on changes to the recent ATTACH patch. (CVS 892)
FossilOrigin-Name: e80afe75b33d4eacb40ef6128cf688f7c3253984
2003-03-31 13:36:09 +00:00
drh da93d238c2 Add the sqliteErrorMsg() function and use it to generate error message
text during parsing and code generation.  This simplifies the code
somewhat and makes it easier to handle names with a database prefix. (CVS 891)

FossilOrigin-Name: 1d3fc977211abdc7ba3fd51d661863e8ce5aef69
2003-03-31 02:12:46 +00:00
drh 1c2d84148a The ATTACH and DETACH statements are now coded but are still mostly untested. (CVS 890)
FossilOrigin-Name: c7c5e927a54f0fbc2ca625754787aff4d9c4eff1
2003-03-31 00:30:47 +00:00
drh 180487389b Remove the experimental sqlite_open_aux_file() API. It will soon be replaced
by ATTACH and DETACH SQL commands. (CVS 1732)

FossilOrigin-Name: 0a358844e40020557c1aeea5779b194670350930
2003-03-30 19:17:02 +00:00
drh 3aa31a16e6 Remove the experimental sqlite_open_aux_file() API. It will soon be replaced
by ATTACH and DETACH SQL commands. (CVS 889)

FossilOrigin-Name: b6d6e07f3a5cb493f2cf0675bc6061c5afe5c078
2003-03-30 19:17:01 +00:00
drh 9077ba8ee5 Remove the obsolete documentation on how to crosscompile version 1.0 of
SQLite. (CVS 888)

FossilOrigin-Name: ac0622bf5fca9c8907319a20158e991efdaa6402
2003-03-30 18:58:58 +00:00
drh 1dd8c40e8f Detect when a child node of a btree page has zero entries and report that
as a case of database corruption. (CVS 887)

FossilOrigin-Name: 66c80ae232a78ecb010280ab1aa684cb78b0662f
2003-03-30 18:41:22 +00:00
drh 0be9df076a Fix a memory leak in triggers and update tests to show the latest error
message text. (CVS 886)

FossilOrigin-Name: b90d9de32d10a71fe81f5bfd0cf57faae8c5c3b4
2003-03-30 00:19:49 +00:00
drh 812d7a21dd Regression tests now work - except for some changes in error message
text.  The library is now safe to use for experimental work. (CVS 885)

FossilOrigin-Name: 8a593e9c2d57e758739a7ef54fa40ca6a0071a9a
2003-03-27 13:50:00 +00:00
drh 0951d703f2 Fix a segfault in the trigger code. (CVS 884)
FossilOrigin-Name: 7672914b196cd55744edda8e5d8f1b7b86f898f9
2003-03-27 13:01:28 +00:00
drh 1694cab424 Changes to the "sqlite" structure that allow simultaneous operations on
multiple database files.  Many regession tests pass - but not all of them.
Do not use this version except for debugging SQLite itself. (CVS 1731)

FossilOrigin-Name: 9ac71c329e17a0934d2a824eacc33e9a2ebce7c3
2003-03-27 12:51:25 +00:00
drh d24cc427b7 Changes to the "sqlite" structure that allow simultaneous operations on
multiple database files.  Many regession tests pass - but not all of them.
Do not use this version except for debugging SQLite itself. (CVS 883)

FossilOrigin-Name: d2fb2bb50cf1e13feb90995079f291384abd6ba9
2003-03-27 12:51:24 +00:00
a.rottmann 84e6335c0c Re-generated. (CVS 882)
FossilOrigin-Name: f0c5bcf72cf393ea4c5cd126d085cb959eebd5f2
2003-03-24 09:42:16 +00:00
a.rottmann 62507b650a Updated libtool. (CVS 881)
FossilOrigin-Name: b1ca4e13dcab92cc532f4051f24bf5b1be251463
2003-03-24 09:40:34 +00:00
a.rottmann c7e9383a9e Added pkg-config support. (CVS 880)
FossilOrigin-Name: ec1c5a611307047dd0049353e989e75dcaffaa45
2003-03-24 09:39:32 +00:00
drh 113088ec68 Record the database name in addition to the table name for DELETE, INSERT,
and UPDATE statements. (CVS 879)

FossilOrigin-Name: a5d8fc95ee58dc3205a0bbbcadaa3b9c902a941b
2003-03-20 01:16:58 +00:00
drh 001bbcbb8f Modifications to the VDBE to support more than one database file. (CVS 878)
FossilOrigin-Name: 875da9eed981bfa27b98e95025f9fdbed74b4098
2003-03-19 03:14:00 +00:00
drh 9468c7f489 Do not allow an empty string to be inserted into an INTEGER PRIMARY KEY. (CVS 877)
FossilOrigin-Name: 2aba40bea5fc1c4aef8cfd4c790d40808821ca14
2003-03-07 19:50:07 +00:00
drh 2299706c2a Add more tests to make sure that sqlite_changes() works when using the
non-callback API.  Ticket #250. (CVS 876)

FossilOrigin-Name: 13e501d190e327cc6fc16e182819ea9d7bb9c566
2003-03-01 19:53:15 +00:00
drh dde85d9e00 Get the non-callback API working with the EXPLAIN keyword and for PRAGMAs.
Tickets #258 and #257.  Update the API documentation on the sqlite_changes()
routine to explain how it works with the non-callback API.  Ticket #250. (CVS 875)

FossilOrigin-Name: 620e1065e978545dd7bf6fa6fad1e6b93918dbf8
2003-03-01 19:45:34 +00:00
drh 627a71efa7 Fix a memory leak associated with PRIMARY KEY in a CREATE TABLE statement
that fails.  Ticket #249. (CVS 874)

FossilOrigin-Name: 8e9dc567996c3301c14a1f055ff2265770cbc3e1
2003-02-26 13:52:52 +00:00
drh e0194f2bbd Fix a memory leak associated with PRIMARY KEY in a CREATE TABLE statement
that fails.  Ticket #249. (CVS 1730)

FossilOrigin-Name: 66158843dfa073ffb8779a5170e091cebc018855
2003-02-26 13:52:51 +00:00
drh 50cceb36b6 When the right table in a LEFT OUTER JOIN contains an INTEGER PRIMARY KEY
make sure that key is NULL if there is no row in the right table that
matches the current row in the left table.  Tickets #246 and #247. (CVS 873)

FossilOrigin-Name: 6a45fe3bd7e19cf9c20fc6cb65b0269cdd704490
2003-02-20 01:48:12 +00:00
drh e6da3c1816 Fix the parsing of the LIMIT clause when the limit and offset are separated
by a comma.  The offset comes before the limit in that case. Ticket #245. (CVS 872)

FossilOrigin-Name: 6ef91a364b2922f078b7de81816bca3f2ca0fe46
2003-02-20 00:44:52 +00:00
drh 30710453ca Version 2.8.0 (CVS 870)
FossilOrigin-Name: 5db98b3f4048fc8cd28d8fd225f2b0221ccf1d17
2003-02-16 22:49:47 +00:00
drh be992ef9c9 Couple of last-minute changes before 2.8.0. (CVS 871)
FossilOrigin-Name: 8192c937d524fef703d7ba2eb608c3d74e20440f
2003-02-16 22:48:12 +00:00
drh ad636221bb Update the speed comparison documentation to show the improved performance
of PostgreSQL after performance tuning. (CVS 869)

FossilOrigin-Name: 73c904e57a158820705daf5737e0fc825cfe1aea
2003-02-16 22:36:03 +00:00
drh 94e9203247 Added test code to check for file descriptor leaks. All regression tests pass
now on both win2k and linux. (CVS 868)

FossilOrigin-Name: 75ba78280f7ab6b6acce5878859312f3223ee898
2003-02-16 22:21:32 +00:00
drh 99ee360003 Fix more bugs. The new rollback journal implementation now passes all
regression tests under Linux. (CVS 867)

FossilOrigin-Name: d10adc1c5727d76320d5919be55e86d030e9c8bc
2003-02-16 19:13:36 +00:00
drh 4303feedd3 Fix the pager so that correct rollbacks occur when synchronous is turned off.
This check-in also included unrelated documentation updates. (CVS 866)

FossilOrigin-Name: 3ef0ad8a4f2696a58aff9d812f90038c2c63f3fc
2003-02-15 23:09:17 +00:00
drh 32c4a833e0 Update the documentation for the new journal format to be introduced in
version 2.8.0. (CVS 1729)

FossilOrigin-Name: dc53d92141c931fb133149355c3a1ea64030e676
2003-02-13 02:54:03 +00:00
drh 5527f8ff4a Update the documentation for the new journal format to be introduced in
version 2.8.0. (CVS 865)

FossilOrigin-Name: e05a7a552f694158ee449d8682f5c137f1c2f2ac
2003-02-13 02:54:03 +00:00
drh 4a0681ef1b Fix a bug in the rollback logic for the new journal format. (CVS 864)
FossilOrigin-Name: 7c22aa3f817e737cfd943d903856756468e8678b
2003-02-13 01:58:20 +00:00
drh 8ba1b31379 Added the new FULL option to the SYNCHRONOUS pragma. Still need to test it. (CVS 1728)
FossilOrigin-Name: 8968bc063607856775ad63b6594d40c55cf288c0
2003-02-12 14:09:43 +00:00
drh 973b6e333d Added the new FULL option to the SYNCHRONOUS pragma. Still need to test it. (CVS 863)
FossilOrigin-Name: 792a9e157dd066fcaffd4f5b373010151fb4ca61
2003-02-12 14:09:42 +00:00
drh d8d66e8ca0 Fix a bug in the legacy journal format writing logic. (CVS 862)
FossilOrigin-Name: 6c927dd36c19ebb8bb8222b4d18ed67f4fe733e8
2003-02-12 02:10:15 +00:00
drh 968af52acf Modify the journal format to be more robust against garbage that might appear
in the file after a power failure.  The changes are mostly working but more
testing is still required.  This check-in is to checkpoint the changes so far. (CVS 861)

FossilOrigin-Name: 8ec5632536eea31197a3b1fd6abc57881a0cf1d7
2003-02-11 14:55:40 +00:00
drh 324ccefeb5 Make the shell run much faster for inputs where a single SQL statement spans
thousands of lines by avoiding the call to sqlite_complete() unless the
input ends in a semicolon. (CVS 860)

FossilOrigin-Name: e21afb82b53eade9ee267a97c58db0606f0c0a41
2003-02-05 14:06:20 +00:00
drh bb999ef6fa Make the GROUP BY clause work even if there are no aggregate functions. (CVS 859)
FossilOrigin-Name: b68792315883eed8523f5e11856ec8378dc972c1
2003-02-02 12:41:25 +00:00
drh 17e9e29d1e When a CREATE TABLE ... AS SELECT statement fails, make sure the table name
is removed from the internal hash tables.  Ticket #238. (CVS 858)

FossilOrigin-Name: 65264780c553e8a00ec7a40cf76b89a11b245faf
2003-02-01 13:53:28 +00:00
drh dcd997ea2e The sqlite_exec() function now returns SQLITE_AUTH when authorization fails.
Ticket #231. (CVS 857)

FossilOrigin-Name: d93c1aeb544a5b1056424945eb43854213b30e50
2003-01-31 17:21:49 +00:00
drh 88eee38afd Allow double-quoted strings as string constants in the IN operator. As a
side-efffect, allow the GROUP BY clause to refer to columns by their integer
column number.  Ticket #237. (CVS 856)

FossilOrigin-Name: 187d9c405891e543fc706f8ddb41f3966a842214
2003-01-31 17:16:36 +00:00
drh 3a84069da3 Additional testing and bug fixing with the non-callback API. Updated the
C/C++ interface document to describe the non-callback API. (CVS 855)

FossilOrigin-Name: af1e9299468aa70d7d91e7a5445ba391ccc8ff8b
2003-01-29 22:58:26 +00:00
drh 483750ba8a Better error messages on constraint violations. Additional tests and bug fixes
for the callback-free API. (CVS 854)

FossilOrigin-Name: ccc82f1ab4539a60ee5cc2625743c5389f9ccd8e
2003-01-29 18:46:51 +00:00
drh 326dce7451 The callback-free API is now working, though much more testing is need. (CVS 853)
FossilOrigin-Name: 162b259188e6967fe9c3722da26b81aab5655d83
2003-01-29 14:06:07 +00:00
drh b86ccfb26e First code for the new callback-free API. All regression tests pass but the
new API is mostly untested and is unlikely to work. (CVS 852)

FossilOrigin-Name: 065fa818ffc8d7562889172acea16e4e44e773ef
2003-01-28 23:13:10 +00:00
jplyon 70c15b48ae Added section on comments.
Corrected broken </p> end tags. (CVS 851)

FossilOrigin-Name: c957f4f0c6b486f25bc567dafeed186f91c8c315
2003-01-26 15:28:18 +00:00
drh 79740a572e Version 2.7.6 (CVS 850)
FossilOrigin-Name: bdba796f3b89690ab5d53a9e16924383ef72657c
2003-01-25 16:32:13 +00:00
drh a218b6a22a Fix a bug in the rollback validation logic (code that only runs during
debugging).  The problem was introduced by check-in (835). (CVS 849)

FossilOrigin-Name: b6ea0da76a27a4a67a3978c53405840518de2379
2003-01-25 15:43:22 +00:00
drh a3da6fafd7 Remove an unused variable. (CVS 848)
FossilOrigin-Name: 18f4ffaa2ed89784a1ea3c61c864d20e18fa1e9f
2003-01-25 14:34:23 +00:00
drh 2ac83073e0 Preparations for the release of version 2.7.6. (CVS 847)
FossilOrigin-Name: 5143d4814df1dd440a362a90dd3f328c84527565
2003-01-25 14:32:03 +00:00
drh ced87a65a8 Update the speed.html documentation. Recent optimizations have made the
library much faster. (CVS 846)

FossilOrigin-Name: ed47d162a072a2f98b633cc14f2be1474288d90b
2003-01-25 14:25:42 +00:00
drh d62d3d0d24 Add asserts to btree.c that check for the correct size of various typedefs
and structures.  Ticket #233. (CVS 845)

FossilOrigin-Name: c7e647d011b086a6e57420850f6bc4f28fcb23ee
2003-01-24 12:14:20 +00:00
drh 2554f8b0c0 Minor refinements to the pager. (CVS 844)
FossilOrigin-Name: 19221dee5fee4c8800cbae309f009964c8d646a2
2003-01-22 01:26:44 +00:00
drh 4764f161ab fix a typo on the quickstart.html page. (CVS 843)
FossilOrigin-Name: 61869bb51b981a47d783cc8739833cc0c4733b0a
2003-01-21 23:06:57 +00:00
drh 341eae8d35 In the pager, cache a pointer to the first page on the freelist that does not
need to be synced.  This makes a fetch of a page that is not in cache go a
lot faster when the cache is full.  This check-in also adds some performance
instrumentation to the OS layer. (CVS 842)

FossilOrigin-Name: 00f08fc0b5b6b9c5efbf15a62f9a1cc1cfa71283
2003-01-21 02:39:36 +00:00
drh e78e8284ad Update comments. No changes to code. (CVS 841)
FossilOrigin-Name: f6a8706872c43cee3003b48bb427c7b74b1f89e7
2003-01-19 03:59:45 +00:00
drh 79104c9d2a Update the speed comparison page. (CVS 840)
FossilOrigin-Name: 424cb2edb0c51b911791422ce7a9f5284a57f9ce
2003-01-18 22:01:06 +00:00
drh fcb78a4900 Fix datatype reporting and collating sequence selection so that it works
correctly on views and with the UNION, EXCEPT, and INTERCEPT operators. (CVS 839)

FossilOrigin-Name: 71cc292dce59cf8224b205d1cdbff59ad12f1043
2003-01-18 20:11:05 +00:00
drh be4f31c226 Do not report an error if the input to the sqlite shell ends in a comment.
Ticket #211. (CVS 838)

FossilOrigin-Name: 32a8e6e9771d636c0ad3042632d35865bc08585b
2003-01-18 17:05:00 +00:00
drh 799550beb0 Check the validity of the database connection before the trace callback,
not afterwards. (CVS 837)

FossilOrigin-Name: 960a2e4af3b940d74a82f98e8bf19aeec88a05ce
2003-01-18 17:04:08 +00:00
drh 18de4824f6 Add the sqlite_trace() hook for tracing the SQL that an application executes.
The plan is to leave this API undocumented for the time being, in case we
want to make changes to it later. (CVS 836)

FossilOrigin-Name: f67bff8ff3db9694f87daf1a549d24ea9612da6b
2003-01-16 16:28:53 +00:00
drh db48ee02c4 Improvements to the pager to help large updates against a large database run
faster.  Also improved the testing of the pager rollback algorithms. (CVS 835)

FossilOrigin-Name: 717523d3750dce784fa767ed9a8267d1246798ef
2003-01-16 13:42:43 +00:00
drh 2c3831cb23 Finish out the test suite for the new sqlite_set_authorizer API. (CVS 834)
FossilOrigin-Name: 701a73918db22fd134a8b959670ba7a4a908c8c5
2003-01-14 13:48:20 +00:00
drh bf0c78af2f Fix a memory leak in the PRAGMA authorization code. (CVS 833)
FossilOrigin-Name: ba58979f2ff3ec878a21e7c171fbcd8fa79ace6f
2003-01-14 02:54:08 +00:00
drh 77ad4e4133 More tests of the sqlite_set_authorizer() API together with fixes for bugs
that the new tests uncovered. (CVS 832)

FossilOrigin-Name: cc2ae781ac186f9ee1afacdc9117087421955369
2003-01-14 02:49:27 +00:00
drh 7160220495 Make the GLOB work write with upper-case characters. Ticket #226. (CVS 831)
FossilOrigin-Name: 7ea46e706485cc159f9d1c7e69efcdd048a0bb12
2003-01-14 00:44:08 +00:00
drh e5f9c6442f Revise the sqlite_set_authorizer API to provide more detailed information
about the SQL statement being authorized.  Only partially tested so far. (CVS 830)

FossilOrigin-Name: 45de93f913a18026a45de6254963dbcd1b0f1a19
2003-01-13 23:27:31 +00:00
drh 1962bda764 The initial round of tests for the sqlite_set_authorizer() API. More are
needed before release.  Ticket #215. (CVS 829)

FossilOrigin-Name: 5707b3d56efb6e988f816abefb1836f2f3254117
2003-01-12 19:33:52 +00:00
drh e6d01c3a04 Forgot to include the new "auth.c" source file in the previous checkin. (CVS 828)
FossilOrigin-Name: 7601916419489879fe963c83010b452c49ef063f
2003-01-12 18:07:48 +00:00
drh ed6c8671b3 Initial check-in of the code for the new sqlite_set_authorizer() API function.
The code is mostly untested at this point. (CVS 827)

FossilOrigin-Name: 52d5007f64d0af5286b2a0e1f0b9e53c86bece3f
2003-01-12 18:02:16 +00:00
drh 49f0936ec7 Remove an unused variable from the VDBE. Ticket #223. (CVS 826)
FossilOrigin-Name: 0deaf563fd9784bf0795107cd10e6b3269dfecea
2003-01-12 17:35:00 +00:00
drh f27134cdc4 Change the PopStack() routine so that it doesn't confuse bounds checkers.
Ticket #222. (CVS 825)

FossilOrigin-Name: fc11fa50b8f39f5e0b3674d7df832ffbca0d948f
2003-01-12 17:28:19 +00:00
drh fa9e0df21b Remove the aOrder() array from where.c. (CVS 824)
FossilOrigin-Name: b2c1edb47f481cafe6718bafcdb517cca160a44d
2003-01-11 15:02:44 +00:00
drh fd15981daa Fix two compiler warnings from OS-X. (CVS 823)
FossilOrigin-Name: 4c22da76ca91f3c59dac1c529e82ac3b04b767bd
2003-01-11 14:25:39 +00:00
drh 5a38705ecb Document the SHOW_DATATYPES pragma and add tests for it to the test suite.
Make sure datatypes are show even for aliased columns.
Tickets #220 and #221. (CVS 822)

FossilOrigin-Name: e84d3afe7b9153d003fdcca98221f446c004ffa2
2003-01-11 14:19:51 +00:00
drh 836faa4843 Remove the ColumnCount opcode, which had become a no-op. (CVS 821)
FossilOrigin-Name: 86deb12d68026913d181f9498144fa56445899f2
2003-01-11 13:30:57 +00:00
drh 820f3812d8 Port ot MacOS Classic. Ticket #218. (CVS 820)
FossilOrigin-Name: 13f82d67f60ae869d5bf2e31d9357a860aa62bad
2003-01-08 13:02:52 +00:00
drh 9bd47a97c0 Avoid calling truncate() and stat() on the checkpoint journal to improve the
speed of a large number of UPDATEs within a transaction. (CVS 819)

FossilOrigin-Name: 2f89e9e6963cb715f3671f1fdbf4c966aadff6c8
2003-01-07 14:46:08 +00:00
drh 2b8ef743af In the VDBE, allocate space to hold column names when the VDBE first starts.
The ColumnCount opcode now just writes the null terminator into this space. (CVS 818)

FossilOrigin-Name: 46d8f5e377bf790c18a7acdd1f3bc20b538d69eb
2003-01-07 13:55:22 +00:00
drh 371ac44d1c When constructing records and index keys, use static string space rather than
mallocing (when possible) for a small speed improvement. (CVS 817)

FossilOrigin-Name: 657c9fb5133aef93e4edd433912e6942ad9674ec
2003-01-07 13:43:45 +00:00
drh caec2f12a9 More optimizations. (CVS 816)
FossilOrigin-Name: a362981b20fd33254ad498619eedf75b576682e3
2003-01-07 02:47:47 +00:00
drh 32eb7b47ca Optimizations to the tokenizer. (CVS 815)
FossilOrigin-Name: 032b3daa1d3cf3e00a4a6ba0b09624f1aba6445c
2003-01-07 01:44:37 +00:00
drh 3e87c7abeb Remove unnecessary code from the VDBE. (CVS 814)
FossilOrigin-Name: b96ec281ff29aad8af340b30c6ff4e129ffeeefb
2003-01-06 23:54:05 +00:00
drh 8178a75a11 More optimizations. (CVS 813)
FossilOrigin-Name: 5809132f5bf40bae2331f887e87fe5baecc15c46
2003-01-05 21:41:40 +00:00
drh c3b7057705 Parameterize the number of adjacent pages that participate in the balancing
algorithm in the BTree.  But leave the setting at the current value of 3. (CVS 812)

FossilOrigin-Name: 6c304024bbd21a1886a57ada795531349aa627d7
2003-01-04 19:44:07 +00:00
drh bb49aba82a Another optimization to the btree logic. (CVS 811)
FossilOrigin-Name: 03d20673616cae0dca524fd04557798a98fb7069
2003-01-04 18:53:27 +00:00
drh 428ae8cb41 Optimizations to the BTree module for a modest speed improvement. (CVS 810)
FossilOrigin-Name: 39902a70417475225956704a037493515e9b08b9
2003-01-04 16:48:09 +00:00
drh 2c79995565 Allow the rollback journal to be empty except for its header.
Ticket #212. (CVS 809)

FossilOrigin-Name: 1ba41bc2afab18cc295d9a45845296b46bfa57e5
2003-01-03 02:04:27 +00:00
drh 8c1238aebd Code optimizations to help the library run faster. (CVS 808)
FossilOrigin-Name: db745e87dc26cf1a35cdcec18f4b659742e14120
2003-01-02 14:43:55 +00:00
drh 7b39686749 If compiled with the -DVDBE_PROFILE=1 option, special code is inserted that
uses the pentium RDTSC instruction to compute very precise runtimes on all
VDBE opcodes.  (This only works on i586 processors, of course.)  The results
are written into the vdbe_profile.out file for analysis. Hopefully, this
new feature will reveal hot spots that can be optimized to make the VDBE run
faster. (CVS 807)

FossilOrigin-Name: a1c071ea18766932c90275c704e078134c67be68
2003-01-01 23:06:20 +00:00
drh c64e0ba45c Version 2.7.5 (CVS 806)
FossilOrigin-Name: ee95eefe12c48f28412461125c231122e0d4277a
2002-12-28 01:26:07 +00:00
drh 919792ecb9 Update the version number to 2.7.5. (CVS 805)
FossilOrigin-Name: b0864cc9c89a3c2350ac46634ef3c420f97d11c0
2002-12-28 01:10:14 +00:00
drh 80eb79055e Fix an uninitialized variable in the pager. Tickets #208 and #206.
Bug introduced by check-in (795). (CVS 804)

FossilOrigin-Name: f3dc686e0258a9588e1433a89ac46795f76beeae
2002-12-28 01:06:30 +00:00
drh 5d1f0d4c89 Version 2.7.4 (CVS 803)
FossilOrigin-Name: 0224db6f8ce5e3cecc4432f3966b8f59f80e9303
2002-12-17 22:50:45 +00:00
drh 3450e1d3c2 Preparing for the 2.7.4 release. (CVS 802)
FossilOrigin-Name: f685ae15b1179baeadfadbaef0a73b001c96fac5
2002-12-17 14:30:42 +00:00
drh f1337bb5ff If the "fake_big_file" command fails, be sure to close the file before
returning. (CVS 801)

FossilOrigin-Name: fa1b5e2119617b111c6b463bbf641ddcb9972cae
2002-12-17 14:19:49 +00:00
drh f33cb428e5 Make sure the host machine has enough disk space before running the
large file tests. (CVS 800)

FossilOrigin-Name: b1ec547865a76541951433630bd4528d1988a4de
2002-12-17 14:13:48 +00:00
drh e7e8bc7739 Take care not to modify the sqlite* pointer to sqlite_exec() if we suspect
that the pointer is stale - that it has previously been passed to
sqlite_close().  Possible fix for ticket #202.  Prior to this fix, test
misuse-5.3 was causing a change to a buffer that had been previously free()-ed. (CVS 799)

FossilOrigin-Name: f04547edfa1643ce52925d317915badfc676bd8b
2002-12-17 13:05:25 +00:00
drh 3e7a609667 Save the full pathname of the database file so that journalling still works
even if the user changes working directories after opening the databae.
Ticket #200. (CVS 798)

FossilOrigin-Name: 1c58b4fc032c5975dcce9b8ae844c0e516254a17
2002-12-07 21:45:14 +00:00
drh 1a844c380b Fix a bug in the reverse scan logic that comes up when the table being
scanned is empty.  Add additional tests for the reverse scan. (CVS 797)

FossilOrigin-Name: 0051c87d5e8d07fae09da2eb7b0d8cbd1bbd3c8e
2002-12-04 22:29:28 +00:00
drh dd4852c3d1 Fixes to the logic that decides if the ORDER BY can be ignored due to the
use of an index.  Tests updated. (CVS 796)

FossilOrigin-Name: bfb9a2aa939ecffc5dc2c7c23bddd57d357bdf13
2002-12-04 21:50:16 +00:00
drh c045ec51be Scan the table backwards if there is an ORDER BY ... DESC clause that can
be satisfied by an index. (CVS 795)

FossilOrigin-Name: c7a3487981de0ed5b43ea3ff4d46ab4437068dca
2002-12-04 20:01:06 +00:00
drh 2dcc9aa2a8 Add the sqliteBtreePrevious() routine to the BTree module API. This is
in anticipation of implementing reverse order searching of a table. (CVS 794)

FossilOrigin-Name: 0ad1d93879bee0d34b122591c025192a51b8490f
2002-12-04 13:40:25 +00:00
drh c66c5a266b Allow an aggregate function in the HAVING clause even if no aggregates appear
in the result set.  Ticket #187. (CVS 793)

FossilOrigin-Name: 33c6fd6b3dc271fa1f2d4500b4f76c736accefce
2002-12-03 02:34:49 +00:00
drh 174b619591 Honor ORDER BY clauses in VIEWs. Ticket #193. (CVS 792)
FossilOrigin-Name: dbf7893234a6c5d6bb2d931e52080bb05784c0c9
2002-12-03 02:22:52 +00:00
drh da47d7748f Change to the pager to avoid opening journal files unnecessarily. This can
sometimes results in a significant speed improvement. (CVS 791)

FossilOrigin-Name: fa5c042585c601449ede7319d0c5993cd8ba75a4
2002-12-02 04:25:19 +00:00
drh d0d006e29c Fixed large file support under Linux. I'm unable to test under Windows.
Ticket #191. (CVS 790)

FossilOrigin-Name: 9864a1265b5a37c12b0dd8446d81b84c5a3acc43
2002-12-01 02:00:57 +00:00
drh 86bc1c8273 Add the "space_used.tcl" script to the tools directory. This script is used
to measure how much disk space is used by each table and index of a database. (CVS 789)

FossilOrigin-Name: 83b2c27a568cd67cd5162d513766b23ff9fc2227
2002-11-24 14:52:27 +00:00
drh 58f391b36f Automatically determine if pointers are 4 or 8 bytes in size during the
compilation process.  Ticket #190. (CVS 788)

FossilOrigin-Name: dd5396a73a782b6abe9da3de43a5ee11e0dddbb2
2002-11-20 11:55:18 +00:00
drh 7cdbd32c8e Get the new large file code working with the Borland compiler. Ticket #195. (CVS 787)
FossilOrigin-Name: da4a79e2891aa81e2e6d96689f99b3924f940dd5
2002-11-20 11:07:59 +00:00
drh 7d686b2d57 Remove extra </TD> from HTML output. Ticket #189. (CVS 786)
FossilOrigin-Name: dc5d9c129c566bf57d108b824ba486cfe070dda6
2002-11-11 13:56:47 +00:00
drh 4d9ef4c4ef Back out the changes in the pager that sorted pages prior to writing them
to the database.  Additional measurements showed no performance gains. (CVS 785)

FossilOrigin-Name: 745d66395daf5cb8463305bbc9e4219534d2b7cf
2002-11-11 01:04:47 +00:00
drh 32c05e993f Replace the atoi() library routine with a faster home-grown version in the
VDBE.  This gives a dramatic speed improvement for some kinds of queries. (CVS 784)

FossilOrigin-Name: 263a8ca40f7ff66fbdcb43bf9032391d5b1e68bd
2002-11-11 00:05:42 +00:00
drh 03eb96a7b2 Two optimizations to the pager: (1) Write dirty pages back to the database
file in order and (2) Keep a separate list of in-memory pages that are in
the checkpoint journal in order to speed a checkpoint commit. (CVS 783)

FossilOrigin-Name: a6ef6657a4377684dc2fce7be2bbf009fd2d2f37
2002-11-10 23:32:56 +00:00
drh 8766c34348 Try to better detect when the library is compiled for large file support (LFS)
but the support is not available in the host OS kernel. (CVS 782)

FossilOrigin-Name: a29d60ecc5ee3f535142a81f56eecbef7875ef22
2002-11-09 00:33:15 +00:00
drh 829e802992 Add large file support to Windows. Change large file support for Unix so
that it compiles automatically - without requiring special options on the
compiler command line. (CVS 781)

FossilOrigin-Name: 2008b56fe11e49d52e28f47d14ccd70504e6c094
2002-11-06 14:08:11 +00:00
drh 20e9ab16d8 Changes to include files so that the >2GB file patch will compile under BSD. (CVS 780)
FossilOrigin-Name: 81bb1aed5e9094a9655bd03614bb111d79896928
2002-11-06 00:59:44 +00:00
drh f87e9de4c4 Update the FAQ to explain how to enable large file support. (CVS 779)
FossilOrigin-Name: 4caf624e9061fe7489a8e3c6892975036a2272d5
2002-11-05 23:24:38 +00:00
drh 28be87c7c4 Add support for databases larger than 2GB under Unix. Must be compiled
with -D_FILE_OFFSET_BITS=64 and -D_LARGEFILE_SOURCE in order to work with
larger databases. (CVS 778)

FossilOrigin-Name: a3f67fe9121ca4655510094fe775b8603a87800e
2002-11-05 23:03:02 +00:00
drh 647cb0e159 Add the sqlite_version() SQL function as a built-in. (CVS 777)
FossilOrigin-Name: 7c8c0e7633dca00bde7bc7c22075f688c034c200
2002-11-04 19:32:25 +00:00
drh 7bc09d3111 Improvements in threadtest.c (for Unix) and some minor bug fixes that result
from the better testing. (CVS 776)

FossilOrigin-Name: 326e0983c34b584a3c4a2300399bff0a8281b9f8
2002-11-01 01:55:36 +00:00
drh 194a7b6469 Version 2.7.3 (CVS 775)
FossilOrigin-Name: 4051dbdb0552620eaff2ccef02f64a2ff97a8dfb
2002-10-31 00:15:10 +00:00
drh 1f3e905cd0 Fix an assert that might fail if malloc() fails. (CVS 774)
FossilOrigin-Name: 8ad018944c3aa8f58e1c68b1fa634ef922d6476f
2002-10-31 00:09:39 +00:00
drh bd1edfa321 Bump the version number prior to the release of version 2.7.3. (CVS 773)
FossilOrigin-Name: bc7c7d87e550c786d5bdb4169a0ad75db3fb066a
2002-10-30 23:04:27 +00:00
drh 38dd0b4ff0 In the VDBE, check to make sure a set has been initialized before using it.
Ticket #185. (CVS 772)

FossilOrigin-Name: 8c4cbdd05517e91879a0f2c4559d0f0518d2385b
2002-10-30 22:42:58 +00:00
drh 1f16230b5c Minimal support for oracle8 outer join syntax. (CVS 771)
FossilOrigin-Name: 31df3690d0fe4bd4a293cbe8ca9a26c98c3ed3ce
2002-10-27 19:35:33 +00:00
drh 6977fea801 Correctly handle column names and string constants in parentheses.
Fix for ticket #179. (CVS 770)

FossilOrigin-Name: 3b68aa25c451b7c09ece457ac2b70a9a5d93508a
2002-10-22 23:38:04 +00:00
drh e958bb4aef Take care to track ephemeral strings in the VDBE and make copies of ephemeral
strings that need to be preserved.  Ticket #177. (CVS 769)

FossilOrigin-Name: 562da534bbb605a8ce15824135b012ef2d86bbeb
2002-10-22 15:04:34 +00:00
drh edbbbdf8f7 Rework the changes for ticket #176 (check-ins (760) and (761)) to be
more consistent with the rest of the source code. (CVS 768)

FossilOrigin-Name: f50a177b4239bc7a83563ac9361e830ec04e81fb
2002-10-20 18:19:45 +00:00
drh 3c2007a546 The "table_info" pragma reports unspecified column types as "numeric" instead
of "text".  Fix for ticket #174. (CVS 767)

FossilOrigin-Name: 395ab5fac201a37d6eca833ffd6f58ac8a0121a2
2002-10-20 16:00:27 +00:00
drh 275ed72c9b Export the sqlite_function_type function from windows DLLs. Ticket #173. (CVS 766)
FossilOrigin-Name: d5470dfe102ef9b1dac3b15a2f5cc225e3c26129
2002-10-20 15:55:01 +00:00
drh 315555ca50 Work around a bug in the Borland C compiler. Ticket #172. (CVS 765)
FossilOrigin-Name: 3ef2925650bfbeb4ee5dbd0aaf8e606fc4cd2be1
2002-10-20 15:53:03 +00:00
drh 2678058853 Make sure malloc(0) always returns NULL. Fix for ticket #171. (CVS 764)
FossilOrigin-Name: 4622b7ce8f4727a6405ddf4f0af701db86da86bf
2002-10-20 15:46:22 +00:00
drh 32fbe342db Speed improvement by avoiding a call to sqliteBtreeLast() when inserting a
new row into a table. (CVS 763)

FossilOrigin-Name: d0af59fe6b9d5d026786e7cce1c49c208a0335cc
2002-10-19 20:16:37 +00:00
drh 906bf2a316 Fix the URL for pointing to MinGW on the homepage. (CVS 762)
FossilOrigin-Name: 16aad98aad4d8dd4a8400cdee32004b8c4785d60
2002-10-19 20:13:51 +00:00
mike 16aaf451b7 Minor coding fix in getting the windows platform version, when multithreading (CVS 761)
FossilOrigin-Name: b53ab71d074ada47ce22bd161f6aee24587302af
2002-10-17 09:01:31 +00:00
mike 710dcfbde5 fix for locking in Windows (CVS 760)
FossilOrigin-Name: 83add34f64895a4b465881213eba82f3b1f5c964
2002-10-17 00:38:54 +00:00
drh f1f0fa0769 Remove the call to srand() and add better comments to the sqliteOsRandomSeed()
routine.  Ticket #163. (CVS 759)

FossilOrigin-Name: d87a886d8f63f54466848151e2b0e8565b338593
2002-10-12 13:43:59 +00:00
drh c8f8b632c3 Fix a bug in the left outer join logic. (CVS 758)
FossilOrigin-Name: 6c0f44bd6374010f7a4a091e585eb36e0665f96f
2002-09-30 12:36:26 +00:00
drh 294fb92b50 Fix an uninitialized variable that could cause problems when comparing
two NULLs. (CVS 757)

FossilOrigin-Name: 015425001813971f6d4c97c18d64c7f14fa1955f
2002-09-30 01:31:21 +00:00
drh c4ca897b9a Version 2.7.2 (CVS 756)
FossilOrigin-Name: 59ba43449a53fb32e2dd4259285af8b4206c298a
2002-09-25 19:50:17 +00:00
drh d042ddb31b Bump the version number to 2.7.2. (CVS 755)
FossilOrigin-Name: a164528e8c6df3569ab178a3b737744dcccb64e7
2002-09-25 19:26:59 +00:00
drh a226d05408 Bug fix: When multiple SQL statements were passed into a single sqlite_exec() call, execution speed would decrease for each statement executed because VDBE cursors were not being reused. Now the cursors are reused and execution time is linear. (CVS 754)
FossilOrigin-Name: b0d27a377a9f6134f81108fe45c8c868ab4d4411
2002-09-25 19:04:07 +00:00
drh df68f6b768 Make sure memory malloced() for structures is aligned on an even byte boundry.
Solaris segfaults otherwise. (CVS 753)

FossilOrigin-Name: 14ebe30bf5937effdc388e23e998ba1a34fb0a29
2002-09-21 15:57:57 +00:00
drh 3e56c04c4e Fix a bug in the OP_MemStore operator of the VDBE. A realloc() might
occur but pointer to the old buffer were not being moved over to
the new buffer. (CVS 752)

FossilOrigin-Name: 29145746f34438bd830c763872c5e82572150357
2002-09-17 03:20:46 +00:00
drh 995d71b715 Modify the sqlite_encode_binary() routine to return the strlen() of the
encoded string.  Also fix a bug that occurs when attempting to encode
a zero-length buffer. (CVS 751)

FossilOrigin-Name: f12c3a25ba5408c2a7c846a9f160416fd188cd26
2002-09-16 11:44:05 +00:00
drh cabb081971 Do not put a write lock on the main database file when writing to a temporary
table. (CVS 750)

FossilOrigin-Name: 3f253afe15d4f7392555f340a41d780d1248087f
2002-09-14 13:47:32 +00:00
drh 41a3bd0a01 Rename all tests so that the first part of the test name corresponds to the
file that contains that test.  This makes it much easier to find a particular
test after it fail. (CVS 749)

FossilOrigin-Name: 6cb80ae10af60863cc25c22a6442ba1d43b7409c
2002-09-14 12:04:56 +00:00
drh 6eba16f3d7 Update the SQL language documentation to talk about SELECT DISTINCT. (CVS 748)
FossilOrigin-Name: ef7116751ddc4e82228c115b0a332ffb47a22ae5
2002-09-12 14:08:32 +00:00
drh ac82fcf5f0 Fix for ticket #147: Honor the ORDER BY and LIMIT clauses in a SELECT even
if the destination of that SELECT is a subroutine call. (CVS 747)

FossilOrigin-Name: 23fe36c7e88282f6d1b7547ab892ea88f0e65262
2002-09-08 17:23:41 +00:00
drh 85a1c4a609 Modify the build process so that the VDBE opcode numbers and the table
that contains the opcode names are both automatically generated. This makes
it much easier to create new VDBE opcodes. (CVS 1727)

FossilOrigin-Name: c4f0bb02387a6e6f254320e1e5eef3d5d8a3c538
2002-09-08 00:04:54 +00:00
drh 8f619ccd3c Modify the build process so that the VDBE opcode numbers and the table
that contains the opcode names are both automatically generated. This makes
it much easier to create new VDBE opcodes. (CVS 746)

FossilOrigin-Name: eb54d455b0325d3be96daf6c220c4ee3e0da1a85
2002-09-08 00:04:50 +00:00
drh 8c90ebb0e2 Fix a memory leak that occurred when sqlite_open() failed. (CVS 745)
FossilOrigin-Name: a876021304a5de7ede1bf835971da7e328d1af07
2002-09-05 23:21:37 +00:00
drh 96ddd6db58 Rewind the checkpoint journal after each statement to avoid allowing
the file to become too large. (CVS 744)

FossilOrigin-Name: f4288520dfd1587446e50fa7ef23f75f6f63a7cf
2002-09-05 19:10:33 +00:00
drh 4e371ee41c Fix for ticket #146: Correctly handle reads of unused disk blocks at the
end of the file. (CVS 743)

FossilOrigin-Name: f5c2654768a6201fc554b59f1b2f56bcce738bc4
2002-09-05 16:08:27 +00:00
drh b798fa6481 Always fill in the 5th parameter to sqlite_exec if there is an error. (CVS 742)
FossilOrigin-Name: 7f8fd5c75d614f81ef87f0fc952c341cbc5076d0
2002-09-03 19:43:23 +00:00
drh 96f4531077 Add documentation on NULL handling in SQLite versus other SQL database
engines. (CVS 741)

FossilOrigin-Name: dd8867fc479891ed8fa36c5cf2359e49c6754a8c
2002-09-02 14:11:02 +00:00
drh 0e1cfb8574 Detect when the test scripts are being run as root and issue an appropriate
error message. (CVS 740)

FossilOrigin-Name: 9ca2c507704f85446d873d5e8429554f2ad4df9e
2002-09-02 12:14:50 +00:00
drh f74b8d9b89 Relax the locking requirements on BTree cursors. Any number of read and
write cursors can be open at the same time now, but a write cannot occur
as long as one or more read cursors are open.

Before this change, one or more read cursors could be open on a table,
or a single write cursor, but not both.  Both policies have the same
desirable effect: they prevent writes to a table while a sequential scan
of that table is underway.  But the new policy is a little less restrictive.
Both policies prevent an UPDATE from occurring inside a SELECT (which is
what we want) but the new policy allows a SELECT to occur inside an
UPDATE. (CVS 739)

FossilOrigin-Name: 8c2a0836980341faa479cfe6c716409e6057367d
2002-09-01 23:20:45 +00:00
drh c2eef3b32b Parse foreign key constraints and populate internal data structures
appropriately.  Constraints are still not enforced. (CVS 738)

FossilOrigin-Name: 170711ca65dc894d0486b9d575edb8f1708250fb
2002-08-31 18:53:06 +00:00
drh b680a344e5 Version 2.7.1 (CVS 737)
FossilOrigin-Name: 5f51e13d56a58d7c263043cae9898d796017a369
2002-08-31 17:02:43 +00:00
drh 56cdb3b237 Change the version number for release 2.7.1. (CVS 736)
FossilOrigin-Name: b7f788fcc4a26ae42196a209d2e94672321dc154
2002-08-31 17:02:25 +00:00
drh df01cdf9b0 Initial checking of two new test files: format3.test and memleak.test. (CVS 735)
FossilOrigin-Name: 6ffedb90a6478af6548db5298368eeca2b708cdc
2002-08-31 16:52:44 +00:00
drh b7dadd4d85 Fix for ticket #145: Include the func.c source file in the build of testfixture
so that the "randstr()" function will be available. (CVS 734)

FossilOrigin-Name: c5e0c6a782aedc4a273aaf8bc2ef60918797e5f1
2002-08-31 16:33:25 +00:00
drh 1e0ccab9f0 If the database is locked when sqlite_open() is called, sqlite_exec() should
still honor the busy callback and should return an error message together
with the SQLITE_BUSY result code. (CVS 733)

FossilOrigin-Name: 78a0229a7e5e33fe642847381f5514e6ec30f29f
2002-08-29 23:59:47 +00:00
drh 142e30df99 Slightly faster INSERTs from a SELECT by avoiding an intermediate table.
But it didn't make nearly as much difference as I had hoped. (CVS 732)

FossilOrigin-Name: 723362e74f79c784314d042e3a8c8a9bf07cbd5e
2002-08-28 03:00:58 +00:00
drh 66105a8ea0 Change the tokenizer to ignore C-style comments /*...*/ in accordance with
SQL99. (CVS 731)

FossilOrigin-Name: f1534489484afdb835ad8e6f97909fbe76dbe414
2002-08-27 14:28:29 +00:00
drh da30d3696b Fix for ticket #142: Make sure we get the correct sort order even when the
columns being sorted contain NULLs. (CVS 730)

FossilOrigin-Name: 45847390d007718a4b7a4e9fa445136d013113f8
2002-08-26 19:55:07 +00:00
drh d2df27e41d Version 2.7.0 (CVS 729)
FossilOrigin-Name: 9e341d9c934c2111be6834743f1ce30463b095b6
2002-08-25 20:58:11 +00:00
drh 305f99a0fb Documentation updates prior to the releae of 2.7.0. (CVS 728)
FossilOrigin-Name: e2d95f85a3c4beeb5f8e78498f52fc00475f38ed
2002-08-25 20:11:18 +00:00
drh 8c74a8ca5b Fix for ticket #136: Added the OP_RenameCursor VDBE instruction and used it
to make cursor numbers right on nested subqueries.  Also added OP_Gosub and
OP_Return but have not actually used them for anything yet. (CVS 727)

FossilOrigin-Name: c602603e7cd8dc5c8bb9db2748eacab650de5bf0
2002-08-25 19:20:40 +00:00
drh d94a669894 Fix the memory leak introduced by check-in (725). (CVS 726)
FossilOrigin-Name: b957dafc26383af514795df18bc7b8f367c9bd21
2002-08-25 18:29:11 +00:00
drh 4b59ab5e64 Change the way token memory is allocated in an effort to fix ticket #136.
There is now a memory leak when using views of views. (CVS 725)

FossilOrigin-Name: 22d8726e61eec0e53893f492cb2163824b87a23e
2002-08-24 18:24:51 +00:00
jadams 79983d03e8 Fix for ticket #138: Makefile doesn't use exec_prefix, has some install problems (CVS 724)
FossilOrigin-Name: 97fc4a71a12b52cda67b5192c3bd7bd10ac0c7a6
2002-08-22 18:18:35 +00:00
drh bd842babb5 Fix for ticket #137: Use getpwuid() instead of getpwent(). (CVS 723)
FossilOrigin-Name: ea011990c552a7a6019b63f9b4341ad6c8663479
2002-08-21 11:26:41 +00:00
drh f04d5081a7 This COLLATE keyword was not being parsed correctly inside CREATE TABLE
statements - it was being included as part of the datatype.  This fixes
the problem. (CVS 722)

FossilOrigin-Name: 39bd52d33029233d4b22df08975e9ef3c74c260f
2002-08-18 22:41:22 +00:00
drh 6b8b8749d4 Fix for ticket #110: return an error if trying to start a transaction within a
transaction or when attempting to commit or rollback outside of a transaction. (CVS 721)

FossilOrigin-Name: df51cb166bf7c5b8b0530cc86df8d2d68de81a40
2002-08-18 20:28:06 +00:00
drh d8acdb3c36 Documentation updates. (CVS 720)
FossilOrigin-Name: e372a60be8de3332ab6e45d82f21227b8b9acf82
2002-08-18 19:09:22 +00:00
drh cb48588297 Fix for ticket #135: Remove unused variables from three files. (CVS 719)
FossilOrigin-Name: 8cf17f2a24ee9bd5d1ea66484922819626c412dd
2002-08-15 13:50:48 +00:00
drh c277413089 More documentation updates. (CVS 718)
FossilOrigin-Name: 9c0400aa7a0244605828fa6450ea1cc723240b16
2002-08-15 13:45:17 +00:00
drh 310ae7be1e Additional test cases and documentation updates. (CVS 717)
FossilOrigin-Name: 048b16c111693727482642e2a19a74a91458fc80
2002-08-15 11:48:13 +00:00
drh 3d037a91a5 Fixes and test improvements resulting from code coverage testing. (CVS 716)
FossilOrigin-Name: 66a0f6a8e25e3eeed78eba4b63b097f921c79d99
2002-08-15 01:26:09 +00:00
drh b27b83a941 Fix for ticket #134: Change the lemon.c sources to work around a problem with
the AIX C compiler. (CVS 715)

FossilOrigin-Name: 07f6020bb56d6d1bffdd936017f61cfae5bd134b
2002-08-14 23:18:57 +00:00
drh d1efac52d5 Implement probabilistic reader/writer locks under windows so that windows
can have multiple simultaneous readers. (CVS 714)

FossilOrigin-Name: 2127de3f03537ef2f18120e773f7603e0984ff81
2002-08-14 12:56:54 +00:00
drh c330af1dca Disable sorting by indices if there is a COLLATE subclause in the
ORDER BY clause. (CVS 713)

FossilOrigin-Name: 2438da791afb53b4f1c7a9ff9705d393c86f3cbd
2002-08-14 03:03:57 +00:00
drh 0c44e2edf3 Fix for ticket #132: make the working directory the last choice for where
to write temporary files, not the first choice. (CVS 712)

FossilOrigin-Name: 26a4e7e7a3eee62c170ce264cb964a92bc7f52c9
2002-08-14 00:10:44 +00:00
drh fbe4375cae Update documentation to better explain the typelessness of SQLite and to
describe the distinction between text and numeric data. (CVS 711)

FossilOrigin-Name: 4ff0f578eca4a8672cf570923e6c015c3ba6b9f4
2002-08-14 00:08:12 +00:00
drh a9e99aee95 Make the distinction between text and numeric data. (CVS 710)
FossilOrigin-Name: 310ac4fbaf0ed63f98bfacb55259960be03b0c8b
2002-08-13 23:02:57 +00:00
drh 76800328b2 Documentation and makefile updates. (CVS 709)
FossilOrigin-Name: 92c403f485390bbd83a5be472e61c974f76d46b1
2002-08-13 20:45:39 +00:00
drh 72ca3794ab Bug fix to the left outer join logic. (CVS 708)
FossilOrigin-Name: f9d3d4c1230a7f1176b2002d72e94857e251c04e
2002-08-13 13:15:51 +00:00
drh 7f09b3e36b Bug fix to the left outer join logic. (CVS 1726)
FossilOrigin-Name: 957d908e6b84cd599b5cfd82af80c8fac79c1dbd
2002-08-13 13:15:49 +00:00
drh f8b593e964 Version 2.6.3 (CVS 707)
FossilOrigin-Name: ba706aca0af9ed1ecb64edd4ab327bd5a5a32044
2002-08-13 00:02:10 +00:00
drh 74587e5567 Updates prior to release 2.6.3. (CVS 706)
FossilOrigin-Name: 34c4149eea7a48927e36867f4e25ff7fac40c66e
2002-08-13 00:01:16 +00:00
drh 94f3331a0b Fix for ticket #9 (again). The rollback journal files should now also be
byte-order independent. (CVS 705)

FossilOrigin-Name: 2fb3fdcdf06c1206bf14da640c2f9e599455f0eb
2002-08-12 12:29:56 +00:00
drh 0d316a40cc Fix for ticket #9: Add the ability to read little-endian database files
from a big-endian machine and vice versa. (CVS 704)

FossilOrigin-Name: ce4b943bf68c160445a58ffccfbabbbd30d9829b
2002-08-11 20:10:47 +00:00
drh 6e397e447e Fix typos the source to webpages html files. (CVS 703)
FossilOrigin-Name: 61bb3af7405aa7b54f3e5519537ea483879eed39
2002-08-06 12:04:59 +00:00
drh 68d2e5918a Fix for ticket #131: When a SELECT contains a GROUP BY clause it cannot
use an index for sorting.  It has to sort as a separate operation after
the GROUP BY is complete. (CVS 702)

FossilOrigin-Name: 18745c67acdf7ebec378f5538174117970e9f5cc
2002-08-04 00:52:38 +00:00
drh e0e5ef1471 Remove the restriction that a transaction cannot be started by one linuxthread
and continued by another.  Leave in the documentation the warning about not
carrying a database connection across fork() but do not test for it any more.
Ticket #130. (CVS 701)

FossilOrigin-Name: bdbdb866f2e76abd1f8f545adadc9a900ed0cd1a
2002-08-02 10:36:09 +00:00
drh f1351b6759 Fix for ticket #124: Fix a stack VDBE overflow problem on joins on an
INTEGER PRIMARY KEY. (CVS 700)

FossilOrigin-Name: fe329e078fa209faf62e08599a00c7efa75b8501
2002-07-31 19:50:26 +00:00
drh 4eb9c6b9fd Version 2.6.2 (CVS 699)
FossilOrigin-Name: 223a2150ac1fa34d4bd01dd32b5fed9e90aa38d4
2002-07-31 00:38:06 +00:00
drh 4dec5b40ec Update version number and change log for the 2.6.2 release. (CVS 698)
FossilOrigin-Name: 4f196de07d258dc44b6fd20d776120e2aadd3224
2002-07-31 00:37:36 +00:00
drh f573c99ba7 Fix for ticket #104: Make triggers on views work properly even after closing
and reopening the database.  Also fixed an unrelated bug in the version
2.6.0 database format upgrade logic.  The upgrade logic bug was found while
testing the trigger fixes. (CVS 697)

FossilOrigin-Name: 04973fc2a6a0c93877de7e564618e0e9fcffc06c
2002-07-31 00:32:50 +00:00
drh 92ed08a9d7 Fix for ticket #114: Correctly handle SQLITE_BUSY if it occurs during
database initialization. (CVS 696)

FossilOrigin-Name: 5b814b5df667ccc91d85fbb7f96e523483e9219b
2002-07-30 18:43:40 +00:00
drh c51d204464 Fix for ticket #111: Update the documentation to explain that you may not
start a transaction in one thread and complete it in another thread under
Linux Threads where each thread has its own process ID. (CVS 695)

FossilOrigin-Name: 0b0c0492cc1e55c1c4feba6e92765ea09896096c
2002-07-30 17:42:10 +00:00
drh 62160e798c Fix for ticket #71: Correctly handle CR and CRLF line terminators in the
input files for the COPY command. (CVS 694)

FossilOrigin-Name: be1315755ef801b5ec07f469134e0d33a3ece990
2002-07-30 17:20:40 +00:00
danielk1977 368c7f6df1 UPDATE triggers on TEMP tables were broken. (CVS 693)
FossilOrigin-Name: c080ed01ea51628b86050762f097e702e3aeafdf
2002-07-21 23:09:55 +00:00
drh 77fc55904e Version 2.6.1 (CVS 691)
FossilOrigin-Name: 610b7bc70a12b271994255bd01a76b3525421535
2002-07-19 19:04:04 +00:00
drh 096c497eb3 Rig the ident string so that it is not changed by RCS on checkin. (CVS 692)
FossilOrigin-Name: 773d36c8d94bdcd0c78401282e48432ddd9b61d6
2002-07-19 19:03:41 +00:00
drh 26b3e1bc06 Fix an assertion failure that occurs when attempting to delete all rows of
a table while the "count_changes" pragma is turned on.  Up the version number
to 2.6.1. (CVS 690)

FossilOrigin-Name: 612df004017b241651074ee859096dd0ee5062b8
2002-07-19 18:52:40 +00:00
drh 426cc56a6b Add static ident strings (such as picked up by the RCS "ident" command)
containing the library version number. (CVS 689)

FossilOrigin-Name: 712ee3914e988f0077e9a3d6170ff8db496a9600
2002-07-19 18:13:35 +00:00
drh c231172f3f Better detection and reporting of errors when initializing from the
sqlite_master table. (CVS 688)

FossilOrigin-Name: c8a7b725b7cec792d2148455a4cecbce9dfebe80
2002-07-19 17:46:38 +00:00
drh b782325617 Version 2.6.0 Release 2 (CVS 687)
FossilOrigin-Name: cc4f824b155138326f1a62066a99c65d0f32fb8b
2002-07-18 11:10:30 +00:00
drh ac729e224e Fix a bug in the publish.sh script that was causing the windows DLL to not
be built. (CVS 686)

FossilOrigin-Name: ee8c2758a222251fed0197d2a364346d05728240
2002-07-18 11:07:19 +00:00
drh 199e3cf1b6 Change the name of variable "near" to "nearby" since MSVC mistakenly belieaves
that "near" is a keyword. (CVS 685)

FossilOrigin-Name: 9761a2a0fbfd3e98f719a813bcc544950968aef2
2002-07-18 11:01:47 +00:00
drh bd44700073 Version 2.6.0 Release 1 (CVS 684)
FossilOrigin-Name: dde65e9e060b9154e848d53d15272a0dcc7c2723
2002-07-18 02:50:51 +00:00
drh 3c2c354e0e Update documentation prior to the release of 2.6.0. (CVS 683)
FossilOrigin-Name: f2d9191381e956900a14bd80e50678b9d49e19e5
2002-07-18 02:07:07 +00:00
drh 8e5ba84643 Make the automatic database upgrade work even if there are triggers. Add
tests for automatic upgrade and for failing if reading a more advanced version
of the database.  Ticket #107. (CVS 682)

FossilOrigin-Name: 0493e39c1cbbe4a38e990a2370181a79606af222
2002-07-18 01:27:17 +00:00
drh 491791a827 Fix for ticket #107: Fix a design defect in indices that was causing queries
to fail when using an index on a column containing an empty string.  This
fix is an incompatible file-format change. (CVS 681)

FossilOrigin-Name: 20d152fcddb4fa53556a9c93c7a869600a7c5183
2002-07-18 00:34:09 +00:00
drh 53e3fc70bf Fix for ticket #105: Fix the UPDATE command so that it works properly with
indexed tables when there is a subquery in the WHERE clause.  Add tests
to verify correct operation. (CVS 680)

FossilOrigin-Name: bbca16f88d00cd33ac7229edf3ee4623eff6e62f
2002-07-16 17:22:50 +00:00
drh 0c36cbe0c2 Fix for ticket #100: Correctly handle ON and USING clauses of JOINs within
a VIEW. (CVS 679)

FossilOrigin-Name: 93710f7ed7e1baa6acbf4bc32982e046f61ffa44
2002-07-16 02:05:43 +00:00
drh 704027f16d Fix a syntax error in the tclsqlite.c file. (CVS 678)
FossilOrigin-Name: 47997d7f3ad2dd486a00dc13b7a8c48bb4751e5d
2002-07-15 20:58:47 +00:00
drh ad16844f35 Fix for ticket #102: Honor the ORDER BY clause in subqueries. (CVS 677)
FossilOrigin-Name: 7e918c8b0df5120e3630811f164defb8c9fedd6d
2002-07-15 18:55:24 +00:00
drh 7f953e2052 Fix for ticket #64: Better error reporting in the shell. (CVS 676)
FossilOrigin-Name: e1842e04c4f47e1ce79575b5c787a164add5d559
2002-07-13 17:33:45 +00:00
drh 70562cd342 Partial fix for ticket #96: Return SQLITE_MISUSE from sqlite_exec() if called
from a child process with an active transaction that was started in the parent. (CVS 675)

FossilOrigin-Name: 72a609ec6492e7d740b6e6184fa14a5e6b04a5dc
2002-07-13 17:23:21 +00:00
drh 289f6c2336 Fix for ticket #99: Added documentation on the sqlite_mprintf() API. (CVS 674)
FossilOrigin-Name: d918de5f06d187c76aab0879b728c89a7d4ae55a
2002-07-13 17:18:36 +00:00
drh 674d712126 Added a document describing how to do a security audit. (CVS 673)
FossilOrigin-Name: cff271837796d84471b09147c59cb7601d16b358
2002-07-13 16:52:35 +00:00
drh 25197f4835 Fix for ticket #54: Export additional APIs to the Win32 DLL. (CVS 672)
FossilOrigin-Name: 072fd2ad588332b1f1f725515bedfbc0cf035315
2002-07-13 14:41:49 +00:00
drh 485b39b401 Fix for ticket #95: Do not allow automatically created indices (associated
with UNIQUE or PRIMARY KEY constraints) to be dropped. (CVS 671)

FossilOrigin-Name: 0603eb74e6aca48f62bd95cb6c236b9e559af850
2002-07-13 03:11:52 +00:00
drh 5080aaa7ab Turn of the reporting of datatypes in the 4th callback argument unless the
SHOW_DATATYPES pragma is ON.  Eliminate the NULL pointer that used to separate
the beginning of datatypes from the end of column names so that the callback
can test to see whether or not datatypes are provided.  This is an
incompatible changes, but since the prior behavior was never documented, we
will let it in. (CVS 670)

FossilOrigin-Name: b98727246d5fcc1b097b577be498a77e954c5dc4
2002-07-11 12:18:16 +00:00
drh fa173a764a When reporting back the datatype of columns, use the text of the datatype
as it appears in the CREATE TABLE statement, if available.  Also: removed
the ".reindex" command from the shell. (CVS 669)

FossilOrigin-Name: ff8b6f4ee8099a7170cb786b8ead9a3e42ab5869
2002-07-10 21:26:00 +00:00
drh 6276c1cbf0 Add support for TEMPORARY views. The code is here but it is mostly untested. (CVS 668)
FossilOrigin-Name: 87cd10c1f638db5d1f47bc12669f150485415b3e
2002-07-08 22:03:32 +00:00
drh bea00b9a2b In the BTree subsystem, when using pages from the freelist, attempt to select
pages close to related pages in order to keep data structures near each other
in the database file.  This improves access speed in some circumstances. (CVS 667)

FossilOrigin-Name: fd7e41f0eed80fb1c7e18eb84834ec3cea74a649
2002-07-08 10:59:50 +00:00
drh 6b30867ff6 Make the BTree balance() routine a little faster by reusing database
pages locally rather than freeing and reallocating them. (CVS 666)

FossilOrigin-Name: 3c2dea4310af491d6cb09856d4bc5236d6dc44ac
2002-07-08 02:16:37 +00:00
drh 6f08d709b1 Version 2.5.6 (CVS 664)
FossilOrigin-Name: 111c78e6835306fcd8b6d22b9ae68dfb9ab4febe
2002-07-07 17:13:00 +00:00
drh 5e5377fb80 Fix for Win32: The %p format on Win32 does not prepend a "0x" as it should. (CVS 665)
FossilOrigin-Name: ee86704daf184307fe98b5631f22ceb3d701afce
2002-07-07 17:12:36 +00:00
drh 193a6b4142 More rollback problems: Fix two more errors introduced by checking (410) that
can cause database corruption after a ROLLBACK.  Also add new tests to make
sure everything is working this time. (CVS 663)

FossilOrigin-Name: f6e24d5ccbcfcf5863ffbd65860dafa2f5663e99
2002-07-07 16:52:46 +00:00
drh af1c9661a4 Version 2.5.5 (CVS 662)
FossilOrigin-Name: 6284c65c174bb2cd049fd1db81de52be3abf4000
2002-07-06 16:34:20 +00:00
drh 0de8c11292 Prepare for the 2.5.5 release. (CVS 661)
FossilOrigin-Name: 00f83c2576f4a9689720d344788f66219c1f6827
2002-07-06 16:32:14 +00:00
drh 8e298f92f6 Fix for bug #94: Be sure to journal pages that are added to the freelist then
removed from the freelist and reused during the same transaction. (CVS 660)

FossilOrigin-Name: db178646a01483d59e6f9af302e9bbe394956d93
2002-07-06 16:28:47 +00:00
drh 38640e15af All the code is now in place for SQLite to distinguish between NUMERIC and
TEXT datatypes.  Still need to turn on the new code and test it. (CVS 659)

FossilOrigin-Name: b4737a16c997a6c139d616211fb6bc4b0fae181c
2002-07-05 21:42:36 +00:00
drh 2f2c01e51d Fix for ticket #92: Correct the sqliteExprCompare() function so that is takes
into account the iTable and iColumn fields of the Expr structure.  Otherwise,
"min(a)" and "min(b)" will compare equal to each other in views. (CVS 658)

FossilOrigin-Name: 85793a4f03250166c21007cab3525709592d0866
2002-07-02 13:05:04 +00:00
drh 1f66c57a9c Fix for ticket 91: Modify the "publish.sh" script to use the new mingw
cross-compiler installed on the development platform. (CVS 657)

FossilOrigin-Name: 3cac283de4939538f09cd11e2cbdc84e9a9602f2
2002-07-02 11:55:32 +00:00
drh ea1c936a1e Version 2.5.4 (CVS 656)
FossilOrigin-Name: f7159fde6b8692f91fa8a3c928dc219d0f3d8884
2002-07-01 12:35:51 +00:00
drh a4db7ee12d Update the change log and the version number for the next release. (CVS 655)
FossilOrigin-Name: f9d77140aed301775b2b8dd88d464cc38edfe192
2002-07-01 12:34:36 +00:00
drh 5ad1a6c8c4 Fix for tickets #90 and #89: Make the AS keyword optional again. (CVS 654)
FossilOrigin-Name: 1f8a73b1c3833e3924196458d4c1ecca90f63662
2002-07-01 12:27:09 +00:00
drh 6cbe1f1bc4 Added additional tests. No new errors found. (CVS 653)
FossilOrigin-Name: 8924a7f5bab790ab552332d6359028d0d1825e4a
2002-07-01 00:31:36 +00:00
drh a9f9d1c08b Add a few more tests and fix a few bugs that the tests uncovered. (CVS 652)
FossilOrigin-Name: 91c0db66c86facb21b5b522afadd83d91a488256
2002-06-29 02:20:08 +00:00
drh 3b167c7583 Additional test cases added. The following bug fixed: A segfault was occurring
if a VIEW consisted of a join with a USING clause. (CVS 651)

FossilOrigin-Name: 96515b813eb57e1f48c28d357d1f38639b2fdcfa
2002-06-28 12:18:47 +00:00
drh 83dcb1ad37 Fix for ticket #84: If the WHERE clause is too complex, issue an error message
and refuse to do the SELECT.  The cutoff is a WHERE clause with 100 terms. (CVS 650)

FossilOrigin-Name: c07e493b62125e85eaea36b6945f1e146e2792b8
2002-06-28 01:02:38 +00:00
drh ac83f718fc Fix for ticket #88: A typo in the documention of the "sqlite" shell command. (CVS 649)
FossilOrigin-Name: 16552a7a29450a23765f0f05a9f4058638eafd74
2002-06-27 13:21:01 +00:00
drh 06b2718a5f In the TCL interface, the "sqlite" command now always returns the address
of the "sqlite*" pointer that sqlite_open() returns.  It used to do this
only when compiled with the SQLITE_TEST macro defined. (CVS 648)

FossilOrigin-Name: 9ca6368525fe81fe9c78c6911f4d23009ce858d5
2002-06-26 20:06:05 +00:00
drh b13632063d The datatype of the i-th column in the result set is given by the
azColName(argc+1+i) parameter to the callback. (CVS 647)

FossilOrigin-Name: bdb006b809feb0f29342eb5138c0884d34e95599
2002-06-26 02:45:03 +00:00
drh 411995dc0d Add the sqlite_open_aux_file() API. (CVS 646)
FossilOrigin-Name: 332164d6455658ca633a1dc49811d9fb0fd4b01c
2002-06-25 19:31:18 +00:00
drh e3c163e4e0 Version 2.5.3 (CVS 645)
FossilOrigin-Name: d5cb675432cbaeac2c1a8a08181613b9d1eb5ca1
2002-06-25 15:19:02 +00:00
drh ee6bfdf99c Fix a spelling error in the change log. (CVS 644)
FossilOrigin-Name: 37cc40442bab50506978f428001b77f23d3a4e4c
2002-06-25 14:46:58 +00:00
drh 8124a30f82 Bug fix: When the database file grows in size during a transaction, make sure
the last page of the file gets written to disk even if that page is on the
free list and contains no data.  Otherwise the disk file will be too small
which can lead to database corruption in subsequent transactions. (CVS 643)

FossilOrigin-Name: 36fc0add660f9f3676783765d37280aa874caecb
2002-06-25 14:43:57 +00:00
drh 2150432e7c Enhance the INTEGRITY_CHECK pragma to test the auxiliary database file in
addition to the main database file. (CVS 642)

FossilOrigin-Name: 52eba4de301121f254174b74042015bf6069ef11
2002-06-25 13:16:02 +00:00
drh 90c0bb0b07 Version 2.5.2 (CVS 641)
FossilOrigin-Name: 756310cad23668785eac679ef0842d1f37c306ee
2002-06-25 01:09:30 +00:00
drh e0bc4048a0 Added support for the "sqlite_temp_master" table. Increased the version
number to 2.5.2. (CVS 640)

FossilOrigin-Name: 9c1432bf7485258e485bd652e3acdaeabbfe8850
2002-06-25 01:09:11 +00:00
drh 1cc093c2b5 Partial fix for a problem with LEFT OUTER JOIN. It used to be that the test
for the right-hand table not matching the left table occurred after all
ON, USING, WHERE clause processing.  The test should occur after ON and
USING clauses are checked but before the WHERE clause is check.  This fix
works as long as the total number of "AND" separated terms in the ON, USING,
and WHERE clause does not exceed 32.  To do: make this work for any number
of terms and add test cases.
that (CVS 639)

FossilOrigin-Name: 8b6574cfa86daaae910f8f3ee3c4723a21fb9e53
2002-06-24 22:01:57 +00:00
drh bf5cd97ed7 Fix a VDBE stack leak in LEFT OUTER JOIN. Fix a bug in the code generator
for JOIN ... USING(...). (CVS 638)

FossilOrigin-Name: d861489e1f7dffd1105c271fe8597f73e5b1703c
2002-06-24 12:20:23 +00:00
drh f46f905a1e An optimization: avoid the use of an intermediate table on UNION ALL if there
is no ORDER BY clause. (CVS 637)

FossilOrigin-Name: 8aa73ce61268a50d353d9a5c878461290195525f
2002-06-22 02:33:38 +00:00
drh d11d382c99 Fix for bugs #77 and #80: Rework the LIMIT mechanism to be reentrant and to
clean up the VDBE stack properly. (CVS 636)

FossilOrigin-Name: 9d5523107937e3700c76666fb058694babdd672c
2002-06-21 23:01:49 +00:00
drh 7aa128dbc5 Fix for ticket #76: Fix a database corruption that might occur when
dropping tables or indices. (CVS 635)

FossilOrigin-Name: 7936b0325024c81ed8d4bab192d7350d045ec999
2002-06-21 13:09:16 +00:00
drh bb3a6dbd2e Fix for ticket #78: Avoid an assertion failure when sqlite_close() to be
called in the middle of a transaction. (CVS 634)

FossilOrigin-Name: 2532792a5875f9cc0f7d8eaf90dd49d1f6025ca3
2002-06-21 11:55:48 +00:00
drh ef1360635c Update the file-format change document to describes the changes between
versions 2.4.12 and 2.5.0. (CVS 633)

FossilOrigin-Name: d28a2ecc91c0a6d64725887dcf2758f69553eb59
2002-06-20 11:41:58 +00:00
drh c9b84a1fb1 This patch contains the beginnings of the data-typing infrastructure.
The new build-in TypeOf() function is added.  New opcodes for doing
pure text comparisons are added.  Most changes are disabled pending
the 2.6.0 release. (CVS 632)

FossilOrigin-Name: cbbc858d973c2d515c6a2464981316549a241b73
2002-06-20 11:36:48 +00:00
drh c926afbc2d Fix for ticket #73: The ORDER BY clause is significant for subqueries.
This passes all regression tests, but more testing is needed to exercise
all paths through the new code. (CVS 631)

FossilOrigin-Name: 43c5aff5d078bce9292683cd40311e0dcc81ac14
2002-06-20 03:38:26 +00:00
drh 27a32783ab Fix for ticket #75: Autoincrement INTEGER PRIMARY KEY fields on an INSERT
even if the data is coming from a SELECT statement. (CVS 630)

FossilOrigin-Name: d599f75b659809a6e5eee09b0e9e6e90bde5af1e
2002-06-19 20:32:43 +00:00
drh 9bc542e999 Version 2.5.1 (CVS 629)
FossilOrigin-Name: 5e8a3131aba25e22f3e25b9b1c051019381f11d1
2002-06-19 14:27:22 +00:00
drh e31847449e The query optimizer now attempts to satisfy an ORDER BY clause using
an index.  Sorting is still used if there are no suitable indices. (CVS 628)

FossilOrigin-Name: f09e19b43ef61073713cf32282c90ea666229eba
2002-06-19 14:27:05 +00:00
drh c2bb7c3dd9 Version 2.5.0 (CVS 627)
FossilOrigin-Name: 9baef3e240c4ffd90881ac4664efd205bd9e65f4
2002-06-17 17:26:38 +00:00
drh af33486ebb Update the change summary for version 2.5.0 (CVS 626)
FossilOrigin-Name: 7a216adea5aa5a82718f8c85f8961ba36ab51bb4
2002-06-17 17:15:46 +00:00
drh 8e2ca029a3 Add preliminary logic for the eventual move to having separate TEXT and
NUMTEXT datatypes.  Also change the version number to 2.5.0 in preparation
for an interim release. (CVS 625)

FossilOrigin-Name: 05783a9db585c1ead42135252dca97d2bc6e2118
2002-06-17 17:07:19 +00:00
drh e0140fc13a Expose an additional internal API routine (sqliteInitCallback()) for
use by private code. (CVS 624)

FossilOrigin-Name: cd74495f995803eeb5c2b900d536deb52e5584eb
2002-06-16 18:21:44 +00:00
chw 4d60361fe3 Added explanation and examples for %Q format specifier. (CVS 623)
FossilOrigin-Name: 633ce4dd252ac351b04bdb7bed2d5374ee9a3f12
2002-06-16 04:57:32 +00:00
chw b22f1b58ac Added printf-4.(2-4) test cases to test new %Q format specifier. (CVS 622)
FossilOrigin-Name: 7d5fc35b5d38230230344b4f70763f75940ab908
2002-06-16 04:56:36 +00:00
chw 0cfcf3fbd1 Added %Q format specifier: like %q but automatic enclosing in
single quotes, NULL pointers replaced by NULL w/o single-quotes. (CVS 621)

FossilOrigin-Name: b9c7ecc2f9d8d7d57c51dc4ba0aaa520e89eb31f
2002-06-16 04:55:48 +00:00
chw f220b24fc6 Changed sqlite_mprintf_str to allow a NULL string parameter.
Command template now is cmd FORMAT INT INT ?STRING?. When
STRING omitted a NULL is passed to sqlite_mprintf. (CVS 620)

FossilOrigin-Name: 8bc711571d752a81957007be22ed8a3c6877f676
2002-06-16 04:54:28 +00:00
drh df199a25bd Make the LIMIT clause work even if the destination of the SELECT is
something other than a callback.  (Ticket #66) (CVS 619)

FossilOrigin-Name: 699cf362083043615eb88635a228bfa46a315c9c
2002-06-14 22:38:41 +00:00
drh c27a1ce4bd Improvements to comments. No code changes. (CVS 618)
FossilOrigin-Name: 7e10e60bb78b680bb822908a0b7763f8f5e3ee5a
2002-06-14 20:58:45 +00:00
drh c67980bedc Fix for bug #72: Make sure the file descriptors are properly closed if
sqliteInit() fails for any reason. (CVS 617)

FossilOrigin-Name: e67ac0fec51788aca0429d04310f86c9c1cf9d13
2002-06-14 20:54:14 +00:00
drh 6ca62f21e3 Fix for bug #70: Correct a typo in the documentation. (CVS 616)
FossilOrigin-Name: 3387d5b6d62fbafea69fac7bb8256c37d5c6a4ba
2002-06-12 22:33:54 +00:00
danielk1977 c3d2ac6561 Documentation that should have been checked in along with checkin (614) (CVS 615)
FossilOrigin-Name: 10da13612583caacc6fefe3a1f24187bfae2ebd7
2002-06-11 22:33:47 +00:00
danielk1977 6f34903e85 Add RAISE() function, which allows more advanced flow-control in trigger programs (ticket #55) (CVS 614)
FossilOrigin-Name: d4a2fb10067203a0d49317db747759872e62927e
2002-06-11 02:25:40 +00:00
drh 28f4b6885b Fix the spelling of sqliteRegisterBuiltinFunctions(). (CVS 613)
FossilOrigin-Name: 74d297d97e66452acc5c21048ee8ddf2a90c846f
2002-06-09 10:14:18 +00:00
drh 48185c15c7 Added tests for the new IN operator optimizer and fixed a bug that the
new tests found.  This completes the implementation of enhancement #63. (CVS 612)

FossilOrigin-Name: 2a710e18176c486525f0abb06644a511a2cd1d7a
2002-06-09 01:55:20 +00:00
drh d9e3093038 Fix for ticket #65: If an integer value is too big to be represented as a
32-bit integer, then treat it as a string. (CVS 611)

FossilOrigin-Name: ad9624798edbd6d0c4652fed3d74fe87498844ff
2002-06-09 01:16:01 +00:00
drh d99f70680f Add optimizations for the IN operator in WHERE clauses. This is a partial
implementation of enhancement #63.  Still need to add test cases. (CVS 610)

FossilOrigin-Name: 8481e841ebdeabe07bf780246bda1aa053eb60b7
2002-06-08 23:25:08 +00:00
drh f5db2d3ea2 Bug fix: do not segfault if a SELECT without a FROM clause includes
the * wildcard in the result column list. (CVS 609)

FossilOrigin-Name: d939294994e5f6c7862b66573301e111e56a2681
2002-06-06 23:42:27 +00:00
drh d5c644c0b1 Fix for ticket #59: Add documentation for the || operator. Also added
documentation for the new SQL92 join syntax. (CVS 608)

FossilOrigin-Name: a0abef62bfe1b0f8c6249ba520dd2735190783a5
2002-06-06 23:30:58 +00:00
drh 5df72a5ad6 Fix for ticket #62: Do not report an SQLITE_READONLY error until the application
actually tries to write data into a readonly file.  It is OK to start a
transaction on a read-only file, and doing so will get you a read lock.  This
change allows TEMP tables to be read/write even though the main database is
readonly. (CVS 607)

FossilOrigin-Name: 9ef795d1d756a404d2123ebc19df1985b19c9888
2002-06-06 23:16:05 +00:00
drh 34e33bb835 Additional grammar cleanup resulting from the %fallback directive. (CVS 606)
FossilOrigin-Name: c0cb3a012e02df1a7965413a92f9b5a77331edb4
2002-06-06 19:04:16 +00:00
drh 0bd1f4ea5a Added the %fallback directive to the lemon parser generator and used this
in the parser to make the parse tables much smaller.  This reduced the size
of the library by 15K. (CVS 605)

FossilOrigin-Name: 7ac5bd293cbb2bf252f31f1571f7efac7e77280a
2002-06-06 18:54:39 +00:00
drh bd790ee395 Fix a compiler warning. (CVS 604)
FossilOrigin-Name: 637ee587b5438c54ba2d8bd8fc15e584abb70946
2002-06-02 18:22:06 +00:00
drh 04738cb9ff Add the ability to parse FOREIGN KEYs. Foreign keys are still ignored,
but at least they now do not cause a syntax error. (CVS 603)

FossilOrigin-Name: 6fdcee3c99e994ef3ab83a0cc57344cdb16210df
2002-06-02 18:19:00 +00:00
drh e4de1feb3e Enhance the ORDER BY clause so that an integer term means to sort by the
corresponding column. (CVS 602)

FossilOrigin-Name: 7acbf84b492202d8b5a05276a95b475027eb5f58
2002-06-02 16:09:01 +00:00
drh 1288c9561d Multiplying NULL by zero gives NULL, not zero. I misread the test data
and coded it wrong.  This check-in fixes the problem. (CVS 601)

FossilOrigin-Name: df9cc852ad02dbec5558d3915a0303f7e7b79b2b
2002-06-01 21:41:10 +00:00
drh f570f011eb Refinements to NULL processing: NULLs are indistinct for DISTINCT and UNION.
Multiplying a NULL by zero yields zero. In a CASE expression, a NULL comparison
is considered false, not NULL.  With these changes, NULLs in SQLite now work
the same as in PostgreSQL and in Oracle. (CVS 600)

FossilOrigin-Name: da61aa1d238539dff9c43fd9f464d311e28d669f
2002-05-31 15:51:25 +00:00
drh 0f89253e21 Once it is opened, leave the checkpoint journal file open for the
duration of a transaction, rather than closing it and reopening it
for each statement.  (Ticket #53) (CVS 599)

FossilOrigin-Name: 7a24336d50e72006b2cc0e4feb292b946e79d5f3
2002-05-30 12:27:03 +00:00
drh 461c281a2e Bug fix: bad code was generated for when the first operand of a CASE
was NULL. (CVS 598)

FossilOrigin-Name: 4debc8db929fdc201759ba211acdeadc4e30e8af
2002-05-30 02:35:11 +00:00
drh 739105c72c Built-in aggregate functions (MIN, SUM, AVG, etc) should ignore NULL entires. (CVS 597)
FossilOrigin-Name: 19ae12bef210ae5fe171f10833faa38d640c129f
2002-05-29 23:22:23 +00:00
drh f1756d2a79 Remove extra \ characters from temporary filenames under windows.
(Ticket #52) (CVS 596)

FossilOrigin-Name: ed11abc81e638c21ec1aa0445a6d59de91343095
2002-05-29 12:44:52 +00:00
danielk1977 993b173e55 Update trigger2.test to match checkin 591. Also fix ticket #51 (by documenting problem) (CVS 595)
FossilOrigin-Name: 5e74d0964b8fd99eda798e3737217aa499cc1726
2002-05-28 06:55:27 +00:00
drh d7489c3987 A SELECT statement inside the body of a TRIGGER uses the SRT_Discard target
to discard the query results.  Such selects are intended to be used to call
user-defined functions for their side-effects.  They do not return results. (CVS 594)

FossilOrigin-Name: f8041f3d4d3350b4086cd6ba3e9006bdde8546a9
2002-05-27 12:24:48 +00:00
drh c754fa5486 Fix the "alias.*" bug found by Bernie Cosell and reported on the newsgroup. (CVS 593)
FossilOrigin-Name: f562d542304c0c1b18b0cee78b1ecc353327a02e
2002-05-27 03:25:51 +00:00
drh bb113518f9 Bug fixes and additional test cases for the distinct-NULL patch. (CVS 592)
FossilOrigin-Name: 0e268d0c0faa02c3f95e1567cf631b7a04bfbdf0
2002-05-27 01:04:51 +00:00
danielk1977 d702fccbce Require the INSTEAD OF syntax to create triggers on database views. (CVS 591)
FossilOrigin-Name: d9e48cd5180e2aae7672b9d54e18c37d0fe5258a
2002-05-26 23:24:40 +00:00
drh 8912d106e1 Change functions to handle NULLs correctly. Added the NULLIF() function. (CVS 590)
FossilOrigin-Name: 46ce1a9ab6e527958ebc757fa2175c488299cd84
2002-05-26 21:34:58 +00:00
drh f5905aa7be NULL values are distinct. A comparison involving a NULL is always false.
Operations on a NULL value yield a NULL result.  This change makes SQLite
operate more like the SQL spec, but it may break existing applications that
assumed the old behavior.  All the old tests pass but we still need to add
new tests to better verify the new behavior.  Fix for ticket #44. (CVS 589)

FossilOrigin-Name: 9051173742f1b0e15a809d12a0c9c98fd2c4614d
2002-05-26 20:54:33 +00:00
drh 195e6967fb Additional testing of LEFT OUTER JOIN. (CVS 588)
FossilOrigin-Name: d8d04c14f18d1feba89ccea0be70530a18248c51
2002-05-25 00:18:20 +00:00
drh ad2d8307ac Initial implementation of LEFT OUTER JOIN including the expanded SQL92 join
syntax. The basic functionality is there but there is still a lot of testing
to do. (CVS 587)

FossilOrigin-Name: 99bd1f5b9a1a20bfeefe15c00d96a34a5f40923e
2002-05-24 20:31:36 +00:00
drh 01f3f25376 Add support for the full SQL join syntax. This is just a parser enhancement.
We now recognize all kinds of joins, but we don't actually do anything with
them yet. (CVS 586)

FossilOrigin-Name: e238643efdbe1394c7ff85e34e486f7c6082b6cc
2002-05-24 16:14:15 +00:00
drh 2e392e2c53 Added tests for multi-column primary keys. (CVS 585)
FossilOrigin-Name: ffc49e56b13096b35e6cbb1a2f7d546843d4a91d
2002-05-24 02:14:50 +00:00
drh ad3cab52fe Split the IdList structure into IdList and SrcList. SrcList is used to
represent a FROM clause and IdList is used for everything else.  This change
allows SrcList to grow to support outer joins without burdening the other
uses of IdList. (CVS 584)

FossilOrigin-Name: a167b71d8c27e870bc3079c6132e483bffc83298
2002-05-24 02:04:32 +00:00
drh bd5a451d5d Change the names of the PushList and PopList opcodes to ListPush and ListPop
so that they will appear together with the other List opcodes in the
documentation. (CVS 583)

FossilOrigin-Name: c53b0b9283c5c34def87d58b03fd979d03dc0890
2002-05-23 22:07:02 +00:00
drh 0b4efed236 Fix for ticket #50. (CVS 582)
FossilOrigin-Name: 82b74a494ac7c751a13e67dcfa7fffb1b98ec808
2002-05-23 13:15:37 +00:00
drh 07d6e3a74c Partial fix for ticket #49. The correct result is computed, but now we have
a memory leak.  I'm not sure if the memory leak was pre-existing or a result
of this change. (CVS 581)

FossilOrigin-Name: 4d27ee411902a197cd72416ca9da9197d3f87f13
2002-05-23 12:50:18 +00:00
drh e4697f5e90 Fix some places where a malloc() failure would lead to a segfault. (CVS 580)
FossilOrigin-Name: 01ad352c3c82a86d9c94010cbc85d098b8fbc08a
2002-05-23 02:09:03 +00:00
drh 1873cd508a Do not allow triggers on the SQLITE_MASTER table. (CVS 579)
FossilOrigin-Name: 275ba356f351abcf9a079ac16b765c9443750f0e
2002-05-23 00:30:31 +00:00
drh 97fc3d060a Fix for ticket #46: Report an error if a CREATE TABLE contains two or more
columns with the same name. (CVS 578)

FossilOrigin-Name: ba1953abd04671232cf9e93ab3f962fedbbdc508
2002-05-22 21:27:03 +00:00
drh 2ce1a6ec60 Fix for ticket #47: Use a cast to avoid a warning about discarding a "const"
inside of hash.c. (CVS 577)

FossilOrigin-Name: 0c903461533fabca7815e8cccbd3b712bcd22ddc
2002-05-21 23:44:30 +00:00
drh 2398937b7f Double-quoted strings resolve to column names if possible. Single-quoted
strings continue to be interpreted as string literals. (CVS 576)

FossilOrigin-Name: 55e7d65496624c8e48673d8747f3123786bfedbc
2002-05-21 13:43:04 +00:00
drh 1d1f30555d Clean up some compiler warnings. (CVS 575)
FossilOrigin-Name: 3399b01219b9e75b93587b5634d199d9e6fb6e42
2002-05-21 13:18:25 +00:00
drh b05789ff2b Modify the shell so that when it is doing a ".dump" it always uses single
quotes and not double quotes for quoting literal strings.  This is for
portability to other databases that only support single quote string literals. (CVS 574)

FossilOrigin-Name: f795afd63f19ab61c2b3b96621cb6dda31ce0379
2002-05-21 13:02:24 +00:00
drh 79b0c95687 Fix for ticket #45: Allow an UPDATE statement to change the INTEGER PRIMARY KEY
to itself without triggering a constraint error. (CVS 573)

FossilOrigin-Name: 592da1346872e1373bd13525d05d0f33c1056709
2002-05-21 12:56:43 +00:00
drh c977f7f596 Additional code cleanup resulting from a review of the new trigger code. (CVS 572)
FossilOrigin-Name: 37dbdd551e88440933066133ec9cc1e10b03fc1a
2002-05-21 11:38:11 +00:00
danielk1977 f29ce55958 Style fixes to triggers code in various *.c files (partial fix to ticket #39) (CVS 571)
FossilOrigin-Name: 8a4195c7466962291a296e8f53034ea8cb25005f
2002-05-19 23:43:12 +00:00
danielk1977 633ed08d95 Stylistic changes to src/trigger.c (partial fix to ticket #39). Also more comments. (CVS 570)
FossilOrigin-Name: b1d72cb5847a9f5f08e40b36ad117b5493232ea7
2002-05-17 00:05:58 +00:00
danielk1977 d99bc930f7 Fix for ticket #42: Added comments to structs Trigger, TriggerStep and TriggerStack. (CVS 569)
FossilOrigin-Name: 9ec8a2b139ce38312284d7b4eb61221b1e1e3052
2002-05-16 00:13:12 +00:00
drh b6b2de0c35 Fix a typo in the c_interface.html documentation file. (CVS 568)
FossilOrigin-Name: 454879fa400f8c67456a483e69342bf48e3a02a4
2002-05-15 23:26:22 +00:00
drh ce9079c8f2 Fix for ticket #41: Better handling of CREATE TRIGGER in the sqlite_complete()
function. (CVS 567)

FossilOrigin-Name: f45c4b767a6b1451787836060235ff7499dea0de
2002-05-15 14:17:44 +00:00
drh dc3794561f Beginning to clean up the trigger code. Still lots of work to do. (CVS 566)
FossilOrigin-Name: b10346818b25940c6dc85e94de8e36d20954161c
2002-05-15 12:45:43 +00:00
drh 9adf9ac4e4 Remove all tabs from the beginning of source code lines. Replace tabs with
the appropriate number of spaces. (CVS 565)

FossilOrigin-Name: 690f9a163173c4c7af7e8e92e942cee4184c7974
2002-05-15 11:44:13 +00:00
drh 5b87fa2a57 In the "lang.html" documentation file, put the CREATE TRIGGER and DROP TRIGGER
sections in alphabetical order. (CVS 564)

FossilOrigin-Name: d1d8642b57bd0765ade730248012d58b0859c12c
2002-05-15 11:43:16 +00:00
danielk1977 b38f58b51a Add the Makefile.in that was forgotten with checkin #562 (CVS 563)
FossilOrigin-Name: 29b8330ca6bfe32c499a045189683100f2b15246
2002-05-15 08:43:10 +00:00
danielk1977 c3f9bad209 Added FOR EACH ROW triggers functionality (CVS 562)
FossilOrigin-Name: 794bf67b6b36fce8854d5daff12f21dbb943240c
2002-05-15 08:30:12 +00:00
drh 9456bcc975 Version 2.4.12 (CVS 561)
FossilOrigin-Name: 06cdaf1c80f7bc25fc555c7c8a35258faed2d2e9
2002-05-10 14:41:54 +00:00
drh 4d908a3b43 Update the misuse.test script so that it will work under Windows. Changes
to the speed testing script to support version 2.4.12. (CVS 560)

FossilOrigin-Name: 232b7ef2c8207eb6d2564a641446267d3dec97af
2002-05-10 14:37:30 +00:00
drh c22bd47d55 Improvements to the SQLITE_MISUSE detection logic. Also added test cases
for this logic, including the new test file "misuse.test". (CVS 559)

FossilOrigin-Name: f42907ce457e012592f8c043dc6c915e87258b35
2002-05-10 13:14:07 +00:00
drh 247be43d60 Attempt to detect when two or more threads try to use the same database at
the same time and return an SQLITE_MISUSE error.  Also return this error
if an attempt is made to use a closed database. (CVS 558)

FossilOrigin-Name: a05fabd2df1cb38c555a7b2f31b0ca687db500c2
2002-05-10 05:44:55 +00:00
drh d5feede1ff Fix for ticket #35: Ignore any ORDER BY clause on a subquery in a FROM clause. (CVS 557)
FossilOrigin-Name: 1b0ee944c9af10078aba628e85d79f8682afa2b6
2002-05-08 21:46:14 +00:00
drh 0f18b450ad Fix for ticket #34: VIEWs ignore their ORDER BY clause. (CVS 556)
FossilOrigin-Name: 5f22d21571acedbd6348b61445a7c408cde8d229
2002-05-08 21:30:15 +00:00
drh 891da435d6 Version 2.4.11 (CVS 555)
FossilOrigin-Name: b13151794b42109a59ed34e6b9bce6ce90de537b
2002-05-08 12:03:50 +00:00
drh 685b941542 Increase the version number and update the change log in preparation for
the 2.4.11 release. (CVS 554)

FossilOrigin-Name: f6e406aa0422d9b5a3cfe89b0d38def535f8fe9b
2002-05-08 11:57:09 +00:00
drh 0bb28106be Fix for tickets #32 and #33: Generate the names of the result set early, before
doing the flattening optimization or evaluating subqueries.  Otherwise, the
result set column names are generated incorrectly or after they are needed. (CVS 553)

FossilOrigin-Name: 08f27cb36805d38648274b6fe91dec43a5910057
2002-05-08 11:54:14 +00:00
drh cc47c28068 Added documentation about the new CASE expression. (CVS 552)
FossilOrigin-Name: cc541b10302774b9004babbfb3a11b1f65d4b863
2002-05-06 11:47:32 +00:00
drh 0fface6e33 Fix typos in the man-page (sqlite.1) and remove two unused files.
Patches from Andreas Rottmann. (CVS 551)

FossilOrigin-Name: 5772d31934ced7e35842d7c7689ff4878b7e80f5
2002-05-06 11:34:26 +00:00
drh 133224676a Version 2.4.10 (CVS 550)
FossilOrigin-Name: 5f3618142f7e4654e85ca08383d6d7c1b3395c66
2002-05-03 00:18:11 +00:00
drh 2e18abf43c Update the change log prior to releasing version 2.4.10. (CVS 549)
FossilOrigin-Name: 67838bbc800a1acdd91af8e43f5a65494fb9d690
2002-05-03 00:17:54 +00:00
drh 08192d5f76 Fix for ticket #31: Do not attempt the flattening optimization if the
subselect does not contain a FROM clause.  Handle the special case where
a WHERE clause is constant. (CVS 548)

FossilOrigin-Name: 24e4cf73d22bb41d26bf3c833f1854a9c90923e8
2002-04-30 19:20:28 +00:00
drh ef9f708e8f Fix for ticket #28: Export the "sqlite_changes" function in Windows DLLs. (CVS 547)
FossilOrigin-Name: f7cea4634dd53204b4aa8a3630b9c55c40fdc4b3
2002-04-26 09:47:20 +00:00
drh f7bd5d75db Update the test logic and the comments on the encoder.c module. (CVS 546)
FossilOrigin-Name: 18c28519d973944756694b2c213bfef3153f4b1b
2002-04-25 23:06:47 +00:00
drh e8a49c12a6 Added the "encode.c" source file that contains two utility subroutines that
can be used to encode binary data for use in INSERT and UPDATE statements.
This is just an initial checking.  The code has not yet been integrated into
the library. (CVS 545)

FossilOrigin-Name: 57f7c59713299b03b10ba9c1a5883e2c08a8b138
2002-04-25 11:45:41 +00:00
drh 7caf776079 Fix for ticket #26: Document the fact that CREATE TABLE might not be
immediately visible to other processes that are holding the database open. (CVS 544)

FossilOrigin-Name: 18b31b7ab90ab330e271e0ed5d316f63846845be
2002-04-25 00:21:50 +00:00
drh 41202ccae2 Fix for ticket #22: In the code generator for compound SELECT statements, take
care not to generate column name headers if the output is an intermediate table.
Otherwise the column headers are not generated correctly if a compound SELECT
statement appears as an expression in part of the WHERE clause. (CVS 543)

FossilOrigin-Name: a06d9acdd5af0dc69b3a4d024de082631254aead
2002-04-23 17:10:18 +00:00
drh 60ea3720f2 Version 2.4.9 (CVS 542)
FossilOrigin-Name: 0691720a4b94141635734ab0a8c4072cab189a33
2002-04-22 00:35:06 +00:00
drh 85b988c803 Update the version number and changes log for 2.4.9 (CVS 541)
FossilOrigin-Name: a91da82f8ae2b375bf9f5e064f16d6a5770e20b6
2002-04-22 00:33:23 +00:00
drh e98d4fafe4 Fix for ticket #21 (I think): Do not return an "out of memory" error if we
can not find the users home directory. Instead, just report that we could
not find the home directory. (CVS 540)

FossilOrigin-Name: 8a50c57cc3342de9c6eca6c2567d3aa42b407f10
2002-04-21 19:06:22 +00:00
drh 77155c480a Version 2.4.8 (CVS 538)
FossilOrigin-Name: d703a2c5c4fa3e792e203fd9895b59570b5fdfd1
2002-04-20 14:45:31 +00:00
drh 57809db9c5 Update the change log for the 2.4.8 release. (CVS 539)
FossilOrigin-Name: c01bc2d19e8592fe3b1a5202926be649af96c783
2002-04-20 14:44:01 +00:00
drh 0ac6589202 Fix for ticket #1: Implement the GLOB and LIKE operators as functions that
can be overridden.  This way, a developer can change the LIKE operator to
be case sensitive, for example. (CVS 537)

FossilOrigin-Name: 51572bf71774d7631c7083be90b806e621bc9bee
2002-04-20 14:24:41 +00:00
drh 67505e78c6 Add support for saving the sqlite shell command-line history across sessions. (CVS 536)
FossilOrigin-Name: ca4abf3fe1f0e66802f9f98a20e0c8b82a6459aa
2002-04-19 12:34:06 +00:00
persicom c8cacb3704 Added rights release for Matthew O. Persico (CVS 535)
FossilOrigin-Name: 6c32c07e8218caffebd4503e7d8a90226ac81cdc
2002-04-19 01:00:12 +00:00
drh dd45df8a5b Change shell.c so that it will compile under windows. Shorten the help
command somewhat.  Add the state of ".header" to the output of ".show". (CVS 534)

FossilOrigin-Name: 0582168b8b853559b484f4a024d28c67192160c4
2002-04-18 12:39:03 +00:00
persicom 45698a3a03 Updated to match new shell.c functionality. (CVS 533)
FossilOrigin-Name: ff67ad40106a20fb85797cca4c495dc34ad5519b
2002-04-18 02:53:54 +00:00
persicom 1d0b872d43 Mistake in help text. Spurious trailing whitespace removed. (CVS 532)
FossilOrigin-Name: 4bdd040e4810565c91bcbb5f065580520c5e3c45
2002-04-18 02:53:04 +00:00
persicom 7e2dfdd726 General:
o Added global static chars mainPrompt and continuePrompt.
o Moved Argv0 declaration to head of file. Needed in do_meta_command,
  previously found below that.
o Added struct previous_mode_data to support new .explain toggle
  functionality.
o Added nullvalue, explainPrev and outfile members to
  struct callback_data.
o Added modeDescr array for number/text translation ofdisplay modes.
o Modified zHelp to match new functionality.

callback():
o Added support for .nullvalue

do_meta_command():
o Output filename is now saved to callback struct. If using stdout,
  then the string "stdout" is saved.
o Explain is now a toggle. When it is turned on, the current values of
  mode, header and colWidth are saved if not already in explain mode.
  When turned off, those values are restored.
o Allow .mode plurals columns and lines and dot command plural
  .headers.
o Added processing for new keywords .quit, .nullvalue, .show, .prompt.

main():
o Added -init as an option to override .sqliterc.
o Added -nullvalue as a command line option.
o Processes .sqliterc.

main_init():
o Genesis. Moved some initialization code here from inside main() so
  that it can be called initially by main and again if -init is
  specified.

one_input_line():
o Now takes prompts from settable values.

process_sqliterc():
o Genesis. Read .sqliterc from user's home directory and pass it to
  process_input(). File should contain meta commands for setups. (CVS 531)

FossilOrigin-Name: e751338c468cdad79efcc5cd5b924eb2c1eb3c3a
2002-04-18 02:46:52 +00:00
drh a168045f7d Fix for ticket #19: Do not call sqliteOsSync() if the only changes were
changes to TEMP tables. (CVS 530)

FossilOrigin-Name: 33da20b9c1a8eef16ad7ab5929bb8937c75090f2
2002-04-18 01:56:57 +00:00
drh fc6cdfe9dc When doing a ".dump" command in the command-line shell, make sure VIEWs
are created after TABLEs. (CVS 529)

FossilOrigin-Name: 7edd13468e24d79939f0fa1e58f3b686422ca826
2002-04-13 23:42:24 +00:00
drh 6b0e620fda Version 2.4.7 (CVS 528)
FossilOrigin-Name: 977abbaebe5433c66516d0376a1c229e45b5ab1f
2002-04-12 13:12:25 +00:00
drh adbe353fc6 Add tests to prevent a recurrance of bug #16. Also: put a hyperlink to the new
ticket screen on the main page of the website. (CVS 527)

FossilOrigin-Name: cdab6dad323dd1e95ec8b7684a7c4b06c75905e0
2002-04-12 13:11:52 +00:00
drh c8d30ac109 Fix for bug #15: Add the sqlite_changes() API function for retrieving the
number of rows that changed in the previous operation. (CVS 526)

FossilOrigin-Name: 6e71493b9dc77d508c3ce90562766789e87e6d80
2002-04-12 10:08:59 +00:00
drh b04a5d8768 Fix for bug #16: Check for invalid functions in the VALUES clause of an
INSERT statement. (CVS 525)

FossilOrigin-Name: 43a77f019d34e1a6b3f502ad0ec31a00c8fdbe6e
2002-04-12 03:55:15 +00:00
drh feeb1394ee Fix for bug #11: Output the correct row count when and INSERT does an
IGNORE action. (CVS 524)

FossilOrigin-Name: bb83642e9a6c1c9ade861618496933c9f922a8f8
2002-04-09 03:28:01 +00:00
drh fe1a1773a8 Fix for bug #10: Pop the stack by the right amount on an IGNORE so that the
stack does not grow without bound. (CVS 523)

FossilOrigin-Name: f46acfc3b828620e4e97b09f9aff119b9313e5d7
2002-04-09 03:15:06 +00:00
drh 8b32e17d26 Add a -column option to the sqlite command-line utility.
Patch from Matthew O. Persico. (CVS 522)

FossilOrigin-Name: 760bf568c882d7b28746b1e004309ef08d2ff4c0
2002-04-08 02:42:57 +00:00
drh 6ed41ad735 Added the last_insert_rowid() SQL function. (CVS 521)
FossilOrigin-Name: 6aca3f86bc08849e9d806fdd490f98e4daf71025
2002-04-06 14:10:47 +00:00
drh bf3a4fa4cb Make the FROM clause on a SELECT optional. If omitted, the result of
the SELECT is a single row consisting of the values in the expression list. (CVS 520)

FossilOrigin-Name: 28ce42f7872e2660faa22e66b508db9b1f046af0
2002-04-06 13:57:42 +00:00
drh 41e941dda6 Add an fflush() call to shell.c to insure that all output has been written
before we prompt for a new line of input. (CVS 519)

FossilOrigin-Name: 932274187e045ce331177b1a640ed62da4a22d94
2002-04-04 15:10:12 +00:00
drh 5447322939 Fix for bug #2: Add support for TABLE.* in SELECT statements. (CVS 518)
FossilOrigin-Name: c2320eabfe44d6eb05c02b76547e5bd48a29943c
2002-04-04 02:10:55 +00:00
drh f238f700c2 Added a hyperlink to the SQLite-PHP project. (CVS 517)
FossilOrigin-Name: ffdeec3087e168acaa04a6331e91369e2e0f8345
2002-04-03 20:50:21 +00:00
drh 7b7307fb7c Version 2.4.6 (CVS 516)
FossilOrigin-Name: 5ae7efd87f1a8e2f3e927bf373fbcb5c692d1a02
2002-04-02 13:27:43 +00:00
drh 3f6b548961 Fix for bug #8: Correctly handle terms of a WHERE clause in a join where the
term does not use a comparison operator. (CVS 515)

FossilOrigin-Name: abb12259a09418eb6e3cf573ea718ac58c91ac7b
2002-04-02 13:26:10 +00:00
drh 11f61696bc Version 2.4.5 (CVS 514)
FossilOrigin-Name: b18a7b777cf22249c81b74baafa1a74ad5a1836b
2002-04-02 02:00:02 +00:00
drh dd579122da Fix for bug #6: Correctly handle functions in the WHERE clause of a join. (CVS 513)
FossilOrigin-Name: bdd8ce584e16fe288a7e8386f897cb36a60e8431
2002-04-02 01:58:57 +00:00
drh 5efc18b6da Fix for bug #7: Correctly display the P3 operand in a VDBE trace when the
operand is really a pointer to a structure. (CVS 512)

FossilOrigin-Name: 734dde765b38d61feaa5520e6481c77022367892
2002-04-02 01:44:50 +00:00
drh 29f5befc43 Remove from the index page of the website hyperlinks that are not directly
related to SQLite. (CVS 511)

FossilOrigin-Name: 0cb5cfa814bceecea1a346535cac24ec8e2941d7
2002-04-01 12:15:02 +00:00
drh e1e68f4974 When an attempt is made to insert an explicit NULL into an INTEGER
PRIMARY KEY column, automatically convert the NULL value into a unique
integer key.  This was already happening when an implied NULL was
inserted - when the INTEGER PRIMARY KEY column was omitted from the
list of columns being inserted.  Patches from Christian Werner. (CVS 510)

FossilOrigin-Name: 9e3cf4aa2cb44932015b8bd3fd800d7678cb09b6
2002-03-31 18:29:03 +00:00
drh 035bd01d6a Version 2.4.4 (CVS 509)
FossilOrigin-Name: c4b6c0be00b9688a432bbd23736564a042f5d8ee
2002-03-30 15:32:08 +00:00
drh 132ebed2bf Update the change log to include the previous commit. (CVS 508)
FossilOrigin-Name: 81c4b749614cb0ca50bc52a3d4aac189af0222cd
2002-03-30 15:27:56 +00:00
drh f18543ca39 Fix for bug #3: Allow VIEW as a column name. Also allow COPY. (CVS 507)
FossilOrigin-Name: d2bdc0feeb3a3595850f40ab211df7a3963d6c30
2002-03-30 15:26:50 +00:00
drh edaa6ebfdd Describe the difference between the binary RPMs in the download.html file. (CVS 506)
FossilOrigin-Name: 8ce9a1fad2d8b20876b0557fa57515e0df74ed05
2002-03-30 14:15:51 +00:00
drh 203c211064 Combine the homerpm.sh file in with publish.sh. Update the website files to
refer to the new RPMs that are now being built.  Fix a small problem with
the spec file. (CVS 505)

FossilOrigin-Name: 57d4c7704794d0a28cbf67be3f90dbf81bf3b05d
2002-03-29 18:16:04 +00:00
doughenry 1d36650fa3 added a section to create a spec file and build the rpm files (CVS 504)
FossilOrigin-Name: e529143967a6fd4e65dea6a5ff68a7aabc36f787
2002-03-29 01:29:53 +00:00
doughenry 3c0d1ec01c these files are needed by publish.sh to build rpms (CVS 503)
FossilOrigin-Name: 3c25359376814e9c3912246d79528614a3499e5b
2002-03-29 01:28:45 +00:00
drh 2676a611ec Two typos fixed in the documentation (lang.html). (CVS 502)
FossilOrigin-Name: f0f241e1cc322ebed8f215b4b8ddcc0f5ee2ff65
2002-03-28 14:20:08 +00:00
drh d4037e801a Update the documentation to refer the reader to the CVS server for the change
log, bug lists, or the latest sources. (CVS 500)

FossilOrigin-Name: 2478ba866646d6d445b370554af9cd3d362b0e10
2002-03-27 12:52:47 +00:00
drh 41f03d1d26 Update the change log. (CVS 438)
FossilOrigin-Name: 9637b9aa5d405427ead52438eed8c626feac8658
2002-03-26 03:11:27 +00:00
drh 17a7f8ddab Added support for CASE expressions - patches from Dan Kennedy. (CVS 437)
FossilOrigin-Name: 836b59d057c3fb4087b138c9bfbc03392ddfb89d
2002-03-24 13:13:27 +00:00
drh 6b54e74cf4 Version 2.4.3 (CVS 440)
FossilOrigin-Name: 99d6764e57ddc7f0a321229cc1b7aa9a76f1aae5
2002-03-23 00:59:59 +00:00
drh f1a7a13928 The sqlite_get_table() function now returns an error if you pass in two
or more SELECT statements that return different numbers of columns. (CVS 436)

FossilOrigin-Name: e2558c34034cf49524084ec819df58934a8af983
2002-03-23 00:52:01 +00:00
drh 1cc3d75f69 Fix a bug in subquery generation when the subquery is a compound select.
Also added new tests to cover this case. (CVS 435)

FossilOrigin-Name: aaf7fd4cef04d3d70a0444aad1b606bfc663c3e8
2002-03-23 00:31:29 +00:00
drh 545c23dc42 Version 2.4.2 (CVS 441)
FossilOrigin-Name: 49d032325553fa1dd7f31b852753cc6c9226d8f7
2002-03-20 01:05:00 +00:00
drh 27a3220c54 One more change before 2.4.2: Make the os.h header file more robust in
detecting whether to use unix or windows. (CVS 434)

FossilOrigin-Name: c2e0b79057c9c643e7432e62c90399c8f34339f9
2002-03-20 00:00:29 +00:00
drh 5aed9c7410 Version 2.4.2 (CVS 433)
FossilOrigin-Name: b0805b606904e18800c9850b5aa33724c4619de8
2002-03-19 23:51:12 +00:00
drh f2d74ffb74 Fix an uninitialized variable in AggReset() (CVS 432)
FossilOrigin-Name: 3dcdeae7f620736c1eae52ad78db1efb886ea9c3
2002-03-18 13:03:54 +00:00
drh 84e5920738 Bug fix: allow ROWID as a column in SELECT statements where the FROM clause
includes views which are flattened. (CVS 431)

FossilOrigin-Name: a3a360b308e45eaaf19efda80e30f2d420799cf2
2002-03-14 14:33:31 +00:00
drh 38b360bb80 Version 2.4.1 (CVS 442)
FossilOrigin-Name: 9f12b8805fd2f9a3422ed2a46190cfc881c87b36
2002-03-13 18:59:59 +00:00
drh 51fa3215fa Version 2.4.1 (CVS 430)
FossilOrigin-Name: 9333ecca1e48bfca613d6909498f91ca3a53d53d
2002-03-13 18:54:50 +00:00
drh 094b2bbfc7 Fix bug in anonymous subquery in a join. Parser requires a semicolon or
end-of-input before executing. (CVS 429)

FossilOrigin-Name: c0e3f1c592f583a0659901743a368aff1927f1cb
2002-03-13 18:54:07 +00:00
drh 56c0e926f1 Fix the return type of the xStep function in the FuncDef structure
definition. (CVS 428)

FossilOrigin-Name: 753adb789e1624ceeb52066df350dcd99aa4e3df
2002-03-12 23:10:04 +00:00
drh 1f245e488a Change the way that lemon handles %extra_argument. (CVS 427)
FossilOrigin-Name: ffc387a48a9864b7f323314fbf8295b5bb2a3bd1
2002-03-11 13:55:50 +00:00
drh 54ea6427df Version 2.4.0 (CVS 443)
FossilOrigin-Name: d3f66b44e501ac30aededefbec7ebe224cf080ad
2002-03-11 02:15:00 +00:00
drh 28b4e4890b Preparing for the 2.4.0 release. (CVS 426)
FossilOrigin-Name: 9f5b241cb2fc89f66d3762b4b4978b8e114caf53
2002-03-11 02:06:13 +00:00
drh 7218ac7098 Bug fix: updates within a transaction would fail if there was existed
a temporary table. (CVS 425)

FossilOrigin-Name: 02cc2d60b2a5ee50efdbd90df90810ba559a453f
2002-03-10 21:21:00 +00:00
drh 5191b7e699 Added prototypes to sqlite.h for sqlite_freemem(), sqlite_libversion()
and sqlite_libencoding(). (CVS 424)

FossilOrigin-Name: 145516c93b1a03231e7d84f7f799a39655d7aa99
2002-03-08 02:12:00 +00:00
drh acd4c69580 Fix a bug in the sorting of compound selects. (CVS 423)
FossilOrigin-Name: 0a51323561b7235d46621d9fa25c7111b81c528f
2002-03-07 02:02:51 +00:00
drh 2a0e11df42 Beta 2 (CVS 422)
FossilOrigin-Name: 6c3fb5470ea94bfc99833ff1c78981262c9165eb
2002-03-06 22:04:21 +00:00
drh cd61c2816f Added the default_cache_size and default_synchronous pragmas. Added additional
tests for pragmas.  Added a new speedtest script. (CVS 421)

FossilOrigin-Name: 161c0c5f5db66815e4345c9b5f7a600c03a67475
2002-03-06 22:01:34 +00:00
drh e684090012 Optimizations to the processing of integer comparisons. (CVS 420)
FossilOrigin-Name: b7a7dae919be0e4c35b1fe8cb24fa7359a4b1200
2002-03-06 03:08:25 +00:00
drh 4b845d7ef4 Change the pager locking mechanism so that we don't have to write page 1
to the journal and to the database unless it actually changes. (CVS 419)

FossilOrigin-Name: 480eef1a3a4f049bc0d0cbee32dc8a8d138597c6
2002-03-05 12:41:19 +00:00
drh 603240cf5d Add the ability to turn of calls to fsync() using the "synchronous" pragma.
Increased the default cache size from 100 to 2000 and made the "cache_size"
pragma persistent. (CVS 418)

FossilOrigin-Name: 414da4af1f4aebc3936ca339fbc7932add081912
2002-03-05 01:11:12 +00:00
drh ef2daf547d Updates to the documentation. Changed version number to 2.4.0-beta1 (CVS 417)
FossilOrigin-Name: 36a8fe0ad0ee2a67afafc04125dcc085ec1b5a13
2002-03-04 02:26:15 +00:00
drh 4ff6dfa7de More bugs fixed for views. (CVS 416)
FossilOrigin-Name: 813077623087ffc6cd506f57cf6d1e3d9239f806
2002-03-03 23:06:00 +00:00
drh 417be79cd1 VIEWs are bound to tables when they are used, not when they are first
entered.  This works around the problem of what to do if a table is deleted
that a view refers to. (CVS 415)

FossilOrigin-Name: 6121e5ab9328c90c64d40ade3de73ad11d4aaf4e
2002-03-03 18:59:40 +00:00
drh 75148a27b4 Fix a memory leak in expression processing. (CVS 414)
FossilOrigin-Name: dfe431c9b70bc3a1bf5148826edce0846737e66b
2002-03-03 03:42:31 +00:00
drh c0a165b304 Additional tests of flattening (CVS 413)
FossilOrigin-Name: e1d93c5923195507642d882fff8cd85c454f69ee
2002-03-03 03:11:15 +00:00
drh 2d0794e325 Suppress superfluous OP_OpenTemps when flattening subqueries. (CVS 412)
FossilOrigin-Name: 000441c8fec48cc172894eb767ae9549b8ed8c34
2002-03-03 03:03:52 +00:00
drh 1b2e032999 Bug fixes and additional tests for the subquery flattener. (CVS 411)
FossilOrigin-Name: 2c05389eda391e38894fc6969e29766df82a8fec
2002-03-03 02:49:51 +00:00
drh 30e58750c1 Pager optimization: do not write or journal free pages. This results in
a 2x performance gain for large INSERTs and a 5x performance gain for
large DELETEs. (CVS 410)

FossilOrigin-Name: cf1ebcfb741786f84a596c406f4c492f68cbe881
2002-03-02 20:41:57 +00:00
drh f9ffac96a7 Change the btree node balancers to sort nodes into accending order. This
improves insert and delete speed by 25%. (CVS 409)

FossilOrigin-Name: abbb999d4fc3fe142567b6ede5e625e7bf0da714
2002-03-02 19:00:31 +00:00
drh 832508b7ea Subquery flattening is implemented and passes all regression tests.
We still need to add addition tests to the suite to further exercise
the flattener, however. (CVS 408)

FossilOrigin-Name: d5d3e79cc58da5bd315cc1fea1f7cbf46274da16
2002-03-02 17:04:07 +00:00
drh 567c604bb5 Bug fix when -DMEMORY_DEBUG is off. (CVS 407)
FossilOrigin-Name: e14b0c82f3514f41934a7c0d173b6fdb186aafc8
2002-02-28 04:10:29 +00:00
drh 47c8a67907 Fix bugs in substr() for UTF-8. (CVS 406)
FossilOrigin-Name: e9fd9e7b0fed445b48e7024ecde0354fff1478a6
2002-02-28 04:00:12 +00:00
drh 653bc75992 Remove unused opcodes from the VDBE and fix a bug in the substr() function. (CVS 405)
FossilOrigin-Name: e8611e0c052ddac477f83df485fa5dc882593de0
2002-02-28 03:31:10 +00:00
drh fbc990826c Change the IFNULL and NVL functions to COALESCE. Change MIN and MAX so that
they require at least one argument. (CVS 404)

FossilOrigin-Name: 7d86749d4a78d05930bae2b6491d9428f06fe836
2002-02-28 03:14:18 +00:00
drh 89425d5e02 The new function code passes regression tests. (CVS 403)
FossilOrigin-Name: b00cf110b1cc671b7200a5ce8b9e704f660763c9
2002-02-28 03:04:48 +00:00
drh f55f25f02f Fix the coredump. There are still problems in the test suite though. (CVS 402)
FossilOrigin-Name: 6af10cc53acc1ffa60de3f0d5880a6b72815404c
2002-02-28 01:46:11 +00:00
drh 3212e18238 Added IFNULL and NVL functions. (CVS 401)
FossilOrigin-Name: c6a85c8ee3d653a294bcc033ac6cab2b6de06f96
2002-02-28 00:46:26 +00:00
drh 0bce8354b4 Completely remove the old SQL function system and replace it with the
new user functions.  The code currently compiles but it coredumps on the
test suite.  Do not use in its present state. (CVS 400)

FossilOrigin-Name: 50797fee5066ec9ea23b720e5ab7e8fc8ccc1988
2002-02-28 00:41:10 +00:00
drh dd5baa95e8 Try to reduce the number of malloc() for user-defined functions. Begin
transfering built-in functions over to the user-define function
mechanism. (CVS 399)

FossilOrigin-Name: c4f9e017b449d4036fa8d2bf77b931d4c31d74f7
2002-02-27 19:50:59 +00:00
drh 1350b030c1 Revise the API for user-defined functions. (CVS 398)
FossilOrigin-Name: 633951f0fa11c91f93aa2862df84691750c01e73
2002-02-27 19:00:20 +00:00
drh 4e0f995347 The user-defined function routines failed to detect a malloc() failure. (CVS 397)
FossilOrigin-Name: 085b0d671a1dac964693d69d866224de155dfe4c
2002-02-27 01:53:13 +00:00
drh ff78bd2f07 Bug fixes in the VIEW implementation. (CVS 396)
FossilOrigin-Name: 668ef6380eba256ef82477b63aef850249a619a0
2002-02-27 01:47:11 +00:00
drh a2ed56016f Comment changes only. (CVS 395)
FossilOrigin-Name: 63b87f2ea6cd78f039bf40026d21b18de20b3ba7
2002-02-26 23:55:31 +00:00
drh cd7d2732bf Fix a bug in the quoting of .dump output. By Rajit Singh. (CVS 394)
FossilOrigin-Name: f2310f36d53e9176be7af620ecdf1e5a1dfd4388
2002-02-26 23:24:26 +00:00
drh d3a149efca Added a "stddev()" aggregate function for testing the new user aggregate
function interface. (CVS 393)

FossilOrigin-Name: 2198109712ccf988f93db5740a4f248e80fb9f5d
2002-02-24 17:12:53 +00:00
drh e5095355d6 Code for user-defined aggregates added. Legacy tests all pass but there
has been no testing of the new user-defined aggregate code. (CVS 392)

FossilOrigin-Name: 1e037eb303d8508cb2ea3418e71b03315d895fbd
2002-02-24 03:25:14 +00:00
drh dc04c58360 Move the build-in function definitions into a new source file "func.c". (CVS 391)
FossilOrigin-Name: 530b0f4f2def89e200b7b0724a5967bf981bd91d
2002-02-24 01:55:15 +00:00
drh 8e0a2f903a Added support for user-defined normal functions. Support for user-defined
aggregates is pending. (CVS 390)

FossilOrigin-Name: c490a1ff951c5d4a2de8e4f8d349189bfaef7f74
2002-02-23 23:45:45 +00:00
drh b29b0a5227 Modify lemon to use much less memory for its parser tables. This reduces
the size of the library by 50K, which is important for an embedded library. (CVS 389)

FossilOrigin-Name: 67a135a051e7c96ddbfe85976539b4b8372c7026
2002-02-23 19:39:46 +00:00
drh b59499c73b Bug fix in lemon: 3-way conflicts (SHIFT/REDUCE/REDUCE) were not detected or
resolved.  This is now fixed.  Also, table compression works a little better. (CVS 388)

FossilOrigin-Name: 8da0ac9a8bb859377613dd18f4f423eb49c7338b
2002-02-23 18:45:13 +00:00
drh a76b5dfca6 Code to implement CREATE VIEW is in place. A quick smoke test shows that
it works, but there are probably still many bugs. (CVS 387)

FossilOrigin-Name: 39fed2df11382b9855d518502a6c2ca200fa66b8
2002-02-23 02:32:10 +00:00
drh 17f7193434 Change the SQLITE_MASTER format to version 2 in preparation for adding views. (CVS 386)
FossilOrigin-Name: b2a9807fed544e83002366149b9a363759338c5d
2002-02-21 12:01:27 +00:00
drh 2af0b2d78f Do not allow dot-commands to occur in the middle of a real SQL command. (CVS 385)
FossilOrigin-Name: ffb00bf36a9a5851ea4a69f9c7dd7ce412553e3b
2002-02-21 02:25:02 +00:00
drh 77c679c096 Fix a comment. (CVS 384)
FossilOrigin-Name: 953928537c350e6c9df157553114c6d9d44712d5
2002-02-19 22:43:58 +00:00
drh 5cf8e8c7fa New ROWIDs are numbered sequentially. (CVS 383)
FossilOrigin-Name: 1686196a8aea326f616bc8205df99cd84d955ec4
2002-02-19 22:42:05 +00:00
drh 9562b55115 Optimize simple min() and max() queries. (CVS 382)
FossilOrigin-Name: cc5abfe392bdb8c3ed00e0610bc2b41851bfc9d7
2002-02-19 15:00:07 +00:00
drh aaab5725db Change the name of the sanity_check PRAGMA to "integrity_check" and make
it available on all compiles. (CVS 381)

FossilOrigin-Name: c6e9048e66c8d8e2d5f6c62aa724eef3e9d9f572
2002-02-19 13:39:21 +00:00
drh a80a1e6ae4 Version 2.3.3 (CVS 444)
FossilOrigin-Name: 72c5a92aa6e3ae712af152cff8d1dc5b997b538e
2002-02-19 00:30:00 +00:00
drh 9e2751da83 Final changes before 2.3.3 (CVS 380)
FossilOrigin-Name: a53de7625ac300ba3e61eed2e983010da8fa027b
2002-02-19 00:15:12 +00:00
drh b1feb840df Added a C wrapper program to test threading under Unix. (CVS 379)
FossilOrigin-Name: 8d5634a4470a8145c0fbd0b843d55371d2f95e81
2002-02-18 22:50:26 +00:00
drh 0a36c57eb0 Bug fix: CREATE TABLE, followed by DROP TABLE within the same transaction is
working now. (CVS 378)

FossilOrigin-Name: 553579f936b3a4477c6adfd991adccd06280bfd2
2002-02-18 22:49:59 +00:00
drh 969fa7c128 Add support for CREATE TABLE AS. (CVS 377)
FossilOrigin-Name: 78a50971e9adc8739e7888201c79465a40e1a152
2002-02-18 18:30:32 +00:00
drh e64e7b203e Allow general expressions in the VALUES clause of an INSERT statement. (CVS 376)
FossilOrigin-Name: ec1f3fae6f8cd8466892cd370e1802e492a76e6e
2002-02-18 13:56:36 +00:00
drh cf9095061c Additional tests for the sub-query feature. (CVS 375)
FossilOrigin-Name: a0019fce701fc858134f0a33bda9a511e41a09f8
2002-02-18 13:35:33 +00:00
drh 5ae7af7cc2 Enhancement to Windows "file-exists" function by Joel Lucsy. (CVS 374)
FossilOrigin-Name: d3d59261da9bef3250e99444167ad6ef98764574
2002-02-18 12:48:45 +00:00
drh d820cb1b75 Test and documentation updates for sub-queries. (CVS 373)
FossilOrigin-Name: 607c0c49b2098771020514198cb1076de8245a62
2002-02-18 03:21:45 +00:00
drh 22f70c32f0 Add support for subqueries in the FROM clause of a SELECT. Still need
to add tests for this feature. (CVS 372)

FossilOrigin-Name: 89ffa9ff132858b62a91df1fb7fe49b2d58c01e7
2002-02-18 01:17:00 +00:00
drh 1d83f05257 Make the sqliteParseInfoReset() function locale to the select.c file. (CVS 371)
FossilOrigin-Name: 2336b1eadaedf2556a1988acc7bdf133135154dc
2002-02-17 00:30:36 +00:00
drh 2f4392ff5b All identifiers to be quoted in square brackets, for compatibility with
MS-Access. (CVS 370)

FossilOrigin-Name: e17a858c9eeb70c62f54c88e6be5897e58d67301
2002-02-14 21:42:51 +00:00
drh cffa014dc3 Version 2.3.2 (CVS 446)
FossilOrigin-Name: 4d067000077ee8f0221a7940232dc658c7f04b49
2002-02-14 12:59:59 +00:00
drh 1e336b42f1 Fix an incorrect assert() in pager.c. (CVS 369)
FossilOrigin-Name: 08a68e098a677c508652ba2ff4bd63185cab7546
2002-02-14 12:50:33 +00:00
drh 3cf9084a37 Version 2.3.1 (CVS 445)
FossilOrigin-Name: 846148d6e3fd0529abfef3f819e4a7cb91e44422
2002-02-13 23:29:59 +00:00
drh 976658734c Bug fix: if PRAGMA full_column_names=ON is set and you do a query like this:
"SELECT rowid,* FROM ...", then an assertion failed.  Bummer. (CVS 368)

FossilOrigin-Name: df6bf627a51358e8b14297403feab7b888c38580
2002-02-13 23:22:53 +00:00
drh 3e3a8ab13f Version 2.3.0 (CVS 447)
FossilOrigin-Name: 4c7dfd93530a2a3e50e78235f4e691a5fec109fe
2002-02-03 19:30:00 +00:00
drh 8c87e6e0ff Reenable testing code even if NDEBUG is defined. (CVS 367)
FossilOrigin-Name: 0090c279d83ee355fbac8a484401d29bfa50b0dc
2002-02-03 19:15:02 +00:00
drh 24e97df9c7 Fix a serious bug in INSERT when the source is a SELECT. (CVS 366)
FossilOrigin-Name: 20ea737536700b016385c70105a2af8b2bffce2b
2002-02-03 19:06:02 +00:00
drh 1bffb9c84f Put in PRAGMA SANITY_CHECK in place of VACUUM. (CVS 365)
FossilOrigin-Name: 7c65029e5bf26eb640aef529a7421cd0d6ffd1a9
2002-02-03 17:37:36 +00:00
drh 1dd397f091 The VACUUM command now does a database sanity check. (CVS 364)
FossilOrigin-Name: 95d1f8389dd5e168bdf0290169662296b6a0f6d9
2002-02-03 03:34:07 +00:00
drh 0d65dc0e90 Five-algorithm conflict resolution appears to be working. (CVS 363)
FossilOrigin-Name: 0115518f8e4591123582e3d2bb67282111ebcf60
2002-02-03 00:56:09 +00:00
drh 663fc63a77 Get the ABORT conflict resolution algorithm working. (CVS 362)
FossilOrigin-Name: 9be4d4c6f12056782966396dca0b8e2d384d0cf2
2002-02-02 18:49:19 +00:00
drh fa86c4127d Checkpoint code added to the pager. Regression tests work but the new APIs
have not been tested yet. (CVS 361)

FossilOrigin-Name: aaa53e113ef849e34883ead8ae584c722ad967db
2002-02-02 15:01:15 +00:00
drh 1c92853dac Change to five conflict resolution algorithms: ROLLBACK, ABORT, FAIL,
IGNORE, and REPLACE.  This checkin is code only.  Documentation and
tests are still needed.  Also, ABORT is not fully implemented. (CVS 360)

FossilOrigin-Name: d0e7cf4a83e6abad7129bed356b7492dddaff474
2002-01-31 15:54:21 +00:00
drh b419a926d4 Added ON CONFLICT support to COPY. Updates to documentation. Bug fixes. (CVS 359)
FossilOrigin-Name: cf1538d71c9ce12d5e59f367e03642cbcaf6b717
2002-01-30 16:17:23 +00:00
drh ef6764a1d9 Better testing of the ON CONFLICT logic. (CVS 358)
FossilOrigin-Name: 9bbddb8e013b47547164f71f2d7abd995f8d7385
2002-01-30 04:32:00 +00:00
drh bb37fdc782 More bug fixes in the ON CONFLICT enhancement. (CVS 357)
FossilOrigin-Name: 8229b5f6a348a56432a4a609ee125520c5831973
2002-01-30 00:54:55 +00:00
drh 0ca3e24b2e The new ON CONFLICT logic is in and passes the legacy tests. But the
new capabilities have not been tested and are likely broken. (CVS 356)

FossilOrigin-Name: ac8a4189e2a0c41161ee359db25de94435420368
2002-01-29 23:07:02 +00:00
drh 9cfcf5d4f6 Beginning to insert the infrastructure for ON CONFLICT clauses. (CVS 355)
FossilOrigin-Name: e00a9ff8f99dd58f7cb19a6195fac21f4c8b4af9
2002-01-29 18:41:24 +00:00
drh 881a99e493 Version 2.2.5 (CVS 448)
FossilOrigin-Name: af3bb80810c6cd302a884a106cc70591a738e102
2002-01-28 15:59:59 +00:00
drh 6b12545f4f Bug fix: The IN operator was not working if either side derived from
an INTEGER PRIMARY KEY. (CVS 354)

FossilOrigin-Name: dbcfe198fbaa155874ef82a96b6a4b993ccf3931
2002-01-28 15:53:03 +00:00
drh 71172c5c51 Do not escape the backslash character in shell output. (CVS 353)
FossilOrigin-Name: 5f8c097ebef28315ac2335a768d101e995ccbba2
2002-01-24 00:00:21 +00:00
drh a0f07f1919 Version 2.2.4 (CVS 449)
FossilOrigin-Name: 16712dae4feedd001d8153141a55e298b3a80a94
2002-01-22 14:15:00 +00:00
drh 9208643d2a Constant ORDER BY or GROUP BY expressions are an error. (CVS 352)
FossilOrigin-Name: 035984a5b00b4a1a6505405f40b15c7695283c0a
2002-01-22 14:11:29 +00:00
drh 7613bfae56 Fix a bug in the -separator command-line option. (CVS 351)
FossilOrigin-Name: 593c986f694b14839b2a2ed1da4da468c53fefa5
2002-01-22 12:39:24 +00:00
drh a2e00042a1 The right-hand side of an AS in a SELECT can be used within expressions of
the WHERE, ORDER BY, GROUP BY, and/or HAVING clauses. (CVS 350)

FossilOrigin-Name: 3684beab0f8a71ebdf453871bbde7a9ab1f65385
2002-01-22 03:13:42 +00:00
drh 555fcb489b Version 2.2.3 (CVS 450)
FossilOrigin-Name: a4fe893ce7cdec0d8a4f8cdc640b8967dce7763e
2002-01-16 21:04:59 +00:00
drh af9ff33ac1 Added the last_insert_rowid API function. Improved documentation of
the random ROWID algorithm. (CVS 349)

FossilOrigin-Name: f74d61aaf3fec06cde2c4a6f1465f86ac9058ad2
2002-01-16 21:00:27 +00:00
drh a297b5c3cf Added implementations for sqliteOsEnterMutex() and sqliteOsLeaveMutex(). (CVS 348)
FossilOrigin-Name: f8a026a3ca14ef0b0d562029dd6b184f060457f4
2002-01-15 18:39:43 +00:00
drh 1ab4300ebc Fix warning messages in VC++. Patches from nicolas352001. (CVS 347)
FossilOrigin-Name: f3038d218c91b44b70b75a7b881ea24c87fa6a02
2002-01-14 09:28:19 +00:00
drh 75c3edf8eb Version 2.2.2 (CVS 451)
FossilOrigin-Name: 7da00a33fece0b03b88c5103ce2b57e4d74ba2e4
2002-01-14 03:00:00 +00:00
drh 9647ff85fe Fix a bug that could cause UPDATE to fail for a table that contains
both an INTEGER PRIMARY KEY and an index. (CVS 346)

FossilOrigin-Name: 96cd07a881d7bea86a66d7dfe54713be9c81cb4c
2002-01-14 02:56:24 +00:00
drh da9e034610 Fix a problem with the way temporary tables mask permanent tables. (CVS 345)
FossilOrigin-Name: ba89da603135e5f63f6f97ba3adad02682375c07
2002-01-10 14:31:48 +00:00
drh be67d9cb4b Version 2.2.1 (CVS 452)
FossilOrigin-Name: 61c38f3bfef430f39aa98e9e7fa37324132b4381
2002-01-09 13:44:59 +00:00
drh af989ba546 Homepage changes prior to version 2.2.1. (CVS 344)
FossilOrigin-Name: e78b1ea23ccda4bc476fbb070586dcac2cc83331
2002-01-09 13:35:11 +00:00
drh d229ca9406 Continued work on the DROP/CREATE problem. (CVS 343)
FossilOrigin-Name: 0a3aa99e11ec9803cea646092bc21676e75a6670
2002-01-09 13:30:41 +00:00
drh 74e24cd0fa Working on a bug: Dropping and recreating a table within a transaction
causes an assertion failure. (CVS 342)

FossilOrigin-Name: b3656a5cfef91c89de2cbb9790087d0d53c03e6f
2002-01-09 03:19:59 +00:00
drh 3a88fbda19 Added a manpage from A. Rottmann. (CVS 341)
FossilOrigin-Name: 7deb62241300ff23af5a78dd855f0f69e5f16ffd
2002-01-07 19:58:43 +00:00
drh 462768612b Makefile changes from Andreas Rottmann (CVS 1725)
FossilOrigin-Name: 7910bc7885ddbd90400c3c50014bba499e34d53d
2002-01-07 19:04:22 +00:00
drh e638bbf820 Makefile changes from Andreas Rottmann (CVS 340)
FossilOrigin-Name: e7004afbf808b6389e67e8a335c610227c76101b
2002-01-07 19:04:21 +00:00
drh aacc543e23 Comment updates most. Also some small changes to the VDBE. (CVS 339)
FossilOrigin-Name: 9b0be4fcc1cbca69f5fee906f86dfb36a323fe84
2002-01-06 17:07:40 +00:00
drh c6b52df32d An attempt to delete a single row using a WHERE clause that specifies
the rowid would result in an error if the rowid did not exist.  This
problem has been resolved. (CVS 338)

FossilOrigin-Name: 011be9a9d2632d261489005d97c69b0a0bc5a108
2002-01-04 03:09:29 +00:00
drh c839258651 Comment changes. Change the use of BTree so that either the key is
an integer or the data is empty. (CVS 337)

FossilOrigin-Name: 18e606f7486eb3a4ab128504d88a44f53d39e5b2
2001-12-31 02:48:51 +00:00
drh f7f07c7aef Version 2.2.0 (CVS 453)
FossilOrigin-Name: 6bb62d8fab621b79b2fd1601669b1d4c8a547774
2001-12-22 21:59:59 +00:00
drh 9aa028daa2 Bug fix in the out-of-order INSERT. (CVS 336)
FossilOrigin-Name: a26d0880b20ca5534400a3689d1da31fe6aaa934
2001-12-22 21:48:29 +00:00
drh e7ec22019d Update documentation for the 2.2.0 release. (CVS 335)
FossilOrigin-Name: 14392258c5b6385091be8d684e3ea6841941b483
2001-12-22 19:27:39 +00:00
drh 8aff10153e Bug fixing in the new integer primary key code. (CVS 334)
FossilOrigin-Name: 29cab124b4f7eae9d9feb60d2f3a2c443fd9b9aa
2001-12-22 14:49:24 +00:00
drh 4a32431ce7 Added support for the INTEGER PRIMARY KEY column type. (CVS 333)
FossilOrigin-Name: 236a54d289e858a1e0505a20d907a2a40c01b521
2001-12-21 14:30:42 +00:00
drh 7c917d196f Added the ability to say things like "SELECT rowid, * FROM table1;" (CVS 332)
FossilOrigin-Name: ffbdd43f5de62e7bf81631c83473aca29c3a6c98
2001-12-16 20:05:05 +00:00
drh 6446c4dc67 Comment and documentation changes. (CVS 331)
FossilOrigin-Name: e8595579a5218aa3f344f967a23ac52ea89daca1
2001-12-15 14:22:18 +00:00
drh a3cf986fa5 Version 2.1.7 (CVS 454)
FossilOrigin-Name: 0d44465347125c8e7e962ffb67213f9953a9b7ab
2001-12-15 03:04:59 +00:00
drh c38f3d510c Typo in change log fixed. (CVS 330)
FossilOrigin-Name: 3a31daf6465b989a2b0790a2d1ba22ff955486a0
2001-12-15 03:00:42 +00:00
drh 4cbd68f805 Release 2.1.7 (CVS 329)
FossilOrigin-Name: 71cb9e8ad7616b1f84dc04700685bd4dc157d2db
2001-12-15 02:58:18 +00:00
drh 0ce92edd57 Fix a bug in the sqliteBtreeFirst() function which was causing the first
row of a table to be repeated during a scan. (CVS 328)

FossilOrigin-Name: 1404ac076b2155778b6b21546b30df6f45ea7ba7
2001-12-15 02:47:28 +00:00
drh 653851f577 Fix a critical bug in the creation of temporary tables. (CVS 327)
FossilOrigin-Name: 96f707413699eec16053a0323affbe8bf3760c14
2001-12-15 02:35:59 +00:00
drh 251d4b870d Version 2.1.6 (CVS 455)
FossilOrigin-Name: 6ecd90b6c3f3616af78b5ac6323e0f2e883a61c9
2001-12-14 15:14:59 +00:00
drh a7fcb05988 Fix a race condition in the locking code that would sometimes cause
SQLITE_PROTOCOL or SQLITE_CORRUPT to be returned when SQLITE_BUSY should
have been returned. (CVS 326)

FossilOrigin-Name: b0d218876442187af08161d989e6887b1cb4130c
2001-12-14 15:09:55 +00:00
drh 6a6cfb9b31 Version 2.1.5 (CVS 456)
FossilOrigin-Name: 8e90ad552fad83568297202848fe7eb2b63db33d
2001-12-06 13:30:00 +00:00
drh 2cf65aad6c Bug fix in the sqliteOsLock() and sqliteOsUnlock() routines of POSIX.
Version 2.1.5. (CVS 325)

FossilOrigin-Name: 669454060867593290c1ce8c45bd87d011976289
2001-12-06 13:24:14 +00:00
drh 7df884e0d6 Version 2.1.4 (CVS 457)
FossilOrigin-Name: 121c522e673cc2a2176582981cc5cd8694095337
2001-12-05 00:59:59 +00:00
drh 208611fbca Minor changes prior to 2.1.4 (CVS 324)
FossilOrigin-Name: 2fb22adbd15740d5e1581d4114cdf5149e0b62dc
2001-12-05 00:46:02 +00:00
drh 03c1e9262e Version 2.1.4 (CVS 323)
FossilOrigin-Name: 003f967e8749903af859ad81a8a57767ea20ddec
2001-12-05 00:22:00 +00:00
drh b8ca307e7b Bug fix: sqlite_exec() would sometimes return SQLITE_PROTOCOL when it
should have returned SQLITE_BUSY.  There was also a deadlock that the
previous bug was masking. (CVS 322)

FossilOrigin-Name: 585ed5ebf1c1afc8ae1d569b121208018d8ecd49
2001-12-05 00:21:20 +00:00
drh 6ff13859d5 Add the ability to do a single .command as the second argument
to the command-line shell. (CVS 321)

FossilOrigin-Name: 653f37c365a0b5d59c11b7dbba57905ffaeff2dc
2001-11-25 13:18:23 +00:00
drh e68fefdaa5 Fix typos. (CVS 320)
FossilOrigin-Name: 3be8a189e8ccf8a82acc4ee72cc75b6cc92aa193
2001-11-24 13:50:53 +00:00
drh e91d6fd3c3 Typos fixed. (CVS 319)
FossilOrigin-Name: e86a68c5ace984da09d3ce44dae5d501ec0d0eec
2001-11-24 13:36:30 +00:00
drh 59fefbab1a Update the FAQ. Change the GMT timezone label to UTC on all files. (CVS 318)
FossilOrigin-Name: f1a5808288e4204aee03531de0b9e6646062bd94
2001-11-24 13:23:04 +00:00
drh 44ebccbe26 Version 2.1.3 (CVS 458)
FossilOrigin-Name: 974d42839b6ced9c9b9ea14abec0c4723388a991
2001-11-24 00:45:00 +00:00
drh 7a7c73905d Fix comparison functions so that they are consistent with the order
of elements in indices.  Fix the handling of large integers. (CVS 317)

FossilOrigin-Name: fc2aae04578c305304a45ec6b76d3ab216cc7526
2001-11-24 00:31:46 +00:00
drh ece4ea4af4 Version 2.1.2 (CVS 459)
FossilOrigin-Name: f14835df32b4a16c840b8827f0c17f0e6d526312
2001-11-23 00:30:00 +00:00
drh f5bf0a78be Fix a bug in DROP TABLE that could cause SQLITE_MASTER table corruption.
The root problem was that the sequence of BTree operations (Delete, Next)
would not always leave the cursor pointing at the first entry after the
entry that was deleted.  A consequence of this error was that a DROP TABLE
on a table with indices would not always remove every index associated
with that table from the SQLITE_MASTER table.  Subsequent attempts to
open the database will fail when the index for the missing table was
parsed.  Changes have also been made to ignore extra indices in the
SQLITE_MASTER table so that a database previously corrupted by this bug
is once again readable. (CVS 316)

FossilOrigin-Name: 8a984667113564f2bac7412165b6ff8b7e3e8f70
2001-11-23 00:24:12 +00:00
drh c3a64ba0a6 Fix a bug in the locking protocol. (CVS 315)
FossilOrigin-Name: a9db1c12c5a4d5741de0e5eb5aa87c647a5646b8
2001-11-22 00:01:27 +00:00
drh 5a2c2c20af Attempting to add support for 64-bit platforms. (CVS 314)
FossilOrigin-Name: 03673adbfe0c8a92d79f86ddf1136736594208ad
2001-11-21 02:21:11 +00:00
drh bc1bd58acf Version 2.1.1 (CVS 460)
FossilOrigin-Name: be228cd13a4dcb7fdf7014910b7c61d502cb9a01
2001-11-13 19:44:59 +00:00
drh f6e515b804 Bug fix: Be sure to sends NULLs to the callback when the column value is NULL. (CVS 313)
FossilOrigin-Name: 207a57ad2e4e1a44a4c0231b1ba334594402d6cd
2001-11-13 19:36:55 +00:00
drh a84f6005a9 Bug fix: Sometimes NULL results were not being passed as nulls to the
callback function. (CVS 312)

FossilOrigin-Name: 94ce8282360d4a0dd2032564aae06f0f1902cb5b
2001-11-13 19:35:14 +00:00
drh 606c0ddcfc Version 2.1.0 (CVS 461)
FossilOrigin-Name: 56d8390e47bbf8f97fa602863af4c65ac755964e
2001-11-12 14:00:00 +00:00
drh 7900eaded1 Update change log prior to release of 2.1.0. (CVS 311)
FossilOrigin-Name: 6b3ccb37bf4c10b2d8f96ef8efc22ed8253f1886
2001-11-12 13:51:43 +00:00
drh 84e6b7b5ae Fix to the SUBSTR() function and to the bigrow test. (CVS 310)
FossilOrigin-Name: 8437076c25330759ae058918a8190df26d0881da
2001-11-12 13:10:52 +00:00
drh 778326010c Version 2.1.0 prerelease (CVS 309)
FossilOrigin-Name: 4f4ac42214610d900a5d6db63a511d9e7b22f0f9
2001-11-12 12:43:22 +00:00
drh 58a11680d1 Comment changes (CVS 308)
FossilOrigin-Name: 2d2ad264aad6fbdcef586e73d750e3fde842252f
2001-11-10 13:51:08 +00:00
drh 04096485f4 Minor bugs fixed. (CVS 307)
FossilOrigin-Name: 6e7e7dbf8e93d00eced88404aed792fcf9e75b7d
2001-11-09 22:41:44 +00:00
drh ce927065c2 Bug fixes. (CVS 306)
FossilOrigin-Name: 84997fda33fd6ce93b821d3da3a7251cf60e06ec
2001-11-09 13:41:09 +00:00
drh 487ab3ca18 The new code for taking advantage of inequalities in WHERE clauses
is in place.  It appears to work. (CVS 305)

FossilOrigin-Name: 262bcd17df19f45def6144b5a7e0602ca5b03deb
2001-11-08 00:45:21 +00:00
drh 6b56344d4a New Next opcode and indexing style implemented. (CVS 304)
FossilOrigin-Name: decbeb9151885fee473b3fa58c8cf78a2338d2d8
2001-11-07 16:48:26 +00:00
drh 8721ce4ae7 Incremental update. We are in the middle of modifying the index system
to support range queries without doing a complete table scan. (CVS 303)

FossilOrigin-Name: e6ca23fa4569bc33065bf57ce7ce6132cd6a9de0
2001-11-07 14:22:00 +00:00
drh 17e24df621 Added support for LIMIT. (CVS 302)
FossilOrigin-Name: 177012249ae93dbea4a11fb50faaae7912848bd0
2001-11-06 14:10:41 +00:00
drh 9bbca4c1c0 Implement indices that occur in sort order and the LIMIT...OFFSET clause
of SELECT statements. (CVS 301)

FossilOrigin-Name: eb07768ae93f14bf6c150c1c4329948857a9d01c
2001-11-06 04:00:18 +00:00
drh 80ff32f5be Increase maximum row size to 1MB. (CVS 300)
FossilOrigin-Name: 7dd58fad398253608f55867cf1c7749eef005657
2001-11-04 18:32:46 +00:00
drh b70ce0c69c Version 2.0.8 (CVS 462)
FossilOrigin-Name: 0fd2874205f1a4b89fc069cb429c1b0c7a0b99c1
2001-11-04 00:00:00 +00:00
drh 0f24678d8c Version 2.0.8 (CVS 299)
FossilOrigin-Name: 0a8c2f4f9812ffa7d43be0e3b59648dca40fa83c
2001-11-03 23:59:16 +00:00
drh 9f71c2e002 Added "const" to lots of "char*" parameters in the API. (CVS 298)
FossilOrigin-Name: 1c448f1fd2a2e103e7464df896174534d02152ed
2001-11-03 23:57:09 +00:00
drh a8b38d286e Remove cruft: restrict the number of sorters and lists in the VDBE to one
since no more than one was ever used anyway.  This eliminates several
op-codes and simplifies the implementation of several others. (CVS 297)

FossilOrigin-Name: e1370276c2a0d045b29c981ddcb59f737e19a91c
2001-11-01 14:41:34 +00:00
drh 18b81e5a93 Comment changes only. (CVS 296)
FossilOrigin-Name: b2cb118fb7c6713684d32a48a7ba8ffffe596687
2001-11-01 13:52:52 +00:00
drh 33f51c9b71 More documentation updates (CVS 295)
FossilOrigin-Name: f65df59e554c281ad1efa830f13f87488eb16845
2001-10-31 15:44:46 +00:00
drh ba99af57ac Make lemon 64-bit clean (CVS 294)
FossilOrigin-Name: 475e2fedda2256cc1cfdffa1b12745bc401e552d
2001-10-25 20:37:16 +00:00
194 changed files with 75541 additions and 25615 deletions
+261 -63
View File
@@ -31,8 +31,15 @@ TCC = @TARGET_CC@ @TARGET_CFLAGS@ -I. -I${TOP}/src
# Some standard variables and programs
#
prefix = @prefix@
exec_prefix = @exec_prefix@
INSTALL = @INSTALL@
LIBTOOL = ./libtool
RELEASE = @ALLOWRELEASE@
# libtool compile/link/install
LTCOMPILE = $(LIBTOOL) --mode=compile $(TCC)
LTLINK = $(LIBTOOL) --mode=link $(TCC)
LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
# Compiler options needed for programs that use the TCL library.
#
@@ -56,30 +63,63 @@ LIBREADLINE = @TARGET_READLINE_LIBS@
# ENCODING = ISO8859
ENCODING = @ENCODING@
# Flags controlling use of the in memory btree implementation
#
# SQLITE_OMIT_INMEMORYDB is defined in order to omit the in-memory
# red/black tree driver in the file btree_rb.c
#
# TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
# default to file, 2 to default to memory, and 3 to force temporary
# tables to always be in memory.
#
INMEMORYDB = @INMEMORYDB@
INCOREFLAGS = -DTEMP_STORE=@TEMP_STORE@
ifeq (${INMEMORYDB},0)
INCOREFLAGS += -DSQLITE_OMIT_INMEMORYDB=1
endif
# You should not have to change anything below this line
###############################################################################
# Object files for the SQLite library.
#
LIBOBJ = btree.lo build.lo delete.lo expr.lo hash.lo insert.lo \
main.lo os.lo pager.lo parse.lo printf.lo random.lo select.lo \
table.lo tokenize.lo update.lo util.lo vdbe.lo where.lo
LIBOBJ = attach.lo auth.lo btree.lo build.lo copy.lo date.lo \
delete.lo encode.lo expr.lo func.lo hash.lo insert.lo \
main.lo opcodes.lo os.lo pager.lo parse.lo pragma.lo \
printf.lo random.lo select.lo table.lo tokenize.lo \
update.lo util.lo vacuum.lo vdbe.lo vdbeaux.lo \
where.lo trigger.lo
# Only build the in-core DB if it is required.
ifeq (${INMEMORYDB},1)
LIBOBJ += btree_rb.lo
endif
# All of the source code files.
#
SRC = \
$(TOP)/src/attach.c \
$(TOP)/src/auth.c \
$(TOP)/src/btree.c \
$(TOP)/src/btree.h \
$(TOP)/src/btree_rb.c \
$(TOP)/src/build.c \
$(TOP)/src/copy.c \
$(TOP)/src/date.c \
$(TOP)/src/delete.c \
$(TOP)/src/encode.c \
$(TOP)/src/expr.c \
$(TOP)/src/func.c \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
$(TOP)/src/insert.c \
$(TOP)/src/main.c \
$(TOP)/src/os.c \
$(TOP)/src/pager.c \
$(TOP)/src/pager.h \
$(TOP)/src/parse.y \
$(TOP)/src/pragma.c \
$(TOP)/src/printf.c \
$(TOP)/src/random.c \
$(TOP)/src/select.c \
@@ -89,9 +129,12 @@ SRC = \
$(TOP)/src/table.c \
$(TOP)/src/tclsqlite.c \
$(TOP)/src/tokenize.c \
$(TOP)/src/trigger.c \
$(TOP)/src/update.c \
$(TOP)/src/util.c \
$(TOP)/src/vacuum.c \
$(TOP)/src/vdbe.c \
$(TOP)/src/vdbeaux.c \
$(TOP)/src/vdbe.h \
$(TOP)/src/where.c
@@ -99,17 +142,42 @@ SRC = \
#
TESTSRC = \
$(TOP)/src/btree.c \
$(TOP)/src/func.c \
$(TOP)/src/os.c \
$(TOP)/src/pager.c \
$(TOP)/src/test1.c \
$(TOP)/src/test2.c \
$(TOP)/src/test3.c \
$(TOP)/src/test4.c \
$(TOP)/src/vdbe.c \
$(TOP)/src/md5.c
# Header files used by all library source files.
#
HDR = \
sqlite.h \
$(TOP)/src/btree.h \
config.h \
$(TOP)/src/hash.h \
opcodes.h \
$(TOP)/src/os.h \
$(TOP)/src/sqliteInt.h \
$(TOP)/src/vdbe.h \
parse.h
# Header files used by the VDBE submodule
#
VDBEHDR = \
$(HDR) \
$(TOP)/src/vdbeInt.h
# This is the default Makefile target. The objects listed here
# are what get build when you type just "make" with no arguments.
#
all: sqlite.h libsqlite.la sqlite
all: sqlite.h libsqlite.la sqlite@TARGET_EXEEXT@
Makefile: $(TOP)/Makefile.in
./config.status
# Generate the file "last_change" which contains the date of change
# of the most recently modified source code file
@@ -119,116 +187,188 @@ last_change: $(SRC)
| awk '{print $$5,$$6}' >last_change
libsqlite.la: $(LIBOBJ)
$(LIBTOOL) $(TCC) -o libsqlite.la $(LIBOBJ) -rpath $(prefix)/lib
$(LTLINK) -o libsqlite.la $(LIBOBJ) ${RELEASE} -rpath @exec_prefix@/lib \
-version-info "8:6:8"
libtclsqlite.la: $(LIBOBJ) tclsqlite.lo
$(LIBTOOL) $(TCC) -o libtclsqlite.la $(LIBOBJ) tclsqlite.lo \
$(LIBTCL) -rpath $(prefix)/lib
libtclsqlite.la: tclsqlite.lo libsqlite.la
$(LTLINK) -o libtclsqlite.la tclsqlite.lo \
libsqlite.la $(LIBTCL) -rpath @exec_prefix@/lib/sqlite \
-version-info "8:6:8"
sqlite: $(TOP)/src/shell.c libsqlite.la sqlite.h
$(LIBTOOL) $(TCC) $(READLINE_FLAGS) -o sqlite $(TOP)/src/shell.c \
sqlite@TARGET_EXEEXT@: $(TOP)/src/shell.c libsqlite.la sqlite.h
$(LTLINK) $(READLINE_FLAGS) -o sqlite $(TOP)/src/shell.c \
libsqlite.la $(LIBREADLINE)
# This target creates a directory named "tsrc" and fills it with
# copies of all of the C source code and header files needed to
# build on the target system. Some of the C source code and header
# files are automatically generated. This target takes care of
# all that automatic generation.
#
target_source: $(SRC) $(VDBEHDR)
rm -rf tsrc
mkdir tsrc
cp $(SRC) $(VDBEHDR) tsrc
rm tsrc/sqlite.h.in tsrc/parse.y
cp parse.c opcodes.c tsrc
# Rules to build the LEMON compiler generator
#
lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
lemon@BUILD_EXEEXT@: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
$(BCC) -o lemon $(TOP)/tool/lemon.c
cp $(TOP)/tool/lempar.c .
# Header files used by all library source files.
#
HDR = \
sqlite.h \
$(TOP)/src/btree.h \
$(TOP)/src/os.h \
$(TOP)/src/sqliteInt.h \
$(TOP)/src/vdbe.h \
parse.h
btree.lo: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
$(LIBTOOL) $(TCC) -c $(TOP)/src/btree.c
$(LTCOMPILE) -c $(TOP)/src/btree.c
btree_rb.lo: $(TOP)/src/btree_rb.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/btree_rb.c
build.lo: $(TOP)/src/build.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/build.c
$(LTCOMPILE) -c $(TOP)/src/build.c
main.lo: $(TOP)/src/main.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/main.c
$(LTCOMPILE) -c ${INCOREFLAGS} $(TOP)/src/main.c
pager.lo: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
$(LIBTOOL) $(TCC) -c $(TOP)/src/pager.c
$(LTCOMPILE) -c $(TOP)/src/pager.c
opcodes.lo: opcodes.c
$(LTCOMPILE) -c opcodes.c
opcodes.c: $(TOP)/src/vdbe.c
echo '/* Automatically generated file. Do not edit */' >opcodes.c
echo 'char *sqliteOpcodeNames[] = { "???", ' >>opcodes.c
grep '^case OP_' $(TOP)/src/vdbe.c | \
sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >>opcodes.c
echo '};' >>opcodes.c
opcodes.h: $(TOP)/src/vdbe.h
echo '/* Automatically generated file. Do not edit */' >opcodes.h
grep '^case OP_' $(TOP)/src/vdbe.c | \
sed -e 's/://' | \
awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
os.lo: $(TOP)/src/os.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/os.c
$(LTCOMPILE) -c $(TOP)/src/os.c
parse.lo: parse.c $(HDR)
$(LIBTOOL) $(TCC) -c parse.c
$(LTCOMPILE) -c parse.c
parse.h: parse.c
parse.c: $(TOP)/src/parse.y lemon
parse.c: $(TOP)/src/parse.y lemon@BUILD_EXEEXT@
cp $(TOP)/src/parse.y .
./lemon parse.y
# The config.h file will contain a single #define that tells us how
# many bytes are in a pointer. This only works if a pointer is the
# same size on the host as it is on the target. If you are cross-compiling
# to a target with a different pointer size, you'll need to manually
# configure the config.h file.
#
config.h:
echo '#include <stdio.h>' >temp.c
echo 'int main(){printf(' >>temp.c
echo '"#define SQLITE_PTR_SZ %d",sizeof(char*));' >>temp.c
echo 'exit(0);}' >>temp.c
$(BCC) -o temp temp.c
./temp >config.h
echo >>config.h
rm -f temp.c temp
sqlite.h: $(TOP)/src/sqlite.h.in
sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
-e s/--ENCODING--/$(ENCODING)/ \
$(TOP)/src/sqlite.h.in >sqlite.h
tokenize.lo: $(TOP)/src/tokenize.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/tokenize.c
$(LTCOMPILE) -c $(TOP)/src/tokenize.c
util.lo: $(TOP)/src/util.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/util.c
$(LTCOMPILE) -c $(TOP)/src/util.c
vdbe.lo: $(TOP)/src/vdbe.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/vdbe.c
vdbe.lo: $(TOP)/src/vdbe.c $(VDBEHDR)
$(LTCOMPILE) -c $(TOP)/src/vdbe.c
vdbeaux.lo: $(TOP)/src/vdbe.c $(VDBEHDR)
$(LTCOMPILE) -c $(TOP)/src/vdbeaux.c
where.lo: $(TOP)/src/where.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/where.c
$(LTCOMPILE) -c $(TOP)/src/where.c
copy.lo: $(TOP)/src/copy.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/copy.c
date.lo: $(TOP)/src/date.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/date.c
delete.lo: $(TOP)/src/delete.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/delete.c
$(LTCOMPILE) -c $(TOP)/src/delete.c
encode.lo: $(TOP)/src/encode.c
$(LTCOMPILE) -c $(TOP)/src/encode.c
expr.lo: $(TOP)/src/expr.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/expr.c
$(LTCOMPILE) -c $(TOP)/src/expr.c
func.lo: $(TOP)/src/func.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/func.c
hash.lo: $(TOP)/src/hash.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/hash.c
$(LTCOMPILE) -c $(TOP)/src/hash.c
insert.lo: $(TOP)/src/insert.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/insert.c
$(LTCOMPILE) -c $(TOP)/src/insert.c
random.lo: $(TOP)/src/random.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/random.c
$(LTCOMPILE) -c $(TOP)/src/random.c
select.lo: $(TOP)/src/select.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/select.c
$(LTCOMPILE) -c $(TOP)/src/select.c
table.lo: $(TOP)/src/table.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/table.c
$(LTCOMPILE) -c $(TOP)/src/table.c
trigger.lo: $(TOP)/src/trigger.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/trigger.c
update.lo: $(TOP)/src/update.c $(HDR)
$(LIBTOOL) $(TCC) -c $(TOP)/src/update.c
$(LTCOMPILE) -c $(TOP)/src/update.c
vacuum.lo: $(TOP)/src/vacuum.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/vacuum.c
tclsqlite.lo: $(TOP)/src/tclsqlite.c $(HDR)
$(LIBTOOL) $(TCC) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
$(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
pragma.lo: $(TOP)/src/pragma.c $(HDR)
$(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/pragma.c
printf.lo: $(TOP)/src/printf.c $(HDR)
$(LIBTOOL) $(TCC) $(TCL_FLAGS) -c $(TOP)/src/printf.c
$(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/printf.c
tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.la
$(LIBTOOL) $(TCC) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
$(TOP)/src/tclsqlite.c libsqlite.la $(LIBTCL)
attach.lo: $(TOP)/src/attach.c $(HDR)
$(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/attach.c
testfixture: $(TOP)/src/tclsqlite.c libtclsqlite.la $(TESTSRC)
$(LIBTOOL) $(TCC) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1\
auth.lo: $(TOP)/src/auth.c $(HDR)
$(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/auth.c
tclsqlite-sh.lo: $(TOP)/src/tclsqlite.c $(HDR)
$(LTCOMPILE) $(TCL_FLAGS) -DTCLSH=1 -o $@ -c $(TOP)/src/tclsqlite.c
tclsqlite: tclsqlite-sh.lo libsqlite.la
$(LTLINK) $(TCL_FLAGS) -o tclsqlite tclsqlite-sh.lo libsqlite.la $(LIBTCL)
testfixture@TARGET_EXEEXT@: $(TOP)/src/tclsqlite.c libtclsqlite.la libsqlite.la $(TESTSRC)
$(LTLINK) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1\
-o testfixture $(TESTSRC) $(TOP)/src/tclsqlite.c \
libtclsqlite.la $(LIBTCL)
libtclsqlite.la libsqlite.la $(LIBTCL)
fulltest: testfixture sqlite
fulltest: testfixture@TARGET_EXEEXT@ sqlite@TARGET_EXEEXT@
./testfixture $(TOP)/test/all.test
test: testfixture sqlite
test: testfixture@TARGET_EXEEXT@ sqlite@TARGET_EXEEXT@
./testfixture $(TOP)/test/quick.test
index.html: $(TOP)/www/index.tcl last_change
@@ -258,9 +398,6 @@ arch.png: $(TOP)/www/arch.png
opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
crosscompile.html: $(TOP)/www/crosscompile.tcl
tclsh $(TOP)/www/crosscompile.tcl >crosscompile.html
mingw.html: $(TOP)/www/mingw.tcl
tclsh $(TOP)/www/mingw.tcl >mingw.html
@@ -270,9 +407,33 @@ tclsqlite.html: $(TOP)/www/tclsqlite.tcl
speed.html: $(TOP)/www/speed.tcl
tclsh $(TOP)/www/speed.tcl >speed.html
faq.html: $(TOP)/www/faq.tcl
tclsh $(TOP)/www/faq.tcl >faq.html
formatchng.html: $(TOP)/www/formatchng.tcl
tclsh $(TOP)/www/formatchng.tcl >formatchng.html
conflict.html: $(TOP)/www/conflict.tcl
tclsh $(TOP)/www/conflict.tcl >conflict.html
download.html: $(TOP)/www/download.tcl
tclsh $(TOP)/www/download.tcl >download.html
omitted.html: $(TOP)/www/omitted.tcl
tclsh $(TOP)/www/omitted.tcl >omitted.html
datatypes.html: $(TOP)/www/datatypes.tcl
tclsh $(TOP)/www/datatypes.tcl >datatypes.html
quickstart.html: $(TOP)/www/quickstart.tcl
tclsh $(TOP)/www/quickstart.tcl >quickstart.html
fileformat.html: $(TOP)/www/fileformat.tcl
tclsh $(TOP)/www/fileformat.tcl >fileformat.html
nulls.html: $(TOP)/www/nulls.tcl
tclsh $(TOP)/www/nulls.tcl >nulls.html
# Files to be published on the website.
#
@@ -286,25 +447,62 @@ DOC = \
arch.png \
vdbe.html \
c_interface.html \
crosscompile.html \
mingw.html \
tclsqlite.html \
download.html \
speed.html
speed.html \
faq.html \
formatchng.html \
conflict.html \
omitted.html \
datatypes.html \
quickstart.html \
fileformat.html \
nulls.html
doc: $(DOC)
mkdir -p doc
mv $(DOC) doc
install: sqlite libsqlite.la sqlite.h
$(LIBTOOL) $(INSTALL) libsqlite.la $(prefix)/lib
$(LIBTOOL) $(INSTALL) sqlite $(prefix)/bin
$(INSTALL) sqlite.h $(prefix)/include
$(INSTALL) -d $(DESTDIR)$(exec_prefix)/lib
$(LTINSTALL) libsqlite.la $(DESTDIR)$(exec_prefix)/lib
$(INSTALL) -d $(DESTDIR)$(exec_prefix)/bin
$(LTINSTALL) sqlite $(DESTDIR)$(exec_prefix)/bin
$(INSTALL) -d $(DESTDIR)$(prefix)/include
$(INSTALL) -m 0644 sqlite.h $(DESTDIR)$(prefix)/include
$(INSTALL) -d $(DESTDIR)$(exec_prefix)/lib/pkgconfig;
$(INSTALL) -m 0644 sqlite.pc $(DESTDIR)$(exec_prefix)/lib/pkgconfig;
clean:
rm -f *.lo *.la *.o sqlite libsqlite.la sqlite.h
rm -rf .libs .deps
rm -f lemon lempar.c parse.* sqlite*.tar.gz
rm -f *.lo *.la *.o sqlite@TARGET_EXEEXT@ libsqlite.la sqlite.h opcodes.*
rm -rf .libs .deps
rm -f lemon@BUILD_EXEEXT@ lempar.c parse.* sqlite*.tar.gz
rm -f $(PUBLISH)
rm -f *.da *.bb *.bbg gmon.out
rm -f testfixture test.db
rm -f testfixture@TARGET_EXEEXT@ test.db
rm -rf doc
rm -f sqlite.dll sqlite.lib
#
# Windows section; all this funky .dll stuff ;-)
#
dll: sqlite.dll
REAL_LIBOBJ = $(LIBOBJ:%.lo=.libs/%.o)
sqlite.dll: $(LIBOBJ) $(TOP)/sqlite.def
dllwrap --dllname sqlite.dll --def $(TOP)/sqlite.def $(REAL_LIBOBJ)
strip sqlite.dll
#target for dll import libraries
implib: sqlite.lib
#make Borland C++ and/or Microsoft VC import library for the dll
# ignore any errors (usually due to missing programs)
sqlite.lib: sqlite.dll
-implib -a sqlite.lib sqlite.dll
-lib /machine:i386 /def:$(TOP)/sqlite.def
distclean: clean
rm -f config.log config.status libtool Makefile config.h
+112
View File
@@ -0,0 +1,112 @@
#!/usr/make
#
# Makefile for SQLITE
#
# This is a template makefile for SQLite. Most people prefer to
# use the autoconf generated "configure" script to generate the
# makefile automatically. But that does not work for everybody
# and in every situation. If you are having problems with the
# "configure" script, you might want to try this makefile as an
# alternative. Create a copy of this file, edit the parameters
# below and type "make".
#
#### The toplevel directory of the source tree. This is the directory
# that contains this "Makefile.in" and the "configure.in" script.
#
TOP = ../sqlite
#### C Compiler and options for use in building executables that
# will run on the platform that is doing the build.
#
BCC = gcc -g -O2
#BCC = /opt/ancic/bin/c89 -0
#### If the target operating system supports the "usleep()" system
# call, then define the HAVE_USLEEP macro for all C modules.
#
#USLEEP =
USLEEP = -DHAVE_USLEEP=1
#### If you want the SQLite library to be safe for use within a
# multi-threaded program, then define the following macro
# appropriately:
#
#THREADSAFE = -DTHREADSAFE=1
THREADSAFE = -DTHREADSAFE=0
#### Specify any extra linker options needed to make the library
# thread safe
#
#THREADLIB = -lpthread
THREADLIB =
#### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1
# to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all
# malloc()s and free()s in order to track down memory leaks.
#
# SQLite uses some expensive assert() statements in the inner loop.
# You can make the library go almost twice as fast if you compile
# with -DNDEBUG=1
#
#OPTS = -DMEMORY_DEBUG=2
#OPTS = -DMEMORY_DEBUG=1
#OPTS =
OPTS = -DNDEBUG=1
#### The suffix to add to executable files. ".exe" for windows.
# Nothing for unix.
#
#EXE = .exe
EXE =
#### C Compile and options for use in building executables that
# will run on the target platform. This is usually the same
# as BCC, unless you are cross-compiling.
#
TCC = gcc -O6
#TCC = gcc -g -O0 -Wall
#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6
#TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive
#### Tools used to build a static library.
#
AR = ar cr
#AR = /opt/mingw/bin/i386-mingw32-ar cr
RANLIB = ranlib
#RANLIB = /opt/mingw/bin/i386-mingw32-ranlib
#### Extra compiler options needed for programs that use the TCL library.
#
#TCL_FLAGS =
#TCL_FLAGS = -DSTATIC_BUILD=1
TCL_FLAGS = -I/home/drh/tcltk/8.4linux
#TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1
#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
#### Linker options needed to link against the TCL library.
#
#LIBTCL = -ltcl -lm -ldl
LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
#LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt
#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
#### Compiler options needed for programs that use the readline() library.
#
#READLINE_FLAGS =
READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
#### Linker options needed by programs using readline() must link against.
#
#LIBREADLINE =
LIBREADLINE = -static -lreadline -ltermcap
#### Should the database engine assume text is coded as UTF-8 or iso8859?
#
# ENCODING = UTF8
ENCODING = ISO8859
# You should not have to change anything below this line
###############################################################################
include $(TOP)/main.mk
-368
View File
@@ -1,368 +0,0 @@
#!/usr/make
#
# Makefile for SQLITE
#
# This is a template makefile for SQLite. Most people prefer to
# use the autoconf generated "configure" script to generate the
# makefile automatically. But that does not work for everybody
# and in every situation. If you are having problems with the
# "configure" script, you might want to try this makefile as an
# alternative. Create a copy of this file, edit the parameters
# below and type "make".
#
#### The toplevel directory of the source tree. This is the directory
# that contains this "Makefile.in" and the "configure.in" script.
#
TOP = ../sqlite
#### C Compiler and options for use in building executables that
# will run on the platform that is doing the build.
#
BCC = gcc -g -O2
#BCC = /opt/ancic/bin/c89 -0
#### If the target operating system supports the "usleep()" system
# call, then define the HAVE_USLEEP macro for all C modules.
#
#USLEEP =
USLEEP = -DHAVE_USLEEP=1
#### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1
# to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all
# malloc()s and free()s in order to track down memory leaks.
#
# SQLite uses some expensive assert() statements in the inner loop.
# You can make the library go almost twice as fast if you compile
# with -DNDEBUG=1
#
#OPTS = -DMEMORY_DEBUG=2
#OPTS = -DMEMORY_DEBUG=1
#OPTS =
OPTS = -DNDEBUG=1
#### Compiler flags that change according to the operating system.
#
#OSFLAGS = -DOS_UNIX=0 -DOS_WIN=1
OSFLAGS = -DOS_UNIX=1 -DOS_WIN=0
#### The suffix to add to executable files. ".exe" for windows.
# Nothing for unix.
#
#EXE = .exe
EXE =
#### C Compile and options for use in building executables that
# will run on the target platform. This is usually the same
# as BCC, unless you are cross-compiling.
#
TCC = gcc -O6
#TCC = gcc -g -O0 -Wall
#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6
#TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive
#### Tools used to build a static library.
#
AR = ar cr
#AR = /opt/mingw/bin/i386-mingw32-ar cr
RANLIB = ranlib
#RANLIB = /opt/mingw/bin/i386-mingw32-ranlib
#### Extra compiler options needed for programs that use the TCL library.
#
#TCL_FLAGS =
#TCL_FLAGS = -DSTATIC_BUILD=1
TCL_FLAGS = -I/home/drh/tcltk/8.4linux
#TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1
#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
#### Linker options needed to link against the TCL library.
#
#LIBTCL = -ltcl -lm -ldl
LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
#LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt
#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
#### Compiler options needed for programs that use the readline() library.
#
#READLINE_FLAGS =
READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
#### Linker options needed by programs using readline() must link against.
#
#LIBREADLINE =
LIBREADLINE = -lreadline
#### Should the database engine assume text is coded as UTF-8 or iso8859?
#
# ENCODING = UTF8
ENCODING = ISO8859
# You should not have to change anything below this line
###############################################################################
# This is how we compile
#
TCCX = $(TCC) $(OPTS) $(OSFLAGS) $(USLEEP) -I. -I$(TOP)/src
# Object files for the SQLite library.
#
LIBOBJ = btree.o build.o delete.o expr.o hash.o insert.o \
main.o os.o pager.o parse.o printf.o random.o select.o table.o \
tokenize.o update.o util.o vdbe.o where.o tclsqlite.o
# All of the source code files.
#
SRC = \
$(TOP)/src/btree.c \
$(TOP)/src/btree.h \
$(TOP)/src/build.c \
$(TOP)/src/delete.c \
$(TOP)/src/expr.c \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
$(TOP)/src/insert.c \
$(TOP)/src/main.c \
$(TOP)/src/os.c \
$(TOP)/src/pager.c \
$(TOP)/src/pager.h \
$(TOP)/src/parse.y \
$(TOP)/src/printf.c \
$(TOP)/src/random.c \
$(TOP)/src/select.c \
$(TOP)/src/shell.c \
$(TOP)/src/sqlite.h.in \
$(TOP)/src/sqliteInt.h \
$(TOP)/src/table.c \
$(TOP)/src/tclsqlite.c \
$(TOP)/src/tokenize.c \
$(TOP)/src/update.c \
$(TOP)/src/util.c \
$(TOP)/src/vdbe.c \
$(TOP)/src/vdbe.h \
$(TOP)/src/where.c
# Source code to the test files.
#
TESTSRC = \
$(TOP)/src/btree.c \
$(TOP)/src/os.c \
$(TOP)/src/pager.c \
$(TOP)/src/test1.c \
$(TOP)/src/test2.c \
$(TOP)/src/test3.c \
$(TOP)/src/md5.c
# Header files used by all library source files.
#
HDR = \
sqlite.h \
$(TOP)/src/btree.h \
$(TOP)/src/hash.h \
$(TOP)/src/os.h \
$(TOP)/src/sqliteInt.h \
$(TOP)/src/vdbe.h \
parse.h
# This is the default Makefile target. The objects listed here
# are what get build when you type just "make" with no arguments.
#
all: sqlite.h libsqlite.a sqlite$(EXE)
# Generate the file "last_change" which contains the date of change
# of the most recently modified source code file
#
last_change: $(SRC)
cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
| awk '{print $$5,$$6}' >last_change
libsqlite.a: $(LIBOBJ) tclsqlite.o
$(AR) libsqlite.a $(LIBOBJ) tclsqlite.o
$(RANLIB) libsqlite.a
sqlite$(EXE): $(TOP)/src/shell.c libsqlite.a sqlite.h
$(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
libsqlite.a $(LIBREADLINE)
# This target creates a directory named "tsrc" and fills it with
# copies of all of the C source code and header files needed to
# build on the target system. Some of the C source code and header
# files are automatically generated. This target takes care of
# all that automatic generation.
#
target_source: $(SRC) $(HDR)
rm -rf tsrc
mkdir tsrc
cp $(SRC) $(HDR) tsrc
rm tsrc/sqlite.h.in tsrc/parse.y
cp parse.c tsrc
# Rules to build the LEMON compiler generator
#
lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
$(BCC) -o lemon $(TOP)/tool/lemon.c
cp $(TOP)/tool/lempar.c .
btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
$(TCCX) -c $(TOP)/src/btree.c
build.o: $(TOP)/src/build.c $(HDR)
$(TCCX) -c $(TOP)/src/build.c
main.o: $(TOP)/src/main.c $(HDR)
$(TCCX) -c $(TOP)/src/main.c
pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
$(TCCX) -c $(TOP)/src/pager.c
os.o: $(TOP)/src/os.c $(HDR)
$(TCCX) -c $(TOP)/src/os.c
parse.o: parse.c $(HDR)
$(TCCX) -c parse.c
parse.h: parse.c
parse.c: $(TOP)/src/parse.y lemon
cp $(TOP)/src/parse.y .
./lemon parse.y
sqlite.h: $(TOP)/src/sqlite.h.in
sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
-e s/--ENCODING--/$(ENCODING)/ \
$(TOP)/src/sqlite.h.in >sqlite.h
tokenize.o: $(TOP)/src/tokenize.c $(HDR)
$(TCCX) -c $(TOP)/src/tokenize.c
util.o: $(TOP)/src/util.c $(HDR)
$(TCCX) -c $(TOP)/src/util.c
vdbe.o: $(TOP)/src/vdbe.c $(HDR)
$(TCCX) -c $(TOP)/src/vdbe.c
where.o: $(TOP)/src/where.c $(HDR)
$(TCCX) -c $(TOP)/src/where.c
delete.o: $(TOP)/src/delete.c $(HDR)
$(TCCX) -c $(TOP)/src/delete.c
expr.o: $(TOP)/src/expr.c $(HDR)
$(TCCX) -c $(TOP)/src/expr.c
hash.o: $(TOP)/src/hash.c $(HDR)
$(TCCX) -c $(TOP)/src/hash.c
insert.o: $(TOP)/src/insert.c $(HDR)
$(TCCX) -c $(TOP)/src/insert.c
random.o: $(TOP)/src/random.c $(HDR)
$(TCCX) -c $(TOP)/src/random.c
select.o: $(TOP)/src/select.c $(HDR)
$(TCCX) -c $(TOP)/src/select.c
table.o: $(TOP)/src/table.c $(HDR)
$(TCCX) -c $(TOP)/src/table.c
update.o: $(TOP)/src/update.c $(HDR)
$(TCCX) -c $(TOP)/src/update.c
tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
printf.o: $(TOP)/src/printf.c $(HDR)
$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
$(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
$(TESTSRC) $(TOP)/src/tclsqlite.c \
libsqlite.a $(LIBTCL)
fulltest: testfixture$(EXE) sqlite$(EXE)
./testfixture$(EXE) $(TOP)/test/all.test
test: testfixture$(EXE) sqlite$(EXE)
./testfixture$(EXE) $(TOP)/test/quick.test
index.html: $(TOP)/www/index.tcl last_change
tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
sqlite.html: $(TOP)/www/sqlite.tcl
tclsh $(TOP)/www/sqlite.tcl >sqlite.html
c_interface.html: $(TOP)/www/c_interface.tcl
tclsh $(TOP)/www/c_interface.tcl >c_interface.html
changes.html: $(TOP)/www/changes.tcl
tclsh $(TOP)/www/changes.tcl >changes.html
lang.html: $(TOP)/www/lang.tcl
tclsh $(TOP)/www/lang.tcl >lang.html
vdbe.html: $(TOP)/www/vdbe.tcl
tclsh $(TOP)/www/vdbe.tcl >vdbe.html
arch.html: $(TOP)/www/arch.tcl
tclsh $(TOP)/www/arch.tcl >arch.html
arch.png: $(TOP)/www/arch.png
cp $(TOP)/www/arch.png .
opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
crosscompile.html: $(TOP)/www/crosscompile.tcl
tclsh $(TOP)/www/crosscompile.tcl >crosscompile.html
mingw.html: $(TOP)/www/mingw.tcl
tclsh $(TOP)/www/mingw.tcl >mingw.html
tclsqlite.html: $(TOP)/www/tclsqlite.tcl
tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
speed.html: $(TOP)/www/speed.tcl
tclsh $(TOP)/www/speed.tcl >speed.html
download.html: $(TOP)/www/download.tcl
tclsh $(TOP)/www/download.tcl >download.html
# Files to be published on the website.
#
DOC = \
index.html \
sqlite.html \
changes.html \
lang.html \
opcode.html \
arch.html \
arch.png \
vdbe.html \
c_interface.html \
crosscompile.html \
mingw.html \
tclsqlite.html \
download.html \
speed.html
doc: $(DOC)
mkdir -p doc
mv $(DOC) doc
install: sqlite libsqlite.a sqlite.h
mv sqlite /usr/bin
mv libsqlite.a /usr/lib
mv sqlite.h /usr/include
clean:
rm -f *.o sqlite libsqlite.a sqlite.h
rm -f lemon lempar.c parse.* sqlite*.tar.gz
rm -f $(PUBLISH)
rm -f *.da *.bb *.bbg gmon.out
rm -rf tsrc
+16 -2
View File
@@ -1,6 +1,6 @@
This directory contains source code to
SQLite: An SQL Database Engine in a C Library
SQLite: An Embeddable SQL Database Engine
To compile the project, first create a directory in which to place
the build products. It is recommended, but not required, that the
@@ -18,6 +18,20 @@ For example:
The configure script uses autoconf 2.50 and libtool. If the configure
script does not work out for you, there is a generic makefile named
"Makefile.template" in the top directory of the source tree that you
"Makefile.linux-gcc" in the top directory of the source tree that you
can copy and edit to suite your needs. Comments on the generic makefile
show what changes are needed.
The linux binaries on the website are created using the generic makefile,
not the configure script. The configure script is unmaintained. (You
can volunteer to take over maintenance of the configure script, if you want!)
The windows binaries on the website are created using MinGW32 configured
as a cross-compiler running under Linux. For details, see the ./publish.sh
script at the top-level of the source tree.
Contacts:
http://www.sqlite.org/
http://www.hwaci.com/sw/sqlite/
http://groups.yahoo.com/group/sqlite/
drh@hwaci.com
+1 -1
View File
@@ -1 +1 @@
2.0.7
2.8.16
Vendored
+2289 -1534
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

+337 -222
View File
@@ -1,9 +1,9 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2001-09-04'
timestamp='2004-01-05'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -24,8 +24,9 @@ timestamp='2001-09-04'
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <bothner@cygnus.com>.
# Please send patches to <config-patches@gnu.org>.
# Originally written by Per Bothner <per@bothner.com>.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
@@ -87,30 +88,42 @@ if test $# != 0; then
exit 1
fi
trap 'exit 1' 1 2 15
dummy=dummy-$$
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# CC_FOR_BUILD -- compiler used by this script.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int dummy(){}" > $dummy.c ;
for c in cc gcc c89 ; do
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
if test $? = 0 ; then
# Portable tmp directory creation inspired by the Autoconf team.
set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
rm -f $dummy.c $dummy.o $dummy.rel ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac'
esac ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
@@ -127,29 +140,30 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# Netbsd (nbsd) targets should (where applicable) match one or
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
# Determine the machine/vendor (is the vendor relevant).
case "${UNAME_MACHINE}" in
amiga) machine=m68k-unknown ;;
arm32) machine=arm-unknown ;;
atari*) machine=m68k-atari ;;
sun3*) machine=m68k-sun ;;
mac68k) machine=m68k-apple ;;
macppc) machine=powerpc-apple ;;
hp3[0-9][05]) machine=m68k-hp ;;
ibmrt|romp-ibm) machine=romp-ibm ;;
*) machine=${UNAME_MACHINE}-unknown ;;
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE}" in
i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
case "${UNAME_MACHINE_ARCH}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null
@@ -166,75 +180,115 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
;;
esac
# The OS release
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "${UNAME_VERSION}" in
Debian*)
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
macppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvmeppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pegasos:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mipseb-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sun3:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
fi
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE="alpha" ;;
"EV4.5 (21064)")
UNAME_MACHINE="alpha" ;;
"LCA4 (21066/21068)")
UNAME_MACHINE="alpha" ;;
"EV5 (21164)")
UNAME_MACHINE="alphaev5" ;;
"EV5.6 (21164A)")
UNAME_MACHINE="alphaev56" ;;
"EV5.6 (21164PC)")
UNAME_MACHINE="alphapca56" ;;
"EV5.7 (21164PC)")
UNAME_MACHINE="alphapca57" ;;
"EV6 (21264)")
UNAME_MACHINE="alphaev6" ;;
"EV6.7 (21264A)")
UNAME_MACHINE="alphaev67" ;;
"EV6.8CB (21264C)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8AL (21264B)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8CX (21264D)")
UNAME_MACHINE="alphaev68" ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE="alphaev69" ;;
"EV7 (21364)")
UNAME_MACHINE="alphaev7" ;;
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
cat <<EOF >$dummy.s
.data
\$Lformat:
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
.text
.globl main
.align 4
.ent main
main:
.frame \$30,16,\$26,0
ldgp \$29,0(\$27)
.prologue 1
.long 0x47e03d80 # implver \$0
lda \$2,-1
.long 0x47e20c21 # amask \$2,\$1
lda \$16,\$Lformat
mov \$0,\$17
not \$1,\$18
jsr \$26,printf
ldgp \$29,0(\$26)
mov 0,\$16
jsr \$26,exit
.end main
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
case `./$dummy` in
0-0)
UNAME_MACHINE="alpha"
;;
1-0)
UNAME_MACHINE="alphaev5"
;;
1-1)
UNAME_MACHINE="alphaev56"
;;
1-101)
UNAME_MACHINE="alphapca56"
;;
2-303)
UNAME_MACHINE="alphaev6"
;;
2-307)
UNAME_MACHINE="alphaev67"
;;
2-1307)
UNAME_MACHINE="alphaev68"
;;
esac
fi
rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit 0 ;;
Alpha*:OpenVMS:*:*)
echo alpha-hp-vms
exit 0 ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
@@ -247,33 +301,18 @@ EOF
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit 0;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit 0 ;;
arc64:OpenBSD:*:*)
echo mips64el-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hkmips:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
exit 0 ;;
*:OS/390:*:*)
echo i370-ibm-openedition
exit 0 ;;
*:OS400:*:*)
echo powerpc-ibm-os400
exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
@@ -291,6 +330,13 @@ EOF
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit 0 ;;
DRS?6000:UNIX_SV:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7 && exit 0 ;;
esac ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -319,7 +365,7 @@ EOF
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
@@ -333,12 +379,6 @@ EOF
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
sparc*:NetBSD:*)
echo `uname -p`-unknown-netbsd${UNAME_RELEASE}
exit 0 ;;
atari*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
@@ -365,18 +405,6 @@ EOF
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;;
sun3*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
@@ -415,15 +443,20 @@ EOF
exit (-1);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy \
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c \
&& $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& exit 0
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit 0 ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
@@ -496,8 +529,7 @@ EOF
exit(0);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
@@ -506,7 +538,7 @@ EOF
fi
exit 0 ;;
*:AIX:*:[45])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
@@ -546,10 +578,8 @@ EOF
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
case "${HPUX_REV}" in
11.[0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
@@ -558,13 +588,13 @@ EOF
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
fi ;;
esac
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include <stdlib.h>
@@ -597,11 +627,21 @@ EOF
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
rm -f $dummy.c $dummy
fi ;;
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
# avoid double evaluation of $set_cc_for_build
test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
then
HP_ARCH="hppa2.0w"
else
HP_ARCH="hppa64"
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
ia64:HP-UX:*:*)
@@ -635,8 +675,7 @@ EOF
exit (0);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -664,9 +703,6 @@ EOF
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
hppa*:OpenBSD:*:*)
echo hppa-unknown-openbsd
exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
@@ -685,9 +721,6 @@ EOF
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit 0 ;;
CRAY*X-MP:*:*:*)
echo xmp-cray-unicos
exit 0 ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
@@ -700,26 +733,25 @@ EOF
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3D:*:*:*)
echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
*:UNICOS/mp:*:*)
echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@@ -731,10 +763,21 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
# Determine whether the default compiler uses glibc.
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#if __GLIBC__ >= 2
LIBC=gnu
#else
LIBC=
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
# GNU/KFreeBSD systems have a "k" prefix to indicate we are using
# FreeBSD's kernel, but not the complete OS.
case ${LIBC} in gnu) kernel_only='k' ;; esac
echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -745,11 +788,17 @@ EOF
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit 0 ;;
x86:Interix*:[34]*)
echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
exit 0 ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit 0 ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i386-pc-interix
echo i586-pc-interix
exit 0 ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
@@ -761,25 +810,65 @@ EOF
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
exit 0 ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit 0 ;;
arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
exit 0 ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
mips:Linux:*:*)
case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in
big) echo mips-unknown-linux-gnu && exit 0 ;;
little) echo mipsel-unknown-linux-gnu && exit 0 ;;
esac
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips
#undef mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
;;
mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips64
#undef mips64el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mips64el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips64
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
@@ -815,6 +904,9 @@ EOF
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit 0 ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
@@ -828,7 +920,8 @@ EOF
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
ld_supported_targets=`cd /; ld --help 2>&1 \
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
@@ -840,7 +933,7 @@ EOF
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0 ;;
exit 0 ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0 ;;
@@ -852,32 +945,31 @@ EOF
esac
# Determine whether the default compiler is a.out or elf
eval $set_cc_for_build
cat >$dummy.c <<EOF
#include <features.h>
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
printf ("%s-pc-linux-gnu\n", argv[1]);
# else
printf ("%s-pc-linux-gnulibc1\n", argv[1]);
# endif
# else
printf ("%s-pc-linux-gnulibc1\n", argv[1]);
# endif
#else
printf ("%s-pc-linux-gnuaout\n", argv[1]);
#endif
return 0;
}
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#ifdef __INTEL_COMPILER
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
;;
i*86:DYNIX/ptx:4*:*)
@@ -894,6 +986,26 @@ EOF
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit 0 ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit 0 ;;
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
@@ -915,22 +1027,19 @@ EOF
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
@@ -954,9 +1063,15 @@ EOF
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit 0 ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -973,9 +1088,6 @@ EOF
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
@@ -1047,6 +1159,9 @@ EOF
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit 0 ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit 0 ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
@@ -1054,18 +1169,24 @@ EOF
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:Darwin:*:*)
echo `uname -p`-apple-darwin${UNAME_RELEASE}
case `uname -p` in
*86) UNAME_PROCESSOR=i686 ;;
powerpc) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit 0 ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
if test "${UNAME_MACHINE}" = "x86pc"; then
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo `uname -p`-${UNAME_MACHINE}-nto-qnx
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit 0 ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit 0 ;;
NSR-[KW]:NONSTOP_KERNEL:*:*)
NSR-?:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
*:NonStop-UX:*:*)
@@ -1088,11 +1209,6 @@ EOF
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit 0 ;;
@@ -1111,11 +1227,11 @@ EOF
*:ITS:*:*)
echo pdp10-unknown-its
exit 0 ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
exit 0 ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
*:DRAGONFLY:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE}
exit 0 ;;
esac
@@ -1237,8 +1353,7 @@ main ()
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
# Apollos put the system type in the environment.
-171
View File
@@ -1,171 +0,0 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.52. Invocation command line was
$ ./configure --disable-static
## ---------- ##
## Platform. ##
## ---------- ##
hostname = alice
uname -m = i686
uname -r = 2.4.7
uname -s = Linux
uname -v = #1 Sun Aug 5 19:04:40 CEST 2001
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = i686
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH = /home/andy/bin:/usr/local/games:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
## ------------ ##
## Core tests. ##
## ------------ ##
configure:1105: PATH=".;."; conftest.sh
./configure: conftest.sh: command not found
configure:1108: $? = 127
configure:1236: checking build system type
configure:1254: result: i686-pc-linux-gnu
## ----------------- ##
## Cache variables. ##
## ----------------- ##
ac_cv_build=i686-pc-linux-gnu
ac_cv_build_alias=i686-pc-linux-gnu
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_CXXCPP_set=
ac_cv_env_CXXCPP_value=
ac_cv_env_CXXFLAGS_set=
ac_cv_env_CXXFLAGS_value=
ac_cv_env_CXX_set=
ac_cv_env_CXX_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
configure: caught signal 2
configure: exit 1
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by config.status 2.52, executed with
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
> ./config.status
on alice
config.status:14086: creating Makefile
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by config.status 2.52, executed with
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
> ./config.status
on alice
config.status:14086: creating Makefile
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by config.status 2.52, executed with
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
> ./config.status
on alice
config.status:14086: creating Makefile
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by config.status 2.52, executed with
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
> ./config.status
on alice
config.status:14086: creating Makefile
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by config.status 2.52, executed with
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
> ./config.status
on alice
config.status:14086: creating Makefile
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by config.status 2.52, executed with
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
> ./config.status
on alice
config.status:14086: creating Makefile
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by config.status 2.52, executed with
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
> ./config.status
on alice
config.status:14086: creating Makefile
-476
View File
@@ -1,476 +0,0 @@
#! /bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
SHELL=${CONFIG_SHELL-/bin/sh}
ac_cs_invocation="$0 $@"
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
# Name of the executable.
as_me=`echo "$0" |sed 's,.*[\\/],,'`
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
echo >conf$$.file
if ln -s conf$$.file conf$$ 2>/dev/null; then
# We could just check for DJGPP; but this test a) works b) is more generic
# and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
if test -f conf$$.exe; then
# Don't use ln at all; we don't have any links
as_ln_s='cp -p'
else
as_ln_s='ln -s'
fi
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.file
as_executable_p="test -f"
# Support unset when possible.
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# NLS nuisances.
$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
# IFS
# We need space, tab and new line, in precisely that order.
as_nl='
'
IFS=" $as_nl"
# CDPATH.
$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
exec 6>&1
config_files=" Makefile"
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.
Usage: $0 [OPTIONS] [FILE]...
-h, --help print this help, then exit
-V, --version print version number, then exit
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
Configuration files:
$config_files
Report bugs to <bug-autoconf@gnu.org>."
ac_cs_version="\
config.status
configured by ./configure, generated by GNU Autoconf 2.52,
with options \"\"
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
srcdir=.
# If no file are specified by the user, then we need to provide default
# value. By we need to know if files were specified by the user.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "x$1" : 'x\([^=]*\)='`
ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
shift
set dummy "$ac_option" "$ac_optarg" ${1+"$@"}
shift
;;
-*);;
*) # This is not an option, so the user has probably given explicit
# arguments.
ac_need_defaults=false;;
esac
case $1 in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
echo "running /bin/sh ./configure " " --no-create --no-recursion"
exec /bin/sh ./configure --no-create --no-recursion ;;
--version | --vers* | -V )
echo "$ac_cs_version"; exit 0 ;;
--he | --h)
# Conflict between --help and --header
{ { echo "$as_me:13794: error: ambiguous option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2;}
{ (exit 1); exit 1; }; };;
--help | --hel | -h )
echo "$ac_cs_usage"; exit 0 ;;
--debug | --d* | -d )
debug=: ;;
--file | --fil | --fi | --f )
shift
CONFIG_FILES="$CONFIG_FILES $1"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
shift
CONFIG_HEADERS="$CONFIG_HEADERS $1"
ac_need_defaults=false;;
# This is an error.
-*) { { echo "$as_me:13813: error: unrecognized option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2;}
{ (exit 1); exit 1; }; } ;;
*) ac_config_targets="$ac_config_targets $1" ;;
esac
shift
done
exec 5>>config.log
cat >&5 << _ACEOF
## ----------------------- ##
## Running config.status. ##
## ----------------------- ##
This file was extended by $as_me 2.52, executed with
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
> $ac_cs_invocation
on `(hostname || uname -n) 2>/dev/null | sed 1q`
_ACEOF
for ac_config_target in $ac_config_targets
do
case "$ac_config_target" in
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) { { echo "$as_me:13849: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
fi
# Create a temporary directory, and hook for its removal unless debugging.
$debug ||
{
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
: ${TMPDIR=/tmp}
{
tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=$TMPDIR/cs$$-$RANDOM
(umask 077 && mkdir $tmp)
} ||
{
echo "$me: cannot create a temporary directory in $TMPDIR" >&2
{ (exit 1); exit 1; }
}
#
# CONFIG_FILES section.
#
# No need to generate the scripts if there are no CONFIG_FILES.
# This happens for instance when ./config.status config.h
if test -n "$CONFIG_FILES"; then
# Protect against being on the right side of a sed subst in config.status.
sed 's/,@/@@/; s/@,/@@/; s/,;t t$/@;t t/; /@;t t$/s/[\\&,]/\\&/g;
s/@@/,@/; s/@@/@,/; s/@;t t$/,;t t/' >$tmp/subs.sed <<\CEOF
s,@SHELL@,/bin/sh,;t t
s,@exec_prefix@,${prefix},;t t
s,@prefix@,/usr/local,;t t
s,@program_transform_name@,s,x,x,,;t t
s,@bindir@,${exec_prefix}/bin,;t t
s,@sbindir@,${exec_prefix}/sbin,;t t
s,@libexecdir@,${exec_prefix}/libexec,;t t
s,@datadir@,${prefix}/share,;t t
s,@sysconfdir@,${prefix}/etc,;t t
s,@sharedstatedir@,${prefix}/com,;t t
s,@localstatedir@,${prefix}/var,;t t
s,@libdir@,${exec_prefix}/lib,;t t
s,@includedir@,${prefix}/include,;t t
s,@oldincludedir@,/usr/include,;t t
s,@infodir@,${prefix}/info,;t t
s,@mandir@,${prefix}/man,;t t
s,@PACKAGE_NAME@,,;t t
s,@PACKAGE_TARNAME@,,;t t
s,@PACKAGE_VERSION@,,;t t
s,@PACKAGE_STRING@,,;t t
s,@PACKAGE_BUGREPORT@,,;t t
s,@build_alias@,,;t t
s,@host_alias@,,;t t
s,@target_alias@,,;t t
s,@ECHO_C@,,;t t
s,@ECHO_N@,-n,;t t
s,@ECHO_T@,,;t t
s,@PATH_SEPARATOR@,:,;t t
s,@DEFS@,-DHAVE_DLFCN_H=1 -DHAVE_LIBDL=1 ,;t t
s,@LIBS@,-lreadline ,;t t
s,@build@,i686-pc-linux-gnu,;t t
s,@build_cpu@,i686,;t t
s,@build_vendor@,pc,;t t
s,@build_os@,linux-gnu,;t t
s,@host@,alice,;t t
s,@host_cpu@,i686,;t t
s,@host_vendor@,pc,;t t
s,@host_os@,linux-gnu,;t t
s,@CC@,gcc,;t t
s,@CFLAGS@,-g -O2,;t t
s,@LDFLAGS@,,;t t
s,@CPPFLAGS@,,;t t
s,@ac_ct_CC@,gcc,;t t
s,@EXEEXT@,,;t t
s,@OBJEXT@,o,;t t
s,@LN_S@,ln -s,;t t
s,@ECHO@,echo,;t t
s,@RANLIB@,ranlib,;t t
s,@ac_ct_RANLIB@,ranlib,;t t
s,@STRIP@,strip,;t t
s,@ac_ct_STRIP@,strip,;t t
s,@CPP@,gcc -E,;t t
s,@CXX@,g++,;t t
s,@CXXFLAGS@,-g -O2,;t t
s,@ac_ct_CXX@,g++,;t t
s,@CXXCPP@,g++ -E,;t t
s,@LIBTOOL@,$(SHELL) $(top_builddir)/libtool,;t t
s,@program_prefix@,,;t t
s,@BUILD_CC@,gcc,;t t
s,@BUILD_CFLAGS@,-g -O2,;t t
s,@BUILD_LIBS@,,;t t
s,@TARGET_CC@,gcc,;t t
s,@TARGET_CFLAGS@,-g -O2 -DOS_UNIX=1 -DOS_WIN=0 -DHAVE_USLEEP=1,;t t
s,@TARGET_LINK@,gcc,;t t
s,@TARGET_LFLAGS@,,;t t
s,@TARGET_RANLIB@,ranlib,;t t
s,@TARGET_AR@,ar cr,;t t
s,@ENCODING@,ISO8859,;t t
s,@BUILD_EXEEXT@,,;t t
s,@OS_UNIX@,1,;t t
s,@OS_WIN@,0,;t t
s,@TARGET_EXEEXT@,,;t t
s,@TARGET_LIBS@,,;t t
s,@TARGET_TCL_LIBS@,-ltcl8.3 -ldl -lm,;t t
s,@TARGET_TCL_INC@,-I/usr/include/tcl8.3/,;t t
s,@TARGET_READLINE_LIBS@,-lreadline ,;t t
s,@TARGET_READLINE_INC@,-I/usr/include/readline,;t t
s,@TARGET_HAVE_READLINE@,1,;t t
CEOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_lines=48
ac_sed_frag=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_lines # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
else
sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
fi
if test ! -s $tmp/subs.frag; then
ac_more_lines=false
else
# The purpose of the label and of the branching condition is to
# speed up the sed processing (if there are no `@' at all, there
# is no need to browse any of the substitutions).
# These are the two extra sed commands mentioned above.
(echo ':t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
else
ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
fi
ac_sed_frag=`expr $ac_sed_frag + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_lines`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
fi # test -n "$CONFIG_FILES"
for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case $ac_file in
- | *:- | *:-:* ) # input from stdin
cat >$tmp/stdin
ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
*:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
* ) ac_file_in=$ac_file.in ;;
esac
# Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
{ case "$ac_dir" in
[\\/]* | ?:[\\/]* ) as_incr_dir=;;
*) as_incr_dir=.;;
esac
as_dummy="$ac_dir"
for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
case $as_mkdir_dir in
# Skip DOS drivespec
?:) as_incr_dir=$as_mkdir_dir ;;
*)
as_incr_dir=$as_incr_dir/$as_mkdir_dir
test -d "$as_incr_dir" || mkdir "$as_incr_dir"
;;
esac
done; }
ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
# A "../" for each directory in $ac_dir_suffix.
ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
else
ac_dir_suffix= ac_dots=
fi
case $srcdir in
.) ac_srcdir=.
if test -z "$ac_dots"; then
ac_top_srcdir=.
else
ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
fi ;;
[\\/]* | ?:[\\/]* )
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir ;;
*) # Relative path.
ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_dots$srcdir ;;
esac
if test x"$ac_file" != x-; then
{ echo "$as_me:14086: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
rm -f "$ac_file"
fi
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated automatically by config.status. */
configure_input="Generated automatically from `echo $ac_file_in |
sed 's,.*/,,'` by configure."
# First look for the input files in the build tree, otherwise in the
# src tree.
ac_file_inputs=`IFS=:
for f in $ac_file_in; do
case $f in
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
test -f "$f" || { { echo "$as_me:14104: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo $f;;
*) # Relative
if test -f "$f"; then
# Build tree
echo $f
elif test -f "$srcdir/$f"; then
# Source tree
echo $srcdir/$f
else
# /dev/null tree
{ { echo "$as_me:14117: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
esac
done` || { (exit 1); exit 1; }
sed "/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/;
s/:*\${srcdir}:*/:/;
s/:*@srcdir@:*/:/;
s/^\([^=]*=[ ]*\):*/\1/;
s/:*$//;
s/^[^=]*=[ ]*$//;
}
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s,@configure_input@,$configure_input,;t t
s,@srcdir@,$ac_srcdir,;t t
s,@top_srcdir@,$ac_top_srcdir,;t t
" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
rm -f $tmp/stdin
if test x"$ac_file" != x-; then
mv $tmp/out $ac_file
else
cat $tmp/out
rm -f $tmp/out
fi
done
{ (exit 0); exit 0; }
Vendored
+233 -107
View File
@@ -1,9 +1,9 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2001-09-07'
timestamp='2004-01-05'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -29,7 +29,8 @@ timestamp='2001-09-07'
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to <config-patches@gnu.org>.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@@ -117,7 +118,8 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*)
nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -226,32 +228,46 @@ case $basic_machine in
1750a | 580 \
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| c4x | clipper \
| d10v | d30v | dsp16xx \
| fr30 \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| m32r | m68000 | m68k | m88k | mcore \
| mips16 | mips64 | mips64el | mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el | mips64vr4300 \
| mips64vr4300el | mips64vr5000 | mips64vr5000el \
| mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
| mipsisa32 \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64vr | mips64vrel \
| mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| msp430 \
| ns16k | ns32k \
| openrisc \
| openrisc | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| s390 | s390x \
| sh | sh[34] | sh[34]eb | shbe | shle \
| sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
| stormy16 | strongarm \
| tahoe | thumb | tic80 | tron \
| v850 \
| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xscale \
| x86 | xscale | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
@@ -278,38 +294,56 @@ case $basic_machine in
580-* \
| a29k-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alphapca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armv*-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \
| bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c54x-* \
| clipper-* | cray2-* | cydra-* \
| d10v-* | d30v-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | fx80-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| m32r-* \
| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \
| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
| mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64vr-* | mips64vrel-* \
| mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| msp430-* \
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| s390-* | s390x-* \
| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \
| sparc-* | sparc64-* | sparc86x-* | sparclite-* \
| sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \
| t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
| v850-* | vax-* \
| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
| xtensa-* \
| ymp-* \
| z8k-*)
;;
@@ -343,6 +377,12 @@ case $basic_machine in
basic_machine=a29k-none
os=-bsd
;;
amd64)
basic_machine=x86_64-pc
;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
@@ -374,6 +414,10 @@ case $basic_machine in
basic_machine=ns32k-sequent
os=-dynix
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
@@ -394,16 +438,8 @@ case $basic_machine in
basic_machine=c38-convex
os=-bsd
;;
cray | ymp)
basic_machine=ymp-cray
os=-unicos
;;
cray2)
basic_machine=cray2-cray
os=-unicos
;;
[cjt]90)
basic_machine=${basic_machine}-cray
cray | j90)
basic_machine=j90-cray
os=-unicos
;;
crds | unos)
@@ -418,6 +454,14 @@ case $basic_machine in
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
@@ -598,14 +642,6 @@ case $basic_machine in
basic_machine=m68k-atari
os=-mint
;;
mipsel*-linux*)
basic_machine=mipsel-unknown
os=-linux-gnu
;;
mips*-linux*)
basic_machine=mips-unknown
os=-linux-gnu
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
@@ -620,6 +656,10 @@ case $basic_machine in
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
@@ -692,6 +732,10 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
nv1)
basic_machine=nv1-cray
os=-unicosmp
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@@ -699,6 +743,14 @@ case $basic_machine in
basic_machine=hppa1.1-oki
os=-proelf
;;
or32 | or32-*)
basic_machine=or32-unknown
os=-coff
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
@@ -721,49 +773,55 @@ case $basic_machine in
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pentium | p5 | k5 | k6 | nexgen)
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon)
pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2)
pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-*)
pentium4)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-*)
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
@@ -784,10 +842,26 @@ case $basic_machine in
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sei)
basic_machine=mips-sei
os=-seiux
;;
sequent)
basic_machine=i386-sequent
;;
@@ -795,7 +869,10 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
sparclite-wrs)
sh64)
basic_machine=sh64-unknown
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
@@ -862,22 +939,42 @@ case $basic_machine in
os=-dynix
;;
t3e)
basic_machine=t3e-cray
basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
@@ -899,8 +996,8 @@ case $basic_machine in
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
@@ -921,17 +1018,13 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
windows32)
basic_machine=i386-pc
os=-windows32-msvcrt
;;
xmp)
basic_machine=xmp-cray
os=-unicos
;;
xps | xps100)
xps | xps100)
basic_machine=xps100-honeywell
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
@@ -952,13 +1045,6 @@ case $basic_machine in
op60c)
basic_machine=hppa1.1-oki
;;
mips)
if [ x$os = x-linux-gnu ]; then
basic_machine=mips-unknown
else
basic_machine=mips-mips
fi
;;
romp)
basic_machine=romp-ibm
;;
@@ -978,13 +1064,16 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
sh3 | sh4 | sh3eb | sh4eb)
sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
cydra)
cydra)
basic_machine=cydra-cydrome
;;
orion)
@@ -999,10 +1088,6 @@ case $basic_machine in
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
c4x*)
basic_machine=c4x-none
os=-coff
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
@@ -1058,17 +1143,19 @@ case $os in
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
| -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
| -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos*)
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1080,8 +1167,10 @@ case $os in
;;
esac
;;
-nto-qnx*)
;;
-nto*)
os=-nto-qnx
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
@@ -1090,6 +1179,9 @@ case $os in
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
@@ -1102,6 +1194,9 @@ case $os in
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
@@ -1120,14 +1215,23 @@ case $os in
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-nova*)
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
os=-nextstep2
;;
-nsk*)
os=-nsk
@@ -1139,6 +1243,9 @@ case $os in
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
@@ -1166,8 +1273,14 @@ case $os in
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-none)
;;
@@ -1200,10 +1313,14 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
pdp11-*)
os=-none
;;
*-dec | vax-*)
@@ -1230,6 +1347,9 @@ case $basic_machine in
mips*-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
@@ -1293,19 +1413,19 @@ case $basic_machine in
*-next)
os=-nextstep3
;;
*-gould)
*-gould)
os=-sysv
;;
*-highlevel)
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
*-sgi)
os=-irix
;;
*-siemens)
*-siemens)
os=-sysv4
;;
*-masscomp)
@@ -1374,10 +1494,16 @@ case $basic_machine in
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-vxsim* | -vxworks*)
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
Vendored
+11199 -3927
View File
File diff suppressed because it is too large Load Diff
+77 -6
View File
@@ -138,7 +138,7 @@ AC_INIT(src/sqlite.h.in)
dnl Put the RCS revision string after AC_INIT so that it will also
dnl show in in configure.
# The following RCS revision string applies to configure.in
# $Revision: 1.1 $
# $Revision: 1.7 $
#########
# Programs needed
@@ -154,6 +154,12 @@ if test "$program_prefix" = "NONE"; then
fi
AC_SUBST(program_prefix)
if test -f VERSION; then
VERSION=`cat VERSION`
echo "Version set to $VERSION"
fi
AC_SUBST(VERSION)
#########
# Check to see if the --with-hints=FILE option is used. If there is none,
# then check for a files named "$host.hints" and ../$hosts.hints where
@@ -299,6 +305,67 @@ else
fi
AC_SUBST(ENCODING)
##########
# Do we want to support in-ram databases for ATTACH DATABASE and sqlite_open
#
AC_ARG_ENABLE(incore-db,
[ --enable-incore-db Support incore database],,enable_incore_db=yes)
AC_MSG_CHECKING([whether to support incore databases for attach and open])
if test "$enable_incore_db" = "no"; then
INMEMORYDB=0
AC_MSG_RESULT([no])
else
INMEMORYDB=1
AC_MSG_RESULT([yes])
fi
AC_SUBST(ALLOWATTACHMEM)
##########
# Do we want to support release
#
AC_ARG_ENABLE(releasemode,
[ --enable-releasemode Support libtool link to release mode],,enable_releasemode=no)
AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
if test "$enable_releasemode" = "no"; then
ALLOWRELEASE=""
AC_MSG_RESULT([no])
else
ALLOWRELEASE="-release `cat VERSION`"
AC_MSG_RESULT([yes])
fi
AC_SUBST(ALLOWRELEASE)
##########
# Do we want temporary databases in memory
#
AC_ARG_ENABLE(tempdb-in-ram,
[ --enable-tempdb-in-ram Use an in-ram database for temporary tables],,enable_tempdb_in_ram=no)
AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
case "$enable_tempdb_in_ram" in
never )
TEMP_STORE=0
AC_MSG_RESULT([never])
;;
no )
INMEMORYDB=1
TEMP_STORE=1
AC_MSG_RESULT([no])
;;
always )
INMEMORYDB=1
TEMP_STORE=3
AC_MSG_RESULT([always])
;;
* )
INMEMORYDB=1
TEMP_STORE=2
AC_MSG_RESULT([yes])
;;
esac
AC_SUBST(INMEMORYDB)
AC_SUBST(TEMP_STORE)
###########
# Lots of things are different if we are compiling for Windows using
# the CYGWIN environment. So check for that special case and handle
@@ -317,7 +384,7 @@ fi
if test "$CYGWIN" = "yes"; then
BUILD_EXEEXT=.exe
else
BUILD_EXEEXT=""
BUILD_EXEEXT=$EXEEXT
fi
if test "$cross" = "0"; then
TARGET_EXEEXT=$BUILD_EXEEXT
@@ -368,7 +435,7 @@ else
else
LIBS=""
AC_SEARCH_LIBS(Tcl_Init, dnl
tcl8.4 tcl8.3 tcl8.2 tcl8.1 tcl8.0 tcl80 tcl,,,$otherlibs)
tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,$otherlibs)
fi
TARGET_TCL_LIBS="$LIBS $otherlibs"
fi
@@ -420,7 +487,8 @@ if test "$config_TARGET_READLINE_LIBS" != ""; then
else
CC=$TARGET_CC
LIBS=""
AC_SEARCH_LIBS(readline, readline,,,)
AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap])
AC_CHECK_LIB([readline], [readline])
TARGET_READLINE_LIBS="$LIBS"
fi
AC_SUBST(TARGET_READLINE_LIBS)
@@ -441,7 +509,7 @@ else
AC_CHECK_HEADER(readline.h, [found=yes])
fi
if test "$found" = "no"; then
for dir in /usr /usr/local /usr/local/readline /usr/contrib; do
for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
AC_CHECK_FILE($dir/include/readline.h, found=yes)
if test "$found" = "yes"; then
TARGET_READLINE_INC="-I$dir/include"
@@ -474,4 +542,7 @@ AC_CHECK_FUNC(usleep, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_USLEEP=1"])
#########
# Generate the output files.
#
AC_OUTPUT(Makefile)
AC_OUTPUT([
Makefile
sqlite.pc
])
-489
View File
@@ -1,489 +0,0 @@
#
# This file describes a "configure" script that is used to build
# makefiles for a particular platform. Process this file using
# Autoconf version 1.13 in order to generate that script. All
# lines of this file up to the AC_INIT macro are ignored.
#
# The build process allows for using a cross-compiler. But the default
# action is to target the same platform that we are running on. The
# configure script needs to discover the following properties of the
# build and target systems:
#
# srcdir
#
# The is the name of the directory that contains the
# "configure" shell script. All source files are
# located relative to this directory.
#
# bindir
#
# The name of the directory where executables should be
# written by the "install" target of the makefile.
#
# program_prefix
#
# Add this prefix to the names of all executables that run
# on the target machine. Default: ""
#
# ENABLE_SHARED
#
# True if shared libraries should be generated.
#
# BUILD_CC
#
# The name of a command that is used to convert C
# source files into executables that run on the build
# platform.
#
# BUILD_CFLAGS
#
# Switches that the build compiler needs in order to construct
# command-line programs.
#
# BUILD_LIBS
#
# Libraries that the build compiler needs in order to construct
# command-line programs.
#
# BUILD_EXEEXT
#
# The filename extension for executables on the build
# platform. "" for Unix and ".exe" for Windows.
#
# TARGET_CC
#
# The name of a command that runs on the build platform
# and converts C source files into *.o files for the
# target platform. In other words, the cross-compiler.
#
# TARGET_CFLAGS
#
# Switches that the target compiler needs to turn C source files
# into *.o files. Do not include TARGET_TCL_INC in this list.
# Makefiles might add additional switches such as "-I.".
#
# TARGET_TCL_LIBS
#
# This is the library directives passed to the target linker
# that cause the executable to link against Tcl. This might
# be a switch like "-ltcl8.0" or pathnames of library file
# like "../../src/libtcl8.0.a".
#
# TARGET_TCL_INC
#
# This variables define the directory that contain header
# files for Tcl. If the compiler is able to find <tcl.h>
# on its own, then this can be blank.
#
# TARGET_READLINE_LIBS
#
# This is the library directives passed to the target linker
# that cause the executable to link against the readline library.
# This might be a switch like "-lreadline" or pathnames of library
# file like "../../src/libreadline.a".
#
# TARGET_READLINE_INC
#
# This variables define the directory that contain header
# files for the readline library. If the compiler is able
# to find <readline.h> on its own, then this can be blank.
#
# TARGET_LINK
#
# The name of the linker that combines *.o files generated
# by TARGET_CC into executables for the target platform.
#
# TARGET_LIBS
#
# Additional libraries or other switch that the target linker needs
# to build an executable on the target. Do not include
# on this list any libraries in TARGET_TCL_LIBS and
# TARGET_READLINE_LIBS, etc.
#
# TARGET_EXEEXT
#
# The filename extension for executables on the
# target platform. "" for Unix and ".exe" for windows.
#
# The generated configure script will make an attempt to guess
# at all of the above parameters. You can override any of
# the guesses by setting the environment variable named
# "config_AAAA" where "AAAA" is the name of the parameter
# described above. (Exception: srcdir cannot be set this way.)
# If you have a file that sets one or more of these environment
# variables, you can invoke configure as follows:
#
# configure --with-hints=FILE
#
# where FILE is the name of the file that sets the environment
# variables. FILE should be an absolute pathname.
#
# If you have a Tcl/Tk/BLT source distribution available, then the
# files in that distribution will be used instead of any other
# Tcl/Tk/BLT files the script might discover if you tell the configure
# script about the source tree. Use commandline options:
#
# --with-tcl=PATH --with-tk=PATH --with-blt=PATH
#
# Or set environment variables config_WITH_TCL, config_WITH_TK, or
# config_WITH_BLT.
#
# This configure.in file is easy to reuse on other projects. Just
# change the argument to AC_INIT(). And disable any features that
# you don't need (for example BLT) by erasing or commenting out
# the corresponding code.
#
AC_INIT(src/sqlite.h.in)
dnl Put the RCS revision string after AC_INIT so that it will also
dnl show in in configure.
# The following RCS revision string applies to configure.in
# $Revision: 1.11 $
#########
# Make sure we are not building in a subdirectory of the source tree.
#
changequote(<<<,>>>)
temp=`echo $srcdir | grep '[^./]'`
changequote([,])
if test "$temp" = ""; then
AC_MSG_ERROR([
**************************************************************************
** This program may not be compiled in the same directory that contains **
** the configure script or any subdirectory of that directory. Rerun **
** the configure script from a directory that is separate from the **
** source tree. **
** **
** See the README file for additional information. **
**************************************************************************])
fi
#########
# Set up an appropriate program prefix
#
if test "$program_prefix" = "NONE"; then
program_prefix=""
fi
AC_SUBST(program_prefix)
#########
# Check to see if the --with-hints=FILE option is used. If there is none,
# then check for a files named "$host.hints" and ../$hosts.hints where
# $host is the hostname of the build system. If still no hints are
# found, try looking in $system.hints and ../$system.hints where
# $system is the result of uname -s.
#
AC_ARG_WITH(hints,
[ --with-hints=FILE Read configuration options from FILE],
hints=$withval)
if test "$hints" = ""; then
host=`hostname | sed 's/\..*//'`
if test -r $host.hints; then
hints=$host.hints
else
if test -r ../$host.hints; then
hints=../$host.hints
fi
fi
fi
if test "$hints" = ""; then
sys=`uname -s`
if test -r $sys.hints; then
hints=$sys.hints
else
if test -r ../$sys.hints; then
hints=../$sys.hints
fi
fi
fi
if test "$hints" != ""; then
AC_MSG_RESULT(reading hints from $hints)
. $hints
fi
#########
# Locate a compiler for the build machine. This compiler should
# generate command-line programs that run on the build machine.
#
default_build_cflags="-g"
if test "$config_BUILD_CC" = ""; then
AC_PROG_CC
if test "$cross_compiling" = "yes"; then
AC_MSG_ERROR([unable to find a compiler for building build tools])
fi
BUILD_CC=$CC
default_build_cflags=$CFLAGS
else
BUILD_CC=$config_BUILD_CC
AC_MSG_CHECKING([host compiler])
CC=$BUILD_CC
AC_MSG_RESULT($BUILD_CC)
fi
AC_MSG_CHECKING([switches for the host compiler])
if test "$config_BUILD_CFLAGS" != ""; then
CFLAGS=$config_BUILD_CFLAGS
BUILD_CFLAGS=$config_BUILD_CFLAGS
else
BUILD_CFLAGS=$default_build_cflags
fi
AC_MSG_RESULT($BUILD_CFLAGS)
if test "$config_BUILD_LIBS" != ""; then
BUILD_LIBS=$config_BUILD_LIBS
fi
AC_SUBST(BUILD_CC)
AC_SUBST(BUILD_CFLAGS)
AC_SUBST(BUILD_LIBS)
##########
# Locate a compiler that converts C code into *.o files that run on
# the target machine.
#
AC_MSG_CHECKING([target compiler])
if test "$config_TARGET_CC" != ""; then
TARGET_CC=$config_TARGET_CC
else
TARGET_CC=$BUILD_CC
fi
AC_MSG_RESULT($TARGET_CC)
AC_MSG_CHECKING([switches on the target compiler])
if test "$config_TARGET_CFLAGS" != ""; then
TARGET_CFLAGS=$config_TARGET_CFLAGS
else
TARGET_CFLAGS=$BUILD_CFLAGS
fi
AC_MSG_RESULT($TARGET_CFLAGS)
AC_MSG_CHECKING([target linker])
if test "$config_TARGET_LINK" = ""; then
TARGET_LINK=$TARGET_CC
else
TARGET_LINK=$config_TARGET_LINK
fi
AC_MSG_RESULT($TARGET_LINK)
AC_MSG_CHECKING([switches on the target compiler])
if test "$config_TARGET_TFLAGS" != ""; then
TARGET_TFLAGS=$config_TARGET_TFLAGS
else
TARGET_TFLAGS=$BUILD_CFLAGS
fi
if test "$config_TARGET_RANLIB" != ""; then
TARGET_RANLIB=$config_TARGET_RANLIB
else
AC_PROG_RANLIB
TARGET_RANLIB=$RANLIB
fi
if test "$config_TARGET_AR" != ""; then
TARGET_AR=$config_TARGET_AR
else
TARGET_AR='ar cr'
fi
AC_MSG_RESULT($TARGET_TFLAGS)
AC_SUBST(TARGET_CC)
AC_SUBST(TARGET_CFLAGS)
AC_SUBST(TARGET_LINK)
AC_SUBST(TARGET_LFLAGS)
AC_SUBST(TARGET_RANLIB)
AC_SUBST(TARGET_AR)
# Set the $cross variable if we are cross-compiling. Make
# it 0 if we are not.
#
AC_MSG_CHECKING([if host and target compilers are the same])
if test "$BUILD_CC" = "$TARGET_CC"; then
cross=0
AC_MSG_RESULT(yes)
else
cross=1
AC_MSG_RESULT(no)
fi
##########
# Are we using UTF-8 or iso8859 encodings?
#
AC_ARG_ENABLE(utf8,
[ --enable-utf8 Use UTF-8 encodings],,enable_utf8=no)
AC_MSG_CHECKING([character encoding])
if test "$enable_utf8" = "no"; then
ENCODING=ISO8859
AC_MSG_RESULT([iso8859])
else
ENCODING=UTF8
AC_MSG_RESULT([UTF-8])
fi
AC_SUBST(ENCODING)
###########
# Lots of things are different if we are compiling for Windows using
# the CYGWIN environment. So check for that special case and handle
# things accordingly.
#
AC_MSG_CHECKING([if executables have the .exe suffix])
if test "$config_BUILD_EXEEXT" = ".exe"; then
CYGWIN=yes
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(unknown)
fi
if test "$CYGWIN" != "yes"; then
AC_CYGWIN
fi
if test "$CYGWIN" = "yes"; then
BUILD_EXEEXT=.exe
else
BUILD_EXEEXT=""
fi
if test "$cross" = "0"; then
TARGET_EXEEXT=$BUILD_EXEEXT
else
TARGET_EXEEXT=$config_TARGET_EXEEXT
fi
if test "$TARGET_EXEEXT" = ".exe"; then
OS_UNIX=0
OS_WIN=1
tclsubdir=win
else
OS_UNIX=1
OS_WIN=0
tclsubdir=unix
fi
TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=$OS_UNIX -DOS_WIN=$OS_WIN"
AC_SUBST(BUILD_EXEEXT)
AC_SUBST(OS_UNIX)
AC_SUBST(OS_WIN)
AC_SUBST(TARGET_EXEEXT)
##########
# Extract generic linker options from the environment.
#
if test "$config_TARGET_LIBS" != ""; then
TARGET_LIBS=$config_TARGET_LIBS
else
TARGET_LIBS=""
fi
AC_SUBST(TARGET_LIBS)
##########
# Figure out what C libraries are required to compile Tcl programs.
#
if test "$config_TARGET_TCL_LIBS" != ""; then
TARGET_TCL_LIBS="$config_TARGET_TCL_LIBS"
else
if test "$with_tcl" != ""; then
extra=`echo $with_tcl/$tclsubdir/libtcl8*.a`
fi
CC=$TARGET_CC
AC_CHECK_FUNC(sin, LIBS="", LIBS="-lm")
AC_CHECK_LIB(dl, dlopen)
otherlibs=$LIBS
if test "$extra" != ""; then
LIBS=$extra
else
LIBS=""
AC_SEARCH_LIBS(Tcl_Init, dnl
tcl8.4 tcl8.3 tcl8.2 tcl8.1 tcl8.0 tcl80 tcl,,,$otherlibs)
fi
TARGET_TCL_LIBS="$LIBS $otherlibs"
fi
AC_SUBST(TARGET_TCL_LIBS)
##########
# Figure out where to get the TCL header files.
#
AC_MSG_CHECKING([TCL header files])
found=no
if test "$config_TARGET_TCL_INC" != ""; then
TARGET_TCL_INC=$config_TARGET_TCL_INC
found=yes
else
if test "$with_tcl" != ""; then
TARGET_TCL_INC="-I$with_tcl/generic -I$with_tcl/$tclsubdir"
found=yes
else
TARGET_TCL_INC=""
found=no
fi
fi
if test "$found" = "yes"; then
AC_MSG_RESULT($TARGET_TCL_INC)
else
AC_MSG_RESULT(not specified: still searching...)
AC_CHECK_HEADER(tcl.h, [found=yes])
fi
if test "$found" = "no"; then
for dir in /usr/local /usr/X11 /usr/X11R6 /usr/pkg /usr/contrib /usr; do
AC_CHECK_FILE($dir/include/tcl.h, found=yes)
if test "$found" = "yes"; then
TARGET_TCL_INC="-I$dir/include"
break
fi
done
fi
if test "$found" = "no"; then
TARGET_TCL_INC="-DNO_TCL=1"
fi
AC_SUBST(TARGET_TCL_INC)
##########
# Figure out what C libraries are required to compile programs
# that use "readline()" library.
#
if test "$config_TARGET_READLINE_LIBS" != ""; then
TARGET_READLINE_LIBS="$config_TARGET_READLINE_LIBS"
else
CC=$TARGET_CC
LIBS=""
AC_SEARCH_LIBS(readline, readline,,,)
TARGET_READLINE_LIBS="$LIBS"
fi
AC_SUBST(TARGET_READLINE_LIBS)
##########
# Figure out where to get the READLINE header files.
#
AC_MSG_CHECKING([readline header files])
found=no
if test "$config_TARGET_READLINE_INC" != ""; then
TARGET_READLINE_INC=$config_TARGET_READLINE_INC
found=yes
fi
if test "$found" = "yes"; then
AC_MSG_RESULT($TARGET_READLINE_INC)
else
AC_MSG_RESULT(not specified: still searching...)
AC_CHECK_HEADER(readline.h, [found=yes])
fi
if test "$found" = "no"; then
for dir in /usr /usr/local /usr/local/readline /usr/contrib; do
AC_CHECK_FILE($dir/include/readline.h, found=yes)
if test "$found" = "yes"; then
TARGET_READLINE_INC="-I$dir/include"
break
fi
AC_CHECK_FILE($dir/include/readline/readline.h, found=yes)
if test "$found" = "yes"; then
TARGET_READLINE_INC="-I$dir/include/readline"
break
fi
done
fi
if test "$found" = "yes"; then
if test "$TARGET_READLINE_LIBS" = ""; then
TARGET_HAVE_READLINE=0
else
TARGET_HAVE_READLINE=1
fi
else
TARGET_HAVE_READLINE=0
fi
AC_SUBST(TARGET_READLINE_INC)
AC_SUBST(TARGET_HAVE_READLINE)
#########
# Figure out whether or not we have a "usleep()" function.
#
AC_CHECK_FUNC(usleep, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_USLEEP=1"])
#########
# Generate the output files.
#
AC_OUTPUT(Makefile)
-6346
View File
File diff suppressed because it is too large Load Diff
+1802 -886
View File
File diff suppressed because it is too large Load Diff
+446
View File
@@ -0,0 +1,446 @@
###############################################################################
# The following macros should be defined before this script is
# invoked:
#
# TOP The toplevel directory of the source tree. This is the
# directory that contains this "Makefile.in" and the
# "configure.in" script.
#
# BCC C Compiler and options for use in building executables that
# will run on the platform that is doing the build.
#
# USLEEP If the target operating system supports the "usleep()" system
# call, then define the HAVE_USLEEP macro for all C modules.
#
# THREADSAFE If you want the SQLite library to be safe for use within a
# multi-threaded program, then define the following macro
# appropriately:
#
# THREADLIB Specify any extra linker options needed to make the library
# thread safe
#
# OPTS Extra compiler command-line options.
#
# EXE The suffix to add to executable files. ".exe" for windows
# and "" for Unix.
#
# TCC C Compiler and options for use in building executables that
# will run on the target platform. This is usually the same
# as BCC, unless you are cross-compiling.
#
# AR Tools used to build a static library.
# RANLIB
#
# TCL_FLAGS Extra compiler options needed for programs that use the
# TCL library.
#
# LIBTCL Linker options needed to link against the TCL library.
#
# READLINE_FLAGS Compiler options needed for programs that use the
# readline() library.
#
# LIBREADLINE Linker options needed by programs using readline() must
# link against.
#
# ENCODING "UTF8" or "ISO8859"
#
# Once the macros above are defined, the rest of this make script will
# build the SQLite library and testing tools.
################################################################################
# This is how we compile
#
TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
# Object files for the SQLite library.
#
LIBOBJ = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \
expr.o func.o hash.o insert.o \
main.o opcodes.o os.o pager.o parse.o pragma.o printf.o random.o \
select.o table.o tokenize.o trigger.o update.o util.o \
vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o
# All of the source code files.
#
SRC = \
$(TOP)/src/attach.c \
$(TOP)/src/auth.c \
$(TOP)/src/btree.c \
$(TOP)/src/btree.h \
$(TOP)/src/btree_rb.c \
$(TOP)/src/build.c \
$(TOP)/src/copy.c \
$(TOP)/src/date.c \
$(TOP)/src/delete.c \
$(TOP)/src/encode.c \
$(TOP)/src/expr.c \
$(TOP)/src/func.c \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
$(TOP)/src/insert.c \
$(TOP)/src/main.c \
$(TOP)/src/os.c \
$(TOP)/src/pager.c \
$(TOP)/src/pager.h \
$(TOP)/src/parse.y \
$(TOP)/src/pragma.c \
$(TOP)/src/printf.c \
$(TOP)/src/random.c \
$(TOP)/src/select.c \
$(TOP)/src/shell.c \
$(TOP)/src/sqlite.h.in \
$(TOP)/src/sqliteInt.h \
$(TOP)/src/table.c \
$(TOP)/src/tclsqlite.c \
$(TOP)/src/tokenize.c \
$(TOP)/src/trigger.c \
$(TOP)/src/update.c \
$(TOP)/src/util.c \
$(TOP)/src/vacuum.c \
$(TOP)/src/vdbe.c \
$(TOP)/src/vdbe.h \
$(TOP)/src/vdbeaux.c \
$(TOP)/src/vdbeInt.h \
$(TOP)/src/where.c
# Source code to the test files.
#
TESTSRC = \
$(TOP)/src/btree.c \
$(TOP)/src/func.c \
$(TOP)/src/os.c \
$(TOP)/src/pager.c \
$(TOP)/src/test1.c \
$(TOP)/src/test2.c \
$(TOP)/src/test3.c \
$(TOP)/src/test4.c \
$(TOP)/src/vdbe.c \
$(TOP)/src/md5.c
# Header files used by all library source files.
#
HDR = \
sqlite.h \
$(TOP)/src/btree.h \
config.h \
$(TOP)/src/hash.h \
opcodes.h \
$(TOP)/src/os.h \
$(TOP)/src/sqliteInt.h \
$(TOP)/src/vdbe.h \
parse.h
# Header files used by the VDBE submodule
#
VDBEHDR = \
$(HDR) \
$(TOP)/src/vdbeInt.h
# This is the default Makefile target. The objects listed here
# are what get build when you type just "make" with no arguments.
#
all: sqlite.h config.h libsqlite.a sqlite$(EXE)
# Generate the file "last_change" which contains the date of change
# of the most recently modified source code file
#
last_change: $(SRC)
cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
| awk '{print $$5,$$6}' >last_change
libsqlite.a: $(LIBOBJ)
$(AR) libsqlite.a $(LIBOBJ)
$(RANLIB) libsqlite.a
sqlite$(EXE): $(TOP)/src/shell.c libsqlite.a sqlite.h
$(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
libsqlite.a $(LIBREADLINE) $(THREADLIB)
sqlite_analyzer$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC) \
$(TOP)/tool/spaceanal.tcl
sed \
-e '/^#/d' \
-e 's,\\,\\\\,g' \
-e 's,",\\",g' \
-e 's,^,",' \
-e 's,$$,\\n",' \
$(TOP)/tool/spaceanal.tcl >spaceanal_tcl.h
$(TCCX) $(TCL_FLAGS) -DTCLSH=2 -DSQLITE_TEST=1 -static -o \
sqlite_analyzer$(EXE) $(TESTSRC) $(TOP)/src/tclsqlite.c \
libsqlite.a $(LIBTCL)
# This target creates a directory named "tsrc" and fills it with
# copies of all of the C source code and header files needed to
# build on the target system. Some of the C source code and header
# files are automatically generated. This target takes care of
# all that automatic generation.
#
target_source: $(SRC) $(VDBEHDR) opcodes.c
rm -rf tsrc
mkdir tsrc
cp $(SRC) $(VDBEHDR) tsrc
rm tsrc/sqlite.h.in tsrc/parse.y
cp parse.c opcodes.c tsrc
# Rules to build the LEMON compiler generator
#
lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
$(BCC) -o lemon $(TOP)/tool/lemon.c
cp $(TOP)/tool/lempar.c .
btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
$(TCCX) -c $(TOP)/src/btree.c
btree_rb.o: $(TOP)/src/btree_rb.c $(HDR)
$(TCCX) -c $(TOP)/src/btree_rb.c
build.o: $(TOP)/src/build.c $(HDR)
$(TCCX) -c $(TOP)/src/build.c
main.o: $(TOP)/src/main.c $(HDR)
$(TCCX) -c $(TOP)/src/main.c
pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
$(TCCX) -c $(TOP)/src/pager.c
opcodes.o: opcodes.c
$(TCCX) -c opcodes.c
opcodes.c: $(TOP)/src/vdbe.c
echo '/* Automatically generated file. Do not edit */' >opcodes.c
echo 'char *sqliteOpcodeNames[] = { "???", ' >>opcodes.c
grep '^case OP_' $(TOP)/src/vdbe.c | \
sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >>opcodes.c
echo '};' >>opcodes.c
opcodes.h: $(TOP)/src/vdbe.h
echo '/* Automatically generated file. Do not edit */' >opcodes.h
grep '^case OP_' $(TOP)/src/vdbe.c | \
sed -e 's/://' | \
awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
os.o: $(TOP)/src/os.c $(HDR)
$(TCCX) -c $(TOP)/src/os.c
parse.o: parse.c $(HDR)
$(TCCX) -c parse.c
parse.h: parse.c
parse.c: $(TOP)/src/parse.y lemon
cp $(TOP)/src/parse.y .
./lemon parse.y
# The config.h file will contain a single #define that tells us how
# many bytes are in a pointer. This only works if a pointer is the
# same size on the host as it is on the target. If you are cross-compiling
# to a target with a different pointer size, you'll need to manually
# configure the config.h file.
#
config.h:
echo '#include <stdio.h>' >temp.c
echo 'int main(){printf(' >>temp.c
echo '"#define SQLITE_PTR_SZ %d",sizeof(char*));' >>temp.c
echo 'exit(0);}' >>temp.c
$(BCC) -o temp temp.c
./temp >config.h
echo >>config.h
rm -f temp.c temp
sqlite.h: $(TOP)/src/sqlite.h.in
sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
-e s/--ENCODING--/$(ENCODING)/ \
$(TOP)/src/sqlite.h.in >sqlite.h
tokenize.o: $(TOP)/src/tokenize.c $(HDR)
$(TCCX) -c $(TOP)/src/tokenize.c
trigger.o: $(TOP)/src/trigger.c $(HDR)
$(TCCX) -c $(TOP)/src/trigger.c
util.o: $(TOP)/src/util.c $(HDR)
$(TCCX) -c $(TOP)/src/util.c
vacuum.o: $(TOP)/src/vacuum.c $(HDR)
$(TCCX) -c $(TOP)/src/vacuum.c
vdbe.o: $(TOP)/src/vdbe.c $(VDBEHDR)
$(TCCX) -c $(TOP)/src/vdbe.c
vdbeaux.o: $(TOP)/src/vdbeaux.c $(VDBEHDR)
$(TCCX) -c $(TOP)/src/vdbeaux.c
where.o: $(TOP)/src/where.c $(HDR)
$(TCCX) -c $(TOP)/src/where.c
copy.o: $(TOP)/src/copy.c $(HDR)
$(TCCX) -c $(TOP)/src/copy.c
date.o: $(TOP)/src/date.c $(HDR)
$(TCCX) -c $(TOP)/src/date.c
delete.o: $(TOP)/src/delete.c $(HDR)
$(TCCX) -c $(TOP)/src/delete.c
encode.o: $(TOP)/src/encode.c
$(TCCX) -c $(TOP)/src/encode.c
expr.o: $(TOP)/src/expr.c $(HDR)
$(TCCX) -c $(TOP)/src/expr.c
func.o: $(TOP)/src/func.c $(HDR)
$(TCCX) -c $(TOP)/src/func.c
hash.o: $(TOP)/src/hash.c $(HDR)
$(TCCX) -c $(TOP)/src/hash.c
insert.o: $(TOP)/src/insert.c $(HDR)
$(TCCX) -c $(TOP)/src/insert.c
random.o: $(TOP)/src/random.c $(HDR)
$(TCCX) -c $(TOP)/src/random.c
select.o: $(TOP)/src/select.c $(HDR)
$(TCCX) -c $(TOP)/src/select.c
table.o: $(TOP)/src/table.c $(HDR)
$(TCCX) -c $(TOP)/src/table.c
update.o: $(TOP)/src/update.c $(HDR)
$(TCCX) -c $(TOP)/src/update.c
tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
pragma.o: $(TOP)/src/pragma.c $(HDR)
$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/pragma.c
printf.o: $(TOP)/src/printf.c $(HDR)
$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
attach.o: $(TOP)/src/attach.c $(HDR)
$(TCCX) -c $(TOP)/src/attach.c
auth.o: $(TOP)/src/auth.c $(HDR)
$(TCCX) -c $(TOP)/src/auth.c
tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
$(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
$(TESTSRC) $(TOP)/src/tclsqlite.c \
libsqlite.a $(LIBTCL) $(THREADLIB)
fulltest: testfixture$(EXE) sqlite$(EXE)
./testfixture$(EXE) $(TOP)/test/all.test
test: testfixture$(EXE) sqlite$(EXE)
./testfixture$(EXE) $(TOP)/test/quick.test
index.html: $(TOP)/www/index.tcl last_change
tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
sqlite.html: $(TOP)/www/sqlite.tcl
tclsh $(TOP)/www/sqlite.tcl >sqlite.html
c_interface.html: $(TOP)/www/c_interface.tcl
tclsh $(TOP)/www/c_interface.tcl >c_interface.html
changes.html: $(TOP)/www/changes.tcl
tclsh $(TOP)/www/changes.tcl >changes.html
lang.html: $(TOP)/www/lang.tcl
tclsh $(TOP)/www/lang.tcl >lang.html
vdbe.html: $(TOP)/www/vdbe.tcl
tclsh $(TOP)/www/vdbe.tcl >vdbe.html
arch.html: $(TOP)/www/arch.tcl
tclsh $(TOP)/www/arch.tcl >arch.html
arch.png: $(TOP)/www/arch.png
cp $(TOP)/www/arch.png .
opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
mingw.html: $(TOP)/www/mingw.tcl
tclsh $(TOP)/www/mingw.tcl >mingw.html
tclsqlite.html: $(TOP)/www/tclsqlite.tcl
tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
speed.html: $(TOP)/www/speed.tcl
tclsh $(TOP)/www/speed.tcl >speed.html
faq.html: $(TOP)/www/faq.tcl
tclsh $(TOP)/www/faq.tcl >faq.html
formatchng.html: $(TOP)/www/formatchng.tcl
tclsh $(TOP)/www/formatchng.tcl >formatchng.html
conflict.html: $(TOP)/www/conflict.tcl
tclsh $(TOP)/www/conflict.tcl >conflict.html
download.html: $(TOP)/www/download.tcl
tclsh $(TOP)/www/download.tcl >download.html
omitted.html: $(TOP)/www/omitted.tcl
tclsh $(TOP)/www/omitted.tcl >omitted.html
datatypes.html: $(TOP)/www/datatypes.tcl
tclsh $(TOP)/www/datatypes.tcl >datatypes.html
quickstart.html: $(TOP)/www/quickstart.tcl
tclsh $(TOP)/www/quickstart.tcl >quickstart.html
fileformat.html: $(TOP)/www/fileformat.tcl
tclsh $(TOP)/www/fileformat.tcl >fileformat.html
nulls.html: $(TOP)/www/nulls.tcl
tclsh $(TOP)/www/nulls.tcl >nulls.html
# Files to be published on the website.
#
DOC = \
index.html \
sqlite.html \
changes.html \
lang.html \
opcode.html \
arch.html \
arch.png \
vdbe.html \
c_interface.html \
mingw.html \
tclsqlite.html \
download.html \
speed.html \
faq.html \
formatchng.html \
conflict.html \
omitted.html \
datatypes.html \
quickstart.html \
fileformat.html \
nulls.html
doc: $(DOC)
mkdir -p doc
mv $(DOC) doc
install: sqlite libsqlite.a sqlite.h
mv sqlite /usr/bin
mv libsqlite.a /usr/lib
mv sqlite.h /usr/include
clean:
rm -f *.o sqlite libsqlite.a sqlite.h opcodes.*
rm -f lemon lempar.c parse.* sqlite*.tar.gz
rm -f $(PUBLISH)
rm -f *.da *.bb *.bbg gmon.out
rm -rf tsrc
+187 -110
View File
@@ -1,120 +1,197 @@
C Version\s2.0.7\s(CVS\s463)
D 2001-10-22T03:00:00
F Makefile.in 6801df952cb1df64aa32e4de85fed24511d28efd
F Makefile.template 1fdb891f14083ee0b63cf7282f91529634438e7a
F README 93d2977cc5c6595c448de16bdefc312b9d401533
F VERSION 46489bc13fe8b494327fecb3c9a05f4db2e284b3
F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d
F config.guess f38b1e93d1e0fa6f5a6913e9e7b12774b9232588
F config.log 6a73d03433669b10a3f0c221198c3f26b9413914
F config.status eea88b8fe8b8b82d69b886382061efa9b77131cc
F config.sub f14b07d544ca26b5d698259045136b783e18fc7f
F configure 9303d975dbd577fbe61e615045ddc02015b59fb5 x
F configure.ac 38e2e5594cab99eb3a753b0614fcc36f4ddbbb48
F configure.in 0000c0d62beb47cae1d2d81a197c7fe6efd56a45
C Version\s2.8.16\s(CVS\s2336)
D 2005-02-15T13:07:51
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F VERSION e100aeefc5ef366c7dbecc865e47faa2047802ca
F aclocal.m4 7daea4c35e88de30d5a3f6f7a2ab99720e803bbd
F art/SQLite.eps 9b43cc99cfd2be687d386faea6862ea68d6a72b2
F art/SQLite.gif 1bbb94484963f1382e27e1c5e86dd0c1061eba2b
F config.guess 2103e94b15dc57112d7b9ee152c6fac5288895b4
F config.sub 9bf686ec001ae7bc53f5b3563c90c62d4c6d48be
F configure 6a156e79aaddba2e0e6816972d99989f48cc1699 x
F configure.ac 684143ce9ee7bafc4291d0e17f2dfdc70514d1d6
F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538
F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F libtool c56e618713c9510a103bda6b95f3ea3900dcacd6
F ltmain.sh e9ed72eb1d690f447c13945eaf69e28af531eda1
F publish.sh badcd69b8e3a8bc69b162c4c9d7c209b2a0b119e
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
F src/btree.c 89380aea55bd0d5c756d92ec9bee756203f63a6b
F src/btree.h 57d653ef5137b91f2a068aaf71a2905468dd2cb7
F src/build.c 8857c16751a5e9c5ee845e1b3cf2da78935c8cb3
F src/delete.c 6fe2191c49c4a31336e2fac11b3ad665ddcd4246
F src/expr.c 2dd0252ced345c1e64db015b94dc6b5d7a57eef3
F src/hash.c d0110e6da70a5962e21575fccf8206f7d9d75e00
F src/hash.h a5f5b3ce2d086a172c5879b0b06a27a82eac9fac
F src/insert.c b65c1d4b848e45d41e9dcccd2b226ca335de67b6
F src/main.c 47922699c75e24ffec071cdf300405436e5bb16e
F src/md5.c 52f677bfc590e09f71d07d7e327bd59da738d07c
F src/os.c 66b677479eae37e30bdfbe32deb0fe6a2efca983
F src/os.h bed702c9e3b768bc3cb1b12c90b83d099c1546be
F src/pager.c 0bd0b4b693edb43c72774e3e749d8667e2ae7094
F src/pager.h a0d4c5ae271914aa07b62aee0707997d6932b6ca
F src/parse.y 148e4cd134d3cbd816dcb0df50e49e498faa6ba4
F src/printf.c 167fbfb192b4dce48154398f22dbc614e9f5d088
F src/random.c 2a9cc2c9716d14815fd4c2accf89d87a1143e46b
F src/select.c d14511afacf788bf4a0c517011c2c53038539388
F src/shell.c 71597951753b56a97fea1c7a30908f31e635c00c
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in f2c40c869ff40ad3e60d8a3b1f72777fa28b32fc
F src/sqliteInt.h 9a18aebf42a805ba02f55eba2239beabe35f02b3
F src/table.c be9c7bf883c731c6719f0fcc188ea2bac8ae7122
F src/tclsqlite.c 4896e078495bf868742f5394dcf01c5efe5bea02
F src/test1.c e4b31f62ea71963cbae44338acf477a04fc8fc49
F src/test2.c e9f99aa5ee73872819259d6612c11e55e1644321
F src/test3.c 4a0d7b882fdae731dbb759f512ad867122452f96
F src/tokenize.c 8f4c2b5e7fb471ba194979fb4dd5f947402fd792
F src/update.c c916182c6bfbc8a6f20c24920c4560fece6c9569
F src/util.c aa4d2de60cb2445239b71c79c3a8c0b7c0d3336a
F src/vdbe.c aa28392b908ef8ee338e77af49ce2903b85f7b22
F src/vdbe.h f8407fd6b644bc001b1e7c65460c9962f6a15f6b
F src/where.c 22fe910c7c8e2736eb37e9861343e90c0b513c86
F test/all.test 2a51e5395ac7c2c539689b123b9782a05e3837fe
F test/bigrow.test a35f2de9948b24e427fb292c35947795efe182d0
F test/btree.test 47952c7a0c22660566264c68c0664592b7da85ce
F test/btree2.test 08e9485619265cbaf5d11bd71f357cdc26bb87e0
F test/copy.test 768e6f1701a07d08090e1ca7f7dcce0a7a72b43e
F test/delete.test c904a62129fe102b314a96111a8417f10249e4d8
F test/expr.test b4171c84b767f7b7e94dbce4824ba8e981a1c72f
F test/func.test 9012f7fc5369422c890e93549aa61d762e0c8bb3
F test/in.test 9323681388be301dc73f370b4cd62c5a33f79d1e
F test/index.test 6076f29d09a4f26a2efa38b03b8cc338b8662f0e
F test/insert.test a5c122aa726f1cef6f07d6767e8fd6f220994c11
F test/insert2.test d6901ca931e308fea7fca8c95ebe7dc957cc9fc2
F test/ioerr.test 57d9bffaca18b34f9e976f786eadc2591d6efc6a
F test/lock.test 19593689260c419efe7ced55b1418653a4b7bcd1
F test/main.test 1626345b5f630c5398eede500d9354813b76b0fd
F test/malloc.test 70fdd0812e2a57eb746aaf015350f58bb8eee0b1
F test/misc1.test 50a5ca3481fc1f3cd6b978bcd6ed04c06f26a1e6
F test/pager.test 59bbc4e3d489529ed33db6e15595789e51056077
F test/printf.test 3cb415073754cb8ff076f26173143c3cd293a9da
F test/quick.test 6f023c7a73fc413e6d65b7a1879c79764038dc05
F test/quote.test 286db944717afa9a9bf829dd85e59185c65d5435
F test/rowid.test 427bfbbe9684fe7a2f851aa05badaae6d4972ce8
F test/select1.test 75af194669ff9f4fe42c6fd070d9ec3b268354bb
F test/select2.test f91c903e2bab0e9d45274855a981eebf846d5e32
F test/select3.test 5e1fe8e5a4e63fb2827ab3b89527e0fd4ae35259
F test/select4.test 29a2ffb187f3d8b6ca42a0a6b619e9cabe12e228
F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826
F main.mk 7dfbd08ac90b15debd84ebd2606f0dbab739a4ab
F publish.sh 5b6a0545bcea61ec30fec7aafd6746fd6a669939
F spec.template a38492f1c1dd349fc24cb0565e08afc53045304b
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
F src/attach.c 026702566f941bf2bb158a0aaa86bfeb65910aa6
F src/auth.c 8d678ab13950801e10fd09781a7c1ed3bfeffb7c
F src/btree.c 08a05b925b348c05d79b9b062b79e50d565678de
F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f
F src/btree_rb.c af40501eedd7b673ffd5e02f3a4702c76596d64a
F src/build.c ee7905531ed592bd68b484f0821fc3cd007e1576
F src/copy.c 750e13828c3e4a293123e36aaa7cf0f22466248a
F src/date.c 54befeafe3e2af041c22bcc49fd79f0396b75c4d
F src/delete.c 82001c74882319f94dab5f6b92a27311b31092ae
F src/encode.c fc8c51f0b61bc803ccdec092e130bebe762b0a2f
F src/expr.c 6bb3961c0391f2efe788fcfde3c2ff2ff283d5a8
F src/func.c ab5c57f0ebb975e66cc13f09141247c2f7a2c293
F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e
F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7
F src/insert.c c0485ee2d1b99322894e2d1e0b576fd05ed75616
F src/main.c 7802ab78b2f2e66750be2192b2c1334c99bc10a5
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
F src/os.c 989942fc5d209128d1f371f29447914ec98006ef
F src/os.h 250a3789be609adfee5c5aa20137ce8683276f24
F src/pager.c b246986e5ba31b15aa3cf91d3b9ec2e608aceb8e
F src/pager.h 82332878799280145639a48d88cdb4058925e3f6
F src/parse.y 023720cb8c3bef74e51738bca78335d0dc6d2cfd
F src/pragma.c f9c157b0591419d2d3407dac90222020d2a6d822
F src/printf.c 378ec63d9303993eef24814a56a9fc7260aacbea
F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2
F src/select.c a1c18cab14b49f28ed7629a53fe02adeb13083d2
F src/shell.c 920af040d3a33ea8919c82cee45b424ad841cee0
F src/sqlite.h.in b1414cc6686c77917024d8196efa4531e76cf194
F src/sqliteInt.h 3e9203f16d12baf3a364fae9d64903d813651abd
F src/table.c eea34544be947e4939ba9e46391d5da998f90b84
F src/tclsqlite.c 2daaaa41378fbaf167905363197e1d44464b6eb6
F src/test1.c 4ae20bc125b1a7d7824cccca55d538d81f0b4949
F src/test2.c 75819b0f2c63c6a0fd6995445881f2eb94036996
F src/test3.c 30985ebdfaf3ee1462a9b0652d3efbdc8d9798f5
F src/test4.c 6e3e31acfaf21d66420fc35fda5b17dc0000cc8d
F src/tokenize.c 6676b946fd8825b67ab52140af4fdc57a70bda48
F src/trigger.c a9927b57c865b6f3df3fb5e40c9824d722660ded
F src/update.c bd391079138e67d09c9af34528ca4137c29242d1
F src/util.c 48f1e99803e924433477a7ccbdab35663acb621d
F src/vacuum.c 12de02a8dec2b3f8d30ea496b66a0f989322a2c4
F src/vdbe.c f78a26f5bbd647fac84c26e0a54b85361613a004
F src/vdbe.h ac987945e4dd6f987bca534c6005899f089fc270
F src/vdbeInt.h b40ff02ce39fd076e6ff3369e19c1bbfe1986682
F src/vdbeaux.c 14ff0eb6ed9d5998f927433c91b0a3d13d81f4f6
F src/where.c ce4968e37382808ec76a47385384ee21ad9e979e
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
F test/attach.test ba8261d38da6b6a7d4f78ec543c548c4418582ef
F test/attach2.test ce61e6185b3cd891cc0e9a4c868fcc65eb92fc55
F test/auth.test 3bd865e3069af8aa703158ff69cfc5e57b29033b
F test/bigfile.test ea904b853ce2d703b16c5ce90e2b54951bc1ae81
F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
F test/bind.test 56a57043b42c4664ca705f6050e56717a8a6699a
F test/btree.test 677aeaac7b7b81980b446ca9cab15aa0cc5550d5
F test/btree2.test e3b81ec33dc2f89b3e6087436dfe605b870c9080
F test/btree3.test e597fb59be2ac0ea69c62aaa2064e998e528b665
F test/btree3rb.test 127efcf5cdfcc352054e7db12622b01cdd8b36ac
F test/btree4.test fa955a3d7a8bc91d6084b7f494f9e5d1bdfb15b6
F test/btree4rb.test ae6f0438512edcb45cf483471cd6070a765963a9
F test/capi2.test ec96e0e235d87b53cbaef3d8e3e0f8ccf32c71ca
F test/conflict.test 0911bb2f079046914a6e9c3341b36658c4e2103e
F test/copy.test f07ea8d60878da7a67416ab62f78e9706b9d3c45
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/date.test aa4bc2aae379bed3f838ea73de0cde1c352c5545
F test/delete.test 92256384f1801760180ded129f7427884cf28886
F test/expr.test ad985242e140f87eeef329d98257b8369a2066dc
F test/fkey1.test d65c824459916249bee501532d6154ddab0b5db7
F test/format3.test 149cc166c97923fa60def047e90dd3fb32bba916
F test/func.test 56b12001d4d8239c6af2864e3d64916cf5dad711
F test/hook.test 1a67ce0cd64a6455d016962542f2822458dccc49
F test/in.test 0de39b02ceeca90993b096822fb5a884661c5b47
F test/index.test 491d721e9b442a51b118894323f2885a2187a8dd
F test/insert.test a17b7f7017097afb2727aa5b67ceeb7ab0a120a1
F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
F test/interrupt.test 0d50985f1aa6c39fe2cca4cf4a272c79ff1648e8
F test/intpkey.test 9320af48415c594afd4e15f8ef0daa272e05502e
F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4
F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd
F test/join2.test c97e4c5aa65dea462145529e58212a709b4722b8
F test/join3_28.test dbfbca6e102d30205e7c1854b0d4fdfcd04de938
F test/join4_28.test aa3dba47dcc9c835ac505111ff3d925f0657ef15
F test/lastinsert.test 31382f88b9b0270333ac9e4a17f2c2f4732da718
F test/laststmtchanges.test cabd11bdfbaf73a4486c50b58297d9c2038ccc18
F test/limit.test c6365450f3180170c0fa1b0bf1ae48522c33b731
F test/lock.test 226ef831dad60ad4d200dc83e25479ba952aac7e
F test/main.test 6a851b5992c4881a725a3d9647e629199df8de9d
F test/malloc.test 2cfcffb7c858640e01e6520ee1cd54ca57d98e80
F test/memdb.test 6ece25c7c0e6500199d3662607a3edca081abb2a
F test/memleak.test 4d5d374c8ea1fc5ac634aed58cac1047848ce65e
F test/minmax.test 9dc011a23b897718004b38f4f99e0171f9d5a3fe
F test/misc1.test 0b98d493b0cf55cb5f53e1f3df8107c166eecb5a
F test/misc2.test 10c2ce26407d37411b96273e552d5095393732be
F test/misc3.test 3b5e369514a3ba3f919fb7eafa7d027440b5079e
F test/misuse.test 1095f26d1aed406c65e1d2eba651c4bb7c38cbff
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F test/null.test 675e6823d72d4866d2aca6bf5b7259c9cd713703
F test/pager.test 331519008889d45f6df6697395e5bce6ee602fd9
F test/pragma.test 24a3f7a697b45cb90d664ebce5566bec7ac41571
F test/printf.test 46b3d07d59d871d0831b4a657f6dfcafe0574850
F test/progress.test 701b6115c2613128ececdfe1398a1bd0e1a4cfb3 x
F test/quick.test 5a6bccf5c02f16841a79fbac7409a02138880c10
F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d
F test/rowid.test 77f7e8c7ca626a15ff91a536595b695cfce7c845
F test/select1.test 1eab1f8aa85b8d4e3474c0769fb81313548929ab
F test/select2.test aceea74fd895b9d007512f72499db589735bd8e4
F test/select3.test 445a1a3dde4e2fd32541b311f55da5e2f8079d76
F test/select4.test e7e9a32fa745246cb99fadbeb63af4843a17925b
F test/select5.test c2a6c4a003316ee42cbbd689eebef8fdce0db2ac
F test/sort.test 462c1161eee1abaa7cc93990e0b34d5fdb70ce19
F test/subselect.test 335d3dad8d585726c447dfee8d9c4f7383c76b78
F test/table.test 3ef4254d62ece31a3872ab11cdaec846f6fa8fd1
F test/tableapi.test 51d0c209aa6b1158cb952ec917c656d4ce66e9e4
F test/tclsqlite.test feca0f2b23ba51d202d67d71e10ba7a8a1621f82
F test/temptable.test 37acd9e39781c2ff7cff2ba741b6b27ce020a44a
F test/tester.tcl c7ddeebc14cc841abb37134cd5d40c1e3ad367c1
F test/trans.test 855337b8a178c73c433fcf8ee88e4b2f5efff0d9
F test/unique.test ef1f67607a7109e9c0842cd8557550fb121d7ec6
F test/update.test 8cf76467d46b1650539763c95d5208340c61d561
F test/vacuum.test 8acf8669f3b627e54149b25165b034aa06c2432e
F test/where.test 43d5ac94da3f3722375307f948884dc79b326a91
F tool/lemon.c 5533b63e5cdbb1efc939abac3c2f4f37ac839488
F tool/lempar.c 9b604e6a8b3d55c0b9cbcb130a7302fb8bafe2b9
F tool/memleak.awk 296dfbce7a9ca499b95ce04e30334e64a50052e0
F tool/opNames.awk 5ba1f48aa854ee3b7c3d2b54233665bc3e649ea2
F test/select6.test a9e31906e700e7c7592c4d0acfc022808f718baf
F test/sort.test ba07b107c16070208e6aab3cadea66ba079d85ba
F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f
F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4
F test/tableapi.test e0c4cce61e58343caa84dab33fa6823cb35fe1e1
F test/tclsqlite.test 109ed5fbfe23e24f49eff6984dfa8a6bed8b5281
F test/temptable.test a770ba6308d7f7332fce985086b8e06bed6430c2
F test/tester.tcl 2f1d43df1311c9dc06acaa7a82e87bfea85dea5f
F test/thread1.test 53f050d5be6932d9430df7756edd379366508ff6
F test/threadtest1.c f7f896e62ed46feae1dc411114a48c15a0f82ee2
F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86
F test/trans.test 0cb8256daff1ae0da75321e00125338c6681158d
F test/trigger1.test d2d38d8a81a2c4a033b27965aaf28a0b7aa99f31
F test/trigger2.test 0767ab30cb5a2c8402c8524f3d566b410b6f5263
F test/trigger3.test a95ccace88291449f5eae7139ec438a42f90654d
F test/trigger4.test 542afce45774e8f8e1130b96b8675f414d6e4bd8
F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b
F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217
F test/vacuum.test a2a44544df719666efb51afbfeb6062fd59a672a
F test/version.test 92adee5d98cf6e3eb0d1cf5186952e8114931bf6
F test/view.test ac151928890d17716d5c1f7acc5924af61a7dacf
F test/where.test cb3a2ed062ce4b5f08aff2d08027c6a46d68c47b
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/lemon.c db6a3bfaf3388c0f7aea3adb5e05acddcd427016
F tool/lempar.c 0b5e7a58634e0d448929b8e85f7981c2aa708d57
F tool/memleak.awk b744b6109566206c746d826f6ecdba34662216bc
F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
F tool/renumberOps.awk 6d067177ad5f8d711b79577b462da9b3634bd0a9
F tool/report1.txt 9eae07f26a8fc53889b45fc833a66a33daa22816
F tool/showdb.c 3559eac5a3b46e9b558d50856946b25e77633236
F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87
F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b
F tool/spaceanal.tcl fec9907072011cd2b8b956fe7322cf6c50429ba9
F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
F www/arch.tcl 03b521d252575f93b9c52f7c8b0007011512fcfb
F www/c_interface.tcl 6c5989670e014de44dce6580cbde0eea965dadbb
F www/changes.tcl fdd4f8b474bce2463b876c1bedb68c20bc3f5b34
F www/crosscompile.tcl c99efacb3aefaa550c6e80d91b240f55eb9fd33e
F www/download.tcl 3e51c9ff1326b0a182846134987301310dff7d60
F www/arch.tcl b329ca2c8dc75cd1cf0dd714b8bb47bdd458d0da
F www/arch2.fig 613b5ac63511109064c2f93c5754ee662219937d
F www/arch2.gif 49c6bb36160f03ca2b89eaa5bfb1f560c7d68ee7
F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0
F www/c_interface.tcl 17d8bd9e7b4fbdca47c30c8b9bcb728c351d55c0
F www/changes.tcl a3d043896631a14091dbafdb4068980974c3834c
F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
F www/datatypes.tcl 0fe2b810f114a909b844e50ad37a25e6ed8c7271
F www/download.tcl 0932d7f4f0e8b2adbbd22fac73132f86e43ab4a9
F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
F www/index.tcl 68c815d64b35b2dcc4d4f6845827df71c6869f9f
F www/lang.tcl 1899ec4fb77cd69de335ebd998253de869f34d8e
F www/mingw.tcl fc5f4ba9d336b6e8c97347cc6496d6162461ef60
F www/opcode.tcl 4365ad9798872491dbd7d3071510ebe461785ac3
F www/speed.tcl ab7d6d3bc898472bd94320a5d3c63de928d4804b
F www/sqlite.tcl 6a21242a272e9c0939a04419a51c3d50cae33e3e
F www/tclsqlite.tcl 13d50723f583888fc80ae1a38247c0ab415066fa
F www/vdbe.tcl bb7d620995f0a987293e9d4fb6185a3b077e9b44
P f8328a5f11801c5124f9a8dace22df3c1cfb2191
R 123ebf892398ed7efe52cb42cd131987
F www/faq.tcl 88d3b95d9cd8e374772daa3a646c4d107e7f3e9b
F www/fileformat.tcl 56f77e435a6306b337b20b416e3b89500ba2d029
F www/formatchng.tcl ca6cc1cb1bef9bc36f0619049d3c95e749bc6983
F www/index.tcl bacb2a0d052845bbe3bf078765cce907ed7080a4
F www/lang.tcl 17954f37c8bb1d25e026d97041ff6459fb89ac95
F www/mingw.tcl d96b451568c5d28545fefe0c80bee3431c73f69c
F www/nulls.tcl 38117d24afb81efd079b59723b985a6d654cc2e8
F www/omitted.tcl 11037a1b557bd01405092d93dfa08898a4c26cd7
F www/opcode.tcl b8d561f33597c62955796b797646f00144d97332
F www/quickstart.tcl 4e97bef825e6a4153c43afb9f97235fc4da278ab
F www/speed.tcl 2f6b1155b99d39adb185f900456d1d592c4832b3
F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P affde4431749e0c57e786cec926895b3c0f8a04f
R dd9f6bcae9ce8f6c1595e339d4e239bd
U drh
Z b312054a8667af4612baea400c53bbff
Z d67bbcce34bf232ebe03651d1d7d8311
+1 -1
View File
@@ -1 +1 @@
b0442cb9c64682b6f98bf8f26f50bb54bdfd9013
2efbbba55a851a5b83726720aaa9e59b8387556c
+121 -33
View File
@@ -11,34 +11,49 @@
#
srcdir=`echo "$0" | sed 's%\(^.*\)/[^/][^/]*$%\1%'`
# Get the makefile.
# Clear out the build directory "doc"
#
cp $srcdir/Makefile.template ./Makefile
#rm -rf doc
#make doc
# Start building stuff.
# Get the current version number - needed to help build filenames
#
VERS=`cat $srcdir/VERSION`
VERSW=`sed 's/\./_/g' $srcdir/VERSION`
# Start by building an sqlite shell for linux.
#
make clean
make sqlite
strip sqlite
mv sqlite sqlite.bin
mv sqlite sqlite-$VERS.bin
rm -f sqlite.bin.gz
gzip sqlite.bin
gzip sqlite-$VERS.bin
mv sqlite-$VERS.bin.gz doc
# Build the tclsqlite.so shared library for import into tclsh or wish
# under Linux
#
make target_source
rm -f doc/sqlite-source-$VERSW.zip
cd tsrc
zip ../doc/sqlite-source-$VERSW.zip *
rm shell.c
TCLDIR=/home/drh/tcltk/8.2linux
TCLSTUBLIB=$TCLDIR/libtclstub8.2g.a
OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1 -DOS_UNIX=1 -DOS_WIN=0'
OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1'
gcc -fPIC $OPTS -O2 -I. -I$TCLDIR -shared *.c $TCLSTUBLIB -o tclsqlite.so
strip tclsqlite.so
mv tclsqlite.so ..
mv tclsqlite.so tclsqlite-$VERS.so
gzip tclsqlite-$VERS.so
mv tclsqlite-$VERS.so.gz ../doc
rm tclsqlite.c
gcc -fPIC -DNDEBUG=1 -O2 -I. -shared *.c -o sqlite.so
strip sqlite.so
mv sqlite.so sqlite-$VERS.so
gzip sqlite-$VERS.so
mv sqlite-$VERS.so.gz ../doc
cd ..
rm -f tclsqlite.so
gzip tclsqlite.so
# Build the tclsqlite.dll shared library that can be imported into tclsh
# or wish on windows.
@@ -49,8 +64,8 @@ rm shell.c
TCLDIR=/home/drh/tcltk/8.2win
TCLSTUBLIB=$TCLDIR/tclstub82.a
PATH=$PATH:/opt/mingw/bin
OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1 -DOS_UNIX=0 -DOS_WIN=1'
CC="i386-mingw32-gcc -O2 $OPTS -I. -I$TCLDIR"
OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1 -DTHREADSAFE=1'
CC="i386-mingw32msvc-gcc -O2 $OPTS -I. -I$TCLDIR"
rm shell.c
for i in *.c; do
CMD="$CC -c $i"
@@ -60,45 +75,118 @@ done
echo 'EXPORTS' >tclsqlite.def
echo 'Tclsqlite_Init' >>tclsqlite.def
echo 'Sqlite_Init' >>tclsqlite.def
i386-mingw32-dllwrap \
i386-mingw32msvc-dllwrap \
--def tclsqlite.def -v --export-all \
--driver-name i386-mingw32-gcc \
--dlltool-name i386-mingw32-dlltool \
--as i386-mingw32-as \
--driver-name i386-mingw32msvc-gcc \
--dlltool-name i386-mingw32msvc-dlltool \
--as i386-mingw32msvc-as \
--target i386-mingw32 \
-dllname tclsqlite.dll -lmsvcrt *.o $TCLSTUBLIB
i386-mingw32-strip tclsqlite.dll
mv tclsqlite.dll ..
i386-mingw32msvc-strip tclsqlite.dll
#mv tclsqlite.dll ../tclsqlite-$VERSW.dll
rm tclsqlite.o
cat >sqlite.def <<\END_OF_FILE
EXPORTS
sqlite_open
sqlite_close
sqlite_exec
sqlite_last_insert_rowid
sqlite_error_string
sqlite_interrupt
sqlite_complete
sqlite_busy_handler
sqlite_busy_timeout
sqlite_get_table
sqlite_free_table
sqlite_mprintf
sqlite_vmprintf
sqlite_exec_printf
sqlite_exec_vprintf
sqlite_get_table_printf
sqlite_get_table_vprintf
sqlite_freemem
sqlite_libversion
sqlite_libencoding
sqlite_changes
sqlite_create_function
sqlite_create_aggregate
sqlite_function_type
sqlite_user_data
sqlite_aggregate_context
sqlite_aggregate_count
sqlite_set_result_string
sqlite_set_result_int
sqlite_set_result_double
sqlite_set_result_error
sqliteMalloc
sqliteFree
sqliteRealloc
sqlite_set_authorizer
sqlite_trace
sqlite_compile
sqlite_step
sqlite_finalize
sqlite_reset
sqlite_bind
sqlite_last_statement_changes
sqlite_encode_binary
sqlite_decode_binary
END_OF_FILE
i386-mingw32msvc-dllwrap \
--def sqlite.def -v --export-all \
--driver-name i386-mingw32msvc-gcc \
--dlltool-name i386-mingw32msvc-dlltool \
--as i386-mingw32msvc-as \
--target i386-mingw32 \
-dllname sqlite.dll -lmsvcrt *.o
i386-mingw32msvc-strip sqlite.dll
zip ../doc/tclsqlite-$VERSW.zip tclsqlite.dll
zip ../doc/sqlitedll-$VERSW.zip sqlite.dll sqlite.def
cd ..
rm -f tclsqlite.zip
zip tclsqlite.zip tclsqlite.dll
# Build the sqlite.exe executable for windows.
#
make target_source
cd tsrc
rm tclsqlite.c
OPTS='-DSTATIC_BUILD=1 -DNDEBUG=1 -DOS_UNIX=0 -DOS_WIN=1'
i386-mingw32-gcc -O2 $OPTS -I. -I$TCLDIR *.c -o sqlite.exe
mv sqlite.exe ..
OPTS='-DSTATIC_BUILD=1 -DNDEBUG=1'
i386-mingw32msvc-gcc -O2 $OPTS -I. -I$TCLDIR *.c -o sqlite.exe
zip ../doc/sqlite-$VERSW.zip sqlite.exe
cd ..
rm -f sqlite.zip
zip sqlite.zip sqlite.exe
# Construct a tarball of the source tree
#
ORIGIN=`pwd`
cd $srcdir
cd ..
tar czf $ORIGIN/sqlite.tar.gz sqlite
EXCLUDE=`find sqlite -print | grep CVS | sed 's,^, --exclude ,'`
tar czf $ORIGIN/doc/sqlite-$VERS.tar.gz $EXCLUDE sqlite
cd $ORIGIN
vers=`cat $srcdir/VERSION`
rm -f sqlite-$vers.tar.gz
ln sqlite.tar.gz sqlite-$vers.tar.gz
# Build the website
#
cp $srcdir/../historical/* .
rm -rf doc
make doc
ln sqlite.bin.gz sqlite.zip sqlite*.tar.gz tclsqlite.so.gz tclsqlite.zip doc
# Build RPMS (binary) and Source RPM
#
# Make sure we are properly setup to build RPMs
#
echo "%HOME %{expand:%%(cd; pwd)}" > $HOME/.rpmmacros
echo "%_topdir %{HOME}/rpm" >> $HOME/.rpmmacros
mkdir $HOME/rpm
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/SPECS
# create the spec file from the template
sed s/SQLITE_VERSION/$VERS/g $srcdir/spec.template > $HOME/rpm/SPECS/sqlite.spec
# copy the source tarball to the rpm directory
cp doc/sqlite-$VERS.tar.gz $HOME/rpm/SOURCES/.
# build all the rpms
rpm -ba $HOME/rpm/SPECS/sqlite.spec >& rpm-$vers.log
# copy the RPMs into the build directory.
mv $HOME/rpm/RPMS/i386/sqlite*-$VERS*.rpm doc
mv $HOME/rpm/SRPMS/sqlite-$VERS*.rpm doc
+62
View File
@@ -0,0 +1,62 @@
%define name sqlite
%define version SQLITE_VERSION
%define release 1
Name: %{name}
Summary: SQLite is a C library that implements an embeddable SQL database engine
Version: %{version}
Release: %{release}
Source: %{name}-%{version}.tar.gz
Group: System/Libraries
URL: http://www.hwaci.com/sw/sqlite/
License: Public Domain
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
SQLite is a C library that implements an embeddable SQL database engine.
Programs that link with the SQLite library can have SQL database access
without running a separate RDBMS process. The distribution comes with a
standalone command-line access program (sqlite) that can be used to
administer an SQLite database and which serves as an example of how to
use the SQLite library.
%package -n %{name}-devel
Summary: Header files and libraries for developing apps which will use sqlite
Group: Development/C
Requires: %{name} = %{version}-%{release}
%description -n %{name}-devel
The sqlite-devel package contains the header files and libraries needed
to develop programs that use the sqlite database library.
%prep
%setup -q -n %{name}
%build
CFLAGS="%optflags -DNDEBUG=1" CXXFLAGS="%optflags -DNDEBUG=1" ./configure --prefix=%{_prefix}
make
make doc
%install
install -d $RPM_BUILD_ROOT/%{_prefix}
install -d $RPM_BUILD_ROOT/%{_prefix}/bin
install -d $RPM_BUILD_ROOT/%{_prefix}/include
install -d $RPM_BUILD_ROOT/%{_prefix}/lib
make install prefix=$RPM_BUILD_ROOT/%{_prefix}
%clean
rm -fr $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%{_libdir}/*.so*
%{_bindir}/*
%files -n %{name}-devel
%defattr(-, root, root)
%{_libdir}/pkgconfig/sqlite.pc
%{_libdir}/*.a
%{_libdir}/*.la
%{_includedir}/*
%doc doc/*
+203
View File
@@ -0,0 +1,203 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH SQLITE 1 "Mon Apr 15 23:49:17 2002"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
sqlite \- A command line interface for SQLite
.SH SYNOPSIS
.B sqlite
.RI [ options ] " filename " [ SQL ]
.SS SUMMARY
.PP
sqlite is a terminal-based front-end to the SQLite library. It enables
you to type in queries interactively, issue them to SQLite and see the
results. Alternatively, you can specify SQL code on the command-line. In
addition it provides a number of meta-commands.
.SH DESCRIPTION
This manual page documents briefly the
.B sqlite
command.
This manual page was written for the Debian GNU/Linux distribution
because the original program does not have a manual page.
.SS GETTING STARTED
.PP
To start the sqlite program, just type "sqlite" followed by the name
the file that holds the SQLite database. If the file does not exist, a
new one is created automatically. The sqlite program will then prompt
you to enter SQL. Type in SQL statements (terminated by a semicolon),
press "Enter" and the SQL will be executed.
For example, to create a new SQLite database named "ex1" with a single
table named "tbl1", you might do this:
.sp
.nf
$ sqlite ex1
SQLite version 2.0.0
Enter ".help" for instructions
sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values('hello!',10);
sqlite> insert into tbl1 values('goodbye', 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite>
.sp
.fi
.SS SQLITE META-COMMANDS
.PP
Most of the time, sqlite just reads lines of input and passes them on
to the SQLite library for execution. But if an input line begins with
a dot ("."), then that line is intercepted and interpreted by the
sqlite program itself. These "dot commands" are typically used to
change the output format of queries, or to execute certain prepackaged
query statements.
For a listing of the available dot commands, you can enter ".help" at
any time. For example:
.sp
.nf
.cc |
sqlite> .help
.dump ?TABLE? ... Dump the database in an text format
.echo ON|OFF Turn command echo on or off
.exit Exit this program
.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
"off" will revert to the output mode that was
previously in effect
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.indices TABLE Show names of all indices on TABLE
.mode MODE Set mode to one of "line(s)", "column(s)",
"insert", "list", or "html"
.mode insert TABLE Generate SQL insert statements for TABLE
.nullvalue STRING Print STRING instead of nothing for NULL data
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.prompt MAIN CONTINUE Replace the standard prompts
"sqlite > " and " ...> "
with the strings MAIN and CONTINUE
CONTINUE is optional.
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.reindex ?TABLE? Rebuild indices
.schema ?TABLE? Show the CREATE statements
.separator STRING Change separator string for "list" mode
.show Show the current values for the following:
.echo
.explain
.mode
.nullvalue
.output
.separator
.width
.tables ?PATTERN? List names of tables matching a pattern
.timeout MS Try opening locked tables for MS milliseconds
.width NUM NUM ... Set column widths for "column" mode
sqlite>
|cc .
.sp
.fi
.SH OPTIONS
The program has the following options:
.TP
.BI \-init\ file
Read in and process 'file', which contains "dot commands".
You can use this file to initialize display settings.
.TP
.B \-html
Set output mode to HTML.
.TP
.B \-list
Set output mode to 'list'.
.TP
.B \-line
Set output mode to 'line'.
.TP
.B \-column
Set output mode to 'column'.
.TP
.BI \-separator\ separator
Specify which output field separator for 'list' mode to use.
Default is '|'.
.TP
.BI \-nullvalue\ string
When a null is encountered, print 'string'. Default is no string.
.TP
.B \-[no]header
Turn headers on or off. Default is off.
.TP
.B \-echo
Print commands before execution.
.SH OUTPUT MODE
The SQLite program has different output modes, which define the way
the output (from queries) is formatted.
In 'list' mode, which is the default, one record per line is output,
each field separated by the separator specified with the
\fB-separator\fP option or \fB.separator\fP command.
In 'line' mode, each column is output on its own line, records are
separated by blank lines.
In HTML mode, an XHTML table is generated.
In 'column' mode, one record per line is output, aligned neatly in colums.
.SH INIT FILE
sqlite can be initialized using resource files. These can be combined with
command line arguments to set up sqlite exactly the way you want it.
Initialization proceeds as follows:
o The defaults of
.sp
.nf
.cc |
mode = LIST
separator = "|"
main prompt = "sqlite> "
continue prompt = " ...> "
|cc .
.sp
.fi
are established.
o If a file .sqliterc can be found in the user's home directory, it is
read and processed. It should only contain "dot commands". If the
file is not found or cannot be read, processing continues without
notification.
o If a file is specified on the command line with the -init option, it
is processed in the same manner as .sqliterc
o All other command line options are processed
o The database is opened and you are now ready to begin.
.SH SEE ALSO
http://www.hwaci.com/sw/sqlite/
.br
The sqlite-doc package
.SH AUTHOR
This manual page was originally written by Andreas Rottmann
<rotty@debian.org>, for the Debian GNU/Linux system (but may be used
by others).
+45
View File
@@ -0,0 +1,45 @@
EXPORTS
sqlite_open
sqlite_close
sqlite_exec
sqlite_last_insert_rowid
sqlite_error_string
sqlite_interrupt
sqlite_complete
sqlite_busy_handler
sqlite_busy_timeout
sqlite_get_table
sqlite_free_table
sqlite_mprintf
sqlite_vmprintf
sqlite_exec_printf
sqlite_exec_vprintf
sqlite_get_table_printf
sqlite_get_table_vprintf
sqlite_freemem
sqlite_libversion
sqlite_libencoding
sqlite_changes
sqlite_create_function
sqlite_create_aggregate
sqlite_function_type
sqlite_user_data
sqlite_aggregate_context
sqlite_aggregate_count
sqlite_set_result_string
sqlite_set_result_int
sqlite_set_result_double
sqlite_set_result_error
sqliteMalloc
sqliteFree
sqliteRealloc
sqlite_set_authorizer
sqlite_trace
sqlite_compile
sqlite_step
sqlite_finalize
sqlite_reset
sqlite_bind
sqlite_last_statement_changes
sqlite_encode_binary
sqlite_decode_binary
+12
View File
@@ -0,0 +1,12 @@
# Package Information for pkg-config
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: SQLite
Description: SQL database engine
Version: @VERSION@
Libs: -L${libdir} -lsqlite
Cflags: -I${includedir}
-6
View File
@@ -1,6 +0,0 @@
* Document all the changes and release Sqlite 2.0.
* Implement CLUSTER command like in PostgreSQL.
* "OPTIMIZE select" statement to automatically create indices and/or
invoke a CLUSTER command.
* "CREATE INDEX FOR select" to automatically generate needed indices.
* Parse and use constraints.
+311
View File
@@ -0,0 +1,311 @@
/*
** 2003 April 6
**
** 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 code used to implement the ATTACH and DETACH commands.
**
** $Id: attach.c,v 1.10.2.1 2004/05/07 01:46:01 drh Exp $
*/
#include "sqliteInt.h"
/*
** This routine is called by the parser to process an ATTACH statement:
**
** ATTACH DATABASE filename AS dbname
**
** The pFilename and pDbname arguments are the tokens that define the
** filename and dbname in the ATTACH statement.
*/
void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey){
Db *aNew;
int rc, i;
char *zFile, *zName;
sqlite *db;
Vdbe *v;
v = sqliteGetVdbe(pParse);
sqliteVdbeAddOp(v, OP_Halt, 0, 0);
if( pParse->explain ) return;
db = pParse->db;
if( db->file_format<4 ){
sqliteErrorMsg(pParse, "cannot attach auxiliary databases to an "
"older format master database", 0);
pParse->rc = SQLITE_ERROR;
return;
}
if( db->nDb>=MAX_ATTACHED+2 ){
sqliteErrorMsg(pParse, "too many attached databases - max %d",
MAX_ATTACHED);
pParse->rc = SQLITE_ERROR;
return;
}
zFile = 0;
sqliteSetNString(&zFile, pFilename->z, pFilename->n, 0);
if( zFile==0 ) return;
sqliteDequote(zFile);
#ifndef SQLITE_OMIT_AUTHORIZATION
if( sqliteAuthCheck(pParse, SQLITE_ATTACH, zFile, 0, 0)!=SQLITE_OK ){
sqliteFree(zFile);
return;
}
#endif /* SQLITE_OMIT_AUTHORIZATION */
zName = 0;
sqliteSetNString(&zName, pDbname->z, pDbname->n, 0);
if( zName==0 ) return;
sqliteDequote(zName);
for(i=0; i<db->nDb; i++){
if( db->aDb[i].zName && sqliteStrICmp(db->aDb[i].zName, zName)==0 ){
sqliteErrorMsg(pParse, "database %z is already in use", zName);
pParse->rc = SQLITE_ERROR;
sqliteFree(zFile);
return;
}
}
if( db->aDb==db->aDbStatic ){
aNew = sqliteMalloc( sizeof(db->aDb[0])*3 );
if( aNew==0 ) return;
memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
}else{
aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
if( aNew==0 ) return;
}
db->aDb = aNew;
aNew = &db->aDb[db->nDb++];
memset(aNew, 0, sizeof(*aNew));
sqliteHashInit(&aNew->tblHash, SQLITE_HASH_STRING, 0);
sqliteHashInit(&aNew->idxHash, SQLITE_HASH_STRING, 0);
sqliteHashInit(&aNew->trigHash, SQLITE_HASH_STRING, 0);
sqliteHashInit(&aNew->aFKey, SQLITE_HASH_STRING, 1);
aNew->zName = zName;
rc = sqliteBtreeFactory(db, zFile, 0, MAX_PAGES, &aNew->pBt);
if( rc ){
sqliteErrorMsg(pParse, "unable to open database: %s", zFile);
}
#if SQLITE_HAS_CODEC
{
extern int sqliteCodecAttach(sqlite*, int, void*, int);
char *zKey = 0;
int nKey;
if( pKey && pKey->z && pKey->n ){
sqliteSetNString(&zKey, pKey->z, pKey->n, 0);
sqliteDequote(zKey);
nKey = strlen(zKey);
}else{
zKey = 0;
nKey = 0;
}
sqliteCodecAttach(db, db->nDb-1, zKey, nKey);
}
#endif
sqliteFree(zFile);
db->flags &= ~SQLITE_Initialized;
if( pParse->nErr ) return;
if( rc==SQLITE_OK ){
rc = sqliteInit(pParse->db, &pParse->zErrMsg);
}
if( rc ){
int i = db->nDb - 1;
assert( i>=2 );
if( db->aDb[i].pBt ){
sqliteBtreeClose(db->aDb[i].pBt);
db->aDb[i].pBt = 0;
}
sqliteResetInternalSchema(db, 0);
pParse->nErr++;
pParse->rc = SQLITE_ERROR;
}
}
/*
** This routine is called by the parser to process a DETACH statement:
**
** DETACH DATABASE dbname
**
** The pDbname argument is the name of the database in the DETACH statement.
*/
void sqliteDetach(Parse *pParse, Token *pDbname){
int i;
sqlite *db;
Vdbe *v;
Db *pDb;
v = sqliteGetVdbe(pParse);
sqliteVdbeAddOp(v, OP_Halt, 0, 0);
if( pParse->explain ) return;
db = pParse->db;
for(i=0; i<db->nDb; i++){
pDb = &db->aDb[i];
if( pDb->pBt==0 || pDb->zName==0 ) continue;
if( strlen(pDb->zName)!=pDbname->n ) continue;
if( sqliteStrNICmp(pDb->zName, pDbname->z, pDbname->n)==0 ) break;
}
if( i>=db->nDb ){
sqliteErrorMsg(pParse, "no such database: %T", pDbname);
return;
}
if( i<2 ){
sqliteErrorMsg(pParse, "cannot detach database %T", pDbname);
return;
}
#ifndef SQLITE_OMIT_AUTHORIZATION
if( sqliteAuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){
return;
}
#endif /* SQLITE_OMIT_AUTHORIZATION */
sqliteBtreeClose(pDb->pBt);
pDb->pBt = 0;
sqliteFree(pDb->zName);
sqliteResetInternalSchema(db, i);
if( pDb->pAux && pDb->xFreeAux ) pDb->xFreeAux(pDb->pAux);
db->nDb--;
if( i<db->nDb ){
db->aDb[i] = db->aDb[db->nDb];
memset(&db->aDb[db->nDb], 0, sizeof(db->aDb[0]));
sqliteResetInternalSchema(db, i);
}
}
/*
** Initialize a DbFixer structure. This routine must be called prior
** to passing the structure to one of the sqliteFixAAAA() routines below.
**
** The return value indicates whether or not fixation is required. TRUE
** means we do need to fix the database references, FALSE means we do not.
*/
int sqliteFixInit(
DbFixer *pFix, /* The fixer to be initialized */
Parse *pParse, /* Error messages will be written here */
int iDb, /* This is the database that must must be used */
const char *zType, /* "view", "trigger", or "index" */
const Token *pName /* Name of the view, trigger, or index */
){
sqlite *db;
if( iDb<0 || iDb==1 ) return 0;
db = pParse->db;
assert( db->nDb>iDb );
pFix->pParse = pParse;
pFix->zDb = db->aDb[iDb].zName;
pFix->zType = zType;
pFix->pName = pName;
return 1;
}
/*
** The following set of routines walk through the parse tree and assign
** a specific database to all table references where the database name
** was left unspecified in the original SQL statement. The pFix structure
** must have been initialized by a prior call to sqliteFixInit().
**
** These routines are used to make sure that an index, trigger, or
** view in one database does not refer to objects in a different database.
** (Exception: indices, triggers, and views in the TEMP database are
** allowed to refer to anything.) If a reference is explicitly made
** to an object in a different database, an error message is added to
** pParse->zErrMsg and these routines return non-zero. If everything
** checks out, these routines return 0.
*/
int sqliteFixSrcList(
DbFixer *pFix, /* Context of the fixation */
SrcList *pList /* The Source list to check and modify */
){
int i;
const char *zDb;
if( pList==0 ) return 0;
zDb = pFix->zDb;
for(i=0; i<pList->nSrc; i++){
if( pList->a[i].zDatabase==0 ){
pList->a[i].zDatabase = sqliteStrDup(zDb);
}else if( sqliteStrICmp(pList->a[i].zDatabase,zDb)!=0 ){
sqliteErrorMsg(pFix->pParse,
"%s %z cannot reference objects in database %s",
pFix->zType, sqliteStrNDup(pFix->pName->z, pFix->pName->n),
pList->a[i].zDatabase);
return 1;
}
if( sqliteFixSelect(pFix, pList->a[i].pSelect) ) return 1;
if( sqliteFixExpr(pFix, pList->a[i].pOn) ) return 1;
}
return 0;
}
int sqliteFixSelect(
DbFixer *pFix, /* Context of the fixation */
Select *pSelect /* The SELECT statement to be fixed to one database */
){
while( pSelect ){
if( sqliteFixExprList(pFix, pSelect->pEList) ){
return 1;
}
if( sqliteFixSrcList(pFix, pSelect->pSrc) ){
return 1;
}
if( sqliteFixExpr(pFix, pSelect->pWhere) ){
return 1;
}
if( sqliteFixExpr(pFix, pSelect->pHaving) ){
return 1;
}
pSelect = pSelect->pPrior;
}
return 0;
}
int sqliteFixExpr(
DbFixer *pFix, /* Context of the fixation */
Expr *pExpr /* The expression to be fixed to one database */
){
while( pExpr ){
if( sqliteFixSelect(pFix, pExpr->pSelect) ){
return 1;
}
if( sqliteFixExprList(pFix, pExpr->pList) ){
return 1;
}
if( sqliteFixExpr(pFix, pExpr->pRight) ){
return 1;
}
pExpr = pExpr->pLeft;
}
return 0;
}
int sqliteFixExprList(
DbFixer *pFix, /* Context of the fixation */
ExprList *pList /* The expression to be fixed to one database */
){
int i;
if( pList==0 ) return 0;
for(i=0; i<pList->nExpr; i++){
if( sqliteFixExpr(pFix, pList->a[i].pExpr) ){
return 1;
}
}
return 0;
}
int sqliteFixTriggerStep(
DbFixer *pFix, /* Context of the fixation */
TriggerStep *pStep /* The trigger step be fixed to one database */
){
while( pStep ){
if( sqliteFixSelect(pFix, pStep->pSelect) ){
return 1;
}
if( sqliteFixExpr(pFix, pStep->pWhere) ){
return 1;
}
if( sqliteFixExprList(pFix, pStep->pExprList) ){
return 1;
}
pStep = pStep->pNext;
}
return 0;
}
+219
View File
@@ -0,0 +1,219 @@
/*
** 2003 January 11
**
** 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 code used to implement the sqlite_set_authorizer()
** API. This facility is an optional feature of the library. Embedded
** systems that do not need this facility may omit it by recompiling
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
**
** $Id: auth.c,v 1.12.2.2 2004/09/09 13:54:30 drh Exp $
*/
#include "sqliteInt.h"
/*
** All of the code in this file may be omitted by defining a single
** macro.
*/
#ifndef SQLITE_OMIT_AUTHORIZATION
/*
** Set or clear the access authorization function.
**
** The access authorization function is be called during the compilation
** phase to verify that the user has read and/or write access permission on
** various fields of the database. The first argument to the auth function
** is a copy of the 3rd argument to this routine. The second argument
** to the auth function is one of these constants:
**
** SQLITE_COPY
** SQLITE_CREATE_INDEX
** SQLITE_CREATE_TABLE
** SQLITE_CREATE_TEMP_INDEX
** SQLITE_CREATE_TEMP_TABLE
** SQLITE_CREATE_TEMP_TRIGGER
** SQLITE_CREATE_TEMP_VIEW
** SQLITE_CREATE_TRIGGER
** SQLITE_CREATE_VIEW
** SQLITE_DELETE
** SQLITE_DROP_INDEX
** SQLITE_DROP_TABLE
** SQLITE_DROP_TEMP_INDEX
** SQLITE_DROP_TEMP_TABLE
** SQLITE_DROP_TEMP_TRIGGER
** SQLITE_DROP_TEMP_VIEW
** SQLITE_DROP_TRIGGER
** SQLITE_DROP_VIEW
** SQLITE_INSERT
** SQLITE_PRAGMA
** SQLITE_READ
** SQLITE_SELECT
** SQLITE_TRANSACTION
** SQLITE_UPDATE
**
** The third and fourth arguments to the auth function are the name of
** the table and the column that are being accessed. The auth function
** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE. If
** SQLITE_OK is returned, it means that access is allowed. SQLITE_DENY
** means that the SQL statement will never-run - the sqlite_exec() call
** will return with an error. SQLITE_IGNORE means that the SQL statement
** should run but attempts to read the specified column will return NULL
** and attempts to write the column will be ignored.
**
** Setting the auth function to NULL disables this hook. The default
** setting of the auth function is NULL.
*/
int sqlite_set_authorizer(
sqlite *db,
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
void *pArg
){
db->xAuth = xAuth;
db->pAuthArg = pArg;
return SQLITE_OK;
}
/*
** Write an error message into pParse->zErrMsg that explains that the
** user-supplied authorization function returned an illegal value.
*/
static void sqliteAuthBadReturnCode(Parse *pParse, int rc){
sqliteErrorMsg(pParse, "illegal return value (%d) from the "
"authorization function - should be SQLITE_OK, SQLITE_IGNORE, "
"or SQLITE_DENY", rc);
pParse->rc = SQLITE_MISUSE;
}
/*
** The pExpr should be a TK_COLUMN expression. The table referred to
** is in pTabList or else it is the NEW or OLD table of a trigger.
** Check to see if it is OK to read this particular column.
**
** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN
** instruction into a TK_NULL. If the auth function returns SQLITE_DENY,
** then generate an error.
*/
void sqliteAuthRead(
Parse *pParse, /* The parser context */
Expr *pExpr, /* The expression to check authorization on */
SrcList *pTabList /* All table that pExpr might refer to */
){
sqlite *db = pParse->db;
int rc;
Table *pTab; /* The table being read */
const char *zCol; /* Name of the column of the table */
int iSrc; /* Index in pTabList->a[] of table being read */
const char *zDBase; /* Name of database being accessed */
TriggerStack *pStack; /* The stack of current triggers */
if( db->xAuth==0 ) return;
assert( pExpr->op==TK_COLUMN );
for(iSrc=0; iSrc<pTabList->nSrc; iSrc++){
if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break;
}
if( iSrc>=0 && iSrc<pTabList->nSrc ){
pTab = pTabList->a[iSrc].pTab;
}else if( (pStack = pParse->trigStack)!=0 ){
/* This must be an attempt to read the NEW or OLD pseudo-tables
** of a trigger.
*/
assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx );
pTab = pStack->pTab;
}else{
return;
}
if( pTab==0 ) return;
if( pExpr->iColumn>=0 ){
assert( pExpr->iColumn<pTab->nCol );
zCol = pTab->aCol[pExpr->iColumn].zName;
}else if( pTab->iPKey>=0 ){
assert( pTab->iPKey<pTab->nCol );
zCol = pTab->aCol[pTab->iPKey].zName;
}else{
zCol = "ROWID";
}
assert( pExpr->iDb<db->nDb );
zDBase = db->aDb[pExpr->iDb].zName;
rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase,
pParse->zAuthContext);
if( rc==SQLITE_IGNORE ){
pExpr->op = TK_NULL;
}else if( rc==SQLITE_DENY ){
if( db->nDb>2 || pExpr->iDb!=0 ){
sqliteErrorMsg(pParse, "access to %s.%s.%s is prohibited",
zDBase, pTab->zName, zCol);
}else{
sqliteErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol);
}
pParse->rc = SQLITE_AUTH;
}else if( rc!=SQLITE_OK ){
sqliteAuthBadReturnCode(pParse, rc);
}
}
/*
** Do an authorization check using the code and arguments given. Return
** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY. If SQLITE_DENY
** is returned, then the error count and error message in pParse are
** modified appropriately.
*/
int sqliteAuthCheck(
Parse *pParse,
int code,
const char *zArg1,
const char *zArg2,
const char *zArg3
){
sqlite *db = pParse->db;
int rc;
if( db->init.busy || db->xAuth==0 ){
return SQLITE_OK;
}
rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext);
if( rc==SQLITE_DENY ){
sqliteErrorMsg(pParse, "not authorized");
pParse->rc = SQLITE_AUTH;
}else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){
rc = SQLITE_DENY;
sqliteAuthBadReturnCode(pParse, rc);
}
return rc;
}
/*
** Push an authorization context. After this routine is called, the
** zArg3 argument to authorization callbacks will be zContext until
** popped. Or if pParse==0, this routine is a no-op.
*/
void sqliteAuthContextPush(
Parse *pParse,
AuthContext *pContext,
const char *zContext
){
pContext->pParse = pParse;
if( pParse ){
pContext->zAuthContext = pParse->zAuthContext;
pParse->zAuthContext = zContext;
}
}
/*
** Pop an authorization context that was previously pushed
** by sqliteAuthContextPush
*/
void sqliteAuthContextPop(AuthContext *pContext){
if( pContext->pParse ){
pContext->pParse->zAuthContext = pContext->zAuthContext;
pContext->pParse = 0;
}
}
#endif /* SQLITE_OMIT_AUTHORIZATION */
+1323 -538
View File
File diff suppressed because it is too large Load Diff
+129 -34
View File
@@ -10,52 +10,147 @@
**
*************************************************************************
** This header file defines the interface that the sqlite B-Tree file
** subsystem.
** subsystem. See comments in the source code for a detailed description
** of what each interface routine does.
**
** @(#) $Id: btree.h,v 1.16 2001/09/27 03:22:33 drh Exp $
** @(#) $Id: btree.h,v 1.36 2004/02/10 02:57:59 drh Exp $
*/
#ifndef _BTREE_H_
#define _BTREE_H_
/*
** Forward declarations of structure
*/
typedef struct Btree Btree;
typedef struct BtCursor BtCursor;
typedef struct BtOps BtOps;
typedef struct BtCursorOps BtCursorOps;
/*
** An instance of the following structure contains pointers to all
** methods against an open BTree. Alternative BTree implementations
** (examples: file based versus in-memory) can be created by substituting
** different methods. Users of the BTree cannot tell the difference.
**
** In C++ we could do this by defining a virtual base class and then
** creating subclasses for each different implementation. But this is
** C not C++ so we have to be a little more explicit.
*/
struct BtOps {
int (*Close)(Btree*);
int (*SetCacheSize)(Btree*, int);
int (*SetSafetyLevel)(Btree*, int);
int (*BeginTrans)(Btree*);
int (*Commit)(Btree*);
int (*Rollback)(Btree*);
int (*BeginCkpt)(Btree*);
int (*CommitCkpt)(Btree*);
int (*RollbackCkpt)(Btree*);
int (*CreateTable)(Btree*, int*);
int (*CreateIndex)(Btree*, int*);
int (*DropTable)(Btree*, int);
int (*ClearTable)(Btree*, int);
int (*Cursor)(Btree*, int iTable, int wrFlag, BtCursor **ppCur);
int (*GetMeta)(Btree*, int*);
int (*UpdateMeta)(Btree*, int*);
char *(*IntegrityCheck)(Btree*, int*, int);
const char *(*GetFilename)(Btree*);
int (*Copyfile)(Btree*,Btree*);
struct Pager *(*Pager)(Btree*);
#ifdef SQLITE_TEST
int (*PageDump)(Btree*, int, int);
#endif
};
/*
** An instance of this structure defines all of the methods that can
** be executed against a cursor.
*/
struct BtCursorOps {
int (*Moveto)(BtCursor*, const void *pKey, int nKey, int *pRes);
int (*Delete)(BtCursor*);
int (*Insert)(BtCursor*, const void *pKey, int nKey,
const void *pData, int nData);
int (*First)(BtCursor*, int *pRes);
int (*Last)(BtCursor*, int *pRes);
int (*Next)(BtCursor*, int *pRes);
int (*Previous)(BtCursor*, int *pRes);
int (*KeySize)(BtCursor*, int *pSize);
int (*Key)(BtCursor*, int offset, int amt, char *zBuf);
int (*KeyCompare)(BtCursor*, const void *pKey, int nKey,
int nIgnore, int *pRes);
int (*DataSize)(BtCursor*, int *pSize);
int (*Data)(BtCursor*, int offset, int amt, char *zBuf);
int (*CloseCursor)(BtCursor*);
#ifdef SQLITE_TEST
int (*CursorDump)(BtCursor*, int*);
#endif
};
/*
** The number of 4-byte "meta" values contained on the first page of each
** database file.
*/
#define SQLITE_N_BTREE_META 10
int sqliteBtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree);
int sqliteBtreeClose(Btree*);
int sqliteBtreeSetCacheSize(Btree*, int);
int sqliteRbtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree);
int sqliteBtreeBeginTrans(Btree*);
int sqliteBtreeCommit(Btree*);
int sqliteBtreeRollback(Btree*);
int sqliteBtreeCreateTable(Btree*, int*);
int sqliteBtreeDropTable(Btree*, int);
int sqliteBtreeClearTable(Btree*, int);
int sqliteBtreeCursor(Btree*, int iTable, int wrFlag, BtCursor **ppCur);
int sqliteBtreeMoveto(BtCursor*, const void *pKey, int nKey, int *pRes);
int sqliteBtreeDelete(BtCursor*);
int sqliteBtreeInsert(BtCursor*, const void *pKey, int nKey,
const void *pData, int nData);
int sqliteBtreeFirst(BtCursor*, int *pRes);
int sqliteBtreeNext(BtCursor*, int *pRes);
int sqliteBtreeKeySize(BtCursor*, int *pSize);
int sqliteBtreeKey(BtCursor*, int offset, int amt, char *zBuf);
int sqliteBtreeKeyCompare(BtCursor*, const void *pKey, int nKey, int *pRes);
int sqliteBtreeDataSize(BtCursor*, int *pSize);
int sqliteBtreeData(BtCursor*, int offset, int amt, char *zBuf);
int sqliteBtreeCloseCursor(BtCursor*);
#define SQLITE_N_BTREE_META 4
int sqliteBtreeGetMeta(Btree*, int*);
int sqliteBtreeUpdateMeta(Btree*, int*);
#define btOps(pBt) (*((BtOps **)(pBt)))
#define btCOps(pCur) (*((BtCursorOps **)(pCur)))
#define sqliteBtreeClose(pBt) (btOps(pBt)->Close(pBt))
#define sqliteBtreeSetCacheSize(pBt, sz) (btOps(pBt)->SetCacheSize(pBt, sz))
#define sqliteBtreeSetSafetyLevel(pBt, sl) (btOps(pBt)->SetSafetyLevel(pBt, sl))
#define sqliteBtreeBeginTrans(pBt) (btOps(pBt)->BeginTrans(pBt))
#define sqliteBtreeCommit(pBt) (btOps(pBt)->Commit(pBt))
#define sqliteBtreeRollback(pBt) (btOps(pBt)->Rollback(pBt))
#define sqliteBtreeBeginCkpt(pBt) (btOps(pBt)->BeginCkpt(pBt))
#define sqliteBtreeCommitCkpt(pBt) (btOps(pBt)->CommitCkpt(pBt))
#define sqliteBtreeRollbackCkpt(pBt) (btOps(pBt)->RollbackCkpt(pBt))
#define sqliteBtreeCreateTable(pBt,piTable)\
(btOps(pBt)->CreateTable(pBt,piTable))
#define sqliteBtreeCreateIndex(pBt, piIndex)\
(btOps(pBt)->CreateIndex(pBt, piIndex))
#define sqliteBtreeDropTable(pBt, iTable) (btOps(pBt)->DropTable(pBt, iTable))
#define sqliteBtreeClearTable(pBt, iTable)\
(btOps(pBt)->ClearTable(pBt, iTable))
#define sqliteBtreeCursor(pBt, iTable, wrFlag, ppCur)\
(btOps(pBt)->Cursor(pBt, iTable, wrFlag, ppCur))
#define sqliteBtreeMoveto(pCur, pKey, nKey, pRes)\
(btCOps(pCur)->Moveto(pCur, pKey, nKey, pRes))
#define sqliteBtreeDelete(pCur) (btCOps(pCur)->Delete(pCur))
#define sqliteBtreeInsert(pCur, pKey, nKey, pData, nData) \
(btCOps(pCur)->Insert(pCur, pKey, nKey, pData, nData))
#define sqliteBtreeFirst(pCur, pRes) (btCOps(pCur)->First(pCur, pRes))
#define sqliteBtreeLast(pCur, pRes) (btCOps(pCur)->Last(pCur, pRes))
#define sqliteBtreeNext(pCur, pRes) (btCOps(pCur)->Next(pCur, pRes))
#define sqliteBtreePrevious(pCur, pRes) (btCOps(pCur)->Previous(pCur, pRes))
#define sqliteBtreeKeySize(pCur, pSize) (btCOps(pCur)->KeySize(pCur, pSize) )
#define sqliteBtreeKey(pCur, offset, amt, zBuf)\
(btCOps(pCur)->Key(pCur, offset, amt, zBuf))
#define sqliteBtreeKeyCompare(pCur, pKey, nKey, nIgnore, pRes)\
(btCOps(pCur)->KeyCompare(pCur, pKey, nKey, nIgnore, pRes))
#define sqliteBtreeDataSize(pCur, pSize) (btCOps(pCur)->DataSize(pCur, pSize))
#define sqliteBtreeData(pCur, offset, amt, zBuf)\
(btCOps(pCur)->Data(pCur, offset, amt, zBuf))
#define sqliteBtreeCloseCursor(pCur) (btCOps(pCur)->CloseCursor(pCur))
#define sqliteBtreeGetMeta(pBt, aMeta) (btOps(pBt)->GetMeta(pBt, aMeta))
#define sqliteBtreeUpdateMeta(pBt, aMeta) (btOps(pBt)->UpdateMeta(pBt, aMeta))
#define sqliteBtreeIntegrityCheck(pBt, aRoot, nRoot)\
(btOps(pBt)->IntegrityCheck(pBt, aRoot, nRoot))
#define sqliteBtreeGetFilename(pBt) (btOps(pBt)->GetFilename(pBt))
#define sqliteBtreeCopyFile(pBt1, pBt2) (btOps(pBt1)->Copyfile(pBt1, pBt2))
#define sqliteBtreePager(pBt) (btOps(pBt)->Pager(pBt))
#ifdef SQLITE_TEST
int sqliteBtreePageDump(Btree*, int, int);
int sqliteBtreeCursorDump(BtCursor*, int*);
struct Pager *sqliteBtreePager(Btree*);
char *sqliteBtreeSanityCheck(Btree*, int*, int);
#endif
#define sqliteBtreePageDump(pBt, pgno, recursive)\
(btOps(pBt)->PageDump(pBt, pgno, recursive))
#define sqliteBtreeCursorDump(pCur, aResult)\
(btCOps(pCur)->CursorDump(pCur, aResult))
int btree_native_byte_order;
#endif /* SQLITE_TEST */
#endif /* _BTREE_H_ */
+1488
View File
File diff suppressed because it is too large Load Diff
+1465 -898
View File
File diff suppressed because it is too large Load Diff
+110
View File
@@ -0,0 +1,110 @@
/*
** 2003 April 6
**
** 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 code used to implement the COPY command.
**
** $Id: copy.c,v 1.9 2004/02/25 13:47:31 drh Exp $
*/
#include "sqliteInt.h"
/*
** The COPY command is for compatibility with PostgreSQL and specificially
** for the ability to read the output of pg_dump. The format is as
** follows:
**
** COPY table FROM file [USING DELIMITERS string]
**
** "table" is an existing table name. We will read lines of code from
** file to fill this table with data. File might be "stdin". The optional
** delimiter string identifies the field separators. The default is a tab.
*/
void sqliteCopy(
Parse *pParse, /* The parser context */
SrcList *pTableName, /* The name of the table into which we will insert */
Token *pFilename, /* The file from which to obtain information */
Token *pDelimiter, /* Use this as the field delimiter */
int onError /* What to do if a constraint fails */
){
Table *pTab;
int i;
Vdbe *v;
int addr, end;
char *zFile = 0;
const char *zDb;
sqlite *db = pParse->db;
if( sqlite_malloc_failed ) goto copy_cleanup;
assert( pTableName->nSrc==1 );
pTab = sqliteSrcListLookup(pParse, pTableName);
if( pTab==0 || sqliteIsReadOnly(pParse, pTab, 0) ) goto copy_cleanup;
zFile = sqliteStrNDup(pFilename->z, pFilename->n);
sqliteDequote(zFile);
assert( pTab->iDb<db->nDb );
zDb = db->aDb[pTab->iDb].zName;
if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb)
|| sqliteAuthCheck(pParse, SQLITE_COPY, pTab->zName, zFile, zDb) ){
goto copy_cleanup;
}
v = sqliteGetVdbe(pParse);
if( v ){
sqliteBeginWriteOperation(pParse, 1, pTab->iDb);
addr = sqliteVdbeOp3(v, OP_FileOpen, 0, 0, pFilename->z, pFilename->n);
sqliteVdbeDequoteP3(v, addr);
sqliteOpenTableAndIndices(pParse, pTab, 0);
if( db->flags & SQLITE_CountRows ){
sqliteVdbeAddOp(v, OP_Integer, 0, 0); /* Initialize the row count */
}
end = sqliteVdbeMakeLabel(v);
addr = sqliteVdbeAddOp(v, OP_FileRead, pTab->nCol, end);
if( pDelimiter ){
sqliteVdbeChangeP3(v, addr, pDelimiter->z, pDelimiter->n);
sqliteVdbeDequoteP3(v, addr);
}else{
sqliteVdbeChangeP3(v, addr, "\t", 1);
}
if( pTab->iPKey>=0 ){
sqliteVdbeAddOp(v, OP_FileColumn, pTab->iPKey, 0);
sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);
}else{
sqliteVdbeAddOp(v, OP_NewRecno, 0, 0);
}
for(i=0; i<pTab->nCol; i++){
if( i==pTab->iPKey ){
/* The integer primary key column is filled with NULL since its
** value is always pulled from the record number */
sqliteVdbeAddOp(v, OP_String, 0, 0);
}else{
sqliteVdbeAddOp(v, OP_FileColumn, i, 0);
}
}
sqliteGenerateConstraintChecks(pParse, pTab, 0, 0, pTab->iPKey>=0,
0, onError, addr);
sqliteCompleteInsertion(pParse, pTab, 0, 0, 0, 0, -1);
if( (db->flags & SQLITE_CountRows)!=0 ){
sqliteVdbeAddOp(v, OP_AddImm, 1, 0); /* Increment row count */
}
sqliteVdbeAddOp(v, OP_Goto, 0, addr);
sqliteVdbeResolveLabel(v, end);
sqliteVdbeAddOp(v, OP_Noop, 0, 0);
sqliteEndWriteOperation(pParse);
if( db->flags & SQLITE_CountRows ){
sqliteVdbeAddOp(v, OP_ColumnName, 0, 1);
sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC);
sqliteVdbeAddOp(v, OP_Callback, 1, 0);
}
}
copy_cleanup:
sqliteSrcListDelete(pTableName);
sqliteFree(zFile);
return;
}
+875
View File
@@ -0,0 +1,875 @@
/*
** 2003 October 31
**
** 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 the C functions that implement date and time
** functions for SQLite.
**
** There is only one exported symbol in this file - the function
** sqliteRegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: date.c,v 1.16.2.2 2004/07/20 00:40:01 drh Exp $
**
** NOTES:
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
** in Greenwich on November 24, 4714 B.C. according to the Gregorian
** calendar system.
**
** 1970-01-01 00:00:00 is JD 2440587.5
** 2000-01-01 00:00:00 is JD 2451544.5
**
** This implemention requires years to be expressed as a 4-digit number
** which means that only dates between 0000-01-01 and 9999-12-31 can
** be represented, even though julian day numbers allow a much wider
** range of dates.
**
** The Gregorian calendar system is used for all dates and times,
** even those that predate the Gregorian calendar. Historians usually
** use the Julian calendar for dates prior to 1582-10-15 and for some
** dates afterwards, depending on locale. Beware of this difference.
**
** The conversion algorithms are implemented based on descriptions
** in the following text:
**
** Jean Meeus
** Astronomical Algorithms, 2nd Edition, 1998
** ISBM 0-943396-61-1
** Willmann-Bell, Inc
** Richmond, Virginia (USA)
*/
#include "os.h"
#include "sqliteInt.h"
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#ifndef SQLITE_OMIT_DATETIME_FUNCS
/*
** A structure for holding a single date and time.
*/
typedef struct DateTime DateTime;
struct DateTime {
double rJD; /* The julian day number */
int Y, M, D; /* Year, month, and day */
int h, m; /* Hour and minutes */
int tz; /* Timezone offset in minutes */
double s; /* Seconds */
char validYMD; /* True if Y,M,D are valid */
char validHMS; /* True if h,m,s are valid */
char validJD; /* True if rJD is valid */
char validTZ; /* True if tz is valid */
};
/*
** Convert zDate into one or more integers. Additional arguments
** come in groups of 5 as follows:
**
** N number of digits in the integer
** min minimum allowed value of the integer
** max maximum allowed value of the integer
** nextC first character after the integer
** pVal where to write the integers value.
**
** Conversions continue until one with nextC==0 is encountered.
** The function returns the number of successful conversions.
*/
static int getDigits(const char *zDate, ...){
va_list ap;
int val;
int N;
int min;
int max;
int nextC;
int *pVal;
int cnt = 0;
va_start(ap, zDate);
do{
N = va_arg(ap, int);
min = va_arg(ap, int);
max = va_arg(ap, int);
nextC = va_arg(ap, int);
pVal = va_arg(ap, int*);
val = 0;
while( N-- ){
if( !isdigit(*zDate) ){
return cnt;
}
val = val*10 + *zDate - '0';
zDate++;
}
if( val<min || val>max || (nextC!=0 && nextC!=*zDate) ){
return cnt;
}
*pVal = val;
zDate++;
cnt++;
}while( nextC );
return cnt;
}
/*
** Read text from z[] and convert into a floating point number. Return
** the number of digits converted.
*/
static int getValue(const char *z, double *pR){
const char *zEnd;
*pR = sqliteAtoF(z, &zEnd);
return zEnd - z;
}
/*
** Parse a timezone extension on the end of a date-time.
** The extension is of the form:
**
** (+/-)HH:MM
**
** If the parse is successful, write the number of minutes
** of change in *pnMin and return 0. If a parser error occurs,
** return 0.
**
** A missing specifier is not considered an error.
*/
static int parseTimezone(const char *zDate, DateTime *p){
int sgn = 0;
int nHr, nMn;
while( isspace(*zDate) ){ zDate++; }
p->tz = 0;
if( *zDate=='-' ){
sgn = -1;
}else if( *zDate=='+' ){
sgn = +1;
}else{
return *zDate!=0;
}
zDate++;
if( getDigits(zDate, 2, 0, 14, ':', &nHr, 2, 0, 59, 0, &nMn)!=2 ){
return 1;
}
zDate += 5;
p->tz = sgn*(nMn + nHr*60);
while( isspace(*zDate) ){ zDate++; }
return *zDate!=0;
}
/*
** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
** The HH, MM, and SS must each be exactly 2 digits. The
** fractional seconds FFFF can be one or more digits.
**
** Return 1 if there is a parsing error and 0 on success.
*/
static int parseHhMmSs(const char *zDate, DateTime *p){
int h, m, s;
double ms = 0.0;
if( getDigits(zDate, 2, 0, 24, ':', &h, 2, 0, 59, 0, &m)!=2 ){
return 1;
}
zDate += 5;
if( *zDate==':' ){
zDate++;
if( getDigits(zDate, 2, 0, 59, 0, &s)!=1 ){
return 1;
}
zDate += 2;
if( *zDate=='.' && isdigit(zDate[1]) ){
double rScale = 1.0;
zDate++;
while( isdigit(*zDate) ){
ms = ms*10.0 + *zDate - '0';
rScale *= 10.0;
zDate++;
}
ms /= rScale;
}
}else{
s = 0;
}
p->validJD = 0;
p->validHMS = 1;
p->h = h;
p->m = m;
p->s = s + ms;
if( parseTimezone(zDate, p) ) return 1;
p->validTZ = p->tz!=0;
return 0;
}
/*
** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume
** that the YYYY-MM-DD is according to the Gregorian calendar.
**
** Reference: Meeus page 61
*/
static void computeJD(DateTime *p){
int Y, M, D, A, B, X1, X2;
if( p->validJD ) return;
if( p->validYMD ){
Y = p->Y;
M = p->M;
D = p->D;
}else{
Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */
M = 1;
D = 1;
}
if( M<=2 ){
Y--;
M += 12;
}
A = Y/100;
B = 2 - A + (A/4);
X1 = 365.25*(Y+4716);
X2 = 30.6001*(M+1);
p->rJD = X1 + X2 + D + B - 1524.5;
p->validJD = 1;
p->validYMD = 0;
if( p->validHMS ){
p->rJD += (p->h*3600.0 + p->m*60.0 + p->s)/86400.0;
if( p->validTZ ){
p->rJD += p->tz*60/86400.0;
p->validHMS = 0;
p->validTZ = 0;
}
}
}
/*
** Parse dates of the form
**
** YYYY-MM-DD HH:MM:SS.FFF
** YYYY-MM-DD HH:MM:SS
** YYYY-MM-DD HH:MM
** YYYY-MM-DD
**
** Write the result into the DateTime structure and return 0
** on success and 1 if the input string is not a well-formed
** date.
*/
static int parseYyyyMmDd(const char *zDate, DateTime *p){
int Y, M, D, neg;
if( zDate[0]=='-' ){
zDate++;
neg = 1;
}else{
neg = 0;
}
if( getDigits(zDate,4,0,9999,'-',&Y,2,1,12,'-',&M,2,1,31,0,&D)!=3 ){
return 1;
}
zDate += 10;
while( isspace(*zDate) ){ zDate++; }
if( parseHhMmSs(zDate, p)==0 ){
/* We got the time */
}else if( *zDate==0 ){
p->validHMS = 0;
}else{
return 1;
}
p->validJD = 0;
p->validYMD = 1;
p->Y = neg ? -Y : Y;
p->M = M;
p->D = D;
if( p->validTZ ){
computeJD(p);
}
return 0;
}
/*
** Attempt to parse the given string into a Julian Day Number. Return
** the number of errors.
**
** The following are acceptable forms for the input string:
**
** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM
** DDDD.DD
** now
**
** In the first form, the +/-HH:MM is always optional. The fractional
** seconds extension (the ".FFF") is optional. The seconds portion
** (":SS.FFF") is option. The year and date can be omitted as long
** as there is a time string. The time string can be omitted as long
** as there is a year and date.
*/
static int parseDateOrTime(const char *zDate, DateTime *p){
memset(p, 0, sizeof(*p));
if( parseYyyyMmDd(zDate,p)==0 ){
return 0;
}else if( parseHhMmSs(zDate, p)==0 ){
return 0;
}else if( sqliteStrICmp(zDate,"now")==0){
double r;
if( sqliteOsCurrentTime(&r)==0 ){
p->rJD = r;
p->validJD = 1;
return 0;
}
return 1;
}else if( sqliteIsNumber(zDate) ){
p->rJD = sqliteAtoF(zDate, 0);
p->validJD = 1;
return 0;
}
return 1;
}
/*
** Compute the Year, Month, and Day from the julian day number.
*/
static void computeYMD(DateTime *p){
int Z, A, B, C, D, E, X1;
if( p->validYMD ) return;
if( !p->validJD ){
p->Y = 2000;
p->M = 1;
p->D = 1;
}else{
Z = p->rJD + 0.5;
A = (Z - 1867216.25)/36524.25;
A = Z + 1 + A - (A/4);
B = A + 1524;
C = (B - 122.1)/365.25;
D = 365.25*C;
E = (B-D)/30.6001;
X1 = 30.6001*E;
p->D = B - D - X1;
p->M = E<14 ? E-1 : E-13;
p->Y = p->M>2 ? C - 4716 : C - 4715;
}
p->validYMD = 1;
}
/*
** Compute the Hour, Minute, and Seconds from the julian day number.
*/
static void computeHMS(DateTime *p){
int Z, s;
if( p->validHMS ) return;
Z = p->rJD + 0.5;
s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5;
p->s = 0.001*s;
s = p->s;
p->s -= s;
p->h = s/3600;
s -= p->h*3600;
p->m = s/60;
p->s += s - p->m*60;
p->validHMS = 1;
}
/*
** Compute both YMD and HMS
*/
static void computeYMD_HMS(DateTime *p){
computeYMD(p);
computeHMS(p);
}
/*
** Clear the YMD and HMS and the TZ
*/
static void clearYMD_HMS_TZ(DateTime *p){
p->validYMD = 0;
p->validHMS = 0;
p->validTZ = 0;
}
/*
** Compute the difference (in days) between localtime and UTC (a.k.a. GMT)
** for the time value p where p is in UTC.
*/
static double localtimeOffset(DateTime *p){
DateTime x, y;
time_t t;
struct tm *pTm;
x = *p;
computeYMD_HMS(&x);
if( x.Y<1971 || x.Y>=2038 ){
x.Y = 2000;
x.M = 1;
x.D = 1;
x.h = 0;
x.m = 0;
x.s = 0.0;
} else {
int s = x.s + 0.5;
x.s = s;
}
x.tz = 0;
x.validJD = 0;
computeJD(&x);
t = (x.rJD-2440587.5)*86400.0 + 0.5;
sqliteOsEnterMutex();
pTm = localtime(&t);
y.Y = pTm->tm_year + 1900;
y.M = pTm->tm_mon + 1;
y.D = pTm->tm_mday;
y.h = pTm->tm_hour;
y.m = pTm->tm_min;
y.s = pTm->tm_sec;
sqliteOsLeaveMutex();
y.validYMD = 1;
y.validHMS = 1;
y.validJD = 0;
y.validTZ = 0;
computeJD(&y);
return y.rJD - x.rJD;
}
/*
** Process a modifier to a date-time stamp. The modifiers are
** as follows:
**
** NNN days
** NNN hours
** NNN minutes
** NNN.NNNN seconds
** NNN months
** NNN years
** start of month
** start of year
** start of week
** start of day
** weekday N
** unixepoch
** localtime
** utc
**
** Return 0 on success and 1 if there is any kind of error.
*/
static int parseModifier(const char *zMod, DateTime *p){
int rc = 1;
int n;
double r;
char *z, zBuf[30];
z = zBuf;
for(n=0; n<sizeof(zBuf)-1 && zMod[n]; n++){
z[n] = tolower(zMod[n]);
}
z[n] = 0;
switch( z[0] ){
case 'l': {
/* localtime
**
** Assuming the current time value is UTC (a.k.a. GMT), shift it to
** show local time.
*/
if( strcmp(z, "localtime")==0 ){
computeJD(p);
p->rJD += localtimeOffset(p);
clearYMD_HMS_TZ(p);
rc = 0;
}
break;
}
case 'u': {
/*
** unixepoch
**
** Treat the current value of p->rJD as the number of
** seconds since 1970. Convert to a real julian day number.
*/
if( strcmp(z, "unixepoch")==0 && p->validJD ){
p->rJD = p->rJD/86400.0 + 2440587.5;
clearYMD_HMS_TZ(p);
rc = 0;
}else if( strcmp(z, "utc")==0 ){
double c1;
computeJD(p);
c1 = localtimeOffset(p);
p->rJD -= c1;
clearYMD_HMS_TZ(p);
p->rJD += c1 - localtimeOffset(p);
rc = 0;
}
break;
}
case 'w': {
/*
** weekday N
**
** Move the date to the same time on the next occurrance of
** weekday N where 0==Sunday, 1==Monday, and so forth. If the
** date is already on the appropriate weekday, this is a no-op.
*/
if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0
&& (n=r)==r && n>=0 && r<7 ){
int Z;
computeYMD_HMS(p);
p->validTZ = 0;
p->validJD = 0;
computeJD(p);
Z = p->rJD + 1.5;
Z %= 7;
if( Z>n ) Z -= 7;
p->rJD += n - Z;
clearYMD_HMS_TZ(p);
rc = 0;
}
break;
}
case 's': {
/*
** start of TTTTT
**
** Move the date backwards to the beginning of the current day,
** or month or year.
*/
if( strncmp(z, "start of ", 9)!=0 ) break;
z += 9;
computeYMD(p);
p->validHMS = 1;
p->h = p->m = 0;
p->s = 0.0;
p->validTZ = 0;
p->validJD = 0;
if( strcmp(z,"month")==0 ){
p->D = 1;
rc = 0;
}else if( strcmp(z,"year")==0 ){
computeYMD(p);
p->M = 1;
p->D = 1;
rc = 0;
}else if( strcmp(z,"day")==0 ){
rc = 0;
}
break;
}
case '+':
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': {
n = getValue(z, &r);
if( n<=0 ) break;
if( z[n]==':' ){
/* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the
** specified number of hours, minutes, seconds, and fractional seconds
** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be
** omitted.
*/
const char *z2 = z;
DateTime tx;
int day;
if( !isdigit(*z2) ) z2++;
memset(&tx, 0, sizeof(tx));
if( parseHhMmSs(z2, &tx) ) break;
computeJD(&tx);
tx.rJD -= 0.5;
day = (int)tx.rJD;
tx.rJD -= day;
if( z[0]=='-' ) tx.rJD = -tx.rJD;
computeJD(p);
clearYMD_HMS_TZ(p);
p->rJD += tx.rJD;
rc = 0;
break;
}
z += n;
while( isspace(z[0]) ) z++;
n = strlen(z);
if( n>10 || n<3 ) break;
if( z[n-1]=='s' ){ z[n-1] = 0; n--; }
computeJD(p);
rc = 0;
if( n==3 && strcmp(z,"day")==0 ){
p->rJD += r;
}else if( n==4 && strcmp(z,"hour")==0 ){
p->rJD += r/24.0;
}else if( n==6 && strcmp(z,"minute")==0 ){
p->rJD += r/(24.0*60.0);
}else if( n==6 && strcmp(z,"second")==0 ){
p->rJD += r/(24.0*60.0*60.0);
}else if( n==5 && strcmp(z,"month")==0 ){
int x, y;
computeYMD_HMS(p);
p->M += r;
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
p->Y += x;
p->M -= x*12;
p->validJD = 0;
computeJD(p);
y = r;
if( y!=r ){
p->rJD += (r - y)*30.0;
}
}else if( n==4 && strcmp(z,"year")==0 ){
computeYMD_HMS(p);
p->Y += r;
p->validJD = 0;
computeJD(p);
}else{
rc = 1;
}
clearYMD_HMS_TZ(p);
break;
}
default: {
break;
}
}
return rc;
}
/*
** Process time function arguments. argv[0] is a date-time stamp.
** argv[1] and following are modifiers. Parse them all and write
** the resulting time into the DateTime structure p. Return 0
** on success and 1 if there are any errors.
*/
static int isDate(int argc, const char **argv, DateTime *p){
int i;
if( argc==0 ) return 1;
if( argv[0]==0 || parseDateOrTime(argv[0], p) ) return 1;
for(i=1; i<argc; i++){
if( argv[i]==0 || parseModifier(argv[i], p) ) return 1;
}
return 0;
}
/*
** The following routines implement the various date and time functions
** of SQLite.
*/
/*
** julianday( TIMESTRING, MOD, MOD, ...)
**
** Return the julian day number of the date specified in the arguments
*/
static void juliandayFunc(sqlite_func *context, int argc, const char **argv){
DateTime x;
if( isDate(argc, argv, &x)==0 ){
computeJD(&x);
sqlite_set_result_double(context, x.rJD);
}
}
/*
** datetime( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-DD HH:MM:SS
*/
static void datetimeFunc(sqlite_func *context, int argc, const char **argv){
DateTime x;
if( isDate(argc, argv, &x)==0 ){
char zBuf[100];
computeYMD_HMS(&x);
sprintf(zBuf, "%04d-%02d-%02d %02d:%02d:%02d",x.Y, x.M, x.D, x.h, x.m,
(int)(x.s));
sqlite_set_result_string(context, zBuf, -1);
}
}
/*
** time( TIMESTRING, MOD, MOD, ...)
**
** Return HH:MM:SS
*/
static void timeFunc(sqlite_func *context, int argc, const char **argv){
DateTime x;
if( isDate(argc, argv, &x)==0 ){
char zBuf[100];
computeHMS(&x);
sprintf(zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
sqlite_set_result_string(context, zBuf, -1);
}
}
/*
** date( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-DD
*/
static void dateFunc(sqlite_func *context, int argc, const char **argv){
DateTime x;
if( isDate(argc, argv, &x)==0 ){
char zBuf[100];
computeYMD(&x);
sprintf(zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
sqlite_set_result_string(context, zBuf, -1);
}
}
/*
** strftime( FORMAT, TIMESTRING, MOD, MOD, ...)
**
** Return a string described by FORMAT. Conversions as follows:
**
** %d day of month
** %f ** fractional seconds SS.SSS
** %H hour 00-24
** %j day of year 000-366
** %J ** Julian day number
** %m month 01-12
** %M minute 00-59
** %s seconds since 1970-01-01
** %S seconds 00-59
** %w day of week 0-6 sunday==0
** %W week of year 00-53
** %Y year 0000-9999
** %% %
*/
static void strftimeFunc(sqlite_func *context, int argc, const char **argv){
DateTime x;
int n, i, j;
char *z;
const char *zFmt = argv[0];
char zBuf[100];
if( argv[0]==0 || isDate(argc-1, argv+1, &x) ) return;
for(i=0, n=1; zFmt[i]; i++, n++){
if( zFmt[i]=='%' ){
switch( zFmt[i+1] ){
case 'd':
case 'H':
case 'm':
case 'M':
case 'S':
case 'W':
n++;
/* fall thru */
case 'w':
case '%':
break;
case 'f':
n += 8;
break;
case 'j':
n += 3;
break;
case 'Y':
n += 8;
break;
case 's':
case 'J':
n += 50;
break;
default:
return; /* ERROR. return a NULL */
}
i++;
}
}
if( n<sizeof(zBuf) ){
z = zBuf;
}else{
z = sqliteMalloc( n );
if( z==0 ) return;
}
computeJD(&x);
computeYMD_HMS(&x);
for(i=j=0; zFmt[i]; i++){
if( zFmt[i]!='%' ){
z[j++] = zFmt[i];
}else{
i++;
switch( zFmt[i] ){
case 'd': sprintf(&z[j],"%02d",x.D); j+=2; break;
case 'f': {
int s = x.s;
int ms = (x.s - s)*1000.0;
sprintf(&z[j],"%02d.%03d",s,ms);
j += strlen(&z[j]);
break;
}
case 'H': sprintf(&z[j],"%02d",x.h); j+=2; break;
case 'W': /* Fall thru */
case 'j': {
int n; /* Number of days since 1st day of year */
DateTime y = x;
y.validJD = 0;
y.M = 1;
y.D = 1;
computeJD(&y);
n = x.rJD - y.rJD;
if( zFmt[i]=='W' ){
int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */
wd = ((int)(x.rJD+0.5)) % 7;
sprintf(&z[j],"%02d",(n+7-wd)/7);
j += 2;
}else{
sprintf(&z[j],"%03d",n+1);
j += 3;
}
break;
}
case 'J': sprintf(&z[j],"%.16g",x.rJD); j+=strlen(&z[j]); break;
case 'm': sprintf(&z[j],"%02d",x.M); j+=2; break;
case 'M': sprintf(&z[j],"%02d",x.m); j+=2; break;
case 's': {
sprintf(&z[j],"%d",(int)((x.rJD-2440587.5)*86400.0 + 0.5));
j += strlen(&z[j]);
break;
}
case 'S': sprintf(&z[j],"%02d",(int)(x.s+0.5)); j+=2; break;
case 'w': z[j++] = (((int)(x.rJD+1.5)) % 7) + '0'; break;
case 'Y': sprintf(&z[j],"%04d",x.Y); j+=strlen(&z[j]); break;
case '%': z[j++] = '%'; break;
}
}
}
z[j] = 0;
sqlite_set_result_string(context, z, -1);
if( z!=zBuf ){
sqliteFree(z);
}
}
#endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */
/*
** This function registered all of the above C functions as SQL
** functions. This should be the only routine in this file with
** external linkage.
*/
void sqliteRegisterDateTimeFunctions(sqlite *db){
#ifndef SQLITE_OMIT_DATETIME_FUNCS
static struct {
char *zName;
int nArg;
int dataType;
void (*xFunc)(sqlite_func*,int,const char**);
} aFuncs[] = {
{ "julianday", -1, SQLITE_NUMERIC, juliandayFunc },
{ "date", -1, SQLITE_TEXT, dateFunc },
{ "time", -1, SQLITE_TEXT, timeFunc },
{ "datetime", -1, SQLITE_TEXT, datetimeFunc },
{ "strftime", -1, SQLITE_TEXT, strftimeFunc },
};
int i;
for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
sqlite_create_function(db, aFuncs[i].zName,
aFuncs[i].nArg, aFuncs[i].xFunc, 0);
if( aFuncs[i].xFunc ){
sqlite_function_type(db, aFuncs[i].zName, aFuncs[i].dataType);
}
}
#endif
}
+273 -71
View File
@@ -12,65 +12,117 @@
** This file contains C code routines that are called by the parser
** to handle DELETE FROM statements.
**
** $Id: delete.c,v 1.18 2001/10/15 00:44:36 drh Exp $
** $Id: delete.c,v 1.61 2004/02/24 01:05:32 drh Exp $
*/
#include "sqliteInt.h"
/*
** Look up every table that is named in pSrc. If any table is not found,
** add an error message to pParse->zErrMsg and return NULL. If all tables
** are found, return a pointer to the last table.
*/
Table *sqliteSrcListLookup(Parse *pParse, SrcList *pSrc){
Table *pTab = 0;
int i;
for(i=0; i<pSrc->nSrc; i++){
const char *zTab = pSrc->a[i].zName;
const char *zDb = pSrc->a[i].zDatabase;
pTab = sqliteLocateTable(pParse, zTab, zDb);
pSrc->a[i].pTab = pTab;
}
return pTab;
}
/*
** Check to make sure the given table is writable. If it is not
** writable, generate an error message and return 1. If it is
** writable return 0;
*/
int sqliteIsReadOnly(Parse *pParse, Table *pTab, int viewOk){
if( pTab->readOnly ){
sqliteErrorMsg(pParse, "table %s may not be modified", pTab->zName);
return 1;
}
if( !viewOk && pTab->pSelect ){
sqliteErrorMsg(pParse, "cannot modify %s because it is a view",pTab->zName);
return 1;
}
return 0;
}
/*
** Process a DELETE FROM statement.
*/
void sqliteDeleteFrom(
Parse *pParse, /* The parser context */
Token *pTableName, /* The table from which we should delete things */
SrcList *pTabList, /* The table from which we should delete things */
Expr *pWhere /* The WHERE clause. May be null */
){
Vdbe *v; /* The virtual database engine */
Table *pTab; /* The table from which records will be deleted */
IdList *pTabList; /* An ID list holding pTab and nothing else */
const char *zDb; /* Name of database holding pTab */
int end, addr; /* A couple addresses of generated code */
int i; /* Loop counter */
WhereInfo *pWInfo; /* Information about the WHERE clause */
Index *pIdx; /* For looping over indices of the table */
int base; /* Index of the first available table cursor */
int iCur; /* VDBE Cursor number for pTab */
sqlite *db; /* Main database structure */
int openOp; /* Opcode used to open a cursor to the table */
int isView; /* True if attempting to delete from a view */
AuthContext sContext; /* Authorization context */
int row_triggers_exist = 0; /* True if any triggers exist */
int before_triggers; /* True if there are BEFORE triggers */
int after_triggers; /* True if there are AFTER triggers */
int oldIdx = -1; /* Cursor for the OLD table of AFTER triggers */
sContext.pParse = 0;
if( pParse->nErr || sqlite_malloc_failed ){
pTabList = 0;
goto delete_from_cleanup;
}
db = pParse->db;
assert( pTabList->nSrc==1 );
/* Locate the table which we want to delete. This table has to be
** put in an IdList structure because some of the subroutines we
** put in an SrcList structure because some of the subroutines we
** will be calling are designed to work with multiple tables and expect
** an IdList* parameter instead of just a Table* parameger.
** an SrcList* parameter instead of just a Table* parameter.
*/
pTabList = sqliteIdListAppend(0, pTableName);
if( pTabList==0 ) goto delete_from_cleanup;
for(i=0; i<pTabList->nId; i++){
pTabList->a[i].pTab = sqliteFindTable(db, pTabList->a[i].zName);
if( pTabList->a[i].pTab==0 ){
sqliteSetString(&pParse->zErrMsg, "no such table: ",
pTabList->a[i].zName, 0);
pParse->nErr++;
goto delete_from_cleanup;
}
if( pTabList->a[i].pTab->readOnly ){
sqliteSetString(&pParse->zErrMsg, "table ", pTabList->a[i].zName,
" may not be modified", 0);
pParse->nErr++;
goto delete_from_cleanup;
}
pTab = sqliteSrcListLookup(pParse, pTabList);
if( pTab==0 ) goto delete_from_cleanup;
before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,
TK_DELETE, TK_BEFORE, TK_ROW, 0);
after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,
TK_DELETE, TK_AFTER, TK_ROW, 0);
row_triggers_exist = before_triggers || after_triggers;
isView = pTab->pSelect!=0;
if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){
goto delete_from_cleanup;
}
assert( pTab->iDb<db->nDb );
zDb = db->aDb[pTab->iDb].zName;
if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
goto delete_from_cleanup;
}
/* If pTab is really a view, make sure it has been initialized.
*/
if( isView && sqliteViewGetColumnNames(pParse, pTab) ){
goto delete_from_cleanup;
}
/* Allocate a cursor used to store the old.* data for a trigger.
*/
if( row_triggers_exist ){
oldIdx = pParse->nTab++;
}
pTab = pTabList->a[0].pTab;
/* Resolve the column names in all the expressions.
*/
assert( pTabList->nSrc==1 );
iCur = pTabList->a[0].iCursor = pParse->nTab++;
if( pWhere ){
sqliteExprResolveInSelect(pParse, pWhere);
if( sqliteExprResolveIds(pParse, pTabList, pWhere) ){
if( sqliteExprResolveIds(pParse, pTabList, 0, pWhere) ){
goto delete_from_cleanup;
}
if( sqliteExprCheck(pParse, pWhere, 0, 0) ){
@@ -78,14 +130,27 @@ void sqliteDeleteFrom(
}
}
/* Start the view context
*/
if( isView ){
sqliteAuthContextPush(pParse, &sContext, pTab->zName);
}
/* Begin generating code.
*/
v = sqliteGetVdbe(pParse);
if( v==0 ) goto delete_from_cleanup;
if( (db->flags & SQLITE_InTrans)==0 ){
sqliteVdbeAddOp(v, OP_Transaction, 0, 0);
sqliteVdbeAddOp(v, OP_VerifyCookie, db->schema_cookie, 0);
pParse->schemaVerified = 1;
if( v==0 ){
goto delete_from_cleanup;
}
sqliteBeginWriteOperation(pParse, row_triggers_exist, pTab->iDb);
/* If we are trying to delete from a view, construct that view into
** a temporary table.
*/
if( isView ){
Select *pView = sqliteSelectDup(pTab->pSelect);
sqliteSelect(pParse, pView, SRT_TempTable, iCur, 0, 0, 0);
sqliteSelectDelete(pView);
}
/* Initialize the counter of the number of rows deleted, if
@@ -96,37 +161,40 @@ void sqliteDeleteFrom(
}
/* Special case: A DELETE without a WHERE clause deletes everything.
** It is easier just to erase the whole table.
** It is easier just to erase the whole table. Note, however, that
** this means that the row change count will be incorrect.
*/
if( pWhere==0 ){
if( pWhere==0 && !row_triggers_exist ){
if( db->flags & SQLITE_CountRows ){
/* If counting rows deleted, just count the total number of
** entries in the table. */
int endOfLoop = sqliteVdbeMakeLabel(v);
int addr;
openOp = pTab->isTemp ? OP_OpenAux : OP_Open;
sqliteVdbeAddOp(v, openOp, 0, pTab->tnum);
sqliteVdbeAddOp(v, OP_Rewind, 0, 0);
addr = sqliteVdbeAddOp(v, OP_Next, 0, endOfLoop);
sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
sqliteVdbeAddOp(v, OP_Goto, 0, addr);
if( !isView ){
sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
}
sqliteVdbeAddOp(v, OP_Rewind, iCur, sqliteVdbeCurrentAddr(v)+2);
addr = sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
sqliteVdbeAddOp(v, OP_Next, iCur, addr);
sqliteVdbeResolveLabel(v, endOfLoop);
sqliteVdbeAddOp(v, OP_Close, 0, 0);
sqliteVdbeAddOp(v, OP_Close, iCur, 0);
}
sqliteVdbeAddOp(v, OP_Clear, pTab->tnum, pTab->isTemp);
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
sqliteVdbeAddOp(v, OP_Clear, pIdx->tnum, pTab->isTemp);
if( !isView ){
sqliteVdbeAddOp(v, OP_Clear, pTab->tnum, pTab->iDb);
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
sqliteVdbeAddOp(v, OP_Clear, pIdx->tnum, pIdx->iDb);
}
}
}
/* The usual case: There is a WHERE clause so we have to scan through
** the table an pick which records to delete.
** the table and pick which records to delete.
*/
else{
/* Begin the database scan
*/
sqliteVdbeAddOp(v, OP_ListOpen, 0, 0);
pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1);
pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1, 0);
if( pWInfo==0 ) goto delete_from_cleanup;
/* Remember the key of every item to be deleted.
@@ -140,52 +208,186 @@ void sqliteDeleteFrom(
*/
sqliteWhereEnd(pWInfo);
/* Open the pseudo-table used to store OLD if there are triggers.
*/
if( row_triggers_exist ){
sqliteVdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);
}
/* Delete every item whose key was written to the list during the
** database scan. We have to delete items after the scan is complete
** because deleting an item can change the scan order.
*/
base = pParse->nTab;
sqliteVdbeAddOp(v, OP_ListRewind, 0, 0);
openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite;
sqliteVdbeAddOp(v, openOp, base, pTab->tnum);
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
sqliteVdbeAddOp(v, openOp, base+i, pIdx->tnum);
}
end = sqliteVdbeMakeLabel(v);
addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end);
sqliteVdbeAddOp(v, OP_MoveTo, base, 0);
if( pTab->pIndex ){
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
int j;
sqliteVdbeAddOp(v, OP_Recno, base, 0);
for(j=0; j<pIdx->nColumn; j++){
sqliteVdbeAddOp(v, OP_Column, base, pIdx->aiColumn[j]);
}
sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
sqliteVdbeAddOp(v, OP_DeleteIdx, base+i, 0);
/* This is the beginning of the delete loop when there are
** row triggers.
*/
if( row_triggers_exist ){
addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end);
sqliteVdbeAddOp(v, OP_Dup, 0, 0);
if( !isView ){
sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
}
sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0);
sqliteVdbeAddOp(v, OP_Recno, iCur, 0);
sqliteVdbeAddOp(v, OP_RowData, iCur, 0);
sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
if( !isView ){
sqliteVdbeAddOp(v, OP_Close, iCur, 0);
}
sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1,
oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
addr);
}
sqliteVdbeAddOp(v, OP_Delete, base, 0);
if( !isView ){
/* Open cursors for the table we are deleting from and all its
** indices. If there are row triggers, this happens inside the
** OP_ListRead loop because the cursor have to all be closed
** before the trigger fires. If there are no row triggers, the
** cursors are opened only once on the outside the loop.
*/
pParse->nTab = iCur + 1;
sqliteOpenTableAndIndices(pParse, pTab, iCur);
/* This is the beginning of the delete loop when there are no
** row triggers */
if( !row_triggers_exist ){
addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end);
}
/* Delete the row */
sqliteGenerateRowDelete(db, v, pTab, iCur, pParse->trigStack==0);
}
/* If there are row triggers, close all cursors then invoke
** the AFTER triggers
*/
if( row_triggers_exist ){
if( !isView ){
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
}
sqliteVdbeAddOp(v, OP_Close, iCur, 0);
}
sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1,
oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
addr);
}
/* End of the delete loop */
sqliteVdbeAddOp(v, OP_Goto, 0, addr);
sqliteVdbeResolveLabel(v, end);
sqliteVdbeAddOp(v, OP_ListClose, 0, 0);
}
if( (db->flags & SQLITE_InTrans)==0 ){
sqliteVdbeAddOp(v, OP_Commit, 0, 0);
sqliteVdbeAddOp(v, OP_ListReset, 0, 0);
/* Close the cursors after the loop if there are no row triggers */
if( !row_triggers_exist ){
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
}
sqliteVdbeAddOp(v, OP_Close, iCur, 0);
pParse->nTab = iCur;
}
}
sqliteVdbeAddOp(v, OP_SetCounts, 0, 0);
sqliteEndWriteOperation(pParse);
/*
** Return the number of rows that were deleted.
*/
if( db->flags & SQLITE_CountRows ){
sqliteVdbeAddOp(v, OP_ColumnCount, 1, 0);
sqliteVdbeAddOp(v, OP_ColumnName, 0, 0);
sqliteVdbeAddOp(v, OP_ColumnName, 0, 1);
sqliteVdbeChangeP3(v, -1, "rows deleted", P3_STATIC);
sqliteVdbeAddOp(v, OP_Callback, 1, 0);
}
delete_from_cleanup:
sqliteIdListDelete(pTabList);
sqliteAuthContextPop(&sContext);
sqliteSrcListDelete(pTabList);
sqliteExprDelete(pWhere);
return;
}
/*
** This routine generates VDBE code that causes a single row of a
** single table to be deleted.
**
** The VDBE must be in a particular state when this routine is called.
** These are the requirements:
**
** 1. A read/write cursor pointing to pTab, the table containing the row
** to be deleted, must be opened as cursor number "base".
**
** 2. Read/write cursors for all indices of pTab must be open as
** cursor number base+i for the i-th index.
**
** 3. The record number of the row to be deleted must be on the top
** of the stack.
**
** This routine pops the top of the stack to remove the record number
** and then generates code to remove both the table record and all index
** entries that point to that record.
*/
void sqliteGenerateRowDelete(
sqlite *db, /* The database containing the index */
Vdbe *v, /* Generate code into this VDBE */
Table *pTab, /* Table containing the row to be deleted */
int iCur, /* Cursor number for the table */
int count /* Increment the row change counter */
){
int addr;
addr = sqliteVdbeAddOp(v, OP_NotExists, iCur, 0);
sqliteGenerateRowIndexDelete(db, v, pTab, iCur, 0);
sqliteVdbeAddOp(v, OP_Delete, iCur,
(count?OPFLAG_NCHANGE:0) | OPFLAG_CSCHANGE);
sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v));
}
/*
** This routine generates VDBE code that causes the deletion of all
** index entries associated with a single row of a single table.
**
** The VDBE must be in a particular state when this routine is called.
** These are the requirements:
**
** 1. A read/write cursor pointing to pTab, the table containing the row
** to be deleted, must be opened as cursor number "iCur".
**
** 2. Read/write cursors for all indices of pTab must be open as
** cursor number iCur+i for the i-th index.
**
** 3. The "iCur" cursor must be pointing to the row that is to be
** deleted.
*/
void sqliteGenerateRowIndexDelete(
sqlite *db, /* The database containing the index */
Vdbe *v, /* Generate code into this VDBE */
Table *pTab, /* Table containing the row to be deleted */
int iCur, /* Cursor number for the table */
char *aIdxUsed /* Only delete if aIdxUsed!=0 && aIdxUsed[i]!=0 */
){
int i;
Index *pIdx;
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
int j;
if( aIdxUsed!=0 && aIdxUsed[i-1]==0 ) continue;
sqliteVdbeAddOp(v, OP_Recno, iCur, 0);
for(j=0; j<pIdx->nColumn; j++){
int idx = pIdx->aiColumn[j];
if( idx==pTab->iPKey ){
sqliteVdbeAddOp(v, OP_Dup, j, 0);
}else{
sqliteVdbeAddOp(v, OP_Column, iCur, idx);
}
}
sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx);
sqliteVdbeAddOp(v, OP_IdxDelete, iCur+i, 0);
}
}
+254
View File
@@ -0,0 +1,254 @@
/*
** 2002 April 25
**
** 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 helper routines used to translate binary data into
** a null-terminated string (suitable for use in SQLite) and back again.
** These are convenience routines for use by people who want to store binary
** data in an SQLite database. The code in this file is not used by any other
** part of the SQLite library.
**
** $Id: encode.c,v 1.12 2004/03/17 18:44:46 drh Exp $
*/
#include <string.h>
#include <assert.h>
/*
** How This Encoder Works
**
** The output is allowed to contain any character except 0x27 (') and
** 0x00. This is accomplished by using an escape character to encode
** 0x27 and 0x00 as a two-byte sequence. The escape character is always
** 0x01. An 0x00 is encoded as the two byte sequence 0x01 0x01. The
** 0x27 character is encoded as the two byte sequence 0x01 0x28. Finally,
** the escape character itself is encoded as the two-character sequence
** 0x01 0x02.
**
** To summarize, the encoder works by using an escape sequences as follows:
**
** 0x00 -> 0x01 0x01
** 0x01 -> 0x01 0x02
** 0x27 -> 0x01 0x28
**
** If that were all the encoder did, it would work, but in certain cases
** it could double the size of the encoded string. For example, to
** encode a string of 100 0x27 characters would require 100 instances of
** the 0x01 0x03 escape sequence resulting in a 200-character output.
** We would prefer to keep the size of the encoded string smaller than
** this.
**
** To minimize the encoding size, we first add a fixed offset value to each
** byte in the sequence. The addition is modulo 256. (That is to say, if
** the sum of the original character value and the offset exceeds 256, then
** the higher order bits are truncated.) The offset is chosen to minimize
** the number of characters in the string that need to be escaped. For
** example, in the case above where the string was composed of 100 0x27
** characters, the offset might be 0x01. Each of the 0x27 characters would
** then be converted into an 0x28 character which would not need to be
** escaped at all and so the 100 character input string would be converted
** into just 100 characters of output. Actually 101 characters of output -
** we have to record the offset used as the first byte in the sequence so
** that the string can be decoded. Since the offset value is stored as
** part of the output string and the output string is not allowed to contain
** characters 0x00 or 0x27, the offset cannot be 0x00 or 0x27.
**
** Here, then, are the encoding steps:
**
** (1) Choose an offset value and make it the first character of
** output.
**
** (2) Copy each input character into the output buffer, one by
** one, adding the offset value as you copy.
**
** (3) If the value of an input character plus offset is 0x00, replace
** that one character by the two-character sequence 0x01 0x01.
** If the sum is 0x01, replace it with 0x01 0x02. If the sum
** is 0x27, replace it with 0x01 0x03.
**
** (4) Put a 0x00 terminator at the end of the output.
**
** Decoding is obvious:
**
** (5) Copy encoded characters except the first into the decode
** buffer. Set the first encoded character aside for use as
** the offset in step 7 below.
**
** (6) Convert each 0x01 0x01 sequence into a single character 0x00.
** Convert 0x01 0x02 into 0x01. Convert 0x01 0x28 into 0x27.
**
** (7) Subtract the offset value that was the first character of
** the encoded buffer from all characters in the output buffer.
**
** The only tricky part is step (1) - how to compute an offset value to
** minimize the size of the output buffer. This is accomplished by testing
** all offset values and picking the one that results in the fewest number
** of escapes. To do that, we first scan the entire input and count the
** number of occurances of each character value in the input. Suppose
** the number of 0x00 characters is N(0), the number of occurances of 0x01
** is N(1), and so forth up to the number of occurances of 0xff is N(255).
** An offset of 0 is not allowed so we don't have to test it. The number
** of escapes required for an offset of 1 is N(1)+N(2)+N(40). The number
** of escapes required for an offset of 2 is N(2)+N(3)+N(41). And so forth.
** In this way we find the offset that gives the minimum number of escapes,
** and thus minimizes the length of the output string.
*/
/*
** Encode a binary buffer "in" of size n bytes so that it contains
** no instances of characters '\'' or '\000'. The output is
** null-terminated and can be used as a string value in an INSERT
** or UPDATE statement. Use sqlite_decode_binary() to convert the
** string back into its original binary.
**
** The result is written into a preallocated output buffer "out".
** "out" must be able to hold at least 2 +(257*n)/254 bytes.
** In other words, the output will be expanded by as much as 3
** bytes for every 254 bytes of input plus 2 bytes of fixed overhead.
** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.)
**
** The return value is the number of characters in the encoded
** string, excluding the "\000" terminator.
**
** If out==NULL then no output is generated but the routine still returns
** the number of characters that would have been generated if out had
** not been NULL.
*/
int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out){
int i, j, e, m;
unsigned char x;
int cnt[256];
if( n<=0 ){
if( out ){
out[0] = 'x';
out[1] = 0;
}
return 1;
}
memset(cnt, 0, sizeof(cnt));
for(i=n-1; i>=0; i--){ cnt[in[i]]++; }
m = n;
for(i=1; i<256; i++){
int sum;
if( i=='\'' ) continue;
sum = cnt[i] + cnt[(i+1)&0xff] + cnt[(i+'\'')&0xff];
if( sum<m ){
m = sum;
e = i;
if( m==0 ) break;
}
}
if( out==0 ){
return n+m+1;
}
out[0] = e;
j = 1;
for(i=0; i<n; i++){
x = in[i] - e;
if( x==0 || x==1 || x=='\''){
out[j++] = 1;
x++;
}
out[j++] = x;
}
out[j] = 0;
assert( j==n+m+1 );
return j;
}
/*
** Decode the string "in" into binary data and write it into "out".
** This routine reverses the encoding created by sqlite_encode_binary().
** The output will always be a few bytes less than the input. The number
** of bytes of output is returned. If the input is not a well-formed
** encoding, -1 is returned.
**
** The "in" and "out" parameters may point to the same buffer in order
** to decode a string in place.
*/
int sqlite_decode_binary(const unsigned char *in, unsigned char *out){
int i, e;
unsigned char c;
e = *(in++);
i = 0;
while( (c = *(in++))!=0 ){
if( c==1 ){
c = *(in++) - 1;
}
out[i++] = c + e;
}
return i;
}
#ifdef ENCODER_TEST
#include <stdio.h>
/*
** The subroutines above are not tested by the usual test suite. To test
** these routines, compile just this one file with a -DENCODER_TEST=1 option
** and run the result.
*/
int main(int argc, char **argv){
int i, j, n, m, nOut, nByteIn, nByteOut;
unsigned char in[30000];
unsigned char out[33000];
nByteIn = nByteOut = 0;
for(i=0; i<sizeof(in); i++){
printf("Test %d: ", i+1);
n = rand() % (i+1);
if( i%100==0 ){
int k;
for(j=k=0; j<n; j++){
/* if( k==0 || k=='\'' ) k++; */
in[j] = k;
k = (k+1)&0xff;
}
}else{
for(j=0; j<n; j++) in[j] = rand() & 0xff;
}
nByteIn += n;
nOut = sqlite_encode_binary(in, n, out);
nByteOut += nOut;
if( nOut!=strlen(out) ){
printf(" ERROR return value is %d instead of %d\n", nOut, strlen(out));
exit(1);
}
if( nOut!=sqlite_encode_binary(in, n, 0) ){
printf(" ERROR actual output size disagrees with predicted size\n");
exit(1);
}
m = (256*n + 1262)/253;
printf("size %d->%d (max %d)", n, strlen(out)+1, m);
if( strlen(out)+1>m ){
printf(" ERROR output too big\n");
exit(1);
}
for(j=0; out[j]; j++){
if( out[j]=='\'' ){
printf(" ERROR contains (')\n");
exit(1);
}
}
j = sqlite_decode_binary(out, out);
if( j!=n ){
printf(" ERROR decode size %d\n", j);
exit(1);
}
if( memcmp(in, out, n)!=0 ){
printf(" ERROR decode mismatch\n");
exit(1);
}
printf(" OK\n");
}
fprintf(stderr,"Finished. Total encoding: %d->%d bytes\n",
nByteIn, nByteOut);
fprintf(stderr,"Avg size increase: %.3f%%\n",
(nByteOut-nByteIn)*100.0/(double)nByteIn);
}
#endif /* ENCODER_TEST */
+1112 -484
View File
File diff suppressed because it is too large Load Diff
+658
View File
@@ -0,0 +1,658 @@
/*
** 2002 February 23
**
** 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 the C functions that implement various SQL
** functions of SQLite.
**
** There is only one exported symbol in this file - the function
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.43.2.3 2004/07/18 23:03:11 drh Exp $
*/
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include "sqliteInt.h"
#include "os.h"
/*
** Implementation of the non-aggregate min() and max() functions
*/
static void minmaxFunc(sqlite_func *context, int argc, const char **argv){
const char *zBest;
int i;
int (*xCompare)(const char*, const char*);
int mask; /* 0 for min() or 0xffffffff for max() */
if( argc==0 ) return;
mask = (int)sqlite_user_data(context);
zBest = argv[0];
if( zBest==0 ) return;
if( argv[1][0]=='n' ){
xCompare = sqliteCompare;
}else{
xCompare = strcmp;
}
for(i=2; i<argc; i+=2){
if( argv[i]==0 ) return;
if( (xCompare(argv[i], zBest)^mask)<0 ){
zBest = argv[i];
}
}
sqlite_set_result_string(context, zBest, -1);
}
/*
** Return the type of the argument.
*/
static void typeofFunc(sqlite_func *context, int argc, const char **argv){
assert( argc==2 );
sqlite_set_result_string(context, argv[1], -1);
}
/*
** Implementation of the length() function
*/
static void lengthFunc(sqlite_func *context, int argc, const char **argv){
const char *z;
int len;
assert( argc==1 );
z = argv[0];
if( z==0 ) return;
#ifdef SQLITE_UTF8
for(len=0; *z; z++){ if( (0xc0&*z)!=0x80 ) len++; }
#else
len = strlen(z);
#endif
sqlite_set_result_int(context, len);
}
/*
** Implementation of the abs() function
*/
static void absFunc(sqlite_func *context, int argc, const char **argv){
const char *z;
assert( argc==1 );
z = argv[0];
if( z==0 ) return;
if( z[0]=='-' && isdigit(z[1]) ) z++;
sqlite_set_result_string(context, z, -1);
}
/*
** Implementation of the substr() function
*/
static void substrFunc(sqlite_func *context, int argc, const char **argv){
const char *z;
#ifdef SQLITE_UTF8
const char *z2;
int i;
#endif
int p1, p2, len;
assert( argc==3 );
z = argv[0];
if( z==0 ) return;
p1 = atoi(argv[1]?argv[1]:0);
p2 = atoi(argv[2]?argv[2]:0);
#ifdef SQLITE_UTF8
for(len=0, z2=z; *z2; z2++){ if( (0xc0&*z2)!=0x80 ) len++; }
#else
len = strlen(z);
#endif
if( p1<0 ){
p1 += len;
if( p1<0 ){
p2 += p1;
p1 = 0;
}
}else if( p1>0 ){
p1--;
}
if( p1+p2>len ){
p2 = len-p1;
}
#ifdef SQLITE_UTF8
for(i=0; i<p1 && z[i]; i++){
if( (z[i]&0xc0)==0x80 ) p1++;
}
while( z[i] && (z[i]&0xc0)==0x80 ){ i++; p1++; }
for(; i<p1+p2 && z[i]; i++){
if( (z[i]&0xc0)==0x80 ) p2++;
}
while( z[i] && (z[i]&0xc0)==0x80 ){ i++; p2++; }
#endif
if( p2<0 ) p2 = 0;
sqlite_set_result_string(context, &z[p1], p2);
}
/*
** Implementation of the round() function
*/
static void roundFunc(sqlite_func *context, int argc, const char **argv){
int n;
double r;
char zBuf[100];
assert( argc==1 || argc==2 );
if( argv[0]==0 || (argc==2 && argv[1]==0) ) return;
n = argc==2 ? atoi(argv[1]) : 0;
if( n>30 ) n = 30;
if( n<0 ) n = 0;
r = sqliteAtoF(argv[0], 0);
sprintf(zBuf,"%.*f",n,r);
sqlite_set_result_string(context, zBuf, -1);
}
/*
** Implementation of the upper() and lower() SQL functions.
*/
static void upperFunc(sqlite_func *context, int argc, const char **argv){
unsigned char *z;
int i;
if( argc<1 || argv[0]==0 ) return;
z = (unsigned char*)sqlite_set_result_string(context, argv[0], -1);
if( z==0 ) return;
for(i=0; z[i]; i++){
if( islower(z[i]) ) z[i] = toupper(z[i]);
}
}
static void lowerFunc(sqlite_func *context, int argc, const char **argv){
unsigned char *z;
int i;
if( argc<1 || argv[0]==0 ) return;
z = (unsigned char*)sqlite_set_result_string(context, argv[0], -1);
if( z==0 ) return;
for(i=0; z[i]; i++){
if( isupper(z[i]) ) z[i] = tolower(z[i]);
}
}
/*
** Implementation of the IFNULL(), NVL(), and COALESCE() functions.
** All three do the same thing. They return the first non-NULL
** argument.
*/
static void ifnullFunc(sqlite_func *context, int argc, const char **argv){
int i;
for(i=0; i<argc; i++){
if( argv[i] ){
sqlite_set_result_string(context, argv[i], -1);
break;
}
}
}
/*
** Implementation of random(). Return a random integer.
*/
static void randomFunc(sqlite_func *context, int argc, const char **argv){
int r;
sqliteRandomness(sizeof(r), &r);
sqlite_set_result_int(context, r);
}
/*
** Implementation of the last_insert_rowid() SQL function. The return
** value is the same as the sqlite_last_insert_rowid() API function.
*/
static void last_insert_rowid(sqlite_func *context, int arg, const char **argv){
sqlite *db = sqlite_user_data(context);
sqlite_set_result_int(context, sqlite_last_insert_rowid(db));
}
/*
** Implementation of the change_count() SQL function. The return
** value is the same as the sqlite_changes() API function.
*/
static void change_count(sqlite_func *context, int arg, const char **argv){
sqlite *db = sqlite_user_data(context);
sqlite_set_result_int(context, sqlite_changes(db));
}
/*
** Implementation of the last_statement_change_count() SQL function. The
** return value is the same as the sqlite_last_statement_changes() API function.
*/
static void last_statement_change_count(sqlite_func *context, int arg,
const char **argv){
sqlite *db = sqlite_user_data(context);
sqlite_set_result_int(context, sqlite_last_statement_changes(db));
}
/*
** Implementation of the like() SQL function. This function implements
** the build-in LIKE operator. The first argument to the function is the
** string and the second argument is the pattern. So, the SQL statements:
**
** A LIKE B
**
** is implemented as like(A,B).
*/
static void likeFunc(sqlite_func *context, int arg, const char **argv){
if( argv[0]==0 || argv[1]==0 ) return;
sqlite_set_result_int(context,
sqliteLikeCompare((const unsigned char*)argv[0],
(const unsigned char*)argv[1]));
}
/*
** Implementation of the glob() SQL function. This function implements
** the build-in GLOB operator. The first argument to the function is the
** string and the second argument is the pattern. So, the SQL statements:
**
** A GLOB B
**
** is implemented as glob(A,B).
*/
static void globFunc(sqlite_func *context, int arg, const char **argv){
if( argv[0]==0 || argv[1]==0 ) return;
sqlite_set_result_int(context,
sqliteGlobCompare((const unsigned char*)argv[0],
(const unsigned char*)argv[1]));
}
/*
** Implementation of the NULLIF(x,y) function. The result is the first
** argument if the arguments are different. The result is NULL if the
** arguments are equal to each other.
*/
static void nullifFunc(sqlite_func *context, int argc, const char **argv){
if( argv[0]!=0 && sqliteCompare(argv[0],argv[1])!=0 ){
sqlite_set_result_string(context, argv[0], -1);
}
}
/*
** Implementation of the VERSION(*) function. The result is the version
** of the SQLite library that is running.
*/
static void versionFunc(sqlite_func *context, int argc, const char **argv){
sqlite_set_result_string(context, sqlite_version, -1);
}
/*
** EXPERIMENTAL - This is not an official function. The interface may
** change. This function may disappear. Do not write code that depends
** on this function.
**
** Implementation of the QUOTE() function. This function takes a single
** argument. If the argument is numeric, the return value is the same as
** the argument. If the argument is NULL, the return value is the string
** "NULL". Otherwise, the argument is enclosed in single quotes with
** single-quote escapes.
*/
static void quoteFunc(sqlite_func *context, int argc, const char **argv){
if( argc<1 ) return;
if( argv[0]==0 ){
sqlite_set_result_string(context, "NULL", 4);
}else if( sqliteIsNumber(argv[0]) ){
sqlite_set_result_string(context, argv[0], -1);
}else{
int i,j,n;
char *z;
for(i=n=0; argv[0][i]; i++){ if( argv[0][i]=='\'' ) n++; }
z = sqliteMalloc( i+n+3 );
if( z==0 ) return;
z[0] = '\'';
for(i=0, j=1; argv[0][i]; i++){
z[j++] = argv[0][i];
if( argv[0][i]=='\'' ){
z[j++] = '\'';
}
}
z[j++] = '\'';
z[j] = 0;
sqlite_set_result_string(context, z, j);
sqliteFree(z);
}
}
#ifdef SQLITE_SOUNDEX
/*
** Compute the soundex encoding of a word.
*/
static void soundexFunc(sqlite_func *context, int argc, const char **argv){
char zResult[8];
const char *zIn;
int i, j;
static const unsigned char iCode[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,
1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,
0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,
1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,
};
assert( argc==1 );
zIn = argv[0];
for(i=0; zIn[i] && !isalpha(zIn[i]); i++){}
if( zIn[i] ){
zResult[0] = toupper(zIn[i]);
for(j=1; j<4 && zIn[i]; i++){
int code = iCode[zIn[i]&0x7f];
if( code>0 ){
zResult[j++] = code + '0';
}
}
while( j<4 ){
zResult[j++] = '0';
}
zResult[j] = 0;
sqlite_set_result_string(context, zResult, 4);
}else{
sqlite_set_result_string(context, "?000", 4);
}
}
#endif
#ifdef SQLITE_TEST
/*
** This function generates a string of random characters. Used for
** generating test data.
*/
static void randStr(sqlite_func *context, int argc, const char **argv){
static const unsigned char zSrc[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
".-!,:*^+=_|?/<> ";
int iMin, iMax, n, r, i;
unsigned char zBuf[1000];
if( argc>=1 ){
iMin = atoi(argv[0]);
if( iMin<0 ) iMin = 0;
if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1;
}else{
iMin = 1;
}
if( argc>=2 ){
iMax = atoi(argv[1]);
if( iMax<iMin ) iMax = iMin;
if( iMax>=sizeof(zBuf) ) iMax = sizeof(zBuf)-1;
}else{
iMax = 50;
}
n = iMin;
if( iMax>iMin ){
sqliteRandomness(sizeof(r), &r);
r &= 0x7fffffff;
n += r%(iMax + 1 - iMin);
}
assert( n<sizeof(zBuf) );
sqliteRandomness(n, zBuf);
for(i=0; i<n; i++){
zBuf[i] = zSrc[zBuf[i]%(sizeof(zSrc)-1)];
}
zBuf[n] = 0;
sqlite_set_result_string(context, zBuf, n);
}
#endif
/*
** An instance of the following structure holds the context of a
** sum() or avg() aggregate computation.
*/
typedef struct SumCtx SumCtx;
struct SumCtx {
double sum; /* Sum of terms */
int cnt; /* Number of elements summed */
};
/*
** Routines used to compute the sum or average.
*/
static void sumStep(sqlite_func *context, int argc, const char **argv){
SumCtx *p;
if( argc<1 ) return;
p = sqlite_aggregate_context(context, sizeof(*p));
if( p && argv[0] ){
p->sum += sqliteAtoF(argv[0], 0);
p->cnt++;
}
}
static void sumFinalize(sqlite_func *context){
SumCtx *p;
p = sqlite_aggregate_context(context, sizeof(*p));
sqlite_set_result_double(context, p ? p->sum : 0.0);
}
static void avgFinalize(sqlite_func *context){
SumCtx *p;
p = sqlite_aggregate_context(context, sizeof(*p));
if( p && p->cnt>0 ){
sqlite_set_result_double(context, p->sum/(double)p->cnt);
}
}
/*
** An instance of the following structure holds the context of a
** variance or standard deviation computation.
*/
typedef struct StdDevCtx StdDevCtx;
struct StdDevCtx {
double sum; /* Sum of terms */
double sum2; /* Sum of the squares of terms */
int cnt; /* Number of terms counted */
};
#if 0 /* Omit because math library is required */
/*
** Routines used to compute the standard deviation as an aggregate.
*/
static void stdDevStep(sqlite_func *context, int argc, const char **argv){
StdDevCtx *p;
double x;
if( argc<1 ) return;
p = sqlite_aggregate_context(context, sizeof(*p));
if( p && argv[0] ){
x = sqliteAtoF(argv[0], 0);
p->sum += x;
p->sum2 += x*x;
p->cnt++;
}
}
static void stdDevFinalize(sqlite_func *context){
double rN = sqlite_aggregate_count(context);
StdDevCtx *p = sqlite_aggregate_context(context, sizeof(*p));
if( p && p->cnt>1 ){
double rCnt = cnt;
sqlite_set_result_double(context,
sqrt((p->sum2 - p->sum*p->sum/rCnt)/(rCnt-1.0)));
}
}
#endif
/*
** The following structure keeps track of state information for the
** count() aggregate function.
*/
typedef struct CountCtx CountCtx;
struct CountCtx {
int n;
};
/*
** Routines to implement the count() aggregate function.
*/
static void countStep(sqlite_func *context, int argc, const char **argv){
CountCtx *p;
p = sqlite_aggregate_context(context, sizeof(*p));
if( (argc==0 || argv[0]) && p ){
p->n++;
}
}
static void countFinalize(sqlite_func *context){
CountCtx *p;
p = sqlite_aggregate_context(context, sizeof(*p));
sqlite_set_result_int(context, p ? p->n : 0);
}
/*
** This function tracks state information for the min() and max()
** aggregate functions.
*/
typedef struct MinMaxCtx MinMaxCtx;
struct MinMaxCtx {
char *z; /* The best so far */
char zBuf[28]; /* Space that can be used for storage */
};
/*
** Routines to implement min() and max() aggregate functions.
*/
static void minmaxStep(sqlite_func *context, int argc, const char **argv){
MinMaxCtx *p;
int (*xCompare)(const char*, const char*);
int mask; /* 0 for min() or 0xffffffff for max() */
assert( argc==2 );
if( argv[0]==0 ) return; /* Ignore NULL values */
if( argv[1][0]=='n' ){
xCompare = sqliteCompare;
}else{
xCompare = strcmp;
}
mask = (int)sqlite_user_data(context);
assert( mask==0 || mask==-1 );
p = sqlite_aggregate_context(context, sizeof(*p));
if( p==0 || argc<1 ) return;
if( p->z==0 || (xCompare(argv[0],p->z)^mask)<0 ){
int len;
if( p->zBuf[0] ){
sqliteFree(p->z);
}
len = strlen(argv[0]);
if( len < sizeof(p->zBuf)-1 ){
p->z = &p->zBuf[1];
p->zBuf[0] = 0;
}else{
p->z = sqliteMalloc( len+1 );
p->zBuf[0] = 1;
if( p->z==0 ) return;
}
strcpy(p->z, argv[0]);
}
}
static void minMaxFinalize(sqlite_func *context){
MinMaxCtx *p;
p = sqlite_aggregate_context(context, sizeof(*p));
if( p && p->z && p->zBuf[0]<2 ){
sqlite_set_result_string(context, p->z, strlen(p->z));
}
if( p && p->zBuf[0] ){
sqliteFree(p->z);
}
}
/*
** This function registered all of the above C functions as SQL
** functions. This should be the only routine in this file with
** external linkage.
*/
void sqliteRegisterBuiltinFunctions(sqlite *db){
static struct {
char *zName;
signed char nArg;
signed char dataType;
u8 argType; /* 0: none. 1: db 2: (-1) */
void (*xFunc)(sqlite_func*,int,const char**);
} aFuncs[] = {
{ "min", -1, SQLITE_ARGS, 0, minmaxFunc },
{ "min", 0, 0, 0, 0 },
{ "max", -1, SQLITE_ARGS, 2, minmaxFunc },
{ "max", 0, 0, 2, 0 },
{ "typeof", 1, SQLITE_TEXT, 0, typeofFunc },
{ "length", 1, SQLITE_NUMERIC, 0, lengthFunc },
{ "substr", 3, SQLITE_TEXT, 0, substrFunc },
{ "abs", 1, SQLITE_NUMERIC, 0, absFunc },
{ "round", 1, SQLITE_NUMERIC, 0, roundFunc },
{ "round", 2, SQLITE_NUMERIC, 0, roundFunc },
{ "upper", 1, SQLITE_TEXT, 0, upperFunc },
{ "lower", 1, SQLITE_TEXT, 0, lowerFunc },
{ "coalesce", -1, SQLITE_ARGS, 0, ifnullFunc },
{ "coalesce", 0, 0, 0, 0 },
{ "coalesce", 1, 0, 0, 0 },
{ "ifnull", 2, SQLITE_ARGS, 0, ifnullFunc },
{ "random", -1, SQLITE_NUMERIC, 0, randomFunc },
{ "like", 2, SQLITE_NUMERIC, 0, likeFunc },
{ "glob", 2, SQLITE_NUMERIC, 0, globFunc },
{ "nullif", 2, SQLITE_ARGS, 0, nullifFunc },
{ "sqlite_version",0,SQLITE_TEXT, 0, versionFunc},
{ "quote", 1, SQLITE_ARGS, 0, quoteFunc },
{ "last_insert_rowid", 0, SQLITE_NUMERIC, 1, last_insert_rowid },
{ "change_count", 0, SQLITE_NUMERIC, 1, change_count },
{ "last_statement_change_count",
0, SQLITE_NUMERIC, 1, last_statement_change_count },
#ifdef SQLITE_SOUNDEX
{ "soundex", 1, SQLITE_TEXT, 0, soundexFunc},
#endif
#ifdef SQLITE_TEST
{ "randstr", 2, SQLITE_TEXT, 0, randStr },
#endif
};
static struct {
char *zName;
signed char nArg;
signed char dataType;
u8 argType;
void (*xStep)(sqlite_func*,int,const char**);
void (*xFinalize)(sqlite_func*);
} aAggs[] = {
{ "min", 1, 0, 0, minmaxStep, minMaxFinalize },
{ "max", 1, 0, 2, minmaxStep, minMaxFinalize },
{ "sum", 1, SQLITE_NUMERIC, 0, sumStep, sumFinalize },
{ "avg", 1, SQLITE_NUMERIC, 0, sumStep, avgFinalize },
{ "count", 0, SQLITE_NUMERIC, 0, countStep, countFinalize },
{ "count", 1, SQLITE_NUMERIC, 0, countStep, countFinalize },
#if 0
{ "stddev", 1, SQLITE_NUMERIC, 0, stdDevStep, stdDevFinalize },
#endif
};
static const char *azTypeFuncs[] = { "min", "max", "typeof" };
int i;
for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
void *pArg;
switch( aFuncs[i].argType ){
case 0: pArg = 0; break;
case 1: pArg = db; break;
case 2: pArg = (void*)(-1); break;
}
sqlite_create_function(db, aFuncs[i].zName,
aFuncs[i].nArg, aFuncs[i].xFunc, pArg);
if( aFuncs[i].xFunc ){
sqlite_function_type(db, aFuncs[i].zName, aFuncs[i].dataType);
}
}
for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
void *pArg;
switch( aAggs[i].argType ){
case 0: pArg = 0; break;
case 1: pArg = db; break;
case 2: pArg = (void*)(-1); break;
}
sqlite_create_aggregate(db, aAggs[i].zName,
aAggs[i].nArg, aAggs[i].xStep, aAggs[i].xFinalize, pArg);
sqlite_function_type(db, aAggs[i].zName, aAggs[i].dataType);
}
for(i=0; i<sizeof(azTypeFuncs)/sizeof(azTypeFuncs[0]); i++){
int n = strlen(azTypeFuncs[i]);
FuncDef *p = sqliteHashFind(&db->aFunc, azTypeFuncs[i], n);
while( p ){
p->includeTypes = 1;
p = p->pNext;
}
}
sqliteRegisterDateTimeFunctions(db);
}
+52 -25
View File
@@ -12,13 +12,22 @@
** This is the implementation of generic hash-tables
** used in SQLite.
**
** $Id: hash.c,v 1.3 2001/10/22 02:58:10 drh Exp $
** $Id: hash.c,v 1.11 2004/01/08 02:17:33 drh Exp $
*/
#include "sqliteInt.h"
#include <assert.h>
/* Turn bulk memory into a hash table object by initializing the
** fields of the Hash structure.
**
** "new" is a pointer to the hash table that is to be initialized.
** keyClass is one of the constants SQLITE_HASH_INT, SQLITE_HASH_POINTER,
** SQLITE_HASH_BINARY, or SQLITE_HASH_STRING. The value of keyClass
** determines what kind of key the hash table will use. "copyKey" is
** true if the hash table should make its own private copy of keys and
** false if it should just use the supplied pointer. CopyKey only makes
** sense for SQLITE_HASH_STRING and SQLITE_HASH_BINARY and is ignored
** for other key classes.
*/
void sqliteHashInit(Hash *new, int keyClass, int copyKey){
assert( new!=0 );
@@ -33,6 +42,8 @@ void sqliteHashInit(Hash *new, int keyClass, int copyKey){
}
/* Remove all entries from a hash table. Reclaim all memory.
** Call this routine to delete a hash table or to reset a hash table
** to the empty state.
*/
void sqliteHashClear(Hash *pH){
HashElem *elem; /* For looping over all elements of the table */
@@ -64,16 +75,20 @@ static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){
return n2 - n1;
}
#if 0 /* NOT USED */
/*
** Hash and comparison functions when the mode is SQLITE_HASH_POINTER
*/
static int ptrHash(const void *pKey, int nKey){
nKey = (int)pKey;
return nKey ^ (nKey<<8) ^ (nKey>>8);
uptr x = Addr(pKey);
return x ^ (x<<8) ^ (x>>8);
}
static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
return ((int)pKey2) - (int)pKey1;
if( pKey1==pKey2 ) return 0;
if( pKey1<pKey2 ) return -1;
return 1;
}
#endif
/*
** Hash and comparison functions when the mode is SQLITE_HASH_STRING
@@ -95,8 +110,7 @@ static int binHash(const void *pKey, int nKey){
while( nKey-- > 0 ){
h = (h<<3) ^ h ^ *(z++);
}
if( h<0 ) h = -h;
return h;
return h & 0x7fffffff;
}
static int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){
if( n1!=n2 ) return n2-n1;
@@ -105,13 +119,22 @@ static int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){
/*
** Return a pointer to the appropriate hash function given the key class.
**
** The C syntax in this function definition may be unfamilar to some
** programmers, so we provide the following additional explanation:
**
** The name of the function is "hashFunction". The function takes a
** single parameter "keyClass". The return value of hashFunction()
** is a pointer to another function. Specifically, the return value
** of hashFunction() is a pointer to a function that takes two parameters
** with types "const void*" and "int" and returns an "int".
*/
static int (*hashFunction(int keyClass))(const void*,int){
switch( keyClass ){
case SQLITE_HASH_INT: return intHash;
case SQLITE_HASH_POINTER: return ptrHash;
case SQLITE_HASH_STRING: return strHash;
case SQLITE_HASH_BINARY: return binHash;;
case SQLITE_HASH_INT: return &intHash;
/* case SQLITE_HASH_POINTER: return &ptrHash; // NOT USED */
case SQLITE_HASH_STRING: return &strHash;
case SQLITE_HASH_BINARY: return &binHash;;
default: break;
}
return 0;
@@ -119,21 +142,25 @@ static int (*hashFunction(int keyClass))(const void*,int){
/*
** Return a pointer to the appropriate hash function given the key class.
**
** For help in interpreted the obscure C code in the function definition,
** see the header comment on the previous function.
*/
static int (*compareFunction(int keyClass))(const void*,int,const void*,int){
switch( keyClass ){
case SQLITE_HASH_INT: return intCompare;
case SQLITE_HASH_POINTER: return ptrCompare;
case SQLITE_HASH_STRING: return strCompare;
case SQLITE_HASH_BINARY: return binCompare;
case SQLITE_HASH_INT: return &intCompare;
/* case SQLITE_HASH_POINTER: return &ptrCompare; // NOT USED */
case SQLITE_HASH_STRING: return &strCompare;
case SQLITE_HASH_BINARY: return &binCompare;
default: break;
}
return 0;
}
/* Resize the hash table. new_size must be a power of 2.
** The hash table might fail to resize if sqliteMalloc() fails.
/* Resize the hash table so that it cantains "new_size" buckets.
** "new_size" must be a power of 2. The hash table might fail
** to resize if sqliteMalloc() fails.
*/
static void rehash(Hash *pH, int new_size){
struct _ht *new_ht; /* The new hash table */
@@ -170,8 +197,8 @@ static void rehash(Hash *pH, int new_size){
}
/* This function (for internal use only) locates an element in an
** pH that matches the given key. The hash for this key has
** already been computed and is passed as the 3rd parameter.
** hash table that matches the given key. The hash for this key has
** already been computed and is passed as the 4th parameter.
*/
static HashElem *findElementGivenHash(
const Hash *pH, /* The pH to be searched */
@@ -203,7 +230,7 @@ static HashElem *findElementGivenHash(
static void removeElementGivenHash(
Hash *pH, /* The pH containing "elem" */
HashElem* elem, /* The element to be removed from the pH */
int h /* Hash value for the element */
int h /* Hash value for the element */
){
if( elem->prev ){
elem->prev->next = elem->next;
@@ -227,9 +254,9 @@ static void removeElementGivenHash(
pH->count--;
}
/* Attempt to locate an element of the associative pH with a key
/* Attempt to locate an element of the hash table pH with a key
** that matches pKey,nKey. Return the data for this element if it is
** found, or NULL if no match is found.
** found, or NULL if there is no match.
*/
void *sqliteHashFind(const Hash *pH, const void *pKey, int nKey){
int h; /* A hash on key */
@@ -255,12 +282,12 @@ void *sqliteHashFind(const Hash *pH, const void *pKey, int nKey){
** If another element already exists with the same key, then the
** new data replaces the old data and the old data is returned.
** The key is not copied in this instance. If a malloc fails, then
** new data is returned.
** the new data is returned and the hash table is unchanged.
**
** If the "data" parameter to this function is NULL, then the
** element corresponding to "key" is removed from the hash table.
*/
void *sqliteHashInsert(Hash *pH, void *pKey, int nKey, void *data){
void *sqliteHashInsert(Hash *pH, const void *pKey, int nKey, void *data){
int hraw; /* Raw hash value of the key */
int h; /* the hash of the key modulo hash table size */
HashElem *elem; /* Used to loop thru the element list */
@@ -287,14 +314,14 @@ void *sqliteHashInsert(Hash *pH, void *pKey, int nKey, void *data){
new_elem = (HashElem*)sqliteMalloc( sizeof(HashElem) );
if( new_elem==0 ) return data;
if( pH->copyKey && pKey!=0 ){
new_elem->pKey = sqliteMalloc( nKey );
new_elem->pKey = sqliteMallocRaw( nKey );
if( new_elem->pKey==0 ){
sqliteFree(new_elem);
return data;
}
memcpy((void*)new_elem->pKey, pKey, nKey);
}else{
new_elem->pKey = pKey;
new_elem->pKey = (void*)pKey;
}
new_elem->nKey = nKey;
pH->count++;
+10 -3
View File
@@ -12,7 +12,7 @@
** This is the header file for the generic hash-table implemenation
** used in SQLite.
**
** $Id: hash.h,v 1.2 2001/10/09 04:19:47 drh Exp $
** $Id: hash.h,v 1.6 2004/01/08 02:17:33 drh Exp $
*/
#ifndef _SQLITE_HASH_H_
#define _SQLITE_HASH_H_
@@ -71,7 +71,7 @@ struct HashElem {
** if the copyKey parameter to HashInit is 1.
*/
#define SQLITE_HASH_INT 1
#define SQLITE_HASH_POINTER 2
/* #define SQLITE_HASH_POINTER 2 // NOT USED */
#define SQLITE_HASH_STRING 3
#define SQLITE_HASH_BINARY 4
@@ -79,7 +79,7 @@ struct HashElem {
** Access routines. To delete, insert a NULL pointer.
*/
void sqliteHashInit(Hash*, int keytype, int copyKey);
void *sqliteHashInsert(Hash*, void *pKey, int nKey, void *pData);
void *sqliteHashInsert(Hash*, const void *pKey, int nKey, void *pData);
void *sqliteHashFind(const Hash*, const void *pKey, int nKey);
void sqliteHashClear(Hash*);
@@ -98,5 +98,12 @@ void sqliteHashClear(Hash*);
#define sqliteHashFirst(H) ((H)->first)
#define sqliteHashNext(E) ((E)->next)
#define sqliteHashData(E) ((E)->data)
#define sqliteHashKey(E) ((E)->pKey)
#define sqliteHashKeysize(E) ((E)->nKey)
/*
** Number of entries in a hash table
*/
#define sqliteHashCount(H) ((H)->count)
#endif /* _SQLITE_HASH_H_ */
+768 -122
View File
File diff suppressed because it is too large Load Diff
+884 -280
View File
File diff suppressed because it is too large Load Diff
+185 -152
View File
@@ -30,6 +30,7 @@
*/
#include <tcl.h>
#include <string.h>
#include "sqlite.h"
/*
* If compiled on a machine that doesn't have a 32-bit integer,
@@ -54,13 +55,13 @@ typedef char MD5Context[88];
* Note: this code is harmless on little-endian machines.
*/
static void byteReverse (unsigned char *buf, unsigned longs){
uint32 t;
do {
t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |
((unsigned)buf[1]<<8 | buf[0]);
*(uint32 *)buf = t;
buf += 4;
} while (--longs);
uint32 t;
do {
t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |
((unsigned)buf[1]<<8 | buf[0]);
*(uint32 *)buf = t;
buf += 4;
} while (--longs);
}
/* The four core functions - F1 is optimized somewhat */
@@ -72,7 +73,7 @@ static void byteReverse (unsigned char *buf, unsigned longs){
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
@@ -80,85 +81,85 @@ static void byteReverse (unsigned char *buf, unsigned longs){
* the data and converts bytes into longwords for this routine.
*/
static void MD5Transform(uint32 buf[4], const uint32 in[16]){
register uint32 a, b, c, d;
register uint32 a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
/*
@@ -167,12 +168,12 @@ static void MD5Transform(uint32 buf[4], const uint32 in[16]){
*/
static void MD5Init(MD5Context *pCtx){
struct Context *ctx = (struct Context *)pCtx;
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
@@ -182,47 +183,47 @@ static void MD5Init(MD5Context *pCtx){
static
void MD5Update(MD5Context *pCtx, const unsigned char *buf, unsigned int len){
struct Context *ctx = (struct Context *)pCtx;
uint32 t;
uint32 t;
/* Update bitcount */
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
/* Handle any leading odd-sized chunks */
if ( t ) {
unsigned char *p = (unsigned char *)ctx->in + t;
if ( t ) {
unsigned char *p = (unsigned char *)ctx->in + t;
t = 64-t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
buf += t;
len -= t;
}
t = 64-t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
buf += 64;
len -= 64;
}
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
memcpy(ctx->in, buf, len);
}
/*
@@ -231,43 +232,43 @@ void MD5Update(MD5Context *pCtx, const unsigned char *buf, unsigned int len){
*/
static void MD5Final(unsigned char digest[16], MD5Context *pCtx){
struct Context *ctx = (struct Context *)pCtx;
unsigned count;
unsigned char *p;
unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count-8);
}
byteReverse(ctx->in, 14);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count-8);
}
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
((uint32 *)ctx->in)[ 14 ] = ctx->bits[0];
((uint32 *)ctx->in)[ 15 ] = ctx->bits[1];
/* Append length in bits and transform */
((uint32 *)ctx->in)[ 14 ] = ctx->bits[0];
((uint32 *)ctx->in)[ 15 ] = ctx->bits[1];
MD5Transform(ctx->buf, (uint32 *)ctx->in);
byteReverse((unsigned char *)ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
MD5Transform(ctx->buf, (uint32 *)ctx->in);
byteReverse((unsigned char *)ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
/*
@@ -292,7 +293,7 @@ static void DigestToBase16(unsigned char *digest, char *zBuf){
** A TCL command for md5. The argument is the text to be hashed. The
** Result is the hash in base64.
*/
static int md5_cmd(ClientData cd, Tcl_Interp *interp, int argc, char **argv){
static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){
MD5Context ctx;
unsigned char digest[16];
@@ -312,7 +313,7 @@ static int md5_cmd(ClientData cd, Tcl_Interp *interp, int argc, char **argv){
** A TCL command to take the md5 hash of a file. The argument is the
** name of the file.
*/
static int md5file_cmd(ClientData cd, Tcl_Interp*interp, int argc, char **argv){
static int md5file_cmd(void*cd, Tcl_Interp*interp, int argc, const char **argv){
FILE *in;
MD5Context ctx;
unsigned char digest[16];
@@ -346,7 +347,39 @@ static int md5file_cmd(ClientData cd, Tcl_Interp*interp, int argc, char **argv){
** Register the two TCL commands above with the TCL interpreter.
*/
int Md5_Init(Tcl_Interp *interp){
Tcl_CreateCommand(interp, "md5", md5_cmd, 0, 0);
Tcl_CreateCommand(interp, "md5file", md5file_cmd, 0, 0);
Tcl_CreateCommand(interp, "md5", (Tcl_CmdProc*)md5_cmd, 0, 0);
Tcl_CreateCommand(interp, "md5file", (Tcl_CmdProc*)md5file_cmd, 0, 0);
return TCL_OK;
}
/*
** During testing, the special md5sum() aggregate function is available.
** inside SQLite. The following routines implement that function.
*/
static void md5step(sqlite_func *context, int argc, const char **argv){
MD5Context *p;
int i;
if( argc<1 ) return;
p = sqlite_aggregate_context(context, sizeof(*p));
if( p==0 ) return;
if( sqlite_aggregate_count(context)==1 ){
MD5Init(p);
}
for(i=0; i<argc; i++){
if( argv[i] ){
MD5Update(p, (unsigned char*)argv[i], strlen(argv[i]));
}
}
}
static void md5finalize(sqlite_func *context){
MD5Context *p;
unsigned char digest[16];
char zBuf[33];
p = sqlite_aggregate_context(context, sizeof(*p));
MD5Final(digest,p);
DigestToBase16(digest, zBuf);
sqlite_set_result_string(context, zBuf, strlen(zBuf));
}
void Md5_Register(sqlite *db){
sqlite_create_aggregate(db, "md5sum", -1, md5step, md5finalize, 0);
}
+1356 -215
View File
File diff suppressed because it is too large Load Diff
+139 -15
View File
@@ -17,14 +17,99 @@
#ifndef _SQLITE_OS_H_
#define _SQLITE_OS_H_
/*
** Helpful hint: To get this to compile on HP/UX, add -D_INCLUDE_POSIX_SOURCE
** to the compiler command line.
*/
/*
** These #defines should enable >2GB file support on Posix if the
** underlying operating system supports it. If the OS lacks
** large file support, or if the OS is windows, these should be no-ops.
**
** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
** on the compiler command line. This is necessary if you are compiling
** on a recent machine (ex: RedHat 7.2) but you want your code to work
** on an older machine (ex: RedHat 6.0). If you compile on RedHat 7.2
** without this option, LFS is enable. But LFS does not exist in the kernel
** in RedHat 6.0, so the code won't work. Hence, for maximum binary
** portability you should omit LFS.
**
** Similar is true for MacOS. LFS is only supported on MacOS 9 and later.
*/
#ifndef SQLITE_DISABLE_LFS
# define _LARGE_FILE 1
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
# endif
# define _LARGEFILE_SOURCE 1
#endif
/*
** Temporary files are named starting with this prefix followed by 16 random
** alphanumeric characters, and no file extension. They are stored in the
** OS's standard temporary file directory, and are deleted prior to exit.
** If sqlite is being embedded in another program, you may wish to change the
** prefix to reflect your program's name, so that if your program exits
** prematurely, old temporary files can be easily identified. This can be done
** using -DTEMP_FILE_PREFIX=myprefix_ on the compiler command line.
*/
#ifndef TEMP_FILE_PREFIX
# define TEMP_FILE_PREFIX "sqlite_"
#endif
/*
** Figure out if we are dealing with Unix, Windows or MacOS.
**
** N.B. MacOS means Mac Classic (or Carbon). Treat Darwin (OS X) as Unix.
** The MacOS build is designed to use CodeWarrior (tested with v8)
*/
#ifndef OS_UNIX
# ifndef OS_WIN
# ifndef OS_MAC
# if defined(__MACOS__)
# define OS_MAC 1
# define OS_WIN 0
# define OS_UNIX 0
# elif defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
# define OS_MAC 0
# define OS_WIN 1
# define OS_UNIX 0
# else
# define OS_MAC 0
# define OS_WIN 0
# define OS_UNIX 1
# endif
# else
# define OS_WIN 0
# define OS_UNIX 0
# endif
# else
# define OS_MAC 0
# define OS_UNIX 0
# endif
#else
# define OS_MAC 0
# ifndef OS_WIN
# define OS_WIN 0
# endif
#endif
/*
** A handle for an open file is stored in an OsFile object.
*/
#if OS_UNIX
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
# include <unistd.h>
typedef struct OsFile OsFile;
struct OsFile {
struct lockInfo *pLock; /* Information about locks on this inode */
int fd; /* The file descriptor */
struct openCnt *pOpen; /* Info about all open fd's on this inode */
struct lockInfo *pLock; /* Info about locks on this inode */
int fd; /* The file descriptor */
int locked; /* True if this instance holds the lock */
int dirfd; /* File descriptor for the directory */
};
# define SQLITE_TEMPNAME_SIZE 200
# if defined(HAVE_USLEEP) && HAVE_USLEEP
@@ -37,30 +122,69 @@
#if OS_WIN
#include <windows.h>
#include <winbase.h>
typedef HANDLE OsFile;
typedef struct OsFile OsFile;
struct OsFile {
HANDLE h; /* Handle for accessing the file */
int locked; /* 0: unlocked, <0: write lock, >0: read lock */
};
# if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 off_t;
# else
# if !defined(_CYGWIN_TYPES_H)
typedef long long off_t;
# if defined(__MINGW32__)
# define _OFF_T_
# endif
# endif
# endif
# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50)
# define SQLITE_MIN_SLEEP_MS 1
#endif
#if OS_MAC
# include <unistd.h>
# include <Files.h>
typedef struct OsFile OsFile;
struct OsFile {
SInt16 refNum; /* Data fork/file reference number */
SInt16 refNumRF; /* Resource fork reference number (for locking) */
int locked; /* 0: unlocked, <0: write lock, >0: read lock */
int delOnClose; /* True if file is to be deleted on close */
char *pathToDel; /* Name of file to delete on close */
};
# ifdef _LARGE_FILE
typedef SInt64 off_t;
# else
typedef SInt32 off_t;
# endif
# define SQLITE_TEMPNAME_SIZE _MAX_PATH
# define SQLITE_MIN_SLEEP_MS 17
#endif
int sqliteOsDelete(const char*);
int sqliteOsFileExists(const char*);
int sqliteOsFileRename(const char*, const char*);
int sqliteOsOpenReadWrite(const char*, OsFile*, int*);
int sqliteOsOpenExclusive(const char*, OsFile*);
int sqliteOsOpenExclusive(const char*, OsFile*, int);
int sqliteOsOpenReadOnly(const char*, OsFile*);
int sqliteOsOpenDirectory(const char*, OsFile*);
int sqliteOsTempFileName(char*);
int sqliteOsClose(OsFile);
int sqliteOsRead(OsFile, void*, int amt);
int sqliteOsWrite(OsFile, const void*, int amt);
int sqliteOsSeek(OsFile, int offset);
int sqliteOsSync(OsFile);
int sqliteOsTruncate(OsFile, int size);
int sqliteOsFileSize(OsFile, int *pSize);
int sqliteOsLock(OsFile, int wrlock);
int sqliteOsUnlock(OsFile);
int sqliteOsClose(OsFile*);
int sqliteOsRead(OsFile*, void*, int amt);
int sqliteOsWrite(OsFile*, const void*, int amt);
int sqliteOsSeek(OsFile*, off_t offset);
int sqliteOsSync(OsFile*);
int sqliteOsTruncate(OsFile*, off_t size);
int sqliteOsFileSize(OsFile*, off_t *pSize);
int sqliteOsReadLock(OsFile*);
int sqliteOsWriteLock(OsFile*);
int sqliteOsUnlock(OsFile*);
int sqliteOsRandomSeed(char*);
int sqliteOsSleep(int ms);
void sqliteOsEnterMutex();
void sqliteOsLeaveMutex();
int sqliteOsCurrentTime(double*);
void sqliteOsEnterMutex(void);
void sqliteOsLeaveMutex(void);
char *sqliteOsFullPathname(const char*);
+1398 -302
View File
File diff suppressed because it is too large Load Diff
+48 -2
View File
@@ -13,13 +13,41 @@
** subsystem. The page cache subsystem reads and writes a file a page
** at a time and provides a journal for rollback.
**
** @(#) $Id: pager.h,v 1.11 2001/09/16 00:13:27 drh Exp $
** @(#) $Id: pager.h,v 1.26 2004/02/11 02:18:07 drh Exp $
*/
/*
** The size of one page
**
** You can change this value to another (reasonable) value you want.
** It need not be a power of two, though the interface to the disk
** will likely be faster if it is.
**
** Experiments show that a page size of 1024 gives the best speed
** for common usages. The speed differences for different sizes
** such as 512, 2048, 4096, an so forth, is minimal. Note, however,
** that changing the page size results in a completely imcompatible
** file format.
*/
#ifndef SQLITE_PAGE_SIZE
#define SQLITE_PAGE_SIZE 1024
#endif
/*
** Number of extra bytes of data allocated at the end of each page and
** stored on disk but not used by the higher level btree layer. Changing
** this value results in a completely incompatible file format.
*/
#ifndef SQLITE_PAGE_RESERVE
#define SQLITE_PAGE_RESERVE 0
#endif
/*
** The total number of usable bytes stored on disk for each page.
** The usable bytes come at the beginning of the page and the reserve
** bytes come at the end.
*/
#define SQLITE_USABLE_SIZE (SQLITE_PAGE_SIZE-SQLITE_PAGE_RESERVE)
/*
** Maximum number of pages in one database. (This is a limitation of
@@ -38,7 +66,12 @@ typedef unsigned int Pgno;
*/
typedef struct Pager Pager;
int sqlitepager_open(Pager **ppPager,const char *zFilename,int nPage,int nEx);
/*
** See source code comments for a detailed description of the following
** routines:
*/
int sqlitepager_open(Pager **ppPager, const char *zFilename,
int nPage, int nExtra, int useJournal);
void sqlitepager_set_destructor(Pager*, void(*)(void*));
void sqlitepager_set_cachesize(Pager*, int);
int sqlitepager_close(Pager *pPager);
@@ -49,13 +82,26 @@ int sqlitepager_unref(void*);
Pgno sqlitepager_pagenumber(void*);
int sqlitepager_write(void*);
int sqlitepager_iswriteable(void*);
int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void*);
int sqlitepager_pagecount(Pager*);
int sqlitepager_truncate(Pager*,Pgno);
int sqlitepager_begin(void*);
int sqlitepager_commit(Pager*);
int sqlitepager_rollback(Pager*);
int sqlitepager_isreadonly(Pager*);
int sqlitepager_ckpt_begin(Pager*);
int sqlitepager_ckpt_commit(Pager*);
int sqlitepager_ckpt_rollback(Pager*);
void sqlitepager_dont_rollback(void*);
void sqlitepager_dont_write(Pager*, Pgno);
int *sqlitepager_stats(Pager*);
void sqlitepager_set_safety_level(Pager*,int);
const char *sqlitepager_filename(Pager*);
int sqlitepager_rename(Pager*, const char *zNewName);
void sqlitepager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
#ifdef SQLITE_TEST
void sqlitepager_refdump(Pager*);
int pager_refinfo_enable;
int journal_format;
#endif
+527 -161
View File
@@ -14,21 +14,47 @@
** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.37 2001/10/13 02:59:09 drh Exp $
** @(#) $Id: parse.y,v 1.112 2004/02/22 18:40:57 drh Exp $
*/
%token_prefix TK_
%token_type {Token}
%default_type {Token}
%extra_argument {Parse *pParse}
%syntax_error {
sqliteSetString(&pParse->zErrMsg,"syntax error",0);
pParse->sErrToken = TOKEN;
if( pParse->zErrMsg==0 ){
if( TOKEN.z[0] ){
sqliteErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
}else{
sqliteErrorMsg(pParse, "incomplete SQL statement");
}
}
}
%name sqliteParser
%include {
#include "sqliteInt.h"
#include "parse.h"
}
/*
** An instance of this structure holds information about the
** LIMIT clause of a SELECT statement.
*/
struct LimitVal {
int limit; /* The LIMIT value. -1 if there is no limit */
int offset; /* The OFFSET. 0 if there is none */
};
/*
** An instance of the following structure describes the event of a
** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
** TK_DELETE, or TK_INSTEAD. If the event is of the form
**
** UPDATE ON (a,b,c)
**
** Then the "b" IdList records the list "a,b,c".
*/
struct TrigEvent { int a; IdList * b; };
} // end %include
// These are extra tokens used by the lexer but never seen by the
// parser. We put them in a rule so that the parser generator will
@@ -37,24 +63,23 @@
%nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
COLUMN AGG_FUNCTION.
// Input is zero or more commands.
// Input is a single SQL command
input ::= cmdlist.
// A list of commands is zero or more commands
//
cmdlist ::= cmdlist ecmd.
cmdlist ::= ecmd.
cmdlist ::= cmdlist SEMI ecmd.
ecmd ::= explain cmd. {sqliteExec(pParse);}
ecmd ::= cmd. {sqliteExec(pParse);}
ecmd ::= .
explain ::= EXPLAIN. {pParse->explain = 1;}
ecmd ::= explain cmdx SEMI.
ecmd ::= SEMI.
cmdx ::= cmd. { sqliteExec(pParse); }
explain ::= EXPLAIN. { sqliteBeginParse(pParse, 1); }
explain ::= . { sqliteBeginParse(pParse, 0); }
///////////////////// Begin and end transactions. ////////////////////////////
//
cmd ::= BEGIN trans_opt. {sqliteBeginTransaction(pParse);}
cmd ::= BEGIN trans_opt onconf(R). {sqliteBeginTransaction(pParse,R);}
trans_opt ::= .
trans_opt ::= TRANSACTION.
trans_opt ::= TRANSACTION ids.
trans_opt ::= TRANSACTION nm.
cmd ::= COMMIT trans_opt. {sqliteCommitTransaction(pParse);}
cmd ::= END trans_opt. {sqliteCommitTransaction(pParse);}
cmd ::= ROLLBACK trans_opt. {sqliteRollbackTransaction(pParse);}
@@ -62,13 +87,19 @@ cmd ::= ROLLBACK trans_opt. {sqliteRollbackTransaction(pParse);}
///////////////////// The CREATE TABLE statement ////////////////////////////
//
cmd ::= create_table create_table_args.
create_table ::= CREATE(X) temp(T) TABLE ids(Y).
{sqliteStartTable(pParse,&X,&Y,T);}
create_table ::= CREATE(X) temp(T) TABLE nm(Y). {
sqliteStartTable(pParse,&X,&Y,T,0);
}
%type temp {int}
temp(A) ::= TEMP. {A = 1;}
temp(A) ::= . {A = 0;}
create_table_args ::= LP columnlist conslist_opt RP(X).
{sqliteEndTable(pParse,&X);}
create_table_args ::= LP columnlist conslist_opt RP(X). {
sqliteEndTable(pParse,&X,0);
}
create_table_args ::= AS select(S). {
sqliteEndTable(pParse,0,S);
sqliteSelectDelete(S);
}
columnlist ::= columnlist COMMA column.
columnlist ::= column.
@@ -77,32 +108,54 @@ columnlist ::= column.
// an elaborate typename. Perhaps someday we'll do something with it.
//
column ::= columnid type carglist.
columnid ::= ids(X). {sqliteAddColumn(pParse,&X);}
columnid ::= nm(X). {sqliteAddColumn(pParse,&X);}
// An IDENTIFIER can be a generic identifier, or one of several
// keywords. Any non-standard keyword can also be an identifier.
// We also make DESC and identifier since it comes up so often (as
// an abbreviation of "description").
//
%type id {Token}
id(A) ::= DESC(X). {A = X;}
id(A) ::= ASC(X). {A = X;}
id(A) ::= DELIMITERS(X). {A = X;}
id(A) ::= EXPLAIN(X). {A = X;}
id(A) ::= VACUUM(X). {A = X;}
id(A) ::= BEGIN(X). {A = X;}
id(A) ::= END(X). {A = X;}
id(A) ::= PRAGMA(X). {A = X;}
id(A) ::= CLUSTER(X). {A = X;}
id(A) ::= ID(X). {A = X;}
id(A) ::= TEMP(X). {A = X;}
// The following directive causes tokens ABORT, AFTER, ASC, etc. to
// fallback to ID if they will not parse as their original value.
// This obviates the need for the "id" nonterminal.
//
%fallback ID
ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT
COPY DATABASE DEFERRED DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR
GLOB IGNORE IMMEDIATE INITIALLY INSTEAD LIKE MATCH KEY
OF OFFSET PRAGMA RAISE REPLACE RESTRICT ROW STATEMENT
TEMP TRIGGER VACUUM VIEW.
// Define operator precedence early so that this is the first occurance
// of the operator tokens in the grammer. Keeping the operators together
// causes them to be assigned integer values that are close together,
// which keeps parser tables smaller.
//
%left OR.
%left AND.
%right NOT.
%left EQ NE ISNULL NOTNULL IS LIKE GLOB BETWEEN IN.
%left GT GE LT LE.
%left BITAND BITOR LSHIFT RSHIFT.
%left PLUS MINUS.
%left STAR SLASH REM.
%left CONCAT.
%right UMINUS UPLUS BITNOT.
// And "ids" is an identifer-or-string.
//
%type ids {Token}
ids(A) ::= id(X). {A = X;}
ids(A) ::= ID(X). {A = X;}
ids(A) ::= STRING(X). {A = X;}
// The name of a column or table can be any of the following:
//
%type nm {Token}
nm(A) ::= ID(X). {A = X;}
nm(A) ::= STRING(X). {A = X;}
nm(A) ::= JOIN_KW(X). {A = X;}
type ::= .
type ::= typename(X). {sqliteAddColumnType(pParse,&X,&X);}
type ::= typename(X) LP signed RP(Y). {sqliteAddColumnType(pParse,&X,&Y);}
@@ -111,12 +164,13 @@ type ::= typename(X) LP signed COMMA signed RP(Y).
%type typename {Token}
typename(A) ::= ids(X). {A = X;}
typename(A) ::= typename(X) ids. {A = X;}
signed ::= INTEGER.
signed ::= PLUS INTEGER.
signed ::= MINUS INTEGER.
%type signed {int}
signed(A) ::= INTEGER(X). { A = atoi(X.z); }
signed(A) ::= PLUS INTEGER(X). { A = atoi(X.z); }
signed(A) ::= MINUS INTEGER(X). { A = -atoi(X.z); }
carglist ::= carglist carg.
carglist ::= .
carg ::= CONSTRAINT ids ccons.
carg ::= CONSTRAINT nm ccons.
carg ::= ccons.
carg ::= DEFAULT STRING(X). {sqliteAddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT ID(X). {sqliteAddDefaultValue(pParse,&X,0);}
@@ -131,10 +185,43 @@ carg ::= DEFAULT NULL.
// In addition to the type name, we also care about the primary key and
// UNIQUE constraints.
//
ccons ::= NOT NULL. {sqliteAddNotNull(pParse);}
ccons ::= PRIMARY KEY sortorder. {sqliteCreateIndex(pParse,0,0,0,1,0,0);}
ccons ::= UNIQUE. {sqliteCreateIndex(pParse,0,0,0,1,0,0);}
ccons ::= CHECK LP expr RP.
ccons ::= NULL onconf.
ccons ::= NOT NULL onconf(R). {sqliteAddNotNull(pParse, R);}
ccons ::= PRIMARY KEY sortorder onconf(R). {sqliteAddPrimaryKey(pParse,0,R);}
ccons ::= UNIQUE onconf(R). {sqliteCreateIndex(pParse,0,0,0,R,0,0);}
ccons ::= CHECK LP expr RP onconf.
ccons ::= REFERENCES nm(T) idxlist_opt(TA) refargs(R).
{sqliteCreateForeignKey(pParse,0,&T,TA,R);}
ccons ::= defer_subclause(D). {sqliteDeferForeignKey(pParse,D);}
ccons ::= COLLATE id(C). {
sqliteAddCollateType(pParse, sqliteCollateType(C.z, C.n));
}
// The next group of rules parses the arguments to a REFERENCES clause
// that determine if the referential integrity checking is deferred or
// or immediate and which determine what action to take if a ref-integ
// check fails.
//
%type refargs {int}
refargs(A) ::= . { A = OE_Restrict * 0x010101; }
refargs(A) ::= refargs(X) refarg(Y). { A = (X & Y.mask) | Y.value; }
%type refarg {struct {int value; int mask;}}
refarg(A) ::= MATCH nm. { A.value = 0; A.mask = 0x000000; }
refarg(A) ::= ON DELETE refact(X). { A.value = X; A.mask = 0x0000ff; }
refarg(A) ::= ON UPDATE refact(X). { A.value = X<<8; A.mask = 0x00ff00; }
refarg(A) ::= ON INSERT refact(X). { A.value = X<<16; A.mask = 0xff0000; }
%type refact {int}
refact(A) ::= SET NULL. { A = OE_SetNull; }
refact(A) ::= SET DEFAULT. { A = OE_SetDflt; }
refact(A) ::= CASCADE. { A = OE_Cascade; }
refact(A) ::= RESTRICT. { A = OE_Restrict; }
%type defer_subclause {int}
defer_subclause(A) ::= NOT DEFERRABLE init_deferred_pred_opt(X). {A = X;}
defer_subclause(A) ::= DEFERRABLE init_deferred_pred_opt(X). {A = X;}
%type init_deferred_pred_opt {int}
init_deferred_pred_opt(A) ::= . {A = 0;}
init_deferred_pred_opt(A) ::= INITIALLY DEFERRED. {A = 1;}
init_deferred_pred_opt(A) ::= INITIALLY IMMEDIATE. {A = 0;}
// For the time being, the only constraint we care about is the primary
// key and UNIQUE. Both create indices.
@@ -144,19 +231,54 @@ conslist_opt ::= COMMA conslist.
conslist ::= conslist COMMA tcons.
conslist ::= conslist tcons.
conslist ::= tcons.
tcons ::= CONSTRAINT ids.
tcons ::= PRIMARY KEY LP idxlist(X) RP. {sqliteCreateIndex(pParse,0,0,X,1,0,0);}
tcons ::= UNIQUE LP idxlist(X) RP. {sqliteCreateIndex(pParse,0,0,X,1,0,0);}
tcons ::= CHECK expr.
tcons ::= CONSTRAINT nm.
tcons ::= PRIMARY KEY LP idxlist(X) RP onconf(R).
{sqliteAddPrimaryKey(pParse,X,R);}
tcons ::= UNIQUE LP idxlist(X) RP onconf(R).
{sqliteCreateIndex(pParse,0,0,X,R,0,0);}
tcons ::= CHECK expr onconf.
tcons ::= FOREIGN KEY LP idxlist(FA) RP
REFERENCES nm(T) idxlist_opt(TA) refargs(R) defer_subclause_opt(D). {
sqliteCreateForeignKey(pParse, FA, &T, TA, R);
sqliteDeferForeignKey(pParse, D);
}
%type defer_subclause_opt {int}
defer_subclause_opt(A) ::= . {A = 0;}
defer_subclause_opt(A) ::= defer_subclause(X). {A = X;}
// The following is a non-standard extension that allows us to declare the
// default behavior when there is a constraint conflict.
//
%type onconf {int}
%type orconf {int}
%type resolvetype {int}
onconf(A) ::= . { A = OE_Default; }
onconf(A) ::= ON CONFLICT resolvetype(X). { A = X; }
orconf(A) ::= . { A = OE_Default; }
orconf(A) ::= OR resolvetype(X). { A = X; }
resolvetype(A) ::= ROLLBACK. { A = OE_Rollback; }
resolvetype(A) ::= ABORT. { A = OE_Abort; }
resolvetype(A) ::= FAIL. { A = OE_Fail; }
resolvetype(A) ::= IGNORE. { A = OE_Ignore; }
resolvetype(A) ::= REPLACE. { A = OE_Replace; }
////////////////////////// The DROP TABLE /////////////////////////////////////
//
cmd ::= DROP TABLE ids(X). {sqliteDropTable(pParse,&X);}
cmd ::= DROP TABLE nm(X). {sqliteDropTable(pParse,&X,0);}
///////////////////// The CREATE VIEW statement /////////////////////////////
//
cmd ::= CREATE(X) temp(T) VIEW nm(Y) AS select(S). {
sqliteCreateView(pParse, &X, &Y, S, T);
}
cmd ::= DROP VIEW nm(X). {
sqliteDropTable(pParse, &X, 1);
}
//////////////////////// The SELECT statement /////////////////////////////////
//
cmd ::= select(X). {
sqliteSelect(pParse, X, SRT_Callback, 0);
sqliteSelect(pParse, X, SRT_Callback, 0, 0, 0, 0);
sqliteSelectDelete(X);
}
@@ -166,21 +288,21 @@ cmd ::= select(X). {
%destructor oneselect {sqliteSelectDelete($$);}
select(A) ::= oneselect(X). {A = X;}
select(A) ::= select(X) joinop(Y) oneselect(Z). {
select(A) ::= select(X) multiselect_op(Y) oneselect(Z). {
if( Z ){
Z->op = Y;
Z->pPrior = X;
}
A = Z;
}
%type joinop {int}
joinop(A) ::= UNION. {A = TK_UNION;}
joinop(A) ::= UNION ALL. {A = TK_ALL;}
joinop(A) ::= INTERSECT. {A = TK_INTERSECT;}
joinop(A) ::= EXCEPT. {A = TK_EXCEPT;}
%type multiselect_op {int}
multiselect_op(A) ::= UNION. {A = TK_UNION;}
multiselect_op(A) ::= UNION ALL. {A = TK_ALL;}
multiselect_op(A) ::= INTERSECT. {A = TK_INTERSECT;}
multiselect_op(A) ::= EXCEPT. {A = TK_EXCEPT;}
oneselect(A) ::= SELECT distinct(D) selcollist(W) from(X) where_opt(Y)
groupby_opt(P) having_opt(Q) orderby_opt(Z). {
A = sqliteSelectNew(W,X,Y,P,Q,Z,D);
groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). {
A = sqliteSelectNew(W,X,Y,P,Q,Z,D,L.limit,L.offset);
}
// The "distinct" nonterminal is true (1) if the DISTINCT keyword is
@@ -192,8 +314,9 @@ distinct(A) ::= ALL. {A = 0;}
distinct(A) ::= . {A = 0;}
// selcollist is a list of expressions that are to become the return
// values of the SELECT statement. In the case of "SELECT * FROM ..."
// the selcollist value is NULL.
// values of the SELECT statement. The "*" in statements like
// "SELECT * FROM ..." is encoded as a special expression with an
// opcode of TK_ALL.
//
%type selcollist {ExprList*}
%destructor selcollist {sqliteExprListDelete($$);}
@@ -201,28 +324,108 @@ distinct(A) ::= . {A = 0;}
%destructor sclp {sqliteExprListDelete($$);}
sclp(A) ::= selcollist(X) COMMA. {A = X;}
sclp(A) ::= . {A = 0;}
selcollist(A) ::= STAR. {A = 0;}
selcollist(A) ::= sclp(P) expr(X). {A = sqliteExprListAppend(P,X,0);}
selcollist(A) ::= sclp(P) expr(X) as ids(Y). {A = sqliteExprListAppend(P,X,&Y);}
as ::= .
as ::= AS.
%type seltablist {IdList*}
%destructor seltablist {sqliteIdListDelete($$);}
%type stl_prefix {IdList*}
%destructor stl_prefix {sqliteIdListDelete($$);}
%type from {IdList*}
%destructor from {sqliteIdListDelete($$);}
from(A) ::= FROM seltablist(X). {A = X;}
stl_prefix(A) ::= seltablist(X) COMMA. {A = X;}
stl_prefix(A) ::= . {A = 0;}
seltablist(A) ::= stl_prefix(X) ids(Y). {A = sqliteIdListAppend(X,&Y);}
seltablist(A) ::= stl_prefix(X) ids(Y) as ids(Z). {
A = sqliteIdListAppend(X,&Y);
sqliteIdListAddAlias(A,&Z);
selcollist(A) ::= sclp(P) expr(X) as(Y). {
A = sqliteExprListAppend(P,X,Y.n?&Y:0);
}
selcollist(A) ::= sclp(P) STAR. {
A = sqliteExprListAppend(P, sqliteExpr(TK_ALL, 0, 0, 0), 0);
}
selcollist(A) ::= sclp(P) nm(X) DOT STAR. {
Expr *pRight = sqliteExpr(TK_ALL, 0, 0, 0);
Expr *pLeft = sqliteExpr(TK_ID, 0, 0, &X);
A = sqliteExprListAppend(P, sqliteExpr(TK_DOT, pLeft, pRight, 0), 0);
}
// An option "AS <id>" phrase that can follow one of the expressions that
// define the result set, or one of the tables in the FROM clause.
//
%type as {Token}
as(X) ::= AS nm(Y). { X = Y; }
as(X) ::= ids(Y). { X = Y; }
as(X) ::= . { X.n = 0; }
%type seltablist {SrcList*}
%destructor seltablist {sqliteSrcListDelete($$);}
%type stl_prefix {SrcList*}
%destructor stl_prefix {sqliteSrcListDelete($$);}
%type from {SrcList*}
%destructor from {sqliteSrcListDelete($$);}
// A complete FROM clause.
//
from(A) ::= . {A = sqliteMalloc(sizeof(*A));}
from(A) ::= FROM seltablist(X). {A = X;}
// "seltablist" is a "Select Table List" - the content of the FROM clause
// in a SELECT statement. "stl_prefix" is a prefix of this list.
//
stl_prefix(A) ::= seltablist(X) joinop(Y). {
A = X;
if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = Y;
}
stl_prefix(A) ::= . {A = 0;}
seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) on_opt(N) using_opt(U). {
A = sqliteSrcListAppend(X,&Y,&D);
if( Z.n ) sqliteSrcListAddAlias(A,&Z);
if( N ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; }
else { sqliteExprDelete(N); }
}
if( U ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; }
else { sqliteIdListDelete(U); }
}
}
seltablist(A) ::= stl_prefix(X) LP seltablist_paren(S) RP
as(Z) on_opt(N) using_opt(U). {
A = sqliteSrcListAppend(X,0,0);
A->a[A->nSrc-1].pSelect = S;
if( Z.n ) sqliteSrcListAddAlias(A,&Z);
if( N ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; }
else { sqliteExprDelete(N); }
}
if( U ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; }
else { sqliteIdListDelete(U); }
}
}
// A seltablist_paren nonterminal represents anything in a FROM that
// is contained inside parentheses. This can be either a subquery or
// a grouping of table and subqueries.
//
%type seltablist_paren {Select*}
%destructor seltablist_paren {sqliteSelectDelete($$);}
seltablist_paren(A) ::= select(S). {A = S;}
seltablist_paren(A) ::= seltablist(F). {
A = sqliteSelectNew(0,F,0,0,0,0,0,-1,0);
}
%type dbnm {Token}
dbnm(A) ::= . {A.z=0; A.n=0;}
dbnm(A) ::= DOT nm(X). {A = X;}
%type joinop {int}
%type joinop2 {int}
joinop(X) ::= COMMA. { X = JT_INNER; }
joinop(X) ::= JOIN. { X = JT_INNER; }
joinop(X) ::= JOIN_KW(A) JOIN. { X = sqliteJoinType(pParse,&A,0,0); }
joinop(X) ::= JOIN_KW(A) nm(B) JOIN. { X = sqliteJoinType(pParse,&A,&B,0); }
joinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN.
{ X = sqliteJoinType(pParse,&A,&B,&C); }
%type on_opt {Expr*}
%destructor on_opt {sqliteExprDelete($$);}
on_opt(N) ::= ON expr(E). {N = E;}
on_opt(N) ::= . {N = 0;}
%type using_opt {IdList*}
%destructor using_opt {sqliteIdListDelete($$);}
using_opt(U) ::= USING LP idxlist(L) RP. {U = L;}
using_opt(U) ::= . {U = 0;}
%type orderby_opt {ExprList*}
%destructor orderby_opt {sqliteExprListDelete($$);}
@@ -233,21 +436,24 @@ seltablist(A) ::= stl_prefix(X) ids(Y) as ids(Z). {
orderby_opt(A) ::= . {A = 0;}
orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
sortlist(A) ::= sortlist(X) COMMA sortitem(Y) sortorder(Z). {
sortlist(A) ::= sortlist(X) COMMA sortitem(Y) collate(C) sortorder(Z). {
A = sqliteExprListAppend(X,Y,0);
if( A ) A->a[A->nExpr-1].sortOrder = Z; /* 0=ascending, 1=decending */
if( A ) A->a[A->nExpr-1].sortOrder = C+Z;
}
sortlist(A) ::= sortitem(Y) sortorder(Z). {
sortlist(A) ::= sortitem(Y) collate(C) sortorder(Z). {
A = sqliteExprListAppend(0,Y,0);
if( A ) A->a[0].sortOrder = Z;
if( A ) A->a[0].sortOrder = C+Z;
}
sortitem(A) ::= expr(X). {A = X;}
%type sortorder {int}
%type collate {int}
sortorder(A) ::= ASC. {A = 0;}
sortorder(A) ::= DESC. {A = 1;}
sortorder(A) ::= . {A = 0;}
sortorder(A) ::= ASC. {A = SQLITE_SO_ASC;}
sortorder(A) ::= DESC. {A = SQLITE_SO_DESC;}
sortorder(A) ::= . {A = SQLITE_SO_ASC;}
collate(C) ::= . {C = SQLITE_SO_UNK;}
collate(C) ::= COLLATE id(X). {C = sqliteCollateType(X.z, X.n);}
%type groupby_opt {ExprList*}
%destructor groupby_opt {sqliteExprListDelete($$);}
@@ -259,10 +465,19 @@ groupby_opt(A) ::= GROUP BY exprlist(X). {A = X;}
having_opt(A) ::= . {A = 0;}
having_opt(A) ::= HAVING expr(X). {A = X;}
%type limit_opt {struct LimitVal}
limit_opt(A) ::= . {A.limit = -1; A.offset = 0;}
limit_opt(A) ::= LIMIT signed(X). {A.limit = X; A.offset = 0;}
limit_opt(A) ::= LIMIT signed(X) OFFSET signed(Y).
{A.limit = X; A.offset = Y;}
limit_opt(A) ::= LIMIT signed(X) COMMA signed(Y).
{A.limit = Y; A.offset = X;}
/////////////////////////// The DELETE statement /////////////////////////////
//
cmd ::= DELETE FROM ids(X) where_opt(Y).
{sqliteDeleteFrom(pParse, &X, Y);}
cmd ::= DELETE FROM nm(X) dbnm(D) where_opt(Y). {
sqliteDeleteFrom(pParse, sqliteSrcListAppend(0,&X,&D), Y);
}
%type where_opt {Expr*}
%destructor where_opt {sqliteExprDelete($$);}
@@ -275,42 +490,31 @@ where_opt(A) ::= WHERE expr(X). {A = X;}
////////////////////////// The UPDATE command ////////////////////////////////
//
cmd ::= UPDATE ids(X) SET setlist(Y) where_opt(Z).
{sqliteUpdate(pParse,&X,Y,Z);}
cmd ::= UPDATE orconf(R) nm(X) dbnm(D) SET setlist(Y) where_opt(Z).
{sqliteUpdate(pParse,sqliteSrcListAppend(0,&X,&D),Y,Z,R);}
setlist(A) ::= setlist(Z) COMMA ids(X) EQ expr(Y).
setlist(A) ::= setlist(Z) COMMA nm(X) EQ expr(Y).
{A = sqliteExprListAppend(Z,Y,&X);}
setlist(A) ::= ids(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);}
setlist(A) ::= nm(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);}
////////////////////////// The INSERT command /////////////////////////////////
//
cmd ::= INSERT INTO ids(X) inscollist_opt(F) VALUES LP itemlist(Y) RP.
{sqliteInsert(pParse, &X, Y, 0, F);}
cmd ::= INSERT INTO ids(X) inscollist_opt(F) select(S).
{sqliteInsert(pParse, &X, 0, S, F);}
cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F)
VALUES LP itemlist(Y) RP.
{sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), Y, 0, F, R);}
cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F) select(S).
{sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), 0, S, F, R);}
%type insert_cmd {int}
insert_cmd(A) ::= INSERT orconf(R). {A = R;}
insert_cmd(A) ::= REPLACE. {A = OE_Replace;}
%type itemlist {ExprList*}
%destructor itemlist {sqliteExprListDelete($$);}
%type item {Expr*}
%destructor item {sqliteExprDelete($$);}
itemlist(A) ::= itemlist(X) COMMA item(Y). {A = sqliteExprListAppend(X,Y,0);}
itemlist(A) ::= item(X). {A = sqliteExprListAppend(0,X,0);}
item(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
item(A) ::= PLUS INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
item(A) ::= MINUS INTEGER(X). {
A = sqliteExpr(TK_UMINUS, 0, 0, 0);
if( A ) A->pLeft = sqliteExpr(TK_INTEGER, 0, 0, &X);
}
item(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
item(A) ::= PLUS FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
item(A) ::= MINUS FLOAT(X). {
A = sqliteExpr(TK_UMINUS, 0, 0, 0);
if( A ) A->pLeft = sqliteExpr(TK_FLOAT, 0, 0, &X);
}
item(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
item(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);}
itemlist(A) ::= itemlist(X) COMMA expr(Y). {A = sqliteExprListAppend(X,Y,0);}
itemlist(A) ::= expr(X). {A = sqliteExprListAppend(0,X,0);}
%type inscollist_opt {IdList*}
%destructor inscollist_opt {sqliteIdListDelete($$);}
@@ -319,36 +523,38 @@ item(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);}
inscollist_opt(A) ::= . {A = 0;}
inscollist_opt(A) ::= LP inscollist(X) RP. {A = X;}
inscollist(A) ::= inscollist(X) COMMA ids(Y). {A = sqliteIdListAppend(X,&Y);}
inscollist(A) ::= ids(Y). {A = sqliteIdListAppend(0,&Y);}
inscollist(A) ::= inscollist(X) COMMA nm(Y). {A = sqliteIdListAppend(X,&Y);}
inscollist(A) ::= nm(Y). {A = sqliteIdListAppend(0,&Y);}
/////////////////////////// Expression Processing /////////////////////////////
//
%left OR.
%left AND.
%right NOT.
%left EQ NE ISNULL NOTNULL IS LIKE GLOB BETWEEN IN.
%left GT GE LT LE.
%left BITAND BITOR LSHIFT RSHIFT.
%left PLUS MINUS.
%left STAR SLASH REM.
%left CONCAT.
%right UMINUS BITNOT.
%type expr {Expr*}
%destructor expr {sqliteExprDelete($$);}
expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqliteExprSpan(A,&B,&E);}
expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqliteExprSpan(A,&B,&E); }
expr(A) ::= NULL(X). {A = sqliteExpr(TK_NULL, 0, 0, &X);}
expr(A) ::= id(X). {A = sqliteExpr(TK_ID, 0, 0, &X);}
expr(A) ::= ids(X) DOT ids(Y). {
expr(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);}
expr(A) ::= JOIN_KW(X). {A = sqliteExpr(TK_ID, 0, 0, &X);}
expr(A) ::= nm(X) DOT nm(Y). {
Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
A = sqliteExpr(TK_DOT, temp1, temp2, 0);
}
expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). {
Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
Expr *temp3 = sqliteExpr(TK_ID, 0, 0, &Z);
Expr *temp4 = sqliteExpr(TK_DOT, temp2, temp3, 0);
A = sqliteExpr(TK_DOT, temp1, temp4, 0);
}
expr(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
expr(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
expr(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
expr(A) ::= VARIABLE(X). {
A = sqliteExpr(TK_VARIABLE, 0, 0, &X);
if( A ) A->iTable = ++pParse->nVar;
}
expr(A) ::= ID(X) LP exprlist(Y) RP(E). {
A = sqliteExprFunction(Y, &X);
sqliteExprSpan(A,&X,&E);
@@ -369,18 +575,24 @@ expr(A) ::= expr(X) BITAND expr(Y). {A = sqliteExpr(TK_BITAND, X, Y, 0);}
expr(A) ::= expr(X) BITOR expr(Y). {A = sqliteExpr(TK_BITOR, X, Y, 0);}
expr(A) ::= expr(X) LSHIFT expr(Y). {A = sqliteExpr(TK_LSHIFT, X, Y, 0);}
expr(A) ::= expr(X) RSHIFT expr(Y). {A = sqliteExpr(TK_RSHIFT, X, Y, 0);}
expr(A) ::= expr(X) LIKE expr(Y). {A = sqliteExpr(TK_LIKE, X, Y, 0);}
expr(A) ::= expr(X) NOT LIKE expr(Y). {
A = sqliteExpr(TK_LIKE, X, Y, 0);
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,&Y->span);
}
expr(A) ::= expr(X) GLOB expr(Y). {A = sqliteExpr(TK_GLOB,X,Y,0);}
expr(A) ::= expr(X) NOT GLOB expr(Y). {
A = sqliteExpr(TK_GLOB, X, Y, 0);
expr(A) ::= expr(X) likeop(OP) expr(Y). [LIKE] {
ExprList *pList = sqliteExprListAppend(0, Y, 0);
pList = sqliteExprListAppend(pList, X, 0);
A = sqliteExprFunction(pList, 0);
if( A ) A->op = OP;
sqliteExprSpan(A, &X->span, &Y->span);
}
expr(A) ::= expr(X) NOT likeop(OP) expr(Y). [LIKE] {
ExprList *pList = sqliteExprListAppend(0, Y, 0);
pList = sqliteExprListAppend(pList, X, 0);
A = sqliteExprFunction(pList, 0);
if( A ) A->op = OP;
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,&Y->span);
}
%type likeop {int}
likeop(A) ::= LIKE. {A = TK_LIKE;}
likeop(A) ::= GLOB. {A = TK_GLOB;}
expr(A) ::= expr(X) PLUS expr(Y). {A = sqliteExpr(TK_PLUS, X, Y, 0);}
expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);}
expr(A) ::= expr(X) STAR expr(Y). {A = sqliteExpr(TK_STAR, X, Y, 0);}
@@ -419,8 +631,8 @@ expr(A) ::= MINUS(B) expr(X). [UMINUS] {
A = sqliteExpr(TK_UMINUS, X, 0, 0);
sqliteExprSpan(A,&B,&X->span);
}
expr(A) ::= PLUS(B) expr(X). [UMINUS] {
A = X;
expr(A) ::= PLUS(B) expr(X). [UPLUS] {
A = sqliteExpr(TK_UPLUS, X, 0, 0);
sqliteExprSpan(A,&B,&X->span);
}
expr(A) ::= LP(B) select(X) RP(E). {
@@ -465,8 +677,43 @@ expr(A) ::= expr(X) NOT IN LP select(Y) RP(E). {
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) IN nm(Y) dbnm(D). {
SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
A = sqliteExpr(TK_IN, X, 0, 0);
if( A ) A->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0);
sqliteExprSpan(A,&X->span,D.z?&D:&Y);
}
expr(A) ::= expr(X) NOT IN nm(Y) dbnm(D). {
SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
A = sqliteExpr(TK_IN, X, 0, 0);
if( A ) A->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0);
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,D.z?&D:&Y);
}
/* CASE expressions */
expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {
A = sqliteExpr(TK_CASE, X, Z, 0);
if( A ) A->pList = Y;
sqliteExprSpan(A, &C, &E);
}
%type case_exprlist {ExprList*}
%destructor case_exprlist {sqliteExprListDelete($$);}
case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). {
A = sqliteExprListAppend(X, Y, 0);
A = sqliteExprListAppend(A, Z, 0);
}
case_exprlist(A) ::= WHEN expr(Y) THEN expr(Z). {
A = sqliteExprListAppend(0, Y, 0);
A = sqliteExprListAppend(A, Z, 0);
}
%type case_else {Expr*}
case_else(A) ::= ELSE expr(X). {A = X;}
case_else(A) ::= . {A = 0;}
%type case_operand {Expr*}
case_operand(A) ::= expr(X). {A = X;}
case_operand(A) ::= . {A = 0;}
%type exprlist {ExprList*}
%destructor exprlist {sqliteExprListDelete($$);}
@@ -481,51 +728,170 @@ expritem(A) ::= . {A = 0;}
///////////////////////////// The CREATE INDEX command ///////////////////////
//
cmd ::= CREATE(S) uniqueflag(U) INDEX ids(X) ON ids(Y) LP idxlist(Z) RP(E).
{sqliteCreateIndex(pParse, &X, &Y, Z, U, &S, &E);}
cmd ::= CREATE(S) uniqueflag(U) INDEX nm(X)
ON nm(Y) dbnm(D) LP idxlist(Z) RP(E) onconf(R). {
SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
if( U!=OE_None ) U = R;
if( U==OE_Default) U = OE_Abort;
sqliteCreateIndex(pParse, &X, pSrc, Z, U, &S, &E);
}
%type uniqueflag {int}
uniqueflag(A) ::= UNIQUE. { A = 1; }
uniqueflag(A) ::= . { A = 0; }
uniqueflag(A) ::= UNIQUE. { A = OE_Abort; }
uniqueflag(A) ::= . { A = OE_None; }
%type idxlist {IdList*}
%destructor idxlist {sqliteIdListDelete($$);}
%type idxlist_opt {IdList*}
%destructor idxlist_opt {sqliteIdListDelete($$);}
%type idxitem {Token}
idxlist(A) ::= idxlist(X) COMMA idxitem(Y).
{A = sqliteIdListAppend(X,&Y);}
idxlist(A) ::= idxitem(Y).
{A = sqliteIdListAppend(0,&Y);}
idxitem(A) ::= ids(X). {A = X;}
///////////////////////////// The CREATE INDEX command ///////////////////////
//
cmd ::= DROP INDEX ids(X). {sqliteDropIndex(pParse, &X);}
idxlist_opt(A) ::= . {A = 0;}
idxlist_opt(A) ::= LP idxlist(X) RP. {A = X;}
idxlist(A) ::= idxlist(X) COMMA idxitem(Y). {A = sqliteIdListAppend(X,&Y);}
idxlist(A) ::= idxitem(Y). {A = sqliteIdListAppend(0,&Y);}
idxitem(A) ::= nm(X) sortorder. {A = X;}
///////////////////////////// The DROP INDEX command /////////////////////////
//
cmd ::= COPY ids(X) FROM ids(Y) USING DELIMITERS STRING(Z).
{sqliteCopy(pParse,&X,&Y,&Z);}
cmd ::= COPY ids(X) FROM ids(Y).
{sqliteCopy(pParse,&X,&Y,0);}
cmd ::= DROP INDEX nm(X) dbnm(Y). {
sqliteDropIndex(pParse, sqliteSrcListAppend(0,&X,&Y));
}
///////////////////////////// The COPY command ///////////////////////////////
//
cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y) USING DELIMITERS STRING(Z).
{sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,&Z,R);}
cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y).
{sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,0,R);}
///////////////////////////// The VACUUM command /////////////////////////////
//
cmd ::= VACUUM. {sqliteVacuum(pParse,0);}
cmd ::= VACUUM ids(X). {sqliteVacuum(pParse,&X);}
cmd ::= VACUUM nm(X). {sqliteVacuum(pParse,&X);}
///////////////////////////// The PRAGMA command /////////////////////////////
//
cmd ::= PRAGMA ids(X) EQ ids(Y). {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ nm(Y). {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ ON(Y). {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ plus_num(Y). {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ minus_num(Y). {sqlitePragma(pParse,&X,&Y,1);}
cmd ::= PRAGMA ids(X) LP ids(Y) RP. {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) LP nm(Y) RP. {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X). {sqlitePragma(pParse,&X,&X,0);}
plus_num(A) ::= plus_opt number(X). {A = X;}
minus_num(A) ::= MINUS number(X). {A = X;}
number(A) ::= INTEGER(X). {A = X;}
number(A) ::= FLOAT(X). {A = X;}
plus_opt ::= PLUS.
plus_opt ::= .
//////////////////////////// The CREATE TRIGGER command /////////////////////
cmd ::= CREATE(A) trigger_decl BEGIN trigger_cmd_list(S) END(Z). {
Token all;
all.z = A.z;
all.n = (Z.z - A.z) + Z.n;
sqliteFinishTrigger(pParse, S, &all);
}
trigger_decl ::= temp(T) TRIGGER nm(B) trigger_time(C) trigger_event(D)
ON nm(E) dbnm(DB) foreach_clause(F) when_clause(G). {
SrcList *pTab = sqliteSrcListAppend(0, &E, &DB);
sqliteBeginTrigger(pParse, &B, C, D.a, D.b, pTab, F, G, T);
}
%type trigger_time {int}
trigger_time(A) ::= BEFORE. { A = TK_BEFORE; }
trigger_time(A) ::= AFTER. { A = TK_AFTER; }
trigger_time(A) ::= INSTEAD OF. { A = TK_INSTEAD;}
trigger_time(A) ::= . { A = TK_BEFORE; }
%type trigger_event {struct TrigEvent}
%destructor trigger_event {sqliteIdListDelete($$.b);}
trigger_event(A) ::= DELETE. { A.a = TK_DELETE; A.b = 0; }
trigger_event(A) ::= INSERT. { A.a = TK_INSERT; A.b = 0; }
trigger_event(A) ::= UPDATE. { A.a = TK_UPDATE; A.b = 0;}
trigger_event(A) ::= UPDATE OF inscollist(X). {A.a = TK_UPDATE; A.b = X; }
%type foreach_clause {int}
foreach_clause(A) ::= . { A = TK_ROW; }
foreach_clause(A) ::= FOR EACH ROW. { A = TK_ROW; }
foreach_clause(A) ::= FOR EACH STATEMENT. { A = TK_STATEMENT; }
%type when_clause {Expr *}
when_clause(A) ::= . { A = 0; }
when_clause(A) ::= WHEN expr(X). { A = X; }
%type trigger_cmd_list {TriggerStep *}
%destructor trigger_cmd_list {sqliteDeleteTriggerStep($$);}
trigger_cmd_list(A) ::= trigger_cmd(X) SEMI trigger_cmd_list(Y). {
X->pNext = Y;
A = X;
}
trigger_cmd_list(A) ::= . { A = 0; }
%type trigger_cmd {TriggerStep *}
%destructor trigger_cmd {sqliteDeleteTriggerStep($$);}
// UPDATE
trigger_cmd(A) ::= UPDATE orconf(R) nm(X) SET setlist(Y) where_opt(Z).
{ A = sqliteTriggerUpdateStep(&X, Y, Z, R); }
// INSERT
trigger_cmd(A) ::= insert_cmd(R) INTO nm(X) inscollist_opt(F)
VALUES LP itemlist(Y) RP.
{A = sqliteTriggerInsertStep(&X, F, Y, 0, R);}
trigger_cmd(A) ::= insert_cmd(R) INTO nm(X) inscollist_opt(F) select(S).
{A = sqliteTriggerInsertStep(&X, F, 0, S, R);}
// DELETE
trigger_cmd(A) ::= DELETE FROM nm(X) where_opt(Y).
{A = sqliteTriggerDeleteStep(&X, Y);}
// SELECT
trigger_cmd(A) ::= select(X). {A = sqliteTriggerSelectStep(X); }
// The special RAISE expression that may occur in trigger programs
expr(A) ::= RAISE(X) LP IGNORE RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, 0);
A->iColumn = OE_Ignore;
sqliteExprSpan(A, &X, &Y);
}
expr(A) ::= RAISE(X) LP ROLLBACK COMMA nm(Z) RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, &Z);
A->iColumn = OE_Rollback;
sqliteExprSpan(A, &X, &Y);
}
expr(A) ::= RAISE(X) LP ABORT COMMA nm(Z) RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, &Z);
A->iColumn = OE_Abort;
sqliteExprSpan(A, &X, &Y);
}
expr(A) ::= RAISE(X) LP FAIL COMMA nm(Z) RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, &Z);
A->iColumn = OE_Fail;
sqliteExprSpan(A, &X, &Y);
}
//////////////////////// DROP TRIGGER statement //////////////////////////////
cmd ::= DROP TRIGGER nm(X) dbnm(D). {
sqliteDropTrigger(pParse,sqliteSrcListAppend(0,&X,&D));
}
//////////////////////// ATTACH DATABASE file AS name /////////////////////////
cmd ::= ATTACH database_kw_opt ids(F) AS nm(D) key_opt(K). {
sqliteAttach(pParse, &F, &D, &K);
}
%type key_opt {Token}
key_opt(A) ::= USING ids(X). { A = X; }
key_opt(A) ::= . { A.z = 0; A.n = 0; }
database_kw_opt ::= DATABASE.
database_kw_opt ::= .
//////////////////////// DETACH DATABASE name /////////////////////////////////
cmd ::= DETACH database_kw_opt nm(D). {
sqliteDetach(pParse, &D);
}
+712
View File
@@ -0,0 +1,712 @@
/*
** 2003 April 6
**
** 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 code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.19 2004/04/23 17:04:45 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
/*
** Interpret the given string as a boolean value.
*/
static int getBoolean(const char *z){
static char *azTrue[] = { "yes", "on", "true" };
int i;
if( z[0]==0 ) return 0;
if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){
return atoi(z);
}
for(i=0; i<sizeof(azTrue)/sizeof(azTrue[0]); i++){
if( sqliteStrICmp(z,azTrue[i])==0 ) return 1;
}
return 0;
}
/*
** Interpret the given string as a safety level. Return 0 for OFF,
** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or
** unrecognized string argument.
**
** Note that the values returned are one less that the values that
** should be passed into sqliteBtreeSetSafetyLevel(). The is done
** to support legacy SQL code. The safety level used to be boolean
** and older scripts may have used numbers 0 for OFF and 1 for ON.
*/
static int getSafetyLevel(char *z){
static const struct {
const char *zWord;
int val;
} aKey[] = {
{ "no", 0 },
{ "off", 0 },
{ "false", 0 },
{ "yes", 1 },
{ "on", 1 },
{ "true", 1 },
{ "full", 2 },
};
int i;
if( z[0]==0 ) return 1;
if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){
return atoi(z);
}
for(i=0; i<sizeof(aKey)/sizeof(aKey[0]); i++){
if( sqliteStrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val;
}
return 1;
}
/*
** Interpret the given string as a temp db location. Return 1 for file
** backed temporary databases, 2 for the Red-Black tree in memory database
** and 0 to use the compile-time default.
*/
static int getTempStore(const char *z){
if( z[0]>='0' && z[0]<='2' ){
return z[0] - '0';
}else if( sqliteStrICmp(z, "file")==0 ){
return 1;
}else if( sqliteStrICmp(z, "memory")==0 ){
return 2;
}else{
return 0;
}
}
/*
** If the TEMP database is open, close it and mark the database schema
** as needing reloading. This must be done when using the TEMP_STORE
** or DEFAULT_TEMP_STORE pragmas.
*/
static int changeTempStorage(Parse *pParse, const char *zStorageType){
int ts = getTempStore(zStorageType);
sqlite *db = pParse->db;
if( db->temp_store==ts ) return SQLITE_OK;
if( db->aDb[1].pBt!=0 ){
if( db->flags & SQLITE_InTrans ){
sqliteErrorMsg(pParse, "temporary storage cannot be changed "
"from within a transaction");
return SQLITE_ERROR;
}
sqliteBtreeClose(db->aDb[1].pBt);
db->aDb[1].pBt = 0;
sqliteResetInternalSchema(db, 0);
}
db->temp_store = ts;
return SQLITE_OK;
}
/*
** Check to see if zRight and zLeft refer to a pragma that queries
** or changes one of the flags in db->flags. Return 1 if so and 0 if not.
** Also, implement the pragma.
*/
static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
static const struct {
const char *zName; /* Name of the pragma */
int mask; /* Mask for the db->flags value */
} aPragma[] = {
{ "vdbe_trace", SQLITE_VdbeTrace },
{ "full_column_names", SQLITE_FullColNames },
{ "short_column_names", SQLITE_ShortColNames },
{ "show_datatypes", SQLITE_ReportTypes },
{ "count_changes", SQLITE_CountRows },
{ "empty_result_callbacks", SQLITE_NullCallback },
};
int i;
for(i=0; i<sizeof(aPragma)/sizeof(aPragma[0]); i++){
if( sqliteStrICmp(zLeft, aPragma[i].zName)==0 ){
sqlite *db = pParse->db;
Vdbe *v;
if( strcmp(zLeft,zRight)==0 && (v = sqliteGetVdbe(pParse))!=0 ){
sqliteVdbeOp3(v, OP_ColumnName, 0, 1, aPragma[i].zName, P3_STATIC);
sqliteVdbeOp3(v, OP_ColumnName, 1, 0, "boolean", P3_STATIC);
sqliteVdbeCode(v, OP_Integer, (db->flags & aPragma[i].mask)!=0, 0,
OP_Callback, 1, 0,
0);
}else if( getBoolean(zRight) ){
db->flags |= aPragma[i].mask;
}else{
db->flags &= ~aPragma[i].mask;
}
return 1;
}
}
return 0;
}
/*
** Process a pragma statement.
**
** Pragmas are of this form:
**
** PRAGMA id = value
**
** The identifier might also be a string. The value is a string, and
** identifier, or a number. If minusFlag is true, then the value is
** a number that was preceded by a minus sign.
*/
void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
char *zLeft = 0;
char *zRight = 0;
sqlite *db = pParse->db;
Vdbe *v = sqliteGetVdbe(pParse);
if( v==0 ) return;
zLeft = sqliteStrNDup(pLeft->z, pLeft->n);
sqliteDequote(zLeft);
if( minusFlag ){
zRight = 0;
sqliteSetNString(&zRight, "-", 1, pRight->z, pRight->n, 0);
}else{
zRight = sqliteStrNDup(pRight->z, pRight->n);
sqliteDequote(zRight);
}
if( sqliteAuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, 0) ){
sqliteFree(zLeft);
sqliteFree(zRight);
return;
}
/*
** PRAGMA default_cache_size
** PRAGMA default_cache_size=N
**
** The first form reports the current persistent setting for the
** page cache size. The value returned is the maximum number of
** pages in the page cache. The second form sets both the current
** page cache size value and the persistent page cache size value
** stored in the database file.
**
** The default cache size is stored in meta-value 2 of page 1 of the
** database file. The cache size is actually the absolute value of
** this memory location. The sign of meta-value 2 determines the
** synchronous setting. A negative value means synchronous is off
** and a positive value means synchronous is on.
*/
if( sqliteStrICmp(zLeft,"default_cache_size")==0 ){
static VdbeOpList getCacheSize[] = {
{ OP_ReadCookie, 0, 2, 0},
{ OP_AbsValue, 0, 0, 0},
{ OP_Dup, 0, 0, 0},
{ OP_Integer, 0, 0, 0},
{ OP_Ne, 0, 6, 0},
{ OP_Integer, 0, 0, 0}, /* 5 */
{ OP_ColumnName, 0, 1, "cache_size"},
{ OP_Callback, 1, 0, 0},
};
int addr;
if( pRight->z==pLeft->z ){
addr = sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
sqliteVdbeChangeP1(v, addr+5, MAX_PAGES);
}else{
int size = atoi(zRight);
if( size<0 ) size = -size;
sqliteBeginWriteOperation(pParse, 0, 0);
sqliteVdbeAddOp(v, OP_Integer, size, 0);
sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2);
addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0);
sqliteVdbeAddOp(v, OP_Ge, 0, addr+3);
sqliteVdbeAddOp(v, OP_Negative, 0, 0);
sqliteVdbeAddOp(v, OP_SetCookie, 0, 2);
sqliteEndWriteOperation(pParse);
db->cache_size = db->cache_size<0 ? -size : size;
sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
}
}else
/*
** PRAGMA cache_size
** PRAGMA cache_size=N
**
** The first form reports the current local setting for the
** page cache size. The local setting can be different from
** the persistent cache size value that is stored in the database
** file itself. The value returned is the maximum number of
** pages in the page cache. The second form sets the local
** page cache size value. It does not change the persistent
** cache size stored on the disk so the cache size will revert
** to its default value when the database is closed and reopened.
** N should be a positive integer.
*/
if( sqliteStrICmp(zLeft,"cache_size")==0 ){
static VdbeOpList getCacheSize[] = {
{ OP_ColumnName, 0, 1, "cache_size"},
{ OP_Callback, 1, 0, 0},
};
if( pRight->z==pLeft->z ){
int size = db->cache_size;;
if( size<0 ) size = -size;
sqliteVdbeAddOp(v, OP_Integer, size, 0);
sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
}else{
int size = atoi(zRight);
if( size<0 ) size = -size;
if( db->cache_size<0 ) size = -size;
db->cache_size = size;
sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
}
}else
/*
** PRAGMA default_synchronous
** PRAGMA default_synchronous=ON|OFF|NORMAL|FULL
**
** The first form returns the persistent value of the "synchronous" setting
** that is stored in the database. This is the synchronous setting that
** is used whenever the database is opened unless overridden by a separate
** "synchronous" pragma. The second form changes the persistent and the
** local synchronous setting to the value given.
**
** If synchronous is OFF, SQLite does not attempt any fsync() systems calls
** to make sure data is committed to disk. Write operations are very fast,
** but a power failure can leave the database in an inconsistent state.
** If synchronous is ON or NORMAL, SQLite will do an fsync() system call to
** make sure data is being written to disk. The risk of corruption due to
** a power loss in this mode is negligible but non-zero. If synchronous
** is FULL, extra fsync()s occur to reduce the risk of corruption to near
** zero, but with a write performance penalty. The default mode is NORMAL.
*/
if( sqliteStrICmp(zLeft,"default_synchronous")==0 ){
static VdbeOpList getSync[] = {
{ OP_ColumnName, 0, 1, "synchronous"},
{ OP_ReadCookie, 0, 3, 0},
{ OP_Dup, 0, 0, 0},
{ OP_If, 0, 0, 0}, /* 3 */
{ OP_ReadCookie, 0, 2, 0},
{ OP_Integer, 0, 0, 0},
{ OP_Lt, 0, 5, 0},
{ OP_AddImm, 1, 0, 0},
{ OP_Callback, 1, 0, 0},
{ OP_Halt, 0, 0, 0},
{ OP_AddImm, -1, 0, 0}, /* 10 */
{ OP_Callback, 1, 0, 0}
};
if( pRight->z==pLeft->z ){
int addr = sqliteVdbeAddOpList(v, ArraySize(getSync), getSync);
sqliteVdbeChangeP2(v, addr+3, addr+10);
}else{
int addr;
int size = db->cache_size;
if( size<0 ) size = -size;
sqliteBeginWriteOperation(pParse, 0, 0);
sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2);
sqliteVdbeAddOp(v, OP_Dup, 0, 0);
addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0);
sqliteVdbeAddOp(v, OP_Ne, 0, addr+3);
sqliteVdbeAddOp(v, OP_AddImm, MAX_PAGES, 0);
sqliteVdbeAddOp(v, OP_AbsValue, 0, 0);
db->safety_level = getSafetyLevel(zRight)+1;
if( db->safety_level==1 ){
sqliteVdbeAddOp(v, OP_Negative, 0, 0);
size = -size;
}
sqliteVdbeAddOp(v, OP_SetCookie, 0, 2);
sqliteVdbeAddOp(v, OP_Integer, db->safety_level, 0);
sqliteVdbeAddOp(v, OP_SetCookie, 0, 3);
sqliteEndWriteOperation(pParse);
db->cache_size = size;
sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level);
}
}else
/*
** PRAGMA synchronous
** PRAGMA synchronous=OFF|ON|NORMAL|FULL
**
** Return or set the local value of the synchronous flag. Changing
** the local value does not make changes to the disk file and the
** default value will be restored the next time the database is
** opened.
*/
if( sqliteStrICmp(zLeft,"synchronous")==0 ){
static VdbeOpList getSync[] = {
{ OP_ColumnName, 0, 1, "synchronous"},
{ OP_Callback, 1, 0, 0},
};
if( pRight->z==pLeft->z ){
sqliteVdbeAddOp(v, OP_Integer, db->safety_level-1, 0);
sqliteVdbeAddOpList(v, ArraySize(getSync), getSync);
}else{
int size = db->cache_size;
if( size<0 ) size = -size;
db->safety_level = getSafetyLevel(zRight)+1;
if( db->safety_level==1 ) size = -size;
db->cache_size = size;
sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level);
}
}else
#ifndef NDEBUG
if( sqliteStrICmp(zLeft, "trigger_overhead_test")==0 ){
if( getBoolean(zRight) ){
always_code_trigger_setup = 1;
}else{
always_code_trigger_setup = 0;
}
}else
#endif
if( flagPragma(pParse, zLeft, zRight) ){
/* The flagPragma() call also generates any necessary code */
}else
if( sqliteStrICmp(zLeft, "table_info")==0 ){
Table *pTab;
pTab = sqliteFindTable(db, zRight, 0);
if( pTab ){
static VdbeOpList tableInfoPreface[] = {
{ OP_ColumnName, 0, 0, "cid"},
{ OP_ColumnName, 1, 0, "name"},
{ OP_ColumnName, 2, 0, "type"},
{ OP_ColumnName, 3, 0, "notnull"},
{ OP_ColumnName, 4, 0, "dflt_value"},
{ OP_ColumnName, 5, 1, "pk"},
};
int i;
sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
sqliteViewGetColumnNames(pParse, pTab);
for(i=0; i<pTab->nCol; i++){
sqliteVdbeAddOp(v, OP_Integer, i, 0);
sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zName, 0);
sqliteVdbeOp3(v, OP_String, 0, 0,
pTab->aCol[i].zType ? pTab->aCol[i].zType : "numeric", 0);
sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].notNull, 0);
sqliteVdbeOp3(v, OP_String, 0, 0,
pTab->aCol[i].zDflt, P3_STATIC);
sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].isPrimKey, 0);
sqliteVdbeAddOp(v, OP_Callback, 6, 0);
}
}
}else
if( sqliteStrICmp(zLeft, "index_info")==0 ){
Index *pIdx;
Table *pTab;
pIdx = sqliteFindIndex(db, zRight, 0);
if( pIdx ){
static VdbeOpList tableInfoPreface[] = {
{ OP_ColumnName, 0, 0, "seqno"},
{ OP_ColumnName, 1, 0, "cid"},
{ OP_ColumnName, 2, 1, "name"},
};
int i;
pTab = pIdx->pTable;
sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
for(i=0; i<pIdx->nColumn; i++){
int cnum = pIdx->aiColumn[i];
sqliteVdbeAddOp(v, OP_Integer, i, 0);
sqliteVdbeAddOp(v, OP_Integer, cnum, 0);
assert( pTab->nCol>cnum );
sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[cnum].zName, 0);
sqliteVdbeAddOp(v, OP_Callback, 3, 0);
}
}
}else
if( sqliteStrICmp(zLeft, "index_list")==0 ){
Index *pIdx;
Table *pTab;
pTab = sqliteFindTable(db, zRight, 0);
if( pTab ){
v = sqliteGetVdbe(pParse);
pIdx = pTab->pIndex;
}
if( pTab && pIdx ){
int i = 0;
static VdbeOpList indexListPreface[] = {
{ OP_ColumnName, 0, 0, "seq"},
{ OP_ColumnName, 1, 0, "name"},
{ OP_ColumnName, 2, 1, "unique"},
};
sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
while(pIdx){
sqliteVdbeAddOp(v, OP_Integer, i, 0);
sqliteVdbeOp3(v, OP_String, 0, 0, pIdx->zName, 0);
sqliteVdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0);
sqliteVdbeAddOp(v, OP_Callback, 3, 0);
++i;
pIdx = pIdx->pNext;
}
}
}else
if( sqliteStrICmp(zLeft, "foreign_key_list")==0 ){
FKey *pFK;
Table *pTab;
pTab = sqliteFindTable(db, zRight, 0);
if( pTab ){
v = sqliteGetVdbe(pParse);
pFK = pTab->pFKey;
}
if( pTab && pFK ){
int i = 0;
static VdbeOpList indexListPreface[] = {
{ OP_ColumnName, 0, 0, "id"},
{ OP_ColumnName, 1, 0, "seq"},
{ OP_ColumnName, 2, 0, "table"},
{ OP_ColumnName, 3, 0, "from"},
{ OP_ColumnName, 4, 1, "to"},
};
sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
while(pFK){
int j;
for(j=0; j<pFK->nCol; j++){
sqliteVdbeAddOp(v, OP_Integer, i, 0);
sqliteVdbeAddOp(v, OP_Integer, j, 0);
sqliteVdbeOp3(v, OP_String, 0, 0, pFK->zTo, 0);
sqliteVdbeOp3(v, OP_String, 0, 0,
pTab->aCol[pFK->aCol[j].iFrom].zName, 0);
sqliteVdbeOp3(v, OP_String, 0, 0, pFK->aCol[j].zCol, 0);
sqliteVdbeAddOp(v, OP_Callback, 5, 0);
}
++i;
pFK = pFK->pNextFrom;
}
}
}else
if( sqliteStrICmp(zLeft, "database_list")==0 ){
int i;
static VdbeOpList indexListPreface[] = {
{ OP_ColumnName, 0, 0, "seq"},
{ OP_ColumnName, 1, 0, "name"},
{ OP_ColumnName, 2, 1, "file"},
};
sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
for(i=0; i<db->nDb; i++){
if( db->aDb[i].pBt==0 ) continue;
assert( db->aDb[i].zName!=0 );
sqliteVdbeAddOp(v, OP_Integer, i, 0);
sqliteVdbeOp3(v, OP_String, 0, 0, db->aDb[i].zName, 0);
sqliteVdbeOp3(v, OP_String, 0, 0,
sqliteBtreeGetFilename(db->aDb[i].pBt), 0);
sqliteVdbeAddOp(v, OP_Callback, 3, 0);
}
}else
/*
** PRAGMA temp_store
** PRAGMA temp_store = "default"|"memory"|"file"
**
** Return or set the local value of the temp_store flag. Changing
** the local value does not make changes to the disk file and the default
** value will be restored the next time the database is opened.
**
** Note that it is possible for the library compile-time options to
** override this setting
*/
if( sqliteStrICmp(zLeft, "temp_store")==0 ){
static VdbeOpList getTmpDbLoc[] = {
{ OP_ColumnName, 0, 1, "temp_store"},
{ OP_Callback, 1, 0, 0},
};
if( pRight->z==pLeft->z ){
sqliteVdbeAddOp(v, OP_Integer, db->temp_store, 0);
sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
}else{
changeTempStorage(pParse, zRight);
}
}else
/*
** PRAGMA default_temp_store
** PRAGMA default_temp_store = "default"|"memory"|"file"
**
** Return or set the value of the persistent temp_store flag. Any
** change does not take effect until the next time the database is
** opened.
**
** Note that it is possible for the library compile-time options to
** override this setting
*/
if( sqliteStrICmp(zLeft, "default_temp_store")==0 ){
static VdbeOpList getTmpDbLoc[] = {
{ OP_ColumnName, 0, 1, "temp_store"},
{ OP_ReadCookie, 0, 5, 0},
{ OP_Callback, 1, 0, 0}};
if( pRight->z==pLeft->z ){
sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
}else{
sqliteBeginWriteOperation(pParse, 0, 0);
sqliteVdbeAddOp(v, OP_Integer, getTempStore(zRight), 0);
sqliteVdbeAddOp(v, OP_SetCookie, 0, 5);
sqliteEndWriteOperation(pParse);
}
}else
#ifndef NDEBUG
if( sqliteStrICmp(zLeft, "parser_trace")==0 ){
extern void sqliteParserTrace(FILE*, char *);
if( getBoolean(zRight) ){
sqliteParserTrace(stdout, "parser: ");
}else{
sqliteParserTrace(0, 0);
}
}else
#endif
if( sqliteStrICmp(zLeft, "integrity_check")==0 ){
int i, j, addr;
/* Code that initializes the integrity check program. Set the
** error count 0
*/
static VdbeOpList initCode[] = {
{ OP_Integer, 0, 0, 0},
{ OP_MemStore, 0, 1, 0},
{ OP_ColumnName, 0, 1, "integrity_check"},
};
/* Code to do an BTree integrity check on a single database file.
*/
static VdbeOpList checkDb[] = {
{ OP_SetInsert, 0, 0, "2"},
{ OP_Integer, 0, 0, 0}, /* 1 */
{ OP_OpenRead, 0, 2, 0},
{ OP_Rewind, 0, 7, 0}, /* 3 */
{ OP_Column, 0, 3, 0}, /* 4 */
{ OP_SetInsert, 0, 0, 0},
{ OP_Next, 0, 4, 0}, /* 6 */
{ OP_IntegrityCk, 0, 0, 0}, /* 7 */
{ OP_Dup, 0, 1, 0},
{ OP_String, 0, 0, "ok"},
{ OP_StrEq, 0, 12, 0}, /* 10 */
{ OP_MemIncr, 0, 0, 0},
{ OP_String, 0, 0, "*** in database "},
{ OP_String, 0, 0, 0}, /* 13 */
{ OP_String, 0, 0, " ***\n"},
{ OP_Pull, 3, 0, 0},
{ OP_Concat, 4, 1, 0},
{ OP_Callback, 1, 0, 0},
};
/* Code that appears at the end of the integrity check. If no error
** messages have been generated, output OK. Otherwise output the
** error message
*/
static VdbeOpList endCode[] = {
{ OP_MemLoad, 0, 0, 0},
{ OP_Integer, 0, 0, 0},
{ OP_Ne, 0, 0, 0}, /* 2 */
{ OP_String, 0, 0, "ok"},
{ OP_Callback, 1, 0, 0},
};
/* Initialize the VDBE program */
sqliteVdbeAddOpList(v, ArraySize(initCode), initCode);
/* Do an integrity check on each database file */
for(i=0; i<db->nDb; i++){
HashElem *x;
/* Do an integrity check of the B-Tree
*/
addr = sqliteVdbeAddOpList(v, ArraySize(checkDb), checkDb);
sqliteVdbeChangeP1(v, addr+1, i);
sqliteVdbeChangeP2(v, addr+3, addr+7);
sqliteVdbeChangeP2(v, addr+6, addr+4);
sqliteVdbeChangeP2(v, addr+7, i);
sqliteVdbeChangeP2(v, addr+10, addr+ArraySize(checkDb));
sqliteVdbeChangeP3(v, addr+13, db->aDb[i].zName, P3_STATIC);
/* Make sure all the indices are constructed correctly.
*/
sqliteCodeVerifySchema(pParse, i);
for(x=sqliteHashFirst(&db->aDb[i].tblHash); x; x=sqliteHashNext(x)){
Table *pTab = sqliteHashData(x);
Index *pIdx;
int loopTop;
if( pTab->pIndex==0 ) continue;
sqliteVdbeAddOp(v, OP_Integer, i, 0);
sqliteVdbeOp3(v, OP_OpenRead, 1, pTab->tnum, pTab->zName, 0);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
if( pIdx->tnum==0 ) continue;
sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0);
sqliteVdbeOp3(v, OP_OpenRead, j+2, pIdx->tnum, pIdx->zName, 0);
}
sqliteVdbeAddOp(v, OP_Integer, 0, 0);
sqliteVdbeAddOp(v, OP_MemStore, 1, 1);
loopTop = sqliteVdbeAddOp(v, OP_Rewind, 1, 0);
sqliteVdbeAddOp(v, OP_MemIncr, 1, 0);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int k, jmp2;
static VdbeOpList idxErr[] = {
{ OP_MemIncr, 0, 0, 0},
{ OP_String, 0, 0, "rowid "},
{ OP_Recno, 1, 0, 0},
{ OP_String, 0, 0, " missing from index "},
{ OP_String, 0, 0, 0}, /* 4 */
{ OP_Concat, 4, 0, 0},
{ OP_Callback, 1, 0, 0},
};
sqliteVdbeAddOp(v, OP_Recno, 1, 0);
for(k=0; k<pIdx->nColumn; k++){
int idx = pIdx->aiColumn[k];
if( idx==pTab->iPKey ){
sqliteVdbeAddOp(v, OP_Recno, 1, 0);
}else{
sqliteVdbeAddOp(v, OP_Column, 1, idx);
}
}
sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx);
jmp2 = sqliteVdbeAddOp(v, OP_Found, j+2, 0);
addr = sqliteVdbeAddOpList(v, ArraySize(idxErr), idxErr);
sqliteVdbeChangeP3(v, addr+4, pIdx->zName, P3_STATIC);
sqliteVdbeChangeP2(v, jmp2, sqliteVdbeCurrentAddr(v));
}
sqliteVdbeAddOp(v, OP_Next, 1, loopTop+1);
sqliteVdbeChangeP2(v, loopTop, sqliteVdbeCurrentAddr(v));
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
static VdbeOpList cntIdx[] = {
{ OP_Integer, 0, 0, 0},
{ OP_MemStore, 2, 1, 0},
{ OP_Rewind, 0, 0, 0}, /* 2 */
{ OP_MemIncr, 2, 0, 0},
{ OP_Next, 0, 0, 0}, /* 4 */
{ OP_MemLoad, 1, 0, 0},
{ OP_MemLoad, 2, 0, 0},
{ OP_Eq, 0, 0, 0}, /* 7 */
{ OP_MemIncr, 0, 0, 0},
{ OP_String, 0, 0, "wrong # of entries in index "},
{ OP_String, 0, 0, 0}, /* 10 */
{ OP_Concat, 2, 0, 0},
{ OP_Callback, 1, 0, 0},
};
if( pIdx->tnum==0 ) continue;
addr = sqliteVdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
sqliteVdbeChangeP1(v, addr+2, j+2);
sqliteVdbeChangeP2(v, addr+2, addr+5);
sqliteVdbeChangeP1(v, addr+4, j+2);
sqliteVdbeChangeP2(v, addr+4, addr+3);
sqliteVdbeChangeP2(v, addr+7, addr+ArraySize(cntIdx));
sqliteVdbeChangeP3(v, addr+10, pIdx->zName, P3_STATIC);
}
}
}
addr = sqliteVdbeAddOpList(v, ArraySize(endCode), endCode);
sqliteVdbeChangeP2(v, addr+2, addr+ArraySize(endCode));
}else
{}
sqliteFree(zLeft);
sqliteFree(zRight);
}
+273 -218
View File
@@ -1,10 +1,14 @@
/*
** The "printf" code that follows dates from the 1980's. It is in
** the public domain. The original comments are included here for
** completeness. They are slightly out-of-date.
** completeness. They are very out-of-date but might be useful as
** an historical reference. Most of the "enhancements" have been backed
** out so that the functionality is now the same as standard printf().
**
** The following modules is an enhanced replacement for the "printf" programs
** found in the standard library. The following enhancements are
**************************************************************************
**
** The following modules is an enhanced replacement for the "printf" subroutines
** found in the standard C library. The following enhancements are
** supported:
**
** + Additional functions. The standard set of "printf" functions
@@ -48,71 +52,80 @@
*/
#include "sqliteInt.h"
/*
** Undefine COMPATIBILITY to make some slight changes in the way things
** work. I think the changes are an improvement, but they are not
** backwards compatible.
*/
/* #define COMPATIBILITY / * Compatible with SUN OS 4.1 */
/*
** Conversion types fall into various categories as defined by the
** following enumeration.
*/
enum et_type { /* The type of the format field */
etRADIX, /* Integer types. %d, %x, %o, and so forth */
etFLOAT, /* Floating point. %f */
etEXP, /* Exponentional notation. %e and %E */
etGENERIC, /* Floating or exponential, depending on exponent. %g */
etSIZE, /* Return number of characters processed so far. %n */
etSTRING, /* Strings. %s */
etPERCENT, /* Percent symbol. %% */
etCHARX, /* Characters. %c */
etERROR, /* Used to indicate no such conversion type */
#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */
#define etFLOAT 2 /* Floating point. %f */
#define etEXP 3 /* Exponentional notation. %e and %E */
#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */
#define etSIZE 5 /* Return number of characters processed so far. %n */
#define etSTRING 6 /* Strings. %s */
#define etDYNSTRING 7 /* Dynamically allocated strings. %z */
#define etPERCENT 8 /* Percent symbol. %% */
#define etCHARX 9 /* Characters. %c */
#define etERROR 10 /* Used to indicate no such conversion type */
/* The rest are extensions, not normally found in printf() */
etCHARLIT, /* Literal characters. %' */
etSQLESCAPE, /* Strings with '\'' doubled. %q */
etORDINAL /* 1st, 2nd, 3rd and so forth */
};
#define etCHARLIT 11 /* Literal characters. %' */
#define etSQLESCAPE 12 /* Strings with '\'' doubled. %q */
#define etSQLESCAPE2 13 /* Strings with '\'' doubled and enclosed in '',
NULL pointers replaced by SQL NULL. %Q */
#define etTOKEN 14 /* a pointer to a Token structure */
#define etSRCLIST 15 /* a pointer to a SrcList */
/*
** An "etByte" is an 8-bit unsigned value.
*/
typedef unsigned char etByte;
/*
** Each builtin conversion character (ex: the 'd' in "%d") is described
** by an instance of the following structure
*/
typedef struct et_info { /* Information about each format field */
int fmttype; /* The format field code letter */
int base; /* The base for radix conversion */
char *charset; /* The character set for conversion */
int flag_signed; /* Is the quantity signed? */
char *prefix; /* Prefix on non-zero values in alt format */
enum et_type type; /* Conversion paradigm */
char fmttype; /* The format field code letter */
etByte base; /* The base for radix conversion */
etByte flags; /* One or more of FLAG_ constants below */
etByte type; /* Conversion paradigm */
char *charset; /* The character set for conversion */
char *prefix; /* Prefix on non-zero values in alt format */
} et_info;
/*
** Allowed values for et_info.flags
*/
#define FLAG_SIGNED 1 /* True if the value to convert is signed */
#define FLAG_INTERN 2 /* True if for internal use only */
/*
** The following table is searched linearly, so it is good to put the
** most frequently used conversion types first.
*/
static et_info fmtinfo[] = {
{ 'd', 10, "0123456789", 1, 0, etRADIX, },
{ 's', 0, 0, 0, 0, etSTRING, },
{ 'q', 0, 0, 0, 0, etSQLESCAPE, },
{ 'c', 0, 0, 0, 0, etCHARX, },
{ 'o', 8, "01234567", 0, "0", etRADIX, },
{ 'u', 10, "0123456789", 0, 0, etRADIX, },
{ 'x', 16, "0123456789abcdef", 0, "x0", etRADIX, },
{ 'X', 16, "0123456789ABCDEF", 0, "X0", etRADIX, },
{ 'r', 10, "0123456789", 0, 0, etORDINAL, },
{ 'f', 0, 0, 1, 0, etFLOAT, },
{ 'e', 0, "e", 1, 0, etEXP, },
{ 'E', 0, "E", 1, 0, etEXP, },
{ 'g', 0, "e", 1, 0, etGENERIC, },
{ 'G', 0, "E", 1, 0, etGENERIC, },
{ 'i', 10, "0123456789", 1, 0, etRADIX, },
{ 'n', 0, 0, 0, 0, etSIZE, },
{ '%', 0, 0, 0, 0, etPERCENT, },
{ 'b', 2, "01", 0, "b0", etRADIX, }, /* Binary */
{ 'p', 10, "0123456789", 0, 0, etRADIX, }, /* Pointers */
{ '\'', 0, 0, 0, 0, etCHARLIT, }, /* Literal char */
{ 'd', 10, 1, etRADIX, "0123456789", 0 },
{ 's', 0, 0, etSTRING, 0, 0 },
{ 'z', 0, 2, etDYNSTRING, 0, 0 },
{ 'q', 0, 0, etSQLESCAPE, 0, 0 },
{ 'Q', 0, 0, etSQLESCAPE2, 0, 0 },
{ 'c', 0, 0, etCHARX, 0, 0 },
{ 'o', 8, 0, etRADIX, "01234567", "0" },
{ 'u', 10, 0, etRADIX, "0123456789", 0 },
{ 'x', 16, 0, etRADIX, "0123456789abcdef", "x0" },
{ 'X', 16, 0, etRADIX, "0123456789ABCDEF", "X0" },
{ 'f', 0, 1, etFLOAT, 0, 0 },
{ 'e', 0, 1, etEXP, "e", 0 },
{ 'E', 0, 1, etEXP, "E", 0 },
{ 'g', 0, 1, etGENERIC, "e", 0 },
{ 'G', 0, 1, etGENERIC, "E", 0 },
{ 'i', 10, 1, etRADIX, "0123456789", 0 },
{ 'n', 0, 0, etSIZE, 0, 0 },
{ '%', 0, 0, etPERCENT, 0, 0 },
{ 'p', 10, 0, etRADIX, "0123456789", 0 },
{ 'T', 0, 2, etTOKEN, 0, 0 },
{ 'S', 0, 2, etSRCLIST, 0, 0 },
};
#define etNINFO (sizeof(fmtinfo)/sizeof(fmtinfo[0]))
@@ -134,9 +147,9 @@ static et_info fmtinfo[] = {
** 16 (the number of significant digits in a 64-bit float) '0' is
** always returned.
*/
static int et_getdigit(double *val, int *cnt){
static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
int digit;
double d;
LONGDOUBLE_TYPE d;
if( (*cnt)++ >= 16 ) return '0';
digit = (int)*val;
d = digit;
@@ -176,53 +189,50 @@ static int et_getdigit(double *val, int *cnt){
** will run.
*/
static int vxprintf(
void (*func)(void*,char*,int),
void *arg,
const char *format,
va_list ap
void (*func)(void*,const char*,int), /* Consumer of text */
void *arg, /* First argument to the consumer */
int useExtended, /* Allow extended %-conversions */
const char *fmt, /* Format string */
va_list ap /* arguments */
){
register const char *fmt; /* The format string. */
register int c; /* Next character in the format string */
register char *bufpt; /* Pointer to the conversion buffer */
register int precision; /* Precision of the current field */
register int length; /* Length of the field */
register int idx; /* A general purpose loop counter */
int count; /* Total number of characters output */
int width; /* Width of the current field */
int flag_leftjustify; /* True if "-" flag is present */
int flag_plussign; /* True if "+" flag is present */
int flag_blanksign; /* True if " " flag is present */
int flag_alternateform; /* True if "#" flag is present */
int flag_zeropad; /* True if field width constant starts with zero */
int flag_long; /* True if "l" flag is present */
int flag_center; /* True if "=" flag is present */
unsigned long longvalue; /* Value for integer types */
double realvalue; /* Value for real types */
et_info *infop; /* Pointer to the appropriate info structure */
char buf[etBUFSIZE]; /* Conversion buffer */
char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
int errorflag = 0; /* True if an error is encountered */
enum et_type xtype; /* Conversion paradigm */
char *zMem; /* String to be freed */
char *zExtra; /* Extra memory used for etTCLESCAPE conversions */
static char spaces[] = " "
" ";
int c; /* Next character in the format string */
char *bufpt; /* Pointer to the conversion buffer */
int precision; /* Precision of the current field */
int length; /* Length of the field */
int idx; /* A general purpose loop counter */
int count; /* Total number of characters output */
int width; /* Width of the current field */
etByte flag_leftjustify; /* True if "-" flag is present */
etByte flag_plussign; /* True if "+" flag is present */
etByte flag_blanksign; /* True if " " flag is present */
etByte flag_alternateform; /* True if "#" flag is present */
etByte flag_zeropad; /* True if field width constant starts with zero */
etByte flag_long; /* True if "l" flag is present */
unsigned long longvalue; /* Value for integer types */
LONGDOUBLE_TYPE realvalue; /* Value for real types */
et_info *infop; /* Pointer to the appropriate info structure */
char buf[etBUFSIZE]; /* Conversion buffer */
char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
etByte errorflag = 0; /* True if an error is encountered */
etByte xtype; /* Conversion paradigm */
char *zExtra; /* Extra memory used for etTCLESCAPE conversions */
static char spaces[] = " ";
#define etSPACESIZE (sizeof(spaces)-1)
#ifndef etNOFLOATINGPOINT
int exp; /* exponent of real numbers */
double rounder; /* Used for rounding floating point values */
int flag_dp; /* True if decimal point should be shown */
int flag_rtz; /* True if trailing zeros should be removed */
int flag_exp; /* True to force display of the exponent */
int nsd; /* Number of significant digits returned */
int exp; /* exponent of real numbers */
double rounder; /* Used for rounding floating point values */
etByte flag_dp; /* True if decimal point should be shown */
etByte flag_rtz; /* True if trailing zeros should be removed */
etByte flag_exp; /* True to force display of the exponent */
int nsd; /* Number of significant digits returned */
#endif
fmt = format; /* Put in a register for speed */
func(arg,"",0);
count = length = 0;
bufpt = 0;
for(; (c=(*fmt))!=0; ++fmt){
if( c!='%' ){
register int amt;
int amt;
bufpt = (char *)fmt;
amt = 1;
while( (c=(*++fmt))!='%' && c!=0 ) amt++;
@@ -238,7 +248,7 @@ static int vxprintf(
}
/* Find out what flags are present */
flag_leftjustify = flag_plussign = flag_blanksign =
flag_alternateform = flag_zeropad = flag_center = 0;
flag_alternateform = flag_zeropad = 0;
do{
switch( c ){
case '-': flag_leftjustify = 1; c = 0; break;
@@ -246,11 +256,9 @@ static int vxprintf(
case ' ': flag_blanksign = 1; c = 0; break;
case '#': flag_alternateform = 1; c = 0; break;
case '0': flag_zeropad = 1; c = 0; break;
case '=': flag_center = 1; c = 0; break;
default: break;
}
}while( c==0 && (c=(*++fmt))!=0 );
if( flag_center ) flag_leftjustify = 0;
/* Get the field width */
width = 0;
if( c=='*' ){
@@ -275,10 +283,7 @@ static int vxprintf(
c = *++fmt;
if( c=='*' ){
precision = va_arg(ap,int);
#ifndef etCOMPATIBILITY
/* This is sensible, but SUN OS 4.1 doesn't do it. */
if( precision<0 ) precision = -precision;
#endif
c = *++fmt;
}else{
while( c>='0' && c<='9' ){
@@ -300,18 +305,16 @@ static int vxprintf(
}
/* Fetch the info entry for the field */
infop = 0;
xtype = etERROR;
for(idx=0; idx<etNINFO; idx++){
if( c==fmtinfo[idx].fmttype ){
infop = &fmtinfo[idx];
if( useExtended || (infop->flags & FLAG_INTERN)==0 ){
xtype = infop->type;
}
break;
}
}
/* No info entry found. It must be an error. */
if( infop==0 ){
xtype = etERROR;
}else{
xtype = infop->type;
}
zExtra = 0;
/*
@@ -333,11 +336,10 @@ static int vxprintf(
** infop Pointer to the appropriate info struct.
*/
switch( xtype ){
case etORDINAL:
case etRADIX:
if( flag_long ) longvalue = va_arg(ap,long);
else longvalue = va_arg(ap,int);
#ifdef etCOMPATIBILITY
else longvalue = va_arg(ap,int);
#if 1
/* For the format %#x, the value zero is printed "0" not "0x0".
** I think this is stupid. */
if( longvalue==0 ) flag_alternateform = 0;
@@ -346,7 +348,7 @@ static int vxprintf(
** but leave the prefix for hex. */
if( longvalue==0 && infop->base==8 ) flag_alternateform = 0;
#endif
if( infop->flag_signed ){
if( infop->flags & FLAG_SIGNED ){
if( *(long*)&longvalue<0 ){
longvalue = -*(long*)&longvalue;
prefix = '-';
@@ -356,27 +358,8 @@ static int vxprintf(
}else prefix = 0;
if( flag_zeropad && precision<width-(prefix!=0) ){
precision = width-(prefix!=0);
}
bufpt = &buf[etBUFSIZE];
if( xtype==etORDINAL ){
long a,b;
a = longvalue%10;
b = longvalue%100;
bufpt -= 2;
if( a==0 || a>3 || (b>10 && b<14) ){
bufpt[0] = 't';
bufpt[1] = 'h';
}else if( a==1 ){
bufpt[0] = 's';
bufpt[1] = 't';
}else if( a==2 ){
bufpt[0] = 'n';
bufpt[1] = 'd';
}else if( a==3 ){
bufpt[0] = 'r';
bufpt[1] = 'd';
}
}
bufpt = &buf[etBUFSIZE-1];
{
register char *cset; /* Use registers for speed */
register int base;
@@ -386,20 +369,20 @@ static int vxprintf(
*(--bufpt) = cset[longvalue%base];
longvalue = longvalue/base;
}while( longvalue>0 );
}
length = (long)&buf[etBUFSIZE]-(long)bufpt;
}
length = &buf[etBUFSIZE-1]-bufpt;
for(idx=precision-length; idx>0; idx--){
*(--bufpt) = '0'; /* Zero pad */
}
}
if( prefix ) *(--bufpt) = prefix; /* Add sign */
if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
char *pre, x;
pre = infop->prefix;
if( *bufpt!=pre[0] ){
for(pre=infop->prefix; (x=(*pre))!=0; pre++) *(--bufpt) = x;
}
}
}
length = (long)&buf[etBUFSIZE]-(long)bufpt;
length = &buf[etBUFSIZE-1]-bufpt;
break;
case etFLOAT:
case etEXP:
@@ -411,14 +394,14 @@ static int vxprintf(
if( realvalue<0.0 ){
realvalue = -realvalue;
prefix = '-';
}else{
}else{
if( flag_plussign ) prefix = '+';
else if( flag_blanksign ) prefix = ' ';
else prefix = 0;
}
}
if( infop->type==etGENERIC && precision>0 ) precision--;
rounder = 0.0;
#ifdef COMPATIBILITY
#if 0
/* Rounding works like BSD when the constant 0.4999 is used. Wierd! */
for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1);
#else
@@ -429,17 +412,16 @@ static int vxprintf(
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
exp = 0;
if( realvalue>0.0 ){
int k = 0;
while( realvalue>=1e8 && k++<100 ){ realvalue *= 1e-8; exp+=8; }
while( realvalue>=10.0 && k++<100 ){ realvalue *= 0.1; exp++; }
while( realvalue<1e-8 && k++<100 ){ realvalue *= 1e8; exp-=8; }
while( realvalue<1.0 && k++<100 ){ realvalue *= 10.0; exp--; }
if( k>=100 ){
while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; }
while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }
while( realvalue<1e-8 && exp>=-350 ){ realvalue *= 1e8; exp-=8; }
while( realvalue<1.0 && exp>=-350 ){ realvalue *= 10.0; exp--; }
if( exp>350 || exp<-350 ){
bufpt = "NaN";
length = 3;
break;
}
}
}
bufpt = buf;
/*
** If the field type is etGENERIC, then convert to either etEXP
@@ -458,9 +440,9 @@ static int vxprintf(
precision = precision - exp;
xtype = etFLOAT;
}
}else{
}else{
flag_rtz = 0;
}
}
/*
** The "exp+precision" test causes output to be of type etEXP if
** the precision is too large to fit in buf[].
@@ -482,7 +464,7 @@ static int vxprintf(
if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0;
}
bufpt++; /* point to next free slot */
}else{ /* etEXP or etGENERIC */
}else{ /* etEXP or etGENERIC */
flag_dp = (precision>0 || flag_alternateform);
if( prefix ) *(bufpt++) = prefix; /* Sign */
*(bufpt++) = et_getdigit(&realvalue,&nsd); /* First digit */
@@ -501,15 +483,15 @@ static int vxprintf(
if( exp>=100 ){
*(bufpt++) = (exp/100)+'0'; /* 100's digit */
exp %= 100;
}
}
*(bufpt++) = exp/10+'0'; /* 10's digit */
*(bufpt++) = exp%10+'0'; /* 1's digit */
}
}
}
/* The converted number is in buf[] and zero terminated. Output it.
** Note that the number is in the usual order, not reversed as with
** integer conversions. */
length = (long)bufpt-(long)buf;
length = bufpt-buf;
bufpt = buf;
/* Special case: Add leading zeros if the flag_zeropad flag is
@@ -541,41 +523,70 @@ static int vxprintf(
if( precision>=0 ){
for(idx=1; idx<precision; idx++) buf[idx] = c;
length = precision;
}else{
}else{
length =1;
}
}
bufpt = buf;
break;
case etSTRING:
zMem = bufpt = va_arg(ap,char*);
if( bufpt==0 ) bufpt = "(null)";
case etDYNSTRING:
bufpt = va_arg(ap,char*);
if( bufpt==0 ){
bufpt = "";
}else if( xtype==etDYNSTRING ){
zExtra = bufpt;
}
length = strlen(bufpt);
if( precision>=0 && precision<length ) length = precision;
break;
case etSQLESCAPE:
case etSQLESCAPE2:
{
int i, j, n, c;
int i, j, n, c, isnull;
char *arg = va_arg(ap,char*);
if( arg==0 ) arg = "(NULL)";
isnull = arg==0;
if( isnull ) arg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
for(i=n=0; (c=arg[i])!=0; i++){
if( c=='\'' ) n++;
}
n += i + 1;
n += i + 1 + ((!isnull && xtype==etSQLESCAPE2) ? 2 : 0);
if( n>etBUFSIZE ){
bufpt = zExtra = sqliteMalloc( n );
if( bufpt==0 ) return -1;
}else{
bufpt = buf;
}
for(i=j=0; (c=arg[i])!=0; i++){
j = 0;
if( !isnull && xtype==etSQLESCAPE2 ) bufpt[j++] = '\'';
for(i=0; (c=arg[i])!=0; i++){
bufpt[j++] = c;
if( c=='\'' ) bufpt[j++] = c;
}
if( !isnull && xtype==etSQLESCAPE2 ) bufpt[j++] = '\'';
bufpt[j] = 0;
length = j;
if( precision>=0 && precision<length ) length = precision;
}
break;
case etTOKEN: {
Token *pToken = va_arg(ap, Token*);
(*func)(arg, pToken->z, pToken->n);
length = width = 0;
break;
}
case etSRCLIST: {
SrcList *pSrc = va_arg(ap, SrcList*);
int k = va_arg(ap, int);
struct SrcList_item *pItem = &pSrc->a[k];
assert( k>=0 && k<pSrc->nSrc );
if( pItem->zDatabase && pItem->zDatabase[0] ){
(*func)(arg, pItem->zDatabase, strlen(pItem->zDatabase));
(*func)(arg, ".", 1);
}
(*func)(arg, pItem->zName, strlen(pItem->zName));
length = width = 0;
break;
}
case etERROR:
buf[0] = '%';
buf[1] = c;
@@ -595,11 +606,6 @@ static int vxprintf(
register int nspace;
nspace = width-length;
if( nspace>0 ){
if( flag_center ){
nspace = nspace/2;
width -= nspace;
flag_leftjustify = 1;
}
count += nspace;
while( nspace>=etSPACESIZE ){
(*func)(arg,spaces,etSPACESIZE);
@@ -639,7 +645,9 @@ struct sgMprintf {
char *zBase; /* A base allocation */
char *zText; /* The string collected so far */
int nChar; /* Length of the string so far */
int nTotal; /* Output size if unconstrained */
int nAlloc; /* Amount of space allocated in zText */
void *(*xRealloc)(void*,int); /* Function used to realloc memory */
};
/*
@@ -648,83 +656,130 @@ struct sgMprintf {
** This routine add nNewChar characters of text in zNewText to
** the sgMprintf structure pointed to by "arg".
*/
static void mout(void *arg, char *zNewText, int nNewChar){
static void mout(void *arg, const char *zNewText, int nNewChar){
struct sgMprintf *pM = (struct sgMprintf*)arg;
pM->nTotal += nNewChar;
if( pM->nChar + nNewChar + 1 > pM->nAlloc ){
pM->nAlloc = pM->nChar + nNewChar*2 + 1;
if( pM->zText==pM->zBase ){
pM->zText = sqliteMalloc(pM->nAlloc);
if( pM->zText && pM->nChar ) memcpy(pM->zText,pM->zBase,pM->nChar);
if( pM->xRealloc==0 ){
nNewChar = pM->nAlloc - pM->nChar - 1;
}else{
char *z = sqliteRealloc(pM->zText, pM->nAlloc);
if( z==0 ){
sqliteFree(pM->zText);
pM->nChar = 0;
pM->nAlloc = 0;
pM->nAlloc = pM->nChar + nNewChar*2 + 1;
if( pM->zText==pM->zBase ){
pM->zText = pM->xRealloc(0, pM->nAlloc);
if( pM->zText && pM->nChar ){
memcpy(pM->zText, pM->zBase, pM->nChar);
}
}else{
pM->zText = pM->xRealloc(pM->zText, pM->nAlloc);
}
pM->zText = z;
}
}
if( pM->zText ){
memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);
pM->nChar += nNewChar;
if( nNewChar>0 ){
memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);
pM->nChar += nNewChar;
}
pM->zText[pM->nChar] = 0;
}
}
/*
** sqlite_mprintf() works like printf(), but allocations memory to hold the
** resulting string and returns a pointer to the allocated memory. Use
** sqliteFree() to release the memory allocated.
** This routine is a wrapper around xprintf() that invokes mout() as
** the consumer.
*/
static char *base_vprintf(
void *(*xRealloc)(void*,int), /* Routine to realloc memory. May be NULL */
int useInternal, /* Use internal %-conversions if true */
char *zInitBuf, /* Initially write here, before mallocing */
int nInitBuf, /* Size of zInitBuf[] */
const char *zFormat, /* format string */
va_list ap /* arguments */
){
struct sgMprintf sM;
sM.zBase = sM.zText = zInitBuf;
sM.nChar = sM.nTotal = 0;
sM.nAlloc = nInitBuf;
sM.xRealloc = xRealloc;
vxprintf(mout, &sM, useInternal, zFormat, ap);
if( xRealloc ){
if( sM.zText==sM.zBase ){
sM.zText = xRealloc(0, sM.nChar+1);
memcpy(sM.zText, sM.zBase, sM.nChar+1);
}else if( sM.nAlloc>sM.nChar+10 ){
sM.zText = xRealloc(sM.zText, sM.nChar+1);
}
}
return sM.zText;
}
/*
** Realloc that is a real function, not a macro.
*/
static void *printf_realloc(void *old, int size){
return sqliteRealloc(old,size);
}
/*
** Print into memory obtained from sqliteMalloc(). Use the internal
** %-conversion extensions.
*/
char *sqliteVMPrintf(const char *zFormat, va_list ap){
char zBase[1000];
return base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
}
/*
** Print into memory obtained from sqliteMalloc(). Use the internal
** %-conversion extensions.
*/
char *sqliteMPrintf(const char *zFormat, ...){
va_list ap;
char *z;
char zBase[1000];
va_start(ap, zFormat);
z = base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
va_end(ap);
return z;
}
/*
** Print into memory obtained from malloc(). Do not use the internal
** %-conversion extensions. This routine is for use by external users.
*/
char *sqlite_mprintf(const char *zFormat, ...){
va_list ap;
struct sgMprintf sMprintf;
char *zNew;
char *z;
char zBuf[200];
sMprintf.nChar = 0;
sMprintf.nAlloc = sizeof(zBuf);
sMprintf.zText = zBuf;
sMprintf.zBase = zBuf;
va_start(ap,zFormat);
vxprintf(mout,&sMprintf,zFormat,ap);
z = base_vprintf((void*(*)(void*,int))realloc, 0,
zBuf, sizeof(zBuf), zFormat, ap);
va_end(ap);
sMprintf.zText[sMprintf.nChar] = 0;
if( sMprintf.zText==sMprintf.zBase ){
zNew = sqliteMalloc( sMprintf.nChar+1 );
if( zNew ) strcpy(zNew,zBuf);
}else{
zNew = sqliteRealloc(sMprintf.zText,sMprintf.nChar+1);
if( zNew==0 ){
sqliteFree(sMprintf.zText);
}
}
return zNew;
return z;
}
/* This is the varargs version of sqlite_mprintf.
*/
char *sqlite_vmprintf(const char *zFormat, va_list ap){
struct sgMprintf sMprintf;
char zBuf[200];
sMprintf.nChar = 0;
sMprintf.zText = zBuf;
sMprintf.nAlloc = sizeof(zBuf);
sMprintf.zBase = zBuf;
vxprintf(mout,&sMprintf,zFormat,ap);
sMprintf.zText[sMprintf.nChar] = 0;
if( sMprintf.zText==sMprintf.zBase ){
sMprintf.zText = sqliteMalloc( strlen(zBuf)+1 );
if( sMprintf.zText ) strcpy(sMprintf.zText,zBuf);
}else{
char *z = sqliteRealloc(sMprintf.zText,sMprintf.nChar+1);
if( z==0 ){
sqliteFree(sMprintf.zText);
}
sMprintf.zText = z;
}
return sMprintf.zText;
return base_vprintf((void*(*)(void*,int))realloc, 0,
zBuf, sizeof(zBuf), zFormat, ap);
}
/*
** sqlite_snprintf() works like snprintf() except that it ignores the
** current locale settings. This is important for SQLite because we
** are not able to use a "," as the decimal point in place of "." as
** specified by some locales.
*/
char *sqlite_snprintf(int n, char *zBuf, const char *zFormat, ...){
char *z;
va_list ap;
va_start(ap,zFormat);
z = base_vprintf(0, 0, zBuf, n, zFormat, ap);
va_end(ap);
return z;
}
/*
@@ -737,7 +792,7 @@ char *sqlite_vmprintf(const char *zFormat, va_list ap){
*/
int sqlite_exec_printf(
sqlite *db, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
sqlite_callback xCallback, /* Callback function */
void *pArg, /* 1st argument to callback function */
char **errmsg, /* Error msg written here */
@@ -753,7 +808,7 @@ int sqlite_exec_printf(
}
int sqlite_exec_vprintf(
sqlite *db, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
sqlite_callback xCallback, /* Callback function */
void *pArg, /* 1st argument to callback function */
char **errmsg, /* Error msg written here */
@@ -764,12 +819,12 @@ int sqlite_exec_vprintf(
zSql = sqlite_vmprintf(sqlFormat, ap);
rc = sqlite_exec(db, zSql, xCallback, pArg, errmsg);
sqliteFree(zSql);
free(zSql);
return rc;
}
int sqlite_get_table_printf(
sqlite *db, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
char ***resultp, /* Result written to a char *[] that this points to */
int *nrow, /* Number of result rows written here */
int *ncol, /* Number of result columns written here */
@@ -786,7 +841,7 @@ int sqlite_get_table_printf(
}
int sqlite_get_table_vprintf(
sqlite *db, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
char ***resultp, /* Result written to a char *[] that this points to */
int *nrow, /* Number of result rows written here */
int *ncolumn, /* Number of result columns written here */
@@ -798,6 +853,6 @@ int sqlite_get_table_vprintf(
zSql = sqlite_vmprintf(sqlFormat, ap);
rc = sqlite_get_table(db, zSql, resultp, nrow, ncolumn, errmsg);
sqliteFree(zSql);
free(zSql);
return rc;
}
+25 -31
View File
@@ -15,25 +15,35 @@
** Random numbers are used by some of the database backends in order
** to generate random integer keys for tables or random filenames.
**
** $Id: random.c,v 1.8 2001/10/09 04:19:47 drh Exp $
** $Id: random.c,v 1.11 2004/02/11 09:46:33 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
/*
** Get a single 8-bit random value from the RC4 PRNG. The Mutex
** must be held while executing this routine.
**
** Why not just use a library random generator like lrand48() for this?
** Because the OP_NewRecno opcode in the VDBE depends on having a very
** good source of random numbers. The lrand48() library function may
** well be good enough. But maybe not. Or maybe lrand48() has some
** subtle problems on some systems that could cause problems. It is hard
** to know. To minimize the risk of problems due to bad lrand48()
** implementations, SQLite uses this random number generator based
** on RC4, which we know works very well.
*/
static int randomByte(){
int t;
unsigned char t;
/* All threads share a single random number generator.
** This structure is the current state of the generator.
*/
static struct {
int isInit; /* True if initialized */
int i, j; /* State variables */
int s[256]; /* State variables */
unsigned char isInit; /* True if initialized */
unsigned char i, j; /* State variables */
unsigned char s[256]; /* State variables */
} prng;
/* Initialize the state of the random number generator once,
@@ -55,8 +65,7 @@ static int randomByte(){
prng.s[i] = i;
}
for(i=0; i<256; i++){
int t;
prng.j = (prng.j + prng.s[i] + k[i]) & 0xff;
prng.j += prng.s[i] + k[i];
t = prng.s[prng.j];
prng.s[prng.j] = prng.s[i];
prng.s[i] = t;
@@ -66,38 +75,23 @@ static int randomByte(){
/* Generate and return single random byte
*/
prng.i = (prng.i + 1) & 0xff;
prng.j = (prng.j + prng.s[prng.i]) & 0xff;
prng.i++;
t = prng.s[prng.i];
prng.j += t;
prng.s[prng.i] = prng.s[prng.j];
prng.s[prng.j] = t;
t = prng.s[prng.i] + prng.s[prng.j];
return prng.s[t & 0xff];
t += prng.s[prng.i];
return prng.s[t];
}
/*
** Return an random 8-bit integer.
** Return N random bytes.
*/
int sqliteRandomByte(){
int r;
void sqliteRandomness(int N, void *pBuf){
unsigned char *zBuf = pBuf;
sqliteOsEnterMutex();
r = randomByte();
sqliteOsLeaveMutex();
return r;
}
/*
** Return a random 32-bit integer. The integer is generated by making
** 4 calls to sqliteRandomByte().
*/
int sqliteRandomInteger(){
int r;
int i;
sqliteOsEnterMutex();
r = randomByte();
for(i=1; i<4; i++){
r = (r<<8) + randomByte();
while( N-- ){
*(zBuf++) = randomByte();
}
sqliteOsLeaveMutex();
return r;
}
+1839 -411
View File
File diff suppressed because it is too large Load Diff
+633 -208
View File
File diff suppressed because it is too large Load Diff
-596
View File
@@ -1,596 +0,0 @@
#!/usr/bin/wish
#
# A GUI shell for SQLite
#
# The following code is slighly modified from the original. See comments
# for the modifications...
############################################################################
# A console widget for Tcl/Tk. Invoke console:create with a window name,
# a prompt string, and a title to get a new top-level window that allows
# the user to enter tcl commands. This is mainly useful for testing and
# debugging.
#
# Copyright (C) 1998, 1999 D. Richard Hipp
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Author contact information:
# drh@acm.org
# http://www.hwaci.com/drh/
# Create a console widget named $w. The prompt string is $prompt.
# The title at the top of the window is $title
#
proc console:create {w prompt title} {
upvar #0 $w.t v
if {[winfo exists $w]} {destroy $w}
if {[info exists v]} {unset v}
toplevel $w
wm title $w $title
wm iconname $w $title
frame $w.mb -bd 2 -relief raised
pack $w.mb -side top -fill x
menubutton $w.mb.file -text File -menu $w.mb.file.m
menubutton $w.mb.edit -text Edit -menu $w.mb.edit.m
pack $w.mb.file $w.mb.edit -side left -padx 8 -pady 1
set m [menu $w.mb.file.m]
# $m add command -label {Source...} -command "console:SourceFile $w.t"
# $m add command -label {Save As...} -command "console:SaveFile $w.t"
# $m add separator
$m add command -label {Close} -command "destroy $w"
$m add command -label {Exit} -command exit
console:create_child $w $prompt $w.mb.edit.m
}
# This routine creates a console as a child window within a larger
# window. It also creates an edit menu named "$editmenu" if $editmenu!="".
# The calling function is responsible for posting the edit menu.
#
proc console:create_child {w prompt editmenu} {
upvar #0 $w.t v
if {$editmenu!=""} {
set m [menu $editmenu]
$m add command -label Cut -command "console:Cut $w.t"
$m add command -label Copy -command "console:Copy $w.t"
$m add command -label Paste -command "console:Paste $w.t"
$m add command -label {Clear Screen} -command "console:Clear $w.t"
$m add separator
$m add command -label {Source...} -command "console:SourceFile $w.t"
$m add command -label {Save As...} -command "console:SaveFile $w.t"
catch {$editmenu config -postcommand "console:EnableEditMenu $w"}
}
scrollbar $w.sb -orient vertical -command "$w.t yview"
pack $w.sb -side right -fill y
text $w.t -font fixed -yscrollcommand "$w.sb set"
pack $w.t -side right -fill both -expand 1
bindtags $w.t Console
set v(editmenu) $editmenu
set v(text) $w.t
set v(history) 0
set v(historycnt) 0
set v(current) -1
set v(prompt) $prompt
set v(prior) {}
set v(plength) [string length $v(prompt)]
set v(x) 0
set v(y) 0
$w.t mark set insert end
$w.t tag config ok -foreground blue
$w.t tag config err -foreground red
$w.t insert end $v(prompt)
$w.t mark set out 1.0
catch {rename puts console:oldputs$w}
proc puts args [format {
if {![winfo exists %s]} {
rename puts {}
rename console:oldputs%s puts
return [uplevel #0 puts $args]
}
switch -glob -- "[llength $args] $args" {
{1 *} {
set msg [lindex $args 0]\n
set tag ok
}
{2 stdout *} {
set msg [lindex $args 1]\n
set tag ok
}
{2 stderr *} {
set msg [lindex $args 1]\n
set tag err
}
{2 -nonewline *} {
set msg [lindex $args 1]
set tag ok
}
{3 -nonewline stdout *} {
set msg [lindex $args 2]
set tag ok
}
{3 -nonewline stderr *} {
set msg [lindex $args 2]
set tag err
}
default {
uplevel #0 console:oldputs%s $args
return
}
}
console:Puts %s $msg $tag
} $w $w $w $w.t]
after idle "focus $w.t"
}
bind Console <1> {console:Button1 %W %x %y}
bind Console <B1-Motion> {console:B1Motion %W %x %y}
bind Console <B1-Leave> {console:B1Leave %W %x %y}
bind Console <B1-Enter> {console:cancelMotor %W}
bind Console <ButtonRelease-1> {console:cancelMotor %W}
bind Console <KeyPress> {console:Insert %W %A}
bind Console <Left> {console:Left %W}
bind Console <Control-b> {console:Left %W}
bind Console <Right> {console:Right %W}
bind Console <Control-f> {console:Right %W}
bind Console <BackSpace> {console:Backspace %W}
bind Console <Control-h> {console:Backspace %W}
bind Console <Delete> {console:Delete %W}
bind Console <Control-d> {console:Delete %W}
bind Console <Home> {console:Home %W}
bind Console <Control-a> {console:Home %W}
bind Console <End> {console:End %W}
bind Console <Control-e> {console:End %W}
bind Console <Return> {console:Enter %W}
bind Console <KP_Enter> {console:Enter %W}
bind Console <Up> {console:Prior %W}
bind Console <Control-p> {console:Prior %W}
bind Console <Down> {console:Next %W}
bind Console <Control-n> {console:Next %W}
bind Console <Control-k> {console:EraseEOL %W}
bind Console <<Cut>> {console:Cut %W}
bind Console <<Copy>> {console:Copy %W}
bind Console <<Paste>> {console:Paste %W}
bind Console <<Clear>> {console:Clear %W}
# Insert test at the "out" mark. The "out" mark is always
# before the input line. New text appears on the line prior
# to the current input line.
#
proc console:Puts {w t tag} {
set nc [string length $t]
set endc [string index $t [expr $nc-1]]
if {$endc=="\n"} {
if {[$w index out]<[$w index {insert linestart}]} {
$w insert out [string range $t 0 [expr $nc-2]] $tag
$w mark set out {out linestart +1 lines}
} else {
$w insert out $t $tag
}
} else {
if {[$w index out]<[$w index {insert linestart}]} {
$w insert out $t $tag
} else {
$w insert out $t\n $tag
$w mark set out {out -1 char}
}
}
$w yview insert
}
# Insert a single character at the insertion cursor
#
proc console:Insert {w a} {
$w insert insert $a
$w yview insert
}
# Move the cursor one character to the left
#
proc console:Left {w} {
upvar #0 $w v
scan [$w index insert] %d.%d row col
if {$col>$v(plength)} {
$w mark set insert "insert -1c"
}
}
# Erase the character to the left of the cursor
#
proc console:Backspace {w} {
upvar #0 $w v
scan [$w index insert] %d.%d row col
if {$col>$v(plength)} {
$w delete {insert -1c}
}
}
# Erase to the end of the line
#
proc console:EraseEOL {w} {
upvar #0 $w v
scan [$w index insert] %d.%d row col
if {$col>=$v(plength)} {
$w delete insert {insert lineend}
}
}
# Move the cursor one character to the right
#
proc console:Right {w} {
$w mark set insert "insert +1c"
}
# Erase the character to the right of the cursor
#
proc console:Delete w {
$w delete insert
}
# Move the cursor to the beginning of the current line
#
proc console:Home w {
upvar #0 $w v
scan [$w index insert] %d.%d row col
$w mark set insert $row.$v(plength)
}
# Move the cursor to the end of the current line
#
proc console:End w {
$w mark set insert {insert lineend}
}
# Called when "Enter" is pressed. Do something with the line
# of text that was entered.
#
proc console:Enter w {
upvar #0 $w v
scan [$w index insert] %d.%d row col
set start $row.$v(plength)
set line [$w get $start "$start lineend"]
if {$v(historycnt)>0} {
set last [lindex $v(history) [expr $v(historycnt)-1]]
if {[string compare $last $line]} {
lappend v(history) $line
incr v(historycnt)
}
} else {
set v(history) [list $line]
set v(historycnt) 1
}
set v(current) $v(historycnt)
$w insert end \n
$w mark set out end
if {$v(prior)==""} {
set cmd $line
} else {
set cmd $v(prior)\n$line
}
##### Original
# if {[info complete $cmd]} { }
# set rc [catch {uplevel #0 $cmd} res]
##### New
global DB
if {[$DB complete $cmd]} {
set CODE {}
set rc [catch {$DB eval $cmd RESULT $CODE}]
##### End Of Changes
if {![winfo exists $w]} return
if {$rc} {
$w insert end $res\n err
} elseif {[string length $res]>0} {
$w insert end $res\n ok
}
set v(prior) {}
$w insert end $v(prompt)
} else {
set v(prior) $cmd
regsub -all {[^ ]} $v(prompt) . x
$w insert end $x
}
$w mark set insert end
$w mark set out {insert linestart}
$w yview insert
}
# Change the line to the previous line
#
proc console:Prior w {
upvar #0 $w v
if {$v(current)<=0} return
incr v(current) -1
set line [lindex $v(history) $v(current)]
console:SetLine $w $line
}
# Change the line to the next line
#
proc console:Next w {
upvar #0 $w v
if {$v(current)>=$v(historycnt)} return
incr v(current) 1
set line [lindex $v(history) $v(current)]
console:SetLine $w $line
}
# Change the contents of the entry line
#
proc console:SetLine {w line} {
upvar #0 $w v
scan [$w index insert] %d.%d row col
set start $row.$v(plength)
$w delete $start end
$w insert end $line
$w mark set insert end
$w yview insert
}
# Called when the mouse button is pressed at position $x,$y on
# the console widget.
#
proc console:Button1 {w x y} {
global tkPriv
upvar #0 $w v
set v(mouseMoved) 0
set v(pressX) $x
set p [console:nearestBoundry $w $x $y]
scan [$w index insert] %d.%d ix iy
scan $p %d.%d px py
if {$px==$ix} {
$w mark set insert $p
}
$w mark set anchor $p
focus $w
}
# Find the boundry between characters that is nearest
# to $x,$y
#
proc console:nearestBoundry {w x y} {
set p [$w index @$x,$y]
set bb [$w bbox $p]
if {![string compare $bb ""]} {return $p}
if {($x-[lindex $bb 0])<([lindex $bb 2]/2)} {return $p}
$w index "$p + 1 char"
}
# This routine extends the selection to the point specified by $x,$y
#
proc console:SelectTo {w x y} {
upvar #0 $w v
set cur [console:nearestBoundry $w $x $y]
if {[catch {$w index anchor}]} {
$w mark set anchor $cur
}
set anchor [$w index anchor]
if {[$w compare $cur != $anchor] || (abs($v(pressX) - $x) >= 3)} {
if {$v(mouseMoved)==0} {
$w tag remove sel 0.0 end
}
set v(mouseMoved) 1
}
if {[$w compare $cur < anchor]} {
set first $cur
set last anchor
} else {
set first anchor
set last $cur
}
if {$v(mouseMoved)} {
$w tag remove sel 0.0 $first
$w tag add sel $first $last
$w tag remove sel $last end
update idletasks
}
}
# Called whenever the mouse moves while button-1 is held down.
#
proc console:B1Motion {w x y} {
upvar #0 $w v
set v(y) $y
set v(x) $x
console:SelectTo $w $x $y
}
# Called whenever the mouse leaves the boundries of the widget
# while button 1 is held down.
#
proc console:B1Leave {w x y} {
upvar #0 $w v
set v(y) $y
set v(x) $x
console:motor $w
}
# This routine is called to automatically scroll the window when
# the mouse drags offscreen.
#
proc console:motor w {
upvar #0 $w v
if {![winfo exists $w]} return
if {$v(y)>=[winfo height $w]} {
$w yview scroll 1 units
} elseif {$v(y)<0} {
$w yview scroll -1 units
} else {
return
}
console:SelectTo $w $v(x) $v(y)
set v(timer) [after 50 console:motor $w]
}
# This routine cancels the scrolling motor if it is active
#
proc console:cancelMotor w {
upvar #0 $w v
catch {after cancel $v(timer)}
catch {unset v(timer)}
}
# Do a Copy operation on the stuff currently selected.
#
proc console:Copy w {
if {![catch {set text [$w get sel.first sel.last]}]} {
clipboard clear -displayof $w
clipboard append -displayof $w $text
}
}
# Return 1 if the selection exists and is contained
# entirely on the input line. Return 2 if the selection
# exists but is not entirely on the input line. Return 0
# if the selection does not exist.
#
proc console:canCut w {
set r [catch {
scan [$w index sel.first] %d.%d s1x s1y
scan [$w index sel.last] %d.%d s2x s2y
scan [$w index insert] %d.%d ix iy
}]
if {$r==1} {return 0}
if {$s1x==$ix && $s2x==$ix} {return 1}
return 2
}
# Do a Cut operation if possible. Cuts are only allowed
# if the current selection is entirely contained on the
# current input line.
#
proc console:Cut w {
if {[console:canCut $w]==1} {
console:Copy $w
$w delete sel.first sel.last
}
}
# Do a paste opeation.
#
proc console:Paste w {
if {[console:canCut $w]==1} {
$w delete sel.first sel.last
}
if {[catch {selection get -displayof $w -selection CLIPBOARD} topaste]} {
return
}
set prior 0
foreach line [split $topaste \n] {
if {$prior} {
console:Enter $w
update
}
set prior 1
$w insert insert $line
}
}
# Enable or disable entries in the Edit menu
#
proc console:EnableEditMenu w {
upvar #0 $w.t v
set m $v(editmenu)
if {$m=="" || ![winfo exists $m]} return
switch [console:canCut $w.t] {
0 {
$m entryconf Copy -state disabled
$m entryconf Cut -state disabled
}
1 {
$m entryconf Copy -state normal
$m entryconf Cut -state normal
}
2 {
$m entryconf Copy -state normal
$m entryconf Cut -state disabled
}
}
}
# Prompt for the user to select an input file, the "source" that file.
#
proc console:SourceFile w {
set types {
{{TCL Scripts} {.tcl}}
{{All Files} *}
}
set f [tk_getOpenFile -filetypes $types -title "TCL Script To Source..."]
if {$f!=""} {
uplevel #0 source $f
}
}
# Prompt the user for the name of a writable file. Then write the
# entire contents of the console screen to that file.
#
proc console:SaveFile w {
set types {
{{Text Files} {.txt}}
{{All Files} *}
}
set f [tk_getSaveFile -filetypes $types -title "Write Screen To..."]
if {$f!=""} {
if {[catch {open $f w} fd]} {
tk_messageBox -type ok -icon error -message $fd
} else {
puts $fd [string trimright [$w get 1.0 end] \n]
close $fd
}
}
}
# Erase everything from the console above the insertion line.
#
proc console:Clear w {
$w delete 1.0 {insert linestart}
}
# Start the console
#
# console:create {.@console} {% } {Tcl/Tk Console}
###############################################################################
if {[info command sqlite]==""} {
load ./tclsqlite.so sqlite
}
proc set_title {title} {
if {$title==""} {
set main SQLite
} else {
set main "SQLite - $title"
}
wm title . $main
wm iconname . SQLite
}
set_title {}
frame .mb -bd 1 -relief raised
pack .mb -side top -fill x
menubutton .mb.file -text File -underline 0 -menu .mb.file.m
pack .mb.file -side left -padx 5
set m [menu .mb.file.m]
$m add separator
$m add command -label Exit -command exit
menubutton .mb.edit -text Edit -underline 0 -menu .mb.edit.m
pack .mb.edit -side left -padx 5
#menu .mb.edit.m
frame .f
pack .f -side top -fill both -expand 1
console:create_child .f {sqlite> } .mb.edit.m
+544 -15
View File
@@ -12,17 +12,12 @@
** This header file defines the interface that the SQLite library
** presents to client programs.
**
** @(#) $Id: sqlite.h.in,v 1.22 2001/10/22 02:58:10 drh Exp $
** @(#) $Id: sqlite.h.in,v 1.60.2.1 2004/10/06 15:52:36 drh Exp $
*/
#ifndef _SQLITE_H_
#define _SQLITE_H_
#include <stdarg.h> /* Needed for the definition of va_list */
/*
** The version of the SQLite library.
*/
#define SQLITE_VERSION "--VERS--"
/*
** Make sure we can call this stuff from C++.
*/
@@ -30,6 +25,15 @@
extern "C" {
#endif
/*
** The version of the SQLite library.
*/
#ifdef SQLITE_VERSION
# undef SQLITE_VERSION
#else
# define SQLITE_VERSION "--VERS--"
#endif
/*
** The version string is also compiled into the library so that a program
** can check to make sure that the lib*.a file and the *.h file are from
@@ -73,7 +77,7 @@ typedef struct sqlite sqlite;
** The Truth: As currently implemented, all databases are opened
** for writing all the time. Maybe someday we will provide the
** ability to open a database readonly. The mode parameters is
** provide in anticipation of that enhancement.
** provided in anticipation of that enhancement.
*/
sqlite *sqlite_open(const char *filename, int mode, char **errmsg);
@@ -118,7 +122,8 @@ typedef int (*sqlite_callback)(void*,int,char**, char**);
** message is written into memory obtained from malloc() and
** *errmsg is made to point to that message. The calling function
** is responsible for freeing the memory that holds the error
** message. If errmsg==NULL, then no error message is ever written.
** message. Use sqlite_freemem() for this. If errmsg==NULL,
** then no error message is ever written.
**
** The return value is is SQLITE_OK if there are no errors and
** some other return code if there is an error. The particular
@@ -131,14 +136,14 @@ typedef int (*sqlite_callback)(void*,int,char**, char**);
*/
int sqlite_exec(
sqlite*, /* An open database */
char *sql, /* SQL to be executed */
const char *sql, /* SQL to be executed */
sqlite_callback, /* Callback function */
void *, /* 1st argument to callback function */
char **errmsg /* Error msg written here */
);
/*
** Return values for sqlite_exec()
** Return values for sqlite_exec() and sqlite_step()
*/
#define SQLITE_OK 0 /* Successful result */
#define SQLITE_ERROR 1 /* SQL error or missing database */
@@ -160,6 +165,74 @@ int sqlite_exec(
#define SQLITE_SCHEMA 17 /* The database schema changed */
#define SQLITE_TOOBIG 18 /* Too much data for one row of a table */
#define SQLITE_CONSTRAINT 19 /* Abort due to contraint violation */
#define SQLITE_MISMATCH 20 /* Data type mismatch */
#define SQLITE_MISUSE 21 /* Library used incorrectly */
#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
#define SQLITE_AUTH 23 /* Authorization denied */
#define SQLITE_FORMAT 24 /* Auxiliary database format error */
#define SQLITE_RANGE 25 /* 2nd parameter to sqlite_bind out of range */
#define SQLITE_NOTADB 26 /* File opened that is not a database file */
#define SQLITE_ROW 100 /* sqlite_step() has another row ready */
#define SQLITE_DONE 101 /* sqlite_step() has finished executing */
/*
** Each entry in an SQLite table has a unique integer key. (The key is
** the value of the INTEGER PRIMARY KEY column if there is such a column,
** otherwise the key is generated at random. The unique key is always
** available as the ROWID, OID, or _ROWID_ column.) The following routine
** returns the integer key of the most recent insert in the database.
**
** This function is similar to the mysql_insert_id() function from MySQL.
*/
int sqlite_last_insert_rowid(sqlite*);
/*
** This function returns the number of database rows that were changed
** (or inserted or deleted) by the most recent called sqlite_exec().
**
** All changes are counted, even if they were later undone by a
** ROLLBACK or ABORT. Except, changes associated with creating and
** dropping tables are not counted.
**
** If a callback invokes sqlite_exec() recursively, then the changes
** in the inner, recursive call are counted together with the changes
** in the outer call.
**
** SQLite implements the command "DELETE FROM table" without a WHERE clause
** by dropping and recreating the table. (This is much faster than going
** through and deleting individual elements form the table.) Because of
** this optimization, the change count for "DELETE FROM table" will be
** zero regardless of the number of elements that were originally in the
** table. To get an accurate count of the number of rows deleted, use
** "DELETE FROM table WHERE 1" instead.
*/
int sqlite_changes(sqlite*);
/*
** This function returns the number of database rows that were changed
** by the last INSERT, UPDATE, or DELETE statment executed by sqlite_exec(),
** or by the last VM to run to completion. The change count is not updated
** by SQL statements other than INSERT, UPDATE or DELETE.
**
** Changes are counted, even if they are later undone by a ROLLBACK or
** ABORT. Changes associated with trigger programs that execute as a
** result of the INSERT, UPDATE, or DELETE statement are not counted.
**
** If a callback invokes sqlite_exec() recursively, then the changes
** in the inner, recursive call are counted together with the changes
** in the outer call.
**
** SQLite implements the command "DELETE FROM table" without a WHERE clause
** by dropping and recreating the table. (This is much faster than going
** through and deleting individual elements form the table.) Because of
** this optimization, the change count for "DELETE FROM table" will be
** zero regardless of the number of elements that were originally in the
** table. To get an accurate count of the number of rows deleted, use
** "DELETE FROM table WHERE 1" instead.
**
******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
*/
int sqlite_last_statement_changes(sqlite*);
/* If the parameter to this routine is one of the return value constants
** defined above, then this routine returns a constant text string which
@@ -265,7 +338,7 @@ void sqlite_busy_timeout(sqlite*, int ms);
*/
int sqlite_get_table(
sqlite*, /* An open database */
char *sql, /* SQL to be executed */
const char *sql, /* SQL to be executed */
char ***resultp, /* Result written to a char *[] that this points to */
int *nrow, /* Number of result rows written here */
int *ncolumn, /* Number of result columns written here */
@@ -317,7 +390,7 @@ void sqlite_free_table(char **result);
*/
int sqlite_exec_printf(
sqlite*, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
sqlite_callback, /* Callback function */
void *, /* 1st argument to callback function */
char **errmsg, /* Error msg written here */
@@ -325,7 +398,7 @@ int sqlite_exec_printf(
);
int sqlite_exec_vprintf(
sqlite*, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
sqlite_callback, /* Callback function */
void *, /* 1st argument to callback function */
char **errmsg, /* Error msg written here */
@@ -333,7 +406,7 @@ int sqlite_exec_vprintf(
);
int sqlite_get_table_printf(
sqlite*, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
char ***resultp, /* Result written to a char *[] that this points to */
int *nrow, /* Number of result rows written here */
int *ncolumn, /* Number of result columns written here */
@@ -342,13 +415,469 @@ int sqlite_get_table_printf(
);
int sqlite_get_table_vprintf(
sqlite*, /* An open database */
char *sqlFormat, /* printf-style format string for the SQL */
const char *sqlFormat, /* printf-style format string for the SQL */
char ***resultp, /* Result written to a char *[] that this points to */
int *nrow, /* Number of result rows written here */
int *ncolumn, /* Number of result columns written here */
char **errmsg, /* Error msg written here */
va_list ap /* Arguments to the format string */
);
char *sqlite_mprintf(const char*,...);
char *sqlite_vmprintf(const char*, va_list);
/*
** Windows systems should call this routine to free memory that
** is returned in the in the errmsg parameter of sqlite_open() when
** SQLite is a DLL. For some reason, it does not work to call free()
** directly.
*/
void sqlite_freemem(void *p);
/*
** Windows systems need functions to call to return the sqlite_version
** and sqlite_encoding strings.
*/
const char *sqlite_libversion(void);
const char *sqlite_libencoding(void);
/*
** A pointer to the following structure is used to communicate with
** the implementations of user-defined functions.
*/
typedef struct sqlite_func sqlite_func;
/*
** Use the following routines to create new user-defined functions. See
** the documentation for details.
*/
int sqlite_create_function(
sqlite*, /* Database where the new function is registered */
const char *zName, /* Name of the new function */
int nArg, /* Number of arguments. -1 means any number */
void (*xFunc)(sqlite_func*,int,const char**), /* C code to implement */
void *pUserData /* Available via the sqlite_user_data() call */
);
int sqlite_create_aggregate(
sqlite*, /* Database where the new function is registered */
const char *zName, /* Name of the function */
int nArg, /* Number of arguments */
void (*xStep)(sqlite_func*,int,const char**), /* Called for each row */
void (*xFinalize)(sqlite_func*), /* Called once to get final result */
void *pUserData /* Available via the sqlite_user_data() call */
);
/*
** Use the following routine to define the datatype returned by a
** user-defined function. The second argument can be one of the
** constants SQLITE_NUMERIC, SQLITE_TEXT, or SQLITE_ARGS or it
** can be an integer greater than or equal to zero. When the datatype
** parameter is non-negative, the type of the result will be the
** same as the datatype-th argument. If datatype==SQLITE_NUMERIC
** then the result is always numeric. If datatype==SQLITE_TEXT then
** the result is always text. If datatype==SQLITE_ARGS then the result
** is numeric if any argument is numeric and is text otherwise.
*/
int sqlite_function_type(
sqlite *db, /* The database there the function is registered */
const char *zName, /* Name of the function */
int datatype /* The datatype for this function */
);
#define SQLITE_NUMERIC (-1)
/* #define SQLITE_TEXT (-2) // See below */
#define SQLITE_ARGS (-3)
/*
** SQLite version 3 defines SQLITE_TEXT differently. To allow both
** version 2 and version 3 to be included, undefine them both if a
** conflict is seen. Define SQLITE2_TEXT to be the version 2 value.
*/
#ifdef SQLITE_TEXT
# undef SQLITE_TEXT
#else
# define SQLITE_TEXT (-2)
#endif
#define SQLITE2_TEXT (-2)
/*
** The user function implementations call one of the following four routines
** in order to return their results. The first parameter to each of these
** routines is a copy of the first argument to xFunc() or xFinialize().
** The second parameter to these routines is the result to be returned.
** A NULL can be passed as the second parameter to sqlite_set_result_string()
** in order to return a NULL result.
**
** The 3rd argument to _string and _error is the number of characters to
** take from the string. If this argument is negative, then all characters
** up to and including the first '\000' are used.
**
** The sqlite_set_result_string() function allocates a buffer to hold the
** result and returns a pointer to this buffer. The calling routine
** (that is, the implmentation of a user function) can alter the content
** of this buffer if desired.
*/
char *sqlite_set_result_string(sqlite_func*,const char*,int);
void sqlite_set_result_int(sqlite_func*,int);
void sqlite_set_result_double(sqlite_func*,double);
void sqlite_set_result_error(sqlite_func*,const char*,int);
/*
** The pUserData parameter to the sqlite_create_function() and
** sqlite_create_aggregate() routines used to register user functions
** is available to the implementation of the function using this
** call.
*/
void *sqlite_user_data(sqlite_func*);
/*
** Aggregate functions use the following routine to allocate
** a structure for storing their state. The first time this routine
** is called for a particular aggregate, a new structure of size nBytes
** is allocated, zeroed, and returned. On subsequent calls (for the
** same aggregate instance) the same buffer is returned. The implementation
** of the aggregate can use the returned buffer to accumulate data.
**
** The buffer allocated is freed automatically be SQLite.
*/
void *sqlite_aggregate_context(sqlite_func*, int nBytes);
/*
** The next routine returns the number of calls to xStep for a particular
** aggregate function instance. The current call to xStep counts so this
** routine always returns at least 1.
*/
int sqlite_aggregate_count(sqlite_func*);
/*
** This routine registers a callback with the SQLite library. The
** callback is invoked (at compile-time, not at run-time) for each
** attempt to access a column of a table in the database. The callback
** returns SQLITE_OK if access is allowed, SQLITE_DENY if the entire
** SQL statement should be aborted with an error and SQLITE_IGNORE
** if the column should be treated as a NULL value.
*/
int sqlite_set_authorizer(
sqlite*,
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
void *pUserData
);
/*
** The second parameter to the access authorization function above will
** be one of the values below. These values signify what kind of operation
** is to be authorized. The 3rd and 4th parameters to the authorization
** function will be parameters or NULL depending on which of the following
** codes is used as the second parameter. The 5th parameter is the name
** of the database ("main", "temp", etc.) if applicable. The 6th parameter
** is the name of the inner-most trigger or view that is responsible for
** the access attempt or NULL if this access attempt is directly from
** input SQL code.
**
** Arg-3 Arg-4
*/
#define SQLITE_COPY 0 /* Table Name File Name */
#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */
#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
#define SQLITE_CREATE_VIEW 8 /* View Name NULL */
#define SQLITE_DELETE 9 /* Table Name NULL */
#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
#define SQLITE_DROP_TABLE 11 /* Table Name NULL */
#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */
#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
#define SQLITE_DROP_VIEW 17 /* View Name NULL */
#define SQLITE_INSERT 18 /* Table Name NULL */
#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */
#define SQLITE_READ 20 /* Table Name Column Name */
#define SQLITE_SELECT 21 /* NULL NULL */
#define SQLITE_TRANSACTION 22 /* NULL NULL */
#define SQLITE_UPDATE 23 /* Table Name Column Name */
#define SQLITE_ATTACH 24 /* Filename NULL */
#define SQLITE_DETACH 25 /* Database Name NULL */
/*
** The return value of the authorization function should be one of the
** following constants:
*/
/* #define SQLITE_OK 0 // Allow access (This is actually defined above) */
#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
/*
** Register a function that is called at every invocation of sqlite_exec()
** or sqlite_compile(). This function can be used (for example) to generate
** a log file of all SQL executed against a database.
*/
void *sqlite_trace(sqlite*, void(*xTrace)(void*,const char*), void*);
/*** The Callback-Free API
**
** The following routines implement a new way to access SQLite that does not
** involve the use of callbacks.
**
** An sqlite_vm is an opaque object that represents a single SQL statement
** that is ready to be executed.
*/
typedef struct sqlite_vm sqlite_vm;
/*
** To execute an SQLite query without the use of callbacks, you first have
** to compile the SQL using this routine. The 1st parameter "db" is a pointer
** to an sqlite object obtained from sqlite_open(). The 2nd parameter
** "zSql" is the text of the SQL to be compiled. The remaining parameters
** are all outputs.
**
** *pzTail is made to point to the first character past the end of the first
** SQL statement in zSql. This routine only compiles the first statement
** in zSql, so *pzTail is left pointing to what remains uncompiled.
**
** *ppVm is left pointing to a "virtual machine" that can be used to execute
** the compiled statement. Or if there is an error, *ppVm may be set to NULL.
** If the input text contained no SQL (if the input is and empty string or
** a comment) then *ppVm is set to NULL.
**
** If any errors are detected during compilation, an error message is written
** into space obtained from malloc() and *pzErrMsg is made to point to that
** error message. The calling routine is responsible for freeing the text
** of this message when it has finished with it. Use sqlite_freemem() to
** free the message. pzErrMsg may be NULL in which case no error message
** will be generated.
**
** On success, SQLITE_OK is returned. Otherwise and error code is returned.
*/
int sqlite_compile(
sqlite *db, /* The open database */
const char *zSql, /* SQL statement to be compiled */
const char **pzTail, /* OUT: uncompiled tail of zSql */
sqlite_vm **ppVm, /* OUT: the virtual machine to execute zSql */
char **pzErrmsg /* OUT: Error message. */
);
/*
** After an SQL statement has been compiled, it is handed to this routine
** to be executed. This routine executes the statement as far as it can
** go then returns. The return value will be one of SQLITE_DONE,
** SQLITE_ERROR, SQLITE_BUSY, SQLITE_ROW, or SQLITE_MISUSE.
**
** SQLITE_DONE means that the execute of the SQL statement is complete
** an no errors have occurred. sqlite_step() should not be called again
** for the same virtual machine. *pN is set to the number of columns in
** the result set and *pazColName is set to an array of strings that
** describe the column names and datatypes. The name of the i-th column
** is (*pazColName)[i] and the datatype of the i-th column is
** (*pazColName)[i+*pN]. *pazValue is set to NULL.
**
** SQLITE_ERROR means that the virtual machine encountered a run-time
** error. sqlite_step() should not be called again for the same
** virtual machine. *pN is set to 0 and *pazColName and *pazValue are set
** to NULL. Use sqlite_finalize() to obtain the specific error code
** and the error message text for the error.
**
** SQLITE_BUSY means that an attempt to open the database failed because
** another thread or process is holding a lock. The calling routine
** can try again to open the database by calling sqlite_step() again.
** The return code will only be SQLITE_BUSY if no busy handler is registered
** using the sqlite_busy_handler() or sqlite_busy_timeout() routines. If
** a busy handler callback has been registered but returns 0, then this
** routine will return SQLITE_ERROR and sqltie_finalize() will return
** SQLITE_BUSY when it is called.
**
** SQLITE_ROW means that a single row of the result is now available.
** The data is contained in *pazValue. The value of the i-th column is
** (*azValue)[i]. *pN and *pazColName are set as described in SQLITE_DONE.
** Invoke sqlite_step() again to advance to the next row.
**
** SQLITE_MISUSE is returned if sqlite_step() is called incorrectly.
** For example, if you call sqlite_step() after the virtual machine
** has halted (after a prior call to sqlite_step() has returned SQLITE_DONE)
** or if you call sqlite_step() with an incorrectly initialized virtual
** machine or a virtual machine that has been deleted or that is associated
** with an sqlite structure that has been closed.
*/
int sqlite_step(
sqlite_vm *pVm, /* The virtual machine to execute */
int *pN, /* OUT: Number of columns in result */
const char ***pazValue, /* OUT: Column data */
const char ***pazColName /* OUT: Column names and datatypes */
);
/*
** This routine is called to delete a virtual machine after it has finished
** executing. The return value is the result code. SQLITE_OK is returned
** if the statement executed successfully and some other value is returned if
** there was any kind of error. If an error occurred and pzErrMsg is not
** NULL, then an error message is written into memory obtained from malloc()
** and *pzErrMsg is made to point to that error message. The calling routine
** should use sqlite_freemem() to delete this message when it has finished
** with it.
**
** This routine can be called at any point during the execution of the
** virtual machine. If the virtual machine has not completed execution
** when this routine is called, that is like encountering an error or
** an interrupt. (See sqlite_interrupt().) Incomplete updates may be
** rolled back and transactions cancelled, depending on the circumstances,
** and the result code returned will be SQLITE_ABORT.
*/
int sqlite_finalize(sqlite_vm*, char **pzErrMsg);
/*
** This routine deletes the virtual machine, writes any error message to
** *pzErrMsg and returns an SQLite return code in the same way as the
** sqlite_finalize() function.
**
** Additionally, if ppVm is not NULL, *ppVm is left pointing to a new virtual
** machine loaded with the compiled version of the original query ready for
** execution.
**
** If sqlite_reset() returns SQLITE_SCHEMA, then *ppVm is set to NULL.
**
******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
*/
int sqlite_reset(sqlite_vm*, char **pzErrMsg);
/*
** If the SQL that was handed to sqlite_compile contains variables that
** are represeted in the SQL text by a question mark ('?'). This routine
** is used to assign values to those variables.
**
** The first parameter is a virtual machine obtained from sqlite_compile().
** The 2nd "idx" parameter determines which variable in the SQL statement
** to bind the value to. The left most '?' is 1. The 3rd parameter is
** the value to assign to that variable. The 4th parameter is the number
** of bytes in the value, including the terminating \000 for strings.
** Finally, the 5th "copy" parameter is TRUE if SQLite should make its
** own private copy of this value, or false if the space that the 3rd
** parameter points to will be unchanging and can be used directly by
** SQLite.
**
** Unbound variables are treated as having a value of NULL. To explicitly
** set a variable to NULL, call this routine with the 3rd parameter as a
** NULL pointer.
**
** If the 4th "len" parameter is -1, then strlen() is used to find the
** length.
**
** This routine can only be called immediately after sqlite_compile()
** or sqlite_reset() and before any calls to sqlite_step().
**
******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
*/
int sqlite_bind(sqlite_vm*, int idx, const char *value, int len, int copy);
/*
** This routine configures a callback function - the progress callback - that
** is invoked periodically during long running calls to sqlite_exec(),
** sqlite_step() and sqlite_get_table(). An example use for this API is to keep
** a GUI updated during a large query.
**
** The progress callback is invoked once for every N virtual machine opcodes,
** where N is the second argument to this function. The progress callback
** itself is identified by the third argument to this function. The fourth
** argument to this function is a void pointer passed to the progress callback
** function each time it is invoked.
**
** If a call to sqlite_exec(), sqlite_step() or sqlite_get_table() results
** in less than N opcodes being executed, then the progress callback is not
** invoked.
**
** Calling this routine overwrites any previously installed progress callback.
** To remove the progress callback altogether, pass NULL as the third
** argument to this function.
**
** If the progress callback returns a result other than 0, then the current
** query is immediately terminated and any database changes rolled back. If the
** query was part of a larger transaction, then the transaction is not rolled
** back and remains active. The sqlite_exec() call returns SQLITE_ABORT.
**
******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
*/
void sqlite_progress_handler(sqlite*, int, int(*)(void*), void*);
/*
** Register a callback function to be invoked whenever a new transaction
** is committed. The pArg argument is passed through to the callback.
** callback. If the callback function returns non-zero, then the commit
** is converted into a rollback.
**
** If another function was previously registered, its pArg value is returned.
** Otherwise NULL is returned.
**
** Registering a NULL function disables the callback.
**
******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
*/
void *sqlite_commit_hook(sqlite*, int(*)(void*), void*);
/*
** Open an encrypted SQLite database. If pKey==0 or nKey==0, this routine
** is the same as sqlite_open().
**
** The code to implement this API is not available in the public release
** of SQLite.
*/
sqlite *sqlite_open_encrypted(
const char *zFilename, /* Name of the encrypted database */
const void *pKey, /* Pointer to the key */
int nKey, /* Number of bytes in the key */
int *pErrcode, /* Write error code here */
char **pzErrmsg /* Write error message here */
);
/*
** Change the key on an open database. If the current database is not
** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
** database is decrypted.
**
** The code to implement this API is not available in the public release
** of SQLite.
*/
int sqlite_rekey(
sqlite *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The new key */
);
/*
** Encode a binary buffer "in" of size n bytes so that it contains
** no instances of characters '\'' or '\000'. The output is
** null-terminated and can be used as a string value in an INSERT
** or UPDATE statement. Use sqlite_decode_binary() to convert the
** string back into its original binary.
**
** The result is written into a preallocated output buffer "out".
** "out" must be able to hold at least 2 +(257*n)/254 bytes.
** In other words, the output will be expanded by as much as 3
** bytes for every 254 bytes of input plus 2 bytes of fixed overhead.
** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.)
**
** The return value is the number of characters in the encoded
** string, excluding the "\000" terminator.
**
** If out==NULL then no output is generated but the routine still returns
** the number of characters that would have been generated if out had
** not been NULL.
*/
int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out);
/*
** Decode the string "in" into binary data and write it into "out".
** This routine reverses the encoding created by sqlite_encode_binary().
** The output will always be a few bytes less than the input. The number
** of bytes of output is returned. If the input is not a well-formed
** encoding, -1 is returned.
**
** The "in" and "out" parameters may point to the same buffer in order
** to decode a string in place.
*/
int sqlite_decode_binary(const unsigned char *in, unsigned char *out);
#ifdef __cplusplus
} /* End of the 'extern "C"' block */
+923 -129
View File
File diff suppressed because it is too large Load Diff
+26 -5
View File
@@ -17,7 +17,8 @@
** if they are not used.
*/
#include <stdlib.h>
#include "sqlite.h"
#include <string.h>
#include "sqliteInt.h"
/*
** This structure is used to pass data from sqlite_get_table() through
@@ -25,11 +26,12 @@
*/
typedef struct TabResult {
char **azResult;
char *zErrMsg;
int nResult;
int nAlloc;
int nRow;
int nColumn;
int nData;
long nData;
int rc;
} TabResult;
@@ -81,6 +83,12 @@ static int sqlite_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
}
p->azResult[p->nData++] = z;
}
}else if( p->nColumn!=nCol ){
sqliteSetString(&p->zErrMsg,
"sqlite_get_table() called with two or more incompatible queries",
(char*)0);
p->rc = SQLITE_ERROR;
return 1;
}
/* Copy over the row data
@@ -116,7 +124,7 @@ static int sqlite_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
*/
int sqlite_get_table(
sqlite *db, /* The database on which the SQL executes */
char *zSql, /* The SQL to be executed */
const char *zSql, /* The SQL to be executed */
char ***pazResult, /* Write the result table here */
int *pnRow, /* Write the number of rows in the result here */
int *pnColumn, /* Write the number of columns of result here */
@@ -128,6 +136,7 @@ int sqlite_get_table(
*pazResult = 0;
if( pnColumn ) *pnColumn = 0;
if( pnRow ) *pnRow = 0;
res.zErrMsg = 0;
res.nResult = 0;
res.nRow = 0;
res.nColumn = 0;
@@ -145,8 +154,18 @@ int sqlite_get_table(
}
if( rc==SQLITE_ABORT ){
sqlite_free_table(&res.azResult[1]);
if( res.zErrMsg ){
if( pzErrMsg ){
free(*pzErrMsg);
*pzErrMsg = res.zErrMsg;
sqliteStrRealloc(pzErrMsg);
}else{
sqliteFree(res.zErrMsg);
}
}
return res.rc;
}
sqliteFree(res.zErrMsg);
if( rc!=SQLITE_OK ){
sqlite_free_table(&res.azResult[1]);
return rc;
@@ -154,10 +173,11 @@ int sqlite_get_table(
if( res.nAlloc>res.nData ){
char **azNew;
azNew = realloc( res.azResult, sizeof(char*)*(res.nData+1) );
if( res.azResult==0 ){
if( azNew==0 ){
sqlite_free_table(&res.azResult[1]);
return SQLITE_NOMEM;
}
res.nAlloc = res.nData+1;
res.azResult = azNew;
}
*pazResult = &res.azResult[1];
@@ -175,7 +195,8 @@ void sqlite_free_table(
if( azResult ){
int i, n;
azResult--;
n = (int)azResult[0];
if( azResult==0 ) return;
n = (int)(long)azResult[0];
for(i=1; i<n; i++){ if( azResult[i] ) free(azResult[i]); }
free(azResult);
}
+715 -50
View File
@@ -11,14 +11,15 @@
*************************************************************************
** A TCL Interface to SQLite
**
** $Id: tclsqlite.c,v 1.27 2001/10/22 02:58:10 drh Exp $
** $Id: tclsqlite.c,v 1.59.2.1 2004/06/19 11:57:40 drh Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
#include "sqlite.h"
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
/*
** If TCL uses UTF-8 and SQLite is configured to use iso8859, then we
@@ -30,6 +31,17 @@
# define UTF_TRANSLATION_NEEDED 1
#endif
/*
** New SQL functions can be created as TCL scripts. Each such function
** is described by an instance of the following structure.
*/
typedef struct SqlFunc SqlFunc;
struct SqlFunc {
Tcl_Interp *interp; /* The TCL interpret to execute the function */
char *zScript; /* The script to be run */
SqlFunc *pNext; /* Next function on the list of them all */
};
/*
** There is one instance of this structure for each SQLite database
** that has been opened by the SQLite TCL interface.
@@ -39,6 +51,12 @@ struct SqliteDb {
sqlite *db; /* The "real" database structure */
Tcl_Interp *interp; /* The interpreter used for this database */
char *zBusy; /* The busy callback routine */
char *zCommit; /* The commit hook callback routine */
char *zTrace; /* The trace callback routine */
char *zProgress; /* The progress callback routine */
char *zAuth; /* The authorization callback routine */
SqlFunc *pFunc; /* List of SQL functions */
int rc; /* Return code of most recent sqlite_exec() */
};
/*
@@ -50,7 +68,7 @@ struct CallbackData {
Tcl_Interp *interp; /* The TCL interpreter */
char *zArray; /* The array into which data is written */
Tcl_Obj *pCode; /* The code to execute for each row */
int once; /* Set only for the first invocation of callback */
int once; /* Set for first callback only */
int tcl_rc; /* Return code from TCL script */
int nColName; /* Number of entries in the azColName[] array */
char **azColName; /* Column names translated to UTF-8 */
@@ -74,26 +92,42 @@ static int DbEvalCallback(
int i, rc;
Tcl_DString dCol;
Tcl_DStringInit(&dCol);
if( azCol==0 || (cbData->once && cbData->zArray[0]) ){
Tcl_SetVar2(cbData->interp, cbData->zArray, "*", "", 0);
if( azCol ){
cbData->azColName = malloc( nCol*sizeof(char*) );
if( cbData->azColName==0 ){ return 1; }
if( cbData->azColName==0 ){
assert( cbData->once );
cbData->once = 0;
if( cbData->zArray[0] ){
Tcl_SetVar2(cbData->interp, cbData->zArray, "*", "", 0);
}
cbData->azColName = malloc( nCol*sizeof(char*) );
if( cbData->azColName==0 ){ return 1; }
cbData->nColName = nCol;
for(i=0; i<nCol; i++){
Tcl_ExternalToUtfDString(NULL, azN[i], -1, &dCol);
if( azCol ){
cbData->azColName[i] = malloc( Tcl_DStringLength(&dCol) + 1);
if( cbData->azColName[i] ){
strcpy(cbData->azColName[i], Tcl_DStringValue(&dCol));
cbData->azColName[i] = malloc( Tcl_DStringLength(&dCol) + 1 );
if( cbData->azColName[i] ){
strcpy(cbData->azColName[i], Tcl_DStringValue(&dCol));
}else{
return 1;
}
if( cbData->zArray[0] ){
Tcl_SetVar2(cbData->interp, cbData->zArray, "*",
Tcl_DStringValue(&dCol), TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
if( azN[nCol]!=0 ){
Tcl_DString dType;
Tcl_DStringInit(&dType);
Tcl_DStringAppend(&dType, "typeof:", -1);
Tcl_DStringAppend(&dType, Tcl_DStringValue(&dCol), -1);
Tcl_DStringFree(&dCol);
Tcl_ExternalToUtfDString(NULL, azN[i+nCol], -1, &dCol);
Tcl_SetVar2(cbData->interp, cbData->zArray,
Tcl_DStringValue(&dType), Tcl_DStringValue(&dCol),
TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
Tcl_DStringFree(&dType);
}
}
Tcl_SetVar2(cbData->interp, cbData->zArray, "*", Tcl_DStringValue(&dCol),
TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
Tcl_DStringFree(&dCol);
}
cbData->once = 0;
}
if( azCol!=0 ){
if( cbData->zArray[0] ){
@@ -150,6 +184,12 @@ static int DbEvalCallback(
for(i=0; i<nCol; i++){
Tcl_SetVar2(cbData->interp, cbData->zArray, "*", azN[i],
TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
if( azN[nCol] ){
char *z = sqlite_mprintf("typeof:%s", azN[i]);
Tcl_SetVar2(cbData->interp, cbData->zArray, z, azN[i+nCol],
TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
sqlite_freemem(z);
}
}
cbData->once = 0;
}
@@ -210,15 +250,55 @@ static int DbEvalCallback2(
return 0;
}
/*
** This is a second alternative callback for database queries. A the
** first column of the first row of the result is made the TCL result.
*/
static int DbEvalCallback3(
void *clientData, /* An instance of CallbackData */
int nCol, /* Number of columns in the result */
char ** azCol, /* Data for each column */
char ** azN /* Name for each column */
){
Tcl_Interp *interp = (Tcl_Interp*)clientData;
Tcl_Obj *pElem;
if( azCol==0 ) return 1;
if( nCol==0 ) return 1;
#ifdef UTF_TRANSLATION_NEEDED
{
Tcl_DString dCol;
Tcl_DStringInit(&dCol);
Tcl_ExternalToUtfDString(NULL, azCol[0], -1, &dCol);
pElem = Tcl_NewStringObj(Tcl_DStringValue(&dCol), -1);
Tcl_DStringFree(&dCol);
}
#else
pElem = Tcl_NewStringObj(azCol[0], -1);
#endif
Tcl_SetObjResult(interp, pElem);
return 1;
}
/*
** Called when the command is deleted.
*/
static void DbDeleteCmd(void *db){
SqliteDb *pDb = (SqliteDb*)db;
sqlite_close(pDb->db);
while( pDb->pFunc ){
SqlFunc *pFunc = pDb->pFunc;
pDb->pFunc = pFunc->pNext;
Tcl_Free((char*)pFunc);
}
if( pDb->zBusy ){
Tcl_Free(pDb->zBusy);
}
if( pDb->zTrace ){
Tcl_Free(pDb->zTrace);
}
if( pDb->zAuth ){
Tcl_Free(pDb->zAuth);
}
Tcl_Free((char*)pDb);
}
@@ -247,6 +327,149 @@ static int DbBusyHandler(void *cd, const char *zTable, int nTries){
return 1;
}
/*
** This routine is invoked as the 'progress callback' for the database.
*/
static int DbProgressHandler(void *cd){
SqliteDb *pDb = (SqliteDb*)cd;
int rc;
assert( pDb->zProgress );
rc = Tcl_Eval(pDb->interp, pDb->zProgress);
if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){
return 1;
}
return 0;
}
/*
** This routine is called by the SQLite trace handler whenever a new
** block of SQL is executed. The TCL script in pDb->zTrace is executed.
*/
static void DbTraceHandler(void *cd, const char *zSql){
SqliteDb *pDb = (SqliteDb*)cd;
Tcl_DString str;
Tcl_DStringInit(&str);
Tcl_DStringAppend(&str, pDb->zTrace, -1);
Tcl_DStringAppendElement(&str, zSql);
Tcl_Eval(pDb->interp, Tcl_DStringValue(&str));
Tcl_DStringFree(&str);
Tcl_ResetResult(pDb->interp);
}
/*
** This routine is called when a transaction is committed. The
** TCL script in pDb->zCommit is executed. If it returns non-zero or
** if it throws an exception, the transaction is rolled back instead
** of being committed.
*/
static int DbCommitHandler(void *cd){
SqliteDb *pDb = (SqliteDb*)cd;
int rc;
rc = Tcl_Eval(pDb->interp, pDb->zCommit);
if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){
return 1;
}
return 0;
}
/*
** This routine is called to evaluate an SQL function implemented
** using TCL script.
*/
static void tclSqlFunc(sqlite_func *context, int argc, const char **argv){
SqlFunc *p = sqlite_user_data(context);
Tcl_DString cmd;
int i;
int rc;
Tcl_DStringInit(&cmd);
Tcl_DStringAppend(&cmd, p->zScript, -1);
for(i=0; i<argc; i++){
Tcl_DStringAppendElement(&cmd, argv[i] ? argv[i] : "");
}
rc = Tcl_Eval(p->interp, Tcl_DStringValue(&cmd));
if( rc ){
sqlite_set_result_error(context, Tcl_GetStringResult(p->interp), -1);
}else{
sqlite_set_result_string(context, Tcl_GetStringResult(p->interp), -1);
}
}
#ifndef SQLITE_OMIT_AUTHORIZATION
/*
** This is the authentication function. It appends the authentication
** type code and the two arguments to zCmd[] then invokes the result
** on the interpreter. The reply is examined to determine if the
** authentication fails or succeeds.
*/
static int auth_callback(
void *pArg,
int code,
const char *zArg1,
const char *zArg2,
const char *zArg3,
const char *zArg4
){
char *zCode;
Tcl_DString str;
int rc;
const char *zReply;
SqliteDb *pDb = (SqliteDb*)pArg;
switch( code ){
case SQLITE_COPY : zCode="SQLITE_COPY"; break;
case SQLITE_CREATE_INDEX : zCode="SQLITE_CREATE_INDEX"; break;
case SQLITE_CREATE_TABLE : zCode="SQLITE_CREATE_TABLE"; break;
case SQLITE_CREATE_TEMP_INDEX : zCode="SQLITE_CREATE_TEMP_INDEX"; break;
case SQLITE_CREATE_TEMP_TABLE : zCode="SQLITE_CREATE_TEMP_TABLE"; break;
case SQLITE_CREATE_TEMP_TRIGGER: zCode="SQLITE_CREATE_TEMP_TRIGGER"; break;
case SQLITE_CREATE_TEMP_VIEW : zCode="SQLITE_CREATE_TEMP_VIEW"; break;
case SQLITE_CREATE_TRIGGER : zCode="SQLITE_CREATE_TRIGGER"; break;
case SQLITE_CREATE_VIEW : zCode="SQLITE_CREATE_VIEW"; break;
case SQLITE_DELETE : zCode="SQLITE_DELETE"; break;
case SQLITE_DROP_INDEX : zCode="SQLITE_DROP_INDEX"; break;
case SQLITE_DROP_TABLE : zCode="SQLITE_DROP_TABLE"; break;
case SQLITE_DROP_TEMP_INDEX : zCode="SQLITE_DROP_TEMP_INDEX"; break;
case SQLITE_DROP_TEMP_TABLE : zCode="SQLITE_DROP_TEMP_TABLE"; break;
case SQLITE_DROP_TEMP_TRIGGER : zCode="SQLITE_DROP_TEMP_TRIGGER"; break;
case SQLITE_DROP_TEMP_VIEW : zCode="SQLITE_DROP_TEMP_VIEW"; break;
case SQLITE_DROP_TRIGGER : zCode="SQLITE_DROP_TRIGGER"; break;
case SQLITE_DROP_VIEW : zCode="SQLITE_DROP_VIEW"; break;
case SQLITE_INSERT : zCode="SQLITE_INSERT"; break;
case SQLITE_PRAGMA : zCode="SQLITE_PRAGMA"; break;
case SQLITE_READ : zCode="SQLITE_READ"; break;
case SQLITE_SELECT : zCode="SQLITE_SELECT"; break;
case SQLITE_TRANSACTION : zCode="SQLITE_TRANSACTION"; break;
case SQLITE_UPDATE : zCode="SQLITE_UPDATE"; break;
case SQLITE_ATTACH : zCode="SQLITE_ATTACH"; break;
case SQLITE_DETACH : zCode="SQLITE_DETACH"; break;
default : zCode="????"; break;
}
Tcl_DStringInit(&str);
Tcl_DStringAppend(&str, pDb->zAuth, -1);
Tcl_DStringAppendElement(&str, zCode);
Tcl_DStringAppendElement(&str, zArg1 ? zArg1 : "");
Tcl_DStringAppendElement(&str, zArg2 ? zArg2 : "");
Tcl_DStringAppendElement(&str, zArg3 ? zArg3 : "");
Tcl_DStringAppendElement(&str, zArg4 ? zArg4 : "");
rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str));
Tcl_DStringFree(&str);
zReply = Tcl_GetStringResult(pDb->interp);
if( strcmp(zReply,"SQLITE_OK")==0 ){
rc = SQLITE_OK;
}else if( strcmp(zReply,"SQLITE_DENY")==0 ){
rc = SQLITE_DENY;
}else if( strcmp(zReply,"SQLITE_IGNORE")==0 ){
rc = SQLITE_IGNORE;
}else{
rc = 999;
}
return rc;
}
#endif /* SQLITE_OMIT_AUTHORIZATION */
/*
** The "sqlite" command below creates a new Tcl command for each
** connection it opens to an SQLite database. This routine is invoked
@@ -263,22 +486,84 @@ static int DbBusyHandler(void *cd, const char *zTable, int nTries){
static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
SqliteDb *pDb = (SqliteDb*)cd;
int choice;
static char *DB_optStrs[] = {
"busy", "close", "complete", "eval", "timeout", 0
int rc = TCL_OK;
static const char *DB_strs[] = {
"authorizer", "busy", "changes",
"close", "commit_hook", "complete",
"errorcode", "eval", "function",
"last_insert_rowid", "last_statement_changes", "onecolumn",
"progress", "rekey", "timeout",
"trace",
0
};
enum DB_opts {
DB_BUSY, DB_CLOSE, DB_COMPLETE, DB_EVAL, DB_TIMEOUT
enum DB_enum {
DB_AUTHORIZER, DB_BUSY, DB_CHANGES,
DB_CLOSE, DB_COMMIT_HOOK, DB_COMPLETE,
DB_ERRORCODE, DB_EVAL, DB_FUNCTION,
DB_LAST_INSERT_ROWID, DB_LAST_STATEMENT_CHANGES, DB_ONECOLUMN,
DB_PROGRESS, DB_REKEY, DB_TIMEOUT,
DB_TRACE
};
if( objc<2 ){
Tcl_WrongNumArgs(interp, 1, objv, "SUBCOMMAND ...");
return TCL_ERROR;
}
if( Tcl_GetIndexFromObj(interp, objv[1], DB_optStrs, "option", 0, &choice) ){
if( Tcl_GetIndexFromObj(interp, objv[1], DB_strs, "option", 0, &choice) ){
return TCL_ERROR;
}
switch( (enum DB_opts)choice ){
switch( (enum DB_enum)choice ){
/* $db authorizer ?CALLBACK?
**
** Invoke the given callback to authorize each SQL operation as it is
** compiled. 5 arguments are appended to the callback before it is
** invoked:
**
** (1) The authorization type (ex: SQLITE_CREATE_TABLE, SQLITE_INSERT, ...)
** (2) First descriptive name (depends on authorization type)
** (3) Second descriptive name
** (4) Name of the database (ex: "main", "temp")
** (5) Name of trigger that is doing the access
**
** The callback should return on of the following strings: SQLITE_OK,
** SQLITE_IGNORE, or SQLITE_DENY. Any other return value is an error.
**
** If this method is invoked with no arguments, the current authorization
** callback string is returned.
*/
case DB_AUTHORIZER: {
if( objc>3 ){
Tcl_WrongNumArgs(interp, 2, objv, "?CALLBACK?");
}else if( objc==2 ){
if( pDb->zAuth ){
Tcl_AppendResult(interp, pDb->zAuth, 0);
}
}else{
char *zAuth;
int len;
if( pDb->zAuth ){
Tcl_Free(pDb->zAuth);
}
zAuth = Tcl_GetStringFromObj(objv[2], &len);
if( zAuth && len>0 ){
pDb->zAuth = Tcl_Alloc( len + 1 );
strcpy(pDb->zAuth, zAuth);
}else{
pDb->zAuth = 0;
}
#ifndef SQLITE_OMIT_AUTHORIZATION
if( pDb->zAuth ){
pDb->interp = interp;
sqlite_set_authorizer(pDb->db, auth_callback, pDb);
}else{
sqlite_set_authorizer(pDb->db, 0, 0);
}
#endif
}
break;
}
/* $db busy ?CALLBACK?
**
@@ -316,6 +601,87 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
break;
}
/* $db progress ?N CALLBACK?
**
** Invoke the given callback every N virtual machine opcodes while executing
** queries.
*/
case DB_PROGRESS: {
if( objc==2 ){
if( pDb->zProgress ){
Tcl_AppendResult(interp, pDb->zProgress, 0);
}
}else if( objc==4 ){
char *zProgress;
int len;
int N;
if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &N) ){
return TCL_ERROR;
};
if( pDb->zProgress ){
Tcl_Free(pDb->zProgress);
}
zProgress = Tcl_GetStringFromObj(objv[3], &len);
if( zProgress && len>0 ){
pDb->zProgress = Tcl_Alloc( len + 1 );
strcpy(pDb->zProgress, zProgress);
}else{
pDb->zProgress = 0;
}
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
if( pDb->zProgress ){
pDb->interp = interp;
sqlite_progress_handler(pDb->db, N, DbProgressHandler, pDb);
}else{
sqlite_progress_handler(pDb->db, 0, 0, 0);
}
#endif
}else{
Tcl_WrongNumArgs(interp, 2, objv, "N CALLBACK");
return TCL_ERROR;
}
break;
}
/*
** $db changes
**
** Return the number of rows that were modified, inserted, or deleted by
** the most recent "eval".
*/
case DB_CHANGES: {
Tcl_Obj *pResult;
int nChange;
if( objc!=2 ){
Tcl_WrongNumArgs(interp, 2, objv, "");
return TCL_ERROR;
}
nChange = sqlite_changes(pDb->db);
pResult = Tcl_GetObjResult(interp);
Tcl_SetIntObj(pResult, nChange);
break;
}
/*
** $db last_statement_changes
**
** Return the number of rows that were modified, inserted, or deleted by
** the last statment to complete execution (excluding changes due to
** triggers)
*/
case DB_LAST_STATEMENT_CHANGES: {
Tcl_Obj *pResult;
int lsChange;
if( objc!=2 ){
Tcl_WrongNumArgs(interp, 2, objv, "");
return TCL_ERROR;
}
lsChange = sqlite_last_statement_changes(pDb->db);
pResult = Tcl_GetObjResult(interp);
Tcl_SetIntObj(pResult, lsChange);
break;
}
/* $db close
**
** Shutdown the database
@@ -325,6 +691,43 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
break;
}
/* $db commit_hook ?CALLBACK?
**
** Invoke the given callback just before committing every SQL transaction.
** If the callback throws an exception or returns non-zero, then the
** transaction is aborted. If CALLBACK is an empty string, the callback
** is disabled.
*/
case DB_COMMIT_HOOK: {
if( objc>3 ){
Tcl_WrongNumArgs(interp, 2, objv, "?CALLBACK?");
}else if( objc==2 ){
if( pDb->zCommit ){
Tcl_AppendResult(interp, pDb->zCommit, 0);
}
}else{
char *zCommit;
int len;
if( pDb->zCommit ){
Tcl_Free(pDb->zCommit);
}
zCommit = Tcl_GetStringFromObj(objv[2], &len);
if( zCommit && len>0 ){
pDb->zCommit = Tcl_Alloc( len + 1 );
strcpy(pDb->zCommit, zCommit);
}else{
pDb->zCommit = 0;
}
if( pDb->zCommit ){
pDb->interp = interp;
sqlite_commit_hook(pDb->db, DbCommitHandler, pDb);
}else{
sqlite_commit_hook(pDb->db, 0, 0);
}
}
break;
}
/* $db complete SQL
**
** Return TRUE if SQL is a complete SQL statement. Return FALSE if
@@ -343,6 +746,17 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
Tcl_SetBooleanObj(pResult, isComplete);
break;
}
/*
** $db errorcode
**
** Return the numeric error code that was returned by the most recent
** call to sqlite_exec().
*/
case DB_ERRORCODE: {
Tcl_SetObjResult(interp, Tcl_NewIntObj(pDb->rc));
break;
}
/*
** $db eval $sql ?array { ...code... }?
@@ -357,7 +771,6 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
CallbackData cbData;
char *zErrMsg;
char *zSql;
int rc;
#ifdef UTF_TRANSLATION_NEEDED
Tcl_DString dSql;
int i;
@@ -396,15 +809,18 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
rc = sqlite_exec(pDb->db, zSql, DbEvalCallback2, pList, &zErrMsg);
Tcl_SetObjResult(interp, pList);
}
if( zErrMsg ){
pDb->rc = rc;
if( rc==SQLITE_ABORT ){
if( zErrMsg ) free(zErrMsg);
rc = cbData.tcl_rc;
}else if( zErrMsg ){
Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);
free(zErrMsg);
rc = TCL_ERROR;
}else if( rc!=SQLITE_OK && rc!=SQLITE_ABORT ){
}else if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, sqlite_error_string(rc), 0);
rc = TCL_ERROR;
}else{
rc = cbData.tcl_rc;
}
Tcl_DecrRefCount(objv[2]);
#ifdef UTF_TRANSLATION_NEEDED
@@ -414,11 +830,108 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
if( cbData.azColName[i] ) free(cbData.azColName[i]);
}
free(cbData.azColName);
cbData.azColName = 0;
}
#endif
return rc;
}
/*
** $db function NAME SCRIPT
**
** Create a new SQL function called NAME. Whenever that function is
** called, invoke SCRIPT to evaluate the function.
*/
case DB_FUNCTION: {
SqlFunc *pFunc;
char *zName;
char *zScript;
int nScript;
if( objc!=4 ){
Tcl_WrongNumArgs(interp, 2, objv, "NAME SCRIPT");
return TCL_ERROR;
}
zName = Tcl_GetStringFromObj(objv[2], 0);
zScript = Tcl_GetStringFromObj(objv[3], &nScript);
pFunc = (SqlFunc*)Tcl_Alloc( sizeof(*pFunc) + nScript + 1 );
if( pFunc==0 ) return TCL_ERROR;
pFunc->interp = interp;
pFunc->pNext = pDb->pFunc;
pFunc->zScript = (char*)&pFunc[1];
strcpy(pFunc->zScript, zScript);
sqlite_create_function(pDb->db, zName, -1, tclSqlFunc, pFunc);
sqlite_function_type(pDb->db, zName, SQLITE_NUMERIC);
break;
}
/*
** $db last_insert_rowid
**
** Return an integer which is the ROWID for the most recent insert.
*/
case DB_LAST_INSERT_ROWID: {
Tcl_Obj *pResult;
int rowid;
if( objc!=2 ){
Tcl_WrongNumArgs(interp, 2, objv, "");
return TCL_ERROR;
}
rowid = sqlite_last_insert_rowid(pDb->db);
pResult = Tcl_GetObjResult(interp);
Tcl_SetIntObj(pResult, rowid);
break;
}
/*
** $db onecolumn SQL
**
** Return a single column from a single row of the given SQL query.
*/
case DB_ONECOLUMN: {
char *zSql;
char *zErrMsg = 0;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 2, objv, "SQL");
return TCL_ERROR;
}
zSql = Tcl_GetStringFromObj(objv[2], 0);
rc = sqlite_exec(pDb->db, zSql, DbEvalCallback3, interp, &zErrMsg);
if( rc==SQLITE_ABORT ){
rc = SQLITE_OK;
}else if( zErrMsg ){
Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);
free(zErrMsg);
rc = TCL_ERROR;
}else if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, sqlite_error_string(rc), 0);
rc = TCL_ERROR;
}
break;
}
/*
** $db rekey KEY
**
** Change the encryption key on the currently open database.
*/
case DB_REKEY: {
int nKey;
void *pKey;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 2, objv, "KEY");
return TCL_ERROR;
}
pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey);
#ifdef SQLITE_HAS_CODEC
rc = sqlite_rekey(pDb->db, pKey, nKey);
if( rc ){
Tcl_AppendResult(interp, sqlite_error_string(rc), 0);
rc = TCL_ERROR;
}
#endif
break;
}
/*
** $db timeout MILLESECONDS
**
@@ -434,12 +947,49 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
sqlite_busy_timeout(pDb->db, ms);
break;
}
/* $db trace ?CALLBACK?
**
** Make arrangements to invoke the CALLBACK routine for each SQL statement
** that is executed. The text of the SQL is appended to CALLBACK before
** it is executed.
*/
case DB_TRACE: {
if( objc>3 ){
Tcl_WrongNumArgs(interp, 2, objv, "?CALLBACK?");
}else if( objc==2 ){
if( pDb->zTrace ){
Tcl_AppendResult(interp, pDb->zTrace, 0);
}
}else{
char *zTrace;
int len;
if( pDb->zTrace ){
Tcl_Free(pDb->zTrace);
}
zTrace = Tcl_GetStringFromObj(objv[2], &len);
if( zTrace && len>0 ){
pDb->zTrace = Tcl_Alloc( len + 1 );
strcpy(pDb->zTrace, zTrace);
}else{
pDb->zTrace = 0;
}
if( pDb->zTrace ){
pDb->interp = interp;
sqlite_trace(pDb->db, DbTraceHandler, pDb);
}else{
sqlite_trace(pDb->db, 0, 0);
}
}
break;
}
} /* End of the SWITCH statement */
return TCL_OK;
return rc;
}
/*
** sqlite DBNAME FILENAME ?MODE?
** sqlite DBNAME FILENAME ?MODE? ?-key KEY?
**
** This is the main Tcl command. When the "sqlite" Tcl command is
** invoked, this routine runs to process that command.
@@ -459,22 +1009,44 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
** Return the encoding used by LIKE and GLOB operators. Choices
** are UTF-8 and iso8859.
**
** sqlite -version
**
** Return the version number of the SQLite library.
**
** sqlite -tcl-uses-utf
**
** Return "1" if compiled with a Tcl uses UTF-8. Return "0" if
** not. Used by tests to make sure the library was compiled
** correctly.
*/
static int DbMain(void *cd, Tcl_Interp *interp, int argc, char **argv){
static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
int mode;
SqliteDb *p;
void *pKey = 0;
int nKey = 0;
const char *zArg;
char *zErrMsg;
if( argc==2 ){
if( strcmp(argv[1],"-encoding")==0 ){
const char *zFile;
char zBuf[80];
if( objc==2 ){
zArg = Tcl_GetStringFromObj(objv[1], 0);
if( strcmp(zArg,"-encoding")==0 ){
Tcl_AppendResult(interp,sqlite_encoding,0);
return TCL_OK;
}
if( strcmp(argv[1],"-tcl-uses-utf")==0 ){
if( strcmp(zArg,"-version")==0 ){
Tcl_AppendResult(interp,sqlite_version,0);
return TCL_OK;
}
if( strcmp(zArg,"-has-codec")==0 ){
#ifdef SQLITE_HAS_CODEC
Tcl_AppendResult(interp,"1",0);
#else
Tcl_AppendResult(interp,"0",0);
#endif
return TCL_OK;
}
if( strcmp(zArg,"-tcl-uses-utf")==0 ){
#ifdef TCL_UTF_MAX
Tcl_AppendResult(interp,"1",0);
#else
@@ -483,14 +1055,26 @@ static int DbMain(void *cd, Tcl_Interp *interp, int argc, char **argv){
return TCL_OK;
}
}
if( argc!=3 && argc!=4 ){
Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0],
" HANDLE FILENAME ?MODE?\"", 0);
if( objc==5 || objc==6 ){
zArg = Tcl_GetStringFromObj(objv[objc-2], 0);
if( strcmp(zArg,"-key")==0 ){
pKey = Tcl_GetByteArrayFromObj(objv[objc-1], &nKey);
objc -= 2;
}
}
if( objc!=3 && objc!=4 ){
Tcl_WrongNumArgs(interp, 1, objv,
#ifdef SQLITE_HAS_CODEC
"HANDLE FILENAME ?-key CODEC-KEY?"
#else
"HANDLE FILENAME ?MODE?"
#endif
);
return TCL_ERROR;
}
if( argc==3 ){
if( objc==3 ){
mode = 0666;
}else if( Tcl_GetInt(interp, argv[3], &mode)!=TCL_OK ){
}else if( Tcl_GetIntFromObj(interp, objv[3], &mode)!=TCL_OK ){
return TCL_ERROR;
}
zErrMsg = 0;
@@ -500,14 +1084,38 @@ static int DbMain(void *cd, Tcl_Interp *interp, int argc, char **argv){
return TCL_ERROR;
}
memset(p, 0, sizeof(*p));
p->db = sqlite_open(argv[2], mode, &zErrMsg);
zFile = Tcl_GetStringFromObj(objv[2], 0);
#ifdef SQLITE_HAS_CODEC
p->db = sqlite_open_encrypted(zFile, pKey, nKey, 0, &zErrMsg);
#else
p->db = sqlite_open(zFile, mode, &zErrMsg);
#endif
if( p->db==0 ){
Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);
Tcl_Free((char*)p);
free(zErrMsg);
return TCL_ERROR;
}
Tcl_CreateObjCommand(interp, argv[1], DbObjCmd, (char*)p, DbDeleteCmd);
zArg = Tcl_GetStringFromObj(objv[1], 0);
Tcl_CreateObjCommand(interp, zArg, DbObjCmd, (char*)p, DbDeleteCmd);
/* The return value is the value of the sqlite* pointer
*/
sprintf(zBuf, "%p", p->db);
if( strncmp(zBuf,"0x",2) ){
sprintf(zBuf, "0x%p", p->db);
}
Tcl_AppendResult(interp, zBuf, 0);
/* If compiled with SQLITE_TEST turned on, then register the "md5sum"
** SQL function.
*/
#ifdef SQLITE_TEST
{
extern void Md5_Register(sqlite*);
Md5_Register(p->db);
}
#endif
return TCL_OK;
}
@@ -531,13 +1139,13 @@ static int DbMain(void *cd, Tcl_Interp *interp, int argc, char **argv){
*/
int Sqlite_Init(Tcl_Interp *interp){
Tcl_InitStubs(interp, "8.0", 0);
Tcl_CreateCommand(interp, "sqlite", DbMain, 0, 0);
Tcl_CreateObjCommand(interp, "sqlite", (Tcl_ObjCmdProc*)DbMain, 0, 0);
Tcl_PkgProvide(interp, "sqlite", "2.0");
return TCL_OK;
}
int Tclsqlite_Init(Tcl_Interp *interp){
Tcl_InitStubs(interp, "8.0", 0);
Tcl_CreateCommand(interp, "sqlite", DbMain, 0, 0);
Tcl_CreateObjCommand(interp, "sqlite", (Tcl_ObjCmdProc*)DbMain, 0, 0);
Tcl_PkgProvide(interp, "sqlite", "2.0");
return TCL_OK;
}
@@ -557,12 +1165,18 @@ int Et_AppInit(Tcl_Interp *interp){
return Sqlite_Init(interp);
}
#endif
/***************************************************************************
** The remaining code is only included if the TCLSH macro is defined to
** be an integer greater than 0
*/
#if defined(TCLSH) && TCLSH>0
/*
** If the macro TCLSH is defined and is one, then put in code for the
** "main" routine that will initialize Tcl.
** "main" routine that implement a interactive shell into which the user
** can type TCL commands.
*/
#if defined(TCLSH) && TCLSH==1
#if TCLSH==1
static char zMainloop[] =
"set line {}\n"
"while {![eof stdin]} {\n"
@@ -585,12 +1199,14 @@ static char zMainloop[] =
"}\n"
"}\n"
;
#endif /* TCLSH==1 */
#define TCLSH_MAIN main /* Needed to fake out mktclapp */
int TCLSH_MAIN(int argc, char **argv){
Tcl_Interp *interp;
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
int Libsqlite_Init( Tcl_Interp *interp) {
#ifdef TCL_THREADS
if (Thread_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#endif
Sqlite_Init(interp);
#ifdef SQLITE_TEST
{
@@ -602,8 +1218,20 @@ int TCLSH_MAIN(int argc, char **argv){
Sqlitetest2_Init(interp);
Sqlitetest3_Init(interp);
Md5_Init(interp);
Tcl_StaticPackage(interp, "sqlite", Libsqlite_Init, Libsqlite_Init);
}
#endif
return TCL_OK;
}
#define TCLSH_MAIN main /* Needed to fake out mktclapp */
#if TCLSH==1
int TCLSH_MAIN(int argc, char **argv){
#ifndef TCL_THREADS
Tcl_Interp *interp;
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
Libsqlite_Init(interp);
if( argc>=2 ){
int i;
Tcl_SetVar(interp,"argv0",argv[1],TCL_GLOBAL_ONLY);
@@ -613,16 +1241,53 @@ int TCLSH_MAIN(int argc, char **argv){
TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT | TCL_APPEND_VALUE);
}
if( Tcl_EvalFile(interp, argv[1])!=TCL_OK ){
char *zInfo = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
const char *zInfo = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
if( zInfo==0 ) zInfo = interp->result;
fprintf(stderr,"%s: %s\n", *argv, zInfo);
return 1;
return TCL_ERROR;
}
}else{
Tcl_GlobalEval(interp, zMainloop);
}
return 0;
#else
Tcl_Main(argc, argv, Libsqlite_Init);
#endif /* TCL_THREADS */
return 0;
}
#endif /* TCLSH==1 */
/*
** If the macro TCLSH is set to 2, then implement a space analysis tool.
*/
#if TCLSH==2
static char zAnalysis[] =
#include "spaceanal_tcl.h"
;
int main(int argc, char **argv){
Tcl_Interp *interp;
int i;
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
Libsqlite_Init(interp);
Tcl_SetVar(interp,"argv0",argv[0],TCL_GLOBAL_ONLY);
Tcl_SetVar(interp,"argv", "", TCL_GLOBAL_ONLY);
for(i=1; i<argc; i++){
Tcl_SetVar(interp, "argv", argv[i],
TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT | TCL_APPEND_VALUE);
}
if( Tcl_GlobalEval(interp, zAnalysis)!=TCL_OK ){
const char *zInfo = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
if( zInfo==0 ) zInfo = interp->result;
fprintf(stderr,"%s: %s\n", *argv, zInfo);
return TCL_ERROR;
}
return 0;
}
#endif /* TCLSH==2 */
#endif /* TCLSH */
#endif /* !defined(NO_TCL) */
#endif /* NO_TCL */
+729 -21
View File
@@ -13,13 +13,74 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.4 2001/09/24 03:12:40 drh Exp $
** $Id: test1.c,v 1.36.2.1 2004/05/07 00:57:06 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>
#if OS_WIN
# define PTR_FMT "%x"
#else
# define PTR_FMT "%p"
#endif
/*
** Decode a pointer to an sqlite object.
*/
static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite **ppDb){
if( sscanf(zA, PTR_FMT, (void**)ppDb)!=1 &&
(zA[0]!='0' || zA[1]!='x' || sscanf(&zA[2], PTR_FMT, (void**)ppDb)!=1)
){
Tcl_AppendResult(interp, "\"", zA, "\" is not a valid pointer value", 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Decode a pointer to an sqlite_vm object.
*/
static int getVmPointer(Tcl_Interp *interp, const char *zArg, sqlite_vm **ppVm){
if( sscanf(zArg, PTR_FMT, (void**)ppVm)!=1 ){
Tcl_AppendResult(interp, "\"", zArg, "\" is not a valid pointer value", 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Generate a text representation of a pointer that can be understood
** by the getDbPointer and getVmPointer routines above.
**
** The problem is, on some machines (Solaris) if you do a printf with
** "%p" you cannot turn around and do a scanf with the same "%p" and
** get your pointer back. You have to prepend a "0x" before it will
** work. Or at least that is what is reported to me (drh). But this
** behavior varies from machine to machine. The solution used her is
** to test the string right after it is generated to see if it can be
** understood by scanf, and if not, try prepending an "0x" to see if
** that helps. If nothing works, a fatal error is generated.
*/
static int makePointerStr(Tcl_Interp *interp, char *zPtr, void *p){
void *p2;
sprintf(zPtr, PTR_FMT, p);
if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
sprintf(zPtr, "0x" PTR_FMT, p);
if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
Tcl_AppendResult(interp, "unable to convert a pointer to a string "
"in the file " __FILE__ " in function makePointerStr(). Please "
"report this problem to the SQLite mailing list or as a new but "
"report. Please provide detailed information about how you compiled "
"SQLite and what computer you are running on.", 0);
return TCL_ERROR;
}
}
return TCL_OK;
}
/*
** Usage: sqlite_open filename
**
@@ -45,7 +106,7 @@ static int sqlite_test_open(
free(zErr);
return TCL_ERROR;
}
sprintf(zBuf,"%d",(int)db);
if( makePointerStr(interp, zBuf, db) ) return TCL_ERROR;
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@@ -91,7 +152,7 @@ static int test_exec_printf(
" DB FORMAT STRING", 0);
return TCL_ERROR;
}
db = (sqlite*)atoi(argv[1]);
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
Tcl_DStringInit(&str);
rc = sqlite_exec_printf(db, argv[2], exec_printf_cb, &str, &zErr, argv[3]);
sprintf(zBuf, "%d", rc);
@@ -102,6 +163,30 @@ static int test_exec_printf(
return TCL_OK;
}
/*
** Usage: sqlite_mprintf_z_test SEPARATOR ARG0 ARG1 ...
**
** Test the %z format of mprintf(). Use multiple mprintf() calls to
** concatenate arg0 through argn using separator as the separator.
** Return the result.
*/
static int test_mprintf_z(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
char *zResult = 0;
int i;
for(i=2; i<argc; i++){
zResult = sqliteMPrintf("%z%s%s", zResult, argv[1], argv[i]);
}
Tcl_AppendResult(interp, zResult, 0);
sqliteFree(zResult);
return TCL_OK;
}
/*
** Usage: sqlite_get_table_printf DB FORMAT STRING
**
@@ -128,7 +213,7 @@ static int test_get_table_printf(
" DB FORMAT STRING", 0);
return TCL_ERROR;
}
db = (sqlite*)atoi(argv[1]);
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
Tcl_DStringInit(&str);
rc = sqlite_get_table_printf(db, argv[2], &aResult, &nRow, &nCol,
&zErr, argv[3]);
@@ -150,6 +235,31 @@ static int test_get_table_printf(
return TCL_OK;
}
/*
** Usage: sqlite_last_insert_rowid DB
**
** Returns the integer ROWID of the most recent insert.
*/
static int test_last_rowid(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite *db;
char zBuf[30];
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB\"", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
sprintf(zBuf, "%d", sqlite_last_insert_rowid(db));
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
/*
** Usage: sqlite_close DB
**
@@ -167,11 +277,178 @@ static int sqlite_test_close(
" FILENAME\"", 0);
return TCL_ERROR;
}
db = (sqlite*)atoi(argv[1]);
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
sqlite_close(db);
return TCL_OK;
}
/*
** Implementation of the x_coalesce() function.
** Return the first argument non-NULL argument.
*/
static void ifnullFunc(sqlite_func *context, int argc, const char **argv){
int i;
for(i=0; i<argc; i++){
if( argv[i] ){
sqlite_set_result_string(context, argv[i], -1);
break;
}
}
}
/*
** A structure into which to accumulate text.
*/
struct dstr {
int nAlloc; /* Space allocated */
int nUsed; /* Space used */
char *z; /* The space */
};
/*
** Append text to a dstr
*/
static void dstrAppend(struct dstr *p, const char *z, int divider){
int n = strlen(z);
if( p->nUsed + n + 2 > p->nAlloc ){
char *zNew;
p->nAlloc = p->nAlloc*2 + n + 200;
zNew = sqliteRealloc(p->z, p->nAlloc);
if( zNew==0 ){
sqliteFree(p->z);
memset(p, 0, sizeof(*p));
return;
}
p->z = zNew;
}
if( divider && p->nUsed>0 ){
p->z[p->nUsed++] = divider;
}
memcpy(&p->z[p->nUsed], z, n+1);
p->nUsed += n;
}
/*
** Invoked for each callback from sqliteExecFunc
*/
static int execFuncCallback(void *pData, int argc, char **argv, char **NotUsed){
struct dstr *p = (struct dstr*)pData;
int i;
for(i=0; i<argc; i++){
if( argv[i]==0 ){
dstrAppend(p, "NULL", ' ');
}else{
dstrAppend(p, argv[i], ' ');
}
}
return 0;
}
/*
** Implementation of the x_sqlite_exec() function. This function takes
** a single argument and attempts to execute that argument as SQL code.
** This is illegal and should set the SQLITE_MISUSE flag on the database.
**
** 2004-Jan-07: We have changed this to make it legal to call sqlite_exec()
** from within a function call.
**
** This routine simulates the effect of having two threads attempt to
** use the same database at the same time.
*/
static void sqliteExecFunc(sqlite_func *context, int argc, const char **argv){
struct dstr x;
memset(&x, 0, sizeof(x));
sqlite_exec((sqlite*)sqlite_user_data(context), argv[0],
execFuncCallback, &x, 0);
sqlite_set_result_string(context, x.z, x.nUsed);
sqliteFree(x.z);
}
/*
** Usage: sqlite_test_create_function DB
**
** Call the sqlite_create_function API on the given database in order
** to create a function named "x_coalesce". This function does the same thing
** as the "coalesce" function. This function also registers an SQL function
** named "x_sqlite_exec" that invokes sqlite_exec(). Invoking sqlite_exec()
** in this way is illegal recursion and should raise an SQLITE_MISUSE error.
** The effect is similar to trying to use the same database connection from
** two threads at the same time.
**
** The original motivation for this routine was to be able to call the
** sqlite_create_function function while a query is in progress in order
** to test the SQLITE_MISUSE detection logic.
*/
static int test_create_function(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite *db;
extern void Md5_Register(sqlite*);
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" FILENAME\"", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
sqlite_create_function(db, "x_coalesce", -1, ifnullFunc, 0);
sqlite_create_function(db, "x_sqlite_exec", 1, sqliteExecFunc, db);
return TCL_OK;
}
/*
** Routines to implement the x_count() aggregate function.
*/
typedef struct CountCtx CountCtx;
struct CountCtx {
int n;
};
static void countStep(sqlite_func *context, int argc, const char **argv){
CountCtx *p;
p = sqlite_aggregate_context(context, sizeof(*p));
if( (argc==0 || argv[0]) && p ){
p->n++;
}
}
static void countFinalize(sqlite_func *context){
CountCtx *p;
p = sqlite_aggregate_context(context, sizeof(*p));
sqlite_set_result_int(context, p ? p->n : 0);
}
/*
** Usage: sqlite_test_create_aggregate DB
**
** Call the sqlite_create_function API on the given database in order
** to create a function named "x_count". This function does the same thing
** as the "md5sum" function.
**
** The original motivation for this routine was to be able to call the
** sqlite_create_aggregate function while a query is in progress in order
** to test the SQLITE_MISUSE detection logic.
*/
static int test_create_aggregate(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite *db;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" FILENAME\"", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
sqlite_create_aggregate(db, "x_count", 0, countStep, countFinalize, 0);
sqlite_create_aggregate(db, "x_count", 1, countStep, countFinalize, 0);
return TCL_OK;
}
/*
** Usage: sqlite_mprintf_int FORMAT INTEGER INTEGER INTEGER
**
@@ -195,7 +472,7 @@ static int sqlite_mprintf_int(
}
z = sqlite_mprintf(argv[1], a[0], a[1], a[2]);
Tcl_AppendResult(interp, z, 0);
sqliteFree(z);
sqlite_freemem(z);
return TCL_OK;
}
@@ -212,17 +489,17 @@ static int sqlite_mprintf_str(
){
int a[3], i;
char *z;
if( argc!=5 ){
if( argc<4 || argc>5 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" FORMAT INT INT STRING\"", 0);
" FORMAT INT INT ?STRING?\"", 0);
return TCL_ERROR;
}
for(i=2; i<4; i++){
if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;
}
z = sqlite_mprintf(argv[1], a[0], a[1], argv[4]);
z = sqlite_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL);
Tcl_AppendResult(interp, z, 0);
sqliteFree(z);
sqlite_freemem(z);
return TCL_OK;
}
@@ -251,7 +528,37 @@ static int sqlite_mprintf_double(
if( Tcl_GetDouble(interp, argv[4], &r) ) return TCL_ERROR;
z = sqlite_mprintf(argv[1], a[0], a[1], r);
Tcl_AppendResult(interp, z, 0);
sqliteFree(z);
sqlite_freemem(z);
return TCL_OK;
}
/*
** Usage: sqlite_mprintf_str FORMAT DOUBLE DOUBLE
**
** Call mprintf with a single double argument which is the product of the
** two arguments given above. This is used to generate overflow and underflow
** doubles to test that they are converted properly.
*/
static int sqlite_mprintf_scaled(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
int i;
double r[2];
char *z;
if( argc!=4 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" FORMAT DOUBLE DOUBLE\"", 0);
return TCL_ERROR;
}
for(i=2; i<4; i++){
if( Tcl_GetDouble(interp, argv[i], &r[i-2]) ) return TCL_ERROR;
}
z = sqlite_mprintf(argv[1], r[0]*r[1]);
Tcl_AppendResult(interp, z, 0);
sqlite_freemem(z);
return TCL_OK;
}
@@ -299,21 +606,422 @@ static int sqlite_malloc_stat(
}
#endif
/*
** Usage: sqlite_abort
**
** Shutdown the process immediately. This is not a clean shutdown.
** This command is used to test the recoverability of a database in
** the event of a program crash.
*/
static int sqlite_abort(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
assert( interp==0 ); /* This will always fail */
return TCL_OK;
}
/*
** The following routine is a user-defined SQL function whose purpose
** is to test the sqlite_set_result() API.
*/
static void testFunc(sqlite_func *context, int argc, const char **argv){
while( argc>=2 ){
if( argv[0]==0 ){
sqlite_set_result_error(context, "first argument to test function "
"may not be NULL", -1);
}else if( sqliteStrICmp(argv[0],"string")==0 ){
sqlite_set_result_string(context, argv[1], -1);
}else if( argv[1]==0 ){
sqlite_set_result_error(context, "2nd argument may not be NULL if the "
"first argument is not \"string\"", -1);
}else if( sqliteStrICmp(argv[0],"int")==0 ){
sqlite_set_result_int(context, atoi(argv[1]));
}else if( sqliteStrICmp(argv[0],"double")==0 ){
sqlite_set_result_double(context, sqliteAtoF(argv[1], 0));
}else{
sqlite_set_result_error(context,"first argument should be one of: "
"string int double", -1);
}
argc -= 2;
argv += 2;
}
}
/*
** Usage: sqlite_register_test_function DB NAME
**
** Register the test SQL function on the database DB under the name NAME.
*/
static int test_register_func(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite *db;
int rc;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" DB FUNCTION-NAME", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite_create_function(db, argv[2], -1, testFunc, 0);
if( rc!=0 ){
Tcl_AppendResult(interp, sqlite_error_string(rc), 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** This SQLite callback records the datatype of all columns.
**
** The pArg argument is really a pointer to a TCL interpreter. The
** column names are inserted as the result of this interpreter.
**
** This routine returns non-zero which causes the query to abort.
*/
static int rememberDataTypes(void *pArg, int nCol, char **argv, char **colv){
int i;
Tcl_Interp *interp = (Tcl_Interp*)pArg;
Tcl_Obj *pList, *pElem;
if( colv[nCol+1]==0 ){
return 1;
}
pList = Tcl_NewObj();
for(i=0; i<nCol; i++){
pElem = Tcl_NewStringObj(colv[i+nCol] ? colv[i+nCol] : "NULL", -1);
Tcl_ListObjAppendElement(interp, pList, pElem);
}
Tcl_SetObjResult(interp, pList);
return 1;
}
/*
** Invoke an SQL statement but ignore all the data in the result. Instead,
** return a list that consists of the datatypes of the various columns.
**
** This only works if "PRAGMA show_datatypes=on" has been executed against
** the database connection.
*/
static int sqlite_datatypes(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite *db;
int rc;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" DB SQL", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite_exec(db, argv[2], rememberDataTypes, interp, 0);
if( rc!=0 && rc!=SQLITE_ABORT ){
Tcl_AppendResult(interp, sqlite_error_string(rc), 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Usage: sqlite_compile DB SQL ?TAILVAR?
**
** Attempt to compile an SQL statement. Return a pointer to the virtual
** machine used to execute that statement. Unprocessed SQL is written
** into TAILVAR.
*/
static int test_compile(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite *db;
sqlite_vm *vm;
int rc;
char *zErr = 0;
const char *zTail;
char zBuf[50];
if( argc!=3 && argc!=4 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" DB SQL TAILVAR", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite_compile(db, argv[2], argc==4 ? &zTail : 0, &vm, &zErr);
if( argc==4 ) Tcl_SetVar(interp, argv[3], zTail, 0);
if( rc ){
assert( vm==0 );
sprintf(zBuf, "(%d) ", rc);
Tcl_AppendResult(interp, zBuf, zErr, 0);
sqlite_freemem(zErr);
return TCL_ERROR;
}
if( vm ){
if( makePointerStr(interp, zBuf, vm) ) return TCL_ERROR;
Tcl_AppendResult(interp, zBuf, 0);
}
return TCL_OK;
}
/*
** Usage: sqlite_step VM ?NVAR? ?VALUEVAR? ?COLNAMEVAR?
**
** Step a virtual machine. Return a the result code as a string.
** Column results are written into three variables.
*/
static int test_step(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite_vm *vm;
int rc, i;
const char **azValue = 0;
const char **azColName = 0;
int N = 0;
char *zRc;
char zBuf[50];
if( argc<2 || argc>5 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" VM NVAR VALUEVAR COLNAMEVAR", 0);
return TCL_ERROR;
}
if( getVmPointer(interp, argv[1], &vm) ) return TCL_ERROR;
rc = sqlite_step(vm, argc>=3?&N:0, argc>=4?&azValue:0, argc==5?&azColName:0);
if( argc>=3 ){
sprintf(zBuf, "%d", N);
Tcl_SetVar(interp, argv[2], zBuf, 0);
}
if( argc>=4 ){
Tcl_SetVar(interp, argv[3], "", 0);
if( azValue ){
for(i=0; i<N; i++){
Tcl_SetVar(interp, argv[3], azValue[i] ? azValue[i] : "",
TCL_APPEND_VALUE | TCL_LIST_ELEMENT);
}
}
}
if( argc==5 ){
Tcl_SetVar(interp, argv[4], "", 0);
if( azColName ){
for(i=0; i<N*2; i++){
Tcl_SetVar(interp, argv[4], azColName[i] ? azColName[i] : "",
TCL_APPEND_VALUE | TCL_LIST_ELEMENT);
}
}
}
switch( rc ){
case SQLITE_DONE: zRc = "SQLITE_DONE"; break;
case SQLITE_BUSY: zRc = "SQLITE_BUSY"; break;
case SQLITE_ROW: zRc = "SQLITE_ROW"; break;
case SQLITE_ERROR: zRc = "SQLITE_ERROR"; break;
case SQLITE_MISUSE: zRc = "SQLITE_MISUSE"; break;
default: zRc = "unknown"; break;
}
Tcl_AppendResult(interp, zRc, 0);
return TCL_OK;
}
/*
** Usage: sqlite_finalize VM
**
** Shutdown a virtual machine.
*/
static int test_finalize(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite_vm *vm;
int rc;
char *zErrMsg = 0;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" VM\"", 0);
return TCL_ERROR;
}
if( getVmPointer(interp, argv[1], &vm) ) return TCL_ERROR;
rc = sqlite_finalize(vm, &zErrMsg);
if( rc ){
char zBuf[50];
sprintf(zBuf, "(%d) ", rc);
Tcl_AppendResult(interp, zBuf, zErrMsg, 0);
sqlite_freemem(zErrMsg);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Usage: sqlite_reset VM
**
** Reset a virtual machine and prepare it to be run again.
*/
static int test_reset(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite_vm *vm;
int rc;
char *zErrMsg = 0;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" VM\"", 0);
return TCL_ERROR;
}
if( getVmPointer(interp, argv[1], &vm) ) return TCL_ERROR;
rc = sqlite_reset(vm, &zErrMsg);
if( rc ){
char zBuf[50];
sprintf(zBuf, "(%d) ", rc);
Tcl_AppendResult(interp, zBuf, zErrMsg, 0);
sqlite_freemem(zErrMsg);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** This is the "static_bind_value" that variables are bound to when
** the FLAG option of sqlite_bind is "static"
*/
static char *sqlite_static_bind_value = 0;
/*
** Usage: sqlite_bind VM IDX VALUE FLAGS
**
** Sets the value of the IDX-th occurance of "?" in the original SQL
** string. VALUE is the new value. If FLAGS=="null" then VALUE is
** ignored and the value is set to NULL. If FLAGS=="static" then
** the value is set to the value of a static variable named
** "sqlite_static_bind_value". If FLAGS=="normal" then a copy
** of the VALUE is made.
*/
static int test_bind(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite_vm *vm;
int rc;
int idx;
if( argc!=5 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" VM IDX VALUE (null|static|normal)\"", 0);
return TCL_ERROR;
}
if( getVmPointer(interp, argv[1], &vm) ) return TCL_ERROR;
if( Tcl_GetInt(interp, argv[2], &idx) ) return TCL_ERROR;
if( strcmp(argv[4],"null")==0 ){
rc = sqlite_bind(vm, idx, 0, 0, 0);
}else if( strcmp(argv[4],"static")==0 ){
rc = sqlite_bind(vm, idx, sqlite_static_bind_value, -1, 0);
}else if( strcmp(argv[4],"normal")==0 ){
rc = sqlite_bind(vm, idx, argv[3], -1, 1);
}else{
Tcl_AppendResult(interp, "4th argument should be "
"\"null\" or \"static\" or \"normal\"", 0);
return TCL_ERROR;
}
if( rc ){
char zBuf[50];
sprintf(zBuf, "(%d) ", rc);
Tcl_AppendResult(interp, zBuf, sqlite_error_string(rc), 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Usage: breakpoint
**
** This routine exists for one purpose - to provide a place to put a
** breakpoint with GDB that can be triggered using TCL code. The use
** for this is when a particular test fails on (say) the 1485th iteration.
** In the TCL test script, we can add code like this:
**
** if {$i==1485} breakpoint
**
** Then run testfixture in the debugger and wait for the breakpoint to
** fire. Then additional breakpoints can be set to trace down the bug.
*/
static int test_breakpoint(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
return TCL_OK; /* Do nothing */
}
/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest1_Init(Tcl_Interp *interp){
Tcl_CreateCommand(interp, "sqlite_mprintf_int", sqlite_mprintf_int, 0, 0);
Tcl_CreateCommand(interp, "sqlite_mprintf_str", sqlite_mprintf_str, 0, 0);
Tcl_CreateCommand(interp, "sqlite_mprintf_double", sqlite_mprintf_double,0,0);
Tcl_CreateCommand(interp, "sqlite_open", sqlite_test_open, 0, 0);
Tcl_CreateCommand(interp, "sqlite_exec_printf", test_exec_printf, 0, 0);
Tcl_CreateCommand(interp, "sqlite_get_table_printf", test_get_table_printf,
0, 0);
Tcl_CreateCommand(interp, "sqlite_close", sqlite_test_close, 0, 0);
extern int sqlite_search_count;
extern int sqlite_interrupt_count;
extern int sqlite_open_file_count;
extern int sqlite_current_time;
extern int sqlite_temp_directory;
static struct {
char *zName;
Tcl_CmdProc *xProc;
} aCmd[] = {
{ "sqlite_mprintf_int", (Tcl_CmdProc*)sqlite_mprintf_int },
{ "sqlite_mprintf_str", (Tcl_CmdProc*)sqlite_mprintf_str },
{ "sqlite_mprintf_double", (Tcl_CmdProc*)sqlite_mprintf_double },
{ "sqlite_mprintf_scaled", (Tcl_CmdProc*)sqlite_mprintf_scaled },
{ "sqlite_mprintf_z_test", (Tcl_CmdProc*)test_mprintf_z },
{ "sqlite_open", (Tcl_CmdProc*)sqlite_test_open },
{ "sqlite_last_insert_rowid", (Tcl_CmdProc*)test_last_rowid },
{ "sqlite_exec_printf", (Tcl_CmdProc*)test_exec_printf },
{ "sqlite_get_table_printf", (Tcl_CmdProc*)test_get_table_printf },
{ "sqlite_close", (Tcl_CmdProc*)sqlite_test_close },
{ "sqlite_create_function", (Tcl_CmdProc*)test_create_function },
{ "sqlite_create_aggregate", (Tcl_CmdProc*)test_create_aggregate },
{ "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func },
{ "sqlite_abort", (Tcl_CmdProc*)sqlite_abort },
{ "sqlite_datatypes", (Tcl_CmdProc*)sqlite_datatypes },
#ifdef MEMORY_DEBUG
Tcl_CreateCommand(interp, "sqlite_malloc_fail", sqlite_malloc_fail, 0, 0);
Tcl_CreateCommand(interp, "sqlite_malloc_stat", sqlite_malloc_stat, 0, 0);
{ "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail },
{ "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat },
#endif
{ "sqlite_compile", (Tcl_CmdProc*)test_compile },
{ "sqlite_step", (Tcl_CmdProc*)test_step },
{ "sqlite_finalize", (Tcl_CmdProc*)test_finalize },
{ "sqlite_bind", (Tcl_CmdProc*)test_bind },
{ "sqlite_reset", (Tcl_CmdProc*)test_reset },
{ "breakpoint", (Tcl_CmdProc*)test_breakpoint },
};
int i;
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
}
Tcl_LinkVar(interp, "sqlite_search_count",
(char*)&sqlite_search_count, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_interrupt_count",
(char*)&sqlite_interrupt_count, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_open_file_count",
(char*)&sqlite_open_file_count, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_current_time",
(char*)&sqlite_current_time, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_static_bind_value",
(char*)&sqlite_static_bind_value, TCL_LINK_STRING);
Tcl_LinkVar(interp, "sqlite_temp_directory",
(char*)&sqlite_temp_directory, TCL_LINK_STRING);
return TCL_OK;
}
+188 -28
View File
@@ -13,8 +13,9 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test2.c,v 1.6 2001/10/12 17:30:05 drh Exp $
** $Id: test2.c,v 1.16 2004/02/10 01:54:28 drh Exp $
*/
#include "os.h"
#include "sqliteInt.h"
#include "pager.h"
#include "tcl.h"
@@ -42,6 +43,13 @@ static char *errorName(int rc){
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
case SQLITE_MISMATCH: zName = "SQLITE_MISMATCH"; break;
case SQLITE_MISUSE: zName = "SQLITE_MISUSE"; break;
case SQLITE_NOLFS: zName = "SQLITE_NOLFS"; break;
default: zName = "SQLITE_Unknown"; break;
}
return zName;
@@ -56,7 +64,7 @@ static int pager_open(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
int nPage;
@@ -68,7 +76,7 @@ static int pager_open(
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;
rc = sqlitepager_open(&pPager, argv[1], nPage, 0);
rc = sqlitepager_open(&pPager, argv[1], nPage, 0, 1);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
@@ -87,7 +95,7 @@ static int pager_close(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
int rc;
@@ -114,7 +122,7 @@ static int pager_rollback(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
int rc;
@@ -141,7 +149,7 @@ static int pager_commit(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
int rc;
@@ -159,6 +167,87 @@ static int pager_commit(
return TCL_OK;
}
/*
** Usage: pager_ckpt_begin ID
**
** Start a new checkpoint.
*/
static int pager_ckpt_begin(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
Pager *pPager;
int rc;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
rc = sqlitepager_ckpt_begin(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Usage: pager_ckpt_rollback ID
**
** Rollback changes to a checkpoint
*/
static int pager_ckpt_rollback(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
Pager *pPager;
int rc;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
rc = sqlitepager_ckpt_rollback(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Usage: pager_ckpt_commit ID
**
** Commit changes to a checkpoint
*/
static int pager_ckpt_commit(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
Pager *pPager;
int rc;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
rc = sqlitepager_ckpt_commit(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
return TCL_OK;
}
/*
** Usage: pager_stats ID
**
@@ -168,7 +257,7 @@ static int pager_stats(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
int i, *a;
@@ -201,7 +290,7 @@ static int pager_pagecount(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
char zBuf[100];
@@ -225,7 +314,7 @@ static int page_get(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
char zBuf[100];
@@ -259,7 +348,7 @@ static int page_lookup(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Pager *pPager;
char zBuf[100];
@@ -289,7 +378,7 @@ static int page_unref(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
void *pPage;
int rc;
@@ -316,7 +405,7 @@ static int page_read(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
char zBuf[100];
void *pPage;
@@ -340,7 +429,7 @@ static int page_number(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
char zBuf[100];
void *pPage;
@@ -364,7 +453,7 @@ static int page_write(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
void *pPage;
int rc;
@@ -379,8 +468,55 @@ static int page_write(
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
strncpy((char*)pPage, argv[2], SQLITE_PAGE_SIZE-1);
((char*)pPage)[SQLITE_PAGE_SIZE-1] = 0;
strncpy((char*)pPage, argv[2], SQLITE_USABLE_SIZE-1);
((char*)pPage)[SQLITE_USABLE_SIZE-1] = 0;
return TCL_OK;
}
/*
** Usage: fake_big_file N FILENAME
**
** Write a few bytes at the N megabyte point of FILENAME. This will
** create a large file. If the file was a valid SQLite database, then
** the next time the database is opened, SQLite will begin allocating
** new pages after N. If N is 2096 or bigger, this will test the
** ability of SQLite to write to large files.
*/
static int fake_big_file(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int rc;
int n;
off_t offset;
OsFile fd;
int readOnly = 0;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" N-MEGABYTES FILE\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR;
rc = sqliteOsOpenReadWrite(argv[2], &fd, &readOnly);
if( rc ){
Tcl_AppendResult(interp, "open failed: ", errorName(rc), 0);
return TCL_ERROR;
}
offset = n;
offset *= 1024*1024;
rc = sqliteOsSeek(&fd, offset);
if( rc ){
Tcl_AppendResult(interp, "seek failed: ", errorName(rc), 0);
return TCL_ERROR;
}
rc = sqliteOsWrite(&fd, "Hello, World!", 14);
sqliteOsClose(&fd);
if( rc ){
Tcl_AppendResult(interp, "write failed: ", errorName(rc), 0);
return TCL_ERROR;
}
return TCL_OK;
}
@@ -389,19 +525,43 @@ static int page_write(
*/
int Sqlitetest2_Init(Tcl_Interp *interp){
extern int sqlite_io_error_pending;
Tcl_CreateCommand(interp, "pager_open", pager_open, 0, 0);
Tcl_CreateCommand(interp, "pager_close", pager_close, 0, 0);
Tcl_CreateCommand(interp, "pager_commit", pager_commit, 0, 0);
Tcl_CreateCommand(interp, "pager_rollback", pager_rollback, 0, 0);
Tcl_CreateCommand(interp, "pager_stats", pager_stats, 0, 0);
Tcl_CreateCommand(interp, "pager_pagecount", pager_pagecount, 0, 0);
Tcl_CreateCommand(interp, "page_get", page_get, 0, 0);
Tcl_CreateCommand(interp, "page_lookup", page_lookup, 0, 0);
Tcl_CreateCommand(interp, "page_unref", page_unref, 0, 0);
Tcl_CreateCommand(interp, "page_read", page_read, 0, 0);
Tcl_CreateCommand(interp, "page_write", page_write, 0, 0);
Tcl_CreateCommand(interp, "page_number", page_number, 0, 0);
char zBuf[100];
static struct {
char *zName;
Tcl_CmdProc *xProc;
} aCmd[] = {
{ "pager_open", (Tcl_CmdProc*)pager_open },
{ "pager_close", (Tcl_CmdProc*)pager_close },
{ "pager_commit", (Tcl_CmdProc*)pager_commit },
{ "pager_rollback", (Tcl_CmdProc*)pager_rollback },
{ "pager_ckpt_begin", (Tcl_CmdProc*)pager_ckpt_begin },
{ "pager_ckpt_commit", (Tcl_CmdProc*)pager_ckpt_commit },
{ "pager_ckpt_rollback", (Tcl_CmdProc*)pager_ckpt_rollback },
{ "pager_stats", (Tcl_CmdProc*)pager_stats },
{ "pager_pagecount", (Tcl_CmdProc*)pager_pagecount },
{ "page_get", (Tcl_CmdProc*)page_get },
{ "page_lookup", (Tcl_CmdProc*)page_lookup },
{ "page_unref", (Tcl_CmdProc*)page_unref },
{ "page_read", (Tcl_CmdProc*)page_read },
{ "page_write", (Tcl_CmdProc*)page_write },
{ "page_number", (Tcl_CmdProc*)page_number },
{ "fake_big_file", (Tcl_CmdProc*)fake_big_file },
};
int i;
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
}
Tcl_LinkVar(interp, "sqlite_io_error_pending",
(char*)&sqlite_io_error_pending, TCL_LINK_INT);
#ifdef SQLITE_TEST
Tcl_LinkVar(interp, "journal_format",
(char*)&journal_format, TCL_LINK_INT);
#endif
sprintf(zBuf, "%d", SQLITE_PAGE_SIZE);
Tcl_SetVar(interp, "SQLITE_PAGE_SIZE", zBuf, TCL_GLOBAL_ONLY);
sprintf(zBuf, "%d", SQLITE_PAGE_RESERVE);
Tcl_SetVar(interp, "SQLITE_PAGE_RESERVE", zBuf, TCL_GLOBAL_ONLY);
sprintf(zBuf, "%d", SQLITE_USABLE_SIZE);
Tcl_SetVar(interp, "SQLITE_USABLE_SIZE", zBuf, TCL_GLOBAL_ONLY);
return TCL_OK;
}
+212 -58
View File
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test3.c,v 1.12 2001/09/23 02:35:53 drh Exp $
** $Id: test3.c,v 1.23 2003/04/13 18:26:52 paul Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -57,7 +57,7 @@ static int btree_open(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc;
@@ -67,12 +67,15 @@ static int btree_open(
" FILENAME\"", 0);
return TCL_ERROR;
}
rc = sqliteBtreeOpen(argv[1], 0666, 10, &pBt);
rc = sqliteBtreeFactory(0, argv[1], 0, 1000, &pBt);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"0x%x",(int)pBt);
sprintf(zBuf,"%p", pBt);
if( strncmp(zBuf,"0x",2) ){
sprintf(zBuf, "0x%p", pBt);
}
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@@ -86,7 +89,7 @@ static int btree_close(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc;
@@ -113,7 +116,7 @@ static int btree_begin_transaction(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc;
@@ -140,7 +143,7 @@ static int btree_rollback(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc;
@@ -167,7 +170,7 @@ static int btree_commit(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc;
@@ -194,7 +197,7 @@ static int btree_create_table(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc, iTable;
@@ -224,7 +227,7 @@ static int btree_drop_table(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int iTable;
@@ -253,7 +256,7 @@ static int btree_clear_table(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int iTable;
@@ -282,7 +285,7 @@ static int btree_get_meta(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc;
@@ -316,7 +319,7 @@ static int btree_update_meta(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int rc;
@@ -351,7 +354,7 @@ static int btree_page_dump(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int iPage;
@@ -381,7 +384,7 @@ static int btree_tree_dump(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int iPage;
@@ -411,7 +414,7 @@ static int btree_pager_stats(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int i;
@@ -446,7 +449,7 @@ static int btree_pager_ref_dump(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
@@ -461,17 +464,17 @@ static int btree_pager_ref_dump(
}
/*
** Usage: btree_sanity_check ID ROOT ...
** Usage: btree_integrity_check ID ROOT ...
**
** Look through every page of the given BTree file to verify correct
** formatting and linkage. Return a line of text for each problem found.
** Return an empty string if everything worked.
*/
static int btree_sanity_check(
static int btree_integrity_check(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
char *zResult;
@@ -490,10 +493,10 @@ static int btree_sanity_check(
for(i=0; i<argc-2; i++){
if( Tcl_GetInt(interp, argv[i+2], &aRoot[i]) ) return TCL_ERROR;
}
zResult = sqliteBtreeSanityCheck(pBt, aRoot, nRoot);
zResult = sqliteBtreeIntegrityCheck(pBt, aRoot, nRoot);
if( zResult ){
Tcl_AppendResult(interp, zResult, 0);
free(zResult);
sqliteFree(zResult);
}
return TCL_OK;
}
@@ -507,7 +510,7 @@ static int btree_cursor(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
Btree *pBt;
int iTable;
@@ -543,7 +546,7 @@ static int btree_close_cursor(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
@@ -571,7 +574,7 @@ static int btree_move_to(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
@@ -589,6 +592,8 @@ static int btree_move_to(
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
if( res<0 ) res = -1;
if( res>0 ) res = 1;
sprintf(zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
@@ -603,7 +608,7 @@ static int btree_delete(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
@@ -632,7 +637,7 @@ static int btree_insert(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
@@ -655,16 +660,20 @@ static int btree_insert(
/*
** Usage: btree_next ID
**
** Move the cursor to the next entry in the table.
** Move the cursor to the next entry in the table. Return 0 on success
** or 1 if the cursor was already on the last entry in the table or if
** the table is empty.
*/
static int btree_next(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
int res = 0;
char zBuf[100];
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
@@ -672,11 +681,113 @@ static int btree_next(
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
rc = sqliteBtreeNext(pCur, 0);
rc = sqliteBtreeNext(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
/*
** Usage: btree_prev ID
**
** Move the cursor to the previous entry in the table. Return 0 on
** success and 1 if the cursor was already on the first entry in
** the table or if the table was empty.
*/
static int btree_prev(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
int res = 0;
char zBuf[100];
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
rc = sqliteBtreePrevious(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
/*
** Usage: btree_first ID
**
** Move the cursor to the first entry in the table. Return 0 if the
** cursor was left point to something and 1 if the table is empty.
*/
static int btree_first(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
int res = 0;
char zBuf[100];
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
rc = sqliteBtreeFirst(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
/*
** Usage: btree_last ID
**
** Move the cursor to the last entry in the table. Return 0 if the
** cursor was left point to something and 1 if the table is empty.
*/
static int btree_last(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
int res = 0;
char zBuf[100];
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
rc = sqliteBtreeLast(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@@ -689,7 +800,7 @@ static int btree_key(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
@@ -727,7 +838,7 @@ static int btree_data(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
@@ -756,6 +867,34 @@ static int btree_data(
return SQLITE_OK;
}
/*
** Usage: btree_payload_size ID
**
** Return the number of bytes of payload
*/
static int btree_payload_size(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int n1, n2;
char zBuf[50];
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
sqliteBtreeKeySize(pCur, &n1);
sqliteBtreeDataSize(pCur, &n2);
sprintf(zBuf, "%d", n1+n2);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
/*
** Usage: btree_cursor_dump ID
**
@@ -775,7 +914,7 @@ static int btree_cursor_dump(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
@@ -807,32 +946,47 @@ static int btree_cursor_dump(
** Register commands with the TCL interpreter.
*/
int Sqlitetest3_Init(Tcl_Interp *interp){
Tcl_CreateCommand(interp, "btree_open", btree_open, 0, 0);
Tcl_CreateCommand(interp, "btree_close", btree_close, 0, 0);
Tcl_CreateCommand(interp, "btree_begin_transaction",
btree_begin_transaction, 0, 0);
Tcl_CreateCommand(interp, "btree_commit", btree_commit, 0, 0);
Tcl_CreateCommand(interp, "btree_rollback", btree_rollback, 0, 0);
Tcl_CreateCommand(interp, "btree_create_table", btree_create_table, 0, 0);
Tcl_CreateCommand(interp, "btree_drop_table", btree_drop_table, 0, 0);
Tcl_CreateCommand(interp, "btree_clear_table", btree_clear_table, 0, 0);
Tcl_CreateCommand(interp, "btree_get_meta", btree_get_meta, 0, 0);
Tcl_CreateCommand(interp, "btree_update_meta", btree_update_meta, 0, 0);
Tcl_CreateCommand(interp, "btree_page_dump", btree_page_dump, 0, 0);
Tcl_CreateCommand(interp, "btree_tree_dump", btree_tree_dump, 0, 0);
Tcl_CreateCommand(interp, "btree_pager_stats", btree_pager_stats, 0, 0);
Tcl_CreateCommand(interp, "btree_pager_ref_dump", btree_pager_ref_dump, 0, 0);
Tcl_CreateCommand(interp, "btree_cursor", btree_cursor, 0, 0);
Tcl_CreateCommand(interp, "btree_close_cursor", btree_close_cursor, 0, 0);
Tcl_CreateCommand(interp, "btree_move_to", btree_move_to, 0, 0);
Tcl_CreateCommand(interp, "btree_delete", btree_delete, 0, 0);
Tcl_CreateCommand(interp, "btree_insert", btree_insert, 0, 0);
Tcl_CreateCommand(interp, "btree_next", btree_next, 0, 0);
Tcl_CreateCommand(interp, "btree_key", btree_key, 0, 0);
Tcl_CreateCommand(interp, "btree_data", btree_data, 0, 0);
Tcl_CreateCommand(interp, "btree_cursor_dump", btree_cursor_dump, 0, 0);
Tcl_CreateCommand(interp, "btree_sanity_check", btree_sanity_check, 0, 0);
static struct {
char *zName;
Tcl_CmdProc *xProc;
} aCmd[] = {
{ "btree_open", (Tcl_CmdProc*)btree_open },
{ "btree_close", (Tcl_CmdProc*)btree_close },
{ "btree_begin_transaction", (Tcl_CmdProc*)btree_begin_transaction },
{ "btree_commit", (Tcl_CmdProc*)btree_commit },
{ "btree_rollback", (Tcl_CmdProc*)btree_rollback },
{ "btree_create_table", (Tcl_CmdProc*)btree_create_table },
{ "btree_drop_table", (Tcl_CmdProc*)btree_drop_table },
{ "btree_clear_table", (Tcl_CmdProc*)btree_clear_table },
{ "btree_get_meta", (Tcl_CmdProc*)btree_get_meta },
{ "btree_update_meta", (Tcl_CmdProc*)btree_update_meta },
{ "btree_page_dump", (Tcl_CmdProc*)btree_page_dump },
{ "btree_tree_dump", (Tcl_CmdProc*)btree_tree_dump },
{ "btree_pager_stats", (Tcl_CmdProc*)btree_pager_stats },
{ "btree_pager_ref_dump", (Tcl_CmdProc*)btree_pager_ref_dump },
{ "btree_cursor", (Tcl_CmdProc*)btree_cursor },
{ "btree_close_cursor", (Tcl_CmdProc*)btree_close_cursor },
{ "btree_move_to", (Tcl_CmdProc*)btree_move_to },
{ "btree_delete", (Tcl_CmdProc*)btree_delete },
{ "btree_insert", (Tcl_CmdProc*)btree_insert },
{ "btree_next", (Tcl_CmdProc*)btree_next },
{ "btree_prev", (Tcl_CmdProc*)btree_prev },
{ "btree_key", (Tcl_CmdProc*)btree_key },
{ "btree_data", (Tcl_CmdProc*)btree_data },
{ "btree_payload_size", (Tcl_CmdProc*)btree_payload_size },
{ "btree_first", (Tcl_CmdProc*)btree_first },
{ "btree_last", (Tcl_CmdProc*)btree_last },
{ "btree_cursor_dump", (Tcl_CmdProc*)btree_cursor_dump },
{ "btree_integrity_check", (Tcl_CmdProc*)btree_integrity_check },
};
int i;
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
}
Tcl_LinkVar(interp, "pager_refinfo_enable", (char*)&pager_refinfo_enable,
TCL_LINK_INT);
Tcl_LinkVar(interp, "btree_native_byte_order",(char*)&btree_native_byte_order,
TCL_LINK_INT);
return TCL_OK;
}
+634
View File
@@ -0,0 +1,634 @@
/*
** 2003 December 18
**
** 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.
**
*************************************************************************
** Code for testing the the SQLite library in a multithreaded environment.
**
** $Id: test4.c,v 1.3 2004/04/23 17:04:45 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#if defined(OS_UNIX) && OS_UNIX==1 && defined(THREADSAFE) && THREADSAFE==1
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sched.h>
#include <ctype.h>
/*
** Each thread is controlled by an instance of the following
** structure.
*/
typedef struct Thread Thread;
struct Thread {
/* The first group of fields are writable by the master and read-only
** to the thread. */
char *zFilename; /* Name of database file */
void (*xOp)(Thread*); /* next operation to do */
char *zArg; /* argument usable by xOp */
int opnum; /* Operation number */
int busy; /* True if this thread is in use */
/* The next group of fields are writable by the thread but read-only to the
** master. */
int completed; /* Number of operations completed */
sqlite *db; /* Open database */
sqlite_vm *vm; /* Pending operation */
char *zErr; /* operation error */
char *zStaticErr; /* Static error message */
int rc; /* operation return code */
int argc; /* number of columns in result */
const char **argv; /* result columns */
const char **colv; /* result column names */
};
/*
** There can be as many as 26 threads running at once. Each is named
** by a capital letter: A, B, C, ..., Y, Z.
*/
#define N_THREAD 26
static Thread threadset[N_THREAD];
/*
** The main loop for a thread. Threads use busy waiting.
*/
static void *thread_main(void *pArg){
Thread *p = (Thread*)pArg;
if( p->db ){
sqlite_close(p->db);
}
p->db = sqlite_open(p->zFilename, 0, &p->zErr);
p->vm = 0;
p->completed = 1;
while( p->opnum<=p->completed ) sched_yield();
while( p->xOp ){
if( p->zErr && p->zErr!=p->zStaticErr ){
sqlite_freemem(p->zErr);
p->zErr = 0;
}
(*p->xOp)(p);
p->completed++;
while( p->opnum<=p->completed ) sched_yield();
}
if( p->vm ){
sqlite_finalize(p->vm, 0);
p->vm = 0;
}
if( p->db ){
sqlite_close(p->db);
p->db = 0;
}
if( p->zErr && p->zErr!=p->zStaticErr ){
sqlite_freemem(p->zErr);
p->zErr = 0;
}
p->completed++;
return 0;
}
/*
** Get a thread ID which is an upper case letter. Return the index.
** If the argument is not a valid thread ID put an error message in
** the interpreter and return -1.
*/
static int parse_thread_id(Tcl_Interp *interp, const char *zArg){
if( zArg==0 || zArg[0]==0 || zArg[1]!=0 || !isupper(zArg[0]) ){
Tcl_AppendResult(interp, "thread ID must be an upper case letter", 0);
return -1;
}
return zArg[0] - 'A';
}
/*
** Usage: thread_create NAME FILENAME
**
** NAME should be an upper case letter. Start the thread running with
** an open connection to the given database.
*/
static int tcl_thread_create(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
pthread_t x;
int rc;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID FILENAME", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( threadset[i].busy ){
Tcl_AppendResult(interp, "thread ", argv[1], " is already running", 0);
return TCL_ERROR;
}
threadset[i].busy = 1;
sqliteFree(threadset[i].zFilename);
threadset[i].zFilename = sqliteStrDup(argv[2]);
threadset[i].opnum = 1;
threadset[i].completed = 0;
rc = pthread_create(&x, 0, thread_main, &threadset[i]);
if( rc ){
Tcl_AppendResult(interp, "failed to create the thread", 0);
sqliteFree(threadset[i].zFilename);
threadset[i].busy = 0;
return TCL_ERROR;
}
pthread_detach(x);
return TCL_OK;
}
/*
** Wait for a thread to reach its idle state.
*/
static void thread_wait(Thread *p){
while( p->opnum>p->completed ) sched_yield();
}
/*
** Usage: thread_wait ID
**
** Wait on thread ID to reach its idle state.
*/
static int tcl_thread_wait(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
return TCL_OK;
}
/*
** Stop a thread.
*/
static void stop_thread(Thread *p){
thread_wait(p);
p->xOp = 0;
p->opnum++;
thread_wait(p);
sqliteFree(p->zArg);
p->zArg = 0;
sqliteFree(p->zFilename);
p->zFilename = 0;
p->busy = 0;
}
/*
** Usage: thread_halt ID
**
** Cause a thread to shut itself down. Wait for the shutdown to be
** completed. If ID is "*" then stop all threads.
*/
static int tcl_thread_halt(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID", 0);
return TCL_ERROR;
}
if( argv[1][0]=='*' && argv[1][1]==0 ){
for(i=0; i<N_THREAD; i++){
if( threadset[i].busy ) stop_thread(&threadset[i]);
}
}else{
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
stop_thread(&threadset[i]);
}
return TCL_OK;
}
/*
** Usage: thread_argc ID
**
** Wait on the most recent thread_step to complete, then return the
** number of columns in the result set.
*/
static int tcl_thread_argc(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
char zBuf[100];
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
sprintf(zBuf, "%d", threadset[i].argc);
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
/*
** Usage: thread_argv ID N
**
** Wait on the most recent thread_step to complete, then return the
** value of the N-th columns in the result set.
*/
static int tcl_thread_argv(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
int n;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID N", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;
thread_wait(&threadset[i]);
if( n<0 || n>=threadset[i].argc ){
Tcl_AppendResult(interp, "column number out of range", 0);
return TCL_ERROR;
}
Tcl_AppendResult(interp, threadset[i].argv[n], 0);
return TCL_OK;
}
/*
** Usage: thread_colname ID N
**
** Wait on the most recent thread_step to complete, then return the
** name of the N-th columns in the result set.
*/
static int tcl_thread_colname(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
int n;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID N", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;
thread_wait(&threadset[i]);
if( n<0 || n>=threadset[i].argc ){
Tcl_AppendResult(interp, "column number out of range", 0);
return TCL_ERROR;
}
Tcl_AppendResult(interp, threadset[i].colv[n], 0);
return TCL_OK;
}
/*
** Usage: thread_result ID
**
** Wait on the most recent operation to complete, then return the
** result code from that operation.
*/
static int tcl_thread_result(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
const char *zName;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
switch( threadset[i].rc ){
case SQLITE_OK: zName = "SQLITE_OK"; break;
case SQLITE_ERROR: zName = "SQLITE_ERROR"; break;
case SQLITE_INTERNAL: zName = "SQLITE_INTERNAL"; break;
case SQLITE_PERM: zName = "SQLITE_PERM"; break;
case SQLITE_ABORT: zName = "SQLITE_ABORT"; break;
case SQLITE_BUSY: zName = "SQLITE_BUSY"; break;
case SQLITE_LOCKED: zName = "SQLITE_LOCKED"; break;
case SQLITE_NOMEM: zName = "SQLITE_NOMEM"; break;
case SQLITE_READONLY: zName = "SQLITE_READONLY"; break;
case SQLITE_INTERRUPT: zName = "SQLITE_INTERRUPT"; break;
case SQLITE_IOERR: zName = "SQLITE_IOERR"; break;
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
case SQLITE_MISMATCH: zName = "SQLITE_MISMATCH"; break;
case SQLITE_MISUSE: zName = "SQLITE_MISUSE"; break;
case SQLITE_NOLFS: zName = "SQLITE_NOLFS"; break;
case SQLITE_AUTH: zName = "SQLITE_AUTH"; break;
case SQLITE_FORMAT: zName = "SQLITE_FORMAT"; break;
case SQLITE_RANGE: zName = "SQLITE_RANGE"; break;
case SQLITE_ROW: zName = "SQLITE_ROW"; break;
case SQLITE_DONE: zName = "SQLITE_DONE"; break;
default: zName = "SQLITE_Unknown"; break;
}
Tcl_AppendResult(interp, zName, 0);
return TCL_OK;
}
/*
** Usage: thread_error ID
**
** Wait on the most recent operation to complete, then return the
** error string.
*/
static int tcl_thread_error(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
Tcl_AppendResult(interp, threadset[i].zErr, 0);
return TCL_OK;
}
/*
** This procedure runs in the thread to compile an SQL statement.
*/
static void do_compile(Thread *p){
if( p->db==0 ){
p->zErr = p->zStaticErr = "no database is open";
p->rc = SQLITE_ERROR;
return;
}
if( p->vm ){
sqlite_finalize(p->vm, 0);
p->vm = 0;
}
p->rc = sqlite_compile(p->db, p->zArg, 0, &p->vm, &p->zErr);
}
/*
** Usage: thread_compile ID SQL
**
** Compile a new virtual machine.
*/
static int tcl_thread_compile(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID SQL", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
threadset[i].xOp = do_compile;
sqliteFree(threadset[i].zArg);
threadset[i].zArg = sqliteStrDup(argv[2]);
threadset[i].opnum++;
return TCL_OK;
}
/*
** This procedure runs in the thread to step the virtual machine.
*/
static void do_step(Thread *p){
if( p->vm==0 ){
p->zErr = p->zStaticErr = "no virtual machine available";
p->rc = SQLITE_ERROR;
return;
}
p->rc = sqlite_step(p->vm, &p->argc, &p->argv, &p->colv);
}
/*
** Usage: thread_step ID
**
** Advance the virtual machine by one step
*/
static int tcl_thread_step(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" IDL", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
threadset[i].xOp = do_step;
threadset[i].opnum++;
return TCL_OK;
}
/*
** This procedure runs in the thread to finalize a virtual machine.
*/
static void do_finalize(Thread *p){
if( p->vm==0 ){
p->zErr = p->zStaticErr = "no virtual machine available";
p->rc = SQLITE_ERROR;
return;
}
p->rc = sqlite_finalize(p->vm, &p->zErr);
p->vm = 0;
}
/*
** Usage: thread_finalize ID
**
** Finalize the virtual machine.
*/
static int tcl_thread_finalize(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" IDL", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
threadset[i].xOp = do_finalize;
sqliteFree(threadset[i].zArg);
threadset[i].zArg = 0;
threadset[i].opnum++;
return TCL_OK;
}
/*
** Usage: thread_swap ID ID
**
** Interchange the sqlite* pointer between two threads.
*/
static int tcl_thread_swap(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
int i, j;
sqlite *temp;
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID1 ID2", 0);
return TCL_ERROR;
}
i = parse_thread_id(interp, argv[1]);
if( i<0 ) return TCL_ERROR;
if( !threadset[i].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[i]);
j = parse_thread_id(interp, argv[2]);
if( j<0 ) return TCL_ERROR;
if( !threadset[j].busy ){
Tcl_AppendResult(interp, "no such thread", 0);
return TCL_ERROR;
}
thread_wait(&threadset[j]);
temp = threadset[i].db;
threadset[i].db = threadset[j].db;
threadset[j].db = temp;
return TCL_OK;
}
/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest4_Init(Tcl_Interp *interp){
static struct {
char *zName;
Tcl_CmdProc *xProc;
} aCmd[] = {
{ "thread_create", (Tcl_CmdProc*)tcl_thread_create },
{ "thread_wait", (Tcl_CmdProc*)tcl_thread_wait },
{ "thread_halt", (Tcl_CmdProc*)tcl_thread_halt },
{ "thread_argc", (Tcl_CmdProc*)tcl_thread_argc },
{ "thread_argv", (Tcl_CmdProc*)tcl_thread_argv },
{ "thread_colname", (Tcl_CmdProc*)tcl_thread_colname },
{ "thread_result", (Tcl_CmdProc*)tcl_thread_result },
{ "thread_error", (Tcl_CmdProc*)tcl_thread_error },
{ "thread_compile", (Tcl_CmdProc*)tcl_thread_compile },
{ "thread_step", (Tcl_CmdProc*)tcl_thread_step },
{ "thread_finalize", (Tcl_CmdProc*)tcl_thread_finalize },
{ "thread_swap", (Tcl_CmdProc*)tcl_thread_swap },
};
int i;
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
}
return TCL_OK;
}
#else
int Sqlitetest4_Init(Tcl_Interp *interp){ return TCL_OK; }
#endif /* OS_UNIX */
+384 -152
View File
@@ -15,7 +15,7 @@
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.30 2001/10/22 02:58:10 drh Exp $
** $Id: tokenize.c,v 1.68 2004/02/14 23:59:58 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -29,79 +29,122 @@
typedef struct Keyword Keyword;
struct Keyword {
char *zName; /* The keyword name */
int len; /* Number of characters in the keyword */
int tokenType; /* The token value for this keyword */
Keyword *pNext; /* Next keyword with the same hash */
u8 tokenType; /* Token value for this keyword */
u8 len; /* Length of this keyword */
u8 iNext; /* Index in aKeywordTable[] of next with same hash */
};
/*
** These are the keywords
*/
static Keyword aKeywordTable[] = {
{ "ALL", 0, TK_ALL, 0 },
{ "AND", 0, TK_AND, 0 },
{ "AS", 0, TK_AS, 0 },
{ "ASC", 0, TK_ASC, 0 },
{ "BEGIN", 0, TK_BEGIN, 0 },
{ "BETWEEN", 0, TK_BETWEEN, 0 },
{ "BY", 0, TK_BY, 0 },
{ "CHECK", 0, TK_CHECK, 0 },
{ "CLUSTER", 0, TK_CLUSTER, 0 },
{ "COMMIT", 0, TK_COMMIT, 0 },
{ "CONSTRAINT", 0, TK_CONSTRAINT, 0 },
{ "COPY", 0, TK_COPY, 0 },
{ "CREATE", 0, TK_CREATE, 0 },
{ "DEFAULT", 0, TK_DEFAULT, 0 },
{ "DELETE", 0, TK_DELETE, 0 },
{ "DELIMITERS", 0, TK_DELIMITERS, 0 },
{ "DESC", 0, TK_DESC, 0 },
{ "DISTINCT", 0, TK_DISTINCT, 0 },
{ "DROP", 0, TK_DROP, 0 },
{ "END", 0, TK_END, 0 },
{ "EXCEPT", 0, TK_EXCEPT, 0 },
{ "EXPLAIN", 0, TK_EXPLAIN, 0 },
{ "FROM", 0, TK_FROM, 0 },
{ "GLOB", 0, TK_GLOB, 0 },
{ "GROUP", 0, TK_GROUP, 0 },
{ "HAVING", 0, TK_HAVING, 0 },
{ "IN", 0, TK_IN, 0 },
{ "INDEX", 0, TK_INDEX, 0 },
{ "INSERT", 0, TK_INSERT, 0 },
{ "INTERSECT", 0, TK_INTERSECT, 0 },
{ "INTO", 0, TK_INTO, 0 },
{ "IS", 0, TK_IS, 0 },
{ "ISNULL", 0, TK_ISNULL, 0 },
{ "KEY", 0, TK_KEY, 0 },
{ "LIKE", 0, TK_LIKE, 0 },
{ "NOT", 0, TK_NOT, 0 },
{ "NOTNULL", 0, TK_NOTNULL, 0 },
{ "NULL", 0, TK_NULL, 0 },
{ "ON", 0, TK_ON, 0 },
{ "OR", 0, TK_OR, 0 },
{ "ORDER", 0, TK_ORDER, 0 },
{ "PRAGMA", 0, TK_PRAGMA, 0 },
{ "PRIMARY", 0, TK_PRIMARY, 0 },
{ "ROLLBACK", 0, TK_ROLLBACK, 0 },
{ "SELECT", 0, TK_SELECT, 0 },
{ "SET", 0, TK_SET, 0 },
{ "TABLE", 0, TK_TABLE, 0 },
{ "TEMP", 0, TK_TEMP, 0 },
{ "TEMPORARY", 0, TK_TEMP, 0 },
{ "TRANSACTION", 0, TK_TRANSACTION, 0 },
{ "UNION", 0, TK_UNION, 0 },
{ "UNIQUE", 0, TK_UNIQUE, 0 },
{ "UPDATE", 0, TK_UPDATE, 0 },
{ "USING", 0, TK_USING, 0 },
{ "VACUUM", 0, TK_VACUUM, 0 },
{ "VALUES", 0, TK_VALUES, 0 },
{ "WHERE", 0, TK_WHERE, 0 },
{ "ABORT", TK_ABORT, },
{ "AFTER", TK_AFTER, },
{ "ALL", TK_ALL, },
{ "AND", TK_AND, },
{ "AS", TK_AS, },
{ "ASC", TK_ASC, },
{ "ATTACH", TK_ATTACH, },
{ "BEFORE", TK_BEFORE, },
{ "BEGIN", TK_BEGIN, },
{ "BETWEEN", TK_BETWEEN, },
{ "BY", TK_BY, },
{ "CASCADE", TK_CASCADE, },
{ "CASE", TK_CASE, },
{ "CHECK", TK_CHECK, },
{ "CLUSTER", TK_CLUSTER, },
{ "COLLATE", TK_COLLATE, },
{ "COMMIT", TK_COMMIT, },
{ "CONFLICT", TK_CONFLICT, },
{ "CONSTRAINT", TK_CONSTRAINT, },
{ "COPY", TK_COPY, },
{ "CREATE", TK_CREATE, },
{ "CROSS", TK_JOIN_KW, },
{ "DATABASE", TK_DATABASE, },
{ "DEFAULT", TK_DEFAULT, },
{ "DEFERRED", TK_DEFERRED, },
{ "DEFERRABLE", TK_DEFERRABLE, },
{ "DELETE", TK_DELETE, },
{ "DELIMITERS", TK_DELIMITERS, },
{ "DESC", TK_DESC, },
{ "DETACH", TK_DETACH, },
{ "DISTINCT", TK_DISTINCT, },
{ "DROP", TK_DROP, },
{ "END", TK_END, },
{ "EACH", TK_EACH, },
{ "ELSE", TK_ELSE, },
{ "EXCEPT", TK_EXCEPT, },
{ "EXPLAIN", TK_EXPLAIN, },
{ "FAIL", TK_FAIL, },
{ "FOR", TK_FOR, },
{ "FOREIGN", TK_FOREIGN, },
{ "FROM", TK_FROM, },
{ "FULL", TK_JOIN_KW, },
{ "GLOB", TK_GLOB, },
{ "GROUP", TK_GROUP, },
{ "HAVING", TK_HAVING, },
{ "IGNORE", TK_IGNORE, },
{ "IMMEDIATE", TK_IMMEDIATE, },
{ "IN", TK_IN, },
{ "INDEX", TK_INDEX, },
{ "INITIALLY", TK_INITIALLY, },
{ "INNER", TK_JOIN_KW, },
{ "INSERT", TK_INSERT, },
{ "INSTEAD", TK_INSTEAD, },
{ "INTERSECT", TK_INTERSECT, },
{ "INTO", TK_INTO, },
{ "IS", TK_IS, },
{ "ISNULL", TK_ISNULL, },
{ "JOIN", TK_JOIN, },
{ "KEY", TK_KEY, },
{ "LEFT", TK_JOIN_KW, },
{ "LIKE", TK_LIKE, },
{ "LIMIT", TK_LIMIT, },
{ "MATCH", TK_MATCH, },
{ "NATURAL", TK_JOIN_KW, },
{ "NOT", TK_NOT, },
{ "NOTNULL", TK_NOTNULL, },
{ "NULL", TK_NULL, },
{ "OF", TK_OF, },
{ "OFFSET", TK_OFFSET, },
{ "ON", TK_ON, },
{ "OR", TK_OR, },
{ "ORDER", TK_ORDER, },
{ "OUTER", TK_JOIN_KW, },
{ "PRAGMA", TK_PRAGMA, },
{ "PRIMARY", TK_PRIMARY, },
{ "RAISE", TK_RAISE, },
{ "REFERENCES", TK_REFERENCES, },
{ "REPLACE", TK_REPLACE, },
{ "RESTRICT", TK_RESTRICT, },
{ "RIGHT", TK_JOIN_KW, },
{ "ROLLBACK", TK_ROLLBACK, },
{ "ROW", TK_ROW, },
{ "SELECT", TK_SELECT, },
{ "SET", TK_SET, },
{ "STATEMENT", TK_STATEMENT, },
{ "TABLE", TK_TABLE, },
{ "TEMP", TK_TEMP, },
{ "TEMPORARY", TK_TEMP, },
{ "THEN", TK_THEN, },
{ "TRANSACTION", TK_TRANSACTION, },
{ "TRIGGER", TK_TRIGGER, },
{ "UNION", TK_UNION, },
{ "UNIQUE", TK_UNIQUE, },
{ "UPDATE", TK_UPDATE, },
{ "USING", TK_USING, },
{ "VACUUM", TK_VACUUM, },
{ "VALUES", TK_VALUES, },
{ "VIEW", TK_VIEW, },
{ "WHEN", TK_WHEN, },
{ "WHERE", TK_WHERE, },
};
/*
** This is the hash table
*/
#define KEY_HASH_SIZE 71
static Keyword *apHashTable[KEY_HASH_SIZE];
#define KEY_HASH_SIZE 101
static u8 aiHashTable[KEY_HASH_SIZE];
/*
@@ -109,28 +152,30 @@ static Keyword *apHashTable[KEY_HASH_SIZE];
** keyword. If it is a keyword, the token code of that keyword is
** returned. If the input is not a keyword, TK_ID is returned.
*/
static int sqliteKeywordCode(const char *z, int n){
int h;
int sqliteKeywordCode(const char *z, int n){
int h, i;
Keyword *p;
if( aKeywordTable[0].len==0 ){
static char needInit = 1;
if( needInit ){
/* Initialize the keyword hash table */
sqliteOsEnterMutex();
if( aKeywordTable[0].len==0 ){
int i;
int n;
n = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]);
for(i=0; i<n; i++){
if( needInit ){
int nk;
nk = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]);
for(i=0; i<nk; i++){
aKeywordTable[i].len = strlen(aKeywordTable[i].zName);
h = sqliteHashNoCase(aKeywordTable[i].zName, aKeywordTable[i].len);
h %= KEY_HASH_SIZE;
aKeywordTable[i].pNext = apHashTable[h];
apHashTable[h] = &aKeywordTable[i];
aKeywordTable[i].iNext = aiHashTable[h];
aiHashTable[h] = i+1;
}
needInit = 0;
}
sqliteOsLeaveMutex();
}
h = sqliteHashNoCase(z, n) % KEY_HASH_SIZE;
for(p=apHashTable[h]; p; p=p->pNext){
for(i=aiHashTable[h]; i; i=p->iNext){
p = &aKeywordTable[i-1];
if( p->len==n && sqliteStrNICmp(p->zName, z, n)==0 ){
return p->tokenType;
}
@@ -140,8 +185,12 @@ static int sqliteKeywordCode(const char *z, int n){
/*
** If X is a character that can be used in an identifier then
** isIdChar[X] will be 1. Otherwise isIdChar[X] will be 0.
** If X is a character that can be used in an identifier and
** X&0x80==0 then isIdChar[X] will be 1. If X&0x80==0x80 then
** X is always an identifier character. (Hence all UTF-8
** characters can be part of an identifier). isIdChar[X] will
** be 0 for every character in the lower 128 ASCII characters
** that cannot be used as part of an identifier.
**
** In this implementation, an identifier can be a string of
** alphabetic characters, digits, and "_" plus any character
@@ -159,32 +208,22 @@ static const char isIdChar[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 8x */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 9x */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Ax */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Bx */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Cx */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Dx */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Ex */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Fx */
};
/*
** Return the length of the token that begins at z[0]. Return
** -1 if the token is (or might be) incomplete. Store the token
** type in *tokenType before returning.
** Return the length of the token that begins at z[0].
** Store the token type in *tokenType before returning.
*/
static int sqliteGetToken(const unsigned char *z, int *tokenType){
int i;
switch( *z ){
case ' ': case '\t': case '\n': case '\f': case '\r': {
for(i=1; z[i] && isspace(z[i]); i++){}
for(i=1; isspace(z[i]); i++){}
*tokenType = TK_SPACE;
return i;
}
case '-': {
if( z[1]==0 ) return -1;
if( z[1]=='-' ){
for(i=2; z[i] && z[i]!='\n'; i++){}
*tokenType = TK_COMMENT;
@@ -214,8 +253,14 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){
return 1;
}
case '/': {
*tokenType = TK_SLASH;
return 1;
if( z[1]!='*' || z[2]==0 ){
*tokenType = TK_SLASH;
return 1;
}
for(i=3; z[i] && (z[i]!='/' || z[i-1]!='*'); i++){}
if( z[i] ) i++;
*tokenType = TK_COMMENT;
return i;
}
case '%': {
*tokenType = TK_REM;
@@ -298,19 +343,16 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){
return i;
}
case '.': {
if( !isdigit(z[1]) ){
*tokenType = TK_DOT;
return 1;
}
/* Fall thru into the next case */
*tokenType = TK_DOT;
return 1;
}
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': {
*tokenType = TK_INTEGER;
for(i=1; z[i] && isdigit(z[i]); i++){}
if( z[i]=='.' ){
i++;
while( z[i] && isdigit(z[i]) ){ i++; }
for(i=1; isdigit(z[i]); i++){}
if( z[i]=='.' && isdigit(z[i+1]) ){
i += 2;
while( isdigit(z[i]) ){ i++; }
*tokenType = TK_FLOAT;
}
if( (z[i]=='e' || z[i]=='E') &&
@@ -319,18 +361,25 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){
)
){
i += 2;
while( z[i] && isdigit(z[i]) ){ i++; }
*tokenType = TK_FLOAT;
}else if( z[0]=='.' ){
while( isdigit(z[i]) ){ i++; }
*tokenType = TK_FLOAT;
}
return i;
}
case '[': {
for(i=1; z[i] && z[i-1]!=']'; i++){}
*tokenType = TK_ID;
return i;
}
case '?': {
*tokenType = TK_VARIABLE;
return 1;
}
default: {
if( !isIdChar[*z] ){
if( (*z&0x80)==0 && !isIdChar[*z] ){
break;
}
for(i=1; isIdChar[z[i]]; i++){}
for(i=1; (z[i]&0x80)!=0 || isIdChar[z[i]]; i++){}
*tokenType = sqliteKeywordCode((char*)z, i);
return i;
}
@@ -346,11 +395,12 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){
** memory obtained from malloc() and *pzErrMsg made to point to that
** error message. Or maybe not.
*/
int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
int sqliteRunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
int nErr = 0;
int i;
void *pEngine;
int once = 1;
int tokenType;
int lastTokenParsed = -1;
sqlite *db = pParse->db;
extern void *sqliteParserAlloc(void*(*)(int));
extern void sqliteParserFree(void*, void(*)(void*));
@@ -359,79 +409,72 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
db->flags &= ~SQLITE_Interrupt;
pParse->rc = SQLITE_OK;
i = 0;
sqliteParseInfoReset(pParse);
pEngine = sqliteParserAlloc((void*(*)(int))malloc);
if( pEngine==0 ){
sqliteSetString(pzErrMsg, "out of memory", 0);
sqliteSetString(pzErrMsg, "out of memory", (char*)0);
return 1;
}
while( sqlite_malloc_failed==0 && nErr==0 && i>=0 && zSql[i]!=0 ){
int tokenType;
if( (db->flags & SQLITE_Interrupt)!=0 ){
pParse->rc = SQLITE_INTERRUPT;
sqliteSetString(pzErrMsg, "interrupt", 0);
break;
}
pParse->sLastToken.dyn = 0;
pParse->zTail = zSql;
while( sqlite_malloc_failed==0 && zSql[i]!=0 ){
assert( i>=0 );
pParse->sLastToken.z = &zSql[i];
assert( pParse->sLastToken.dyn==0 );
pParse->sLastToken.n = sqliteGetToken((unsigned char*)&zSql[i], &tokenType);
i += pParse->sLastToken.n;
if( once ){
pParse->sFirstToken = pParse->sLastToken;
once = 0;
}
switch( tokenType ){
case TK_SPACE:
case TK_COMMENT: {
if( (db->flags & SQLITE_Interrupt)!=0 ){
pParse->rc = SQLITE_INTERRUPT;
sqliteSetString(pzErrMsg, "interrupt", (char*)0);
goto abort_parse;
}
break;
}
case TK_ILLEGAL:
case TK_ILLEGAL: {
sqliteSetNString(pzErrMsg, "unrecognized token: \"", -1,
pParse->sLastToken.z, pParse->sLastToken.n, "\"", 1, 0);
nErr++;
break;
default:
goto abort_parse;
}
case TK_SEMI: {
pParse->zTail = &zSql[i];
/* Fall thru into the default case */
}
default: {
sqliteParser(pEngine, tokenType, pParse->sLastToken, pParse);
if( pParse->zErrMsg && pParse->sErrToken.z ){
sqliteSetNString(pzErrMsg, "near \"", -1,
pParse->sErrToken.z, pParse->sErrToken.n,
"\": ", -1,
pParse->zErrMsg, -1,
0);
nErr++;
sqliteFree(pParse->zErrMsg);
pParse->zErrMsg = 0;
}else if( pParse->rc!=SQLITE_OK ){
sqliteSetString(pzErrMsg, sqlite_error_string(pParse->rc), 0);
nErr++;
lastTokenParsed = tokenType;
if( pParse->rc!=SQLITE_OK ){
goto abort_parse;
}
break;
}
}
}
if( nErr==0 && (db->flags & SQLITE_Interrupt)==0 ){
sqliteParser(pEngine, 0, pParse->sLastToken, pParse);
if( pParse->zErrMsg && pParse->sErrToken.z ){
sqliteSetNString(pzErrMsg, "near \"", -1,
pParse->sErrToken.z, pParse->sErrToken.n,
"\": ", -1,
pParse->zErrMsg, -1,
0);
nErr++;
sqliteFree(pParse->zErrMsg);
pParse->zErrMsg = 0;
abort_parse:
if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){
if( lastTokenParsed!=TK_SEMI ){
sqliteParser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
pParse->zTail = &zSql[i];
}
sqliteParser(pEngine, 0, pParse->sLastToken, pParse);
}
sqliteParserFree(pEngine, free);
if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
sqliteSetString(&pParse->zErrMsg, sqlite_error_string(pParse->rc),
(char*)0);
}
if( pParse->zErrMsg ){
if( pzErrMsg ){
sqliteFree(*pzErrMsg);
if( pzErrMsg && *pzErrMsg==0 ){
*pzErrMsg = pParse->zErrMsg;
}else{
sqliteFree(pParse->zErrMsg);
}
pParse->zErrMsg = 0;
if( !nErr ) nErr++;
}
if( pParse->pVdbe ){
if( pParse->pVdbe && pParse->nErr>0 ){
sqliteVdbeDelete(pParse->pVdbe);
pParse->pVdbe = 0;
}
@@ -439,9 +482,198 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
sqliteDeleteTable(pParse->db, pParse->pNewTable);
pParse->pNewTable = 0;
}
sqliteParseInfoReset(pParse);
if( nErr>0 && pParse->rc==SQLITE_OK ){
if( pParse->pNewTrigger ){
sqliteDeleteTrigger(pParse->pNewTrigger);
pParse->pNewTrigger = 0;
}
if( nErr>0 && (pParse->rc==SQLITE_OK || pParse->rc==SQLITE_DONE) ){
pParse->rc = SQLITE_ERROR;
}
return nErr;
}
/*
** Token types used by the sqlite_complete() routine. See the header
** comments on that procedure for additional information.
*/
#define tkEXPLAIN 0
#define tkCREATE 1
#define tkTEMP 2
#define tkTRIGGER 3
#define tkEND 4
#define tkSEMI 5
#define tkWS 6
#define tkOTHER 7
/*
** Return TRUE if the given SQL string ends in a semicolon.
**
** Special handling is require for CREATE TRIGGER statements.
** Whenever the CREATE TRIGGER keywords are seen, the statement
** must end with ";END;".
**
** This implementation uses a state machine with 7 states:
**
** (0) START At the beginning or end of an SQL statement. This routine
** returns 1 if it ends in the START state and 0 if it ends
** in any other state.
**
** (1) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
** a statement.
**
** (2) CREATE The keyword CREATE has been seen at the beginning of a
** statement, possibly preceeded by EXPLAIN and/or followed by
** TEMP or TEMPORARY
**
** (3) NORMAL We are in the middle of statement which ends with a single
** semicolon.
**
** (4) TRIGGER We are in the middle of a trigger definition that must be
** ended by a semicolon, the keyword END, and another semicolon.
**
** (5) SEMI We've seen the first semicolon in the ";END;" that occurs at
** the end of a trigger definition.
**
** (6) END We've seen the ";END" of the ";END;" that occurs at the end
** of a trigger difinition.
**
** Transitions between states above are determined by tokens extracted
** from the input. The following tokens are significant:
**
** (0) tkEXPLAIN The "explain" keyword.
** (1) tkCREATE The "create" keyword.
** (2) tkTEMP The "temp" or "temporary" keyword.
** (3) tkTRIGGER The "trigger" keyword.
** (4) tkEND The "end" keyword.
** (5) tkSEMI A semicolon.
** (6) tkWS Whitespace
** (7) tkOTHER Any other SQL token.
**
** Whitespace never causes a state transition and is always ignored.
*/
int sqlite_complete(const char *zSql){
u8 state = 0; /* Current state, using numbers defined in header comment */
u8 token; /* Value of the next token */
/* The following matrix defines the transition from one state to another
** according to what token is seen. trans[state][token] returns the
** next state.
*/
static const u8 trans[7][8] = {
/* Token: */
/* State: ** EXPLAIN CREATE TEMP TRIGGER END SEMI WS OTHER */
/* 0 START: */ { 1, 2, 3, 3, 3, 0, 0, 3, },
/* 1 EXPLAIN: */ { 3, 2, 3, 3, 3, 0, 1, 3, },
/* 2 CREATE: */ { 3, 3, 2, 4, 3, 0, 2, 3, },
/* 3 NORMAL: */ { 3, 3, 3, 3, 3, 0, 3, 3, },
/* 4 TRIGGER: */ { 4, 4, 4, 4, 4, 5, 4, 4, },
/* 5 SEMI: */ { 4, 4, 4, 4, 6, 5, 5, 4, },
/* 6 END: */ { 4, 4, 4, 4, 4, 0, 6, 4, },
};
while( *zSql ){
switch( *zSql ){
case ';': { /* A semicolon */
token = tkSEMI;
break;
}
case ' ':
case '\r':
case '\t':
case '\n':
case '\f': { /* White space is ignored */
token = tkWS;
break;
}
case '/': { /* C-style comments */
if( zSql[1]!='*' ){
token = tkOTHER;
break;
}
zSql += 2;
while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
if( zSql[0]==0 ) return 0;
zSql++;
token = tkWS;
break;
}
case '-': { /* SQL-style comments from "--" to end of line */
if( zSql[1]!='-' ){
token = tkOTHER;
break;
}
while( *zSql && *zSql!='\n' ){ zSql++; }
if( *zSql==0 ) return state==0;
token = tkWS;
break;
}
case '[': { /* Microsoft-style identifiers in [...] */
zSql++;
while( *zSql && *zSql!=']' ){ zSql++; }
if( *zSql==0 ) return 0;
token = tkOTHER;
break;
}
case '"': /* single- and double-quoted strings */
case '\'': {
int c = *zSql;
zSql++;
while( *zSql && *zSql!=c ){ zSql++; }
if( *zSql==0 ) return 0;
token = tkOTHER;
break;
}
default: {
if( isIdChar[(u8)*zSql] ){
/* Keywords and unquoted identifiers */
int nId;
for(nId=1; isIdChar[(u8)zSql[nId]]; nId++){}
switch( *zSql ){
case 'c': case 'C': {
if( nId==6 && sqliteStrNICmp(zSql, "create", 6)==0 ){
token = tkCREATE;
}else{
token = tkOTHER;
}
break;
}
case 't': case 'T': {
if( nId==7 && sqliteStrNICmp(zSql, "trigger", 7)==0 ){
token = tkTRIGGER;
}else if( nId==4 && sqliteStrNICmp(zSql, "temp", 4)==0 ){
token = tkTEMP;
}else if( nId==9 && sqliteStrNICmp(zSql, "temporary", 9)==0 ){
token = tkTEMP;
}else{
token = tkOTHER;
}
break;
}
case 'e': case 'E': {
if( nId==3 && sqliteStrNICmp(zSql, "end", 3)==0 ){
token = tkEND;
}else if( nId==7 && sqliteStrNICmp(zSql, "explain", 7)==0 ){
token = tkEXPLAIN;
}else{
token = tkOTHER;
}
break;
}
default: {
token = tkOTHER;
break;
}
}
zSql += nId-1;
}else{
/* Operators and special symbols */
token = tkOTHER;
}
break;
}
}
state = trans[state][token];
zSql++;
}
return state==0;
}
+764
View File
@@ -0,0 +1,764 @@
/*
**
** 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.
**
*************************************************************************
*
*/
#include "sqliteInt.h"
/*
** Delete a linked list of TriggerStep structures.
*/
void sqliteDeleteTriggerStep(TriggerStep *pTriggerStep){
while( pTriggerStep ){
TriggerStep * pTmp = pTriggerStep;
pTriggerStep = pTriggerStep->pNext;
if( pTmp->target.dyn ) sqliteFree((char*)pTmp->target.z);
sqliteExprDelete(pTmp->pWhere);
sqliteExprListDelete(pTmp->pExprList);
sqliteSelectDelete(pTmp->pSelect);
sqliteIdListDelete(pTmp->pIdList);
sqliteFree(pTmp);
}
}
/*
** This is called by the parser when it sees a CREATE TRIGGER statement
** up to the point of the BEGIN before the trigger actions. A Trigger
** structure is generated based on the information available and stored
** in pParse->pNewTrigger. After the trigger actions have been parsed, the
** sqliteFinishTrigger() function is called to complete the trigger
** construction process.
*/
void sqliteBeginTrigger(
Parse *pParse, /* The parse context of the CREATE TRIGGER statement */
Token *pName, /* The name of the trigger */
int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
IdList *pColumns, /* column list if this is an UPDATE OF trigger */
SrcList *pTableName,/* The name of the table/view the trigger applies to */
int foreach, /* One of TK_ROW or TK_STATEMENT */
Expr *pWhen, /* WHEN clause */
int isTemp /* True if the TEMPORARY keyword is present */
){
Trigger *nt;
Table *tab;
char *zName = 0; /* Name of the trigger */
sqlite *db = pParse->db;
int iDb; /* When database to store the trigger in */
DbFixer sFix;
/* Check that:
** 1. the trigger name does not already exist.
** 2. the table (or view) does exist in the same database as the trigger.
** 3. that we are not trying to create a trigger on the sqlite_master table
** 4. That we are not trying to create an INSTEAD OF trigger on a table.
** 5. That we are not trying to create a BEFORE or AFTER trigger on a view.
*/
if( sqlite_malloc_failed ) goto trigger_cleanup;
assert( pTableName->nSrc==1 );
if( db->init.busy
&& sqliteFixInit(&sFix, pParse, db->init.iDb, "trigger", pName)
&& sqliteFixSrcList(&sFix, pTableName)
){
goto trigger_cleanup;
}
tab = sqliteSrcListLookup(pParse, pTableName);
if( !tab ){
goto trigger_cleanup;
}
iDb = isTemp ? 1 : tab->iDb;
if( iDb>=2 && !db->init.busy ){
sqliteErrorMsg(pParse, "triggers may not be added to auxiliary "
"database %s", db->aDb[tab->iDb].zName);
goto trigger_cleanup;
}
zName = sqliteStrNDup(pName->z, pName->n);
sqliteDequote(zName);
if( sqliteHashFind(&(db->aDb[iDb].trigHash), zName,pName->n+1) ){
sqliteErrorMsg(pParse, "trigger %T already exists", pName);
goto trigger_cleanup;
}
if( sqliteStrNICmp(tab->zName, "sqlite_", 7)==0 ){
sqliteErrorMsg(pParse, "cannot create trigger on system table");
pParse->nErr++;
goto trigger_cleanup;
}
if( tab->pSelect && tr_tm != TK_INSTEAD ){
sqliteErrorMsg(pParse, "cannot create %s trigger on view: %S",
(tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);
goto trigger_cleanup;
}
if( !tab->pSelect && tr_tm == TK_INSTEAD ){
sqliteErrorMsg(pParse, "cannot create INSTEAD OF"
" trigger on table: %S", pTableName, 0);
goto trigger_cleanup;
}
#ifndef SQLITE_OMIT_AUTHORIZATION
{
int code = SQLITE_CREATE_TRIGGER;
const char *zDb = db->aDb[tab->iDb].zName;
const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;
if( tab->iDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;
if( sqliteAuthCheck(pParse, code, zName, tab->zName, zDbTrig) ){
goto trigger_cleanup;
}
if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(tab->iDb), 0, zDb)){
goto trigger_cleanup;
}
}
#endif
/* INSTEAD OF triggers can only appear on views and BEGIN triggers
** cannot appear on views. So we might as well translate every
** INSTEAD OF trigger into a BEFORE trigger. It simplifies code
** elsewhere.
*/
if (tr_tm == TK_INSTEAD){
tr_tm = TK_BEFORE;
}
/* Build the Trigger object */
nt = (Trigger*)sqliteMalloc(sizeof(Trigger));
if( nt==0 ) goto trigger_cleanup;
nt->name = zName;
zName = 0;
nt->table = sqliteStrDup(pTableName->a[0].zName);
if( sqlite_malloc_failed ) goto trigger_cleanup;
nt->iDb = iDb;
nt->iTabDb = tab->iDb;
nt->op = op;
nt->tr_tm = tr_tm;
nt->pWhen = sqliteExprDup(pWhen);
nt->pColumns = sqliteIdListDup(pColumns);
nt->foreach = foreach;
sqliteTokenCopy(&nt->nameToken,pName);
assert( pParse->pNewTrigger==0 );
pParse->pNewTrigger = nt;
trigger_cleanup:
sqliteFree(zName);
sqliteSrcListDelete(pTableName);
sqliteIdListDelete(pColumns);
sqliteExprDelete(pWhen);
}
/*
** This routine is called after all of the trigger actions have been parsed
** in order to complete the process of building the trigger.
*/
void sqliteFinishTrigger(
Parse *pParse, /* Parser context */
TriggerStep *pStepList, /* The triggered program */
Token *pAll /* Token that describes the complete CREATE TRIGGER */
){
Trigger *nt = 0; /* The trigger whose construction is finishing up */
sqlite *db = pParse->db; /* The database */
DbFixer sFix;
if( pParse->nErr || pParse->pNewTrigger==0 ) goto triggerfinish_cleanup;
nt = pParse->pNewTrigger;
pParse->pNewTrigger = 0;
nt->step_list = pStepList;
while( pStepList ){
pStepList->pTrig = nt;
pStepList = pStepList->pNext;
}
if( sqliteFixInit(&sFix, pParse, nt->iDb, "trigger", &nt->nameToken)
&& sqliteFixTriggerStep(&sFix, nt->step_list) ){
goto triggerfinish_cleanup;
}
/* if we are not initializing, and this trigger is not on a TEMP table,
** build the sqlite_master entry
*/
if( !db->init.busy ){
static VdbeOpList insertTrig[] = {
{ OP_NewRecno, 0, 0, 0 },
{ OP_String, 0, 0, "trigger" },
{ OP_String, 0, 0, 0 }, /* 2: trigger name */
{ OP_String, 0, 0, 0 }, /* 3: table name */
{ OP_Integer, 0, 0, 0 },
{ OP_String, 0, 0, 0 }, /* 5: SQL */
{ OP_MakeRecord, 5, 0, 0 },
{ OP_PutIntKey, 0, 0, 0 },
};
int addr;
Vdbe *v;
/* Make an entry in the sqlite_master table */
v = sqliteGetVdbe(pParse);
if( v==0 ) goto triggerfinish_cleanup;
sqliteBeginWriteOperation(pParse, 0, 0);
sqliteOpenMasterTable(v, nt->iDb);
addr = sqliteVdbeAddOpList(v, ArraySize(insertTrig), insertTrig);
sqliteVdbeChangeP3(v, addr+2, nt->name, 0);
sqliteVdbeChangeP3(v, addr+3, nt->table, 0);
sqliteVdbeChangeP3(v, addr+5, pAll->z, pAll->n);
if( nt->iDb==0 ){
sqliteChangeCookie(db, v);
}
sqliteVdbeAddOp(v, OP_Close, 0, 0);
sqliteEndWriteOperation(pParse);
}
if( !pParse->explain ){
Table *pTab;
sqliteHashInsert(&db->aDb[nt->iDb].trigHash,
nt->name, strlen(nt->name)+1, nt);
pTab = sqliteLocateTable(pParse, nt->table, db->aDb[nt->iTabDb].zName);
assert( pTab!=0 );
nt->pNext = pTab->pTrigger;
pTab->pTrigger = nt;
nt = 0;
}
triggerfinish_cleanup:
sqliteDeleteTrigger(nt);
sqliteDeleteTrigger(pParse->pNewTrigger);
pParse->pNewTrigger = 0;
sqliteDeleteTriggerStep(pStepList);
}
/*
** Make a copy of all components of the given trigger step. This has
** the effect of copying all Expr.token.z values into memory obtained
** from sqliteMalloc(). As initially created, the Expr.token.z values
** all point to the input string that was fed to the parser. But that
** string is ephemeral - it will go away as soon as the sqlite_exec()
** call that started the parser exits. This routine makes a persistent
** copy of all the Expr.token.z strings so that the TriggerStep structure
** will be valid even after the sqlite_exec() call returns.
*/
static void sqlitePersistTriggerStep(TriggerStep *p){
if( p->target.z ){
p->target.z = sqliteStrNDup(p->target.z, p->target.n);
p->target.dyn = 1;
}
if( p->pSelect ){
Select *pNew = sqliteSelectDup(p->pSelect);
sqliteSelectDelete(p->pSelect);
p->pSelect = pNew;
}
if( p->pWhere ){
Expr *pNew = sqliteExprDup(p->pWhere);
sqliteExprDelete(p->pWhere);
p->pWhere = pNew;
}
if( p->pExprList ){
ExprList *pNew = sqliteExprListDup(p->pExprList);
sqliteExprListDelete(p->pExprList);
p->pExprList = pNew;
}
if( p->pIdList ){
IdList *pNew = sqliteIdListDup(p->pIdList);
sqliteIdListDelete(p->pIdList);
p->pIdList = pNew;
}
}
/*
** Turn a SELECT statement (that the pSelect parameter points to) into
** a trigger step. Return a pointer to a TriggerStep structure.
**
** The parser calls this routine when it finds a SELECT statement in
** body of a TRIGGER.
*/
TriggerStep *sqliteTriggerSelectStep(Select *pSelect){
TriggerStep *pTriggerStep = sqliteMalloc(sizeof(TriggerStep));
if( pTriggerStep==0 ) return 0;
pTriggerStep->op = TK_SELECT;
pTriggerStep->pSelect = pSelect;
pTriggerStep->orconf = OE_Default;
sqlitePersistTriggerStep(pTriggerStep);
return pTriggerStep;
}
/*
** Build a trigger step out of an INSERT statement. Return a pointer
** to the new trigger step.
**
** The parser calls this routine when it sees an INSERT inside the
** body of a trigger.
*/
TriggerStep *sqliteTriggerInsertStep(
Token *pTableName, /* Name of the table into which we insert */
IdList *pColumn, /* List of columns in pTableName to insert into */
ExprList *pEList, /* The VALUE clause: a list of values to be inserted */
Select *pSelect, /* A SELECT statement that supplies values */
int orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
){
TriggerStep *pTriggerStep = sqliteMalloc(sizeof(TriggerStep));
if( pTriggerStep==0 ) return 0;
assert(pEList == 0 || pSelect == 0);
assert(pEList != 0 || pSelect != 0);
pTriggerStep->op = TK_INSERT;
pTriggerStep->pSelect = pSelect;
pTriggerStep->target = *pTableName;
pTriggerStep->pIdList = pColumn;
pTriggerStep->pExprList = pEList;
pTriggerStep->orconf = orconf;
sqlitePersistTriggerStep(pTriggerStep);
return pTriggerStep;
}
/*
** Construct a trigger step that implements an UPDATE statement and return
** a pointer to that trigger step. The parser calls this routine when it
** sees an UPDATE statement inside the body of a CREATE TRIGGER.
*/
TriggerStep *sqliteTriggerUpdateStep(
Token *pTableName, /* Name of the table to be updated */
ExprList *pEList, /* The SET clause: list of column and new values */
Expr *pWhere, /* The WHERE clause */
int orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
){
TriggerStep *pTriggerStep = sqliteMalloc(sizeof(TriggerStep));
if( pTriggerStep==0 ) return 0;
pTriggerStep->op = TK_UPDATE;
pTriggerStep->target = *pTableName;
pTriggerStep->pExprList = pEList;
pTriggerStep->pWhere = pWhere;
pTriggerStep->orconf = orconf;
sqlitePersistTriggerStep(pTriggerStep);
return pTriggerStep;
}
/*
** Construct a trigger step that implements a DELETE statement and return
** a pointer to that trigger step. The parser calls this routine when it
** sees a DELETE statement inside the body of a CREATE TRIGGER.
*/
TriggerStep *sqliteTriggerDeleteStep(Token *pTableName, Expr *pWhere){
TriggerStep *pTriggerStep = sqliteMalloc(sizeof(TriggerStep));
if( pTriggerStep==0 ) return 0;
pTriggerStep->op = TK_DELETE;
pTriggerStep->target = *pTableName;
pTriggerStep->pWhere = pWhere;
pTriggerStep->orconf = OE_Default;
sqlitePersistTriggerStep(pTriggerStep);
return pTriggerStep;
}
/*
** Recursively delete a Trigger structure
*/
void sqliteDeleteTrigger(Trigger *pTrigger){
if( pTrigger==0 ) return;
sqliteDeleteTriggerStep(pTrigger->step_list);
sqliteFree(pTrigger->name);
sqliteFree(pTrigger->table);
sqliteExprDelete(pTrigger->pWhen);
sqliteIdListDelete(pTrigger->pColumns);
if( pTrigger->nameToken.dyn ) sqliteFree((char*)pTrigger->nameToken.z);
sqliteFree(pTrigger);
}
/*
* This function is called to drop a trigger from the database schema.
*
* This may be called directly from the parser and therefore identifies
* the trigger by name. The sqliteDropTriggerPtr() routine does the
* same job as this routine except it take a spointer to the trigger
* instead of the trigger name.
*
* Note that this function does not delete the trigger entirely. Instead it
* removes it from the internal schema and places it in the trigDrop hash
* table. This is so that the trigger can be restored into the database schema
* if the transaction is rolled back.
*/
void sqliteDropTrigger(Parse *pParse, SrcList *pName){
Trigger *pTrigger;
int i;
const char *zDb;
const char *zName;
int nName;
sqlite *db = pParse->db;
if( sqlite_malloc_failed ) goto drop_trigger_cleanup;
assert( pName->nSrc==1 );
zDb = pName->a[0].zDatabase;
zName = pName->a[0].zName;
nName = strlen(zName);
for(i=0; i<db->nDb; i++){
int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
if( zDb && sqliteStrICmp(db->aDb[j].zName, zDb) ) continue;
pTrigger = sqliteHashFind(&(db->aDb[j].trigHash), zName, nName+1);
if( pTrigger ) break;
}
if( !pTrigger ){
sqliteErrorMsg(pParse, "no such trigger: %S", pName, 0);
goto drop_trigger_cleanup;
}
sqliteDropTriggerPtr(pParse, pTrigger, 0);
drop_trigger_cleanup:
sqliteSrcListDelete(pName);
}
/*
** Drop a trigger given a pointer to that trigger. If nested is false,
** then also generate code to remove the trigger from the SQLITE_MASTER
** table.
*/
void sqliteDropTriggerPtr(Parse *pParse, Trigger *pTrigger, int nested){
Table *pTable;
Vdbe *v;
sqlite *db = pParse->db;
assert( pTrigger->iDb<db->nDb );
if( pTrigger->iDb>=2 ){
sqliteErrorMsg(pParse, "triggers may not be removed from "
"auxiliary database %s", db->aDb[pTrigger->iDb].zName);
return;
}
pTable = sqliteFindTable(db, pTrigger->table,db->aDb[pTrigger->iTabDb].zName);
assert(pTable);
assert( pTable->iDb==pTrigger->iDb || pTrigger->iDb==1 );
#ifndef SQLITE_OMIT_AUTHORIZATION
{
int code = SQLITE_DROP_TRIGGER;
const char *zDb = db->aDb[pTrigger->iDb].zName;
const char *zTab = SCHEMA_TABLE(pTrigger->iDb);
if( pTrigger->iDb ) code = SQLITE_DROP_TEMP_TRIGGER;
if( sqliteAuthCheck(pParse, code, pTrigger->name, pTable->zName, zDb) ||
sqliteAuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
return;
}
}
#endif
/* Generate code to destroy the database record of the trigger.
*/
if( pTable!=0 && !nested && (v = sqliteGetVdbe(pParse))!=0 ){
int base;
static VdbeOpList dropTrigger[] = {
{ OP_Rewind, 0, ADDR(9), 0},
{ OP_String, 0, 0, 0}, /* 1 */
{ OP_Column, 0, 1, 0},
{ OP_Ne, 0, ADDR(8), 0},
{ OP_String, 0, 0, "trigger"},
{ OP_Column, 0, 0, 0},
{ OP_Ne, 0, ADDR(8), 0},
{ OP_Delete, 0, 0, 0},
{ OP_Next, 0, ADDR(1), 0}, /* 8 */
};
sqliteBeginWriteOperation(pParse, 0, 0);
sqliteOpenMasterTable(v, pTrigger->iDb);
base = sqliteVdbeAddOpList(v, ArraySize(dropTrigger), dropTrigger);
sqliteVdbeChangeP3(v, base+1, pTrigger->name, 0);
if( pTrigger->iDb==0 ){
sqliteChangeCookie(db, v);
}
sqliteVdbeAddOp(v, OP_Close, 0, 0);
sqliteEndWriteOperation(pParse);
}
/*
* If this is not an "explain", then delete the trigger structure.
*/
if( !pParse->explain ){
const char *zName = pTrigger->name;
int nName = strlen(zName);
if( pTable->pTrigger == pTrigger ){
pTable->pTrigger = pTrigger->pNext;
}else{
Trigger *cc = pTable->pTrigger;
while( cc ){
if( cc->pNext == pTrigger ){
cc->pNext = cc->pNext->pNext;
break;
}
cc = cc->pNext;
}
assert(cc);
}
sqliteHashInsert(&(db->aDb[pTrigger->iDb].trigHash), zName, nName+1, 0);
sqliteDeleteTrigger(pTrigger);
}
}
/*
** pEList is the SET clause of an UPDATE statement. Each entry
** in pEList is of the format <id>=<expr>. If any of the entries
** in pEList have an <id> which matches an identifier in pIdList,
** then return TRUE. If pIdList==NULL, then it is considered a
** wildcard that matches anything. Likewise if pEList==NULL then
** it matches anything so always return true. Return false only
** if there is no match.
*/
static int checkColumnOverLap(IdList *pIdList, ExprList *pEList){
int e;
if( !pIdList || !pEList ) return 1;
for(e=0; e<pEList->nExpr; e++){
if( sqliteIdListIndex(pIdList, pEList->a[e].zName)>=0 ) return 1;
}
return 0;
}
/* A global variable that is TRUE if we should always set up temp tables for
* for triggers, even if there are no triggers to code. This is used to test
* how much overhead the triggers algorithm is causing.
*
* This flag can be set or cleared using the "trigger_overhead_test" pragma.
* The pragma is not documented since it is not really part of the interface
* to SQLite, just the test procedure.
*/
int always_code_trigger_setup = 0;
/*
* Returns true if a trigger matching op, tr_tm and foreach that is NOT already
* on the Parse objects trigger-stack (to prevent recursive trigger firing) is
* found in the list specified as pTrigger.
*/
int sqliteTriggersExist(
Parse *pParse, /* Used to check for recursive triggers */
Trigger *pTrigger, /* A list of triggers associated with a table */
int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */
int tr_tm, /* one of TK_BEFORE, TK_AFTER */
int foreach, /* one of TK_ROW or TK_STATEMENT */
ExprList *pChanges /* Columns that change in an UPDATE statement */
){
Trigger * pTriggerCursor;
if( always_code_trigger_setup ){
return 1;
}
pTriggerCursor = pTrigger;
while( pTriggerCursor ){
if( pTriggerCursor->op == op &&
pTriggerCursor->tr_tm == tr_tm &&
pTriggerCursor->foreach == foreach &&
checkColumnOverLap(pTriggerCursor->pColumns, pChanges) ){
TriggerStack * ss;
ss = pParse->trigStack;
while( ss && ss->pTrigger != pTrigger ){
ss = ss->pNext;
}
if( !ss )return 1;
}
pTriggerCursor = pTriggerCursor->pNext;
}
return 0;
}
/*
** Convert the pStep->target token into a SrcList and return a pointer
** to that SrcList.
**
** This routine adds a specific database name, if needed, to the target when
** forming the SrcList. This prevents a trigger in one database from
** referring to a target in another database. An exception is when the
** trigger is in TEMP in which case it can refer to any other database it
** wants.
*/
static SrcList *targetSrcList(
Parse *pParse, /* The parsing context */
TriggerStep *pStep /* The trigger containing the target token */
){
Token sDb; /* Dummy database name token */
int iDb; /* Index of the database to use */
SrcList *pSrc; /* SrcList to be returned */
iDb = pStep->pTrig->iDb;
if( iDb==0 || iDb>=2 ){
assert( iDb<pParse->db->nDb );
sDb.z = pParse->db->aDb[iDb].zName;
sDb.n = strlen(sDb.z);
pSrc = sqliteSrcListAppend(0, &sDb, &pStep->target);
} else {
pSrc = sqliteSrcListAppend(0, &pStep->target, 0);
}
return pSrc;
}
/*
** Generate VDBE code for zero or more statements inside the body of a
** trigger.
*/
static int codeTriggerProgram(
Parse *pParse, /* The parser context */
TriggerStep *pStepList, /* List of statements inside the trigger body */
int orconfin /* Conflict algorithm. (OE_Abort, etc) */
){
TriggerStep * pTriggerStep = pStepList;
int orconf;
while( pTriggerStep ){
int saveNTab = pParse->nTab;
orconf = (orconfin == OE_Default)?pTriggerStep->orconf:orconfin;
pParse->trigStack->orconf = orconf;
switch( pTriggerStep->op ){
case TK_SELECT: {
Select * ss = sqliteSelectDup(pTriggerStep->pSelect);
assert(ss);
assert(ss->pSrc);
sqliteSelect(pParse, ss, SRT_Discard, 0, 0, 0, 0);
sqliteSelectDelete(ss);
break;
}
case TK_UPDATE: {
SrcList *pSrc;
pSrc = targetSrcList(pParse, pTriggerStep);
sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0);
sqliteUpdate(pParse, pSrc,
sqliteExprListDup(pTriggerStep->pExprList),
sqliteExprDup(pTriggerStep->pWhere), orconf);
sqliteVdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0);
break;
}
case TK_INSERT: {
SrcList *pSrc;
pSrc = targetSrcList(pParse, pTriggerStep);
sqliteInsert(pParse, pSrc,
sqliteExprListDup(pTriggerStep->pExprList),
sqliteSelectDup(pTriggerStep->pSelect),
sqliteIdListDup(pTriggerStep->pIdList), orconf);
break;
}
case TK_DELETE: {
SrcList *pSrc;
sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0);
pSrc = targetSrcList(pParse, pTriggerStep);
sqliteDeleteFrom(pParse, pSrc, sqliteExprDup(pTriggerStep->pWhere));
sqliteVdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0);
break;
}
default:
assert(0);
}
pParse->nTab = saveNTab;
pTriggerStep = pTriggerStep->pNext;
}
return 0;
}
/*
** This is called to code FOR EACH ROW triggers.
**
** When the code that this function generates is executed, the following
** must be true:
**
** 1. No cursors may be open in the main database. (But newIdx and oldIdx
** can be indices of cursors in temporary tables. See below.)
**
** 2. If the triggers being coded are ON INSERT or ON UPDATE triggers, then
** a temporary vdbe cursor (index newIdx) must be open and pointing at
** a row containing values to be substituted for new.* expressions in the
** trigger program(s).
**
** 3. If the triggers being coded are ON DELETE or ON UPDATE triggers, then
** a temporary vdbe cursor (index oldIdx) must be open and pointing at
** a row containing values to be substituted for old.* expressions in the
** trigger program(s).
**
*/
int sqliteCodeRowTrigger(
Parse *pParse, /* Parse context */
int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */
ExprList *pChanges, /* Changes list for any UPDATE OF triggers */
int tr_tm, /* One of TK_BEFORE, TK_AFTER */
Table *pTab, /* The table to code triggers from */
int newIdx, /* The indice of the "new" row to access */
int oldIdx, /* The indice of the "old" row to access */
int orconf, /* ON CONFLICT policy */
int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
){
Trigger * pTrigger;
TriggerStack * pTriggerStack;
assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE);
assert(tr_tm == TK_BEFORE || tr_tm == TK_AFTER );
assert(newIdx != -1 || oldIdx != -1);
pTrigger = pTab->pTrigger;
while( pTrigger ){
int fire_this = 0;
/* determine whether we should code this trigger */
if( pTrigger->op == op && pTrigger->tr_tm == tr_tm &&
pTrigger->foreach == TK_ROW ){
fire_this = 1;
pTriggerStack = pParse->trigStack;
while( pTriggerStack ){
if( pTriggerStack->pTrigger == pTrigger ){
fire_this = 0;
}
pTriggerStack = pTriggerStack->pNext;
}
if( op == TK_UPDATE && pTrigger->pColumns &&
!checkColumnOverLap(pTrigger->pColumns, pChanges) ){
fire_this = 0;
}
}
if( fire_this && (pTriggerStack = sqliteMalloc(sizeof(TriggerStack)))!=0 ){
int endTrigger;
SrcList dummyTablist;
Expr * whenExpr;
AuthContext sContext;
dummyTablist.nSrc = 0;
/* Push an entry on to the trigger stack */
pTriggerStack->pTrigger = pTrigger;
pTriggerStack->newIdx = newIdx;
pTriggerStack->oldIdx = oldIdx;
pTriggerStack->pTab = pTab;
pTriggerStack->pNext = pParse->trigStack;
pTriggerStack->ignoreJump = ignoreJump;
pParse->trigStack = pTriggerStack;
sqliteAuthContextPush(pParse, &sContext, pTrigger->name);
/* code the WHEN clause */
endTrigger = sqliteVdbeMakeLabel(pParse->pVdbe);
whenExpr = sqliteExprDup(pTrigger->pWhen);
if( sqliteExprResolveIds(pParse, &dummyTablist, 0, whenExpr) ){
pParse->trigStack = pParse->trigStack->pNext;
sqliteFree(pTriggerStack);
sqliteExprDelete(whenExpr);
return 1;
}
sqliteExprIfFalse(pParse, whenExpr, endTrigger, 1);
sqliteExprDelete(whenExpr);
sqliteVdbeAddOp(pParse->pVdbe, OP_ContextPush, 0, 0);
codeTriggerProgram(pParse, pTrigger->step_list, orconf);
sqliteVdbeAddOp(pParse->pVdbe, OP_ContextPop, 0, 0);
/* Pop the entry off the trigger stack */
pParse->trigStack = pParse->trigStack->pNext;
sqliteAuthContextPop(&sContext);
sqliteFree(pTriggerStack);
sqliteVdbeResolveLabel(pParse->pVdbe, endTrigger);
}
pTrigger = pTrigger->pNext;
}
return 0;
}
+335 -134
View File
@@ -12,85 +12,109 @@
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
** $Id: update.c,v 1.19 2001/10/15 00:44:36 drh Exp $
** $Id: update.c,v 1.70.2.1 2004/04/29 16:16:29 drh Exp $
*/
#include "sqliteInt.h"
/*
** Process an UPDATE statement.
**
** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
** \_______/ \________/ \______/ \________________/
* onError pTabList pChanges pWhere
*/
void sqliteUpdate(
Parse *pParse, /* The parser context */
Token *pTableName, /* The table in which we should change things */
SrcList *pTabList, /* The table in which we should change things */
ExprList *pChanges, /* Things to be changed */
Expr *pWhere /* The WHERE clause. May be null */
Expr *pWhere, /* The WHERE clause. May be null */
int onError /* How to handle constraint errors */
){
int i, j; /* Loop counters */
Table *pTab; /* The table to be updated */
IdList *pTabList = 0; /* List containing only pTab */
int end, addr; /* A couple of addresses in the generated code */
int loopStart; /* VDBE instruction address of the start of the loop */
int jumpInst; /* Addr of VDBE instruction to jump out of loop */
WhereInfo *pWInfo; /* Information about the WHERE clause */
Vdbe *v; /* The virtual database engine */
Index *pIdx; /* For looping over indices */
int nIdx; /* Number of indices that need updating */
int base; /* Index of first available table cursor */
int nIdxTotal; /* Total number of indices */
int iCur; /* VDBE Cursor number of pTab */
sqlite *db; /* The database structure */
Index **apIdx = 0; /* An array of indices that need updating too */
char *aIdxUsed = 0; /* aIdxUsed[i]==1 if the i-th index is used */
int *aXRef = 0; /* aXRef[i] is the index in pChanges->a[] of the
** an expression for the i-th column of the table.
** aXRef[i]==-1 if the i-th column is not changed. */
int openOp; /* Opcode used to open tables */
int chngRecno; /* True if the record number is being changed */
Expr *pRecnoExpr; /* Expression defining the new record number */
int openAll; /* True if all indices need to be opened */
int isView; /* Trying to update a view */
int iStackDepth; /* Index of memory cell holding stack depth */
AuthContext sContext; /* The authorization context */
int before_triggers; /* True if there are any BEFORE triggers */
int after_triggers; /* True if there are any AFTER triggers */
int row_triggers_exist = 0; /* True if any row triggers exist */
int newIdx = -1; /* index of trigger "new" temp table */
int oldIdx = -1; /* index of trigger "old" temp table */
sContext.pParse = 0;
if( pParse->nErr || sqlite_malloc_failed ) goto update_cleanup;
db = pParse->db;
assert( pTabList->nSrc==1 );
iStackDepth = pParse->nMem++;
/* Locate the table which we want to update. This table has to be
** put in an IdList structure because some of the subroutines we
** will be calling are designed to work with multiple tables and expect
** an IdList* parameter instead of just a Table* parameger.
/* Locate the table which we want to update.
*/
pTabList = sqliteIdListAppend(0, pTableName);
if( pTabList==0 ) goto update_cleanup;
for(i=0; i<pTabList->nId; i++){
pTabList->a[i].pTab = sqliteFindTable(db, pTabList->a[i].zName);
if( pTabList->a[i].pTab==0 ){
sqliteSetString(&pParse->zErrMsg, "no such table: ",
pTabList->a[i].zName, 0);
pParse->nErr++;
goto update_cleanup;
}
if( pTabList->a[i].pTab->readOnly ){
sqliteSetString(&pParse->zErrMsg, "table ", pTabList->a[i].zName,
" may not be modified", 0);
pParse->nErr++;
pTab = sqliteSrcListLookup(pParse, pTabList);
if( pTab==0 ) goto update_cleanup;
before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,
TK_UPDATE, TK_BEFORE, TK_ROW, pChanges);
after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,
TK_UPDATE, TK_AFTER, TK_ROW, pChanges);
row_triggers_exist = before_triggers || after_triggers;
isView = pTab->pSelect!=0;
if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){
goto update_cleanup;
}
if( isView ){
if( sqliteViewGetColumnNames(pParse, pTab) ){
goto update_cleanup;
}
}
pTab = pTabList->a[0].pTab;
aXRef = sqliteMalloc( sizeof(int) * pTab->nCol );
if( aXRef==0 ) goto update_cleanup;
for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;
/* Resolve the column names in all the expressions in both the
** WHERE clause and in the new values. Also find the column index
** for each column to be updated in the pChanges array.
/* If there are FOR EACH ROW triggers, allocate cursors for the
** special OLD and NEW tables
*/
if( pWhere ){
sqliteExprResolveInSelect(pParse, pWhere);
if( row_triggers_exist ){
newIdx = pParse->nTab++;
oldIdx = pParse->nTab++;
}
/* Allocate a cursors for the main database table and for all indices.
** The index cursors might not be used, but if they are used they
** need to occur right after the database cursor. So go ahead and
** allocate enough space, just in case.
*/
pTabList->a[0].iCursor = iCur = pParse->nTab++;
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
pParse->nTab++;
}
/* Resolve the column names in all the expressions of the
** of the UPDATE statement. Also find the column index
** for each column to be updated in the pChanges array. For each
** column to be updated, make sure we have authorization to change
** that column.
*/
chngRecno = 0;
for(i=0; i<pChanges->nExpr; i++){
sqliteExprResolveInSelect(pParse, pChanges->a[i].pExpr);
}
if( pWhere ){
if( sqliteExprResolveIds(pParse, pTabList, pWhere) ){
goto update_cleanup;
}
if( sqliteExprCheck(pParse, pWhere, 0, 0) ){
goto update_cleanup;
}
}
for(i=0; i<pChanges->nExpr; i++){
if( sqliteExprResolveIds(pParse, pTabList, pChanges->a[i].pExpr) ){
if( sqliteExprResolveIds(pParse, pTabList, 0, pChanges->a[i].pExpr) ){
goto update_cleanup;
}
if( sqliteExprCheck(pParse, pChanges->a[i].pExpr, 0, 0) ){
@@ -98,53 +122,110 @@ void sqliteUpdate(
}
for(j=0; j<pTab->nCol; j++){
if( sqliteStrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){
if( j==pTab->iPKey ){
chngRecno = 1;
pRecnoExpr = pChanges->a[i].pExpr;
}
aXRef[j] = i;
break;
}
}
if( j>=pTab->nCol ){
sqliteSetString(&pParse->zErrMsg, "no such column: ",
pChanges->a[i].zName, 0);
pParse->nErr++;
if( sqliteIsRowid(pChanges->a[i].zName) ){
chngRecno = 1;
pRecnoExpr = pChanges->a[i].pExpr;
}else{
sqliteErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);
goto update_cleanup;
}
}
#ifndef SQLITE_OMIT_AUTHORIZATION
{
int rc;
rc = sqliteAuthCheck(pParse, SQLITE_UPDATE, pTab->zName,
pTab->aCol[j].zName, db->aDb[pTab->iDb].zName);
if( rc==SQLITE_DENY ){
goto update_cleanup;
}else if( rc==SQLITE_IGNORE ){
aXRef[j] = -1;
}
}
#endif
}
/* Allocate memory for the array apIdx[] and fill it with pointers to every
** index that needs to be updated. Indices only need updating if their
** key includes one of the columns named in pChanges or if the record
** number of the original table entry is changing.
*/
for(nIdx=nIdxTotal=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdxTotal++){
if( chngRecno ){
i = 0;
}else {
for(i=0; i<pIdx->nColumn; i++){
if( aXRef[pIdx->aiColumn[i]]>=0 ) break;
}
}
if( i<pIdx->nColumn ) nIdx++;
}
if( nIdxTotal>0 ){
apIdx = sqliteMalloc( sizeof(Index*) * nIdx + nIdxTotal );
if( apIdx==0 ) goto update_cleanup;
aIdxUsed = (char*)&apIdx[nIdx];
}
for(nIdx=j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
if( chngRecno ){
i = 0;
}else{
for(i=0; i<pIdx->nColumn; i++){
if( aXRef[pIdx->aiColumn[i]]>=0 ) break;
}
}
if( i<pIdx->nColumn ){
apIdx[nIdx++] = pIdx;
aIdxUsed[j] = 1;
}else{
aIdxUsed[j] = 0;
}
}
/* Resolve the column names in all the expressions in the
** WHERE clause.
*/
if( pWhere ){
if( sqliteExprResolveIds(pParse, pTabList, 0, pWhere) ){
goto update_cleanup;
}
if( sqliteExprCheck(pParse, pWhere, 0, 0) ){
goto update_cleanup;
}
}
/* Allocate memory for the array apIdx[] and fill it pointers to every
** index that needs to be updated. Indices only need updating if their
** key includes one of the columns named in pChanges.
/* Start the view context
*/
for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
for(i=0; i<pIdx->nColumn; i++){
if( aXRef[pIdx->aiColumn[i]]>=0 ) break;
}
if( i<pIdx->nColumn ) nIdx++;
}
if( nIdx>0 ){
apIdx = sqliteMalloc( sizeof(Index*) * nIdx );
if( apIdx==0 ) goto update_cleanup;
}
for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
for(i=0; i<pIdx->nColumn; i++){
if( aXRef[pIdx->aiColumn[i]]>=0 ) break;
}
if( i<pIdx->nColumn ) apIdx[nIdx++] = pIdx;
if( isView ){
sqliteAuthContextPush(pParse, &sContext, pTab->zName);
}
/* Begin generating code.
*/
v = sqliteGetVdbe(pParse);
if( v==0 ) goto update_cleanup;
if( (db->flags & SQLITE_InTrans)==0 ){
sqliteVdbeAddOp(v, OP_Transaction, 0, 0);
sqliteVdbeAddOp(v, OP_VerifyCookie, db->schema_cookie, 0);
pParse->schemaVerified = 1;
sqliteBeginWriteOperation(pParse, 1, pTab->iDb);
/* If we are trying to update a view, construct that view into
** a temporary table.
*/
if( isView ){
Select *pView;
pView = sqliteSelectDup(pTab->pSelect);
sqliteSelect(pParse, pView, SRT_TempTable, iCur, 0, 0, 0);
sqliteSelectDelete(pView);
}
/* Begin the database scan
*/
sqliteVdbeAddOp(v, OP_ListOpen, 0, 0);
pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1);
pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1, 0);
if( pWInfo==0 ) goto update_cleanup;
/* Remember the index of every item to be updated.
@@ -157,101 +238,221 @@ void sqliteUpdate(
/* Initialize the count of updated rows
*/
if( db->flags & SQLITE_CountRows ){
if( db->flags & SQLITE_CountRows && !pParse->trigStack ){
sqliteVdbeAddOp(v, OP_Integer, 0, 0);
}
/* Rewind the list of records that need to be updated and
** open every index that needs updating.
*/
sqliteVdbeAddOp(v, OP_ListRewind, 0, 0);
base = pParse->nTab;
openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite;
sqliteVdbeAddOp(v, openOp, base, pTab->tnum);
for(i=0; i<nIdx; i++){
sqliteVdbeAddOp(v, openOp, base+i+1, apIdx[i]->tnum);
}
if( row_triggers_exist ){
/* Create pseudo-tables for NEW and OLD
*/
sqliteVdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);
sqliteVdbeAddOp(v, OP_OpenPseudo, newIdx, 0);
/* Loop over every record that needs updating. We have to load
** the old data for each record to be updated because some columns
** might not change and we will need to copy the old value.
** Also, the old data is needed to delete the old index entires.
*/
end = sqliteVdbeMakeLabel(v);
addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end);
sqliteVdbeAddOp(v, OP_Dup, 0, 0);
sqliteVdbeAddOp(v, OP_MoveTo, base, 0);
/* Delete the old indices for the current record.
*/
for(i=0; i<nIdx; i++){
/* The top of the update loop for when there are triggers.
*/
sqliteVdbeAddOp(v, OP_ListRewind, 0, 0);
sqliteVdbeAddOp(v, OP_StackDepth, 0, 0);
sqliteVdbeAddOp(v, OP_MemStore, iStackDepth, 1);
loopStart = sqliteVdbeAddOp(v, OP_MemLoad, iStackDepth, 0);
sqliteVdbeAddOp(v, OP_StackReset, 0, 0);
jumpInst = sqliteVdbeAddOp(v, OP_ListRead, 0, 0);
sqliteVdbeAddOp(v, OP_Dup, 0, 0);
pIdx = apIdx[i];
for(j=0; j<pIdx->nColumn; j++){
sqliteVdbeAddOp(v, OP_Column, base, pIdx->aiColumn[j]);
}
sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
sqliteVdbeAddOp(v, OP_DeleteIdx, base+i+1, 0);
}
/* Compute a completely new data for this record.
*/
for(i=0; i<pTab->nCol; i++){
j = aXRef[i];
if( j<0 ){
sqliteVdbeAddOp(v, OP_Column, base, i);
/* Open a cursor and make it point to the record that is
** being updated.
*/
sqliteVdbeAddOp(v, OP_Dup, 0, 0);
if( !isView ){
sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
}
sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0);
/* Generate the OLD table
*/
sqliteVdbeAddOp(v, OP_Recno, iCur, 0);
sqliteVdbeAddOp(v, OP_RowData, iCur, 0);
sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
/* Generate the NEW table
*/
if( chngRecno ){
sqliteExprCode(pParse, pRecnoExpr);
}else{
sqliteExprCode(pParse, pChanges->a[j].pExpr);
sqliteVdbeAddOp(v, OP_Recno, iCur, 0);
}
for(i=0; i<pTab->nCol; i++){
if( i==pTab->iPKey ){
sqliteVdbeAddOp(v, OP_String, 0, 0);
continue;
}
j = aXRef[i];
if( j<0 ){
sqliteVdbeAddOp(v, OP_Column, iCur, i);
}else{
sqliteExprCode(pParse, pChanges->a[j].pExpr);
}
}
sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0);
if( !isView ){
sqliteVdbeAddOp(v, OP_Close, iCur, 0);
}
/* Fire the BEFORE and INSTEAD OF triggers
*/
if( sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE, pTab,
newIdx, oldIdx, onError, loopStart) ){
goto update_cleanup;
}
}
/* Insert new index entries that correspond to the new data
*/
for(i=0; i<nIdx; i++){
sqliteVdbeAddOp(v, OP_Dup, pTab->nCol, 0); /* The KEY */
pIdx = apIdx[i];
for(j=0; j<pIdx->nColumn; j++){
sqliteVdbeAddOp(v, OP_Dup, j+pTab->nCol-pIdx->aiColumn[j], 0);
if( !isView ){
/*
** Open every index that needs updating. Note that if any
** index could potentially invoke a REPLACE conflict resolution
** action, then we need to open all indices because we might need
** to be deleting some records.
*/
sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
sqliteVdbeAddOp(v, OP_OpenWrite, iCur, pTab->tnum);
if( onError==OE_Replace ){
openAll = 1;
}else{
openAll = 0;
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
if( pIdx->onError==OE_Replace ){
openAll = 1;
break;
}
}
}
sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
sqliteVdbeAddOp(v, OP_PutIdx, base+i+1, pIdx->isUnique);
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
if( openAll || aIdxUsed[i] ){
sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0);
sqliteVdbeAddOp(v, OP_OpenWrite, iCur+i+1, pIdx->tnum);
assert( pParse->nTab>iCur+i+1 );
}
}
/* Loop over every record that needs updating. We have to load
** the old data for each record to be updated because some columns
** might not change and we will need to copy the old value.
** Also, the old data is needed to delete the old index entires.
** So make the cursor point at the old record.
*/
if( !row_triggers_exist ){
sqliteVdbeAddOp(v, OP_ListRewind, 0, 0);
jumpInst = loopStart = sqliteVdbeAddOp(v, OP_ListRead, 0, 0);
sqliteVdbeAddOp(v, OP_Dup, 0, 0);
}
sqliteVdbeAddOp(v, OP_NotExists, iCur, loopStart);
/* If the record number will change, push the record number as it
** will be after the update. (The old record number is currently
** on top of the stack.)
*/
if( chngRecno ){
sqliteExprCode(pParse, pRecnoExpr);
sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);
}
/* Compute new data for this record.
*/
for(i=0; i<pTab->nCol; i++){
if( i==pTab->iPKey ){
sqliteVdbeAddOp(v, OP_String, 0, 0);
continue;
}
j = aXRef[i];
if( j<0 ){
sqliteVdbeAddOp(v, OP_Column, iCur, i);
}else{
sqliteExprCode(pParse, pChanges->a[j].pExpr);
}
}
/* Do constraint checks
*/
sqliteGenerateConstraintChecks(pParse, pTab, iCur, aIdxUsed, chngRecno, 1,
onError, loopStart);
/* Delete the old indices for the current record.
*/
sqliteGenerateRowIndexDelete(db, v, pTab, iCur, aIdxUsed);
/* If changing the record number, delete the old record.
*/
if( chngRecno ){
sqliteVdbeAddOp(v, OP_Delete, iCur, 0);
}
/* Create the new index entries and the new record.
*/
sqliteCompleteInsertion(pParse, pTab, iCur, aIdxUsed, chngRecno, 1, -1);
}
/* Write the new data back into the database.
/* Increment the row counter
*/
sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
sqliteVdbeAddOp(v, OP_Put, base, 0);
/* Increment the count of rows affected by the update
*/
if( db->flags & SQLITE_CountRows ){
if( db->flags & SQLITE_CountRows && !pParse->trigStack){
sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
}
/* If there are triggers, close all the cursors after each iteration
** through the loop. The fire the after triggers.
*/
if( row_triggers_exist ){
if( !isView ){
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
if( openAll || aIdxUsed[i] )
sqliteVdbeAddOp(v, OP_Close, iCur+i+1, 0);
}
sqliteVdbeAddOp(v, OP_Close, iCur, 0);
pParse->nTab = iCur;
}
if( sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER, pTab,
newIdx, oldIdx, onError, loopStart) ){
goto update_cleanup;
}
}
/* Repeat the above with the next record to be updated, until
** all record selected by the WHERE clause have been updated.
*/
sqliteVdbeAddOp(v, OP_Goto, 0, addr);
sqliteVdbeResolveLabel(v, end);
sqliteVdbeAddOp(v, OP_ListClose, 0, 0);
if( (db->flags & SQLITE_InTrans)==0 ){
sqliteVdbeAddOp(v, OP_Commit, 0, 0);
sqliteVdbeAddOp(v, OP_Goto, 0, loopStart);
sqliteVdbeChangeP2(v, jumpInst, sqliteVdbeCurrentAddr(v));
sqliteVdbeAddOp(v, OP_ListReset, 0, 0);
/* Close all tables if there were no FOR EACH ROW triggers */
if( !row_triggers_exist ){
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
if( openAll || aIdxUsed[i] ){
sqliteVdbeAddOp(v, OP_Close, iCur+i+1, 0);
}
}
sqliteVdbeAddOp(v, OP_Close, iCur, 0);
pParse->nTab = iCur;
}else{
sqliteVdbeAddOp(v, OP_Close, newIdx, 0);
sqliteVdbeAddOp(v, OP_Close, oldIdx, 0);
}
sqliteVdbeAddOp(v, OP_SetCounts, 0, 0);
sqliteEndWriteOperation(pParse);
/*
** Return the number of rows that were changed.
*/
if( db->flags & SQLITE_CountRows ){
sqliteVdbeAddOp(v, OP_ColumnCount, 1, 0);
sqliteVdbeAddOp(v, OP_ColumnName, 0, 0);
sqliteVdbeChangeP3(v, -1, "rows updated", P3_STATIC);
if( db->flags & SQLITE_CountRows && !pParse->trigStack ){
sqliteVdbeOp3(v, OP_ColumnName, 0, 1, "rows updated", P3_STATIC);
sqliteVdbeAddOp(v, OP_Callback, 1, 0);
}
update_cleanup:
sqliteAuthContextPop(&sContext);
sqliteFree(apIdx);
sqliteFree(aXRef);
sqliteIdListDelete(pTabList);
sqliteSrcListDelete(pTabList);
sqliteExprListDelete(pChanges);
sqliteExprDelete(pWhere);
return;
+511 -378
View File
File diff suppressed because it is too large Load Diff
+305
View File
@@ -0,0 +1,305 @@
/*
** 2003 April 6
**
** 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 code used to implement the VACUUM command.
**
** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro.
**
** $Id: vacuum.c,v 1.13.2.5 2005/02/14 00:25:48 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
/*
** A structure for holding a dynamic string - a string that can grow
** without bound.
*/
typedef struct dynStr dynStr;
struct dynStr {
char *z; /* Text of the string in space obtained from sqliteMalloc() */
int nAlloc; /* Amount of space allocated to z[] */
int nUsed; /* Next unused slot in z[] */
};
/*
** A structure that holds the vacuum context
*/
typedef struct vacuumStruct vacuumStruct;
struct vacuumStruct {
sqlite *dbOld; /* Original database */
sqlite *dbNew; /* New database */
char **pzErrMsg; /* Write errors here */
int rc; /* Set to non-zero on an error */
const char *zTable; /* Name of a table being copied */
const char *zPragma; /* Pragma to execute with results */
dynStr s1, s2; /* Two dynamic strings */
};
#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM
/*
** Append text to a dynamic string
*/
static void appendText(dynStr *p, const char *zText, int nText){
if( nText<0 ) nText = strlen(zText);
if( p->z==0 || p->nUsed + nText + 1 >= p->nAlloc ){
char *zNew;
p->nAlloc = p->nUsed + nText + 1000;
zNew = sqliteRealloc(p->z, p->nAlloc);
if( zNew==0 ){
sqliteFree(p->z);
memset(p, 0, sizeof(*p));
return;
}
p->z = zNew;
}
memcpy(&p->z[p->nUsed], zText, nText+1);
p->nUsed += nText;
}
/*
** Append text to a dynamic string, having first put the text in quotes.
*/
static void appendQuoted(dynStr *p, const char *zText){
int i, j;
appendText(p, "'", 1);
for(i=j=0; zText[i]; i++){
if( zText[i]=='\'' ){
appendText(p, &zText[j], i-j+1);
j = i + 1;
appendText(p, "'", 1);
}
}
if( j<i ){
appendText(p, &zText[j], i-j);
}
appendText(p, "'", 1);
}
/*
** Execute statements of SQL. If an error occurs, write the error
** message into *pzErrMsg and return non-zero.
*/
static int execsql(char **pzErrMsg, sqlite *db, const char *zSql){
char *zErrMsg = 0;
int rc;
/* printf("***** executing *****\n%s\n", zSql); */
rc = sqlite_exec(db, zSql, 0, 0, &zErrMsg);
if( zErrMsg ){
sqliteSetString(pzErrMsg, zErrMsg, (char*)0);
sqlite_freemem(zErrMsg);
}
return rc;
}
/*
** This is the second stage callback. Each invocation contains all the
** data for a single row of a single table in the original database. This
** routine must write that information into the new database.
*/
static int vacuumCallback2(void *pArg, int argc, char **argv, char **NotUsed){
vacuumStruct *p = (vacuumStruct*)pArg;
const char *zSep = "(";
int i;
if( argv==0 ) return 0;
p->s2.nUsed = 0;
appendText(&p->s2, "INSERT INTO ", -1);
appendQuoted(&p->s2, p->zTable);
appendText(&p->s2, " VALUES", -1);
for(i=0; i<argc; i++){
appendText(&p->s2, zSep, 1);
zSep = ",";
if( argv[i]==0 ){
appendText(&p->s2, "NULL", 4);
}else{
appendQuoted(&p->s2, argv[i]);
}
}
appendText(&p->s2,")", 1);
p->rc = execsql(p->pzErrMsg, p->dbNew, p->s2.z);
return p->rc;
}
/*
** This is the first stage callback. Each invocation contains three
** arguments where are taken from the SQLITE_MASTER table of the original
** database: (1) the entry type, (2) the entry name, and (3) the SQL for
** the entry. In all cases, execute the SQL of the third argument.
** For tables, run a query to select all entries in that table and
** transfer them to the second-stage callback.
*/
static int vacuumCallback1(void *pArg, int argc, char **argv, char **NotUsed){
vacuumStruct *p = (vacuumStruct*)pArg;
int rc = 0;
assert( argc==3 );
if( argv==0 ) return 0;
assert( argv[0]!=0 );
assert( argv[1]!=0 );
assert( argv[2]!=0 );
rc = execsql(p->pzErrMsg, p->dbNew, argv[2]);
if( rc==SQLITE_OK && strcmp(argv[0],"table")==0 ){
char *zErrMsg = 0;
p->s1.nUsed = 0;
appendText(&p->s1, "SELECT * FROM ", -1);
appendQuoted(&p->s1, argv[1]);
p->zTable = argv[1];
rc = sqlite_exec(p->dbOld, p->s1.z, vacuumCallback2, p, &zErrMsg);
if( zErrMsg ){
sqliteSetString(p->pzErrMsg, zErrMsg, (char*)0);
sqlite_freemem(zErrMsg);
}
}
if( rc!=SQLITE_ABORT ) p->rc = rc;
return rc;
}
/*
** Generate a random name of 20 character in length.
*/
static void randomName(unsigned char *zBuf){
static const unsigned char zChars[] =
"abcdefghijklmnopqrstuvwxyz"
"0123456789";
int i;
sqliteRandomness(20, zBuf);
for(i=0; i<20; i++){
zBuf[i] = zChars[ zBuf[i]%(sizeof(zChars)-1) ];
}
}
#endif
/*
** The non-standard VACUUM command is used to clean up the database,
** collapse free space, etc. It is modelled after the VACUUM command
** in PostgreSQL.
**
** In version 1.0.x of SQLite, the VACUUM command would call
** gdbm_reorganize() on all the database tables. But beginning
** with 2.0.0, SQLite no longer uses GDBM so this command has
** become a no-op.
*/
void sqliteVacuum(Parse *pParse, Token *pTableName){
Vdbe *v = sqliteGetVdbe(pParse);
sqliteVdbeAddOp(v, OP_Vacuum, 0, 0);
return;
}
/*
** This routine implements the OP_Vacuum opcode of the VDBE.
*/
int sqliteRunVacuum(char **pzErrMsg, sqlite *db){
#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM
const char *zFilename; /* full pathname of the database file */
int nFilename; /* number of characters in zFilename[] */
char *zTemp = 0; /* a temporary file in same directory as zFilename */
sqlite *dbNew = 0; /* The new vacuumed database */
int rc = SQLITE_OK; /* Return code from service routines */
int i; /* Loop counter */
char *zErrMsg; /* Error message */
vacuumStruct sVac; /* Information passed to callbacks */
if( db->flags & SQLITE_InTrans ){
sqliteSetString(pzErrMsg, "cannot VACUUM from within a transaction",
(char*)0);
return SQLITE_ERROR;
}
if( db->flags & SQLITE_Interrupt ){
return SQLITE_INTERRUPT;
}
memset(&sVac, 0, sizeof(sVac));
/* Get the full pathname of the database file and create two
** temporary filenames in the same directory as the original file.
*/
zFilename = sqliteBtreeGetFilename(db->aDb[0].pBt);
if( zFilename==0 ){
/* This only happens with the in-memory database. VACUUM is a no-op
** there, so just return */
return SQLITE_OK;
}
nFilename = strlen(zFilename);
zTemp = sqliteMalloc( nFilename+100 );
if( zTemp==0 ) return SQLITE_NOMEM;
strcpy(zTemp, zFilename);
for(i=0; i<10; i++){
zTemp[nFilename] = '-';
randomName((unsigned char*)&zTemp[nFilename+1]);
if( !sqliteOsFileExists(zTemp) ) break;
}
if( i>=10 ){
sqliteSetString(pzErrMsg, "unable to create a temporary database file "
"in the same directory as the original database", (char*)0);
goto end_of_vacuum;
}
dbNew = sqlite_open(zTemp, 0, &zErrMsg);
if( dbNew==0 ){
sqliteSetString(pzErrMsg, "unable to open a temporary database at ",
zTemp, " - ", zErrMsg, (char*)0);
goto end_of_vacuum;
}
if( (rc = execsql(pzErrMsg, db, "BEGIN"))!=0 ) goto end_of_vacuum;
if( (rc = execsql(pzErrMsg, dbNew, "PRAGMA synchronous=off; BEGIN"))!=0 ){
goto end_of_vacuum;
}
sVac.dbOld = db;
sVac.dbNew = dbNew;
sVac.pzErrMsg = pzErrMsg;
if( rc==SQLITE_OK ){
rc = sqlite_exec(db,
"SELECT type, name, sql FROM sqlite_master "
"WHERE sql NOT NULL AND type!='view' "
"UNION ALL "
"SELECT type, name, sql FROM sqlite_master "
"WHERE sql NOT NULL AND type=='view'",
vacuumCallback1, &sVac, &zErrMsg);
}
if( rc==SQLITE_OK ){
int meta1[SQLITE_N_BTREE_META];
int meta2[SQLITE_N_BTREE_META];
sqliteBtreeGetMeta(db->aDb[0].pBt, meta1);
sqliteBtreeGetMeta(dbNew->aDb[0].pBt, meta2);
meta2[1] = meta1[1]+1;
meta2[3] = meta1[3];
meta2[4] = meta1[4];
meta2[6] = meta1[6];
rc = sqliteBtreeUpdateMeta(dbNew->aDb[0].pBt, meta2);
}
if( rc==SQLITE_OK ){
rc = sqliteBtreeCopyFile(db->aDb[0].pBt, dbNew->aDb[0].pBt);
sqlite_exec(db, "COMMIT", 0, 0, 0);
sqliteResetInternalSchema(db, 0);
}
end_of_vacuum:
if( rc && zErrMsg!=0 ){
sqliteSetString(pzErrMsg, "unable to vacuum database - ",
zErrMsg, (char*)0);
}
sqlite_exec(db, "ROLLBACK", 0, 0, 0);
if( (dbNew && (dbNew->flags & SQLITE_Interrupt))
|| (db->flags & SQLITE_Interrupt) ){
rc = SQLITE_INTERRUPT;
}
if( dbNew ) sqlite_close(dbNew);
sqliteOsDelete(zTemp);
sqliteFree(zTemp);
sqliteFree(sVac.s1.z);
sqliteFree(sVac.s2.z);
if( zErrMsg ) sqlite_freemem(zErrMsg);
if( rc==SQLITE_ABORT && sVac.rc!=SQLITE_INTERRUPT ) sVac.rc = SQLITE_ERROR;
return sVac.rc;
#endif
}
+3171 -2410
View File
File diff suppressed because it is too large Load Diff
+37 -151
View File
@@ -15,7 +15,7 @@
** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database.
**
** $Id: vdbe.h,v 1.30 2001/10/19 16:44:57 drh Exp $
** $Id: vdbe.h,v 1.71 2004/02/22 20:05:02 drh Exp $
*/
#ifndef _SQLITE_VDBE_H_
#define _SQLITE_VDBE_H_
@@ -34,21 +34,37 @@ typedef struct Vdbe Vdbe;
** as an instance of the following structure:
*/
struct VdbeOp {
int opcode; /* What operation to perform */
u8 opcode; /* What operation to perform */
int p1; /* First operand */
int p2; /* Second parameter (often the jump destination) */
char *p3; /* Third parameter */
int p3type; /* P3_STATIC, P3_DYNAMIC or P3_POINTER */
#ifdef VDBE_PROFILE
int cnt; /* Number of times this instruction was executed */
long long cycles; /* Total time spend executing this instruction */
#endif
};
typedef struct VdbeOp VdbeOp;
/*
** A smaller version of VdbeOp used for the VdbeAddOpList() function because
** it takes up less space.
*/
struct VdbeOpList {
u8 opcode; /* What operation to perform */
signed char p1; /* First operand */
short int p2; /* Second parameter (often the jump destination) */
char *p3; /* Third parameter */
};
typedef struct VdbeOpList VdbeOpList;
/*
** Allowed values of VdbeOp.p3type
*/
#define P3_NOTUSED 0 /* The P3 parameter is not used */
#define P3_DYNAMIC 1 /* Pointer to a string obtained from sqliteMalloc() */
#define P3_STATIC (-1) /* Pointer to a static string */
#define P3_POINTER (-2) /* P3 is a pointer to some structure or object */
#define P3_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
#define P3_STATIC (-2) /* Pointer to a static string */
#define P3_POINTER (-3) /* P3 is a pointer to some structure or object */
/*
** The following macro converts a relative address in the p2 field
@@ -59,147 +75,10 @@ typedef struct VdbeOp VdbeOp;
#define ADDR(X) (-1-(X))
/*
** These are the available opcodes.
**
** If any of the values changes or if opcodes are added or removed,
** be sure to also update the zOpName[] array in sqliteVdbe.c to
** mirror the change.
**
** The source tree contains an AWK script named renumberOps.awk that
** can be used to renumber these opcodes when new opcodes are inserted.
** The makefile scans the vdbe.c source file and creates the "opcodes.h"
** header file that defines a number for each opcode used by the VDBE.
*/
#define OP_Transaction 1
#define OP_Commit 2
#define OP_Rollback 3
#define OP_ReadCookie 4
#define OP_SetCookie 5
#define OP_VerifyCookie 6
#define OP_Open 7
#define OP_OpenTemp 8
#define OP_OpenWrite 9
#define OP_OpenAux 10
#define OP_OpenWrAux 11
#define OP_Close 12
#define OP_MoveTo 13
#define OP_Fcnt 14
#define OP_NewRecno 15
#define OP_Put 16
#define OP_Distinct 17
#define OP_Found 18
#define OP_NotFound 19
#define OP_Delete 20
#define OP_Column 21
#define OP_KeyAsData 22
#define OP_Recno 23
#define OP_FullKey 24
#define OP_Rewind 25
#define OP_Next 26
#define OP_Destroy 27
#define OP_Clear 28
#define OP_CreateIndex 29
#define OP_CreateTable 30
#define OP_Reorganize 31
#define OP_BeginIdx 32
#define OP_NextIdx 33
#define OP_PutIdx 34
#define OP_DeleteIdx 35
#define OP_MemLoad 36
#define OP_MemStore 37
#define OP_ListOpen 38
#define OP_ListWrite 39
#define OP_ListRewind 40
#define OP_ListRead 41
#define OP_ListClose 42
#define OP_SortOpen 43
#define OP_SortPut 44
#define OP_SortMakeRec 45
#define OP_SortMakeKey 46
#define OP_Sort 47
#define OP_SortNext 48
#define OP_SortKey 49
#define OP_SortCallback 50
#define OP_SortClose 51
#define OP_FileOpen 52
#define OP_FileRead 53
#define OP_FileColumn 54
#define OP_FileClose 55
#define OP_AggReset 56
#define OP_AggFocus 57
#define OP_AggIncr 58
#define OP_AggNext 59
#define OP_AggSet 60
#define OP_AggGet 61
#define OP_SetInsert 62
#define OP_SetFound 63
#define OP_SetNotFound 64
#define OP_SetClear 65
#define OP_MakeRecord 66
#define OP_MakeKey 67
#define OP_MakeIdxKey 68
#define OP_Goto 69
#define OP_If 70
#define OP_Halt 71
#define OP_ColumnCount 72
#define OP_ColumnName 73
#define OP_Callback 74
#define OP_NullCallback 75
#define OP_Integer 76
#define OP_String 77
#define OP_Null 78
#define OP_Pop 79
#define OP_Dup 80
#define OP_Pull 81
#define OP_Add 82
#define OP_AddImm 83
#define OP_Subtract 84
#define OP_Multiply 85
#define OP_Divide 86
#define OP_Remainder 87
#define OP_BitAnd 88
#define OP_BitOr 89
#define OP_BitNot 90
#define OP_ShiftLeft 91
#define OP_ShiftRight 92
#define OP_AbsValue 93
#define OP_Precision 94
#define OP_Min 95
#define OP_Max 96
#define OP_Like 97
#define OP_Glob 98
#define OP_Eq 99
#define OP_Ne 100
#define OP_Lt 101
#define OP_Le 102
#define OP_Gt 103
#define OP_Ge 104
#define OP_IsNull 105
#define OP_NotNull 106
#define OP_Negative 107
#define OP_And 108
#define OP_Or 109
#define OP_Not 110
#define OP_Concat 111
#define OP_Noop 112
#define OP_Strlen 113
#define OP_Substr 114
#define OP_MAX 114
#include "opcodes.h"
/*
** Prototypes for the VDBE interface. See comments on the implementation
@@ -208,19 +87,26 @@ typedef struct VdbeOp VdbeOp;
Vdbe *sqliteVdbeCreate(sqlite*);
void sqliteVdbeCreateCallback(Vdbe*, int*);
int sqliteVdbeAddOp(Vdbe*,int,int,int);
int sqliteVdbeAddOpList(Vdbe*, int nOp, VdbeOp const *aOp);
int sqliteVdbeOp3(Vdbe*,int,int,int,const char *zP3,int);
int sqliteVdbeCode(Vdbe*,...);
int sqliteVdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
void sqliteVdbeChangeP1(Vdbe*, int addr, int P1);
void sqliteVdbeChangeP3(Vdbe*, int addr, char *zP1, int N);
void sqliteVdbeChangeP2(Vdbe*, int addr, int P2);
void sqliteVdbeChangeP3(Vdbe*, int addr, const char *zP1, int N);
void sqliteVdbeDequoteP3(Vdbe*, int addr);
int sqliteVdbeFindOp(Vdbe*, int, int);
VdbeOp *sqliteVdbeGetOp(Vdbe*, int);
int sqliteVdbeMakeLabel(Vdbe*);
void sqliteVdbeDelete(Vdbe*);
int sqliteVdbeOpcode(const char *zName);
int sqliteVdbeExec(Vdbe*,sqlite_callback,void*,char**,void*,
int(*)(void*,const char*,int));
int sqliteVdbeList(Vdbe*,sqlite_callback,void*,char**);
void sqliteVdbeMakeReady(Vdbe*,int,int);
int sqliteVdbeExec(Vdbe*);
int sqliteVdbeList(Vdbe*);
int sqliteVdbeFinalize(Vdbe*,char**);
void sqliteVdbeResolveLabel(Vdbe*, int);
int sqliteVdbeCurrentAddr(Vdbe*);
void sqliteVdbeTrace(Vdbe*,FILE*);
void sqliteVdbeCompressSpace(Vdbe*,int);
int sqliteVdbeReset(Vdbe*,char **);
int sqliteVdbeSetVariables(Vdbe*,int,const char**);
#endif
+303
View File
@@ -0,0 +1,303 @@
/*
** 2003 September 6
**
** 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 is the header file for information that is private to the
** VDBE. This information used to all be at the top of the single
** source code file "vdbe.c". When that file became too big (over
** 6000 lines long) it was split up into several smaller files and
** this header information was factored out.
*/
/*
** When converting from the native format to the key format and back
** again, in addition to changing the byte order we invert the high-order
** bit of the most significant byte. This causes negative numbers to
** sort before positive numbers in the memcmp() function.
*/
#define keyToInt(X) (sqliteVdbeByteSwap(X) ^ 0x80000000)
#define intToKey(X) (sqliteVdbeByteSwap((X) ^ 0x80000000))
/*
** The makefile scans this source file and creates the following
** array of string constants which are the names of all VDBE opcodes.
** This array is defined in a separate source code file named opcode.c
** which is automatically generated by the makefile.
*/
extern char *sqliteOpcodeNames[];
/*
** SQL is translated into a sequence of instructions to be
** executed by a virtual machine. Each instruction is an instance
** of the following structure.
*/
typedef struct VdbeOp Op;
/*
** Boolean values
*/
typedef unsigned char Bool;
/*
** A cursor is a pointer into a single BTree within a database file.
** The cursor can seek to a BTree entry with a particular key, or
** loop over all entries of the Btree. You can also insert new BTree
** entries or retrieve the key or data from the entry that the cursor
** is currently pointing to.
**
** Every cursor that the virtual machine has open is represented by an
** instance of the following structure.
**
** If the Cursor.isTriggerRow flag is set it means that this cursor is
** really a single row that represents the NEW or OLD pseudo-table of
** a row trigger. The data for the row is stored in Cursor.pData and
** the rowid is in Cursor.iKey.
*/
struct Cursor {
BtCursor *pCursor; /* The cursor structure of the backend */
int lastRecno; /* Last recno from a Next or NextIdx operation */
int nextRowid; /* Next rowid returned by OP_NewRowid */
Bool recnoIsValid; /* True if lastRecno is valid */
Bool keyAsData; /* The OP_Column command works on key instead of data */
Bool atFirst; /* True if pointing to first entry */
Bool useRandomRowid; /* Generate new record numbers semi-randomly */
Bool nullRow; /* True if pointing to a row with no data */
Bool nextRowidValid; /* True if the nextRowid field is valid */
Bool pseudoTable; /* This is a NEW or OLD pseudo-tables of a trigger */
Bool deferredMoveto; /* A call to sqliteBtreeMoveto() is needed */
int movetoTarget; /* Argument to the deferred sqliteBtreeMoveto() */
Btree *pBt; /* Separate file holding temporary table */
int nData; /* Number of bytes in pData */
char *pData; /* Data for a NEW or OLD pseudo-table */
int iKey; /* Key for the NEW or OLD pseudo-table row */
};
typedef struct Cursor Cursor;
/*
** A sorter builds a list of elements to be sorted. Each element of
** the list is an instance of the following structure.
*/
typedef struct Sorter Sorter;
struct Sorter {
int nKey; /* Number of bytes in the key */
char *zKey; /* The key by which we will sort */
int nData; /* Number of bytes in the data */
char *pData; /* The data associated with this key */
Sorter *pNext; /* Next in the list */
};
/*
** Number of buckets used for merge-sort.
*/
#define NSORT 30
/*
** Number of bytes of string storage space available to each stack
** layer without having to malloc. NBFS is short for Number of Bytes
** For Strings.
*/
#define NBFS 32
/*
** A single level of the stack or a single memory cell
** is an instance of the following structure.
*/
struct Mem {
int i; /* Integer value */
int n; /* Number of characters in string value, including '\0' */
int flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
double r; /* Real value */
char *z; /* String value */
char zShort[NBFS]; /* Space for short strings */
};
typedef struct Mem Mem;
/*
** Allowed values for Mem.flags
*/
#define MEM_Null 0x0001 /* Value is NULL */
#define MEM_Str 0x0002 /* Value is a string */
#define MEM_Int 0x0004 /* Value is an integer */
#define MEM_Real 0x0008 /* Value is a real number */
#define MEM_Dyn 0x0010 /* Need to call sqliteFree() on Mem.z */
#define MEM_Static 0x0020 /* Mem.z points to a static string */
#define MEM_Ephem 0x0040 /* Mem.z points to an ephemeral string */
#define MEM_Short 0x0080 /* Mem.z points to Mem.zShort */
/* The following MEM_ value appears only in AggElem.aMem.s.flag fields.
** It indicates that the corresponding AggElem.aMem.z points to a
** aggregate function context that needs to be finalized.
*/
#define MEM_AggCtx 0x0100 /* Mem.z points to an agg function context */
/*
** The "context" argument for a installable function. A pointer to an
** instance of this structure is the first argument to the routines used
** implement the SQL functions.
**
** There is a typedef for this structure in sqlite.h. So all routines,
** even the public interface to SQLite, can use a pointer to this structure.
** But this file is the only place where the internal details of this
** structure are known.
**
** This structure is defined inside of vdbe.c because it uses substructures
** (Mem) which are only defined there.
*/
struct sqlite_func {
FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
Mem s; /* The return value is stored here */
void *pAgg; /* Aggregate context */
u8 isError; /* Set to true for an error */
u8 isStep; /* Current in the step function */
int cnt; /* Number of times that the step function has been called */
};
/*
** An Agg structure describes an Aggregator. Each Agg consists of
** zero or more Aggregator elements (AggElem). Each AggElem contains
** a key and one or more values. The values are used in processing
** aggregate functions in a SELECT. The key is used to implement
** the GROUP BY clause of a select.
*/
typedef struct Agg Agg;
typedef struct AggElem AggElem;
struct Agg {
int nMem; /* Number of values stored in each AggElem */
AggElem *pCurrent; /* The AggElem currently in focus */
HashElem *pSearch; /* The hash element for pCurrent */
Hash hash; /* Hash table of all aggregate elements */
FuncDef **apFunc; /* Information about aggregate functions */
};
struct AggElem {
char *zKey; /* The key to this AggElem */
int nKey; /* Number of bytes in the key, including '\0' at end */
Mem aMem[1]; /* The values for this AggElem */
};
/*
** A Set structure is used for quick testing to see if a value
** is part of a small set. Sets are used to implement code like
** this:
** x.y IN ('hi','hoo','hum')
*/
typedef struct Set Set;
struct Set {
Hash hash; /* A set is just a hash table */
HashElem *prev; /* Previously accessed hash elemen */
};
/*
** A Keylist is a bunch of keys into a table. The keylist can
** grow without bound. The keylist stores the ROWIDs of database
** records that need to be deleted or updated.
*/
typedef struct Keylist Keylist;
struct Keylist {
int nKey; /* Number of slots in aKey[] */
int nUsed; /* Next unwritten slot in aKey[] */
int nRead; /* Next unread slot in aKey[] */
Keylist *pNext; /* Next block of keys */
int aKey[1]; /* One or more keys. Extra space allocated as needed */
};
/*
** A Context stores the last insert rowid, the last statement change count,
** and the current statement change count (i.e. changes since last statement).
** Elements of Context structure type make up the ContextStack, which is
** updated by the ContextPush and ContextPop opcodes (used by triggers)
*/
typedef struct Context Context;
struct Context {
int lastRowid; /* Last insert rowid (from db->lastRowid) */
int lsChange; /* Last statement change count (from db->lsChange) */
int csChange; /* Current statement change count (from db->csChange) */
};
/*
** An instance of the virtual machine. This structure contains the complete
** state of the virtual machine.
**
** The "sqlite_vm" structure pointer that is returned by sqlite_compile()
** is really a pointer to an instance of this structure.
*/
struct Vdbe {
sqlite *db; /* The whole database */
Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */
FILE *trace; /* Write an execution trace here, if not NULL */
int nOp; /* Number of instructions in the program */
int nOpAlloc; /* Number of slots allocated for aOp[] */
Op *aOp; /* Space to hold the virtual machine's program */
int nLabel; /* Number of labels used */
int nLabelAlloc; /* Number of slots allocated in aLabel[] */
int *aLabel; /* Space to hold the labels */
Mem *aStack; /* The operand stack, except string values */
Mem *pTos; /* Top entry in the operand stack */
char **zArgv; /* Text values used by the callback */
char **azColName; /* Becomes the 4th parameter to callbacks */
int nCursor; /* Number of slots in aCsr[] */
Cursor *aCsr; /* One element of this array for each open cursor */
Sorter *pSort; /* A linked list of objects to be sorted */
FILE *pFile; /* At most one open file handler */
int nField; /* Number of file fields */
char **azField; /* Data for each file field */
int nVar; /* Number of entries in azVariable[] */
char **azVar; /* Values for the OP_Variable opcode */
int *anVar; /* Length of each value in azVariable[] */
u8 *abVar; /* TRUE if azVariable[i] needs to be sqliteFree()ed */
char *zLine; /* A single line from the input file */
int nLineAlloc; /* Number of spaces allocated for zLine */
int magic; /* Magic number for sanity checking */
int nMem; /* Number of memory locations currently allocated */
Mem *aMem; /* The memory locations */
Agg agg; /* Aggregate information */
int nSet; /* Number of sets allocated */
Set *aSet; /* An array of sets */
int nCallback; /* Number of callbacks invoked so far */
Keylist *pList; /* A list of ROWIDs */
int keylistStackDepth; /* The size of the "keylist" stack */
Keylist **keylistStack; /* The stack used by opcodes ListPush & ListPop */
int contextStackDepth; /* The size of the "context" stack */
Context *contextStack; /* Stack used by opcodes ContextPush & ContextPop*/
int pc; /* The program counter */
int rc; /* Value to return */
unsigned uniqueCnt; /* Used by OP_MakeRecord when P2!=0 */
int errorAction; /* Recovery action to do in case of an error */
int undoTransOnError; /* If error, either ROLLBACK or COMMIT */
int inTempTrans; /* True if temp database is transactioned */
int returnStack[100]; /* Return address stack for OP_Gosub & OP_Return */
int returnDepth; /* Next unused element in returnStack[] */
int nResColumn; /* Number of columns in one row of the result set */
char **azResColumn; /* Values for one row of result */
int popStack; /* Pop the stack this much on entry to VdbeExec() */
char *zErrMsg; /* Error message written here */
u8 explain; /* True if EXPLAIN present on SQL command */
};
/*
** The following are allowed values for Vdbe.magic
*/
#define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */
#define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */
#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */
#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */
/*
** Function prototypes
*/
void sqliteVdbeCleanupCursor(Cursor*);
void sqliteVdbeSorterReset(Vdbe*);
void sqliteVdbeAggReset(Agg*);
void sqliteVdbeKeylistFree(Keylist*);
void sqliteVdbePopStack(Vdbe*,int);
int sqliteVdbeCursorMoveto(Cursor*);
int sqliteVdbeByteSwap(int);
#if !defined(NDEBUG) || defined(VDBE_PROFILE)
void sqliteVdbePrintOp(FILE*, int, Op*);
#endif
+1061
View File
File diff suppressed because it is too large Load Diff
+984 -199
View File
File diff suppressed because it is too large Load Diff
+40 -4
View File
@@ -10,7 +10,7 @@
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.11 2001/10/22 02:58:11 drh Exp $
# $Id: all.test,v 1.19 2003/02/16 22:21:33 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -20,9 +20,27 @@ proc finish_test {} {memleak_check}
if {[file exists ./sqlite_test_count]} {
set COUNT [exec cat ./sqlite_test_count]
} else {
set COUNT 3
set COUNT 4
}
if {[llength $argv]>0} {
foreach {name value} $argv {
switch -- $name {
-count {
set COUNT $value
}
-quick {
set ISQUICK $value
}
default {
puts stderr "Unknown option: $name"
exit
}
}
}
}
set argv {}
# LeakList will hold a list of the number of unfreed mallocs after
# each round of the test. This number should be constant. If it
# grows, it may mean there is a memory leak in the library.
@@ -33,13 +51,28 @@ set EXCLUDE {
all.test
quick.test
malloc.test
misuse.test
memleak.test
}
# btree2.test
for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
set btree_native_byte_order [expr {($Counter>>1)&0x1}]
if {$Counter%2} {
set ::SETUP_SQL {PRAGMA default_synchronous=off;}
} else {
catch {unset ::SETUP_SQL}
}
foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
set tail [file tail $testfile]
if {[lsearch -exact $EXCLUDE $tail]>=0} continue
source $testfile
catch {db close}
if {$sqlite_open_file_count>0} {
puts "$tail did not close all files: $sqlite_open_file_count"
incr nErr
lappend ::failList $tail
}
}
if {[info exists Leak]} {
lappend LeakList $Leak
@@ -65,9 +98,12 @@ if {$LeakList!=""} {
puts " Ok"
}
# Run the malloc tests after memory leak detection. We do leak
# some if malloc fails.
# Run the malloc tests and the misuse test after memory leak detection.
# Both tests leak memory.
#
catch {source $testdir/misuse.test}
catch {source $testdir/malloc.test}
catch {db close}
set sqlite_open_file_count 0
really_finish_test
+586
View File
@@ -0,0 +1,586 @@
# 2003 April 4
#
# 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 implements regression tests for SQLite library. The
# focus of this script is testing the ATTACH and DETACH commands
# and related functionality.
#
# $Id: attach.test,v 1.13 2004/02/14 01:39:50 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
for {set i 2} {$i<=15} {incr i} {
file delete -force test$i.db
file delete -force test$i.db-journal
}
do_test attach-1.1 {
execsql {
CREATE TABLE t1(a,b);
INSERT INTO t1 VALUES(1,2);
INSERT INTO t1 VALUES(3,4);
SELECT * FROM t1;
}
} {1 2 3 4}
do_test attach-1.2 {
sqlite db2 test2.db
execsql {
CREATE TABLE t2(x,y);
INSERT INTO t2 VALUES(1,'x');
INSERT INTO t2 VALUES(2,'y');
SELECT * FROM t2;
} db2
} {1 x 2 y}
do_test attach-1.3 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
SELECT * FROM two.t2;
}
} {1 x 2 y}
do_test attach-1.4 {
execsql {
SELECT * FROM t2;
}
} {1 x 2 y}
do_test attach-1.5 {
execsql {
DETACH DATABASE two;
SELECT * FROM t1;
}
} {1 2 3 4}
do_test attach-1.6 {
catchsql {
SELECT * FROM t2;
}
} {1 {no such table: t2}}
do_test attach-1.7 {
catchsql {
SELECT * FROM two.t2;
}
} {1 {no such table: two.t2}}
do_test attach-1.8 {
catchsql {
ATTACH DATABASE 'test3.db' AS three;
}
} {1 {cannot attach empty database: three}}
do_test attach-1.9 {
catchsql {
SELECT * FROM three.sqlite_master;
}
} {1 {no such table: three.sqlite_master}}
do_test attach-1.10 {
catchsql {
DETACH DATABASE three;
}
} {1 {no such database: three}}
do_test attach-1.11 {
execsql {
ATTACH 'test.db' AS db2;
ATTACH 'test.db' AS db3;
ATTACH 'test.db' AS db4;
ATTACH 'test.db' AS db5;
ATTACH 'test.db' AS db6;
ATTACH 'test.db' AS db7;
ATTACH 'test.db' AS db8;
ATTACH 'test.db' AS db9;
}
} {}
proc db_list {db} {
set list {}
foreach {idx name file} [execsql {PRAGMA database_list} $db] {
lappend list $idx $name
}
return $list
}
do_test attach-1.11b {
db_list db
} {0 main 1 temp 2 db2 3 db3 4 db4 5 db5 6 db6 7 db7 8 db8 9 db9}
do_test attach-1.12 {
catchsql {
ATTACH 'test.db' as db2;
}
} {1 {database db2 is already in use}}
do_test attach-1.13 {
catchsql {
ATTACH 'test.db' as db5;
}
} {1 {database db5 is already in use}}
do_test attach-1.14 {
catchsql {
ATTACH 'test.db' as db9;
}
} {1 {database db9 is already in use}}
do_test attach-1.15 {
catchsql {
ATTACH 'test.db' as main;
}
} {1 {database main is already in use}}
do_test attach-1.16 {
catchsql {
ATTACH 'test.db' as temp;
}
} {1 {database temp is already in use}}
do_test attach-1.17 {
catchsql {
ATTACH 'test.db' as MAIN;
}
} {1 {database MAIN is already in use}}
do_test attach-1.18 {
catchsql {
ATTACH 'test.db' as db10;
ATTACH 'test.db' as db11;
}
} {0 {}}
do_test attach-1.19 {
catchsql {
ATTACH 'test.db' as db12;
}
} {1 {too many attached databases - max 10}}
do_test attach-1.20.1 {
execsql {
DETACH db5;
}
db_list db
} {0 main 1 temp 2 db2 3 db3 4 db4 5 db11 6 db6 7 db7 8 db8 9 db9 10 db10}
integrity_check attach-1.20.2
do_test attach-1.21 {
catchsql {
ATTACH 'test.db' as db12;
}
} {0 {}}
do_test attach-1.22 {
catchsql {
ATTACH 'test.db' as db13;
}
} {1 {too many attached databases - max 10}}
do_test attach-1.23 {
catchsql {
DETACH db14;
}
} {1 {no such database: db14}}
do_test attach-1.24 {
catchsql {
DETACH db12;
}
} {0 {}}
do_test attach-1.25 {
catchsql {
DETACH db12;
}
} {1 {no such database: db12}}
do_test attach-1.26 {
catchsql {
DETACH main;
}
} {1 {cannot detach database main}}
do_test attach-1.27 {
catchsql {
DETACH Temp;
}
} {1 {cannot detach database Temp}}
do_test attach-1.28 {
catchsql {
DETACH db11;
DETACH db10;
DETACH db9;
DETACH db8;
DETACH db7;
DETACH db6;
DETACH db4;
DETACH db3;
DETACH db2;
}
} {0 {}}
do_test attach-1.29 {
db_list db
} {0 main 1 temp}
do_test attach-2.1 {
execsql {
CREATE TABLE tx(x1,x2,y1,y2);
CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
INSERT INTO tx(x1,x2,y1,y2) VALUES(OLD.x,NEW.x,OLD.y,NEW.y);
END;
SELECT * FROM tx;
} db2;
} {}
do_test attach-2.2 {
execsql {
UPDATE t2 SET x=x+10;
SELECT * FROM tx;
} db2;
} {1 11 x x 2 12 y y}
do_test attach-2.3 {
execsql {
CREATE TABLE tx(x1,x2,y1,y2);
SELECT * FROM tx;
}
} {}
do_test attach-2.4 {
execsql {
ATTACH 'test2.db' AS db2;
}
} {}
do_test attach-2.5 {
execsql {
UPDATE db2.t2 SET x=x+10;
SELECT * FROM db2.tx;
}
} {1 11 x x 2 12 y y 11 21 x x 12 22 y y}
do_test attach-2.6 {
execsql {
SELECT * FROM main.tx;
}
} {}
do_test attach-2.7 {
execsql {
SELECT type, name, tbl_name FROM db2.sqlite_master;
}
} {table t2 t2 table tx tx trigger r1 t2}
do_test attach-2.8 {
db_list db
} {0 main 1 temp 2 db2}
do_test attach-2.9 {
execsql {
CREATE INDEX i2 ON t2(x);
SELECT * FROM t2 WHERE x>5;
} db2
} {21 x 22 y}
do_test attach-2.10 {
execsql {
SELECT type, name, tbl_name FROM sqlite_master;
} db2
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
#do_test attach-2.11 {
# catchsql {
# SELECT * FROM t2 WHERE x>5;
# }
#} {1 {database schema has changed}}
do_test attach-2.12 {
db_list db
} {0 main 1 temp 2 db2}
do_test attach-2.13 {
catchsql {
SELECT * FROM t2 WHERE x>5;
}
} {0 {21 x 22 y}}
do_test attach-2.14 {
execsql {
SELECT type, name, tbl_name FROM sqlite_master;
}
} {table t1 t1 table tx tx}
do_test attach-2.15 {
execsql {
SELECT type, name, tbl_name FROM db2.sqlite_master;
}
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
do_test attach-2.16 {
db close
sqlite db test.db
execsql {
ATTACH 'test2.db' AS db2;
SELECT type, name, tbl_name FROM db2.sqlite_master;
}
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
do_test attach-3.1 {
db close
db2 close
sqlite db test.db
sqlite db2 test2.db
execsql {
SELECT * FROM t1
}
} {1 2 3 4}
do_test attach-3.2 {
catchsql {
SELECT * FROM t2
}
} {1 {no such table: t2}}
do_test attach-3.3 {
catchsql {
ATTACH DATABASE 'test2.db' AS db2;
SELECT * FROM t2
}
} {0 {21 x 22 y}}
# Even though main has a transaction, test2.db should not be locked.
do_test attach-3.4 {
execsql BEGIN
catchsql {
SELECT * FROM t2;
} db2;
} {0 {21 x 22 y}}
# Reading from db2 should not lock test2.db
do_test attach-3.5 {
execsql {SELECT * FROM t2}
catchsql {
SELECT * FROM t2;
} db2;
} {0 {21 x 22 y}}
# Making a change to db2 causes test2.ddb to become locked.
do_test attach-3.6 {
execsql {
UPDATE t2 SET x=x+1 WHERE x=50;
}
catchsql {
SELECT * FROM t2;
} db2;
} {1 {database is locked}}
do_test attach-3.7 {
execsql ROLLBACK
execsql {SELECT * FROM t2} db2
} {21 x 22 y}
do_test attach-3.8 {
execsql BEGIN
execsql BEGIN db2
catchsql {SELECT * FROM t2}
} {1 {database is locked}}
do_test attach-3.9 {
catchsql {SELECT * FROM t2} db2
} {0 {21 x 22 y}}
do_test attach-3.10 {
execsql {SELECT * FROM t1}
} {1 2 3 4}
do_test attach-3.11 {
catchsql {UPDATE t1 SET a=a+1}
} {0 {}}
do_test attach-3.12 {
execsql {SELECT * FROM t1}
} {2 2 4 4}
do_test attach-3.13 {
catchsql {UPDATE t2 SET x=x+1 WHERE x=50}
} {1 {database is locked}}
do_test attach-3.14 {
# Unable to reinitialize the schema tables because the aux database
# is still locked.
catchsql {SELECT * FROM t1}
} {1 {database is locked}}
do_test attach-3.15 {
execsql COMMIT db2
execsql {SELECT * FROM t1}
} {1 2 3 4}
# Ticket #323
do_test attach-4.1 {
execsql {DETACH db2}
db2 close
sqlite db2 test2.db
execsql {
CREATE TABLE t3(x,y);
CREATE UNIQUE INDEX t3i1 ON t3(x);
INSERT INTO t3 VALUES(1,2);
SELECT * FROM t3;
} db2;
} {1 2}
do_test attach-4.2 {
execsql {
CREATE TABLE t3(a,b);
CREATE UNIQUE INDEX t3i1b ON t3(a);
INSERT INTO t3 VALUES(9,10);
SELECT * FROM t3;
}
} {9 10}
do_test attach-4.3 {
execsql {
ATTACH DATABASE 'test2.db' AS db2;
SELECT * FROM db2.t3;
}
} {1 2}
do_test attach-4.4 {
execsql {
SELECT * FROM main.t3;
}
} {9 10}
do_test attach-4.5 {
execsql {
INSERT INTO db2.t3 VALUES(9,10);
SELECT * FROM db2.t3;
}
} {1 2 9 10}
do_test attach-4.6 {
execsql {
DETACH db2;
}
execsql {
CREATE TABLE t4(x);
CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN
INSERT INTO t4 VALUES('db2.' || NEW.x);
END;
INSERT INTO t3 VALUES(6,7);
SELECT * FROM t4;
} db2
} {db2.6}
do_test attach-4.7 {
execsql {
CREATE TABLE t4(y);
CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN
INSERT INTO t4 VALUES('main.' || NEW.a);
END;
INSERT INTO main.t3 VALUES(11,12);
SELECT * FROM main.t4;
}
} {main.11}
do_test attach-4.8 {
execsql {
ATTACH DATABASE 'test2.db' AS db2;
INSERT INTO db2.t3 VALUES(13,14);
SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;
}
} {db2.6 db2.13 main.11}
do_test attach-4.9 {
execsql {
INSERT INTO main.t3 VALUES(15,16);
SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;
}
} {db2.6 db2.13 main.11 main.15}
do_test attach-4.10 {
execsql {
DETACH DATABASE db2;
}
execsql {
CREATE VIEW v3 AS SELECT x*100+y FROM t3;
SELECT * FROM v3;
} db2
} {102 910 607 1314}
do_test attach-4.11 {
execsql {
CREATE VIEW v3 AS SELECT a*100+b FROM t3;
SELECT * FROM v3;
}
} {910 1112 1516}
do_test attach-4.12 {
execsql {
ATTACH DATABASE 'test2.db' AS db2;
SELECT * FROM db2.v3;
}
} {102 910 607 1314}
do_test attach-4.13 {
execsql {
SELECT * FROM main.v3;
}
} {910 1112 1516}
# Tests for the sqliteFix...() routines in attach.c
#
do_test attach-5.1 {
db close
sqlite db test.db
db2 close
file delete -force test2.db
sqlite db2 test2.db
catchsql {
ATTACH DATABASE 'test.db' AS orig;
CREATE TRIGGER r1 AFTER INSERT ON orig.t1 BEGIN;
SELECT 'no-op';
END;
} db2
} {1 {triggers may not be added to auxiliary database orig}}
do_test attach-5.2 {
catchsql {
CREATE TABLE t5(x,y);
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
SELECT 'no-op';
END;
} db2
} {0 {}}
do_test attach-5.3 {
catchsql {
DROP TRIGGER r5;
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
SELECT 'no-op' FROM orig.t1;
END;
} db2
} {1 {trigger r5 cannot reference objects in database orig}}
do_test attach-5.4 {
catchsql {
CREATE TEMP TABLE t6(p,q,r);
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
SELECT 'no-op' FROM temp.t6;
END;
} db2
} {1 {trigger r5 cannot reference objects in database temp}}
do_test attach-5.5 {
catchsql {
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
SELECT 'no-op' || (SELECT * FROM temp.t6);
END;
} db2
} {1 {trigger r5 cannot reference objects in database temp}}
do_test attach-5.6 {
catchsql {
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
SELECT 'no-op' FROM t1 WHERE x<(SELECT min(x) FROM temp.t6);
END;
} db2
} {1 {trigger r5 cannot reference objects in database temp}}
do_test attach-5.7 {
catchsql {
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
SELECT 'no-op' FROM t1 GROUP BY 1 HAVING x<(SELECT min(x) FROM temp.t6);
END;
} db2
} {1 {trigger r5 cannot reference objects in database temp}}
do_test attach-5.7 {
catchsql {
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
SELECT max(1,x,(SELECT min(x) FROM temp.t6)) FROM t1;
END;
} db2
} {1 {trigger r5 cannot reference objects in database temp}}
do_test attach-5.8 {
catchsql {
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
INSERT INTO t1 VALUES((SELECT min(x) FROM temp.t6),5);
END;
} db2
} {1 {trigger r5 cannot reference objects in database temp}}
do_test attach-5.9 {
catchsql {
CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
DELETE FROM t1 WHERE x<(SELECT min(x) FROM temp.t6);
END;
} db2
} {1 {trigger r5 cannot reference objects in database temp}}
# Check to make sure we get a sensible error if unable to open
# the file that we are trying to attach.
#
do_test attach-6.1 {
catchsql {
ATTACH DATABASE 'no-such-file' AS nosuch;
}
} {1 {cannot attach empty database: nosuch}}
file delete -force no-such-file
if {$tcl_platform(platform)=="unix"} {
do_test attach-6.2 {
sqlite dbx cannot-read
dbx eval {CREATE TABLE t1(a,b,c)}
dbx close
file attributes cannot-read -permission 0000
catchsql {
ATTACH DATABASE 'cannot-read' AS noread;
}
} {1 {unable to open database: cannot-read}}
file delete -force cannot-read
}
for {set i 2} {$i<=15} {incr i} {
catch {db$i close}
}
file delete -force test2.db
finish_test
+146
View File
@@ -0,0 +1,146 @@
# 2003 July 1
#
# 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 implements regression tests for SQLite library. The
# focus of this script is testing the ATTACH and DETACH commands
# and related functionality.
#
# $Id: attach2.test,v 1.5 2004/02/12 15:31:22 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Ticket #354
#
do_test attach2-1.1 {
db eval {
CREATE TABLE t1(a,b);
CREATE INDEX x1 ON t1(a);
}
file delete -force test2.db
file delete -force test2.db-journal
sqlite db2 test2.db
db2 eval {
CREATE TABLE t1(a,b);
CREATE INDEX x1 ON t1(a);
}
catchsql {
ATTACH 'test2.db' AS t2;
}
} {0 {}}
# Ticket #514
#
proc db_list {db} {
set list {}
foreach {idx name file} [execsql {PRAGMA database_list} $db] {
lappend list $idx $name
}
return $list
}
db eval {DETACH t2}
do_test attach2-2.1 {
# lock test2.db then try to attach it. Should get an error.
db2 eval {BEGIN}
catchsql {
ATTACH 'test2.db' AS t2;
}
} {1 {database is locked}}
do_test attach2-2.2 {
# make sure test2.db did not get attached.
db_list db
} {0 main 1 temp}
do_test attach2-2.3 {
# unlock test2.db and try to attach again. should work this time.
db2 eval {COMMIT}
catchsql {
ATTACH 'test2.db' AS t2;
}
} {0 {}}
do_test attach2-2.4 {
db_list db
} {0 main 1 temp 2 t2}
do_test attach2-2.5 {
catchsql {
SELECT name FROM t2.sqlite_master;
}
} {0 {t1 x1}}
do_test attach2-2.6 {
# lock test2.db and try to read from it. should get an error.
db2 eval BEGIN
catchsql {
SELECT name FROM t2.sqlite_master;
}
} {1 {database is locked}}
do_test attach2-2.7 {
# but we can still read from test1.db even though test2.db is locked.
catchsql {
SELECT name FROM main.sqlite_master;
}
} {0 {t1 x1}}
do_test attach2-2.8 {
# start a transaction on test.db even though test2.db is locked.
catchsql {
BEGIN;
INSERT INTO t1 VALUES(8,9);
}
} {0 {}}
do_test attach2-2.9 {
execsql {
SELECT * FROM t1
}
} {8 9}
do_test attach2-2.10 {
# now try to write to test2.db. the write should fail
catchsql {
INSERT INTO t2.t1 VALUES(1,2);
}
} {1 {database is locked}}
do_test attach2-2.11 {
# when the write failed in the previous test, the transaction should
# have rolled back.
db2 eval ROLLBACK
execsql {
SELECT * FROM t1
}
} {}
do_test attach2-2.12 {
catchsql {
COMMIT
}
} {1 {cannot commit - no transaction is active}}
# Ticket #574: Make sure it works usingi the non-callback API
#
do_test attach2-3.1 {
db close
set DB [sqlite db test.db]
set rc [catch {sqlite_compile $DB "ATTACH 'test2.db' AS t2" TAIL} VM]
if {$rc} {lappend rc $VM}
sqlite_finalize $VM
set rc
} {0}
do_test attach2-3.2 {
set rc [catch {sqlite_compile $DB "DETACH t2" TAIL} VM]
if {$rc} {lappend rc $VM}
sqlite_finalize $VM
set rc
} {0}
db close
for {set i 2} {$i<=15} {incr i} {
catch {db$i close}
}
file delete -force test2.db
finish_test
+1898
View File
File diff suppressed because it is too large Load Diff
+177
View File
@@ -0,0 +1,177 @@
# 2002 November 30
#
# 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 implements regression tests for SQLite library. The
# focus of this script testing the ability of SQLite to handle database
# files larger than 4GB.
#
# $Id: bigfile.test,v 1.3 2003/12/19 12:31:22 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# These tests only work for Tcl version 8.4 and later. Prior to 8.4,
# Tcl was unable to handle large files.
#
scan $::tcl_version %f vx
if {$vx<8.4} return
# This is the md5 checksum of all the data in table t1 as created
# by the first test. We will use this number to make sure that data
# never changes.
#
set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
do_test bigfile-1.1 {
execsql {
BEGIN;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
COMMIT;
}
execsql {
SELECT md5sum(x) FROM t1;
}
} $::MAGIC_SUM
# Try to create a large file - a file that is larger than 2^32 bytes.
# If this fails, it means that the system being tested does not support
# large files. So skip all of the remaining tests in this file.
#
db close
if {[catch {fake_big_file 4096 test.db}]} {
puts "**** Unable to create a file larger than 4096 MB. *****"
finish_test
return
}
do_test bigfile-1.2 {
sqlite db test.db
execsql {
SELECT md5sum(x) FROM t1;
}
} $::MAGIC_SUM
# The previous test may fail on some systems because they are unable
# to handle large files. If that is so, then skip all of the following
# tests. We will know the above test failed because the "db" command
# does not exist.
#
if {[llength [info command db]]>0} {
do_test bigfile-1.3 {
execsql {
CREATE TABLE t2 AS SELECT * FROM t1;
SELECT md5sum(x) FROM t2;
}
} $::MAGIC_SUM
do_test bigfile-1.4 {
db close
sqlite db test.db
execsql {
SELECT md5sum(x) FROM t1;
}
} $::MAGIC_SUM
do_test bigfile-1.5 {
execsql {
SELECT md5sum(x) FROM t2;
}
} $::MAGIC_SUM
db close
if {[catch {fake_big_file 8192 test.db}]} {
puts "**** Unable to create a file larger than 8192 MB. *****"
finish_test
return
}
do_test bigfile-1.6 {
sqlite db test.db
execsql {
SELECT md5sum(x) FROM t1;
}
} $::MAGIC_SUM
do_test bigfile-1.7 {
execsql {
CREATE TABLE t3 AS SELECT * FROM t1;
SELECT md5sum(x) FROM t3;
}
} $::MAGIC_SUM
do_test bigfile-1.8 {
db close
sqlite db test.db
execsql {
SELECT md5sum(x) FROM t1;
}
} $::MAGIC_SUM
do_test bigfile-1.9 {
execsql {
SELECT md5sum(x) FROM t2;
}
} $::MAGIC_SUM
do_test bigfile-1.10 {
execsql {
SELECT md5sum(x) FROM t3;
}
} $::MAGIC_SUM
db close
if {[catch {fake_big_file 16384 test.db}]} {
puts "**** Unable to create a file larger than 16384 MB. *****"
finish_test
return
}
do_test bigfile-1.11 {
sqlite db test.db
execsql {
SELECT md5sum(x) FROM t1;
}
} $::MAGIC_SUM
do_test bigfile-1.12 {
execsql {
CREATE TABLE t4 AS SELECT * FROM t1;
SELECT md5sum(x) FROM t4;
}
} $::MAGIC_SUM
do_test bigfile-1.13 {
db close
sqlite db test.db
execsql {
SELECT md5sum(x) FROM t1;
}
} $::MAGIC_SUM
do_test bigfile-1.14 {
execsql {
SELECT md5sum(x) FROM t2;
}
} $::MAGIC_SUM
do_test bigfile-1.15 {
execsql {
SELECT md5sum(x) FROM t3;
}
} $::MAGIC_SUM
do_test bigfile-1.16 {
execsql {
SELECT md5sum(x) FROM t3;
}
} $::MAGIC_SUM
} ;# End of the "if( db command exists )"
finish_test
+115 -5
View File
@@ -12,7 +12,7 @@
# focus of this file is stressing the library by putting large amounts
# of data in a single row of a table.
#
# $Id: bigrow.test,v 1.1 2001/09/24 03:12:40 drh Exp $
# $Id: bigrow.test,v 1.4 2001/11/24 00:31:47 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -50,11 +50,22 @@ do_test bigrow-1.3 {
execsql {SELECT b FROM t1}
} [list $::big1]
do_test bigrow-1.4 {
set sql "INSERT INTO t1 VALUES('abc',"
append sql "'[string range $::bigstr 0 65520]', 'xyz');"
set ::big2 [string range $::bigstr 0 65520]
set sql "INSERT INTO t1 VALUES('abc2',"
append sql "'$::big2', 'xyz2');"
set r [catch {execsql $sql} msg]
lappend r $msg
} {1 {too much data for one table row}}
} {0 {}}
do_test bigrow-1.4.1 {
execsql {SELECT b FROM t1 ORDER BY c}
} [list $::big1 $::big2]
do_test bigrow-1.4.2 {
execsql {SELECT c FROM t1 ORDER BY c}
} {xyz xyz2}
do_test bigrow-1.4.3 {
execsql {DELETE FROM t1 WHERE a='abc2'}
execsql {SELECT c FROM t1}
} {xyz}
do_test bigrow-1.5 {
execsql {
@@ -79,7 +90,7 @@ do_test bigrow-1.8 {
} {abc}
do_test bigrow-1.9 {
execsql "SELECT b FROM t1 WHERE a!='$::big1' ORDER BY a"
} {B 2}
} {2 B}
# Try doing some indexing on big columns
#
@@ -101,5 +112,104 @@ do_test bigrow-2.3 {
}
execsql "SELECT b FROM t1 WHERE a=='$::big1'"
} {abc}
catch {unset ::bigstr}
catch {unset ::big1}
catch {unset ::big2}
# Mosts of the tests above were created back when rows were limited in
# size to 64K. Now rows can be much bigger. Test that logic. Also
# make sure things work correctly at the transition boundries between
# row sizes of 256 to 257 bytes and from 65536 to 65537 bytes.
#
# We begin by testing the 256..257 transition.
#
do_test bigrow-3.1 {
execsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
}
execsql {SELECT a,length(b),c FROM t1}
} {one 30 hi}
do_test bigrow-3.2 {
execsql {
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
}
execsql {SELECT a,length(b),c FROM t1}
} {one 240 hi}
for {set i 1} {$i<10} {incr i} {
do_test bigrow-3.3.$i {
execsql "UPDATE t1 SET b=b||'$i'"
execsql {SELECT a,length(b),c FROM t1}
} "one [expr {240+$i}] hi"
}
# Now test the 65536..65537 row-size transition.
#
do_test bigrow-4.1 {
execsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
}
execsql {SELECT a,length(b),c FROM t1}
} {one 30 hi}
do_test bigrow-4.2 {
execsql {
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
UPDATE t1 SET b=b||b;
}
execsql {SELECT a,length(b),c FROM t1}
} {one 122880 hi}
do_test bigrow-4.3 {
execsql {
UPDATE t1 SET b=substr(b,1,65515)
}
execsql {SELECT a,length(b),c FROM t1}
} {one 65515 hi}
for {set i 1} {$i<10} {incr i} {
do_test bigrow-4.4.$i {
execsql "UPDATE t1 SET b=b||'$i'"
execsql {SELECT a,length(b),c FROM t1}
} "one [expr {65515+$i}] hi"
}
# Check to make sure the library recovers safely if a row contains
# too much data.
#
do_test bigrow-5.1 {
execsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
}
execsql {SELECT a,length(b),c FROM t1}
} {one 30 hi}
set i 1
for {set sz 60} {$sz<1048560} {incr sz $sz} {
do_test bigrow-5.2.$i {
execsql {
UPDATE t1 SET b=b||b;
SELECT a,length(b),c FROM t1;
}
} "one $sz hi"
incr i
}
do_test bigrow-5.3 {
set r [catch {execsql {UPDATE t1 SET b=b||b}} msg]
lappend r $msg
} {1 {too much data for one table row}}
do_test bigrow-5.4 {
execsql {DROP TABLE t1}
} {}
finish_test
+72
View File
@@ -0,0 +1,72 @@
# 2003 September 6
#
# 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 implements regression tests for SQLite library. The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.1 2003/09/06 22:45:21 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test bind-1.1 {
db close
set DB [sqlite db test.db]
execsql {CREATE TABLE t1(a,b,c)}
set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(?,?,?)} TAIL]
set TAIL
} {}
do_test bind-1.2 {
sqlite_step $VM N VALUES COLNAMES
} {SQLITE_DONE}
do_test bind-1.3 {
execsql {SELECT rowid, * FROM t1}
} {1 {} {} {}}
do_test bind-1.4 {
sqlite_reset $VM
sqlite_bind $VM 1 {test value 1} normal
sqlite_step $VM N VALUES COLNAMES
} SQLITE_DONE
do_test bind-1.5 {
execsql {SELECT rowid, * FROM t1}
} {1 {} {} {} 2 {test value 1} {} {}}
do_test bind-1.6 {
sqlite_reset $VM
sqlite_bind $VM 3 {'test value 2'} normal
sqlite_step $VM N VALUES COLNAMES
} SQLITE_DONE
do_test bind-1.7 {
execsql {SELECT rowid, * FROM t1}
} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}
do_test bind-1.8 {
sqlite_reset $VM
set sqlite_static_bind_value 123
sqlite_bind $VM 1 {} static
sqlite_bind $VM 2 {abcdefg} normal
sqlite_bind $VM 3 {} null
execsql {DELETE FROM t1}
sqlite_step $VM N VALUES COLNAMES
execsql {SELECT rowid, * FROM t1}
} {1 123 abcdefg {}}
do_test bind-1.9 {
sqlite_reset $VM
sqlite_bind $VM 1 {456} normal
sqlite_step $VM N VALUES COLNAMES
execsql {SELECT rowid, * FROM t1}
} {1 123 abcdefg {} 2 456 abcdefg {}}
do_test bind-1.99 {
sqlite_finalize $VM
} {}
finish_test
+14 -12
View File
@@ -11,13 +11,14 @@
# This file implements regression tests for SQLite library. The
# focus of this script is btree database backend
#
# $Id: btree.test,v 1.10 2001/09/23 02:35:53 drh Exp $
# $Id: btree.test,v 1.15 2004/02/10 01:54:28 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {[info commands btree_open]!=""} {
if {[info commands btree_open]!="" && $SQLITE_PAGE_SIZE==1024
&& $SQLITE_USABLE_SIZE==1024} {
# Basic functionality. Open and close a database.
#
@@ -344,6 +345,7 @@ do_test btree-4.8 {
} {2}
do_test btree-4.9 {
set r {}
btree_first $::c1
while 1 {
set key [btree_key $::c1]
if {$key==""} break
@@ -358,30 +360,30 @@ do_test btree-4.9 {
#
do_test btree-5.1 {
btree_get_meta $::b1
} {0 0 0 0}
} {0 0 0 0 0 0 0 0 0 0}
do_test btree-5.2 {
set rc [catch {btree_update_meta $::b1 1 2 3 4} msg]
set rc [catch {btree_update_meta $::b1 1 2 3 4 5 6 7 8 9 10} msg]
lappend rc $msg
} {1 SQLITE_ERROR}
do_test btree-5.3 {
btree_begin_transaction $::b1
set rc [catch {btree_update_meta $::b1 1 2 3 4} msg]
set rc [catch {btree_update_meta $::b1 1 2 3 4 5 6 7 8 9 10} msg]
lappend rc $msg
} {0 {}}
do_test btree-5.4 {
btree_get_meta $::b1
} {0 2 3 4}
} {0 2 3 4 5 6 7 8 9 10}
do_test btree-5.5 {
btree_close_cursor $::c1
btree_rollback $::b1
btree_get_meta $::b1
} {0 0 0 0}
} {0 0 0 0 0 0 0 0 0 0}
do_test btree-5.6 {
btree_begin_transaction $::b1
btree_update_meta $::b1 999 10 20 30
btree_update_meta $::b1 999 10 20 30 40 50 60 70 80 90
btree_commit $::b1
btree_get_meta $::b1
} {0 10 20 30}
} {0 10 20 30 40 50 60 70 80 90}
proc select_all {cursor} {
set r {}
@@ -986,7 +988,7 @@ do_test btree-12.12 {
btree_key $::c1
} {402}
do_test btree-13.1 {
btree_sanity_check $::b1 2 3
btree_integrity_check $::b1 2 3
} {}
# To Do:
@@ -997,11 +999,11 @@ do_test btree-13.1 {
# 4. Implement btree_sanity and put it throughout this script
#
do_test btree-10.98 {
do_test btree-15.98 {
btree_close_cursor $::c1
lindex [btree_pager_stats $::b1] 1
} {1}
do_test btree-10.99 {
do_test btree-15.99 {
btree_rollback $::b1
lindex [btree_pager_stats $::b1] 1
} {0}
+4 -4
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is btree database backend
#
# $Id: btree2.test,v 1.9 2001/10/22 02:58:11 drh Exp $
# $Id: btree2.test,v 1.10 2002/02/19 13:39:23 drh Exp $
set testdir [file dirname $argv0]
@@ -53,7 +53,7 @@ do_test btree2-1.5 {
btree_delete $::c2
btree_close_cursor $::c2
btree_commit $::b
btree_sanity_check $::b 2 3 4 5 6
btree_integrity_check $::b 2 3 4 5 6
} {}
# This test module works by making lots of pseudo-random changes to a
@@ -125,7 +125,7 @@ proc make_payload {keynum L len} {
# success or an error message if something is amiss.
#
proc check_invariants {} {
set ck [btree_sanity_check $::b 2 3 4 5 6]
set ck [btree_integrity_check $::b 2 3 4 5 6]
if {$ck!=""} {
puts "\n*** SANITY:\n$ck"
exit
@@ -259,7 +259,7 @@ proc random_changes {n I K D} {
} elseif {[btree_move_to $::c6 $basekey]==0} {
btree_delete $::c6
}
# set ck [btree_sanity_check $::b 2 3 4 5 6]
# set ck [btree_integrity_check $::b 2 3 4 5 6]
# if {$ck!=""} {
# puts "\nSANITY CHECK FAILED!\n$ck"
# exit
+86
View File
@@ -0,0 +1,86 @@
# 2001 November 22
#
# 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 implements regression tests for SQLite library. The
# focus of this script is btree database backend
#
# In particular, this file tests a small part of the Delete logic
# for the BTree backend. When a row is deleted from a table, the
# cursor is suppose to be left pointing at either the previous or
# next entry in that table. If the cursor is left pointing at the
# next entry, then the next Next operation is ignored. So the
# sequence of operations (Delete, Next) should always leave the
# cursor pointing at the first entry past the one that was deleted.
# This test is designed to verify that behavior.
#
# $Id: btree3.test,v 1.2 2002/12/04 13:40:27 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {[info commands btree_open]!=""} {
# Open a test database.
#
file delete -force test1.bt
file delete -force test1.bt-journal
set b1 [btree_open test1.bt]
btree_begin_transaction $::b1
# Insert a few one records
#
set data {abcdefghijklmnopqrstuvwxyz0123456789}
append data $data
append data $data
append data $data
append data $data
for {set k 2} {$k<=10} {incr k} {
for {set j 1} {$j<=$k} {incr j} {
set jkey [format %02d $j]
btree_clear_table $::b1 2
set ::c1 [btree_cursor $::b1 2 1]
for {set i 1} {$i<=$k} {incr i} {
set key [format %02d $i]
do_test btree3-$k.$j.1.$i {
btree_insert $::c1 $::key $::data
} {}
# btree_tree_dump $::b1 2
}
do_test btree3-$k.$j.2 {
btree_move_to $::c1 $::jkey
btree_key $::c1
} $::jkey
do_test btree3-$k.$j.3 {
btree_delete $::c1
} {}
if {$j<$k} {
do_test btree3-$k.$j.4 {
btree_next $::c1
btree_key $::c1
} [format %02d [expr $j+1]]
}
if {$j>1} {
do_test btree3-$k.$j.5 {
btree_prev $::c1
btree_key $::c1
} [format %02d [expr $j-1]]
}
btree_close_cursor $::c1
}
}
btree_rollback $::b1
btree_pager_ref_dump $::b1
btree_close $::b1
} ;# end if( not mem: and has pager_open command );
finish_test
+84
View File
@@ -0,0 +1,84 @@
# 2001 November 22
#
# 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 implements regression tests for SQLite library. The
# focus of this script is btree database backend
#
# In particular, this file tests a small part of the Delete logic
# for the BTree backend. When a row is deleted from a table, the
# cursor is suppose to be left pointing at either the previous or
# next entry in that table. If the cursor is left pointing at the
# next entry, then the next Next operation is ignored. So the
# sequence of operations (Delete, Next) should always leave the
# cursor pointing at the first entry past the one that was deleted.
# This test is designed to verify that behavior.
#
# $Id: btree3rb.test,v 1.1 2003/04/20 23:45:23 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {[info commands btree_open]!=""} {
# Open a test database.
#
set b1 [btree_open :memory:]
btree_begin_transaction $::b1
# Insert a few one records
#
set data {abcdefghijklmnopqrstuvwxyz0123456789}
append data $data
append data $data
append data $data
append data $data
for {set k 2} {$k<=20} {incr k} {
for {set j 1} {$j<=$k} {incr j} {
set jkey [format %02d $j]
btree_clear_table $::b1 2
set ::c1 [btree_cursor $::b1 2 1]
for {set i 1} {$i<=$k} {incr i} {
set key [format %02d $i]
do_test btree3rb-$k.$j.1.$i {
btree_insert $::c1 $::key $::data
} {}
# btree_tree_dump $::b1 2
}
do_test btree3rb-$k.$j.2 {
btree_move_to $::c1 $::jkey
btree_key $::c1
} $::jkey
do_test btree3rb-$k.$j.3 {
btree_delete $::c1
} {}
if {$j<$k} {
do_test btree3rb-$k.$j.4 {
btree_next $::c1
btree_key $::c1
} [format %02d [expr $j+1]]
}
if {$j>1} {
do_test btree3rb-$k.$j.5 {
btree_prev $::c1
btree_key $::c1
} [format %02d [expr $j-1]]
}
btree_close_cursor $::c1
}
}
btree_rollback $::b1
#btree_pager_ref_dump $::b1
btree_close $::b1
} ;# end if( not mem: and has pager_open command );
finish_test
+98
View File
@@ -0,0 +1,98 @@
# 2002 December 03
#
# 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 implements regression tests for SQLite library. The
# focus of this script is btree database backend
#
# This file focuses on testing the sqliteBtreeNext() and
# sqliteBtreePrevious() procedures and making sure they are able
# to step through an entire table from either direction.
#
# $Id: btree4.test,v 1.1 2002/12/04 13:40:27 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {[info commands btree_open]!=""} {
# Open a test database.
#
file delete -force test1.bt
file delete -force test1.bt-journal
set b1 [btree_open test1.bt]
btree_begin_transaction $::b1
set data {abcdefghijklmnopqrstuvwxyz0123456789}
append data $data
append data $data
append data $data
append data $data
foreach N {10 100 1000} {
btree_clear_table $::b1 2
set ::c1 [btree_cursor $::b1 2 1]
do_test btree4-$N.1 {
for {set i 1} {$i<=$N} {incr i} {
btree_insert $::c1 [format k-%05d $i] $::data-$i
}
btree_first $::c1
btree_key $::c1
} {k-00001}
do_test btree4-$N.2 {
btree_data $::c1
} $::data-1
for {set i 2} {$i<=$N} {incr i} {
do_test btree-$N.3.$i.1 {
btree_next $::c1
} 0
do_test btree-$N.3.$i.2 {
btree_key $::c1
} [format k-%05d $i]
do_test btree-$N.3.$i.3 {
btree_data $::c1
} $::data-$i
}
do_test btree4-$N.4 {
btree_next $::c1
} 1
do_test btree4-$N.5 {
btree_last $::c1
} 0
do_test btree4-$N.6 {
btree_key $::c1
} [format k-%05d $N]
do_test btree4-$N.7 {
btree_data $::c1
} $::data-$N
for {set i [expr {$N-1}]} {$i>=1} {incr i -1} {
do_test btree4-$N.8.$i.1 {
btree_prev $::c1
} 0
do_test btree4-$N.8.$i.2 {
btree_key $::c1
} [format k-%05d $i]
do_test btree4-$N.8.$i.3 {
btree_data $::c1
} $::data-$i
}
do_test btree4-$N.9 {
btree_prev $::c1
} 1
btree_close_cursor $::c1
}
btree_rollback $::b1
btree_pager_ref_dump $::b1
btree_close $::b1
} ;# end if( not mem: and has pager_open command );
finish_test
+95
View File
@@ -0,0 +1,95 @@
# 2002 December 03
#
# 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 implements regression tests for SQLite library. The
# focus of this script is btree database backend
#
# This file focuses on testing the sqliteBtreeNext() and
# sqliteBtreePrevious() procedures and making sure they are able
# to step through an entire table from either direction.
#
# $Id: btree4rb.test,v 1.1 2003/04/20 23:45:23 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {[info commands btree_open]!=""} {
# Open a test database.
#
set b1 [btree_open :memory:]
btree_begin_transaction $::b1
set data {abcdefghijklmnopqrstuvwxyz0123456789}
append data $data
append data $data
append data $data
append data $data
foreach N {10 100 1000} {
btree_clear_table $::b1 2
set ::c1 [btree_cursor $::b1 2 1]
do_test btree4rb-$N.1 {
for {set i 1} {$i<=$N} {incr i} {
btree_insert $::c1 [format k-%05d $i] $::data-$i
}
btree_first $::c1
btree_key $::c1
} {k-00001}
do_test btree4rb-$N.2 {
btree_data $::c1
} $::data-1
for {set i 2} {$i<=$N} {incr i} {
do_test btree-$N.3.$i.1 {
btree_next $::c1
} 0
do_test btree-$N.3.$i.2 {
btree_key $::c1
} [format k-%05d $i]
do_test btree-$N.3.$i.3 {
btree_data $::c1
} $::data-$i
}
do_test btree4rb-$N.4 {
btree_next $::c1
} 1
do_test btree4rb-$N.5 {
btree_last $::c1
} 0
do_test btree4rb-$N.6 {
btree_key $::c1
} [format k-%05d $N]
do_test btree4rb-$N.7 {
btree_data $::c1
} $::data-$N
for {set i [expr {$N-1}]} {$i>=1} {incr i -1} {
do_test btree4rb-$N.8.$i.1 {
btree_prev $::c1
} 0
do_test btree4rb-$N.8.$i.2 {
btree_key $::c1
} [format k-%05d $i]
do_test btree4rb-$N.8.$i.3 {
btree_data $::c1
} $::data-$i
}
do_test btree4rb-$N.9 {
btree_prev $::c1
} 1
btree_close_cursor $::c1
}
btree_rollback $::b1
btree_close $::b1
} ;# end if( not mem: and has pager_open command );
finish_test
+475
View File
@@ -0,0 +1,475 @@
# 2003 January 29
#
# 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 implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API.
#
# $Id: capi2.test,v 1.10 2003/08/05 13:13:38 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Check basic functionality
#
do_test capi2-1.1 {
db close
set DB [sqlite db test.db]
execsql {CREATE TABLE t1(a,b,c)}
set VM [sqlite_compile $DB {SELECT name, rowid FROM sqlite_master} TAIL]
set TAIL
} {}
do_test capi2-1.2 {
sqlite_step $VM N VALUES COLNAMES
} {SQLITE_ROW}
do_test capi2-1.3 {
set N
} {2}
do_test capi2-1.4 {
set VALUES
} {t1 1}
do_test capi2-1.5 {
set COLNAMES
} {name rowid text INTEGER}
do_test capi2-1.6 {
set N x
set VALUES y
set COLNAMES z
sqlite_step $VM N VALUES COLNAMES
} {SQLITE_DONE}
do_test capi2-1.7 {
list $N $VALUES $COLNAMES
} {2 {} {name rowid text INTEGER}}
do_test capi2-1.8 {
set N x
set VALUES y
set COLNAMES z
sqlite_step $VM N VALUES COLNAMES
} {SQLITE_MISUSE}
do_test capi2-1.9 {
list $N $VALUES $COLNAMES
} {0 {} {}}
do_test capi2-1.10 {
sqlite_finalize $VM
} {}
# Check to make sure that the "tail" of a multi-statement SQL script
# is returned by sqlite_compile.
#
do_test capi2-2.1 {
set SQL {
SELECT name, rowid FROM sqlite_master;
SELECT name, rowid FROM sqlite_temp_master;
-- A comment at the end
}
set VM [sqlite_compile $DB $SQL SQL]
set SQL
} {
SELECT name, rowid FROM sqlite_temp_master;
-- A comment at the end
}
do_test capi2-2.2 {
set r [sqlite_step $VM n val colname]
lappend r $n $val $colname
} {SQLITE_ROW 2 {t1 1} {name rowid text INTEGER}}
do_test capi2-2.3 {
set r [sqlite_step $VM n val colname]
lappend r $n $val $colname
} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
do_test capi2-2.4 {
sqlite_finalize $VM
} {}
do_test capi2-2.5 {
set VM [sqlite_compile $DB $SQL SQL]
set SQL
} {
-- A comment at the end
}
do_test capi2-2.6 {
set r [sqlite_step $VM n val colname]
lappend r $n $val $colname
} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
do_test capi2-2.7 {
sqlite_finalize $VM
} {}
do_test capi2-2.8 {
set VM [sqlite_compile $DB $SQL SQL]
list $SQL $VM
} {{} {}}
# Check the error handling.
#
do_test capi2-3.1 {
set rc [catch {
sqlite_compile $DB {select bogus from sqlite_master} TAIL
} msg]
lappend rc $msg $TAIL
} {1 {(1) no such column: bogus} {}}
do_test capi2-3.2 {
set rc [catch {
sqlite_compile $DB {select bogus from } TAIL
} msg]
lappend rc $msg $TAIL
} {1 {(1) near " ": syntax error} {}}
do_test capi2-3.3 {
set rc [catch {
sqlite_compile $DB {;;;;select bogus from sqlite_master} TAIL
} msg]
lappend rc $msg $TAIL
} {1 {(1) no such column: bogus} {}}
do_test capi2-3.4 {
set rc [catch {
sqlite_compile $DB {select bogus from sqlite_master;x;} TAIL
} msg]
lappend rc $msg $TAIL
} {1 {(1) no such column: bogus} {x;}}
do_test capi2-3.5 {
set rc [catch {
sqlite_compile $DB {select bogus from sqlite_master;;;x;} TAIL
} msg]
lappend rc $msg $TAIL
} {1 {(1) no such column: bogus} {;;x;}}
do_test capi2-3.6 {
set rc [catch {
sqlite_compile $DB {select 5/0} TAIL
} VM]
lappend rc $TAIL
} {0 {}}
do_test capi2-3.7 {
set N {}
set VALUE {}
set COLNAME {}
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 {{}} {5/0 NUMERIC}}
do_test capi2-3.8 {
sqlite_finalize $VM
} {}
do_test capi2-3.9 {
execsql {CREATE UNIQUE INDEX i1 ON t1(a)}
set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(1,2,3)} TAIL]
set TAIL
} {}
do_test capi2-3.9b {db changes} {0}
do_test capi2-3.10 {
set N {}
set VALUE {}
set COLNAME {}
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_DONE 0 {} {}}
do_test capi2-3.10b {db changes} {1}
do_test capi2-3.11 {
sqlite_finalize $VM
} {}
do_test capi2-3.11b {db changes} {1}
do_test capi2-3.12 {
list [catch {sqlite_finalize $VM} msg] [set msg]
} {1 {(21) library routine called out of sequence}}
do_test capi2-3.13 {
set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(1,3,4)} TAIL]
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ERROR 0 {} {}}
do_test capi2-3.13b {db changes} {0}
do_test capi2-3.14 {
list [catch {sqlite_finalize $VM} msg] [set msg]
} {1 {(19) column a is not unique}}
do_test capi2-3.15 {
set VM [sqlite_compile $DB {CREATE TABLE t2(a NOT NULL, b)} TAIL]
set TAIL
} {}
do_test capi2-3.16 {
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_DONE 0 {} {}}
do_test capi2-3.17 {
list [catch {sqlite_finalize $VM} msg] [set msg]
} {0 {}}
do_test capi2-3.18 {
set VM [sqlite_compile $DB {INSERT INTO t2 VALUES(NULL,2)} TAIL]
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ERROR 0 {} {}}
do_test capi2-3.19 {
list [catch {sqlite_finalize $VM} msg] [set msg]
} {1 {(19) t2.a may not be NULL}}
# Two or more virtual machines exists at the same time.
#
do_test capi2-4.1 {
set VM1 [sqlite_compile $DB {INSERT INTO t2 VALUES(1,2)} TAIL]
set TAIL
} {}
do_test capi2-4.2 {
set VM2 [sqlite_compile $DB {INSERT INTO t2 VALUES(2,3)} TAIL]
set TAIL
} {}
do_test capi2-4.3 {
set VM3 [sqlite_compile $DB {INSERT INTO t2 VALUES(3,4)} TAIL]
set TAIL
} {}
do_test capi2-4.4 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_DONE 0 {} {}}
do_test capi2-4.5 {
execsql {SELECT * FROM t2 ORDER BY a}
} {2 3}
do_test capi2-4.6 {
list [catch {sqlite_finalize $VM2} msg] [set msg]
} {0 {}}
do_test capi2-4.7 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_DONE 0 {} {}}
do_test capi2-4.8 {
execsql {SELECT * FROM t2 ORDER BY a}
} {2 3 3 4}
do_test capi2-4.9 {
list [catch {sqlite_finalize $VM3} msg] [set msg]
} {0 {}}
do_test capi2-4.10 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_DONE 0 {} {}}
do_test capi2-4.11 {
execsql {SELECT * FROM t2 ORDER BY a}
} {1 2 2 3 3 4}
do_test capi2-4.12 {
list [catch {sqlite_finalize $VM1} msg] [set msg]
} {0 {}}
# Interleaved SELECTs
#
do_test capi2-5.1 {
set VM1 [sqlite_compile $DB {SELECT * FROM t2} TAIL]
set VM2 [sqlite_compile $DB {SELECT * FROM t2} TAIL]
set VM3 [sqlite_compile $DB {SELECT * FROM t2} TAIL]
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {2 3} {a b {} {}}}
do_test capi2-5.2 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {2 3} {a b {} {}}}
do_test capi2-5.3 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {3 4} {a b {} {}}}
do_test capi2-5.4 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {2 3} {a b {} {}}}
do_test capi2-5.5 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {3 4} {a b {} {}}}
do_test capi2-5.6 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {1 2} {a b {} {}}}
do_test capi2-5.7 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_DONE 2 {} {a b {} {}}}
do_test capi2-5.8 {
list [catch {sqlite_finalize $VM3} msg] [set msg]
} {0 {}}
do_test capi2-5.9 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {1 2} {a b {} {}}}
do_test capi2-5.10 {
list [catch {sqlite_finalize $VM1} msg] [set msg]
} {0 {}}
do_test capi2-5.11 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {3 4} {a b {} {}}}
do_test capi2-5.12 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 2 {1 2} {a b {} {}}}
do_test capi2-5.11 {
list [catch {sqlite_finalize $VM2} msg] [set msg]
} {0 {}}
# Check for proper SQLITE_BUSY returns.
#
do_test capi2-6.1 {
execsql {
BEGIN;
CREATE TABLE t3(x counter);
INSERT INTO t3 VALUES(1);
INSERT INTO t3 VALUES(2);
INSERT INTO t3 SELECT x+2 FROM t3;
INSERT INTO t3 SELECT x+4 FROM t3;
INSERT INTO t3 SELECT x+8 FROM t3;
COMMIT;
}
set VM1 [sqlite_compile $DB {SELECT * FROM t3} TAIL]
sqlite db2 test.db
execsql {BEGIN} db2
} {}
do_test capi2-6.2 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_BUSY 0 {} {}}
do_test capi2-6.3 {
execsql {COMMIT} db2
} {}
do_test capi2-6.4 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 1 {x counter}}
do_test capi2-6.5 {
catchsql {BEGIN} db2
} {1 {database is locked}}
do_test capi2-6.6 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 2 {x counter}}
do_test capi2-6.7 {
execsql {SELECT * FROM t2} db2
} {2 3 3 4 1 2}
do_test capi2-6.8 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 3 {x counter}}
do_test capi2-6.9 {
execsql {SELECT * FROM t2}
} {2 3 3 4 1 2}
do_test capi2-6.10 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 4 {x counter}}
do_test capi2-6.11 {
execsql {BEGIN}
} {}
do_test capi2-6.12 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 5 {x counter}}
# execsql {pragma vdbe_trace=on}
do_test capi2-6.13 {
catchsql {UPDATE t3 SET x=x+1}
} {1 {database table is locked}}
do_test capi2-6.14 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 6 {x counter}}
# puts [list [catch {sqlite_finalize $VM1} msg] [set msg]]; exit
do_test capi2-6.15 {
execsql {SELECT * FROM t1}
} {1 2 3}
do_test capi2-6.16 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 7 {x counter}}
do_test capi2-6.17 {
catchsql {UPDATE t1 SET b=b+1}
} {0 {}}
do_test capi2-6.18 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 8 {x counter}}
do_test capi2-6.19 {
execsql {SELECT * FROM t1}
} {1 3 3}
do_test capi2-6.20 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 9 {x counter}}
do_test capi2-6.21 {
execsql {ROLLBACK; SELECT * FROM t1}
} {1 2 3}
do_test capi2-6.22 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 10 {x counter}}
do_test capi2-6.23 {
execsql {BEGIN TRANSACTION ON CONFLICT ROLLBACK;}
} {}
do_test capi2-6.24 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 11 {x counter}}
do_test capi2-6.25 {
execsql {
INSERT INTO t1 VALUES(2,3,4);
SELECT * FROM t1;
}
} {1 2 3 2 3 4}
do_test capi2-6.26 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 12 {x counter}}
do_test capi2-6.27 {
catchsql {
INSERT INTO t1 VALUES(2,4,5);
SELECT * FROM t1;
}
} {1 {column a is not unique}}
do_test capi2-6.28 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_ROW 1 13 {x counter}}
do_test capi2-6.99 {
list [catch {sqlite_finalize $VM1} msg] [set msg]
} {0 {}}
catchsql {ROLLBACK}
do_test capi2-7.1 {
stepsql $DB {
SELECT * FROM t1
}
} {0 1 2 3}
do_test capi2-7.2 {
stepsql $DB {
PRAGMA count_changes=on
}
} {0}
do_test capi2-7.3 {
stepsql $DB {
UPDATE t1 SET a=a+10;
}
} {0 1}
do_test capi2-7.4 {
stepsql $DB {
INSERT INTO t1 SELECT a+1,b+1,c+1 FROM t1;
}
} {0 1}
do_test capi2-7.4b {db changes} {1}
do_test capi2-7.5 {
stepsql $DB {
UPDATE t1 SET a=a+10;
}
} {0 2}
do_test capi2-7.5b {db changes} {2}
do_test capi2-7.6 {
stepsql $DB {
SELECT * FROM t1;
}
} {0 21 2 3 22 3 4}
do_test capi2-7.7 {
stepsql $DB {
INSERT INTO t1 SELECT a+2,b+2,c+2 FROM t1;
}
} {0 2}
do_test capi2-7.8 {
db changes
} {2}
do_test capi2-7.9 {
stepsql $DB {
SELECT * FROM t1;
}
} {0 21 2 3 22 3 4 23 4 5 24 5 6}
do_test capi2-7.10 {
stepsql $DB {
UPDATE t1 SET a=a-20;
SELECT * FROM t1;
}
} {0 4 1 2 3 2 3 4 3 4 5 4 5 6}
do_test capi2-7.11 {
db changes
} {0}
do_test capi2-7.12 {
set x [stepsql $DB {EXPLAIN SELECT * FROM t1}]
lindex $x 0
} {0}
# Ticket #261 - make sure we can finalize before the end of a query.
#
do_test capi2-8.1 {
set VM1 [sqlite_compile $DB {SELECT * FROM t2} TAIL]
sqlite_finalize $VM1
} {}
# Tickets #384 and #385 - make sure the TAIL argument to sqlite_compile
# and all of the return pointers in sqlite_step can be null.
#
do_test capi2-9.1 {
set VM1 [sqlite_compile $DB {SELECT * FROM t2}]
sqlite_step $VM1
sqlite_finalize $VM1
} {}
db2 close
finish_test
+694
View File
@@ -0,0 +1,694 @@
# 2002 January 29
#
# 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 implements regression tests for SQLite library.
#
# This file implements tests for the conflict resolution extension
# to SQLite.
#
# $Id: conflict.test,v 1.19 2003/08/05 13:13:39 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Create tables for the first group of tests.
#
do_test conflict-1.0 {
execsql {
CREATE TABLE t1(a, b, c, UNIQUE(a,b));
CREATE TABLE t2(x);
SELECT c FROM t1 ORDER BY c;
}
} {}
# Six columns of configuration data as follows:
#
# i The reference number of the test
# conf The conflict resolution algorithm on the BEGIN statement
# cmd An INSERT or REPLACE command to execute against table t1
# t0 True if there is an error from $cmd
# t1 Content of "c" column of t1 assuming no error in $cmd
# t2 Content of "x" column of t2
#
foreach {i conf cmd t0 t1 t2} {
1 {} INSERT 1 {} 1
2 {} {INSERT OR IGNORE} 0 3 1
3 {} {INSERT OR REPLACE} 0 4 1
4 {} REPLACE 0 4 1
5 {} {INSERT OR FAIL} 1 {} 1
6 {} {INSERT OR ABORT} 1 {} 1
7 {} {INSERT OR ROLLBACK} 1 {} {}
8 IGNORE INSERT 0 3 1
9 IGNORE {INSERT OR IGNORE} 0 3 1
10 IGNORE {INSERT OR REPLACE} 0 4 1
11 IGNORE REPLACE 0 4 1
12 IGNORE {INSERT OR FAIL} 1 {} 1
13 IGNORE {INSERT OR ABORT} 1 {} 1
14 IGNORE {INSERT OR ROLLBACK} 1 {} {}
15 REPLACE INSERT 0 4 1
16 FAIL INSERT 1 {} 1
17 ABORT INSERT 1 {} 1
18 ROLLBACK INSERT 1 {} {}
} {
do_test conflict-1.$i {
if {$conf!=""} {set conf "ON CONFLICT $conf"}
set r0 [catch {execsql [subst {
DELETE FROM t1;
DELETE FROM t2;
INSERT INTO t1 VALUES(1,2,3);
BEGIN $conf;
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
} [list $t0 $t1 $t2]
}
# Create tables for the first group of tests.
#
do_test conflict-2.0 {
execsql {
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(a,b));
CREATE TABLE t2(x);
SELECT c FROM t1 ORDER BY c;
}
} {}
# Six columns of configuration data as follows:
#
# i The reference number of the test
# conf The conflict resolution algorithm on the BEGIN statement
# cmd An INSERT or REPLACE command to execute against table t1
# t0 True if there is an error from $cmd
# t1 Content of "c" column of t1 assuming no error in $cmd
# t2 Content of "x" column of t2
#
foreach {i conf cmd t0 t1 t2} {
1 {} INSERT 1 {} 1
2 {} {INSERT OR IGNORE} 0 3 1
3 {} {INSERT OR REPLACE} 0 4 1
4 {} REPLACE 0 4 1
5 {} {INSERT OR FAIL} 1 {} 1
6 {} {INSERT OR ABORT} 1 {} 1
7 {} {INSERT OR ROLLBACK} 1 {} {}
8 IGNORE INSERT 0 3 1
9 IGNORE {INSERT OR IGNORE} 0 3 1
10 IGNORE {INSERT OR REPLACE} 0 4 1
11 IGNORE REPLACE 0 4 1
12 IGNORE {INSERT OR FAIL} 1 {} 1
13 IGNORE {INSERT OR ABORT} 1 {} 1
14 IGNORE {INSERT OR ROLLBACK} 1 {} {}
15 REPLACE INSERT 0 4 1
16 FAIL INSERT 1 {} 1
17 ABORT INSERT 1 {} 1
18 ROLLBACK INSERT 1 {} {}
} {
do_test conflict-2.$i {
if {$conf!=""} {set conf "ON CONFLICT $conf"}
set r0 [catch {execsql [subst {
DELETE FROM t1;
DELETE FROM t2;
INSERT INTO t1 VALUES(1,2,3);
BEGIN $conf;
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
} [list $t0 $t1 $t2]
}
# Create tables for the first group of tests.
#
do_test conflict-3.0 {
execsql {
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1(a, b, c INTEGER, PRIMARY KEY(c), UNIQUE(a,b));
CREATE TABLE t2(x);
SELECT c FROM t1 ORDER BY c;
}
} {}
# Six columns of configuration data as follows:
#
# i The reference number of the test
# conf The conflict resolution algorithm on the BEGIN statement
# cmd An INSERT or REPLACE command to execute against table t1
# t0 True if there is an error from $cmd
# t1 Content of "c" column of t1 assuming no error in $cmd
# t2 Content of "x" column of t2
#
foreach {i conf cmd t0 t1 t2} {
1 {} INSERT 1 {} 1
2 {} {INSERT OR IGNORE} 0 3 1
3 {} {INSERT OR REPLACE} 0 4 1
4 {} REPLACE 0 4 1
5 {} {INSERT OR FAIL} 1 {} 1
6 {} {INSERT OR ABORT} 1 {} 1
7 {} {INSERT OR ROLLBACK} 1 {} {}
8 IGNORE INSERT 0 3 1
9 IGNORE {INSERT OR IGNORE} 0 3 1
10 IGNORE {INSERT OR REPLACE} 0 4 1
11 IGNORE REPLACE 0 4 1
12 IGNORE {INSERT OR FAIL} 1 {} 1
13 IGNORE {INSERT OR ABORT} 1 {} 1
14 IGNORE {INSERT OR ROLLBACK} 1 {} {}
15 REPLACE INSERT 0 4 1
16 FAIL INSERT 1 {} 1
17 ABORT INSERT 1 {} 1
18 ROLLBACK INSERT 1 {} {}
} {
do_test conflict-3.$i {
if {$conf!=""} {set conf "ON CONFLICT $conf"}
set r0 [catch {execsql [subst {
DELETE FROM t1;
DELETE FROM t2;
INSERT INTO t1 VALUES(1,2,3);
BEGIN $conf;
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
} [list $t0 $t1 $t2]
}
do_test conflict-4.0 {
execsql {
DROP TABLE t2;
CREATE TABLE t2(x);
SELECT x FROM t2;
}
} {}
# Six columns of configuration data as follows:
#
# i The reference number of the test
# conf1 The conflict resolution algorithm on the UNIQUE constraint
# conf2 The conflict resolution algorithm on the BEGIN statement
# cmd An INSERT or REPLACE command to execute against table t1
# t0 True if there is an error from $cmd
# t1 Content of "c" column of t1 assuming no error in $cmd
# t2 Content of "x" column of t2
#
foreach {i conf1 conf2 cmd t0 t1 t2} {
1 {} {} INSERT 1 {} 1
2 REPLACE {} INSERT 0 4 1
3 IGNORE {} INSERT 0 3 1
4 FAIL {} INSERT 1 {} 1
5 ABORT {} INSERT 1 {} 1
6 ROLLBACK {} INSERT 1 {} {}
7 REPLACE {} {INSERT OR IGNORE} 0 3 1
8 IGNORE {} {INSERT OR REPLACE} 0 4 1
9 FAIL {} {INSERT OR IGNORE} 0 3 1
10 ABORT {} {INSERT OR REPLACE} 0 4 1
11 ROLLBACK {} {INSERT OR IGNORE } 0 3 1
12 REPLACE IGNORE INSERT 0 3 1
13 IGNORE REPLACE INSERT 0 4 1
14 FAIL IGNORE INSERT 0 3 1
15 ABORT REPLACE INSERT 0 4 1
16 ROLLBACK IGNORE INSERT 0 3 1
12 IGNORE REPLACE INSERT 0 4 1
13 IGNORE FAIL INSERT 1 {} 1
14 IGNORE ABORT INSERT 1 {} 1
15 IGNORE ROLLBACK INSERT 1 {} {}
} {
do_test conflict-4.$i {
if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
set r0 [catch {execsql [subst {
DROP TABLE t1;
CREATE TABLE t1(a,b,c,UNIQUE(a,b) $conf1);
DELETE FROM t2;
INSERT INTO t1 VALUES(1,2,3);
BEGIN $conf2;
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
} [list $t0 $t1 $t2]
}
do_test conflict-5.0 {
execsql {
DROP TABLE t2;
CREATE TABLE t2(x);
SELECT x FROM t2;
}
} {}
# Six columns of configuration data as follows:
#
# i The reference number of the test
# conf1 The conflict resolution algorithm on the NOT NULL constraint
# conf2 The conflict resolution algorithm on the BEGIN statement
# cmd An INSERT or REPLACE command to execute against table t1
# t0 True if there is an error from $cmd
# t1 Content of "c" column of t1 assuming no error in $cmd
# t2 Content of "x" column of t2
#
foreach {i conf1 conf2 cmd t0 t1 t2} {
1 {} {} INSERT 1 {} 1
2 REPLACE {} INSERT 0 5 1
3 IGNORE {} INSERT 0 {} 1
4 FAIL {} INSERT 1 {} 1
5 ABORT {} INSERT 1 {} 1
6 ROLLBACK {} INSERT 1 {} {}
7 REPLACE {} {INSERT OR IGNORE} 0 {} 1
8 IGNORE {} {INSERT OR REPLACE} 0 5 1
9 FAIL {} {INSERT OR IGNORE} 0 {} 1
10 ABORT {} {INSERT OR REPLACE} 0 5 1
11 ROLLBACK {} {INSERT OR IGNORE} 0 {} 1
12 {} {} {INSERT OR IGNORE} 0 {} 1
13 {} {} {INSERT OR REPLACE} 0 5 1
14 {} {} {INSERT OR FAIL} 1 {} 1
15 {} {} {INSERT OR ABORT} 1 {} 1
16 {} {} {INSERT OR ROLLBACK} 1 {} {}
17 {} IGNORE INSERT 0 {} 1
18 {} REPLACE INSERT 0 5 1
19 {} FAIL INSERT 1 {} 1
20 {} ABORT INSERT 1 {} 1
21 {} ROLLBACK INSERT 1 {} {}
22 REPLACE FAIL INSERT 1 {} 1
23 IGNORE ROLLBACK INSERT 1 {} {}
} {
if {$t0} {set t1 {t1.c may not be NULL}}
do_test conflict-5.$i {
if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
set r0 [catch {execsql [subst {
DROP TABLE t1;
CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);
DELETE FROM t2;
BEGIN $conf2;
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,NULL);
}]} r1]
catch {execsql {COMMIT}}
if {!$r0} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
} [list $t0 $t1 $t2]
}
do_test conflict-6.0 {
execsql {
DROP TABLE t2;
CREATE TABLE t2(a,b,c);
INSERT INTO t2 VALUES(1,2,1);
INSERT INTO t2 VALUES(2,3,2);
INSERT INTO t2 VALUES(3,4,1);
INSERT INTO t2 VALUES(4,5,4);
SELECT c FROM t2 ORDER BY b;
CREATE TABLE t3(x);
INSERT INTO t3 VALUES(1);
}
} {1 2 1 4}
# Six columns of configuration data as follows:
#
# i The reference number of the test
# conf1 The conflict resolution algorithm on the UNIQUE constraint
# conf2 The conflict resolution algorithm on the BEGIN statement
# cmd An UPDATE command to execute against table t1
# t0 True if there is an error from $cmd
# t1 Content of "b" column of t1 assuming no error in $cmd
# t2 Content of "x" column of t3
#
foreach {i conf1 conf2 cmd t0 t1 t2} {
1 {} {} UPDATE 1 {6 7 8 9} 1
2 REPLACE {} UPDATE 0 {7 6 9} 1
3 IGNORE {} UPDATE 0 {6 7 3 9} 1
4 FAIL {} UPDATE 1 {6 7 3 4} 1
5 ABORT {} UPDATE 1 {1 2 3 4} 1
6 ROLLBACK {} UPDATE 1 {1 2 3 4} 0
7 REPLACE {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
8 IGNORE {} {UPDATE OR REPLACE} 0 {7 6 9} 1
9 FAIL {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
10 ABORT {} {UPDATE OR REPLACE} 0 {7 6 9} 1
11 ROLLBACK {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
12 {} {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
13 {} {} {UPDATE OR REPLACE} 0 {7 6 9} 1
14 {} {} {UPDATE OR FAIL} 1 {6 7 3 4} 1
15 {} {} {UPDATE OR ABORT} 1 {1 2 3 4} 1
16 {} {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0
17 {} IGNORE UPDATE 0 {6 7 3 9} 1
18 {} REPLACE UPDATE 0 {7 6 9} 1
19 {} FAIL UPDATE 1 {6 7 3 4} 1
20 {} ABORT UPDATE 1 {1 2 3 4} 1
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
22 REPLACE IGNORE UPDATE 0 {6 7 3 9} 1
23 IGNORE REPLACE UPDATE 0 {7 6 9} 1
24 REPLACE FAIL UPDATE 1 {6 7 3 4} 1
25 IGNORE ABORT UPDATE 1 {1 2 3 4} 1
26 REPLACE ROLLBACK UPDATE 1 {1 2 3 4} 0
} {
if {$t0} {set t1 {column a is not unique}}
do_test conflict-6.$i {
if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
set r0 [catch {execsql [subst {
DROP TABLE t1;
CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);
INSERT INTO t1 SELECT * FROM t2;
UPDATE t3 SET x=0;
BEGIN $conf2;
$cmd t3 SET x=1;
$cmd t1 SET b=b*2;
$cmd t1 SET a=c+5;
}]} r1]
catch {execsql {COMMIT}}
if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}
set r2 [execsql {SELECT x FROM t3}]
list $r0 $r1 $r2
} [list $t0 $t1 $t2]
}
# Test to make sure a lot of IGNOREs don't cause a stack overflow
#
do_test conflict-7.1 {
execsql {
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
CREATE TABLE t1(a unique, b);
}
for {set i 1} {$i<=50} {incr i} {
execsql "INSERT into t1 values($i,[expr {$i+1}]);"
}
execsql {
SELECT count(*), min(a), max(b) FROM t1;
}
} {50 1 51}
do_test conflict-7.2 {
execsql {
PRAGMA count_changes=on;
UPDATE OR IGNORE t1 SET a=1000;
}
} {1}
do_test conflict-7.2.1 {
db changes
} {1}
do_test conflict-7.3 {
execsql {
SELECT b FROM t1 WHERE a=1000;
}
} {2}
do_test conflict-7.4 {
execsql {
SELECT count(*) FROM t1;
}
} {50}
do_test conflict-7.5 {
execsql {
PRAGMA count_changes=on;
UPDATE OR REPLACE t1 SET a=1001;
}
} {50}
do_test conflict-7.5.1 {
db changes
} {50}
do_test conflict-7.6 {
execsql {
SELECT b FROM t1 WHERE a=1001;
}
} {51}
do_test conflict-7.7 {
execsql {
SELECT count(*) FROM t1;
}
} {1}
do_test conflict-7.7.1 {
db changes
} {0}
# Make sure the row count is right for rows that are ignored on
# an insert.
#
do_test conflict-8.1 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2);
}
execsql {
INSERT OR IGNORE INTO t1 VALUES(2,3);
}
} {1}
do_test conflict-8.1.1 {
db changes
} {1}
do_test conflict-8.2 {
execsql {
INSERT OR IGNORE INTO t1 VALUES(2,4);
}
} {0}
do_test conflict-8.2.1 {
db changes
} {0}
do_test conflict-8.3 {
execsql {
INSERT OR REPLACE INTO t1 VALUES(2,4);
}
} {1}
do_test conflict-8.3.1 {
db changes
} {1}
do_test conflict-8.4 {
execsql {
INSERT OR IGNORE INTO t1 SELECT * FROM t1;
}
} {0}
do_test conflict-8.4.1 {
db changes
} {0}
do_test conflict-8.5 {
execsql {
INSERT OR IGNORE INTO t1 SELECT a+2,b+2 FROM t1;
}
} {2}
do_test conflict-8.5.1 {
db changes
} {2}
do_test conflict-8.6 {
execsql {
INSERT OR IGNORE INTO t1 SELECT a+3,b+3 FROM t1;
}
} {3}
do_test conflict-8.6.1 {
db changes
} {3}
integrity_check conflict-8.99
do_test conflict-9.1 {
execsql {
PRAGMA count_changes=0;
CREATE TABLE t2(
a INTEGER UNIQUE ON CONFLICT IGNORE,
b INTEGER UNIQUE ON CONFLICT FAIL,
c INTEGER UNIQUE ON CONFLICT REPLACE,
d INTEGER UNIQUE ON CONFLICT ABORT,
e INTEGER UNIQUE ON CONFLICT ROLLBACK
);
CREATE TABLE t3(x);
INSERT INTO t3 VALUES(1);
SELECT * FROM t3;
}
} {1}
do_test conflict-9.2 {
catchsql {
INSERT INTO t2 VALUES(1,1,1,1,1);
INSERT INTO t2 VALUES(2,2,2,2,2);
SELECT * FROM t2;
}
} {0 {1 1 1 1 1 2 2 2 2 2}}
do_test conflict-9.3 {
catchsql {
INSERT INTO t2 VALUES(1,3,3,3,3);
SELECT * FROM t2;
}
} {0 {1 1 1 1 1 2 2 2 2 2}}
do_test conflict-9.4 {
catchsql {
UPDATE t2 SET a=a+1 WHERE a=1;
SELECT * FROM t2;
}
} {0 {1 1 1 1 1 2 2 2 2 2}}
do_test conflict-9.5 {
catchsql {
INSERT INTO t2 VALUES(3,1,3,3,3);
SELECT * FROM t2;
}
} {1 {column b is not unique}}
do_test conflict-9.6 {
catchsql {
UPDATE t2 SET b=b+1 WHERE b=1;
SELECT * FROM t2;
}
} {1 {column b is not unique}}
do_test conflict-9.7 {
catchsql {
BEGIN;
UPDATE t3 SET x=x+1;
INSERT INTO t2 VALUES(3,1,3,3,3);
SELECT * FROM t2;
}
} {1 {column b is not unique}}
do_test conflict-9.8 {
execsql {COMMIT}
execsql {SELECT * FROM t3}
} {2}
do_test conflict-9.9 {
catchsql {
BEGIN;
UPDATE t3 SET x=x+1;
UPDATE t2 SET b=b+1 WHERE b=1;
SELECT * FROM t2;
}
} {1 {column b is not unique}}
do_test conflict-9.10 {
execsql {COMMIT}
execsql {SELECT * FROM t3}
} {3}
do_test conflict-9.11 {
catchsql {
INSERT INTO t2 VALUES(3,3,3,1,3);
SELECT * FROM t2;
}
} {1 {column d is not unique}}
do_test conflict-9.12 {
catchsql {
UPDATE t2 SET d=d+1 WHERE d=1;
SELECT * FROM t2;
}
} {1 {column d is not unique}}
do_test conflict-9.13 {
catchsql {
BEGIN;
UPDATE t3 SET x=x+1;
INSERT INTO t2 VALUES(3,3,3,1,3);
SELECT * FROM t2;
}
} {1 {column d is not unique}}
do_test conflict-9.14 {
execsql {COMMIT}
execsql {SELECT * FROM t3}
} {4}
do_test conflict-9.15 {
catchsql {
BEGIN;
UPDATE t3 SET x=x+1;
UPDATE t2 SET d=d+1 WHERE d=1;
SELECT * FROM t2;
}
} {1 {column d is not unique}}
do_test conflict-9.16 {
execsql {COMMIT}
execsql {SELECT * FROM t3}
} {5}
do_test conflict-9.17 {
catchsql {
INSERT INTO t2 VALUES(3,3,3,3,1);
SELECT * FROM t2;
}
} {1 {column e is not unique}}
do_test conflict-9.18 {
catchsql {
UPDATE t2 SET e=e+1 WHERE e=1;
SELECT * FROM t2;
}
} {1 {column e is not unique}}
do_test conflict-9.19 {
catchsql {
BEGIN;
UPDATE t3 SET x=x+1;
INSERT INTO t2 VALUES(3,3,3,3,1);
SELECT * FROM t2;
}
} {1 {column e is not unique}}
do_test conflict-9.20 {
catch {execsql {COMMIT}}
execsql {SELECT * FROM t3}
} {5}
do_test conflict-9.21 {
catchsql {
BEGIN;
UPDATE t3 SET x=x+1;
UPDATE t2 SET e=e+1 WHERE e=1;
SELECT * FROM t2;
}
} {1 {column e is not unique}}
do_test conflict-9.22 {
catch {execsql {COMMIT}}
execsql {SELECT * FROM t3}
} {5}
do_test conflict-9.23 {
catchsql {
INSERT INTO t2 VALUES(3,3,1,3,3);
SELECT * FROM t2;
}
} {0 {2 2 2 2 2 3 3 1 3 3}}
do_test conflict-9.24 {
catchsql {
UPDATE t2 SET c=c-1 WHERE c=2;
SELECT * FROM t2;
}
} {0 {2 2 1 2 2}}
do_test conflict-9.25 {
catchsql {
BEGIN;
UPDATE t3 SET x=x+1;
INSERT INTO t2 VALUES(3,3,1,3,3);
SELECT * FROM t2;
}
} {0 {3 3 1 3 3}}
do_test conflict-9.26 {
catch {execsql {COMMIT}}
execsql {SELECT * FROM t3}
} {6}
do_test conflict-10.1 {
catchsql {
DELETE FROM t1;
BEGIN ON CONFLICT ROLLBACK;
INSERT INTO t1 VALUES(1,2);
INSERT INTO t1 VALUES(1,3);
COMMIT;
}
execsql {SELECT * FROM t1}
} {}
do_test conflict-10.2 {
catchsql {
CREATE TABLE t4(x);
CREATE UNIQUE INDEX t4x ON t4(x);
BEGIN ON CONFLICT ROLLBACK;
INSERT INTO t4 VALUES(1);
INSERT INTO t4 VALUES(1);
COMMIT;
}
execsql {SELECT * FROM t4}
} {}
integrity_check conflict-99.0
finish_test
+122 -2
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the COPY statement.
#
# $Id: copy.test,v 1.6 2001/09/16 00:13:28 drh Exp $
# $Id: copy.test,v 1.17 2004/02/17 18:26:57 dougcurrie Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -39,6 +39,15 @@ set f [open data5.txt w]
puts $f "11|22|33"
puts $f "22|33|11"
close $f
set f [open dataX.txt w]
fconfigure $f -translation binary
puts -nonewline $f "11|22|33\r"
puts -nonewline $f "22|33|44\r\n"
puts -nonewline $f "33|44|55\n"
puts -nonewline $f "44|55|66\r"
puts -nonewline $f "55|66|77\r\n"
puts -nonewline $f "66|77|88\n"
close $f
# Try to COPY into a non-existant table.
#
@@ -123,6 +132,7 @@ do_test copy-2.1 {
execsql {COPY test2 FROM 'data21.txt'}
execsql {SELECT x from test2}
} $x
file delete -force data21.txt
# Test the escape character mechanism
#
@@ -137,9 +147,119 @@ do_test copy-3.1 {
SELECT * FROM t1 ORDER BY a;
}
} {hello {world 2} {hello world} 1}
do_test copy-3.2 {
set fd [open data6.txt w]
puts $fd "1\thello\\\nworld"
puts $fd "2\thello world"
close $fd
execsql {
DELETE FROM t1;
COPY t1 FROM 'data6.txt';
SELECT * FROM t1 ORDER BY a;
}
} {1 {hello
world} 2 {hello world}}
do_test copy-3.3 {
set fd [open data6.txt w]
puts $fd "1:hello\\b\\f\\n\\r\\t\\vworld"
puts $fd "2:hello world"
close $fd
execsql {
DELETE FROM t1;
COPY t1 FROM 'data6.txt' USING DELIMITERS ':';
SELECT * FROM t1 ORDER BY a;
}
} [list 1 "hello\b\f\n\r\t\vworld" 2 "hello world"]
# Test the embedded NULL logic.
#
do_test copy-4.1 {
set fd [open data6.txt w]
puts $fd "1\t\\N"
puts $fd "\\N\thello world"
close $fd
execsql {
DELETE FROM t1;
COPY t1 FROM 'data6.txt';
SELECT * FROM t1 WHERE a IS NULL;
}
} {{} {hello world}}
do_test copy-4.2 {
execsql {
SELECT * FROM t1 WHERE b IS NULL;
}
} {1 {}}
# Test the conflict resolution logic for COPY
#
do_test copy-5.1 {
execsql {
DROP TABLE t1;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);
COPY t1 FROM 'data5.txt' USING DELIMITERS '|';
SELECT * FROM t1;
}
} {11 22 33 22 33 11}
do_test copy-5.2 {
set fd [open data6.txt w]
puts $fd "33|22|44"
close $fd
catchsql {
COPY t1 FROM 'data6.txt' USING DELIMITERS '|';
SELECT * FROM t1;
}
} {1 {column b is not unique}}
do_test copy-5.3 {
set fd [open data6.txt w]
puts $fd "33|22|44"
close $fd
catchsql {
COPY OR IGNORE t1 FROM 'data6.txt' USING DELIMITERS '|';
SELECT * FROM t1;
}
} {0 {11 22 33 22 33 11}}
do_test copy-5.4 {
set fd [open data6.txt w]
puts $fd "33|22|44"
close $fd
catchsql {
COPY OR REPLACE t1 FROM 'data6.txt' USING DELIMITERS '|';
SELECT * FROM t1;
}
} {0 {22 33 11 33 22 44}}
do_test copy-5.5 {
execsql {
DELETE FROM t1;
PRAGMA count_changes=on;
COPY t1 FROM 'data5.txt' USING DELIMITERS '|';
}
} {2}
do_test copy-5.6 {
execsql {
COPY OR REPLACE t1 FROM 'data5.txt' USING DELIMITERS '|';
}
} {2}
do_test copy-5.7 {
execsql {
COPY OR IGNORE t1 FROM 'data5.txt' USING DELIMITERS '|';
}
} {0}
do_test copy-6.1 {
execsql {
PRAGMA count_changes=off;
CREATE TABLE t2(a,b,c);
COPY t2 FROM 'dataX.txt' USING DELIMITERS '|';
SELECT * FROM t2;
}
} {11 22 33 22 33 44 33 44 55 44 55 66 55 66 77 66 77 88}
integrity_check copy-7.1
# Cleanup
#
file delete -force data1.txt data2.txt data3.txt data4.txt data5.txt data21.txt
#file delete -force data1.txt data2.txt data3.txt data4.txt data5.txt \
data6.txt dataX.txt
finish_test
+96
View File
@@ -0,0 +1,96 @@
/*
** This program tests the ability of SQLite database to recover from a crash.
** This program runs under Unix only, but the results are applicable to all
** systems.
**
** The main process first constructs a test database, then starts creating
** subprocesses that write to that database. Each subprocess is killed off,
** without a chance to clean up its database connection, after a random
** delay. This killing of the subprocesses simulates a crash or power
** failure. The next subprocess to open the database should rollback
** whatever operation was in process at the time of the simulated crash.
**
** If any problems are encountered, an error is reported and the test stops.
** If no problems are seen after a large number of tests, we assume that
** the rollback mechanism is working.
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include "sqlite.h"
static void do_some_sql(int parent){
char *zErr;
int rc = SQLITE_OK;
sqlite *db;
int cnt = 0;
static char zBig[] =
"-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
"-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
if( access("./test.db-journal",0)==0 ){
/*printf("pid %d: journal exists. rollback will be required\n",getpid());*/ unlink("test.db-saved");
system("cp test.db test.db-saved");
unlink("test.db-journal-saved");
system("cp test.db-journal test.db-journal-saved");
}
db = sqlite_open("./test.db", 0, &zErr);
if( db==0 ){
printf("ERROR: %s\n", zErr);
if( strcmp(zErr,"database disk image is malformed")==0 ){
kill(parent, SIGKILL);
}
exit(1);
}
srand(getpid());
while( rc==SQLITE_OK ){
cnt++;
rc = sqlite_exec_printf(db,
"INSERT INTO t1 VALUES(%d,'%d%s')", 0, 0, &zErr,
rand(), rand(), zBig);
}
if( rc!=SQLITE_OK ){
printf("ERROR #%d: %s\n", rc, zErr);
if( rc==SQLITE_CORRUPT ){
kill(parent, SIGKILL);
}
}
printf("pid %d: cnt=%d\n", getpid(), cnt);
}
int main(int argc, char **argv){
int i;
sqlite *db;
char *zErr;
int status;
int parent = getpid();
unlink("test.db");
unlink("test.db-journal");
db = sqlite_open("test.db", 0, &zErr);
if( db==0 ){
printf("Cannot initialize: %s\n", zErr);
return 1;
}
sqlite_exec(db, "CREATE TABLE t1(a,b)", 0, 0, 0);
sqlite_close(db);
for(i=0; i<10000; i++){
int pid = fork();
if( pid==0 ){
sched_yield();
do_some_sql(parent);
return 0;
}
printf("test %d, pid=%d\n", i, pid);
usleep(rand()%10000 + 1000);
kill(pid, SIGKILL);
waitpid(pid, &status, 0);
}
return 0;
}
+257
View File
@@ -0,0 +1,257 @@
# 2003 October 31
#
# 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 implements regression tests for SQLite library. The
# focus of this file is testing date and time functions.
#
# $Id: date.test,v 1.7.2.1 2004/07/18 22:25:16 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
proc datetest {tnum expr result} {
do_test date-$tnum [subst {
execsql "SELECT coalesce($expr,'NULL')"
}] [list $result]
}
datetest 1.1 julianday('2000-01-01') 2451544.5
datetest 1.2 julianday('1970-01-01') 2440587.5
datetest 1.3 julianday('1910-04-20') 2418781.5
datetest 1.4 julianday('1986-02-09') 2446470.5
datetest 1.5 julianday('12:00:00') 2451545
datetest 1.6 {julianday('2000-01-01 12:00:00')} 2451545
datetest 1.7 {julianday('2000-01-01 12:00')} 2451545
datetest 1.8 julianday('bogus') NULL
datetest 1.9 julianday('1999-12-31') 2451543.5
datetest 1.10 julianday('1999-12-32') NULL
datetest 1.11 julianday('1999-13-01') NULL
datetest 1.12 julianday('2003-02-31') 2452701.5
datetest 1.13 julianday('2003-03-03') 2452701.5
datetest 1.14 julianday('+2000-01-01') NULL
datetest 1.15 julianday('200-01-01') NULL
datetest 1.16 julianday('2000-1-01') NULL
datetest 1.17 julianday('2000-01-1') NULL
datetest 1.18 {julianday('2000-01-01 12:00:00')} 2451545
datetest 1.19 {julianday('2000-01-01 12:00:00.1')} 2451545.00000116
datetest 1.20 {julianday('2000-01-01 12:00:00.01')} 2451545.00000012
datetest 1.21 {julianday('2000-01-01 12:00:00.001')} 2451545.00000001
datetest 1.22 {julianday('2000-01-01 12:00:00.')} NULL
datetest 1.23 julianday(12345.6) 12345.6
datetest 1.24 {julianday('2001-01-01 12:00:00 bogus')} NULL
datetest 1.25 {julianday('2001-01-01 bogus')} NULL
datetest 2.1 datetime(0,'unixepoch') {1970-01-01 00:00:00}
datetest 2.2 datetime(946684800,'unixepoch') {2000-01-01 00:00:00}
datetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26
datetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27
datetest 2.5 {date('2003-10-22','weekday 2')} 2003-10-28
datetest 2.6 {date('2003-10-22','weekday 3')} 2003-10-22
datetest 2.7 {date('2003-10-22','weekday 4')} 2003-10-23
datetest 2.8 {date('2003-10-22','weekday 5')} 2003-10-24
datetest 2.9 {date('2003-10-22','weekday 6')} 2003-10-25
datetest 2.10 {date('2003-10-22','weekday 7')} NULL
datetest 2.11 {date('2003-10-22','weekday 5.5')} NULL
datetest 2.12 {datetime('2003-10-22 12:34','weekday 0')} {2003-10-26 12:34:00}
datetest 2.13 {datetime('2003-10-22 12:34','start of month')} \
{2003-10-01 00:00:00}
datetest 2.14 {datetime('2003-10-22 12:34','start of year')} \
{2003-01-01 00:00:00}
datetest 2.15 {datetime('2003-10-22 12:34','start of day')} \
{2003-10-22 00:00:00}
datetest 2.16 time('12:34:56.43') 12:34:56
datetest 2.17 {datetime('2003-10-22 12:34','1 day')} {2003-10-23 12:34:00}
datetest 2.18 {datetime('2003-10-22 12:34','+1 day')} {2003-10-23 12:34:00}
datetest 2.19 {datetime('2003-10-22 12:34','+1.25 day')} {2003-10-23 18:34:00}
datetest 2.20 {datetime('2003-10-22 12:34','-1.0 day')} {2003-10-21 12:34:00}
datetest 2.21 {datetime('2003-10-22 12:34','1 month')} {2003-11-22 12:34:00}
datetest 2.22 {datetime('2003-10-22 12:34','11 month')} {2004-09-22 12:34:00}
datetest 2.23 {datetime('2003-10-22 12:34','-13 month')} {2002-09-22 12:34:00}
datetest 2.24 {datetime('2003-10-22 12:34','1.5 months')} {2003-12-07 12:34:00}
datetest 2.25 {datetime('2003-10-22 12:34','-5 years')} {1998-10-22 12:34:00}
datetest 2.26 {datetime('2003-10-22 12:34','+10.5 minutes')} \
{2003-10-22 12:44:30}
datetest 2.27 {datetime('2003-10-22 12:34','-1.25 hours')} \
{2003-10-22 11:19:00}
datetest 2.28 {datetime('2003-10-22 12:34','11.25 seconds')} \
{2003-10-22 12:34:11}
datetest 2.29 {datetime('2003-10-22 12:24','+5 bogus')} NULL
datetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31
datetest 3.2 {strftime('%f','2003-10-31 12:34:56.432')} 56.432
datetest 3.3 {strftime('%H','2003-10-31 12:34:56.432')} 12
datetest 3.4 {strftime('%j','2003-10-31 12:34:56.432')} 304
datetest 3.5 {strftime('%J','2003-10-31 12:34:56.432')} 2452944.024264259
datetest 3.6 {strftime('%m','2003-10-31 12:34:56.432')} 10
datetest 3.7 {strftime('%M','2003-10-31 12:34:56.432')} 34
datetest 3.8 {strftime('%s','2003-10-31 12:34:56.432')} 1067603696
datetest 3.9 {strftime('%S','2003-10-31 12:34:56.432')} 56
datetest 3.10 {strftime('%w','2003-10-31 12:34:56.432')} 5
datetest 3.11.1 {strftime('%W','2003-10-31 12:34:56.432')} 43
datetest 3.11.2 {strftime('%W','2004-01-01')} 00
datetest 3.11.3 {strftime('%W','2004-01-02')} 00
datetest 3.11.4 {strftime('%W','2004-01-03')} 00
datetest 3.11.5 {strftime('%W','2004-01-04')} 00
datetest 3.11.6 {strftime('%W','2004-01-05')} 01
datetest 3.11.7 {strftime('%W','2004-01-06')} 01
datetest 3.11.8 {strftime('%W','2004-01-07')} 01
datetest 3.11.9 {strftime('%W','2004-01-08')} 01
datetest 3.11.10 {strftime('%W','2004-01-09')} 01
datetest 3.11.11 {strftime('%W','2004-07-18')} 28
datetest 3.11.12 {strftime('%W','2004-12-31')} 52
datetest 3.11.13 {strftime('%W','2007-12-31')} 53
datetest 3.11.14 {strftime('%W','2007-01-01')} 01
datetest 3.12 {strftime('%Y','2003-10-31 12:34:56.432')} 2003
datetest 3.13 {strftime('%%','2003-10-31 12:34:56.432')} %
datetest 3.14 {strftime('%_','2003-10-31 12:34:56.432')} NULL
datetest 3.15 {strftime('%Y-%m-%d','2003-10-31')} 2003-10-31
proc repeat {n txt} {
set x {}
while {$n>0} {
append x $txt
incr n -1
}
return $x
}
datetest 3.16 "strftime('[repeat 200 %Y]','2003-10-31')" [repeat 200 2003]
datetest 3.17 "strftime('[repeat 200 abc%m123]','2003-10-31')" \
[repeat 200 abc10123]
set now [clock format [clock seconds] -format "%Y-%m-%d" -gmt 1]
datetest 4.1 {date('now')} $now
datetest 5.1 {datetime('1994-04-16 14:00:00 -05:00')} {1994-04-16 09:00:00}
datetest 5.2 {datetime('1994-04-16 14:00:00 +05:15')} {1994-04-16 19:15:00}
datetest 5.3 {datetime('1994-04-16 05:00:00 -08:30')} {1994-04-15 20:30:00}
datetest 5.4 {datetime('1994-04-16 14:00:00 +11:55')} {1994-04-17 01:55:00}
# localtime->utc and utc->localtime conversions. These tests only work
# if the localtime is in the US Eastern Time (the time in Charlotte, NC
# and in New York.)
#
if {[clock scan [clock format 0 -format {%b %d, %Y %H:%M:%S}] -gmt 1]==-18000} {
datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\
{2000-10-29 01:59:00}
datetest 6.2 {datetime('2000-10-29 06:00:00','localtime')}\
{2000-10-29 01:00:00}
datetest 6.3 {datetime('2000-04-02 06:59:00','localtime')}\
{2000-04-02 01:59:00}
datetest 6.4 {datetime('2000-04-02 07:00:00','localtime')}\
{2000-04-02 03:00:00}
datetest 6.5 {datetime('2000-10-29 01:59:00','utc')} {2000-10-29 05:59:00}
datetest 6.6 {datetime('2000-10-29 02:00:00','utc')} {2000-10-29 07:00:00}
datetest 6.7 {datetime('2000-04-02 01:59:00','utc')} {2000-04-02 06:59:00}
datetest 6.8 {datetime('2000-04-02 02:00:00','utc')} {2000-04-02 06:00:00}
datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \
{2000-01-01 07:00:00}
datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \
{1969-01-01 07:00:00}
datetest 6.12 {datetime('2039-01-01 12:00:00','localtime')} \
{2039-01-01 07:00:00}
datetest 6.13 {datetime('2000-07-01 12:00:00','localtime')} \
{2000-07-01 08:00:00}
datetest 6.14 {datetime('1969-07-01 12:00:00','localtime')} \
{1969-07-01 07:00:00}
datetest 6.15 {datetime('2039-07-01 12:00:00','localtime')} \
{2039-07-01 07:00:00}
set sqlite_current_time \
[db eval {SELECT strftime('%s','2000-07-01 12:34:56')}]
datetest 6.16 {datetime('now','localtime')} {2000-07-01 08:34:56}
set sqlite_current_time 0
}
# Date-time functions that contain NULL arguments return a NULL
# result.
#
datetest 7.1 {datetime(null)} NULL
datetest 7.2 {datetime('now',null)} NULL
datetest 7.3 {datetime('now','localtime',null)} NULL
datetest 7.4 {time(null)} NULL
datetest 7.5 {time('now',null)} NULL
datetest 7.6 {time('now','localtime',null)} NULL
datetest 7.7 {date(null)} NULL
datetest 7.8 {date('now',null)} NULL
datetest 7.9 {date('now','localtime',null)} NULL
datetest 7.10 {julianday(null)} NULL
datetest 7.11 {julianday('now',null)} NULL
datetest 7.12 {julianday('now','localtime',null)} NULL
datetest 7.13 {strftime(null,'now')} NULL
datetest 7.14 {strftime('%s',null)} NULL
datetest 7.15 {strftime('%s','now',null)} NULL
datetest 7.16 {strftime('%s','now','localtime',null)} NULL
# Test modifiers when the date begins as a julian day number - to
# make sure the HH:MM:SS is preserved. Ticket #551.
#
set sqlite_current_time [db eval {SELECT strftime('%s','2003-10-22 12:34:00')}]
datetest 8.1 {datetime('now','weekday 0')} {2003-10-26 12:34:00}
datetest 8.2 {datetime('now','weekday 1')} {2003-10-27 12:34:00}
datetest 8.3 {datetime('now','weekday 2')} {2003-10-28 12:34:00}
datetest 8.4 {datetime('now','weekday 3')} {2003-10-22 12:34:00}
datetest 8.5 {datetime('now','start of month')} {2003-10-01 00:00:00}
datetest 8.6 {datetime('now','start of year')} {2003-01-01 00:00:00}
datetest 8.7 {datetime('now','start of day')} {2003-10-22 00:00:00}
datetest 8.8 {datetime('now','1 day')} {2003-10-23 12:34:00}
datetest 8.9 {datetime('now','+1 day')} {2003-10-23 12:34:00}
datetest 8.10 {datetime('now','+1.25 day')} {2003-10-23 18:34:00}
datetest 8.11 {datetime('now','-1.0 day')} {2003-10-21 12:34:00}
datetest 8.12 {datetime('now','1 month')} {2003-11-22 12:34:00}
datetest 8.13 {datetime('now','11 month')} {2004-09-22 12:34:00}
datetest 8.14 {datetime('now','-13 month')} {2002-09-22 12:34:00}
datetest 8.15 {datetime('now','1.5 months')} {2003-12-07 12:34:00}
datetest 8.16 {datetime('now','-5 years')} {1998-10-22 12:34:00}
datetest 8.17 {datetime('now','+10.5 minutes')} {2003-10-22 12:44:30}
datetest 8.18 {datetime('now','-1.25 hours')} {2003-10-22 11:19:00}
datetest 8.19 {datetime('now','11.25 seconds')} {2003-10-22 12:34:11}
set sqlite_current_time 0
# Negative years work. Example: '-4713-11-26' is JD 1.5.
#
datetest 9.1 {julianday('-4713-11-24 12:00:00')} {0}
datetest 9.2 {julianday(datetime(5))} {5}
datetest 9.3 {julianday(datetime(10))} {10}
datetest 9.4 {julianday(datetime(100))} {100}
datetest 9.5 {julianday(datetime(1000))} {1000}
datetest 9.6 {julianday(datetime(10000))} {10000}
datetest 9.7 {julianday(datetime(100000))} {100000}
# datetime() with just an HH:MM:SS correctly inserts the date 2000-01-01.
#
datetest 10.1 {datetime('01:02:03')} {2000-01-01 01:02:03}
datetest 10.2 {date('01:02:03')} {2000-01-01}
datetest 10.3 {strftime('%Y-%m-%d %H:%M','01:02:03')} {2000-01-01 01:02}
# Test the new HH:MM:SS modifier
#
datetest 11.1 {datetime('2004-02-28 20:00:00', '-01:20:30')} \
{2004-02-28 18:39:30}
datetest 11.2 {datetime('2004-02-28 20:00:00', '+12:30:00')} \
{2004-02-29 08:30:00}
datetest 11.3 {datetime('2004-02-28 20:00:00', '+12:30')} \
{2004-02-29 08:30:00}
datetest 11.4 {datetime('2004-02-28 20:00:00', '12:30')} \
{2004-02-29 08:30:00}
datetest 11.5 {datetime('2004-02-28 20:00:00', '-12:00')} \
{2004-02-28 08:00:00}
datetest 11.6 {datetime('2004-02-28 20:00:00', '-12:01')} \
{2004-02-28 07:59:00}
datetest 11.7 {datetime('2004-02-28 20:00:00', '-11:59')} \
{2004-02-28 08:01:00}
datetest 11.8 {datetime('2004-02-28 20:00:00', '11:59')} \
{2004-02-29 07:59:00}
datetest 11.9 {datetime('2004-02-28 20:00:00', '12:01')} \
{2004-02-29 08:01:00}
finish_test
+94 -1
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the DELETE FROM statement.
#
# $Id: delete.test,v 1.10 2001/10/15 00:44:36 drh Exp $
# $Id: delete.test,v 1.13 2003/06/15 23:42:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -60,6 +60,8 @@ do_test delete-3.1.6 {
do_test delete-3.1.7 {
execsql {SELECT * FROM table1 ORDER BY f1}
} {1 2 4 16}
integrity_check delete-3.2
# Semantic errors in the WHERE clause
#
@@ -73,6 +75,7 @@ do_test delete-4.2 {
set v [catch {execsql {DELETE FROM table2 WHERE xyzzy(f1+4)}} msg]
lappend v $msg
} {1 {no such function: xyzzy}}
integrity_check delete-4.3
# Lots of deletes
#
@@ -142,6 +145,8 @@ do_test delete-5.7 {
execsql "DELETE FROM table1 WHERE f1!=48"
execsql {SELECT f1 FROM table1 ORDER BY f1}
} {48}
integrity_check delete-5.8
# Delete large quantities of data. We want to test the List overflow
# mechanism in the vdbe.
@@ -192,7 +197,95 @@ do_test delete-6.10 {
execsql {INSERT INTO table2 VALUES(2,3)}
execsql {SELECT f1 FROM table2}
} {2}
integrity_check delete-6.11
do_test delete-7.1 {
execsql {
CREATE TABLE t3(a);
INSERT INTO t3 VALUES(1);
INSERT INTO t3 SELECT a+1 FROM t3;
INSERT INTO t3 SELECT a+2 FROM t3;
SELECT * FROM t3;
}
} {1 2 3 4}
do_test delete-7.2 {
execsql {
CREATE TABLE cnt(del);
INSERT INTO cnt VALUES(0);
CREATE TRIGGER r1 AFTER DELETE ON t3 FOR EACH ROW BEGIN
UPDATE cnt SET del=del+1;
END;
DELETE FROM t3 WHERE a<2;
SELECT * FROM t3;
}
} {2 3 4}
do_test delete-7.3 {
execsql {
SELECT * FROM cnt;
}
} {1}
do_test delete-7.4 {
execsql {
DELETE FROM t3;
SELECT * FROM t3;
}
} {}
do_test delete-7.5 {
execsql {
SELECT * FROM cnt;
}
} {4}
do_test delete-7.6 {
execsql {
INSERT INTO t3 VALUES(1);
INSERT INTO t3 SELECT a+1 FROM t3;
INSERT INTO t3 SELECT a+2 FROM t3;
CREATE TABLE t4 AS SELECT * FROM t3;
PRAGMA count_changes=ON;
DELETE FROM t3;
DELETE FROM t4;
}
} {4 4}
integrity_check delete-7.7
# Make sure error messages are consistent when attempting to delete
# from a read-only database. Ticket #304.
#
do_test delete-8.0 {
execsql {
PRAGMA count_changes=OFF;
INSERT INTO t3 VALUES(123);
SELECT * FROM t3;
}
} {123}
db close
catch {file attributes test.db -permissions 0444}
catch {file attributes test.db -readonly 1}
sqlite db test.db
do_test delete-8.1 {
catchsql {
DELETE FROM t3;
}
} {1 {attempt to write a readonly database}}
do_test delete-8.2 {
execsql {SELECT * FROM t3}
} {123}
do_test delete-8.3 {
catchsql {
DELETE FROM t3 WHERE 1;
}
} {1 {attempt to write a readonly database}}
do_test delete-8.4 {
execsql {SELECT * FROM t3}
} {123}
do_test delete-8.5 {
catchsql {
DELETE FROM t3 WHERE a<100;
}
} {0 {}}
do_test delete-8.6 {
execsql {SELECT * FROM t3}
} {123}
integrity_check delete-8.7
finish_test
+222 -17
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.16 2001/10/13 02:59:09 drh Exp $
# $Id: expr.test,v 1.31 2004/03/03 01:51:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -22,8 +22,7 @@ execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}
proc test_expr {name settings expr result} {
do_test $name [format {
execsql {UPDATE test1 SET %s}
execsql {SELECT %s FROM test1}
execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}
} $settings $expr] $result
}
@@ -63,16 +62,74 @@ test_expr expr-1.33 {i1=1, i2=2} {i1=1 OR i2=1} {1}
test_expr expr-1.34 {i1=1, i2=2} {i1=2 OR i2=2} {1}
test_expr expr-1.35 {i1=1, i2=2} {i1-i2=-1} {1}
test_expr expr-1.36 {i1=1, i2=0} {not i1} {0}
test_expr expr-1.37 {i1=1, i2=NULL} {not i2} {1}
test_expr expr-1.37 {i1=1, i2=0} {not i2} {1}
test_expr expr-1.38 {i1=1} {-i1} {-1}
test_expr expr-1.39 {i1=1} {+i1} {1}
test_expr expr-1.40 {i1=1, i2=2} {+(i2+i1)} {3}
test_expr expr-1.41 {i1=1, i2=2} {-(i2+i1)} {-3}
test_expr expr-1.42 {i1=1, i2=2} {i1|i2} {3}
test_expr expr-1.42b {i1=1, i2=2} {4|2} {6}
test_expr expr-1.43 {i1=1, i2=2} {i1&i2} {0}
test_expr expr-1.43b {i1=1, i2=2} {4&5} {4}
test_expr expr-1.44 {i1=1} {~i1} {-2}
test_expr expr-1.45 {i1=1, i2=3} {i1<<i2} {8}
test_expr expr-1.46 {i1=32, i2=3} {i1>>i2} {4}
test_expr expr-1.47 {i1=9999999999, i2=8888888888} {i1<i2} 0
test_expr expr-1.48 {i1=9999999999, i2=8888888888} {i1=i2} 0
test_expr expr-1.49 {i1=9999999999, i2=8888888888} {i1>i2} 1
test_expr expr-1.50 {i1=99999999999, i2=99999999998} {i1<i2} 0
test_expr expr-1.51 {i1=99999999999, i2=99999999998} {i1=i2} 0
test_expr expr-1.52 {i1=99999999999, i2=99999999998} {i1>i2} 1
test_expr expr-1.53 {i1=099999999999, i2=99999999999} {i1<i2} 0
test_expr expr-1.54 {i1=099999999999, i2=99999999999} {i1=i2} 1
test_expr expr-1.55 {i1=099999999999, i2=99999999999} {i1>i2} 0
test_expr expr-1.56 {i1=25, i2=11} {i1%i2} 3
test_expr expr-1.58 {i1=NULL, i2=1} {coalesce(i1+i2,99)} 99
test_expr expr-1.59 {i1=1, i2=NULL} {coalesce(i1+i2,99)} 99
test_expr expr-1.60 {i1=NULL, i2=NULL} {coalesce(i1+i2,99)} 99
test_expr expr-1.61 {i1=NULL, i2=1} {coalesce(i1-i2,99)} 99
test_expr expr-1.62 {i1=1, i2=NULL} {coalesce(i1-i2,99)} 99
test_expr expr-1.63 {i1=NULL, i2=NULL} {coalesce(i1-i2,99)} 99
test_expr expr-1.64 {i1=NULL, i2=1} {coalesce(i1*i2,99)} 99
test_expr expr-1.65 {i1=1, i2=NULL} {coalesce(i1*i2,99)} 99
test_expr expr-1.66 {i1=NULL, i2=NULL} {coalesce(i1*i2,99)} 99
test_expr expr-1.67 {i1=NULL, i2=1} {coalesce(i1/i2,99)} 99
test_expr expr-1.68 {i1=1, i2=NULL} {coalesce(i1/i2,99)} 99
test_expr expr-1.69 {i1=NULL, i2=NULL} {coalesce(i1/i2,99)} 99
test_expr expr-1.70 {i1=NULL, i2=1} {coalesce(i1<i2,99)} 99
test_expr expr-1.71 {i1=1, i2=NULL} {coalesce(i1>i2,99)} 99
test_expr expr-1.72 {i1=NULL, i2=NULL} {coalesce(i1<=i2,99)} 99
test_expr expr-1.73 {i1=NULL, i2=1} {coalesce(i1>=i2,99)} 99
test_expr expr-1.74 {i1=1, i2=NULL} {coalesce(i1!=i2,99)} 99
test_expr expr-1.75 {i1=NULL, i2=NULL} {coalesce(i1==i2,99)} 99
test_expr expr-1.76 {i1=NULL, i2=NULL} {coalesce(not i1,99)} 99
test_expr expr-1.77 {i1=NULL, i2=NULL} {coalesce(-i1,99)} 99
test_expr expr-1.78 {i1=NULL, i2=NULL} {coalesce(i1 IS NULL AND i2=5,99)} 99
test_expr expr-1.79 {i1=NULL, i2=NULL} {coalesce(i1 IS NULL OR i2=5,99)} 1
test_expr expr-1.80 {i1=NULL, i2=NULL} {coalesce(i1=5 AND i2 IS NULL,99)} 99
test_expr expr-1.81 {i1=NULL, i2=NULL} {coalesce(i1=5 OR i2 IS NULL,99)} 1
test_expr expr-1.82 {i1=NULL, i2=3} {coalesce(min(i1,i2,1),99)} 99
test_expr expr-1.83 {i1=NULL, i2=3} {coalesce(max(i1,i2,1),99)} 99
test_expr expr-1.84 {i1=3, i2=NULL} {coalesce(min(i1,i2,1),99)} 99
test_expr expr-1.85 {i1=3, i2=NULL} {coalesce(max(i1,i2,1),99)} 99
test_expr expr-1.86 {i1=3, i2=8} {5 between i1 and i2} 1
test_expr expr-1.87 {i1=3, i2=8} {5 not between i1 and i2} 0
test_expr expr-1.88 {i1=3, i2=8} {55 between i1 and i2} 0
test_expr expr-1.89 {i1=3, i2=8} {55 not between i1 and i2} 1
test_expr expr-1.90 {i1=3, i2=NULL} {5 between i1 and i2} {{}}
test_expr expr-1.91 {i1=3, i2=NULL} {5 not between i1 and i2} {{}}
test_expr expr-1.92 {i1=3, i2=NULL} {2 between i1 and i2} 0
test_expr expr-1.93 {i1=3, i2=NULL} {2 not between i1 and i2} 1
test_expr expr-1.94 {i1=NULL, i2=8} {2 between i1 and i2} {{}}
test_expr expr-1.95 {i1=NULL, i2=8} {2 not between i1 and i2} {{}}
test_expr expr-1.94 {i1=NULL, i2=8} {55 between i1 and i2} 0
test_expr expr-1.95 {i1=NULL, i2=8} {55 not between i1 and i2} 1
test_expr expr-1.96 {i1=NULL, i2=3} {coalesce(i1<<i2,99)} 99
test_expr expr-1.97 {i1=32, i2=NULL} {coalesce(i1>>i2,99)} 99
test_expr expr-1.98 {i1=NULL, i2=NULL} {coalesce(i1|i2,99)} 99
test_expr expr-1.99 {i1=32, i2=NULL} {coalesce(i1&i2,99)} 99
test_expr expr-1.100 {i1=1, i2=''} {i1=i2} 0
test_expr expr-1.101 {i1=0, i2=''} {i1=i2} 0
test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57
test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
@@ -97,6 +154,8 @@ test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3
test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0
@@ -123,18 +182,49 @@ test_expr expr-3.22 {t1='abc', t2='xyz'} {t1!=t2} 1
test_expr expr-3.23 {t1='xyz', t2='abc'} {t1!=t2} 1
test_expr expr-3.24 {t1='abc', t2='abc'} {t1!=t2} 0
test_expr expr-3.25 {t1=NULL, t2='hi'} {t1 isnull} 1
test_expr expr-3.25b {t1=NULL, t2='hi'} {t1 is null} 1
test_expr expr-3.26 {t1=NULL, t2='hi'} {t2 isnull} 0
test_expr expr-3.27 {t1=NULL, t2='hi'} {t1 notnull} 0
test_expr expr-3.28 {t1=NULL, t2='hi'} {t2 notnull} 1
test_expr expr-3.28b {t1=NULL, t2='hi'} {t2 is not null} 1
test_expr expr-3.29 {t1='xyz', t2='abc'} {t1||t2} {xyzabc}
test_expr expr-3.30 {t1=NULL, t2='abc'} {t1||t2} {abc}
test_expr expr-3.31 {t1='xyz', t2=NULL} {t1||t2} {xyz}
test_expr expr-3.30 {t1=NULL, t2='abc'} {t1||t2} {{}}
test_expr expr-3.31 {t1='xyz', t2=NULL} {t1||t2} {{}}
test_expr expr-3.32 {t1='xyz', t2='abc'} {t1||' hi '||t2} {{xyz hi abc}}
test_expr epxr-3.33 {t1='abc', t2=NULL} {coalesce(t1<t2,99)} 99
test_expr epxr-3.34 {t1='abc', t2=NULL} {coalesce(t2<t1,99)} 99
test_expr epxr-3.35 {t1='abc', t2=NULL} {coalesce(t1>t2,99)} 99
test_expr epxr-3.36 {t1='abc', t2=NULL} {coalesce(t2>t1,99)} 99
test_expr epxr-3.37 {t1='abc', t2=NULL} {coalesce(t1<=t2,99)} 99
test_expr epxr-3.38 {t1='abc', t2=NULL} {coalesce(t2<=t1,99)} 99
test_expr epxr-3.39 {t1='abc', t2=NULL} {coalesce(t1>=t2,99)} 99
test_expr epxr-3.40 {t1='abc', t2=NULL} {coalesce(t2>=t1,99)} 99
test_expr epxr-3.41 {t1='abc', t2=NULL} {coalesce(t1==t2,99)} 99
test_expr epxr-3.42 {t1='abc', t2=NULL} {coalesce(t2==t1,99)} 99
test_expr epxr-3.43 {t1='abc', t2=NULL} {coalesce(t1!=t2,99)} 99
test_expr epxr-3.44 {t1='abc', t2=NULL} {coalesce(t2!=t1,99)} 99
test_expr expr-4.1 {t1='abc', t2='Abc'} {t1<t2} 0
test_expr expr-4.2 {t1='abc', t2='Abc'} {t1>t2} 1
test_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 1
test_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 0
test_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 0
test_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 1
test_expr expr-4.5 {t1='0', t2='0.0'} {t1==t2} 0
test_expr expr-4.6 {t1='0.000', t2='0.0'} {t1==t2} 0
test_expr expr-4.7 {t1=' 0.000', t2=' 0.0'} {t1==t2} 0
test_expr expr-4.8 {t1='0.0', t2='abc'} {t1<t2} 1
test_expr expr-4.9 {t1='0.0', t2='abc'} {t1==t2} 0
test_expr expr-4.10 {r1='0.0', r2='abc'} {r1>r2} 0
test_expr expr-4.11 {r1='abc', r2='Abc'} {r1<r2} 0
test_expr expr-4.12 {r1='abc', r2='Abc'} {r1>r2} 1
test_expr expr-4.13 {r1='abc', r2='Bbc'} {r1<r2} 0
test_expr expr-4.14 {r1='abc', r2='Bbc'} {r1>r2} 1
test_expr expr-4.15 {r1='0', r2='0.0'} {r1==r2} 1
test_expr expr-4.16 {r1='0.000', r2='0.0'} {r1==r2} 1
test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 0
test_expr expr-4.18 {r1='0.0', r2='abc'} {r1<r2} 1
test_expr expr-4.19 {r1='0.0', r2='abc'} {r1==r2} 0
test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0
test_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0
test_expr expr-5.2 {t1='abc', t2='ABC'} {t1 LIKE t2} 1
@@ -187,6 +277,11 @@ if {[sqlite -encoding]=="iso8859"} {
test_expr expr-5.53 "t1='ax\241', t2='A_%'" {t1 LIKE t2} 1
}
}
test_expr expr-5.54 {t1='abc', t2=NULL} {t1 LIKE t2} {{}}
test_expr expr-5.55 {t1='abc', t2=NULL} {t1 NOT LIKE t2} {{}}
test_expr expr-5.56 {t1='abc', t2=NULL} {t2 LIKE t1} {{}}
test_expr expr-5.57 {t1='abc', t2=NULL} {t2 NOT LIKE t1} {{}}
test_expr expr-6.1 {t1='abc', t2='xyz'} {t1 GLOB t2} 0
test_expr expr-6.2 {t1='abc', t2='ABC'} {t1 GLOB t2} 0
@@ -208,12 +303,17 @@ test_expr expr-6.17 {t1='abc', t2='a[A-Dc]c'} {t1 GLOB t2} 0
test_expr expr-6.18 {t1='abc', t2='a[^A-Dc]c'} {t1 GLOB t2} 1
test_expr expr-6.19 {t1='abc', t2='a[]b]c'} {t1 GLOB t2} 1
test_expr expr-6.20 {t1='abc', t2='a[^]b]c'} {t1 GLOB t2} 0
test_expr expr-6.21 {t1='abcdefg', t2='a*[de]g'} {t1 GLOB t2} 0
test_expr expr-6.22 {t1='abcdefg', t2='a*[^de]g'} {t1 GLOB t2} 1
test_expr expr-6.21a {t1='abcdefg', t2='a*[de]g'} {t1 GLOB t2} 0
test_expr expr-6.21b {t1='abcdefg', t2='a*[df]g'} {t1 GLOB t2} 1
test_expr expr-6.21c {t1='abcdefg', t2='a*[d-h]g'} {t1 GLOB t2} 1
test_expr expr-6.21d {t1='abcdefg', t2='a*[b-e]g'} {t1 GLOB t2} 0
test_expr expr-6.22a {t1='abcdefg', t2='a*[^de]g'} {t1 GLOB t2} 1
test_expr expr-6.22b {t1='abcdefg', t2='a*[^def]g'} {t1 GLOB t2} 0
test_expr expr-6.23 {t1='abcdefg', t2='a*?g'} {t1 GLOB t2} 1
test_expr expr-6.24 {t1='ac', t2='a*c'} {t1 GLOB t2} 1
test_expr expr-6.25 {t1='ac', t2='a*?c'} {t1 GLOB t2} 0
# These tests only work on versions of TCL that support Unicode
#
if {"\u1234"!="u1234" && [sqlite -encoding]=="UTF-8"} {
@@ -235,6 +335,35 @@ if {"\u1234"!="u1234" && [sqlite -encoding]=="UTF-8"} {
test_expr expr-6.41 "t1='a\u1234b', t2='a\[a-\u1233\]b'" {t1 GLOB t2} 0
}
test_expr expr-6.51 {t1='ABC', t2='xyz'} {t1 GLOB t2} 0
test_expr expr-6.52 {t1='ABC', t2='abc'} {t1 GLOB t2} 0
test_expr expr-6.53 {t1='ABC', t2='a?c'} {t1 GLOB t2} 0
test_expr expr-6.54 {t1='ABC', t2='A?C'} {t1 GLOB t2} 1
test_expr expr-6.55 {t1='ABC', t2='abc?'} {t1 GLOB t2} 0
test_expr expr-6.56 {t1='ABC', t2='a*c'} {t1 GLOB t2} 0
test_expr expr-6.57 {t1='ABC', t2='A*C'} {t1 GLOB t2} 1
test_expr expr-6.58 {t1='ABxyzzyC', t2='A*C'} {t1 GLOB t2} 1
test_expr expr-6.59 {t1='ABxyzzy', t2='A*C'} {t1 GLOB t2} 0
test_expr expr-6.60 {t1='ABxyzzyCx', t2='A*C'} {t1 GLOB t2} 0
test_expr expr-6.61 {t1='ABC', t2='xyz'} {t1 NOT GLOB t2} 1
test_expr expr-6.62 {t1='ABC', t2='ABC'} {t1 NOT GLOB t2} 0
test_expr expr-6.63 {t1='ABC', t2='A[Bx]C'} {t1 GLOB t2} 1
test_expr expr-6.64 {t1='ABC', t2='A[Cx]C'} {t1 GLOB t2} 0
test_expr expr-6.65 {t1='ABC', t2='A[A-D]C'} {t1 GLOB t2} 1
test_expr expr-6.66 {t1='ABC', t2='A[^A-D]C'} {t1 GLOB t2} 0
test_expr expr-6.67 {t1='ABC', t2='A[a-dC]C'} {t1 GLOB t2} 0
test_expr expr-6.68 {t1='ABC', t2='A[^a-dC]C'} {t1 GLOB t2} 1
test_expr expr-6.69a {t1='ABC', t2='A[]B]C'} {t1 GLOB t2} 1
test_expr expr-6.69b {t1='A]C', t2='A[]B]C'} {t1 GLOB t2} 1
test_expr expr-6.70a {t1='ABC', t2='A[^]B]C'} {t1 GLOB t2} 0
test_expr expr-6.70b {t1='AxC', t2='A[^]B]C'} {t1 GLOB t2} 1
test_expr expr-6.70c {t1='A]C', t2='A[^]B]C'} {t1 GLOB t2} 0
test_expr expr-6.71 {t1='ABCDEFG', t2='A*[DE]G'} {t1 GLOB t2} 0
test_expr expr-6.72 {t1='ABCDEFG', t2='A*[^DE]G'} {t1 GLOB t2} 1
test_expr expr-6.73 {t1='ABCDEFG', t2='A*?G'} {t1 GLOB t2} 1
test_expr expr-6.74 {t1='AC', t2='A*C'} {t1 GLOB t2} 1
test_expr expr-6.75 {t1='AC', t2='A*?C'} {t1 GLOB t2} 0
# Theses tests are for when SQLite assumes iso8859 characters.
#
if {[sqlite -encoding]=="iso8859"} {
@@ -261,6 +390,40 @@ if {[sqlite -encoding]=="iso8859"} {
test_expr expr-6.62 "t1='a\266b', t2='a\[x-\265\]b'" {t1 GLOB t2} 0
}
}
test_expr expr-6.63 {t1=NULL, t2='a*?c'} {t1 GLOB t2} {{}}
test_expr expr-6.64 {t1='ac', t2=NULL} {t1 GLOB t2} {{}}
test_expr expr-6.65 {t1=NULL, t2='a*?c'} {t1 NOT GLOB t2} {{}}
test_expr expr-6.66 {t1='ac', t2=NULL} {t1 NOT GLOB t2} {{}}
test_expr expr-case.1 {i1=1, i2=2} \
{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne
test_expr expr-case.2 {i1=2, i2=2} \
{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} eq
test_expr expr-case.3 {i1=NULL, i2=2} \
{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne
test_expr expr-case.4 {i1=2, i2=NULL} \
{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne
test_expr expr-case.5 {i1=2} \
{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'error' END} two
test_expr expr-case.6 {i1=1} \
{CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} one
test_expr expr-case.7 {i1=2} \
{CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} error
test_expr expr-case.8 {i1=3} \
{CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} error
test_expr expr-case.9 {i1=3} \
{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'error' END} error
test_expr expr-case.10 {i1=3} \
{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' END} {{}}
test_expr expr-case.11 {i1=null} \
{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 3 END} 3
test_expr expr-case.12 {i1=1} \
{CASE i1 WHEN 1 THEN null WHEN 2 THEN 'two' ELSE 3 END} {{}}
test_expr expr-case.13 {i1=7} \
{ CASE WHEN i1 < 5 THEN 'low'
WHEN i1 < 10 THEN 'medium'
WHEN i1 < 15 THEN 'high' ELSE 'error' END} medium
# The sqliteExprIfFalse and sqliteExprIfTrue routines are only
# executed as part of a WHERE clause. Create a table suitable
@@ -285,8 +448,8 @@ proc test_expr2 {name expr result} {
test_expr2 expr-7.2 {a<10 AND a>8} {9}
test_expr2 expr-7.3 {a<=10 AND a>=8} {8 9 10}
test_expr2 expr-7.4 {a>=8 AND a<=10} {8 9 10}
test_expr2 expr-7.5 {a>=20 OR a<=1} {{} 1 20}
test_expr2 expr-7.6 {b!=4 AND a<=3} {{} 1 3}
test_expr2 expr-7.5 {a>=20 OR a<=1} {1 20}
test_expr2 expr-7.6 {b!=4 AND a<=3} {1 3}
test_expr2 expr-7.7 {b==8 OR b==16 OR b==32} {3 4 5}
test_expr2 expr-7.8 {NOT b<>8 OR b==1024} {3 10}
test_expr2 expr-7.9 {b LIKE '10%'} {10 20}
@@ -297,18 +460,60 @@ test_expr2 expr-7.13 {b GLOB '*1[456]'} {4}
test_expr2 expr-7.14 {a ISNULL} {{}}
test_expr2 expr-7.15 {a NOTNULL AND a<3} {1 2}
test_expr2 expr-7.16 {a AND a<3} {1 2}
test_expr2 expr-7.17 {NOT a} {{}}
test_expr2 expr-7.17 {NOT a} {}
test_expr2 expr-7.18 {a==11 OR (b>1000 AND b<2000)} {10 11}
test_expr2 expr-7.19 {a<=1 OR a>=20} {{} 1 20}
test_expr2 expr-7.20 {a<1 OR a>20} {{}}
test_expr2 expr-7.21 {a>19 OR a<1} {{} 20}
test_expr2 expr-7.19 {a<=1 OR a>=20} {1 20}
test_expr2 expr-7.20 {a<1 OR a>20} {}
test_expr2 expr-7.21 {a>19 OR a<1} {20}
test_expr2 expr-7.22 {a!=1 OR a=100} \
{{} 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
{2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
test_expr2 expr-7.23 {(a notnull AND a<4) OR a==8} {1 2 3 8}
test_expr2 expr-7.24 {a LIKE '2_' OR a==8} {8 20}
test_expr2 expr-7.25 {a GLOB '2?' OR a==8} {8 20}
test_expr2 expr-7.26 {a isnull OR a=8} {{} 8}
test_expr2 expr-7.27 {a notnull OR a=8} \
{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
test_expr2 expr-7.28 {a<0 OR b=0} {{}}
test_expr2 expr-7.29 {b=0 OR a<0} {{}}
test_expr2 expr-7.30 {a<0 AND b=0} {}
test_expr2 expr-7.31 {b=0 AND a<0} {}
test_expr2 expr-7.32 {a IS NULL AND (a<0 OR b=0)} {{}}
test_expr2 expr-7.33 {a IS NULL AND (b=0 OR a<0)} {{}}
test_expr2 expr-7.34 {a IS NULL AND (a<0 AND b=0)} {}
test_expr2 expr-7.35 {a IS NULL AND (b=0 AND a<0)} {}
test_expr2 expr-7.32 {(a<0 OR b=0) AND a IS NULL} {{}}
test_expr2 expr-7.33 {(b=0 OR a<0) AND a IS NULL} {{}}
test_expr2 expr-7.34 {(a<0 AND b=0) AND a IS NULL} {}
test_expr2 expr-7.35 {(b=0 AND a<0) AND a IS NULL} {}
test_expr2 expr-7.36 {a<2 OR (a<0 OR b=0)} {{} 1}
test_expr2 expr-7.37 {a<2 OR (b=0 OR a<0)} {{} 1}
test_expr2 expr-7.38 {a<2 OR (a<0 AND b=0)} {1}
test_expr2 expr-7.39 {a<2 OR (b=0 AND a<0)} {1}
test_expr2 expr-7.40 {((a<2 OR a IS NULL) AND b<3) OR b>1e10} {{} 1}
test_expr2 expr-7.41 {a BETWEEN -1 AND 1} {1}
test_expr2 expr-7.42 {a NOT BETWEEN 2 AND 100} {1}
test_expr2 expr-7.43 {(b+1234)||'this is a string that is at least 32 characters long' BETWEEN 1 AND 2} {}
test_expr2 expr-7.44 {123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a BETWEEN '123a' AND '123b'} {}
test_expr2 expr-7.45 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123b')<0} {}
test_expr2 expr-7.46 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123z')>0} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
test_expr2 expr-7.50 {((a between 1 and 2 OR 0) AND 1) OR 0} {1 2}
test_expr2 expr-7.51 {((a not between 3 and 100 OR 0) AND 1) OR 0} {1 2}
test_expr2 expr-7.52 {((a in (1,2) OR 0) AND 1) OR 0} {1 2}
test_expr2 expr-7.53 {((a not in (3,4,5,6,7,8,9,10) OR 0) AND a<11) OR 0} {1 2}
test_expr2 expr-7.54 {((a>0 OR 0) AND a<3) OR 0} {1 2}
test_expr2 expr-7.55 {((a in (1,2) OR 0) IS NULL AND 1) OR 0} {{}}
test_expr2 expr-7.56 {((a not in (3,4,5,6,7,8,9,10) IS NULL OR 0) AND 1) OR 0} \
{{}}
test_expr2 expr-7.57 {((a>0 IS NULL OR 0) AND 1) OR 0} {{}}
test_expr2 expr-7.58 {(a||'')<='1'} {1}
test_expr2 expr-7.59 {LIKE('10%',b)} {10 20}
test_expr2 expr-7.60 {LIKE('_4',b)} {6}
test_expr2 expr-7.61 {GLOB('1?',a)} {10 11 12 13 14 15 16 17 18 19}
test_expr2 expr-7.62 {GLOB('1*4',b)} {10 14}
test_expr2 expr-7.63 {GLOB('*1[456]',b)} {4}
finish_test
+53
View File
@@ -0,0 +1,53 @@
# 2001 September 15
#
# 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 implements regression tests for SQLite library.
#
# This file implements tests for foreign keys.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Create a table and some data to work with.
#
do_test fkey1-1.0 {
execsql {
CREATE TABLE t1(
a INTEGER PRIMARY KEY,
b INTEGER
REFERENCES t1 ON DELETE CASCADE
REFERENCES t2,
c TEXT,
FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE
);
}
} {}
do_test fkey1-1.1 {
execsql {
CREATE TABLE t2(
x INTEGER PRIMARY KEY,
y TEXT
);
}
} {}
do_test fkey1-1.2 {
execsql {
CREATE TABLE t3(
a INTEGER REFERENCES t2,
b INTEGER REFERENCES t1,
FOREIGN KEY (a,b) REFERENCES t2(x,y)
);
}
} {}
finish_test
+738
View File
@@ -0,0 +1,738 @@
# 2001 September 15
#
# 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 implements regression tests for SQLite library. The
# focus of this file is testing the the library is able to correctly
# handle file-format 3 (version 2.6.x) databases.
#
# $Id: format3.test,v 1.4 2003/12/23 02:17:35 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Create a bunch of data to sort against
#
do_test format3-1.0 {
set fd [open data.txt w]
puts $fd "1\tone\t0\tI\t3.141592653"
puts $fd "2\ttwo\t1\tII\t2.15"
puts $fd "3\tthree\t1\tIII\t4221.0"
puts $fd "4\tfour\t2\tIV\t-0.0013442"
puts $fd "5\tfive\t2\tV\t-11"
puts $fd "6\tsix\t2\tVI\t0.123"
puts $fd "7\tseven\t2\tVII\t123.0"
puts $fd "8\teight\t3\tVIII\t-1.6"
close $fd
execsql {
CREATE TABLE t1(
n int,
v varchar(10),
log int,
roman varchar(10),
flt real
);
COPY t1 FROM 'data.txt'
}
file delete data.txt
db close
set ::bt [btree_open test.db]
btree_begin_transaction $::bt
set m [btree_get_meta $::bt]
set m [lreplace $m 2 2 3]
eval btree_update_meta $::bt $m
btree_commit $::bt
btree_close $::bt
sqlite db test.db
execsql {SELECT count(*) FROM t1}
} {8}
do_test format3-1.1 {
execsql {SELECT n FROM t1 ORDER BY n}
} {1 2 3 4 5 6 7 8}
do_test format3-1.1.1 {
execsql {SELECT n FROM t1 ORDER BY n ASC}
} {1 2 3 4 5 6 7 8}
do_test format3-1.1.1 {
execsql {SELECT ALL n FROM t1 ORDER BY n ASC}
} {1 2 3 4 5 6 7 8}
do_test format3-1.2 {
execsql {SELECT n FROM t1 ORDER BY n DESC}
} {8 7 6 5 4 3 2 1}
do_test format3-1.3a {
execsql {SELECT v FROM t1 ORDER BY v}
} {eight five four one seven six three two}
do_test format3-1.3b {
execsql {SELECT n FROM t1 ORDER BY v}
} {8 5 4 1 7 6 3 2}
do_test format3-1.4 {
execsql {SELECT n FROM t1 ORDER BY v DESC}
} {2 3 6 7 1 4 5 8}
do_test format3-1.5 {
execsql {SELECT flt FROM t1 ORDER BY flt}
} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123.0 4221.0}
do_test format3-1.6 {
execsql {SELECT flt FROM t1 ORDER BY flt DESC}
} {4221.0 123.0 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
do_test format3-1.7 {
execsql {SELECT roman FROM t1 ORDER BY roman}
} {I II III IV V VI VII VIII}
do_test format3-1.8 {
execsql {SELECT n FROM t1 ORDER BY log, flt}
} {1 2 3 5 4 6 7 8}
do_test format3-1.8.1 {
execsql {SELECT n FROM t1 ORDER BY log asc, flt}
} {1 2 3 5 4 6 7 8}
do_test format3-1.8.2 {
execsql {SELECT n FROM t1 ORDER BY log, flt ASC}
} {1 2 3 5 4 6 7 8}
do_test format3-1.8.3 {
execsql {SELECT n FROM t1 ORDER BY log ASC, flt asc}
} {1 2 3 5 4 6 7 8}
do_test format3-1.9 {
execsql {SELECT n FROM t1 ORDER BY log, flt DESC}
} {1 3 2 7 6 4 5 8}
do_test format3-1.9.1 {
execsql {SELECT n FROM t1 ORDER BY log ASC, flt DESC}
} {1 3 2 7 6 4 5 8}
do_test format3-1.10 {
execsql {SELECT n FROM t1 ORDER BY log DESC, flt}
} {8 5 4 6 7 2 3 1}
do_test format3-1.11 {
execsql {SELECT n FROM t1 ORDER BY log DESC, flt DESC}
} {8 7 6 4 5 3 2 1}
# These tests are designed to reach some hard-to-reach places
# inside the string comparison routines.
#
# (Later) The sorting behavior changed in 2.7.0. But we will
# keep these tests. You can never have too many test cases!
#
do_test format3-2.1.1 {
execsql {
UPDATE t1 SET v='x' || -flt;
UPDATE t1 SET v='x-2b' where v=='x-0.123';
SELECT v FROM t1 ORDER BY v;
}
} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
do_test format3-2.1.2 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999);
}
} {x-4221 x-123 x-3.141592653 x-2.15 x0.0013442 x1.6 x11 x-2b}
do_test format3-2.1.3 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;
}
} {x-4221 x-123 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
do_test format3-2.1.4 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999) DESC;
}
} {x-2b x11 x1.6 x0.0013442 x-2.15 x-3.141592653 x-123 x-4221}
do_test format3-2.1.5 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0 DESC;
}
} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123 x-4221}
# This is a bug fix for 2.2.4.
# Strings are normally mapped to upper-case for a caseless comparison.
# But this can cause problems for characters in between 'Z' and 'a'.
#
do_test format3-3.1 {
execsql {
CREATE TABLE t2(a,b);
INSERT INTO t2 VALUES('AGLIENTU',1);
INSERT INTO t2 VALUES('AGLIE`',2);
INSERT INTO t2 VALUES('AGNA',3);
SELECT a, b FROM t2 ORDER BY a;
}
} {AGLIENTU 1 AGLIE` 2 AGNA 3}
do_test format3-3.2 {
execsql {
SELECT a, b FROM t2 ORDER BY a DESC;
}
} {AGNA 3 AGLIE` 2 AGLIENTU 1}
do_test format3-3.3 {
execsql {
DELETE FROM t2;
INSERT INTO t2 VALUES('aglientu',1);
INSERT INTO t2 VALUES('aglie`',2);
INSERT INTO t2 VALUES('agna',3);
SELECT a, b FROM t2 ORDER BY a;
}
} {aglie` 2 aglientu 1 agna 3}
do_test format3-3.4 {
execsql {
SELECT a, b FROM t2 ORDER BY a DESC;
}
} {agna 3 aglientu 1 aglie` 2}
# Version 2.7.0 testing.
#
do_test format3-4.1 {
execsql {
INSERT INTO t1 VALUES(9,'x2.7',3,'IX',4.0e5);
INSERT INTO t1 VALUES(10,'x5.0e10',3,'X',-4.0e5);
INSERT INTO t1 VALUES(11,'x-4.0e9',3,'XI',4.1e4);
INSERT INTO t1 VALUES(12,'x01234567890123456789',3,'XII',-4.2e3);
SELECT n FROM t1 ORDER BY n;
}
} {1 2 3 4 5 6 7 8 9 10 11 12}
do_test format3-4.2 {
execsql {
SELECT n||'' FROM t1 ORDER BY 1;
}
} {1 2 3 4 5 6 7 8 9 10 11 12}
do_test format3-4.3 {
execsql {
SELECT n+0 FROM t1 ORDER BY 1;
}
} {1 2 3 4 5 6 7 8 9 10 11 12}
do_test format3-4.4 {
execsql {
SELECT n||'' FROM t1 ORDER BY 1 DESC;
}
} {12 11 10 9 8 7 6 5 4 3 2 1}
do_test format3-4.5 {
execsql {
SELECT n+0 FROM t1 ORDER BY 1 DESC;
}
} {12 11 10 9 8 7 6 5 4 3 2 1}
do_test format3-4.6 {
execsql {
SELECT v FROM t1 ORDER BY 1;
}
} {x-123 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221 x0.0013442 x01234567890123456789 x1.6 x11 x2.7 x5.0e10}
do_test format3-4.7 {
execsql {
SELECT v FROM t1 ORDER BY 1 DESC;
}
} {x5.0e10 x2.7 x11 x1.6 x01234567890123456789 x0.0013442 x-4221 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123}
do_test format3-4.8 {
execsql {
SELECT substr(v,2,99) FROM t1 ORDER BY 1;
}
} {-4.0e9 -4221 -123 -3.141592653 -2.15 0.0013442 1.6 2.7 11 5.0e10 01234567890123456789 -2b}
# Build some new test data, this time with indices.
#
do_test format3-5.0 {
execsql {
DROP TABLE t1;
CREATE TABLE t1(w int, x text, y blob);
DROP TABLE t2;
CREATE TABLE t2(p varchar(1), q clob, r real, s numeric(8));
}
for {set i 1} {$i<=100} {incr i} {
set w $i
set x [expr {int(log($i)/log(2))}]
set y [expr {$i*$i + 2*$i + 1}]
execsql "INSERT INTO t1 VALUES($w,$x,$y)"
}
execsql {
INSERT INTO t2 SELECT 101-w, x, (SELECT max(y) FROM t1)+1-y, y FROM t1;
CREATE INDEX i1w ON t1(w);
CREATE INDEX i1xy ON t1(x,y);
CREATE INDEX i2p ON t2(p);
CREATE INDEX i2r ON t2(r);
CREATE INDEX i2qs ON t2(q, s);
}
} {}
# Do an SQL statement. Append the search count to the end of the result.
#
proc count sql {
set ::sqlite_search_count 0
return [concat [execsql $sql] $::sqlite_search_count]
}
# Verify that queries use an index. We are using the special variable
# "sqlite_search_count" which tallys the number of executions of MoveTo
# and Next operators in the VDBE. By verifing that the search count is
# small we can be assured that indices are being used properly.
#
do_test format3-5.1 {
db close
sqlite db test.db
count {SELECT x, y FROM t1 WHERE w=10}
} {3 121 3}
do_test format3-5.2 {
count {SELECT x, y FROM t1 WHERE w=11}
} {3 144 3}
do_test format3-5.3 {
count {SELECT x, y FROM t1 WHERE 11=w}
} {3 144 3}
do_test format3-5.4 {
count {SELECT x, y FROM t1 WHERE 11=w AND x>2}
} {3 144 3}
do_test format3-5.5 {
count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2}
} {3 144 3}
do_test format3-5.6 {
count {SELECT x, y FROM t1 WHERE y<200 AND x>2 AND w=11}
} {3 144 3}
do_test format3-5.7 {
count {SELECT x, y FROM t1 WHERE w=11 AND y<200 AND x>2}
} {3 144 3}
do_test format3-5.8 {
count {SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3}
} {3 144 3}
do_test format3-5.9 {
count {SELECT x, y FROM t1 WHERE y=144 AND w>10 AND x=3}
} {3 144 3}
do_test format3-5.10 {
count {SELECT x, y FROM t1 WHERE x=3 AND w>=10 AND y=121}
} {3 121 3}
do_test format3-5.11 {
count {SELECT x, y FROM t1 WHERE x=3 AND y=100 AND w<10}
} {3 100 3}
# New for SQLite version 2.1: Verify that that inequality constraints
# are used correctly.
#
do_test format3-5.12 {
count {SELECT w FROM t1 WHERE x=3 AND y<100}
} {8 3}
do_test format3-5.13 {
count {SELECT w FROM t1 WHERE x=3 AND 100>y}
} {8 3}
do_test format3-5.14 {
count {SELECT w FROM t1 WHERE 3=x AND y<100}
} {8 3}
do_test format3-5.15 {
count {SELECT w FROM t1 WHERE 3=x AND 100>y}
} {8 3}
do_test format3-5.16 {
count {SELECT w FROM t1 WHERE x=3 AND y<=100}
} {8 9 5}
do_test format3-5.17 {
count {SELECT w FROM t1 WHERE x=3 AND 100>=y}
} {8 9 5}
do_test format3-5.18 {
count {SELECT w FROM t1 WHERE x=3 AND y>225}
} {15 3}
do_test format3-5.19 {
count {SELECT w FROM t1 WHERE x=3 AND 225<y}
} {15 3}
do_test format3-5.20 {
count {SELECT w FROM t1 WHERE x=3 AND y>=225}
} {14 15 5}
do_test format3-5.21 {
count {SELECT w FROM t1 WHERE x=3 AND 225<=y}
} {14 15 5}
do_test format3-5.22 {
count {SELECT w FROM t1 WHERE x=3 AND y>121 AND y<196}
} {11 12 5}
do_test format3-5.23 {
count {SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196}
} {10 11 12 13 9}
do_test format3-5.24 {
count {SELECT w FROM t1 WHERE x=3 AND 121<y AND 196>y}
} {11 12 5}
do_test format3-5.25 {
count {SELECT w FROM t1 WHERE x=3 AND 121<=y AND 196>=y}
} {10 11 12 13 9}
# Need to work on optimizing the BETWEEN operator.
#
# do_test format3-5.26 {
# count {SELECT w FROM t1 WHERE x=3 AND y BETWEEN 121 AND 196}
# } {10 11 12 13 9}
do_test format3-5.27 {
count {SELECT w FROM t1 WHERE x=3 AND y+1==122}
} {10 17}
do_test format3-5.28 {
count {SELECT w FROM t1 WHERE x+1=4 AND y+1==122}
} {10 99}
do_test format3-5.29 {
count {SELECT w FROM t1 WHERE y==121}
} {10 99}
do_test format3-5.30 {
count {SELECT w FROM t1 WHERE w>97}
} {98 99 100 6}
do_test format3-5.31 {
count {SELECT w FROM t1 WHERE w>=97}
} {97 98 99 100 8}
do_test format3-5.33 {
count {SELECT w FROM t1 WHERE w==97}
} {97 3}
do_test format3-5.34 {
count {SELECT w FROM t1 WHERE w+1==98}
} {97 99}
do_test format3-5.35 {
count {SELECT w FROM t1 WHERE w<3}
} {1 2 4}
do_test format3-5.36 {
count {SELECT w FROM t1 WHERE w<=3}
} {1 2 3 6}
do_test format3-5.37 {
count {SELECT w FROM t1 WHERE w+1<=4 ORDER BY w}
} {1 2 3 199}
# Do the same kind of thing except use a join as the data source.
#
do_test format3-6.1 {
db close
sqlite db test.db
count {
SELECT w, p FROM t2, t1
WHERE x=q AND y=s AND r=8977
}
} {34 67 6}
do_test format3-6.2 {
count {
SELECT w, p FROM t2, t1
WHERE x=q AND s=y AND r=8977
}
} {34 67 6}
do_test format3-6.3 {
count {
SELECT w, p FROM t2, t1
WHERE x=q AND s=y AND r=8977 AND w>10
}
} {34 67 6}
do_test format3-6.4 {
count {
SELECT w, p FROM t2, t1
WHERE p<80 AND x=q AND s=y AND r=8977 AND w>10
}
} {34 67 6}
do_test format3-6.5 {
count {
SELECT w, p FROM t2, t1
WHERE p<80 AND x=q AND 8977=r AND s=y AND w>10
}
} {34 67 6}
do_test format3-6.6 {
count {
SELECT w, p FROM t2, t1
WHERE x=q AND p=77 AND s=y AND w>5
}
} {24 77 6}
do_test format3-6.7 {
count {
SELECT w, p FROM t1, t2
WHERE x=q AND p>77 AND s=y AND w=5
}
} {5 96 6}
# Lets do a 3-way join.
#
do_test format3-7.1 {
count {
SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=11
}
} {11 90 11 9}
do_test format3-7.2 {
count {
SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=12
}
} {12 89 12 9}
do_test format3-7.3 {
count {
SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
WHERE A.w=15 AND B.p=C.w AND B.r=10202-A.y
}
} {15 86 86 9}
# Test to see that the special case of a constant WHERE clause is
# handled.
#
do_test format3-8.1 {
count {
SELECT * FROM t1 WHERE 0
}
} {0}
do_test format3-8.2 {
count {
SELECT * FROM t1 WHERE 1 LIMIT 1
}
} {1 0 4 1}
do_test format3-8.3 {
execsql {
SELECT 99 WHERE 0
}
} {}
do_test format3-8.4 {
execsql {
SELECT 99 WHERE 1
}
} {99}
# Verify that IN operators in a WHERE clause are handled correctly.
#
do_test format3-9.1 {
count {
SELECT * FROM t1 WHERE rowid IN (1,2,3,1234) order by 1;
}
} {1 0 4 2 1 9 3 1 16 0}
do_test format3-9.2 {
count {
SELECT * FROM t1 WHERE rowid+0 IN (1,2,3,1234) order by 1;
}
} {1 0 4 2 1 9 3 1 16 199}
do_test format3-9.3 {
count {
SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1;
}
} {1 0 4 2 1 9 3 1 16 10}
do_test format3-9.4 {
count {
SELECT * FROM t1 WHERE w+0 IN (-1,1,2,3) order by 1;
}
} {1 0 4 2 1 9 3 1 16 199}
do_test format3-9.5 {
count {
SELECT * FROM t1 WHERE rowid IN
(select rowid from t1 where rowid IN (-1,2,4))
ORDER BY 1;
}
} {2 1 9 4 2 25 1}
do_test format3-9.6 {
count {
SELECT * FROM t1 WHERE rowid+0 IN
(select rowid from t1 where rowid IN (-1,2,4))
ORDER BY 1;
}
} {2 1 9 4 2 25 199}
do_test format3-9.7 {
count {
SELECT * FROM t1 WHERE w IN
(select rowid from t1 where rowid IN (-1,2,4))
ORDER BY 1;
}
} {2 1 9 4 2 25 7}
do_test format3-9.8 {
count {
SELECT * FROM t1 WHERE w+0 IN
(select rowid from t1 where rowid IN (-1,2,4))
ORDER BY 1;
}
} {2 1 9 4 2 25 199}
do_test format3-9.9 {
count {
SELECT * FROM t1 WHERE x IN (1,7) ORDER BY 1;
}
} {2 1 9 3 1 16 6}
do_test format3-9.10 {
count {
SELECT * FROM t1 WHERE x+0 IN (1,7) ORDER BY 1;
}
} {2 1 9 3 1 16 199}
do_test format3-9.11 {
count {
SELECT * FROM t1 WHERE y IN (6400,8100) ORDER BY 1;
}
} {79 6 6400 89 6 8100 199}
do_test format3-9.12 {
count {
SELECT * FROM t1 WHERE x=6 AND y IN (6400,8100) ORDER BY 1;
}
} {79 6 6400 89 6 8100 74}
do_test format3-9.13 {
count {
SELECT * FROM t1 WHERE x IN (1,7) AND y NOT IN (6400,8100) ORDER BY 1;
}
} {2 1 9 3 1 16 6}
do_test format3-9.14 {
count {
SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1;
}
} {2 1 9 6}
# This procedure executes the SQL. Then it checks the generated program
# for the SQL and appends a "nosort" to the result if the program contains the
# SortCallback opcode. If the program does not contain the SortCallback
# opcode it appends "sort"
#
proc cksort {sql} {
set data [execsql $sql]
set prog [execsql "EXPLAIN $sql"]
if {[regexp SortCallback $prog]} {set x sort} {set x nosort}
lappend data $x
return $data
}
# Check out the logic that attempts to implement the ORDER BY clause
# using an index rather than by sorting.
#
do_test format3-10.1 {
execsql {
CREATE TABLE t3(a,b,c);
CREATE INDEX t3a ON t3(a);
CREATE INDEX t3bc ON t3(b,c);
CREATE INDEX t3acb ON t3(a,c,b);
INSERT INTO t3 SELECT w, 101-w, y FROM t1;
SELECT count(*), sum(a), sum(b), sum(c) FROM t3;
}
} {100 5050 5050 348550}
do_test format3-10.2 {
cksort {
SELECT * FROM t3 ORDER BY a LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 nosort}
do_test format3-10.3 {
cksort {
SELECT * FROM t3 ORDER BY a+1 LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 sort}
do_test format3-10.4 {
cksort {
SELECT * FROM t3 WHERE a<10 ORDER BY a LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 nosort}
do_test format3-10.5 {
cksort {
SELECT * FROM t3 WHERE a>0 AND a<10 ORDER BY a LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 nosort}
do_test format3-10.6 {
cksort {
SELECT * FROM t3 WHERE a>0 ORDER BY a LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 nosort}
do_test format3-10.7 {
cksort {
SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 sort}
do_test format3-10.8 {
cksort {
SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 sort}
do_test format3-10.9 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3
}
} {1 100 4 nosort}
do_test format3-10.10 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3
}
} {1 100 4 nosort}
do_test format3-10.11 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c LIMIT 3
}
} {1 100 4 nosort}
do_test format3-10.12 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c,b LIMIT 3
}
} {1 100 4 nosort}
do_test format3-10.13 {
cksort {
SELECT * FROM t3 WHERE a>0 ORDER BY a DESC LIMIT 3
}
} {100 1 10201 99 2 10000 98 3 9801 nosort}
do_test format3-10.13.1 {
cksort {
SELECT * FROM t3 WHERE a>0 ORDER BY a+1 DESC LIMIT 3
}
} {100 1 10201 99 2 10000 98 3 9801 sort}
do_test format3-10.14 {
cksort {
SELECT * FROM t3 ORDER BY b LIMIT 3
}
} {100 1 10201 99 2 10000 98 3 9801 nosort}
do_test format3-10.15 {
cksort {
SELECT t3.a, t1.x FROM t3, t1 WHERE t3.a=t1.w ORDER BY t3.a LIMIT 3
}
} {1 0 2 1 3 1 nosort}
do_test format3-10.16 {
cksort {
SELECT t3.a, t1.x FROM t3, t1 WHERE t3.a=t1.w ORDER BY t1.x, t3.a LIMIT 3
}
} {1 0 2 1 3 1 sort}
do_test format3-10.17 {
cksort {
SELECT y FROM t1 ORDER BY w COLLATE text LIMIT 3;
}
} {4 121 10201 sort}
do_test format3-10.18 {
cksort {
SELECT y FROM t1 ORDER BY w COLLATE numeric LIMIT 3;
}
} {4 9 16 sort}
do_test format3-10.19 {
cksort {
SELECT y FROM t1 ORDER BY w LIMIT 3;
}
} {4 9 16 nosort}
# Check that all comparisons are numeric. Similar tests in misc1.test
# check the same comparisons on a format4+ database and find that some
# are numeric and some are text.
#
do_test format3-11.1 {
execsql {SELECT '0'=='0.0'}
} {1}
do_test format3-11.2 {
execsql {SELECT '0'==0.0}
} {1}
do_test format3-11.3 {
execsql {SELECT '123456789012345678901'=='123456789012345678900'}
} {1}
do_test format3-11.4 {
execsql {
CREATE TABLE t6(a INT UNIQUE, b TEXT UNIQUE);
INSERT INTO t6 VALUES('0','0.0');
SELECT * FROM t6;
}
} {0 0.0}
do_test format3-11.5 {
execsql {
INSERT OR IGNORE INTO t6 VALUES(0.0,'x');
SELECT * FROM t6;
}
} {0 0.0}
do_test format3-11.6 {
execsql {
INSERT OR IGNORE INTO t6 VALUES('y',0);
SELECT * FROM t6;
}
} {0 0.0}
do_test format3-11.7 {
execsql {
CREATE TABLE t7(x INTEGER, y TEXT, z);
INSERT INTO t7 VALUES(0,0,1);
INSERT INTO t7 VALUES(0.0,0,2);
INSERT INTO t7 VALUES(0,0.0,3);
INSERT INTO t7 VALUES(0.0,0.0,4);
SELECT DISTINCT x, y FROM t7 ORDER BY z;
}
} {0 0}
# Make sure attempts to attach a format 3 database fail.
#
do_test format3-12.1 {
file delete -force test2.db
sqlite db2 test2.db
catchsql {
CREATE TABLE t8(x,y);
ATTACH DATABASE 'test.db' AS format3;
} db2;
} {1 {incompatible file format in auxiliary database: format3}}
do_test format3-12.2 {
catchsql {
ATTACH DATABASE 'test2.db' AS test2;
}
} {1 {cannot attach auxiliary databases to an older format master database}}
db2 close
finish_test
+199 -21
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.6 2001/10/20 12:30:12 drh Exp $
# $Id: func.test,v 1.16.2.2 2004/07/18 21:14:05 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -25,6 +25,17 @@ do_test func-0.0 {
}
execsql {SELECT t1 FROM tbl1 ORDER BY t1}
} {free is program software this}
do_test func-0.1 {
execsql {
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
INSERT INTO t2 VALUES(NULL);
INSERT INTO t2 VALUES(345);
INSERT INTO t2 VALUES(NULL);
INSERT INTO t2 VALUES(67890);
SELECT * FROM t2;
}
} {1 {} 345 {} 67890}
# Check out the length() function
#
@@ -34,15 +45,18 @@ do_test func-1.0 {
do_test func-1.1 {
set r [catch {execsql {SELECT length(*) FROM tbl1 ORDER BY t1}} msg]
lappend r $msg
} {1 {too few arguments to function length()}}
} {1 {wrong number of arguments to function length()}}
do_test func-1.2 {
set r [catch {execsql {SELECT length(t1,5) FROM tbl1 ORDER BY t1}} msg]
lappend r $msg
} {1 {too many arguments to function length()}}
} {1 {wrong number of arguments to function length()}}
do_test func-1.3 {
execsql {SELECT length(t1), count(*) FROM tbl1 GROUP BY length(t1)
ORDER BY length(t1)}
} {2 1 4 2 7 1 8 1}
do_test func-1.4 {
execsql {SELECT coalesce(length(a),-1) FROM t2}
} {1 -1 3 -1 5}
# Check out the substr() function
#
@@ -73,6 +87,12 @@ do_test func-2.7 {
do_test func-2.8 {
execsql {SELECT t1 FROM tbl1 ORDER BY substr(t1,2,20)}
} {this software free program is}
do_test func-2.9 {
execsql {SELECT substr(a,1,1) FROM t2}
} {1 {} 3 {} 6}
do_test func-2.10 {
execsql {SELECT substr(a,2,2) FROM t2}
} {{} {} 45 {} 78}
# Only do the following tests if TCL has UTF-8 capabilities and
# the UTF-8 encoding is turned on in the SQLite library.
@@ -87,37 +107,44 @@ do_test func-3.0 {
execsql "INSERT INTO tbl1 VALUES('$word')"
}
execsql {SELECT t1 FROM tbl1 ORDER BY t1}
} "characters contains hi\u1234ho UTF-8"
} "UTF-8 characters contains hi\u1234ho"
do_test func-3.1 {
execsql {SELECT length(t1) FROM tbl1 ORDER BY t1}
} {10 8 5 5}
} {5 10 8 5}
do_test func-3.2 {
execsql {SELECT substr(t1,1,2) FROM tbl1 ORDER BY t1}
} {ch co hi UT}
} {UT ch co hi}
do_test func-3.3 {
execsql {SELECT substr(t1,1,3) FROM tbl1 ORDER BY t1}
} "cha con hi\u1234 UTF"
} "UTF cha con hi\u1234"
do_test func-3.4 {
execsql {SELECT substr(t1,2,2) FROM tbl1 ORDER BY t1}
} "ha on i\u1234 TF"
} "TF ha on i\u1234"
do_test func-3.5 {
execsql {SELECT substr(t1,2,3) FROM tbl1 ORDER BY t1}
} "har ont i\u1234h TF-"
} "TF- har ont i\u1234h"
do_test func-3.6 {
execsql {SELECT substr(t1,3,2) FROM tbl1 ORDER BY t1}
} "ar nt \u1234h F-"
} "F- ar nt \u1234h"
do_test func-3.7 {
execsql {SELECT substr(t1,4,2) FROM tbl1 ORDER BY t1}
} "ra ta ho -8"
} "-8 ra ta ho"
do_test func-3.8 {
execsql {SELECT substr(t1,-1,1) FROM tbl1 ORDER BY t1}
} "s s o 8"
} "8 s s o"
do_test func-3.9 {
execsql {SELECT substr(t1,-3,2) FROM tbl1 ORDER BY t1}
} "er in \u1234h F-"
} "F- er in \u1234h"
do_test func-3.10 {
execsql {SELECT substr(t1,-4,3) FROM tbl1 ORDER BY t1}
} "ter ain i\u1234h TF-"
} "TF- ter ain i\u1234h"
do_test func-3.99 {
execsql {DELETE FROM tbl1}
foreach word {this program is free software} {
execsql "INSERT INTO tbl1 VALUES('$word')"
}
execsql {SELECT t1 FROM tbl1}
} {this program is free software}
} ;# End [sqlite -encoding]==UTF-8 and \u1234!=u1234
@@ -131,23 +158,29 @@ do_test func-4.1 {
INSERT INTO t1 VALUES(3,-2,-5);
}
catchsql {SELECT abs(a,b) FROM t1}
} {1 {too many arguments to function abs()}}
} {1 {wrong number of arguments to function abs()}}
do_test func-4.2 {
catchsql {SELECT abs() FROM t1}
} {1 {too few arguments to function abs()}}
} {1 {wrong number of arguments to function abs()}}
do_test func-4.3 {
catchsql {SELECT abs(b) FROM t1 ORDER BY a}
} {0 {2 1.2345678901234 2}}
do_test func-4.4 {
catchsql {SELECT abs(c) FROM t1 ORDER BY a}
} {0 {3 12345.6789 5}}
} {0 {3 12345.67890 5}}
do_test func-4.4.1 {
execsql {SELECT abs(a) FROM t2}
} {1 {} 345 {} 67890}
do_test func-4.4.2 {
execsql {SELECT abs(t1) FROM tbl1}
} {this program is free software}
do_test func-4.5 {
catchsql {SELECT round(a,b,c) FROM t1}
} {1 {too many arguments to function round()}}
} {1 {wrong number of arguments to function round()}}
do_test func-4.6 {
catchsql {SELECT round(b,2) FROM t1}
} {0 {2.00 1.23 -2.00}}
catchsql {SELECT round(b,2) FROM t1 ORDER BY b}
} {0 {-2.00 1.23 2.00}}
do_test func-4.7 {
catchsql {SELECT round(b,0) FROM t1 ORDER BY a}
} {0 {2 1 -2}}
@@ -162,6 +195,151 @@ do_test func-4.10 {
} {0 {x3.0y x-12345.68y x-5.000y}}
do_test func-4.11 {
catchsql {SELECT round() FROM t1 ORDER BY a}
} {1 {too few arguments to function round()}}
} {1 {wrong number of arguments to function round()}}
do_test func-4.12 {
execsql {SELECT coalesce(round(a,2),'nil') FROM t2}
} {1.00 nil 345.00 nil 67890.00}
do_test func-4.13 {
execsql {SELECT round(t1,2) FROM tbl1}
} {0.00 0.00 0.00 0.00 0.00}
# Test the upper() and lower() functions
#
do_test func-5.1 {
execsql {SELECT upper(t1) FROM tbl1}
} {THIS PROGRAM IS FREE SOFTWARE}
do_test func-5.2 {
execsql {SELECT lower(upper(t1)) FROM tbl1}
} {this program is free software}
do_test func-5.3 {
execsql {SELECT upper(a), lower(a) FROM t2}
} {1 1 {} {} 345 345 {} {} 67890 67890}
do_test func-5.4 {
catchsql {SELECT upper(a,5) FROM t2}
} {1 {wrong number of arguments to function upper()}}
do_test func-5.5 {
catchsql {SELECT upper(*) FROM t2}
} {1 {wrong number of arguments to function upper()}}
# Test the coalesce() and nullif() functions
#
do_test func-6.1 {
execsql {SELECT coalesce(a,'xyz') FROM t2}
} {1 xyz 345 xyz 67890}
do_test func-6.2 {
execsql {SELECT coalesce(upper(a),'nil') FROM t2}
} {1 nil 345 nil 67890}
do_test func-6.3 {
execsql {SELECT coalesce(nullif(1,1),'nil')}
} {nil}
do_test func-6.4 {
execsql {SELECT coalesce(nullif(1,2),'nil')}
} {1}
do_test func-6.5 {
execsql {SELECT coalesce(nullif(1,NULL),'nil')}
} {1}
# Test the last_insert_rowid() function
#
do_test func-7.1 {
execsql {SELECT last_insert_rowid()}
} [db last_insert_rowid]
# Tests for aggregate functions and how they handle NULLs.
#
do_test func-8.1 {
execsql {
SELECT sum(a), count(a), round(avg(a),2), min(a), max(a), count(*) FROM t2;
}
} {68236 3 22745.33 1 67890 5}
do_test func-8.2 {
execsql {
SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t2;
}
} {z+67890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}
do_test func-8.3 {
execsql {
CREATE TEMP TABLE t3 AS SELECT a FROM t2 ORDER BY a DESC;
SELECT min('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;
}
} {z+1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}
do_test func-8.4 {
execsql {
SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;
}
} {z+67890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}
# How do you test the random() function in a meaningful, deterministic way?
#
do_test func-9.1 {
execsql {
SELECT random() is not null;
}
} {1}
# Use the "sqlite_register_test_function" TCL command which is part of
# the text fixture in order to verify correct operation of some of
# the user-defined SQL function APIs that are not used by the built-in
# functions.
#
db close
set ::DB [sqlite db test.db]
sqlite_register_test_function $::DB testfunc
do_test func-10.1 {
catchsql {
SELECT testfunc(NULL,NULL);
}
} {1 {first argument to test function may not be NULL}}
do_test func-10.2 {
execsql {
SELECT testfunc(
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'int', 1234
);
}
} {1234}
do_test func-10.3 {
execsql {
SELECT testfunc(
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'string', NULL
);
}
} {{}}
do_test func-10.4 {
execsql {
SELECT testfunc(
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'double', 1.234
);
}
} {1.234}
do_test func-10.5 {
execsql {
SELECT testfunc(
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'int', 1234,
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'string', NULL,
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'double', 1.234,
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'int', 1234,
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'string', NULL,
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'double', 1.234
);
}
} {1.234}
# Test the built-in sqlite_version(*) SQL function.
#
do_test func-11.1 {
execsql {
SELECT sqlite_version(*);
}
} [sqlite -version]
finish_test
+83
View File
@@ -0,0 +1,83 @@
# 2004 Jan 14
#
# 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 implements regression tests for TCL interface to the
# SQLite library.
#
# The focus of the tests in this file is the following interface:
#
# sqlite_commit_hook
#
# $Id: hook.test,v 1.3 2004/01/15 02:44:03 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test hook-1.2 {
db commit_hook
} {}
do_test hook-3.1 {
set commit_cnt 0
proc commit_hook {} {
incr ::commit_cnt
return 0
}
db commit_hook ::commit_hook
db commit_hook
} {::commit_hook}
do_test hook-3.2 {
set commit_cnt
} {0}
do_test hook-3.3 {
execsql {
CREATE TABLE t2(a,b);
}
set commit_cnt
} {1}
do_test hook-3.4 {
execsql {
INSERT INTO t2 VALUES(1,2);
INSERT INTO t2 SELECT a+1, b+1 FROM t2;
INSERT INTO t2 SELECT a+2, b+2 FROM t2;
}
set commit_cnt
} {4}
do_test hook-3.5 {
set commit_cnt {}
proc commit_hook {} {
set ::commit_cnt [execsql {SELECT * FROM t2}]
return 0
}
execsql {
INSERT INTO t2 VALUES(5,6);
}
set commit_cnt
} {1 2 2 3 3 4 4 5 5 6}
do_test hook-3.6 {
set commit_cnt {}
proc commit_hook {} {
set ::commit_cnt [execsql {SELECT * FROM t2}]
return 1
}
catchsql {
INSERT INTO t2 VALUES(6,7);
}
} {1 {constraint failed}}
do_test hook-3.7 {
set commit_cnt
} {1 2 2 3 3 4 4 5 5 6 6 7}
do_test hook-3.8 {
execsql {SELECT * FROM t2}
} {1 2 2 3 3 4 4 5 5 6}
finish_test
+147 -3
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the IN and BETWEEN operator.
#
# $Id: in.test,v 1.5 2001/09/16 00:13:28 drh Exp $
# $Id: in.test,v 1.11 2004/01/15 03:30:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -84,9 +84,9 @@ do_test in-2.8 {
execsql {SELECT a FROM t1 WHERE b IN (8*2,64/2) ORDER BY b}
} {4 5}
do_test in-2.9 {
set v [catch {execsql {SELECT a FROM t1 WHERE b IN (xyz(5,10),20)}} msg]
set v [catch {execsql {SELECT a FROM t1 WHERE b IN (max(5,10),20)}} msg]
lappend v $msg
} {1 {no such function: xyz}}
} {1 {right-hand side of IN operator must be constant}}
do_test in-2.10 {
set v [catch {execsql {SELECT a FROM t1 WHERE min(0,b IN (a,30))}} msg]
lappend v $msg
@@ -156,4 +156,148 @@ do_test in-5.1 {
}
} {hello world}
# Make sure the IN operator works with INTEGER PRIMARY KEY fields.
#
do_test in-6.1 {
execsql {
CREATE TABLE ta(a INTEGER PRIMARY KEY, b);
INSERT INTO ta VALUES(1,1);
INSERT INTO ta VALUES(2,2);
INSERT INTO ta VALUES(3,3);
INSERT INTO ta VALUES(4,4);
INSERT INTO ta VALUES(6,6);
INSERT INTO ta VALUES(8,8);
INSERT INTO ta VALUES(10,
'This is a key that is long enough to require a malloc in the VDBE');
SELECT * FROM ta WHERE a<10;
}
} {1 1 2 2 3 3 4 4 6 6 8 8}
do_test in-6.2 {
execsql {
CREATE TABLE tb(a INTEGER PRIMARY KEY, b);
INSERT INTO tb VALUES(1,1);
INSERT INTO tb VALUES(2,2);
INSERT INTO tb VALUES(3,3);
INSERT INTO tb VALUES(5,5);
INSERT INTO tb VALUES(7,7);
INSERT INTO tb VALUES(9,9);
INSERT INTO tb VALUES(11,
'This is a key that is long enough to require a malloc in the VDBE');
SELECT * FROM tb WHERE a<10;
}
} {1 1 2 2 3 3 5 5 7 7 9 9}
do_test in-6.3 {
execsql {
SELECT a FROM ta WHERE b IN (SELECT a FROM tb);
}
} {1 2 3}
do_test in-6.4 {
execsql {
SELECT a FROM ta WHERE b NOT IN (SELECT a FROM tb);
}
} {4 6 8 10}
do_test in-6.5 {
execsql {
SELECT a FROM ta WHERE b IN (SELECT b FROM tb);
}
} {1 2 3 10}
do_test in-6.6 {
execsql {
SELECT a FROM ta WHERE b NOT IN (SELECT b FROM tb);
}
} {4 6 8}
do_test in-6.7 {
execsql {
SELECT a FROM ta WHERE a IN (SELECT a FROM tb);
}
} {1 2 3}
do_test in-6.8 {
execsql {
SELECT a FROM ta WHERE a NOT IN (SELECT a FROM tb);
}
} {4 6 8 10}
do_test in-6.9 {
execsql {
SELECT a FROM ta WHERE a IN (SELECT b FROM tb);
}
} {1 2 3}
do_test in-6.10 {
execsql {
SELECT a FROM ta WHERE a NOT IN (SELECT b FROM tb);
}
} {4 6 8 10}
# Tests of IN operator against empty sets. (Ticket #185)
#
do_test in-7.1 {
execsql {
SELECT a FROM t1 WHERE a IN ();
}
} {}
do_test in-7.2 {
execsql {
SELECT a FROM t1 WHERE a IN (5);
}
} {5}
do_test in-7.3 {
execsql {
SELECT a FROM t1 WHERE a NOT IN () ORDER BY a;
}
} {5 6 7 8 hello}
do_test in-7.4 {
execsql {
SELECT a FROM t1 WHERE a IN (5) AND b IN ();
}
} {}
do_test in-7.5 {
execsql {
SELECT a FROM t1 WHERE a IN (5) AND b NOT IN ();
}
} {5}
do_test in-7.6 {
execsql {
SELECT a FROM ta WHERE a IN ();
}
} {}
do_test in-7.7 {
execsql {
SELECT a FROM ta WHERE a NOT IN ();
}
} {1 2 3 4 6 8 10}
do_test in-8.1 {
execsql {
SELECT b FROM t1 WHERE a IN ('hello','there')
}
} {world}
do_test in-8.2 {
execsql {
SELECT b FROM t1 WHERE a IN ("hello",'there')
}
} {world}
# Test constructs of the form: expr IN tablename
#
do_test in-9.1 {
execsql {
CREATE TABLE t4 AS SELECT a FROM tb;
SELECT * FROM t4;
}
} {1 2 3 5 7 9 11}
do_test in-9.2 {
execsql {
SELECT b FROM t1 WHERE a IN t4;
}
} {32 128}
do_test in-9.3 {
execsql {
SELECT b FROM t1 WHERE a NOT IN t4;
}
} {64 256 world}
do_test in-9.4 {
catchsql {
SELECT b FROM t1 WHERE a NOT IN tb;
}
} {1 {only a single result allowed for a SELECT that is part of an expression}}
finish_test
+216 -6
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the CREATE INDEX statement.
#
# $Id: index.test,v 1.14 2001/09/27 15:11:55 drh Exp $
# $Id: index.test,v 1.24.2.1 2004/07/20 00:50:30 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -74,12 +74,12 @@ do_test index-2.2 {
#
set r {}
for {set i 1} {$i<100} {incr i} {
lappend r index$i
lappend r [format index%02d $i]
}
do_test index-3.1 {
execsql {CREATE TABLE test1(f1 int, f2 int, f3 int, f4 int, f5 int)}
for {set i 1} {$i<100} {incr i} {
set sql "CREATE INDEX index$i ON test1(f[expr {($i%5)+1}])"
set sql "CREATE INDEX [format index%02d $i] ON test1(f[expr {($i%5)+1}])"
execsql $sql
}
execsql {SELECT name FROM sqlite_master
@@ -154,13 +154,14 @@ do_test index-4.13 {
execsql {DROP TABLE test1}
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} {}
integrity_check index-4.14
# Do not allow indices to be added to sqlite_master
#
do_test index-5.1 {
set v [catch {execsql {CREATE INDEX index1 ON sqlite_master(name)}} msg]
lappend v $msg
} {1 {table sqlite_master may not have new indices added}}
} {1 {table sqlite_master may not be indexed}}
do_test index-5.2 {
execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
} {}
@@ -189,6 +190,18 @@ do_test index-6.3 {
execsql {DROP TABLE test2}
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} {}
do_test index-6.4 {
execsql {
CREATE TABLE test1(a,b);
CREATE INDEX index1 ON test1(a);
CREATE INDEX index2 ON test1(b);
CREATE INDEX index3 ON test1(a,b);
DROP TABLE test1;
SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name;
}
} {}
integrity_check index-6.5
# Create a primary key
#
@@ -212,6 +225,7 @@ do_test index-7.4 {
execsql {DROP table test1}
execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
} {}
integrity_check index-7.5
# Make sure we cannot drop a non-existant index.
#
@@ -232,6 +246,7 @@ do_test index-9.2 {
execsql {CREATE INDEX idx1 ON tab1(a)}
execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1' ORDER BY name}
} {idx1 tab1}
integrity_check index-9.3
# Allow more than one entry with the same key.
#
@@ -302,6 +317,7 @@ do_test index-10.8 {
SELECT b FROM t1 ORDER BY b;
}
} {0}
integrity_check index-10.9
# Automatically create an index when we specify a primary key.
#
@@ -317,7 +333,201 @@ do_test index-11.1 {
for {set i 1} {$i<=50} {incr i} {
execsql "INSERT INTO t3 VALUES('x${i}x',$i,0.$i)"
}
execsql {SELECT c, fcnt() FROM t3 WHERE b==10}
} {0.10 1}
set sqlite_search_count 0
concat [execsql {SELECT c FROM t3 WHERE b==10}] $sqlite_search_count
} {0.10 3}
integrity_check index-11.2
# Numeric strings should compare as if they were numbers. So even if the
# strings are not character-by-character the same, if they represent the
# same number they should compare equal to one another. Verify that this
# is true in indices.
#
do_test index-12.1 {
execsql {
CREATE TABLE t4(a,b);
INSERT INTO t4 VALUES('0.0',1);
INSERT INTO t4 VALUES('0.00',2);
INSERT INTO t4 VALUES('abc',3);
INSERT INTO t4 VALUES('-1.0',4);
INSERT INTO t4 VALUES('+1.0',5);
INSERT INTO t4 VALUES('0',6);
INSERT INTO t4 VALUES('00000',7);
SELECT a FROM t4 ORDER BY b;
}
} {0.0 0.00 abc -1.0 +1.0 0 00000}
do_test index-12.2 {
execsql {
SELECT a FROM t4 WHERE a==0 ORDER BY b
}
} {0.0 0.00 0 00000}
do_test index-12.3 {
execsql {
SELECT a FROM t4 WHERE a<0.5 ORDER BY b
}
} {0.0 0.00 -1.0 0 00000}
do_test index-12.4 {
execsql {
SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
}
} {0.0 0.00 abc +1.0 0 00000}
do_test index-12.5 {
execsql {
CREATE INDEX t4i1 ON t4(a);
SELECT a FROM t4 WHERE a==0 ORDER BY b
}
} {0.0 0.00 0 00000}
do_test index-12.6 {
execsql {
SELECT a FROM t4 WHERE a<0.5 ORDER BY b
}
} {0.0 0.00 -1.0 0 00000}
do_test index-12.7 {
execsql {
SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
}
} {0.0 0.00 abc +1.0 0 00000}
integrity_check index-12.8
# Make sure we cannot drop an automatically created index.
#
do_test index-13.1 {
execsql {
CREATE TABLE t5(
a int UNIQUE,
b float PRIMARY KEY,
c varchar(10),
UNIQUE(a,c)
);
INSERT INTO t5 VALUES(1,2,3);
SELECT * FROM t5;
}
} {1 2 3}
do_test index-13.2 {
set ::idxlist [execsql {
SELECT name FROM sqlite_master WHERE type="index" AND tbl_name="t5";
}]
llength $::idxlist
} {3}
for {set i 0} {$i<[llength $::idxlist]} {incr i} {
do_test index-13.3.$i {
catchsql "
DROP INDEX '[lindex $::idxlist $i]';
"
} {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}
}
do_test index-13.4 {
execsql {
INSERT INTO t5 VALUES('a','b','c');
SELECT * FROM t5;
}
} {1 2 3 a b c}
integrity_check index-13.5
# Check the sort order of data in an index.
#
do_test index-14.1 {
execsql {
CREATE TABLE t6(a,b,c);
CREATE INDEX t6i1 ON t6(a,b);
INSERT INTO t6 VALUES('','',1);
INSERT INTO t6 VALUES('',NULL,2);
INSERT INTO t6 VALUES(NULL,'',3);
INSERT INTO t6 VALUES('abc',123,4);
INSERT INTO t6 VALUES(123,'abc',5);
SELECT c FROM t6 ORDER BY a,b;
}
} {3 5 2 1 4}
do_test index-14.2 {
execsql {
SELECT c FROM t6 WHERE a='';
}
} {2 1}
do_test index-14.3 {
execsql {
SELECT c FROM t6 WHERE b='';
}
} {1 3}
do_test index-14.4 {
execsql {
SELECT c FROM t6 WHERE a>'';
}
} {4}
do_test index-14.5 {
execsql {
SELECT c FROM t6 WHERE a>='';
}
} {2 1 4}
do_test index-14.6 {
execsql {
SELECT c FROM t6 WHERE a>123;
}
} {2 1 4}
do_test index-14.7 {
execsql {
SELECT c FROM t6 WHERE a>=123;
}
} {5 2 1 4}
do_test index-14.8 {
execsql {
SELECT c FROM t6 WHERE a<'abc';
}
} {5 2 1}
do_test index-14.9 {
execsql {
SELECT c FROM t6 WHERE a<='abc';
}
} {5 2 1 4}
do_test index-14.10 {
execsql {
SELECT c FROM t6 WHERE a<='';
}
} {5 2 1}
do_test index-14.11 {
execsql {
SELECT c FROM t6 WHERE a<'';
}
} {5}
integrity_check index-14.12
do_test index-15.1 {
execsql {
DELETE FROM t1;
SELECT * FROM t1;
}
} {}
do_test index-15.2 {
execsql {
INSERT INTO t1 VALUES('1.234e5',1);
INSERT INTO t1 VALUES('12.33e04',2);
INSERT INTO t1 VALUES('12.35E4',3);
INSERT INTO t1 VALUES('12.34e',4);
INSERT INTO t1 VALUES('12.32e+4',5);
INSERT INTO t1 VALUES('12.36E+04',6);
INSERT INTO t1 VALUES('12.36E+',7);
INSERT INTO t1 VALUES('+123.10000E+0003',8);
INSERT INTO t1 VALUES('+',9);
INSERT INTO t1 VALUES('+12347.E+02',10);
INSERT INTO t1 VALUES('+12347E+02',11);
SELECT b FROM t1 ORDER BY a;
}
} {8 5 2 1 3 6 11 9 10 4 7}
integrity_check index-15.1
# Drop index with a quoted name. Ticket #695.
#
do_test index-16.1 {
execsql {
CREATE INDEX "t6i2" ON t6(c);
DROP INDEX "t6i2";
}
} {}
do_test index-16.2 {
execsql {
DROP INDEX "t6i1";
}
} {}
finish_test
+127 -1
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the INSERT statement.
#
# $Id: insert.test,v 1.6 2001/09/16 00:13:28 drh Exp $
# $Id: insert.test,v 1.15 2003/06/15 23:42:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -156,5 +156,131 @@ do_test insert-3.3 {
do_test insert-3.4 {
execsql {SELECT * FROM test2 WHERE f1=22 AND f2=-4.44}
} {22 -4.44 hi abc-123 wham}
integrity_check insert-3.5
# Test of expressions in the VALUES clause
#
do_test insert-4.1 {
execsql {
CREATE TABLE t3(a,b,c);
INSERT INTO t3 VALUES(1+2+3,4,5);
SELECT * FROM t3;
}
} {6 4 5}
do_test insert-4.2 {
execsql {
INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1,5,6);
SELECT * FROM t3 ORDER BY a;
}
} {6 4 5 7 5 6}
do_test insert-4.3 {
catchsql {
INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1,t3.a,6);
SELECT * FROM t3 ORDER BY a;
}
} {1 {no such column: t3.a}}
do_test insert-4.4 {
execsql {
INSERT INTO t3 VALUES((SELECT b FROM t3 WHERE a=0),6,7);
SELECT * FROM t3 ORDER BY a;
}
} {{} 6 7 6 4 5 7 5 6}
do_test insert-4.5 {
execsql {
SELECT b,c FROM t3 WHERE a IS NULL;
}
} {6 7}
do_test insert-4.6 {
catchsql {
INSERT INTO t3 VALUES(notafunc(2,3),2,3);
}
} {1 {no such function: notafunc}}
do_test insert-4.7 {
execsql {
INSERT INTO t3 VALUES(min(1,2,3),max(1,2,3),99);
SELECT * FROM t3 WHERE c=99;
}
} {1 3 99}
# Test the ability to insert from a temporary table into itself.
# Ticket #275.
#
do_test insert-5.1 {
execsql {
CREATE TEMP TABLE t4(x);
INSERT INTO t4 VALUES(1);
SELECT * FROM t4;
}
} {1}
do_test insert-5.2 {
execsql {
INSERT INTO t4 SELECT x+1 FROM t4;
SELECT * FROM t4;
}
} {1 2}
do_test insert-5.3 {
# verify that a temporary table is used to copy t4 to t4
set x [execsql {
EXPLAIN INSERT INTO t4 SELECT x+2 FROM t4;
}]
expr {[lsearch $x OpenTemp]>0}
} {1}
do_test insert-5.4 {
# Verify that table "test1" begins on page 3. This should be the same
# page number used by "t4" above.
execsql {
SELECT rootpage FROM sqlite_master WHERE name='test1';
}
} {3}
do_test insert-5.5 {
# Verify that "t4" begins on page 3.
execsql {
SELECT rootpage FROM sqlite_temp_master WHERE name='t4';
}
} {3}
do_test insert-5.6 {
# This should not use an intermediate temporary table.
execsql {
INSERT INTO t4 SELECT one FROM test1 WHERE three=7;
SELECT * FROM t4
}
} {1 2 8}
do_test insert-5.7 {
# verify that no temporary table is used to copy test1 to t4
set x [execsql {
EXPLAIN INSERT INTO t4 SELECT one FROM test1;
}]
expr {[lsearch $x OpenTemp]>0}
} {0}
# Ticket #334: REPLACE statement corrupting indices.
#
do_test insert-6.1 {
execsql {
CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
INSERT INTO t1 VALUES(1,2);
INSERT INTO t1 VALUES(2,3);
SELECT b FROM t1 WHERE b=2;
}
} {2}
do_test insert-6.2 {
execsql {
REPLACE INTO t1 VALUES(1,4);
SELECT b FROM t1 WHERE b=2;
}
} {}
do_test insert-6.3 {
execsql {
UPDATE OR REPLACE t1 SET a=2 WHERE b=4;
SELECT * FROM t1 WHERE b=4;
}
} {2 4}
do_test insert-6.4 {
execsql {
SELECT * FROM t1 WHERE b=3;
}
} {}
integrity_check insert-99.0
finish_test
+109 -1
View File
@@ -12,7 +12,7 @@
# focus of this file is testing the INSERT statement that takes is
# result from a SELECT.
#
# $Id: insert2.test,v 1.5 2001/10/15 00:44:36 drh Exp $
# $Id: insert2.test,v 1.10 2002/06/25 13:16:04 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -38,6 +38,9 @@ do_test insert2-1.1.1 {
}
} {6}
do_test insert2-1.1.2 {
db changes
} {6}
do_test insert2-1.1.3 {
execsql {SELECT * FROM t1 ORDER BY log}
} {0 1 1 1 2 2 3 4 4 8 5 4}
@@ -83,4 +86,109 @@ do_test insert2-1.4 {
lappend r [execsql {SELECT log FROM t1 WHERE cnt=4 ORDER BY log}]
} {0 1 1 1 2 2 3 4 4 8 5 4 4 {3 5}}
do_test insert2-2.0 {
execsql {
CREATE TABLE t3(a,b,c);
CREATE TABLE t4(x,y);
INSERT INTO t4 VALUES(1,2);
SELECT * FROM t4;
}
} {1 2}
do_test insert2-2.1 {
execsql {
INSERT INTO t3(a,c) SELECT * FROM t4;
SELECT * FROM t3;
}
} {1 {} 2}
do_test insert2-2.2 {
execsql {
DELETE FROM t3;
INSERT INTO t3(c,b) SELECT * FROM t4;
SELECT * FROM t3;
}
} {{} 2 1}
do_test insert2-2.3 {
execsql {
DELETE FROM t3;
INSERT INTO t3(c,a,b) SELECT x, 'hi', y FROM t4;
SELECT * FROM t3;
}
} {hi 2 1}
integrity_check insert2-3.0
# File table t4 with lots of data
#
do_test insert2-3.1 {
execsql {
SELECT * from t4;
}
} {1 2}
do_test insert2-3.2 {
execsql {
BEGIN;
INSERT INTO t4 VALUES(2,4);
INSERT INTO t4 VALUES(3,6);
INSERT INTO t4 VALUES(4,8);
INSERT INTO t4 VALUES(5,10);
INSERT INTO t4 VALUES(6,12);
INSERT INTO t4 VALUES(7,14);
INSERT INTO t4 VALUES(8,16);
INSERT INTO t4 VALUES(9,18);
INSERT INTO t4 VALUES(10,20);
COMMIT;
}
db changes
} {9}
do_test insert2-3.2.1 {
execsql {
SELECT count(*) FROM t4;
}
} {10}
do_test insert2-3.3 {
execsql {
BEGIN;
INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
COMMIT;
SELECT count(*) FROM t4;
}
} {160}
do_test insert2-3.4 {
execsql {
BEGIN;
UPDATE t4 SET y='lots of data for the row where x=' || x
|| ' and y=' || y || ' - even more data to fill space';
COMMIT;
SELECT count(*) FROM t4;
}
} {160}
do_test insert2-3.5 {
execsql {
BEGIN;
INSERT INTO t4 SELECT x+(SELECT max(x)+1 FROM t4),y FROM t4;
SELECT count(*) from t4;
ROLLBACK;
}
} {320}
do_test insert2-3.6 {
execsql {
SELECT count(*) FROM t4;
}
} {160}
do_test insert2-3.7 {
execsql {
BEGIN;
DELETE FROM t4 WHERE x!=123;
SELECT count(*) FROM t4;
ROLLBACK;
}
} {1}
do_test insert2-3.8 {
db changes
} {159}
integrity_check insert2-3.9
finish_test

Some files were not shown because too many files have changed in this diff Show More