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

Merge in all the latest updates and enhancements from trunk.

FossilOrigin-Name: 67587a3348b84424b2ab1f2df1ea923a5168e2e4
This commit is contained in:
drh
2013-08-19 12:49:06 +00:00
29 changed files with 537 additions and 193 deletions

22
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.62 for sqlite 3.7.16.2. # Generated by GNU Autoconf 2.62 for sqlite 3.8.0.
# #
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='sqlite' PACKAGE_NAME='sqlite'
PACKAGE_TARNAME='sqlite' PACKAGE_TARNAME='sqlite'
PACKAGE_VERSION='3.7.16.2' PACKAGE_VERSION='3.8.0'
PACKAGE_STRING='sqlite 3.7.16.2' PACKAGE_STRING='sqlite 3.8.0'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
# Factoring default headers for most tests. # Factoring default headers for most tests.
@@ -1484,7 +1484,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures sqlite 3.7.16.2 to adapt to many kinds of systems. \`configure' configures sqlite 3.8.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1549,7 +1549,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of sqlite 3.7.16.2:";; short | recursive ) echo "Configuration of sqlite 3.8.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@@ -1665,7 +1665,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
sqlite configure 3.7.16.2 sqlite configure 3.8.0
generated by GNU Autoconf 2.62 generated by GNU Autoconf 2.62
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1679,7 +1679,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by sqlite $as_me 3.7.16.2, which was It was created by sqlite $as_me 3.8.0, which was
generated by GNU Autoconf 2.62. Invocation command line was generated by GNU Autoconf 2.62. Invocation command line was
$ $0 $@ $ $0 $@
@@ -14032,7 +14032,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by sqlite $as_me 3.7.16.2, which was This file was extended by sqlite $as_me 3.8.0, which was
generated by GNU Autoconf 2.62. Invocation command line was generated by GNU Autoconf 2.62. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@@ -14085,7 +14085,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\ ac_cs_version="\\
sqlite config.status 3.7.16.2 sqlite config.status 3.8.0
configured by $0, generated by GNU Autoconf 2.62, configured by $0, generated by GNU Autoconf 2.62,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -14518,8 +14518,7 @@ $debug ||
if test -n "$CONFIG_FILES"; then if test -n "$CONFIG_FILES"; then
ac_cr=' ac_cr='
'
' '
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
@@ -15754,3 +15753,4 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:$LINENO: WARNING: Unrecognized options: $ac_unrecognized_opts" >&5 { $as_echo "$as_me:$LINENO: WARNING: Unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2;} $as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2;}
fi

View File

@@ -1,5 +1,5 @@
C Merge\sin\sthe\slatest\schanges\sfrom\strunk. C Merge\sin\sall\sthe\slatest\supdates\sand\senhancements\sfrom\strunk.
D 2013-08-06T14:52:27.425 D 2013-08-19T12:49:06.766
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in aff38bc64c582dd147f18739532198372587b0f0 F Makefile.in aff38bc64c582dd147f18739532198372587b0f0
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -38,7 +38,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63
F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977
F config.h.in 0921066a13130082764ab4ab6456f7b5bebe56de F config.h.in 0921066a13130082764ab4ab6456f7b5bebe56de
F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55
F configure 22aa4520a498ef553e9386921913e498c3c45b56 x F configure 27e9279a219b652bd1c53439353a5e5be70214b2 x
F configure.ac 81c43d151d0b0e406be056394cc9ff4cb3fd0444 F configure.ac 81c43d151d0b0e406be056394cc9ff4cb3fd0444
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1
@@ -171,21 +171,21 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168 F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168
F src/analyze.c a33fcb0b3a399d966951feb9f32115106b3ecc2e F src/analyze.c a33fcb0b3a399d966951feb9f32115106b3ecc2e
F src/attach.c 1816f5a9eea8d2010fc2b22b44f0f63eb3a62704 F src/attach.c 5df737912f668fd160ec1d560755f85fdccbe5b7
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c 43b348822db3e4cef48b2ae5a445fbeb6c73a165 F src/backup.c 43b348822db3e4cef48b2ae5a445fbeb6c73a165
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
F src/btree.c 3f7bbfd72efb1cbf6a49515c376a031767ec930a F src/btree.c 9b985e4f334a1b3df5733e2ac2de1de9bdd41be7
F src/btree.h 6fa8a3ff2483d0bb64a9f0105a8cedeac9e00cca F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf
F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2
F src/build.c cee4724668ebc09bb482c1be30f96e0ae2474f9b F src/build.c f99a715ff9290996b579d5e1ec8e94239dc9ae5e
F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c 4262c227bc91cecc61ae37ed3a40f08069cfa267 F src/ctime.c 4262c227bc91cecc61ae37ed3a40f08069cfa267
F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4
F src/delete.c 30ed4bc76a1a32c55bf17ac1528c5867aa5502c0 F src/delete.c 30ed4bc76a1a32c55bf17ac1528c5867aa5502c0
F src/expr.c 7e55edefb8bd0b35b382ce9226c58472cd63a443 F src/expr.c 0bbb44462a19169189b2709fbbd800950521b5ae
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb
F src/func.c 5c50c1ea31fd864b0fe921fe1a8d4c55acd609ef F src/func.c 5c50c1ea31fd864b0fe921fe1a8d4c55acd609ef
@@ -198,13 +198,13 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303
F src/main.c e3ce4cb4a9d0634ce74b9711bd800405ae470954 F src/main.c 525985af588234b3d01b48fe856b83d9bdc2d912
F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa
F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf
F src/mem3.c 61c9d47b792908c532ca3a62b999cf21795c6534 F src/mem3.c 61c9d47b792908c532ca3a62b999cf21795c6534
F src/mem5.c c2c63b7067570b00bf33d751c39af24182316f7f F src/mem5.c 0025308a93838022bd5696cf9627ff4e40b19918
F src/memjournal.c 0683aac6cab6ec2b5374c0db37c0deb2436a3785 F src/memjournal.c 0683aac6cab6ec2b5374c0db37c0deb2436a3785
F src/mutex.c d3b66a569368015e0fcb1ac15f81c119f504d3bc F src/mutex.c d3b66a569368015e0fcb1ac15f81c119f504d3bc
F src/mutex.h 5bc526e19dccc412b7ff04642f6fdad3fdfdabea F src/mutex.h 5bc526e19dccc412b7ff04642f6fdad3fdfdabea
@@ -217,28 +217,28 @@ F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_unix.c 9eafa5458cf2ff684ddccff82c9bb113c7cad847 F src/os_unix.c 9eafa5458cf2ff684ddccff82c9bb113c7cad847
F src/os_win.c 1d84f2079d9b91f91a4b5dbfa5e08f1b1a0ed0ff F src/os_win.c 1d84f2079d9b91f91a4b5dbfa5e08f1b1a0ed0ff
F src/pager.c 5d2f7475260a8588f9c441bb309d2b7eaa7ded3b F src/pager.c 7c999137cb940133f7fc7609ccfa66f17eec4ab4
F src/pager.h 5cb78b8e1adfd5451e600be7719f5a99d87ac3b1 F src/pager.h 66e42d6942a445d4c25651733ab2079dbebc7ca9
F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
F src/pcache1.c d23d07716de96c7c0c2503ec5051a4384c3fb938 F src/pcache1.c d23d07716de96c7c0c2503ec5051a4384c3fb938
F src/pragma.c 590c75750d93ec5a1f903e4bb0dc6d2a0845bf8b F src/pragma.c 1d96ba749253b49bc229c6294f9c2e5ef3dca85c
F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f
F src/printf.c 41c49dac366a3a411190001a8ab495fa8887974e F src/printf.c 41c49dac366a3a411190001a8ab495fa8887974e
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c 17e670996729ac41aadf6a31f57b4e6f29b3d819 F src/resolve.c 9d53899cc6e1f4ec0b4632d07e97d57827bf63b9
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 8b148eb851f384412aea57091659d14b369918ca F src/select.c 8b148eb851f384412aea57091659d14b369918ca
F src/shell.c 927e17b37b63b24461e372d982138fb22c4df321 F src/shell.c 909f6c4a52c8e0265ce0048e2b3cbadda1bd6051
F src/sqlite.h.in 9dbc04c103f297d2bd26c7e323f0bdb9aaf0dc8a F src/sqlite.h.in dcca940021f8f6643630fb7711bfd4e3fa002566
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
F src/sqliteInt.h 1f9abddff71bbce4f51d275d3dc5262ceae7aa61 F src/sqliteInt.h a24a7f54dd59e8f59d67f7ab0682b5c22f554855
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c e0eaf3a78eca2ef650abb67b6571cc86abcb5f87 F src/tclsqlite.c a25933b085bde305a59b43e52f5624871db46a1e
F src/test1.c 870fc648a48cb6d6808393174f7ebe82b8c840fa F src/test1.c 870fc648a48cb6d6808393174f7ebe82b8c840fa
F src/test2.c 7355101c085304b90024f2261e056cdff13c6c35 F src/test2.c 7355101c085304b90024f2261e056cdff13c6c35
F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c
@@ -249,23 +249,23 @@ F src/test7.c 126b886b53f0358b92aba9b81d3fcbfbe9a93cd6
F src/test8.c 7ee77ea522ae34aa691dfe407139dec80d4fc039 F src/test8.c 7ee77ea522ae34aa691dfe407139dec80d4fc039
F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60
F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8
F src/test_autoext.c 32cff3d01cdd3202486e623c3f8103ed04cb57fa F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12
F src/test_backup.c 3875e899222b651e18b662f86e0e50daa946344e F src/test_backup.c 3875e899222b651e18b662f86e0e50daa946344e
F src/test_btree.c 5b89601dcb42a33ba8b820a6b763cc9cb48bac16 F src/test_btree.c 5b89601dcb42a33ba8b820a6b763cc9cb48bac16
F src/test_config.c 6b614c603cb4db1c996f1b192ca0a46ef0d152cd F src/test_config.c 6b614c603cb4db1c996f1b192ca0a46ef0d152cd
F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094 F src/test_demovfs.c 69b2085076654ebc18014cbc6386f04409c959a9
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_fs.c 8f786bfd0ad48030cf2a06fb1f050e9c60a150d7 F src/test_fs.c ced436e3d4b8e4681328409b8081051ce614e28f
F src/test_func.c 3a8dd37c08ab43b76d38eea2836e34a3897bf170 F src/test_func.c 3a8dd37c08ab43b76d38eea2836e34a3897bf170
F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd
F src/test_init.c 3cbad7ce525aec925f8fda2192d576d47f0d478a F src/test_init.c 3cbad7ce525aec925f8fda2192d576d47f0d478a
F src/test_intarray.c 87847c71c3c36889c0bcc9c4baf9d31881665d61 F src/test_intarray.c 87847c71c3c36889c0bcc9c4baf9d31881665d61
F src/test_intarray.h b999bb18d090b8d9d9c49d36ec37ef8f341fe169 F src/test_intarray.h 2ece66438cfd177b78d1bfda7a4180cd3a10844d
F src/test_journal.c f5c0a05b7b3d5930db769b5ee6c3766dc2221a64 F src/test_journal.c f5c0a05b7b3d5930db769b5ee6c3766dc2221a64
F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
F src/test_malloc.c a105801222c0514f8befa2a1712a95505cce099a F src/test_malloc.c a105801222c0514f8befa2a1712a95505cce099a
F src/test_multiplex.c 5d691eeb6cb6aa7888da28eba5e62a9a857d3c0f F src/test_multiplex.c 5d691eeb6cb6aa7888da28eba5e62a9a857d3c0f
F src/test_multiplex.h 9b63b95f07acedee425fdfe49a47197c9bf5f9d8 F src/test_multiplex.h 110a8c4d356e0aa464ca8730375608a9a0b61ae1
F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f
F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25 F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25
F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba
@@ -290,7 +290,7 @@ F src/update.c e3668141dd9701023681239265e001388f182236
F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f
F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9 F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9
F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8 F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8
F src/vdbe.c 1d95ab3d4aae198744c1c14170b2466b58eb8970 F src/vdbe.c fab5d86a09f735db4bfd53d977465fa82cd5c213
F src/vdbe.h 7aa3ab6210a68471c8490dedfc9aa4ef5684b9a0 F src/vdbe.h 7aa3ab6210a68471c8490dedfc9aa4ef5684b9a0
F src/vdbeInt.h cc1974b94efa98ecaec6fa14a2584d7c1e82eadf F src/vdbeInt.h cc1974b94efa98ecaec6fa14a2584d7c1e82eadf
F src/vdbeapi.c c8c433043d14b5e00e2ed6f7e44543bcc92d1594 F src/vdbeapi.c c8c433043d14b5e00e2ed6f7e44543bcc92d1594
@@ -303,7 +303,7 @@ F src/vtab.c 2e8b489db47e20ae36cd247932dc671c9ded0624
F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
F src/where.c 67245bb73fd9cc04ee7796a0f358d4910c45cfe9 F src/where.c 67a823e7816464bc1de998841e87a2a3e4c20a94
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
@@ -603,7 +603,7 @@ F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7 F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7
F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026 F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026
F test/index5.test fc07c14193c0430814e7a08b5da46888ee795c33 F test/index5.test fc07c14193c0430814e7a08b5da46888ee795c33
F test/index6.test 0005b3093012c6d0f20cc54d9057210221216143 F test/index6.test f53a788b813eb6937346867bae9e587c434dd9a1
F test/indexedby.test 0e959308707c808515c3a51363f7a9835027108c F test/indexedby.test 0e959308707c808515c3a51363f7a9835027108c
F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
@@ -729,7 +729,7 @@ F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54 F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54
F test/permutations.test 742b8005bb3c782797a20beccdbe213ef52531fb F test/permutations.test 742b8005bb3c782797a20beccdbe213ef52531fb
F test/pragma.test 5e7de6c32a5d764f09437d2025f07e4917b9e178 F test/pragma.test 5e7de6c32a5d764f09437d2025f07e4917b9e178
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/pragma2.test 76e4a54cd4677966e4e75f8a7fe86ccbc250de2a
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/progress.test 552dc1edc37333a8d3098b8c26a2b7f06f5799d7 F test/progress.test 552dc1edc37333a8d3098b8c26a2b7f06f5799d7
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
@@ -746,7 +746,7 @@ F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8
F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254
F test/releasetest.mk 2eced2f9ae701fd0a29e714a241760503ccba25a F test/releasetest.mk 2eced2f9ae701fd0a29e714a241760503ccba25a
F test/releasetest.tcl 06d289d8255794073a58d2850742f627924545ce F test/releasetest.tcl 06d289d8255794073a58d2850742f627924545ce
F test/resolver01.test d1b487fc567bdb70b5dd09ccaaa877ddc61a233e F test/resolver01.test 33abf37ff8335e6bf98f2b45a0af3e06996ccd9a
F test/rollback.test a1b4784b864331eae8b2a98c189efa2a8b11ff07 F test/rollback.test a1b4784b864331eae8b2a98c189efa2a8b11ff07
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
F test/rowid.test f777404492adb0e00868fd706a3721328fd3af48 F test/rowid.test f777404492adb0e00868fd706a3721328fd3af48
@@ -920,7 +920,7 @@ F test/tkt2686.test 6ee01c9b9e9c48f6d3a1fdd553b1cc4258f903d6
F test/tkt2767.test 569000d842678f9cf2db7e0d1b27cbc9011381b0 F test/tkt2767.test 569000d842678f9cf2db7e0d1b27cbc9011381b0
F test/tkt2817.test f31839e01f4243cff7399ef654d3af3558cb8d8d F test/tkt2817.test f31839e01f4243cff7399ef654d3af3558cb8d8d
F test/tkt2820.test 39940276b3436d125deb7d8ebeee053e4cf13213 F test/tkt2820.test 39940276b3436d125deb7d8ebeee053e4cf13213
F test/tkt2822.test c3589494fba643e039bcf0bfde7554ff6028406d F test/tkt2822.test f391776423a7c0d0949edfce375708bfb0f3141e
F test/tkt2832.test a9b0b74a02dca166a04d9e37739c414b10929caa F test/tkt2832.test a9b0b74a02dca166a04d9e37739c414b10929caa
F test/tkt2854.test e432965db29e27e16f539b2ba7f502eb2ccc49af F test/tkt2854.test e432965db29e27e16f539b2ba7f502eb2ccc49af
F test/tkt2920.test a8737380e4ae6424e00c0273dc12775704efbebf F test/tkt2920.test a8737380e4ae6424e00c0273dc12775704efbebf
@@ -1119,7 +1119,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P 7e1acb390770d1bd189fac7a3a7f96106f96e3a4 5dcc2d91bd343cd0fac79d3c8f079a5ce534cdf7 P 69d5bed017bda3e184857febcc8b6f6bed6ad228 a0d9ca4f07f1dc3a189864f8ed9cdb0b1d791b1a
R 16c019af84c40424fdcd3228006de852 R 144b203c75da112b948140b14b84bcaf
U drh U drh
Z 236e21ad4140ab8f1ddcd5409f261d54 Z e4751f746fc0244a4adaef8846371a84

View File

@@ -1 +1 @@
69d5bed017bda3e184857febcc8b6f6bed6ad228 67587a3348b84424b2ab1f2df1ea923a5168e2e4

View File

@@ -158,6 +158,7 @@ static void attachFunc(
sqlite3PagerLockingMode(pPager, db->dfltLockMode); sqlite3PagerLockingMode(pPager, db->dfltLockMode);
sqlite3BtreeSecureDelete(aNew->pBt, sqlite3BtreeSecureDelete(aNew->pBt,
sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) ); sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
sqlite3BtreeSetPagerFlags(aNew->pBt, 3 | (db->flags & PAGER_FLAGS_MASK));
} }
aNew->safety_level = 3; aNew->safety_level = 3;
aNew->zName = sqlite3DbStrDup(db, zName); aNew->zName = sqlite3DbStrDup(db, zName);

View File

@@ -2165,17 +2165,14 @@ int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 szMmap){
** probability of damage to near zero but with a write performance reduction. ** probability of damage to near zero but with a write performance reduction.
*/ */
#ifndef SQLITE_OMIT_PAGER_PRAGMAS #ifndef SQLITE_OMIT_PAGER_PRAGMAS
int sqlite3BtreeSetSafetyLevel( int sqlite3BtreeSetPagerFlags(
Btree *p, /* The btree to set the safety level on */ Btree *p, /* The btree to set the safety level on */
int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ unsigned pgFlags /* Various PAGER_* flags */
int fullSync, /* PRAGMA fullfsync. */
int ckptFullSync /* PRAGMA checkpoint_fullfync */
){ ){
BtShared *pBt = p->pBt; BtShared *pBt = p->pBt;
assert( sqlite3_mutex_held(p->db->mutex) ); assert( sqlite3_mutex_held(p->db->mutex) );
assert( level>=1 && level<=3 );
sqlite3BtreeEnter(p); sqlite3BtreeEnter(p);
sqlite3PagerSetSafetyLevel(pBt->pPager, level, fullSync, ckptFullSync); sqlite3PagerSetFlags(pBt->pPager, pgFlags);
sqlite3BtreeLeave(p); sqlite3BtreeLeave(p);
return SQLITE_OK; return SQLITE_OK;
} }

View File

@@ -64,7 +64,7 @@ int sqlite3BtreeOpen(
int sqlite3BtreeClose(Btree*); int sqlite3BtreeClose(Btree*);
int sqlite3BtreeSetCacheSize(Btree*,int); int sqlite3BtreeSetCacheSize(Btree*,int);
int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64); int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int); int sqlite3BtreeSetPagerFlags(Btree*,unsigned);
int sqlite3BtreeSyncDisabled(Btree*); int sqlite3BtreeSyncDisabled(Btree*);
int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
int sqlite3BtreeGetPageSize(Btree*); int sqlite3BtreeGetPageSize(Btree*);

View File

@@ -2866,7 +2866,7 @@ Index *sqlite3CreateIndex(
** the zStmt variable ** the zStmt variable
*/ */
if( pStart ){ if( pStart ){
int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n; int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
if( pName->z[n-1]==';' ) n--; if( pName->z[n-1]==';' ) n--;
/* A named index with an explicit CREATE INDEX statement */ /* A named index with an explicit CREATE INDEX statement */
zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s", zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",

View File

@@ -1734,15 +1734,17 @@ int sqlite3CodeSubselect(
dest.affSdst = (u8)affinity; dest.affSdst = (u8)affinity;
assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
pExpr->x.pSelect->iLimit = 0; pExpr->x.pSelect->iLimit = 0;
testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
sqlite3DbFree(pParse->db, pKeyInfo); sqlite3DbFree(pParse->db, pKeyInfo);
return 0; return 0;
} }
pEList = pExpr->x.pSelect->pEList; pEList = pExpr->x.pSelect->pEList;
if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){ assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, assert( pEList!=0 );
pEList->a[0].pExpr); assert( pEList->nExpr>0 );
} pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
pEList->a[0].pExpr);
}else if( ALWAYS(pExpr->x.pList!=0) ){ }else if( ALWAYS(pExpr->x.pList!=0) ){
/* Case 2: expr IN (exprlist) /* Case 2: expr IN (exprlist)
** **

View File

@@ -117,6 +117,9 @@ char *sqlite3_data_directory = 0;
int sqlite3_initialize(void){ int sqlite3_initialize(void){
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
int rc; /* Result code */ int rc; /* Result code */
#ifdef SQLITE_EXTRA_INIT
int bRunExtraInit = 0; /* Extra initialization needed */
#endif
#ifdef SQLITE_OMIT_WSD #ifdef SQLITE_OMIT_WSD
rc = sqlite3_wsd_init(4096, 24); rc = sqlite3_wsd_init(4096, 24);
@@ -214,6 +217,9 @@ int sqlite3_initialize(void){
sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage,
sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage); sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);
sqlite3GlobalConfig.isInit = 1; sqlite3GlobalConfig.isInit = 1;
#ifdef SQLITE_EXTRA_INIT
bRunExtraInit = 1;
#endif
} }
sqlite3GlobalConfig.inProgress = 0; sqlite3GlobalConfig.inProgress = 0;
} }
@@ -254,7 +260,7 @@ int sqlite3_initialize(void){
** compile-time option. ** compile-time option.
*/ */
#ifdef SQLITE_EXTRA_INIT #ifdef SQLITE_EXTRA_INIT
if( rc==SQLITE_OK && sqlite3GlobalConfig.isInit ){ if( bRunExtraInit ){
int SQLITE_EXTRA_INIT(const char*); int SQLITE_EXTRA_INIT(const char*);
rc = SQLITE_EXTRA_INIT(0); rc = SQLITE_EXTRA_INIT(0);
} }
@@ -442,8 +448,8 @@ int sqlite3_config(int op, ...){
memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m)); memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m));
}else{ }else{
/* The heap pointer is not NULL, then install one of the /* The heap pointer is not NULL, then install one of the
** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor ** mem5.c/mem3.c methods. The enclosing #if guarantees at
** ENABLE_MEMSYS5 is defined, return an error. ** least one of these methods is currently enabled.
*/ */
#ifdef SQLITE_ENABLE_MEMSYS3 #ifdef SQLITE_ENABLE_MEMSYS3
sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3(); sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3();
@@ -462,7 +468,7 @@ int sqlite3_config(int op, ...){
break; break;
} }
/* Record a pointer to the logger funcction and its first argument. /* Record a pointer to the logger function and its first argument.
** The default is NULL. Logging is disabled if the function pointer is ** The default is NULL. Logging is disabled if the function pointer is
** NULL. ** NULL.
*/ */
@@ -2199,20 +2205,20 @@ int sqlite3ParseUri(
zFile = sqlite3_malloc(nByte); zFile = sqlite3_malloc(nByte);
if( !zFile ) return SQLITE_NOMEM; if( !zFile ) return SQLITE_NOMEM;
iIn = 5;
#ifndef SQLITE_ALLOW_URI_AUTHORITY
/* Discard the scheme and authority segments of the URI. */ /* Discard the scheme and authority segments of the URI. */
if( zUri[5]=='/' && zUri[6]=='/' ){ if( zUri[5]=='/' && zUri[6]=='/' ){
iIn = 7; iIn = 7;
while( zUri[iIn] && zUri[iIn]!='/' ) iIn++; while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;
if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){ if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){
*pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", *pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s",
iIn-7, &zUri[7]); iIn-7, &zUri[7]);
rc = SQLITE_ERROR; rc = SQLITE_ERROR;
goto parse_uri_out; goto parse_uri_out;
} }
}else{
iIn = 5;
} }
#endif
/* Copy the filename and any query parameters into the zFile buffer. /* Copy the filename and any query parameters into the zFile buffer.
** Decode %HH escape codes along the way. ** Decode %HH escape codes along the way.
@@ -2476,7 +2482,7 @@ static int openDatabase(
db->nextAutovac = -1; db->nextAutovac = -1;
db->szMmap = sqlite3GlobalConfig.szMmap; db->szMmap = sqlite3GlobalConfig.szMmap;
db->nextPagesize = 0; db->nextPagesize = 0;
db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger | SQLITE_CacheSpill
#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX #if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
| SQLITE_AutoIndex | SQLITE_AutoIndex
#endif #endif

View File

@@ -130,13 +130,13 @@ static SQLITE_WSD struct Mem5Global {
} mem5; } mem5;
/* /*
** Access the static variable through a macro for SQLITE_OMIT_WSD ** Access the static variable through a macro for SQLITE_OMIT_WSD.
*/ */
#define mem5 GLOBAL(struct Mem5Global, mem5) #define mem5 GLOBAL(struct Mem5Global, mem5)
/* /*
** Assuming mem5.zPool is divided up into an array of Mem5Link ** Assuming mem5.zPool is divided up into an array of Mem5Link
** structures, return a pointer to the idx-th such lik. ** structures, return a pointer to the idx-th such link.
*/ */
#define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom])) #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom]))
@@ -232,7 +232,7 @@ static int memsys5UnlinkFirst(int iLogsize){
** Return a block of memory of at least nBytes in size. ** Return a block of memory of at least nBytes in size.
** Return NULL if unable. Return NULL if nBytes==0. ** Return NULL if unable. Return NULL if nBytes==0.
** **
** The caller guarantees that nByte positive. ** The caller guarantees that nByte is positive.
** **
** The caller has obtained a mutex prior to invoking this ** The caller has obtained a mutex prior to invoking this
** routine so there is never any chance that two or more ** routine so there is never any chance that two or more
@@ -354,7 +354,7 @@ static void memsys5FreeUnsafe(void *pOld){
} }
/* /*
** Allocate nBytes of memory ** Allocate nBytes of memory.
*/ */
static void *memsys5Malloc(int nBytes){ static void *memsys5Malloc(int nBytes){
sqlite3_int64 *p = 0; sqlite3_int64 *p = 0;

View File

@@ -453,6 +453,13 @@ struct PagerSavepoint {
#endif #endif
}; };
/*
** Bits of the Pager.doNotSpill flag. See further description below.
*/
#define SPILLFLAG_OFF 0x01 /* Never spill cache. Set via pragma */
#define SPILLFLAG_ROLLBACK 0x02 /* Current rolling back, so do not spill */
#define SPILLFLAG_NOSYNC 0x04 /* Spill is ok, but do not sync */
/* /*
** A open page cache is an instance of struct Pager. A description of ** A open page cache is an instance of struct Pager. A description of
** some of the more important member variables follows: ** some of the more important member variables follows:
@@ -519,19 +526,21 @@ struct PagerSavepoint {
** journal file from being successfully finalized, the setMaster flag ** journal file from being successfully finalized, the setMaster flag
** is cleared anyway (and the pager will move to ERROR state). ** is cleared anyway (and the pager will move to ERROR state).
** **
** doNotSpill, doNotSyncSpill ** doNotSpill
** **
** These two boolean variables control the behavior of cache-spills ** This variables control the behavior of cache-spills (calls made by
** (calls made by the pcache module to the pagerStress() routine to ** the pcache module to the pagerStress() routine to write cached data
** write cached data to the file-system in order to free up memory). ** to the file-system in order to free up memory).
** **
** When doNotSpill is non-zero, writing to the database from pagerStress() ** When bits SPILLFLAG_OFF or SPILLFLAG_ROLLBACK of doNotSpill are set,
** is disabled altogether. This is done in a very obscure case that ** writing to the database from pagerStress() is disabled altogether.
** The SPILLFLAG_ROLLBACK case is done in a very obscure case that
** comes up during savepoint rollback that requires the pcache module ** comes up during savepoint rollback that requires the pcache module
** to allocate a new page to prevent the journal file from being written ** to allocate a new page to prevent the journal file from being written
** while it is being traversed by code in pager_playback(). ** while it is being traversed by code in pager_playback(). The SPILLFLAG_OFF
** case is a user preference.
** **
** If doNotSyncSpill is non-zero, writing to the database from pagerStress() ** If the SPILLFLAG_NOSYNC bit is set, writing to the database from pagerStress()
** is permitted, but syncing the journal file is not. This flag is set ** is permitted, but syncing the journal file is not. This flag is set
** by sqlite3PagerWrite() when the file-system sector-size is larger than ** by sqlite3PagerWrite() when the file-system sector-size is larger than
** the database page-size in order to prevent a journal sync from happening ** the database page-size in order to prevent a journal sync from happening
@@ -635,7 +644,6 @@ struct Pager {
u8 changeCountDone; /* Set after incrementing the change-counter */ u8 changeCountDone; /* Set after incrementing the change-counter */
u8 setMaster; /* True if a m-j name has been written to jrnl */ u8 setMaster; /* True if a m-j name has been written to jrnl */
u8 doNotSpill; /* Do not spill the cache when non-zero */ u8 doNotSpill; /* Do not spill the cache when non-zero */
u8 doNotSyncSpill; /* Do not do a spill that requires jrnl sync */
u8 subjInMemory; /* True to use in-memory sub-journals */ u8 subjInMemory; /* True to use in-memory sub-journals */
Pgno dbSize; /* Number of pages in the database */ Pgno dbSize; /* Number of pages in the database */
Pgno dbOrigSize; /* dbSize before the current transaction */ Pgno dbOrigSize; /* dbSize before the current transaction */
@@ -2295,11 +2303,11 @@ static int pager_playback_one_page(
** requiring a journal-sync before it is written. ** requiring a journal-sync before it is written.
*/ */
assert( isSavepnt ); assert( isSavepnt );
assert( pPager->doNotSpill==0 ); assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)==0 );
pPager->doNotSpill++; pPager->doNotSpill |= SPILLFLAG_ROLLBACK;
rc = sqlite3PagerAcquire(pPager, pgno, &pPg, 1); rc = sqlite3PagerAcquire(pPager, pgno, &pPg, 1);
assert( pPager->doNotSpill==1 ); assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)!=0 );
pPager->doNotSpill--; pPager->doNotSpill &= ~SPILLFLAG_ROLLBACK;
if( rc!=SQLITE_OK ) return rc; if( rc!=SQLITE_OK ) return rc;
pPg->flags &= ~PGHDR_NEED_READ; pPg->flags &= ~PGHDR_NEED_READ;
sqlite3PcacheMakeDirty(pPg); sqlite3PcacheMakeDirty(pPg);
@@ -3404,9 +3412,12 @@ void sqlite3PagerShrink(Pager *pPager){
} }
/* /*
** Adjust the robustness of the database to damage due to OS crashes ** Adjust settings of the pager to those specified in the pgFlags parameter.
** or power failures by changing the number of syncs()s when writing **
** the rollback journal. There are three levels: ** The "level" in pgFlags & PAGER_SYNCHRONOUS_MASK sets the robustness
** of the database to damage due to OS crashes or power failures by
** changing the number of syncs()s when writing the journals.
** There are three levels:
** **
** OFF sqlite3OsSync() is never called. This is the default ** OFF sqlite3OsSync() is never called. This is the default
** for temporary and transient files. ** for temporary and transient files.
@@ -3447,22 +3458,21 @@ void sqlite3PagerShrink(Pager *pPager){
** and FULL=3. ** and FULL=3.
*/ */
#ifndef SQLITE_OMIT_PAGER_PRAGMAS #ifndef SQLITE_OMIT_PAGER_PRAGMAS
void sqlite3PagerSetSafetyLevel( void sqlite3PagerSetFlags(
Pager *pPager, /* The pager to set safety level for */ Pager *pPager, /* The pager to set safety level for */
int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ unsigned pgFlags /* Various flags */
int bFullFsync, /* PRAGMA fullfsync */
int bCkptFullFsync /* PRAGMA checkpoint_fullfsync */
){ ){
unsigned level = pgFlags & PAGER_SYNCHRONOUS_MASK;
assert( level>=1 && level<=3 ); assert( level>=1 && level<=3 );
pPager->noSync = (level==1 || pPager->tempFile) ?1:0; pPager->noSync = (level==1 || pPager->tempFile) ?1:0;
pPager->fullSync = (level==3 && !pPager->tempFile) ?1:0; pPager->fullSync = (level==3 && !pPager->tempFile) ?1:0;
if( pPager->noSync ){ if( pPager->noSync ){
pPager->syncFlags = 0; pPager->syncFlags = 0;
pPager->ckptSyncFlags = 0; pPager->ckptSyncFlags = 0;
}else if( bFullFsync ){ }else if( pgFlags & PAGER_FULLFSYNC ){
pPager->syncFlags = SQLITE_SYNC_FULL; pPager->syncFlags = SQLITE_SYNC_FULL;
pPager->ckptSyncFlags = SQLITE_SYNC_FULL; pPager->ckptSyncFlags = SQLITE_SYNC_FULL;
}else if( bCkptFullFsync ){ }else if( pgFlags & PAGER_CKPT_FULLFSYNC ){
pPager->syncFlags = SQLITE_SYNC_NORMAL; pPager->syncFlags = SQLITE_SYNC_NORMAL;
pPager->ckptSyncFlags = SQLITE_SYNC_FULL; pPager->ckptSyncFlags = SQLITE_SYNC_FULL;
}else{ }else{
@@ -3473,6 +3483,11 @@ void sqlite3PagerSetSafetyLevel(
if( pPager->fullSync ){ if( pPager->fullSync ){
pPager->walSyncFlags |= WAL_SYNC_TRANSACTIONS; pPager->walSyncFlags |= WAL_SYNC_TRANSACTIONS;
} }
if( pgFlags & PAGER_CACHESPILL ){
pPager->doNotSpill &= ~SPILLFLAG_OFF;
}else{
pPager->doNotSpill |= SPILLFLAG_OFF;
}
} }
#endif #endif
@@ -4373,13 +4388,14 @@ static int pagerStress(void *p, PgHdr *pPg){
assert( pPg->pPager==pPager ); assert( pPg->pPager==pPager );
assert( pPg->flags&PGHDR_DIRTY ); assert( pPg->flags&PGHDR_DIRTY );
/* The doNotSyncSpill flag is set during times when doing a sync of /* The doNotSpill NOSYNC bit is set during times when doing a sync of
** journal (and adding a new header) is not allowed. This occurs ** journal (and adding a new header) is not allowed. This occurs
** during calls to sqlite3PagerWrite() while trying to journal multiple ** during calls to sqlite3PagerWrite() while trying to journal multiple
** pages belonging to the same sector. ** pages belonging to the same sector.
** **
** The doNotSpill flag inhibits all cache spilling regardless of whether ** The doNotSpill ROLLBACK and OFF bits inhibits all cache spilling
** or not a sync is required. This is set during a rollback. ** regardless of whether or not a sync is required. This is set during
** a rollback or by user request, respectively.
** **
** Spilling is also prohibited when in an error state since that could ** Spilling is also prohibited when in an error state since that could
** lead to database corruption. In the current implementaton it ** lead to database corruption. In the current implementaton it
@@ -4389,8 +4405,13 @@ static int pagerStress(void *p, PgHdr *pPg){
** test for the error state as a safeguard against future changes. ** test for the error state as a safeguard against future changes.
*/ */
if( NEVER(pPager->errCode) ) return SQLITE_OK; if( NEVER(pPager->errCode) ) return SQLITE_OK;
if( pPager->doNotSpill ) return SQLITE_OK; testcase( pPager->doNotSpill & SPILLFLAG_ROLLBACK );
if( pPager->doNotSyncSpill && (pPg->flags & PGHDR_NEED_SYNC)!=0 ){ testcase( pPager->doNotSpill & SPILLFLAG_OFF );
testcase( pPager->doNotSpill & SPILLFLAG_NOSYNC );
if( pPager->doNotSpill
&& ((pPager->doNotSpill & (SPILLFLAG_ROLLBACK|SPILLFLAG_OFF))!=0
|| (pPg->flags & PGHDR_NEED_SYNC)!=0)
){
return SQLITE_OK; return SQLITE_OK;
} }
@@ -5744,13 +5765,13 @@ int sqlite3PagerWrite(DbPage *pDbPage){
int ii; /* Loop counter */ int ii; /* Loop counter */
int needSync = 0; /* True if any page has PGHDR_NEED_SYNC */ int needSync = 0; /* True if any page has PGHDR_NEED_SYNC */
/* Set the doNotSyncSpill flag to 1. This is because we cannot allow /* Set the doNotSpill NOSYNC bit to 1. This is because we cannot allow
** a journal header to be written between the pages journaled by ** a journal header to be written between the pages journaled by
** this function. ** this function.
*/ */
assert( !MEMDB ); assert( !MEMDB );
assert( pPager->doNotSyncSpill==0 ); assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)==0 );
pPager->doNotSyncSpill++; pPager->doNotSpill |= SPILLFLAG_NOSYNC;
/* This trick assumes that both the page-size and sector-size are /* This trick assumes that both the page-size and sector-size are
** an integer power of 2. It sets variable pg1 to the identifier ** an integer power of 2. It sets variable pg1 to the identifier
@@ -5809,8 +5830,8 @@ int sqlite3PagerWrite(DbPage *pDbPage){
} }
} }
assert( pPager->doNotSyncSpill==1 ); assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)!=0 );
pPager->doNotSyncSpill--; pPager->doNotSpill &= ~SPILLFLAG_NOSYNC;
}else{ }else{
rc = pager_write(pDbPage); rc = pager_write(pDbPage);
} }

View File

@@ -84,6 +84,18 @@ typedef struct PgHdr DbPage;
#define PAGER_ACQUIRE_NOCONTENT 0x01 /* Do not load data from disk */ #define PAGER_ACQUIRE_NOCONTENT 0x01 /* Do not load data from disk */
#define PAGER_ACQUIRE_READONLY 0x02 /* Read-only page is acceptable */ #define PAGER_ACQUIRE_READONLY 0x02 /* Read-only page is acceptable */
/*
** Flags for sqlite3PagerSetFlags()
*/
#define PAGER_SYNCHRONOUS_OFF 0x01 /* PRAGMA synchronous=OFF */
#define PAGER_SYNCHRONOUS_NORMAL 0x02 /* PRAGMA synchronous=NORMAL */
#define PAGER_SYNCHRONOUS_FULL 0x03 /* PRAGMA synchronous=FULL */
#define PAGER_SYNCHRONOUS_MASK 0x03 /* Mask for three values above */
#define PAGER_FULLFSYNC 0x04 /* PRAGMA fullfsync=ON */
#define PAGER_CKPT_FULLFSYNC 0x08 /* PRAGMA checkpoint_fullfsync=ON */
#define PAGER_CACHESPILL 0x10 /* PRAGMA cache_spill=ON */
#define PAGER_FLAGS_MASK 0x1c /* All above except SYNCHRONOUS */
/* /*
** The remainder of this file contains the declarations of the functions ** The remainder of this file contains the declarations of the functions
** that make up the Pager sub-system API. See source code comments for ** that make up the Pager sub-system API. See source code comments for
@@ -110,7 +122,7 @@ int sqlite3PagerMaxPageCount(Pager*, int);
void sqlite3PagerSetCachesize(Pager*, int); void sqlite3PagerSetCachesize(Pager*, int);
void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64); void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);
void sqlite3PagerShrink(Pager*); void sqlite3PagerShrink(Pager*);
void sqlite3PagerSetSafetyLevel(Pager*,int,int,int); void sqlite3PagerSetFlags(Pager*,unsigned);
int sqlite3PagerLockingMode(Pager *, int); int sqlite3PagerLockingMode(Pager *, int);
int sqlite3PagerSetJournalMode(Pager *, int); int sqlite3PagerSetJournalMode(Pager *, int);
int sqlite3PagerGetJournalMode(Pager*); int sqlite3PagerGetJournalMode(Pager*);

View File

@@ -158,6 +158,34 @@ static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1); sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
} }
/*
** Set the safety_level and pager flags for pager iDb. Or if iDb<0
** set these values for all pagers.
*/
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
static void setAllPagerFlags(sqlite3 *db){
if( db->autoCommit ){
Db *pDb = db->aDb;
int n = db->nDb;
assert( SQLITE_FullFSync==PAGER_FULLFSYNC );
assert( SQLITE_CkptFullFSync==PAGER_CKPT_FULLFSYNC );
assert( SQLITE_CacheSpill==PAGER_CACHESPILL );
assert( (PAGER_FULLFSYNC | PAGER_CKPT_FULLFSYNC | PAGER_CACHESPILL)
== PAGER_FLAGS_MASK );
assert( (pDb->safety_level & PAGER_SYNCHRONOUS_MASK)==pDb->safety_level );
while( (n--) > 0 ){
if( pDb->pBt ){
sqlite3BtreeSetPagerFlags(pDb->pBt,
pDb->safety_level | (db->flags & PAGER_FLAGS_MASK) );
}
pDb++;
}
}
}
#endif
#ifndef SQLITE_OMIT_FLAG_PRAGMAS #ifndef SQLITE_OMIT_FLAG_PRAGMAS
/* /*
** Check to see if zRight and zLeft refer to a pragma that queries ** Check to see if zRight and zLeft refer to a pragma that queries
@@ -176,6 +204,7 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
{ "legacy_file_format", SQLITE_LegacyFileFmt }, { "legacy_file_format", SQLITE_LegacyFileFmt },
{ "fullfsync", SQLITE_FullFSync }, { "fullfsync", SQLITE_FullFSync },
{ "checkpoint_fullfsync", SQLITE_CkptFullFSync }, { "checkpoint_fullfsync", SQLITE_CkptFullFSync },
{ "cache_spill", SQLITE_CacheSpill },
{ "reverse_unordered_selects", SQLITE_ReverseOrder }, { "reverse_unordered_selects", SQLITE_ReverseOrder },
{ "query_only", SQLITE_QueryOnly }, { "query_only", SQLITE_QueryOnly },
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
@@ -966,6 +995,7 @@ void sqlite3Pragma(
"Safety level may not be changed inside a transaction"); "Safety level may not be changed inside a transaction");
}else{ }else{
pDb->safety_level = getSafetyLevel(zRight,0,1)+1; pDb->safety_level = getSafetyLevel(zRight,0,1)+1;
setAllPagerFlags(db);
} }
} }
}else }else
@@ -973,8 +1003,7 @@ void sqlite3Pragma(
#ifndef SQLITE_OMIT_FLAG_PRAGMAS #ifndef SQLITE_OMIT_FLAG_PRAGMAS
if( flagPragma(pParse, zLeft, zRight) ){ if( flagPragma(pParse, zLeft, zRight) ){
/* The flagPragma() subroutine also generates any necessary code setAllPagerFlags(db);
** there is nothing more to do here */
}else }else
#endif /* SQLITE_OMIT_FLAG_PRAGMAS */ #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
@@ -1805,17 +1834,6 @@ void sqlite3Pragma(
{/* Empty ELSE clause */} {/* Empty ELSE clause */}
/*
** Reset the safety level, in case the fullfsync flag or synchronous
** setting changed.
*/
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
if( db->autoCommit ){
sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,
(db->flags&SQLITE_FullFSync)!=0,
(db->flags&SQLITE_CkptFullFSync)!=0);
}
#endif
pragma_out: pragma_out:
sqlite3DbFree(db, zLeft); sqlite3DbFree(db, zLeft);
sqlite3DbFree(db, zRight); sqlite3DbFree(db, zRight);

View File

@@ -55,7 +55,7 @@ static void incrAggFunctionDepth(Expr *pExpr, int N){
** column reference is so that the column reference will be recognized as ** column reference is so that the column reference will be recognized as
** usable by indices within the WHERE clause processing logic. ** usable by indices within the WHERE clause processing logic.
** **
** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means ** The TK_AS operator is inhibited if zType[0]=='G'. This means
** that in a GROUP BY clause, the expression is evaluated twice. Hence: ** that in a GROUP BY clause, the expression is evaluated twice. Hence:
** **
** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x
@@ -65,8 +65,9 @@ static void incrAggFunctionDepth(Expr *pExpr, int N){
** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5
** **
** The result of random()%5 in the GROUP BY clause is probably different ** The result of random()%5 in the GROUP BY clause is probably different
** from the result in the result-set. We might fix this someday. Or ** from the result in the result-set. On the other hand Standard SQL does
** then again, we might not... ** not allow the GROUP BY clause to contain references to result-set columns.
** So this should never come up in well-formed queries.
** **
** If the reference is followed by a COLLATE operator, then make sure ** If the reference is followed by a COLLATE operator, then make sure
** the COLLATE operator is preserved. For example: ** the COLLATE operator is preserved. For example:
@@ -396,10 +397,16 @@ static int lookupName(
** forms the result set entry ("a+b" in the example) and return immediately. ** forms the result set entry ("a+b" in the example) and return immediately.
** Note that the expression in the result set should have already been ** Note that the expression in the result set should have already been
** resolved by the time the WHERE clause is resolved. ** resolved by the time the WHERE clause is resolved.
**
** The ability to use an output result-set column in the WHERE, GROUP BY,
** or HAVING clauses, or as part of a larger expression in the ORDRE BY
** clause is not standard SQL. This is a (goofy) SQLite extension, that
** is supported for backwards compatibility only. TO DO: Issue a warning
** on sqlite3_log() whenever the capability is used.
*/ */
if( (pEList = pNC->pEList)!=0 if( (pEList = pNC->pEList)!=0
&& zTab==0 && zTab==0
&& ((pNC->ncFlags & NC_AsMaybe)==0 || cnt==0) && cnt==0
){ ){
for(j=0; j<pEList->nExpr; j++){ for(j=0; j<pEList->nExpr; j++){
char *zAs = pEList->a[j].zName; char *zAs = pEList->a[j].zName;
@@ -961,7 +968,7 @@ static int resolveCompoundOrderBy(
/* /*
** Check every term in the ORDER BY or GROUP BY clause pOrderBy of ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of
** the SELECT statement pSelect. If any term is reference to a ** the SELECT statement pSelect. If any term is reference to a
** result set expression (as determined by the ExprList.a.iCol field) ** result set expression (as determined by the ExprList.a.iOrderByCol field)
** then convert that term into a copy of the corresponding result set ** then convert that term into a copy of the corresponding result set
** column. ** column.
** **
@@ -1009,7 +1016,7 @@ int sqlite3ResolveOrderGroupBy(
** If the order-by term is an integer I between 1 and N (where N is the ** If the order-by term is an integer I between 1 and N (where N is the
** number of columns in the result set of the SELECT) then the expression ** number of columns in the result set of the SELECT) then the expression
** in the resolution is a copy of the I-th result-set expression. If ** in the resolution is a copy of the I-th result-set expression. If
** the order-by term is an identify that corresponds to the AS-name of ** the order-by term is an identifier that corresponds to the AS-name of
** a result-set expression, then the term resolves to a copy of the ** a result-set expression, then the term resolves to a copy of the
** result-set expression. Otherwise, the expression is resolved in ** result-set expression. Otherwise, the expression is resolved in
** the usual way - using sqlite3ResolveExprNames(). ** the usual way - using sqlite3ResolveExprNames().
@@ -1035,16 +1042,19 @@ static int resolveOrderGroupBy(
pParse = pNC->pParse; pParse = pNC->pParse;
for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
Expr *pE = pItem->pExpr; Expr *pE = pItem->pExpr;
iCol = resolveAsName(pParse, pSelect->pEList, pE); Expr *pE2 = sqlite3ExprSkipCollate(pE);
if( iCol>0 ){ if( zType[0]!='G' ){
/* If an AS-name match is found, mark this ORDER BY column as being iCol = resolveAsName(pParse, pSelect->pEList, pE2);
** a copy of the iCol-th result-set column. The subsequent call to if( iCol>0 ){
** sqlite3ResolveOrderGroupBy() will convert the expression to a /* If an AS-name match is found, mark this ORDER BY column as being
** copy of the iCol-th result-set expression. */ ** a copy of the iCol-th result-set column. The subsequent call to
pItem->iOrderByCol = (u16)iCol; ** sqlite3ResolveOrderGroupBy() will convert the expression to a
continue; ** copy of the iCol-th result-set expression. */
pItem->iOrderByCol = (u16)iCol;
continue;
}
} }
if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){ if( sqlite3ExprIsInteger(pE2, &iCol) ){
/* The ORDER BY term is an integer constant. Again, set the column /* The ORDER BY term is an integer constant. Again, set the column
** number so that sqlite3ResolveOrderGroupBy() will convert the ** number so that sqlite3ResolveOrderGroupBy() will convert the
** order-by term to a copy of the result-set expression */ ** order-by term to a copy of the result-set expression */
@@ -1187,7 +1197,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
return WRC_Abort; return WRC_Abort;
} }
/* Add the expression list to the name-context before parsing the /* Add the output column list to the name-context before parsing the
** other expressions in the SELECT statement. This is so that ** other expressions in the SELECT statement. This is so that
** expressions in the WHERE clause (etc.) can refer to expressions by ** expressions in the WHERE clause (etc.) can refer to expressions by
** aliases in the result set. ** aliases in the result set.
@@ -1196,10 +1206,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
** re-evaluated for each reference to it. ** re-evaluated for each reference to it.
*/ */
sNC.pEList = p->pEList; sNC.pEList = p->pEList;
sNC.ncFlags |= NC_AsMaybe;
if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
sNC.ncFlags &= ~NC_AsMaybe;
/* The ORDER BY and GROUP BY clauses may not refer to terms in /* The ORDER BY and GROUP BY clauses may not refer to terms in
** outer queries ** outer queries

View File

@@ -2902,6 +2902,7 @@ static int process_input(struct callback_data *p, FILE *in){
if( nSql==0 ){ if( nSql==0 ){
int i; int i;
for(i=0; zLine[i] && IsSpace(zLine[i]); i++){} for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
assert( nAlloc>0 && zSql!=0 );
memcpy(zSql, zLine+i, nLine+1-i); memcpy(zSql, zLine+i, nLine+1-i);
startline = lineno; startline = lineno;
nSql = nLine-i; nSql = nLine-i;

View File

@@ -7323,4 +7323,4 @@ SQLITE_EXPERIMENTAL int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
#ifdef __cplusplus #ifdef __cplusplus
} /* End of the 'extern "C"' block */ } /* End of the 'extern "C"' block */
#endif #endif
#endif #endif /* _SQLITE3_H_ */

View File

@@ -980,32 +980,33 @@ struct sqlite3 {
*/ */
#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */ #define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
#define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */ #define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */
#define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */ #define SQLITE_FullFSync 0x00000004 /* Use full fsync on the backend */
#define SQLITE_ShortColNames 0x00000008 /* Show short columns names */ #define SQLITE_CkptFullFSync 0x00000008 /* Use full fsync for checkpoint */
#define SQLITE_CountRows 0x00000010 /* Count rows changed by INSERT, */ #define SQLITE_CacheSpill 0x00000010 /* OK to spill pager cache */
#define SQLITE_FullColNames 0x00000020 /* Show full column names on SELECT */
#define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
/* DELETE, or UPDATE and return */ /* DELETE, or UPDATE and return */
/* the count using a callback. */ /* the count using a callback. */
#define SQLITE_NullCallback 0x00000020 /* Invoke the callback once if the */ #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
/* result set is empty */ /* result set is empty */
#define SQLITE_SqlTrace 0x00000040 /* Debug print SQL as it executes */ #define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
#define SQLITE_VdbeListing 0x00000080 /* Debug listings of VDBE programs */ #define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
#define SQLITE_WriteSchema 0x00000100 /* OK to update SQLITE_MASTER */ #define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
#define SQLITE_VdbeAddopTrace 0x00000200 /* Trace sqlite3VdbeAddOp() calls */ #define SQLITE_VdbeAddopTrace 0x00001000 /* Trace sqlite3VdbeAddOp() calls */
#define SQLITE_IgnoreChecks 0x00000400 /* Do not enforce check constraints */ #define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
#define SQLITE_ReadUncommitted 0x0000800 /* For shared-cache mode */ #define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */
#define SQLITE_LegacyFileFmt 0x00001000 /* Create new databases in format 1 */ #define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
#define SQLITE_FullFSync 0x00002000 /* Use full fsync on the backend */ #define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */
#define SQLITE_CkptFullFSync 0x00004000 /* Use full fsync for checkpoint */ #define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */
#define SQLITE_RecoveryMode 0x00008000 /* Ignore schema errors */ #define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */
#define SQLITE_ReverseOrder 0x00010000 /* Reverse unordered SELECTs */ #define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */
#define SQLITE_RecTriggers 0x00020000 /* Enable recursive triggers */ #define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */
#define SQLITE_ForeignKeys 0x00040000 /* Enforce foreign key constraints */ #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
#define SQLITE_AutoIndex 0x00080000 /* Enable automatic indexes */ #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
#define SQLITE_PreferBuiltin 0x00100000 /* Preference to built-in funcs */ #define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
#define SQLITE_LoadExtension 0x00200000 /* Enable load_extension */ #define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
#define SQLITE_EnableTrigger 0x00400000 /* True to enable triggers */ #define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
#define SQLITE_DeferFKs 0x00800000 /* Defer all FK constraints */
#define SQLITE_QueryOnly 0x01000000 /* Disable database changes */
/* /*
@@ -2014,7 +2015,7 @@ struct SrcList {
struct NameContext { struct NameContext {
Parse *pParse; /* The parser */ Parse *pParse; /* The parser */
SrcList *pSrcList; /* One or more tables used to resolve names */ SrcList *pSrcList; /* One or more tables used to resolve names */
ExprList *pEList; /* Optional list of named expressions */ ExprList *pEList; /* Optional list of result-set columns */
AggInfo *pAggInfo; /* Information about aggregates at this level */ AggInfo *pAggInfo; /* Information about aggregates at this level */
NameContext *pNext; /* Next outer name context. NULL for outermost */ NameContext *pNext; /* Next outer name context. NULL for outermost */
int nRef; /* Number of names resolved by this context */ int nRef; /* Number of names resolved by this context */
@@ -2029,9 +2030,7 @@ struct NameContext {
#define NC_HasAgg 0x02 /* One or more aggregate functions seen */ #define NC_HasAgg 0x02 /* One or more aggregate functions seen */
#define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */ #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
#define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */ #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
#define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only #define NC_PartIdx 0x10 /* True if resolving a partial index WHERE */
** if no other resolution is available */
#define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */
/* /*
** An instance of the following structure contains all information ** An instance of the following structure contains all information

View File

@@ -41,6 +41,18 @@
#endif #endif
#include <ctype.h> #include <ctype.h>
/* Used to get the current process ID */
#if !defined(_WIN32)
# include <unistd.h>
# define GETPID getpid
#elif !defined(_WIN32_WCE)
# ifndef SQLITE_AMALGAMATION
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# endif
# define GETPID (int)GetCurrentProcessId
#endif
/* /*
* Windows needs to know which symbols to export. Unix does not. * Windows needs to know which symbols to export. Unix does not.
* BUILD_sqlite should be undefined for Unix. * BUILD_sqlite should be undefined for Unix.
@@ -3899,6 +3911,15 @@ static void init_all(Tcl_Interp *interp){
int TCLSH_MAIN(int argc, char **argv){ int TCLSH_MAIN(int argc, char **argv){
Tcl_Interp *interp; Tcl_Interp *interp;
#if !defined(_WIN32_WCE)
if( getenv("BREAK") ){
fprintf(stderr,
"attach debugger to process %d and press any key to continue.\n",
GETPID());
fgetc(stdin);
}
#endif
/* Call sqlite3_shutdown() once before doing anything else. This is to /* Call sqlite3_shutdown() once before doing anything else. This is to
** test that sqlite3_shutdown() can be safely called by a process before ** test that sqlite3_shutdown() can be safely called by a process before
** sqlite3_initialize() is. */ ** sqlite3_initialize() is. */

View File

@@ -208,13 +208,13 @@ int Sqlitetest_autoext_Init(Tcl_Interp *interp){
autoExtCubeObjCmd, 0, 0); autoExtCubeObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_broken", Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_broken",
autoExtBrokenObjCmd, 0, 0); autoExtBrokenObjCmd, 0, 0);
#endif
Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_sqr", Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_sqr",
cancelAutoExtSqrObjCmd, 0, 0); cancelAutoExtSqrObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_cube", Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_cube",
cancelAutoExtCubeObjCmd, 0, 0); cancelAutoExtCubeObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_broken", Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_broken",
cancelAutoExtBrokenObjCmd, 0, 0); cancelAutoExtBrokenObjCmd, 0, 0);
#endif
Tcl_CreateObjCommand(interp, "sqlite3_reset_auto_extension", Tcl_CreateObjCommand(interp, "sqlite3_reset_auto_extension",
resetAutoExtObjCmd, 0, 0); resetAutoExtObjCmd, 0, 0);
return TCL_OK; return TCL_OK;

View File

@@ -536,7 +536,7 @@ static int demoFullPathname(
if( zPath[0]=='/' ){ if( zPath[0]=='/' ){
zDir[0] = '\0'; zDir[0] = '\0';
}else{ }else{
getcwd(zDir, sizeof(zDir)); if( getcwd(zDir, sizeof(zDir))==0 ) return SQLITE_IOERR;
} }
zDir[MAXPATHNAME] = '\0'; zDir[MAXPATHNAME] = '\0';

View File

@@ -195,6 +195,7 @@ static int fsColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
const char *zFile = (const char *)sqlite3_column_text(pCur->pStmt, 1); const char *zFile = (const char *)sqlite3_column_text(pCur->pStmt, 1);
struct stat sbuf; struct stat sbuf;
int fd; int fd;
int n;
fd = open(zFile, O_RDONLY); fd = open(zFile, O_RDONLY);
if( fd<0 ) return SQLITE_IOERR; if( fd<0 ) return SQLITE_IOERR;
@@ -214,8 +215,9 @@ static int fsColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
pCur->nAlloc = nNew; pCur->nAlloc = nNew;
} }
read(fd, pCur->zBuf, sbuf.st_size); n = (int)read(fd, pCur->zBuf, sbuf.st_size);
close(fd); close(fd);
if( n!=sbuf.st_size ) return SQLITE_ERROR;
pCur->nBuf = sbuf.st_size; pCur->nBuf = sbuf.st_size;
pCur->zBuf[pCur->nBuf] = '\0'; pCur->zBuf[pCur->nBuf] = '\0';

View File

@@ -75,6 +75,8 @@
** action to free the intarray objects. ** action to free the intarray objects.
*/ */
#include "sqlite3.h" #include "sqlite3.h"
#ifndef _INTARRAY_H_
#define _INTARRAY_H_
/* /*
** Make sure we can call this stuff from C++. ** Make sure we can call this stuff from C++.
@@ -123,3 +125,4 @@ int sqlite3_intarray_bind(
#ifdef __cplusplus #ifdef __cplusplus
} /* End of the 'extern "C"' block */ } /* End of the 'extern "C"' block */
#endif #endif
#endif /* _INTARRAY_H_ */

View File

@@ -96,4 +96,4 @@ extern int sqlite3_multiplex_shutdown(void);
} /* End of the 'extern "C"' block */ } /* End of the 'extern "C"' block */
#endif #endif
#endif #endif /* _TEST_MULTIPLEX_H */

View File

@@ -6294,6 +6294,7 @@ vdbe_error_halt:
** top. */ ** top. */
vdbe_return: vdbe_return:
db->lastRowid = lastRowid; db->lastRowid = lastRowid;
testcase( nVmStep>0 );
p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1] += (int)nVmStep; p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1] += (int)nVmStep;
sqlite3VdbeLeave(p); sqlite3VdbeLeave(p);
return rc; return rc;

View File

@@ -33,7 +33,7 @@
# define WHERETRACE(K,X) # define WHERETRACE(K,X)
#endif #endif
/* Forward reference /* Forward references
*/ */
typedef struct WhereClause WhereClause; typedef struct WhereClause WhereClause;
typedef struct WhereMaskSet WhereMaskSet; typedef struct WhereMaskSet WhereMaskSet;
@@ -55,14 +55,15 @@ typedef struct WhereOrSet WhereOrSet;
** So all costs can be stored in a 16-bit unsigned integer without risk ** So all costs can be stored in a 16-bit unsigned integer without risk
** of overflow. ** of overflow.
** **
** Costs are estimates, so don't go to the computational trouble to compute ** Costs are estimates, so no effort is made to compute 10*log2(X) exactly.
** 10*log2(X) exactly. Instead, a close estimate is used. Any value of ** Instead, a close estimate is used. Any value of X<=1 is stored as 0.
** X<=1 is stored as 0. X=2 is 10. X=3 is 16. X=1000 is 99. etc. ** X=2 is 10. X=3 is 16. X=1000 is 99. etc.
** **
** The tool/wherecosttest.c source file implements a command-line program ** The tool/wherecosttest.c source file implements a command-line program
** that will convert between WhereCost to integers and do addition and ** that will convert WhereCosts to integers, convert integers to WhereCosts
** multiplication on WhereCost values. That command-line program is a ** and do addition and multiplication on WhereCost values. The wherecosttest
** useful utility to have around when working with this module. ** command-line program is a useful utility to have around when working with
** this module.
*/ */
typedef unsigned short int WhereCost; typedef unsigned short int WhereCost;
@@ -165,8 +166,8 @@ struct WhereOrCost {
}; };
/* The WhereOrSet object holds a set of possible WhereOrCosts that /* The WhereOrSet object holds a set of possible WhereOrCosts that
** correspond to the subquery(s) of OR-clause processing. At most ** correspond to the subquery(s) of OR-clause processing. Only the
** favorable N_OR_COST elements are retained. ** best N_OR_COST elements are retained.
*/ */
#define N_OR_COST 3 #define N_OR_COST 3
struct WhereOrSet { struct WhereOrSet {
@@ -232,9 +233,9 @@ struct WherePath {
** **
** (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR .... ** (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR ....
** **
** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR ** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR
** and the WhereTerm.u.pOrInfo field points to auxiliary information that ** and the WhereTerm.u.pOrInfo field points to auxiliary information that
** is collected about the ** is collected about the OR clause.
** **
** If a term in the WHERE clause does not match either of the two previous ** If a term in the WHERE clause does not match either of the two previous
** categories, then eOperator==0. The WhereTerm.pExpr field is still set ** categories, then eOperator==0. The WhereTerm.pExpr field is still set
@@ -746,7 +747,7 @@ static void createMask(WhereMaskSet *pMaskSet, int iCursor){
} }
/* /*
** These routine walk (recursively) an expression tree and generates ** These routines walk (recursively) an expression tree and generate
** a bitmask indicating which tables are used in that expression ** a bitmask indicating which tables are used in that expression
** tree. ** tree.
*/ */
@@ -1263,10 +1264,10 @@ static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
** From another point of view, "indexable" means that the subterm could ** From another point of view, "indexable" means that the subterm could
** potentially be used with an index if an appropriate index exists. ** potentially be used with an index if an appropriate index exists.
** This analysis does not consider whether or not the index exists; that ** This analysis does not consider whether or not the index exists; that
** is something the bestIndex() routine will determine. This analysis ** is decided elsewhere. This analysis only looks at whether subterms
** only looks at whether subterms appropriate for indexing exist. ** appropriate for indexing exist.
** **
** All examples A through E above all satisfy case 2. But if a term ** All examples A through E above satisfy case 2. But if a term
** also statisfies case 1 (such as B) we know that the optimizer will ** also statisfies case 1 (such as B) we know that the optimizer will
** always prefer case 1, so in that case we pretend that case 2 is not ** always prefer case 1, so in that case we pretend that case 2 is not
** satisfied. ** satisfied.
@@ -1933,7 +1934,7 @@ static int isDistinctRedundant(
} }
/* /*
** The (an approximate) sum of two WhereCosts. This computation is ** Find (an approximate) sum of two WhereCosts. This computation is
** not a simple "+" operator because WhereCost is stored as a logarithmic ** not a simple "+" operator because WhereCost is stored as a logarithmic
** value. ** value.
** **
@@ -4854,6 +4855,7 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK; if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK;
pWCEnd = pWC->a + pWC->nTerm; pWCEnd = pWC->a + pWC->nTerm;
pNew = pBuilder->pNew; pNew = pBuilder->pNew;
memset(&sSum, 0, sizeof(sSum));
for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){ for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){
if( (pTerm->eOperator & WO_OR)!=0 if( (pTerm->eOperator & WO_OR)!=0

View File

@@ -144,12 +144,21 @@ do_test index6-2.2 {
SELECT * FROM t2 WHERE a=5; SELECT * FROM t2 WHERE a=5;
} }
} {/.* TABLE t2 USING INDEX t2a1 .*/} } {/.* TABLE t2 USING INDEX t2a1 .*/}
do_test index6-2.3 { ifcapable stat3 {
execsql { do_test index6-2.3stat3 {
EXPLAIN QUERY PLAN execsql {
SELECT * FROM t2 WHERE a IS NOT NULL; EXPLAIN QUERY PLAN
} SELECT * FROM t2 WHERE a IS NOT NULL;
} {/.* TABLE t2 USING INDEX t2a1 .*/} }
} {/.* TABLE t2 USING INDEX t2a1 .*/}
} else {
do_test index6-2.3stat3 {
execsql {
EXPLAIN QUERY PLAN
SELECT * FROM t2 WHERE a IS NOT NULL AND a>0;
}
} {/.* TABLE t2 USING INDEX t2a1 .*/}
}
do_test index6-2.4 { do_test index6-2.4 {
execsql { execsql {
EXPLAIN QUERY PLAN EXPLAIN QUERY PLAN

View File

@@ -22,6 +22,7 @@ source $testdir/tester.tcl
# pragma2-1.*: Test freelist_count pragma on the main database. # pragma2-1.*: Test freelist_count pragma on the main database.
# pragma2-2.*: Test freelist_count pragma on an attached database. # pragma2-2.*: Test freelist_count pragma on an attached database.
# pragma2-3.*: Test trying to write to the freelist_count is a no-op. # pragma2-3.*: Test trying to write to the freelist_count is a no-op.
# pragma2-4.*: Tests for PRAGMA cache_spill
# #
ifcapable !pragma||!schema_pragmas { ifcapable !pragma||!schema_pragmas {
@@ -116,4 +117,78 @@ ifcapable attach {
} {9 9} } {9 9}
} }
# Default setting of PRAGMA cache_spill is always ON
#
db close
delete_file test.db test.db-journal
delete_file test2.db test2.db-journal
sqlite3 db test.db
do_execsql_test pragma2-4.1 {
PRAGMA cache_spill;
PRAGMA main.cache_spill;
PRAGMA temp.cache_spill;
} {1 1 1}
do_execsql_test pragma2-4.2 {
PRAGMA cache_spill=OFF;
PRAGMA cache_spill;
PRAGMA main.cache_spill;
PRAGMA temp.cache_spill;
} {0 0 0}
do_execsql_test pragma2-4.3 {
PRAGMA page_size=1024;
PRAGMA cache_size=50;
BEGIN;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);
INSERT INTO t1 VALUES(1, randomblob(400), 1, randomblob(400));
INSERT INTO t1 SELECT a+1, randomblob(400), a+1, randomblob(400) FROM t1;
INSERT INTO t1 SELECT a+2, randomblob(400), a+2, randomblob(400) FROM t1;
INSERT INTO t1 SELECT a+4, randomblob(400), a+4, randomblob(400) FROM t1;
INSERT INTO t1 SELECT a+8, randomblob(400), a+8, randomblob(400) FROM t1;
INSERT INTO t1 SELECT a+16, randomblob(400), a+16, randomblob(400) FROM t1;
INSERT INTO t1 SELECT a+32, randomblob(400), a+32, randomblob(400) FROM t1;
INSERT INTO t1 SELECT a+64, randomblob(400), a+64, randomblob(400) FROM t1;
COMMIT;
ATTACH 'test2.db' AS aux1;
CREATE TABLE aux1.t2(a INTEGER PRIMARY KEY, b, c, d);
INSERT INTO t2 SELECT * FROM t1;
DETACH aux1;
PRAGMA cache_spill=ON;
} {}
do_test pragma2-4.4 {
db eval {
BEGIN;
UPDATE t1 SET c=c+1;
PRAGMA lock_status;
}
} {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill
do_test pragma2-4.5 {
db eval {
COMMIT;
PRAGMA cache_spill=OFF;
BEGIN;
UPDATE t1 SET c=c-1;
PRAGMA lock_status;
}
} {main reserved temp unknown} ;# No cache spill, so no exclusive lock
# Verify that newly attached databases inherit the cache_spill=OFF
# setting.
#
do_execsql_test pragma2-4.6 {
COMMIT;
ATTACH 'test2.db' AS aux1;
PRAGMA aux1.cache_size=50;
BEGIN;
UPDATE t2 SET c=c+1;
PRAGMA lock_status;
} {main unlocked temp unknown aux1 reserved}
do_execsql_test pragma2-4.7 {
COMMIT;
PRAGMA cache_spill=ON; -- Applies to all databases
BEGIN;
UPDATE t2 SET c=c-1;
PRAGMA lock_status;
} {main unlocked temp unknown aux1 exclusive}
finish_test finish_test

View File

@@ -13,10 +13,18 @@
# figures out what identifiers in the SQL statement refer to) that # figures out what identifiers in the SQL statement refer to) that
# were fixed by ticket [2500cdb9be] # were fixed by ticket [2500cdb9be]
# #
# See also tickets [1c69be2daf] and [f617ea3125] from 2013-08-14.
#
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# "ORDER BY y" binds to the output result-set column named "y"
# if available. If no output column is named "y", then try to
# bind against an input column named "y".
#
# This is classical SQL92 behavior.
#
do_test resolver01-1.1 { do_test resolver01-1.1 {
catchsql { catchsql {
CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(11,22); CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(11,22);
@@ -25,15 +33,176 @@ do_test resolver01-1.1 {
} }
} {0 1} } {0 1}
do_test resolver01-1.2 { do_test resolver01-1.2 {
catchsql {
SELECT 1 AS yy FROM t1, t2 ORDER BY y;
}
} {1 {ambiguous column name: y}}
do_test resolver01-1.3 {
catchsql {
CREATE TABLE t3(x,y); INSERT INTO t3 VALUES(11,44),(33,22);
SELECT x AS y FROM t3 ORDER BY y;
}
} {0 {11 33}}
do_test resolver01-1.4 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY y;
}
} {0 {33 11}}
# SQLite allows the WHERE clause to reference output columns if there is
# no other way to resolve the name.
#
do_test resolver01-1.5 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY yy;
}
} {0 {11 33}}
do_test resolver01-1.6 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY 1;
}
} {0 {11 33}}
# The "ORDER BY y COLLATE nocase" form works the same as "ORDER BY y".
# The "y" binds more tightly to output columns than to input columns.
#
# This is for compatibility with SQL92 and with historical SQLite behavior.
# Note that PostgreSQL considers "y COLLATE nocase" to be an expression
# and thus PostgreSQL treats this case as if it where the 3.x case below.
#
do_test resolver01-2.1 {
catchsql { catchsql {
SELECT 2 AS y FROM t1, t2 ORDER BY y COLLATE nocase; SELECT 2 AS y FROM t1, t2 ORDER BY y COLLATE nocase;
} }
} {0 2} } {0 2}
do_test resolver01-1.3 { do_test resolver01-2.2 {
catchsql {
SELECT 2 AS yy FROM t1, t2 ORDER BY y COLLATE nocase;
}
} {1 {ambiguous column name: y}}
do_test resolver01-2.3 {
catchsql {
SELECT x AS y FROM t3 ORDER BY y COLLATE nocase;
}
} {0 {11 33}}
do_test resolver01-2.4 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY y COLLATE nocase;
}
} {0 {33 11}}
do_test resolver01-2.5 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY yy COLLATE nocase;
}
} {0 {11 33}}
do_test resolver01-2.6 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY 1 COLLATE nocase;
}
} {0 {11 33}}
# But if the form is "ORDER BY expr" then bind more tightly to the
# the input column names and only use the output column names if no
# input column name matches.
#
# This is SQL99 behavior, as implemented by PostgreSQL and MS-SQL.
# Note that Oracle works differently.
#
do_test resolver01-3.1 {
catchsql { catchsql {
SELECT 3 AS y FROM t1, t2 ORDER BY +y; SELECT 3 AS y FROM t1, t2 ORDER BY +y;
} }
} {0 3} } {1 {ambiguous column name: y}}
do_test resolver01-3.2 {
catchsql {
SELECT 2 AS yy FROM t1, t2 ORDER BY +y;
}
} {1 {ambiguous column name: y}}
do_test resolver01-3.3 {
catchsql {
SELECT x AS y FROM t3 ORDER BY +y;
}
} {0 {33 11}}
do_test resolver01-3.4 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY +y;
}
} {0 {33 11}}
do_test resolver01-3.5 {
catchsql {
SELECT x AS yy FROM t3 ORDER BY +yy
}
} {0 {11 33}}
# This is the test case given in ticket [f617ea3125e9] (with table name
# changed from "t1" to "t4". The behavior of (1) and (3) match with
# PostgreSQL, but we intentionally break with PostgreSQL to provide
# SQL92 behavior for case (2).
#
do_execsql_test resolver01-4.1 {
CREATE TABLE t4(m CHAR(2));
INSERT INTO t4 VALUES('az');
INSERT INTO t4 VALUES('by');
INSERT INTO t4 VALUES('cx');
SELECT '1', substr(m,2) AS m FROM t4 ORDER BY m;
SELECT '2', substr(m,2) AS m FROM t4 ORDER BY m COLLATE binary;
SELECT '3', substr(m,2) AS m FROM t4 ORDER BY lower(m);
} {1 x 1 y 1 z 2 x 2 y 2 z 3 z 3 y 3 x}
##########################################################################
# Test cases for ticket [1c69be2dafc28]: Make sure the GROUP BY binds
# more tightly to the input tables in all cases.
#
# This first case case has been wrong in SQLite for time out of mind.
# For SQLite version 3.7.17 the answer was two rows, which is wrong.
#
do_execsql_test resolver01-5.1 {
CREATE TABLE t5(m CHAR(2));
INSERT INTO t5 VALUES('ax');
INSERT INTO t5 VALUES('bx');
INSERT INTO t5 VALUES('cy');
SELECT count(*), substr(m,2,1) AS m FROM t5 GROUP BY m ORDER BY 1, 2;
} {1 x 1 x 1 y}
# This case is unambiguous and has always been correct.
#
do_execsql_test resolver01-5.2 {
SELECT count(*), substr(m,2,1) AS mx FROM t5 GROUP BY m ORDER BY 1, 2;
} {1 x 1 x 1 y}
# This case is not allowed in standard SQL, but SQLite allows and does
# the sensible thing.
#
do_execsql_test resolver01-5.3 {
SELECT count(*), substr(m,2,1) AS mx FROM t5 GROUP BY mx ORDER BY 1, 2;
} {1 y 2 x}
do_execsql_test resolver01-5.4 {
SELECT count(*), substr(m,2,1) AS mx FROM t5
GROUP BY substr(m,2,1) ORDER BY 1, 2;
} {1 y 2 x}
# These test case weere provided in the 2013-08-14 email from Rob Golsteijn
# that originally reported the problem of ticket [1c69be2dafc28].
#
do_execsql_test resolver01-6.1 {
CREATE TABLE t61(name);
SELECT min(name) FROM t61 GROUP BY lower(name);
} {}
do_execsql_test resolver01-6.2 {
SELECT min(name) AS name FROM t61 GROUP BY lower(name);
} {}
do_execsql_test resolver01-6.3 {
CREATE TABLE t63(name);
INSERT INTO t63 VALUES (NULL);
INSERT INTO t63 VALUES ('abc');
SELECT count(),
NULLIF(name,'abc') AS name
FROM t63
GROUP BY lower(name);
} {1 {} 1 {}}
finish_test finish_test

View File

@@ -209,14 +209,11 @@ do_test tkt2822-5.4 {
# In "ORDER BY +b" the term is now an expression rather than # In "ORDER BY +b" the term is now an expression rather than
# a label. It therefore matches by rule (3) instead of rule (2). # a label. It therefore matches by rule (3) instead of rule (2).
# #
# 2013-04-13: This is busted. Changed to conform to PostgreSQL and
# MySQL and Oracle behavior.
#
do_test tkt2822-5.5 { do_test tkt2822-5.5 {
execsql { execsql {
SELECT a AS b FROM t3 ORDER BY +b; SELECT a AS b FROM t3 ORDER BY +b;
} }
} {1 9} } {9 1}
# Tests for rule 2 in compound queries # Tests for rule 2 in compound queries
# #