Compare commits
137 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b50f0d19a | |||
| 7fee0bfad2 | |||
| d736829e8b | |||
| f607bec749 | |||
| 6b4b88208e | |||
| 7262ca94cb | |||
| 9f607e9c23 | |||
| d2ac43ea38 | |||
| 9592320b91 | |||
| 2b5f152601 | |||
| 5001b3314d | |||
| 6e2210e0a1 | |||
| 34a7d790ba | |||
| d437ac0c58 | |||
| 769309fcf3 | |||
| 59ff42516c | |||
| 04a8e0cd54 | |||
| 3773c25f16 | |||
| 01e1229063 | |||
| f02cdd379a | |||
| c994b0225b | |||
| e618dd9b5d | |||
| 867be212bc | |||
| c316307315 | |||
| efa3a3c9cc | |||
| ce1037352d | |||
| 67a9b8eded | |||
| 17074e3a9e | |||
| 875ad8ceb1 | |||
| b7306f6f6e | |||
| 9c27758eb4 | |||
| 85b9a1c2fb | |||
| cc4644183b | |||
| 6fb2b54ceb | |||
| ca5aa59453 | |||
| c95f38d456 | |||
| 3a6b258ec3 | |||
| 5bce7d8f6c | |||
| f87e10c75e | |||
| 660af939b0 | |||
| 13b08bb6ff | |||
| 6fde1799f8 | |||
| e0a5e20fa8 | |||
| 303451a8f7 | |||
| 9a94722d48 | |||
| 09882a75c4 | |||
| 54a9ab3f13 | |||
| 13078caac4 | |||
| 2f1f8801ed | |||
| 4449437b56 | |||
| c5861ce88f | |||
| 45f318275e | |||
| 466ea9b1e2 | |||
| ea74c1db64 | |||
| c0bb4459d3 | |||
| 5174f17485 | |||
| 3086529f7c | |||
| 7392569f5e | |||
| 58773a533c | |||
| cd9e01427d | |||
| dd2a8f5ee9 | |||
| 2a11bb23eb | |||
| 8fa622d62b | |||
| 26522d1c45 | |||
| ea64715976 | |||
| 299bf7c2f0 | |||
| 8d7b212c4c | |||
| 72a9f0233b | |||
| 9c3549aa2f | |||
| 980cf25b10 | |||
| 074544d181 | |||
| 96f55d0fa5 | |||
| d31e7addd6 | |||
| 8b98560d6e | |||
| 4ece2f2657 | |||
| a46ba6cca5 | |||
| ccf6db5e64 | |||
| 1fe3ac7347 | |||
| da230bd484 | |||
| 7128b7c1f4 | |||
| 6d6decb8d9 | |||
| e3bf632cc2 | |||
| 982c41977c | |||
| f3cd0c82df | |||
| da4c409aea | |||
| dacf1de95c | |||
| 03854d2ecc | |||
| 07509f8c1e | |||
| fe4e25a0f6 | |||
| 83193d0133 | |||
| cf025a8c18 | |||
| 7095c002b8 | |||
| f1949b6634 | |||
| 056f5396fe | |||
| 2e60568fef | |||
| 64c1f77a8e | |||
| 3c49eaf4be | |||
| f7b0a5f3c3 | |||
| bd573c459b | |||
| df12595c09 | |||
| 6eb3480bd7 | |||
| ec891fd40c | |||
| d882108a01 | |||
| 4011c44322 | |||
| 685a50ad74 | |||
| 397776a823 | |||
| bb2d9b1bf1 | |||
| 0cfd46a1ad | |||
| bb777d517d | |||
| 48baed4f77 | |||
| 8c2b6d784b | |||
| 1c5ed624a0 | |||
| 86d0ea7558 | |||
| 995bbbf993 | |||
| 6bc5c9e788 | |||
| 6b27f5fab7 | |||
| 2b1287cf44 | |||
| f1abe3680e | |||
| dfa552f45b | |||
| f690b57206 | |||
| c9a8668ac7 | |||
| a0368d9396 | |||
| d6f784ef92 | |||
| 79d4544d53 | |||
| 09590aaa1b | |||
| 83023a3357 | |||
| e105dd7622 | |||
| 31f5639fb7 | |||
| 99652dda3c | |||
| c3a20c19a8 | |||
| 72779425b5 | |||
| 8471be3311 | |||
| f9eae18b56 | |||
| b6e9f7a4d1 | |||
| e2f781b9d1 | |||
| 2e362f9775 | |||
| 86fb6e1738 |
+8
-2
@@ -190,7 +190,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
|
||||
update.lo upsert.lo util.lo vacuum.lo \
|
||||
vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
|
||||
vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
|
||||
utf.lo vtab.lo
|
||||
window.lo utf.lo vtab.lo
|
||||
|
||||
# Object files for the amalgamation.
|
||||
#
|
||||
@@ -304,7 +304,8 @@ SRC = \
|
||||
$(TOP)/src/where.c \
|
||||
$(TOP)/src/wherecode.c \
|
||||
$(TOP)/src/whereexpr.c \
|
||||
$(TOP)/src/whereInt.h
|
||||
$(TOP)/src/whereInt.h \
|
||||
$(TOP)/src/window.c
|
||||
|
||||
# Source code for extensions
|
||||
#
|
||||
@@ -418,6 +419,7 @@ TESTSRC = \
|
||||
$(TOP)/src/test_thread.c \
|
||||
$(TOP)/src/test_vfs.c \
|
||||
$(TOP)/src/test_windirent.c \
|
||||
$(TOP)/src/test_window.c \
|
||||
$(TOP)/src/test_wsd.c \
|
||||
$(TOP)/ext/fts3/fts3_term.c \
|
||||
$(TOP)/ext/fts3/fts3_test.c \
|
||||
@@ -493,6 +495,7 @@ TESTSRC2 = \
|
||||
$(TOP)/src/where.c \
|
||||
$(TOP)/src/wherecode.c \
|
||||
$(TOP)/src/whereexpr.c \
|
||||
$(TOP)/src/window.c \
|
||||
parse.c \
|
||||
$(TOP)/ext/fts3/fts3.c \
|
||||
$(TOP)/ext/fts3/fts3_aux.c \
|
||||
@@ -967,6 +970,9 @@ wherecode.lo: $(TOP)/src/wherecode.c $(HDR)
|
||||
whereexpr.lo: $(TOP)/src/whereexpr.c $(HDR)
|
||||
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/whereexpr.c
|
||||
|
||||
window.lo: $(TOP)/src/window.c $(HDR)
|
||||
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/window.c
|
||||
|
||||
tclsqlite.lo: $(TOP)/src/tclsqlite.c $(HDR)
|
||||
$(LTCOMPILE) -DUSE_TCL_STUBS=1 -c $(TOP)/src/tclsqlite.c
|
||||
|
||||
|
||||
+7
-2
@@ -1196,7 +1196,7 @@ LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \
|
||||
update.lo upsert.lo util.lo vacuum.lo \
|
||||
vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
|
||||
vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
|
||||
utf.lo vtab.lo
|
||||
window.lo utf.lo vtab.lo
|
||||
# <</mark>>
|
||||
|
||||
# Object files for the amalgamation.
|
||||
@@ -1307,7 +1307,8 @@ SRC01 = \
|
||||
$(TOP)\src\walker.c \
|
||||
$(TOP)\src\where.c \
|
||||
$(TOP)\src\wherecode.c \
|
||||
$(TOP)\src\whereexpr.c
|
||||
$(TOP)\src\whereexpr.c \
|
||||
$(TOP)\src\window.c
|
||||
|
||||
# Core miscellaneous files.
|
||||
#
|
||||
@@ -1478,6 +1479,7 @@ TESTSRC = \
|
||||
$(TOP)\src\test_thread.c \
|
||||
$(TOP)\src\test_vfs.c \
|
||||
$(TOP)\src\test_windirent.c \
|
||||
$(TOP)\src\test_window.c \
|
||||
$(TOP)\src\test_wsd.c \
|
||||
$(TOP)\ext\fts3\fts3_term.c \
|
||||
$(TOP)\ext\fts3\fts3_test.c \
|
||||
@@ -2046,6 +2048,9 @@ wherecode.lo: $(TOP)\src\wherecode.c $(HDR)
|
||||
whereexpr.lo: $(TOP)\src\whereexpr.c $(HDR)
|
||||
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\whereexpr.c
|
||||
|
||||
window.lo: $(TOP)\src\window.c $(HDR)
|
||||
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\window.c
|
||||
|
||||
tclsqlite.lo: $(TOP)\src\tclsqlite.c $(HDR) $(SQLITE_TCL_DEP)
|
||||
$(LTCOMPILE) $(NO_WARN) -DUSE_TCL_STUBS=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @ZLIB_FLAGS@ @SESSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE @DEBUG_FLAGS@
|
||||
|
||||
AM_CFLAGS = @BUILD_CFLAGS@
|
||||
lib_LTLIBRARIES = libsqlite3.la
|
||||
libsqlite3_la_SOURCES = sqlite3.c
|
||||
libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8
|
||||
|
||||
+45
-18
@@ -29,6 +29,7 @@ AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r])
|
||||
AC_FUNC_STRERROR_R
|
||||
|
||||
AC_CONFIG_FILES([Makefile sqlite3.pc])
|
||||
BUILD_CFLAGS=
|
||||
AC_SUBST(BUILD_CFLAGS)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -86,13 +87,11 @@ AC_SUBST(READLINE_LIBS)
|
||||
AC_ARG_ENABLE(threadsafe, [AS_HELP_STRING(
|
||||
[--enable-threadsafe], [build a thread-safe library [default=yes]])],
|
||||
[], [enable_threadsafe=yes])
|
||||
THREADSAFE_FLAGS=-DSQLITE_THREADSAFE=0
|
||||
if test x"$enable_threadsafe" != "xno"; then
|
||||
THREADSAFE_FLAGS="-D_REENTRANT=1 -DSQLITE_THREADSAFE=1"
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -D_REENTRANT=1 -DSQLITE_THREADSAFE=1"
|
||||
AC_SEARCH_LIBS(pthread_create, pthread)
|
||||
AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
|
||||
fi
|
||||
AC_SUBST(THREADSAFE_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@@ -104,11 +103,32 @@ AC_ARG_ENABLE(dynamic-extensions, [AS_HELP_STRING(
|
||||
if test x"$enable_dynamic_extensions" != "xno"; then
|
||||
AC_SEARCH_LIBS(dlopen, dl)
|
||||
else
|
||||
DYNAMIC_EXTENSION_FLAGS=-DSQLITE_OMIT_LOAD_EXTENSION=1
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_OMIT_LOAD_EXTENSION=1"
|
||||
fi
|
||||
AC_MSG_CHECKING([for whether to support dynamic extensions])
|
||||
AC_MSG_RESULT($enable_dynamic_extensions)
|
||||
AC_SUBST(DYNAMIC_EXTENSION_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# --enable-fts4
|
||||
#
|
||||
AC_ARG_ENABLE(fts4, [AS_HELP_STRING(
|
||||
[--enable-fts4], [include fts4 support [default=yes]])],
|
||||
[], [enable_fts4=yes])
|
||||
if test x"$enable_fts4" = "xyes"; then
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS4"
|
||||
fi
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# --enable-fts3
|
||||
#
|
||||
AC_ARG_ENABLE(fts3, [AS_HELP_STRING(
|
||||
[--enable-fts3], [include fts3 support [default=no]])],
|
||||
[], [])
|
||||
if test x"$enable_fts3" = "xyes" -a x"$enable_fts4" = "xno"; then
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS3"
|
||||
fi
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@@ -119,9 +139,8 @@ AC_ARG_ENABLE(fts5, [AS_HELP_STRING(
|
||||
[], [enable_fts5=yes])
|
||||
if test x"$enable_fts5" = "xyes"; then
|
||||
AC_SEARCH_LIBS(log, m)
|
||||
FTS5_FLAGS=-DSQLITE_ENABLE_FTS5
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS5"
|
||||
fi
|
||||
AC_SUBST(FTS5_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@@ -129,11 +148,21 @@ AC_SUBST(FTS5_FLAGS)
|
||||
#
|
||||
AC_ARG_ENABLE(json1, [AS_HELP_STRING(
|
||||
[--enable-json1], [include json1 support [default=yes]])],
|
||||
[], [enable_json1=yes])
|
||||
[],[enable_json1=yes])
|
||||
if test x"$enable_json1" = "xyes"; then
|
||||
JSON1_FLAGS=-DSQLITE_ENABLE_JSON1
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_JSON1"
|
||||
fi
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# --enable-rtree
|
||||
#
|
||||
AC_ARG_ENABLE(rtree, [AS_HELP_STRING(
|
||||
[--enable-rtree], [include rtree support [default=yes]])],
|
||||
[], [enable_rtree=yes])
|
||||
if test x"$enable_rtree" = "xyes"; then
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE"
|
||||
fi
|
||||
AC_SUBST(JSON1_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@@ -141,11 +170,10 @@ AC_SUBST(JSON1_FLAGS)
|
||||
#
|
||||
AC_ARG_ENABLE(session, [AS_HELP_STRING(
|
||||
[--enable-session], [enable the session extension [default=no]])],
|
||||
[], [enable_session=no])
|
||||
[], [])
|
||||
if test x"$enable_session" = "xyes"; then
|
||||
SESSION_FLAGS="-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
|
||||
fi
|
||||
AC_SUBST(SESSION_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@@ -153,11 +181,11 @@ AC_SUBST(SESSION_FLAGS)
|
||||
#
|
||||
AC_ARG_ENABLE(debug, [AS_HELP_STRING(
|
||||
[--enable-debug], [build with debugging features enabled [default=no]])],
|
||||
[], [enable_session=no])
|
||||
[], [])
|
||||
if test x"$enable_debug" = "xyes"; then
|
||||
DEBUG_FLAGS="-DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE"
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE"
|
||||
CFLAGS="-g -O0"
|
||||
fi
|
||||
AC_SUBST(DEBUG_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@@ -177,9 +205,8 @@ AC_SUBST(EXTRA_SHELL_OBJ)
|
||||
|
||||
AC_CHECK_FUNCS(posix_fallocate)
|
||||
AC_CHECK_HEADERS(zlib.h,[
|
||||
AC_SEARCH_LIBS(deflate,z,[ZLIB_FLAGS="-DSQLITE_HAVE_ZLIB"])
|
||||
AC_SEARCH_LIBS(deflate,z,[BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_HAVE_ZLIB"])
|
||||
])
|
||||
AC_SUBST(ZLIB_FLAGS)
|
||||
|
||||
AC_SEARCH_LIBS(system,,,[SHELL_CFLAGS="-DSQLITE_NOHAVE_SYSTEM"])
|
||||
AC_SUBST(SHELL_CFLAGS)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.24.0.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.25.0.
|
||||
#
|
||||
#
|
||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||
@@ -726,8 +726,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='sqlite'
|
||||
PACKAGE_TARNAME='sqlite'
|
||||
PACKAGE_VERSION='3.24.0'
|
||||
PACKAGE_STRING='sqlite 3.24.0'
|
||||
PACKAGE_VERSION='3.25.0'
|
||||
PACKAGE_STRING='sqlite 3.25.0'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
|
||||
@@ -1465,7 +1465,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# 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.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures sqlite 3.24.0 to adapt to many kinds of systems.
|
||||
\`configure' configures sqlite 3.25.0 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1530,7 +1530,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of sqlite 3.24.0:";;
|
||||
short | recursive ) echo "Configuration of sqlite 3.25.0:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1655,7 +1655,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
sqlite configure 3.24.0
|
||||
sqlite configure 3.25.0
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@@ -2074,7 +2074,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by sqlite $as_me 3.24.0, which was
|
||||
It was created by sqlite $as_me 3.25.0, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -10455,8 +10455,6 @@ fi
|
||||
# Check whether --enable-threadsafe was given.
|
||||
if test "${enable_threadsafe+set}" = set; then :
|
||||
enableval=$enable_threadsafe;
|
||||
else
|
||||
enable_threadsafe=yes
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support threadsafe operation" >&5
|
||||
@@ -11249,12 +11247,10 @@ fi
|
||||
# check for debug enabled
|
||||
# Check whether --enable-debug was given.
|
||||
if test "${enable_debug+set}" = set; then :
|
||||
enableval=$enable_debug; use_debug=$enableval
|
||||
else
|
||||
use_debug=no
|
||||
enableval=$enable_debug;
|
||||
fi
|
||||
|
||||
if test "${use_debug}" = "yes" ; then
|
||||
if test "${enable_debug}" = "yes" ; then
|
||||
TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
|
||||
else
|
||||
TARGET_DEBUG="-DNDEBUG"
|
||||
@@ -11265,12 +11261,10 @@ fi
|
||||
# See whether we should use the amalgamation to build
|
||||
# Check whether --enable-amalgamation was given.
|
||||
if test "${enable_amalgamation+set}" = set; then :
|
||||
enableval=$enable_amalgamation; use_amalgamation=$enableval
|
||||
else
|
||||
use_amalgamation=yes
|
||||
enableval=$enable_amalgamation;
|
||||
fi
|
||||
|
||||
if test "${use_amalgamation}" != "yes" ; then
|
||||
if test "${enable_amalgamation}" == "no" ; then
|
||||
USE_AMALGAMATION=0
|
||||
fi
|
||||
|
||||
@@ -11353,12 +11347,12 @@ fi
|
||||
# See whether we should allow loadable extensions
|
||||
# Check whether --enable-load-extension was given.
|
||||
if test "${enable_load_extension+set}" = set; then :
|
||||
enableval=$enable_load_extension; use_loadextension=$enableval
|
||||
enableval=$enable_load_extension;
|
||||
else
|
||||
use_loadextension=yes
|
||||
enable_load_extension=yes
|
||||
fi
|
||||
|
||||
if test "${use_loadextension}" = "yes" ; then
|
||||
if test "${enable_load_extension}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
|
||||
$as_echo_n "checking for library containing dlopen... " >&6; }
|
||||
@@ -11425,9 +11419,7 @@ fi
|
||||
#
|
||||
# Check whether --enable-memsys5 was given.
|
||||
if test "${enable_memsys5+set}" = set; then :
|
||||
enableval=$enable_memsys5; enable_memsys5=yes
|
||||
else
|
||||
enable_memsys5=no
|
||||
enableval=$enable_memsys5;
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5
|
||||
@@ -11442,9 +11434,7 @@ $as_echo "no" >&6; }
|
||||
fi
|
||||
# Check whether --enable-memsys3 was given.
|
||||
if test "${enable_memsys3+set}" = set; then :
|
||||
enableval=$enable_memsys3; enable_memsys3=yes
|
||||
else
|
||||
enable_memsys3=no
|
||||
enableval=$enable_memsys3;
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5
|
||||
@@ -11462,9 +11452,7 @@ fi
|
||||
# See whether we should enable Full Text Search extensions
|
||||
# Check whether --enable-fts3 was given.
|
||||
if test "${enable_fts3+set}" = set; then :
|
||||
enableval=$enable_fts3; enable_fts3=yes
|
||||
else
|
||||
enable_fts3=no
|
||||
enableval=$enable_fts3;
|
||||
fi
|
||||
|
||||
if test "${enable_fts3}" = "yes" ; then
|
||||
@@ -11472,9 +11460,7 @@ if test "${enable_fts3}" = "yes" ; then
|
||||
fi
|
||||
# Check whether --enable-fts4 was given.
|
||||
if test "${enable_fts4+set}" = set; then :
|
||||
enableval=$enable_fts4; enable_fts4=yes
|
||||
else
|
||||
enable_fts4=no
|
||||
enableval=$enable_fts4;
|
||||
fi
|
||||
|
||||
if test "${enable_fts4}" = "yes" ; then
|
||||
@@ -11538,9 +11524,7 @@ fi
|
||||
fi
|
||||
# Check whether --enable-fts5 was given.
|
||||
if test "${enable_fts5+set}" = set; then :
|
||||
enableval=$enable_fts5; enable_fts5=yes
|
||||
else
|
||||
enable_fts5=no
|
||||
enableval=$enable_fts5;
|
||||
fi
|
||||
|
||||
if test "${enable_fts5}" = "yes" ; then
|
||||
@@ -11607,9 +11591,7 @@ fi
|
||||
# See whether we should enable JSON1
|
||||
# Check whether --enable-json1 was given.
|
||||
if test "${enable_json1+set}" = set; then :
|
||||
enableval=$enable_json1; enable_json1=yes
|
||||
else
|
||||
enable_json1=no
|
||||
enableval=$enable_json1;
|
||||
fi
|
||||
|
||||
if test "${enable_json1}" = "yes" ; then
|
||||
@@ -11621,9 +11603,7 @@ fi
|
||||
# statements.
|
||||
# Check whether --enable-update-limit was given.
|
||||
if test "${enable_update_limit+set}" = set; then :
|
||||
enableval=$enable_update_limit; enable_udlimit=yes
|
||||
else
|
||||
enable_udlimit=no
|
||||
enableval=$enable_update_limit;
|
||||
fi
|
||||
|
||||
if test "${enable_udlimit}" = "yes" ; then
|
||||
@@ -11634,9 +11614,7 @@ fi
|
||||
# See whether we should enable RTREE
|
||||
# Check whether --enable-rtree was given.
|
||||
if test "${enable_rtree+set}" = set; then :
|
||||
enableval=$enable_rtree; enable_rtree=yes
|
||||
else
|
||||
enable_rtree=no
|
||||
enableval=$enable_rtree;
|
||||
fi
|
||||
|
||||
if test "${enable_rtree}" = "yes" ; then
|
||||
@@ -11647,9 +11625,7 @@ fi
|
||||
# See whether we should enable the SESSION extension
|
||||
# Check whether --enable-session was given.
|
||||
if test "${enable_session+set}" = set; then :
|
||||
enableval=$enable_session; enable_session=yes
|
||||
else
|
||||
enable_session=no
|
||||
enableval=$enable_session;
|
||||
fi
|
||||
|
||||
if test "${enable_session}" = "yes" ; then
|
||||
@@ -11712,9 +11688,7 @@ BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
|
||||
# See whether we should use GCOV
|
||||
# Check whether --enable-gcov was given.
|
||||
if test "${enable_gcov+set}" = set; then :
|
||||
enableval=$enable_gcov; use_gcov=$enableval
|
||||
else
|
||||
use_gcov=no
|
||||
enableval=$enable_gcov;
|
||||
fi
|
||||
|
||||
if test "${use_gcov}" = "yes" ; then
|
||||
@@ -12242,7 +12216,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by sqlite $as_me 3.24.0, which was
|
||||
This file was extended by sqlite $as_me 3.25.0, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -12308,7 +12282,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
sqlite config.status 3.24.0
|
||||
sqlite config.status 3.25.0
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
+17
-31
@@ -182,7 +182,7 @@ AC_SUBST(BUILD_CC)
|
||||
# Do we want to support multithreaded use of sqlite
|
||||
#
|
||||
AC_ARG_ENABLE(threadsafe,
|
||||
AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]),,enable_threadsafe=yes)
|
||||
AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]))
|
||||
AC_MSG_CHECKING([whether to support threadsafe operation])
|
||||
if test "$enable_threadsafe" = "no"; then
|
||||
SQLITE_THREADSAFE=0
|
||||
@@ -557,9 +557,8 @@ AC_SEARCH_LIBS(fdatasync, [rt])
|
||||
|
||||
#########
|
||||
# check for debug enabled
|
||||
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]),
|
||||
[use_debug=$enableval],[use_debug=no])
|
||||
if test "${use_debug}" = "yes" ; then
|
||||
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
|
||||
if test "${enable_debug}" = "yes" ; then
|
||||
TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
|
||||
else
|
||||
TARGET_DEBUG="-DNDEBUG"
|
||||
@@ -569,9 +568,8 @@ AC_SUBST(TARGET_DEBUG)
|
||||
#########
|
||||
# See whether we should use the amalgamation to build
|
||||
AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
|
||||
[Disable the amalgamation and instead build all files separately]),
|
||||
[use_amalgamation=$enableval],[use_amalgamation=yes])
|
||||
if test "${use_amalgamation}" != "yes" ; then
|
||||
[Disable the amalgamation and instead build all files separately]))
|
||||
if test "${enable_amalgamation}" == "no" ; then
|
||||
USE_AMALGAMATION=0
|
||||
fi
|
||||
AC_SUBST(USE_AMALGAMATION)
|
||||
@@ -585,9 +583,8 @@ AC_SUBST(HAVE_ZLIB)
|
||||
#########
|
||||
# See whether we should allow loadable extensions
|
||||
AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
|
||||
[Disable loading of external extensions]),
|
||||
[use_loadextension=$enableval],[use_loadextension=yes])
|
||||
if test "${use_loadextension}" = "yes" ; then
|
||||
[Disable loading of external extensions]),,[enable_load_extension=yes])
|
||||
if test "${enable_load_extension}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS=""
|
||||
AC_SEARCH_LIBS(dlopen, dl)
|
||||
else
|
||||
@@ -598,8 +595,7 @@ fi
|
||||
# Do we want to support memsys3 and/or memsys5
|
||||
#
|
||||
AC_ARG_ENABLE(memsys5,
|
||||
AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]),
|
||||
[enable_memsys5=yes],[enable_memsys5=no])
|
||||
AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
|
||||
AC_MSG_CHECKING([whether to support MEMSYS5])
|
||||
if test "${enable_memsys5}" = "yes"; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
|
||||
@@ -608,8 +604,7 @@ else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
AC_ARG_ENABLE(memsys3,
|
||||
AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]),
|
||||
[enable_memsys3=yes],[enable_memsys3=no])
|
||||
AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
|
||||
AC_MSG_CHECKING([whether to support MEMSYS3])
|
||||
if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
|
||||
@@ -621,21 +616,18 @@ fi
|
||||
#########
|
||||
# See whether we should enable Full Text Search extensions
|
||||
AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
|
||||
[Enable the FTS3 extension]),
|
||||
[enable_fts3=yes],[enable_fts3=no])
|
||||
[Enable the FTS3 extension]))
|
||||
if test "${enable_fts3}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
|
||||
fi
|
||||
AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
|
||||
[Enable the FTS4 extension]),
|
||||
[enable_fts4=yes],[enable_fts4=no])
|
||||
[Enable the FTS4 extension]))
|
||||
if test "${enable_fts4}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
|
||||
AC_SEARCH_LIBS([log],[m])
|
||||
fi
|
||||
AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
|
||||
[Enable the FTS5 extension]),
|
||||
[enable_fts5=yes],[enable_fts5=no])
|
||||
[Enable the FTS5 extension]))
|
||||
if test "${enable_fts5}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
|
||||
AC_SEARCH_LIBS([log],[m])
|
||||
@@ -643,9 +635,7 @@ fi
|
||||
|
||||
#########
|
||||
# See whether we should enable JSON1
|
||||
AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],
|
||||
[Enable the JSON1 extension]),
|
||||
[enable_json1=yes],[enable_json1=no])
|
||||
AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],[Enable the JSON1 extension]))
|
||||
if test "${enable_json1}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
|
||||
fi
|
||||
@@ -654,8 +644,7 @@ fi
|
||||
# See whether we should enable the LIMIT clause on UPDATE and DELETE
|
||||
# statements.
|
||||
AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
|
||||
[Enable the UPDATE/DELETE LIMIT clause]),
|
||||
[enable_udlimit=yes],[enable_udlimit=no])
|
||||
[Enable the UPDATE/DELETE LIMIT clause]))
|
||||
if test "${enable_udlimit}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
|
||||
fi
|
||||
@@ -663,8 +652,7 @@ fi
|
||||
#########
|
||||
# See whether we should enable RTREE
|
||||
AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
|
||||
[Enable the RTREE extension]),
|
||||
[enable_rtree=yes],[enable_rtree=no])
|
||||
[Enable the RTREE extension]))
|
||||
if test "${enable_rtree}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
|
||||
fi
|
||||
@@ -672,8 +660,7 @@ fi
|
||||
#########
|
||||
# See whether we should enable the SESSION extension
|
||||
AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
|
||||
[Enable the SESSION extension]),
|
||||
[enable_session=yes],[enable_session=no])
|
||||
[Enable the SESSION extension]))
|
||||
if test "${enable_session}" = "yes" ; then
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
|
||||
OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
|
||||
@@ -733,8 +720,7 @@ BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
|
||||
#########
|
||||
# See whether we should use GCOV
|
||||
AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
|
||||
[Enable coverage testing using gcov]),
|
||||
[use_gcov=$enableval],[use_gcov=no])
|
||||
[Enable coverage testing using gcov]))
|
||||
if test "${use_gcov}" = "yes" ; then
|
||||
USE_GCOV=1
|
||||
else
|
||||
|
||||
@@ -332,7 +332,7 @@ proc do_candidates_test {tn sql res} {
|
||||
|
||||
|
||||
reset_db
|
||||
do_execsql_test 3.0 {
|
||||
do_execsql_test 4.0 {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE TABLE t2(c, d);
|
||||
|
||||
@@ -342,7 +342,7 @@ do_execsql_test 3.0 {
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t2 SELECT (i-1)/20, (i-1)/5 FROM s;
|
||||
}
|
||||
do_candidates_test 3.1 {
|
||||
do_candidates_test 4.1 {
|
||||
SELECT * FROM t1,t2 WHERE (b=? OR a=?) AND (c=? OR d=?)
|
||||
} {
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b); -- stat1: 100 20
|
||||
@@ -351,14 +351,14 @@ do_candidates_test 3.1 {
|
||||
CREATE INDEX t2_idx_00000064 ON t2(d); -- stat1: 100 5
|
||||
}
|
||||
|
||||
do_candidates_test 3.2 {
|
||||
do_candidates_test 4.2 {
|
||||
SELECT * FROM t1,t2 WHERE a=? AND b=? AND c=? AND d=?
|
||||
} {
|
||||
CREATE INDEX t1_idx_000123a7 ON t1(a, b); -- stat1: 100 50 17
|
||||
CREATE INDEX t2_idx_0001295b ON t2(c, d); -- stat1: 100 20 5
|
||||
}
|
||||
|
||||
do_execsql_test 3.2 {
|
||||
do_execsql_test 4.3 {
|
||||
CREATE INDEX t1_idx_00000061 ON t1(a); -- stat1: 100 50
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b); -- stat1: 100 20
|
||||
CREATE INDEX t1_idx_000123a7 ON t1(a, b); -- stat1: 100 50 16
|
||||
|
||||
@@ -36,6 +36,7 @@ void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);
|
||||
#include <stdio.h>
|
||||
void sqlite3Fts5ParserTrace(FILE*, char*);
|
||||
#endif
|
||||
int sqlite3Fts5ParserFallback(int);
|
||||
|
||||
|
||||
struct Fts5Expr {
|
||||
@@ -2591,10 +2592,12 @@ int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){
|
||||
rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
|
||||
}
|
||||
|
||||
/* Avoid a warning indicating that sqlite3Fts5ParserTrace() is unused */
|
||||
/* Avoid warnings indicating that sqlite3Fts5ParserTrace() and
|
||||
** sqlite3Fts5ParserFallback() are unused */
|
||||
#ifndef NDEBUG
|
||||
(void)sqlite3Fts5ParserTrace;
|
||||
#endif
|
||||
(void)sqlite3Fts5ParserFallback;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
+9
-1
@@ -485,7 +485,15 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
|
||||
}
|
||||
case SQLITE_FLOAT: {
|
||||
double r = sqlite3_column_double(pStmt,i);
|
||||
output_formatted(p, "%!.20g", r);
|
||||
sqlite3_uint64 ur;
|
||||
memcpy(&ur,&r,sizeof(r));
|
||||
if( ur==0x7ff0000000000000LL ){
|
||||
p->xCallback("1e999", p->pArg);
|
||||
}else if( ur==0xfff0000000000000LL ){
|
||||
p->xCallback("-1e999", p->pArg);
|
||||
}else{
|
||||
output_formatted(p, "%!.20g", r);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SQLITE_NULL: {
|
||||
|
||||
@@ -593,7 +593,7 @@ char *sqlite3_normalize(const char *zSql){
|
||||
}
|
||||
}
|
||||
while( j>0 && z[j-1]==' ' ){ j--; }
|
||||
if( i>0 && z[j-1]!=';' ){ z[j++] = ';'; }
|
||||
if( j>0 && z[j-1]!=';' ){ z[j++] = ';'; }
|
||||
z[j] = 0;
|
||||
|
||||
/* Make a second pass converting "in(...)" where the "..." is not a
|
||||
|
||||
@@ -75,7 +75,7 @@ LIBOBJ+= vdbe.o parse.o \
|
||||
update.o upsert.o userauth.o util.o vacuum.o \
|
||||
vdbeapi.o vdbeaux.o vdbeblob.o vdbemem.o vdbesort.o \
|
||||
vdbetrace.o wal.o walker.o where.o wherecode.o whereexpr.o \
|
||||
utf.o vtab.o
|
||||
utf.o vtab.o window.o
|
||||
|
||||
LIBOBJ += sqlite3session.o
|
||||
|
||||
@@ -182,7 +182,8 @@ SRC = \
|
||||
$(TOP)/src/where.c \
|
||||
$(TOP)/src/wherecode.c \
|
||||
$(TOP)/src/whereexpr.c \
|
||||
$(TOP)/src/whereInt.h
|
||||
$(TOP)/src/whereInt.h \
|
||||
$(TOP)/src/window.c
|
||||
|
||||
# Source code for extensions
|
||||
#
|
||||
@@ -348,6 +349,7 @@ TESTSRC = \
|
||||
$(TOP)/src/test_thread.c \
|
||||
$(TOP)/src/test_vfs.c \
|
||||
$(TOP)/src/test_windirent.c \
|
||||
$(TOP)/src/test_window.c \
|
||||
$(TOP)/src/test_wsd.c
|
||||
|
||||
# Extensions to be statically loaded.
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
C Calculate\snon-aggregate\sexpressions\sin\sthe\sSELECT\slist\sof\san\saggregate\squery\nthat\sdoes\snot\suse\smin()\sor\smax()\sonce\sper\sgroup,\sinstead\sof\sonce\sper\srow\nvisited.
|
||||
D 2018-06-05T20:04:28.586
|
||||
C Experimental\splanner\schange\sto\savoid\sa\sskip-scan\sif\sa\sregular\sindex\sscan\son\nthe\ssame\sindex\scolumns\scan\sbe\sdone\sinstead.
|
||||
D 2018-07-04T14:28:07.015
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
|
||||
F Makefile.in 0a3a6c81e6fcb969ff9106e882f0a08547014ba463cb6beca4c4efaecc924ee6
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 681fb88cccf1fd58c0b9648f6a09b75332206ef72ca76012ad11699c320cec5f
|
||||
F Makefile.msc c1646e8f86c30ea63e56176deacef192ac87c663ce2c9083f459c45a7268934f
|
||||
F README.md 7764d56778d567913ef11c82da9ab94aefa0826f7c243351e4e2d7adaef6f373
|
||||
F VERSION b7c9d1d11cb70ef8e90cfcf3c944aa58a9f801cc2ad487eebb0a110c16dfc2df
|
||||
F VERSION d3e3afdec1165a5e593dcdfffd8e0f33a2b0186067eb51a073ef6c4aec34923d
|
||||
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
|
||||
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
|
||||
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
|
||||
F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2
|
||||
F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903
|
||||
F autoconf/Makefile.am 465fb475ee5a4b8a63d26c889cb36a4edbff0325b6859eb29a13cdf5c91b005c
|
||||
F autoconf/Makefile.am e14b629addaa1ce372b72043f28f40de2e32b7e211b6e0fc18dbb87989197e40
|
||||
F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac
|
||||
F autoconf/Makefile.msc 6a46d0659d6e4a25346102bcba40a7fb4b0b8b2dc4faabdf0187488c6dd580d6
|
||||
F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7
|
||||
F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1
|
||||
F autoconf/configure.ac 5f6cf281ae675685335ce7f43f8c2d59d3ac8ba4174a57b8e83097c5e10dcf4e
|
||||
F autoconf/configure.ac 573b98629d6963e6d9bf2897c3f4708fb94ce49897822526ad268181875e1736
|
||||
F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd
|
||||
F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873
|
||||
F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43
|
||||
@@ -33,8 +33,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63
|
||||
F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977
|
||||
F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc
|
||||
F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55
|
||||
F configure 80e2dcad8ab88aacc58b55eb0e395f79184b45fcfaa3f36fc20d2e71cfa0a7e4 x
|
||||
F configure.ac d4529ebb26ae046269334f1dac65f2b1d6927c2efe22b2ec24dce24dfe4f83dd
|
||||
F configure a46cba271ae08d635a1f331384c04563bdd37adb3d63cbdcffb1d91babfb64f5 x
|
||||
F configure.ac 18c93e8bbeec8254832c4ea90eb06e7187fd150ef098baed02467eeb374afb17
|
||||
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
|
||||
F doc/lemon.html ac63db056bce24b7368e29319cd1a7eb5f1798cc85922d96a80b6c3a4ff9f51b
|
||||
F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710
|
||||
@@ -45,7 +45,7 @@ F ext/async/sqlite3async.c 0f3070cc3f5ede78f2b9361fb3b629ce200d7d74
|
||||
F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef
|
||||
F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3
|
||||
F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4
|
||||
F ext/expert/expert1.test baa05800dc1c569faa7ce6232cead0fcedc07fea038b3a2489eaaf710831d546
|
||||
F ext/expert/expert1.test 333d037021c901322f9afc4a5687648ea23d56f1a0a079358a390664babf01be
|
||||
F ext/expert/sqlite3expert.c 89b7b59be610b929958db02416539a46ac088fd84f81623c4190aff62e92c3c4
|
||||
F ext/expert/sqlite3expert.h af6354f8ee5c9e025024e63fec3bd640a802afcc3099a44d804752cf0791d811
|
||||
F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72
|
||||
@@ -112,7 +112,7 @@ F ext/fts5/fts5Int.h eda28e3a0a5d87c412e8355fe35da875b04cb389908c8eb0d867ad662ad
|
||||
F ext/fts5/fts5_aux.c ca666a3bbe07c5a3bbe9fffaea19c935a1efaf337333e28bad7bdd1971ffd093
|
||||
F ext/fts5/fts5_buffer.c 1dd1ec0446b3acfc2d7d407eb894762a461613e2695273f48e449bfd13e973ff
|
||||
F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857
|
||||
F ext/fts5/fts5_expr.c c23a2e4c14c401a147c4a730460e5b37057627bf4be95515ee281cd87f4d277c
|
||||
F ext/fts5/fts5_expr.c 4ff82037692dcaf42ddf4f379a08815b4bd8784194a083994fec51eef31ef2dd
|
||||
F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301546dd55
|
||||
F ext/fts5/fts5_index.c 22b71d0e9e4b3ddd123a39ae27174e0012da2806f91b64087a68584f13f189de
|
||||
F ext/fts5/fts5_main.c da46761a7e9b582083fcb9f5a3ee50086205fb91f4e68d984a9946e64218e297
|
||||
@@ -276,7 +276,7 @@ F ext/misc/closure.c fe928228e8dfb2f00227311c203ccba9c2e5561f4f6de6da87e5b4a30cd
|
||||
F ext/misc/completion.c e75b8886a2531f9a7ec02dab5f179bb37e6bd46b5da7665a6cbf2dfbe2daa483
|
||||
F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f035b189
|
||||
F ext/misc/csv.c 65297bcce8d5acd5aadef42acbe739aef5a2ef5e74c7b73361ca19f3e21de657
|
||||
F ext/misc/dbdump.c 69ef1be5b210538f77dfcc6fcb55b4b5f5e98b1e0bcfd67d818711e10761db4d
|
||||
F ext/misc/dbdump.c 12389a10c410fadf1e68eeb382def92d5a7fa9ce7cce4fb86a736fa2bac1000a
|
||||
F ext/misc/eval.c 6ea9b22a5fa0dd973b67ca4e53555be177bc0b7b263aadf1024429457c82c0e3
|
||||
F ext/misc/fileio.c 48c7751c78fc4cdd29d8c862fd2f3f98bbfefa2a3cf1ca1496df4bf02eb8cded
|
||||
F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
|
||||
@@ -285,7 +285,7 @@ F ext/misc/json1.c 02f5f0d9c131df79f4ee168d2b426f0f0d273b7771fc0bb5293c4e7692d9a
|
||||
F ext/misc/memvfs.c ab36f49e02ebcdf85a1e08dc4d8599ea8f343e073ac9e0bca18a98b7e1ec9567
|
||||
F ext/misc/mmapwarm.c 70b618f2d0bde43fae288ad0b7498a629f2b6f61b50a27e06fae3cd23c83af29
|
||||
F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
|
||||
F ext/misc/normalize.c 19262ef3ef29d4de2f281b423326865c8916c63d0cb09f1dc98d24d5c1e8ba64
|
||||
F ext/misc/normalize.c b4290464f542bae7a97b43f15bd197949b833ffd668b7c313631bd5d4610212c
|
||||
F ext/misc/percentile.c 92699c8cd7d517ff610e6037e56506f8904dae2e
|
||||
F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
|
||||
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
|
||||
@@ -417,7 +417,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
|
||||
F main.mk 3f50dfe5cb4257c1aca96e417636ed51bc2561e71d31a21e9ccdf66feb912f43
|
||||
F main.mk d9872d31efa4a02e177f6d43b7fdae2a5f822e50d1eb72907f6575a567b85378
|
||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||
@@ -429,37 +429,37 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
|
||||
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
||||
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||
F src/alter.c cf7a8af45cb0ace672f47a1b29ab24092a9e8cd8d945a9974e3b5d925f548594
|
||||
F src/analyze.c 71fbbeb7b25417592f54d869fe90c28b48e4cecb9926ef9b06d90fb0aec48941
|
||||
F src/attach.c 4a3138bd771d5426ae4344d8d5e900440af29fabc5ec2f39f69a45010dfbccd7
|
||||
F src/alter.c 6beb476095a4cfeb95ebedb2e5e17894d1687b24fddd5b8761a4de120e0392c6
|
||||
F src/analyze.c 41f0b8d638fc2a7309477904ac38e535f2aabea3256da3251e529730e099df77
|
||||
F src/attach.c 4bd5b92633671d3e8ce431153ebb1893b50335818423b5373f3f27969f79769a
|
||||
F src/auth.c a38f3c63c974787ecf75e3213f8cac6568b9a7af7591fb0372ec0517dd16dca8
|
||||
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
|
||||
F src/backup.c 78d3cecfbe28230a3a9a1793e2ead609f469be43e8f486ca996006be551857ab
|
||||
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
|
||||
F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
|
||||
F src/btree.c 44405d03a05496e13b40b3a208bcf941c42c815da90d6ff4b04267a6985e5eb7
|
||||
F src/btree.h 448f15b98ea85dcf7e4eb76f731cadb89636c676ad25dfaac6de77cd66556598
|
||||
F src/btree.c bb23e5470ec0c9b9ae8e17c86cb686bc4112642d8f457bd42b3b3727d5ef78be
|
||||
F src/btree.h febb2e817be499570b7a2e32a9bbb4b607a9234f6b84bb9ae84916d4806e96f2
|
||||
F src/btreeInt.h 620ab4c7235f43572cf3ac2ac8723cbdf68073be4d29da24897c7b77dda5fd96
|
||||
F src/build.c 5fc41458505331bfb0c175f40b9a13cb335f826bed3ae311aaae000c132d7b16
|
||||
F src/build.c 3b3bfa88800739e1f11313dcecfba5ef8e4757b6c929cdf7de9fcfc01002b81f
|
||||
F src/callback.c 36caff1e7eb7deb58572d59c41cee8f064a11d00297616995c5050ea0cfc1288
|
||||
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c 849d4cebe008cfc6e4799b034a172b4eaf8856b100739632a852732ba66eee48
|
||||
F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
|
||||
F src/dbpage.c 8db4c97f630e7d83f884ea75caf1ffd0988c160e9d530194d93721c80821e0f6
|
||||
F src/dbpage.c 4aa7f26198934dbd002e69418220eae3dbc71b010bbac32bd78faf86b52ce6c3
|
||||
F src/dbstat.c edabb82611143727511a45ca0859b8cd037851ebe756ae3db289859dd18b6f91
|
||||
F src/delete.c 4c8c7604277a2041647f96b78f4b9a47858e9217e4fb333d35e7b5ab32c5b57f
|
||||
F src/expr.c 16f90ae2af2a100bc430a89184afde54878d82f18267e8d00bc4f33e695a7c57
|
||||
F src/expr.c 7e257eeffe9553c10a6ac0a1f0177bf740c4da834e7d6e2cbb7d3ebaa3d7f3e1
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c b1da9ef8dc834603bb0d28972378a7ce65897847f9a1e89ab800bbdf24c788ee
|
||||
F src/func.c e2e3c02621a528a472933fd4733a5da635676f1461be73293f6e9f62f18d4eaa
|
||||
F src/func.c 0aaa0b07ac4ba47529f2ce47434a5a367aec123ed2902ece84bfdd8f2b795fa1
|
||||
F src/global.c 9bf034fd560bdd514715170ed8460bb7f823cec113f0569ef3f18a20c7ccd128
|
||||
F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a
|
||||
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
|
||||
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 76b1dc902e4c3930d9a17a40cd8ee2e94b1fd8cce766672caef164a6d5d4df1d
|
||||
F src/insert.c bcacf6a0d277f8fa0e4f9ffecda544a2330ca4478f904cd89564c2dd86d0b16b
|
||||
F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e
|
||||
F src/loadext.c 6aae5739198d96c51ae6eb97c4a5b1744c22ed7a5a565a5399a717780d48a36b
|
||||
F src/main.c 0402e234155e0aad75fe6cd204864f492495be8605a50b4b3d4d72895cced3ce
|
||||
F src/main.c 0087639013e4b62ce16a92e4b0cb6127876224fadeea72016396626078dc8736
|
||||
F src/malloc.c 07295435093ce354c6d9063ac05a2eeae28bd251d2e63c48b3d67c12c76f7e18
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
|
||||
@@ -475,7 +475,7 @@ F src/mutex_noop.c 9d4309c075ba9cc7249e19412d3d62f7f94839c4
|
||||
F src/mutex_unix.c aaf9ebc3f89df28483c52208497a99a02cc3650011422fc9d4c57e4392f7fe58
|
||||
F src/mutex_w32.c 7670d770c94bbfe8289bec9d7f1394c5a00a57c37f892aab6b6612d085255235
|
||||
F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7
|
||||
F src/os.c 1cb0d1d1b3a4267966dee6e292d2b2cdf88e47c0c59cebff27ecafac052dd165
|
||||
F src/os.c 8aeb0b0f40f8f5b0da03fe49706695adaf42d2f516ab95abc72e86c245e119de
|
||||
F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432
|
||||
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
|
||||
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
|
||||
@@ -484,30 +484,30 @@ F src/os_win.c ac29c25cde4cfb4adacc59cdec4aa45698ca0e29164ea127859585ccd9faa354
|
||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||
F src/pager.c 1bb6a57fa0465296a4d6109a1a64610a0e7adde1f3acf3ef539a9d972908ce8f
|
||||
F src/pager.h c571b064df842ec8f2e90855dead9acf4cbe0d1b2c05afe0ef0d0145f7fd0388
|
||||
F src/parse.y 0b81472496809693a139067fea1fe3f14a7be8aa26c8f18bb327034d1252a06a
|
||||
F src/parse.y 9b57f1d0d3d7578ab2917e07ff5d8def4b0aac571113dd7b7cb8108e7194d025
|
||||
F src/pcache.c 135ef0bc6fb2e3b7178d49ab5c9176254c8a691832c1bceb1156b2fbdd0869bd
|
||||
F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170
|
||||
F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880
|
||||
F src/pragma.c c0d13c0e82a9197aef5533d63300c5b0c8a216ae1fd14ada64e1f12f398d7e82
|
||||
F src/pragma.c 71c585f1d26e14b931fa4573f587933d6dfddecd9d9001b0f126f74f7306bf87
|
||||
F src/pragma.h bb83728944b42f6d409c77f5838a8edbdb0fe83046c5496ffc9602b40340a324
|
||||
F src/prepare.c 95a9dba7a5d032039a77775188cb3b6fb17f2fa1a0b7cd915b30b4b823383ffa
|
||||
F src/prepare.c e966ecc97c3671ff0e96227c8c877b83f2d33ea371ee190bbf1698b36b5605c0
|
||||
F src/printf.c 7f6f3cba8e0c49c19e30a1ff4e9aeda6e06814dcbad4b664a69e1b6cb6e7e365
|
||||
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c 14602f46800ba182ea6a490e0f304127d29ac1f724bdadcc639e25d3223fcf6e
|
||||
F src/resolve.c 1f965d00b4c26b7eb886b90c687069f5db0d05157dbc1ca406fe88e990eac671
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c 8d3176c5258cc83942815ebe75b4c1f8dcf62b5e0f4d37373a14ebf23c046f9f
|
||||
F src/shell.c.in c29cb307d6275131e6f9874e0fa73f87acf40a22c4a82faba2059a93b4d294d1
|
||||
F src/sqlite.h.in 63b07f76731f2b1e55c48fdb9f0508dcc6fbe3971010b8612ffd847c3c56d9a1
|
||||
F src/select.c 82aa95aa1cfeadef5ecae1126afff1efca64c49050bbf7116425a8a1d4fc5e6c
|
||||
F src/shell.c.in 8578421c5fb2a972461b2a996f7173646e55e0dbd2a2eee30c8f5dc7d3dbadfd
|
||||
F src/sqlite.h.in 243e0b1d302c237372c06002fe84f731fd22587eccd142d15de834a5296514ff
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 9887b27e69c01e79c2cbe74ef73bf01af5b5703d6a7f0a4371e386d7249cb1c7
|
||||
F src/sqliteInt.h d2bd297dba08f2390a91c31ff775e0964e9663df5b2910a569fe6f830b8b2beb
|
||||
F src/sqliteInt.h c14c850bf0c4dd3860cc5092f140ae9faf93b77737b3febf38454088e1ab3988
|
||||
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
|
||||
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
|
||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||
F src/tclsqlite.c 916a92de77ec5cbe27818ca194d8cf0c58aa7ad5b87527098f6aa5a6068800ce
|
||||
F src/test1.c 51aa5f3030217ca45eb62e90944838794d4faaae7a8f60e0330ae01f30bc997b
|
||||
F src/test1.c b5e21f2ec8386cabb67346c9399603ddb33f76094a0941f280b403aa93631717
|
||||
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
|
||||
F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b
|
||||
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
|
||||
F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6
|
||||
F src/test5.c 328aae2c010c57a9829d255dc099d6899311672d
|
||||
F src/test6.c e8d839fbc552ce044bec8234561a2d5b8819b48e29548ad0ba400471697946a8
|
||||
@@ -520,7 +520,7 @@ F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0
|
||||
F src/test_bestindex.c 78809f11026f18a93fcfd798d9479cba37e1201c830260bf1edc674b2fa9b857
|
||||
F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce
|
||||
F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274
|
||||
F src/test_config.c 097c6189803886a1fb26ec37d8bc62b90512cb53ab79a1fb6d35196c1ec42ded
|
||||
F src/test_config.c 6c3f341ece48020c4ddbce055643a91c653283b3a6853c46ea18d22e5c72847d
|
||||
F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f
|
||||
F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e
|
||||
F src/test_devsym.c 1960abbb234b97e9b920f07e99503fc04b443f62bbc3c6ff2c2cea2133e3b8a2
|
||||
@@ -548,41 +548,43 @@ F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe
|
||||
F src/test_sqllog.c 11e6ce7575f489155c604ac4b439f2ac1d3d5aef
|
||||
F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e
|
||||
F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939
|
||||
F src/test_tclsh.c 58052fe48efe8f579834f4648d239569f2efc6285f5019ebdf0040f58d16238d
|
||||
F src/test_tclsh.c 06317648b0d85a85fd823f7973b55535c59a3156c1ef59394fe511f932cfa78d
|
||||
F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb268dfc
|
||||
F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858
|
||||
F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e
|
||||
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
|
||||
F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1
|
||||
F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a90484215
|
||||
F src/test_window.c 0d19b33e7a262d3b55e85bc0fb84a70f503686cbd769939176162fe866ce7f9e
|
||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
||||
F src/tokenize.c bbde32eac9eb1280f5292bcdfef66f5a57e43176cbf9347e0efab9f75e133f97
|
||||
F src/tokenize.c e0a90f3d594e3db842581543abf157c8e63617655c91ad35d77e339a1bc36ce0
|
||||
F src/treeview.c 2c5c4bc0a443401db5fd621542150452ddf5055d38edd4eef868bc2b6bfb0260
|
||||
F src/trigger.c 4ace6d1d5ba9a89822deb287317f33c810440526eafe185c2d8a48c31df1e995
|
||||
F src/update.c 46dc24c6158446aaab45caee09b6d99327cb479268b83ffeb5b701823da3b67b
|
||||
F src/upsert.c 47edd408cc73f8d3c00a140550d1ad180b407c146285947969dd09874802bf88
|
||||
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
|
||||
F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157
|
||||
F src/vacuum.c 37730af7540033135909ecaee3667dddec043293428d8718546d0d64ba4a5025
|
||||
F src/vdbe.c fcec6e9ad743f92f0a557f0b61728d001581ee96e18c3e5c7d09702afde79b38
|
||||
F src/vdbe.h e3f43bcc27ff30b0f25a6104d0cb5657e1c4b5e1b5cd2dd2216d5bcc2156a746
|
||||
F src/vdbeInt.h 42d3e65ea0c664f6d9bc9a53de645c0baf8566ff0188409ff3b8d2abc327bc17
|
||||
F src/vdbeapi.c 765a0bbe01311626417de6cb743f7f25f9f98435c98a9df4bb0714d11014633d
|
||||
F src/vdbeaux.c b00d35805a2b326d1371ab7ce8f3a95c8af35b1431367ffe482fc2c735d69fb1
|
||||
F src/vacuum.c 36e7d21a20c0bf6ef4ef7c399d192b5239410b7c4d3c1070fba4e30810d0b855
|
||||
F src/vdbe.c 37b942ccdd224dd51bd80312b8d236f27c7c728e76c3f425c50e9d8ecff3b7b4
|
||||
F src/vdbe.h 847735b3e083285aa225d2bf1fe97107a0a2b8942c80d643cdb764990705820d
|
||||
F src/vdbeInt.h 6b5cbd338dc9aaad343fb11b455e47463b0474d9f79710f50e647158941146e0
|
||||
F src/vdbeapi.c e35f813312b0f6e8e2835b357f121e0d1da6d3013bac3e367fe4efd518e7a2ec
|
||||
F src/vdbeaux.c c2d65c763b0811afe409e02e9d0d1f300c6e97892474fc94eec3da71955cd418
|
||||
F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191
|
||||
F src/vdbemem.c 803323406d8623a7619ea5d5f74016697eeaed19c02b98ce9c3013e77dbe1c38
|
||||
F src/vdbemem.c 87b48c0bd68041a61fb3f4e18a1a696f5339d65e572d288a266a602a01863f1a
|
||||
F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2f
|
||||
F src/vdbetrace.c 79d6dbbc479267b255a7de8080eee6e729928a0ef93ed9b0bfa5618875b48392
|
||||
F src/vtab.c 10ea07dec111de6fb0a4fc87a7ffa4c65fdc088a19dbfaf7d6f2b128f2e8eb7b
|
||||
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c aa9cffc7a2bad6b826a86c8562dd4978398720ed41cb8ee7aa9d054eb8b456a0
|
||||
F src/wal.c d44a0811afd2155b1157c38b33141d4ac028fda6232485bed664015bb05819ca
|
||||
F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a
|
||||
F src/walker.c da987a20d40145c0a03c07d8fefcb2ed363becc7680d0500d9c79915591f5b1f
|
||||
F src/where.c 60ec752fcbe9f9e0271ac60548d159a540a1ee47a4f9fedc85e88a3d0e392dd1
|
||||
F src/whereInt.h cbae2bcd37cfebdb7812a8b188cdb19634ced2b9346470d1c270556b0c33ea53
|
||||
F src/wherecode.c 728c7f70731430ccdac807a79969873e1af6968bf1c4745dff3f9dd35f636cc8
|
||||
F src/whereexpr.c e90b2e76dcabc81edff56633bf281bc01d93b71e0c81482dc06925ce39f5844a
|
||||
F src/walker.c ba7225773931760cf60bf22f34d0cce2588df7ce5ce0f215a52eb88234b55ac4
|
||||
F src/where.c a38a485f36335c299f1810bcba11fa3cfe7ac10bc6148e4c13500a9c79d59219
|
||||
F src/whereInt.h b90ef9b9707ef750eab2a7a080c48fb4900315033274689def32d0cf5a81ebe4
|
||||
F src/wherecode.c 3317f2b083a66d3e65a03edf316ade4ccb0a99c9956273282ebb579b95d4ba96
|
||||
F src/whereexpr.c 571618c67a3eb5ce0f1158c2792c1aee9b4a4a264392fc4fb1b35467f80abf9a
|
||||
F src/window.c 7df0313f9b21c904e51226b24c0203aa26be502202f469143bacc5e74ebc0d38
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
|
||||
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
|
||||
@@ -610,6 +612,7 @@ F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93
|
||||
F test/analyzeD.test e50cd0b3e6063216cc0c88a1776e8645dc0bd65a6bb275769cbee33b7fd8d90c
|
||||
F test/analyzeE.test 8684e8ac5722fb97c251887ad97e5d496a98af1d
|
||||
F test/analyzeF.test 9e1a0537949eb5483642b1140a5c39e5b4025939024b935398471fa552f4dabb
|
||||
F test/analyzeG.test 266499f54bb42a56382ac5c8d2efafe7a0d52290395c5bc5b4a1f5254569132f
|
||||
F test/analyzer1.test 459fa02c445ddbf0101a3bad47b34290a35f2e49
|
||||
F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b
|
||||
F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b
|
||||
@@ -967,6 +970,7 @@ F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
|
||||
F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
|
||||
F test/in4.test d2b38cba404bc4320f4fe1b595b3d163f212c068
|
||||
F test/in5.test 7ae37fcd4a5e198291c6ab5f31a5bb3d15397efe8b75a6736d7a95a7b8dd9e08
|
||||
F test/in6.test 62d943a02f722948f4410ee0b53c3cb39acd7c41afb083df8d7004238fe90a20
|
||||
F test/incrblob.test c9b96afc292aeff43d6687bcb09b0280aa599822
|
||||
F test/incrblob2.test a494c9e848560039a23974b9119cfc2cf3ad3bd15cc2694ee6367ae537ef8f1f
|
||||
F test/incrblob3.test d8d036fde015d4a159cd3cbae9d29003b37227a4
|
||||
@@ -992,7 +996,7 @@ F test/indexexpr1.test 635261197bcdc19b9b2c59bbfa7227d525c00e9587faddb2d293c44d2
|
||||
F test/indexexpr2.test 08551aa8956a91582979e17b6d369f321a5cb6ed6d3e952925a3e54e9e7de216
|
||||
F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d
|
||||
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
|
||||
F test/insert.test 38742b5e9601c8f8d76e9b7555f7270288c2d371
|
||||
F test/insert.test 5604b1ff5675cc84c34a5b315792b958f48c32edccc0dafcc81d3b776270b70a
|
||||
F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208
|
||||
F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30
|
||||
F test/insert4.test 46bead5f39e181850ee56adcf49d3a3157c460c52249211714612ac89fe34835
|
||||
@@ -1108,7 +1112,7 @@ F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
|
||||
F test/nan.test 437d40e6d0778b050d7750726c0cbd2c9936b81962926e8f8c48ca698f00f4d1
|
||||
F test/nockpt.test 8c43b25af63b0bd620cf1b003529e37b6f1dc53bd22690e96a1bd73f78dde53a
|
||||
F test/nolock.test f196cf8b8fbea4e2ca345140a2b3f3b0da45c76e
|
||||
F test/normalize.test 501630ab49b0b26b65c74124bf03e3374c1b57fa97aae750f84803609141d167
|
||||
F test/normalize.test 1dedf653ca33b0b55fd0c7967d2861a51f1801a7aa899a02d4c0d7adfcd5acdc
|
||||
F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf
|
||||
F test/notify2.test 2ecabaa1305083856b7c39cf32816b612740c161
|
||||
F test/notify3.test 10ff25cde502e72a92053a2f215d64bece4ef934
|
||||
@@ -1147,7 +1151,8 @@ F test/parser1.test 391b9bf9a229547a129c61ac345ed1a6f5eb1854
|
||||
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
|
||||
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
||||
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
||||
F test/permutations.test 10793f1de89a226fa22dde9ba9398de22571fee1bfb53a935a11be4aa014704f
|
||||
F test/permutations.test 5c2167e03dc55ff697e11bb3abf10c66ba452e4afb2dbd85a2b144048355300e
|
||||
F test/pg_common.tcl 3bf36b30d7b09e5896a1fb0268ace22f2ebfa91d07a422d8ffbf57551d9ce0dc
|
||||
F test/pragma.test 7c8cfc328a1717a95663cf8edb06c52ddfeaf97bb0aee69ae7457132e8d39e7d
|
||||
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
||||
F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed
|
||||
@@ -1172,7 +1177,7 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8
|
||||
F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8
|
||||
F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c
|
||||
F test/reindex.test 44edd3966b474468b823d481eafef0c305022254
|
||||
F test/releasetest.tcl 5f15ab8056799e9a6e26a310d49236d2e774d6a30d0ec74601e18d4ce146b79c x
|
||||
F test/releasetest.tcl 769892f81050b3f59c66f274d478d855159b474ea27019dec82f1215c0b91ef7 x
|
||||
F test/resetdb.test 2107b34a8c437183f48eb833905df43818160a55f4ac69bbaf54f356fb2b27bd
|
||||
F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
|
||||
F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa
|
||||
@@ -1184,7 +1189,7 @@ F test/rowid.test 5b7509f384f4f6fae1af3c8c104c8ca299fea18d
|
||||
F test/rowvalue.test ef851a80f7e6de93b51caca9e4b6b7d2dcd540bbcca7d51860e80435b8b4c0de
|
||||
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
|
||||
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
|
||||
F test/rowvalue4.test cbd1cead27a797d11ec93301fd801c89e97eb1809b3d984b7f16a3876e362eac
|
||||
F test/rowvalue4.test 2b20468da3775aba971caf3158e9696a4d99c69a7623fb495f332a596daebbee
|
||||
F test/rowvalue5.test c81c7d8cf36711ab37675ad7376084ae2a359cb6
|
||||
F test/rowvalue6.test d19b54feb604d5601f8614b15e214e0774c01087
|
||||
F test/rowvalue7.test 5d06ff19d9e6969e574a2e662a531dd0c67801a8
|
||||
@@ -1241,7 +1246,7 @@ F test/sharedA.test 49d87ec54ab640fbbc3786ee3c01de94aaa482a3a9f834ad3fe92770eb69
|
||||
F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e
|
||||
F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939
|
||||
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
|
||||
F test/shell1.test 50154b0c4779df435b9e60ca60104b05f1cc217eab1aa383131359329e73d939
|
||||
F test/shell1.test 707c03fbd07ac506cfb6fa09da4ee22e2b50453c3db2f404694116eb990168f3
|
||||
F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b
|
||||
F test/shell3.test ac8c2b744014c3e9a0e26bfd829ab65f00923dc1a91ffd044863e9423cc91494
|
||||
F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d
|
||||
@@ -1579,13 +1584,14 @@ F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496
|
||||
F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03
|
||||
F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
|
||||
F test/walprotocol.test a112aba0b79e3adeaa485fed09484b32c654e97df58e454aa8489ac2cd57bf84
|
||||
F test/walprotocol2.test ad92f036102f722b2d7f7ca7c1faf72d75f501a50c80a92d7fd87f8b1da6608c
|
||||
F test/walro.test cb438d05ba0d191f10b688e39c4f0cd5b71569a1d1f4440e5bdf3c6880e08c20
|
||||
F test/walro2.test 0e79dd15cbdb4f482c01ea248373669c732414a726b357d04846a816afafb768
|
||||
F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68
|
||||
F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
|
||||
F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
|
||||
F test/walthread.test 14b20fcfa6ae152f5d8e12f5dc8a8a724b7ef189f5d8ef1e2ceab79f2af51747
|
||||
F test/where.test f19ea3fa31c425b04af42c8b192a5b595ee84498df8d27dcd79ec043b25fbbfb
|
||||
F test/where.test 6bfcd29db193b814e5736832ffa899b4ff2969a106b718a79375063d5eb02b29
|
||||
F test/where2.test 478d2170637b9211f593120648858593bf2445a1
|
||||
F test/where3.test 2341a294e17193a6b1699ea7f192124a5286ca6acfcc3f4b06d16c931fbcda2c
|
||||
F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8
|
||||
@@ -1614,6 +1620,16 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2
|
||||
F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
|
||||
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
|
||||
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
|
||||
F test/window1.test 7cb260079cd88d6d6177b0f592686f2bbbc2d10f4f415c8a37cd153eb83c87ca
|
||||
F test/window2.tcl 9bfa842d8a62b0d36dc8c1b5972206393c43847433c6d75940b87fec93ce3143
|
||||
F test/window2.test 8e6d2a1b9f54dfebee1cde961c8590cd87b4db45c50f44947a211e1b63c2a05e
|
||||
F test/window3.tcl 577a3b1ff913208e5248c04dab9df17fd760ce159a752789e26d0cb4a5f91823
|
||||
F test/window3.test 87fb18021903fc4d1659b8b2092aea55d611a9606cfa7272686234e5197c4b31
|
||||
F test/window4.tcl 7cec7e578aa9f78b7265bff8d552cda17a1d8d89f0449d0e74970a527b8846f5
|
||||
F test/window4.test dcd8767869988e0d23d56bc3f8b46ec116de23127b81b5f66fd48d5529072ed1
|
||||
F test/window5.test 8187f46597c90b73e8f96659e893353cbda337479cc582f7a488eab351ba08d3
|
||||
F test/window6.test e8100090c9aa161cad55a6471a82b2ccba83534c8afdf3ec287262bb76c5e5df
|
||||
F test/windowfault.test 97d5fc404308edb579a5a183e294ed874c844ecf01f0a28ba46df3141ebaee1f
|
||||
F test/with1.test 58475190cd8caaeebea8cfeb2a264ec97a0c492b8ffe9ad20cefbb23df462f96
|
||||
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
|
||||
F test/with3.test 5e8ce2c585170bbbc0544e2a01a4941fa0be173ba5265e5c92eb588cd99a232d
|
||||
@@ -1650,7 +1666,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
|
||||
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
|
||||
F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f
|
||||
F tool/lemon.c 33892e2a243865f73e6c6e7cecce3c6eb4bb95db4a3d9d86d146c8064feb92fd
|
||||
F tool/lempar.c bf7db78e7213f1d51516710483eab506fd52bf632c7abfb3e2e9b885c90c03e1
|
||||
F tool/lempar.c a6ebc2024f2d3ab90b93b4ea8bb39b4a320e7a4a4268e1fdef8ae45e8e714593
|
||||
F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
|
||||
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
|
||||
F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
|
||||
@@ -1658,7 +1674,7 @@ F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439
|
||||
F tool/mkautoconfamal.sh 422fc365358a2e92876ffc62971a0ff28ed472fc8bcf9de0df921c736fdeca5e
|
||||
F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x
|
||||
F tool/mkctimec.tcl dd183b73ae1c28249669741c250525f0407e579a70482371668fd5f130d9feb3
|
||||
F tool/mkkeywordhash.c 20f366ad3794e1db42e333a6f35fa41a024f2e3528579c9d58eb13eaa3ab4913
|
||||
F tool/mkkeywordhash.c 1f7f2ac1d9f262c08b67faaca47e6a68262ff39113fa4b27d1db2843b4c33e73
|
||||
F tool/mkmsvcmin.tcl cad0c7b54d7dd92bc87d59f36d4cc4f070eb2e625f14159dc2f5c4204e6a13ea
|
||||
F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
|
||||
F tool/mkopcodeh.tcl 17d1ccc05a926e19e3a9679ea3e4d1aaa15ba753e2fa7363e6e81c80e0ef8b86
|
||||
@@ -1667,8 +1683,8 @@ F tool/mkpragmatab.tcl 2144bc8550a6471a029db262a132d2df4b9e0db61b90398bf64f5b7b3
|
||||
F tool/mkshellc.tcl 1f45770aea226ac093a9c72f718efbb88a2a2833409ec2e1c4cecae4202626f5
|
||||
F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb
|
||||
F tool/mksqlite3c.tcl d532ccbe81234f766bab6e5c0451c99529debcea138caccc1862a9645b2d54f2
|
||||
F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f
|
||||
F tool/mksqlite3c.tcl 7fe318ab6e0f8b6f59a1268b9e61b403a7885418b59c43fce9974228eab5a8da
|
||||
F tool/mksqlite3h.tcl 080873e3856eceb9d289a08a00c4b30f875ea3feadcbece796bd509b1532792c
|
||||
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
|
||||
F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5
|
||||
@@ -1730,10 +1746,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 8a0b730d0ea640d5cf75febe39b2162411a12eb5275765a85882158b5a085681
|
||||
R 68f88270aa2c2118664b882e11dbe18f
|
||||
T *branch * exp-agg-opt
|
||||
T *sym-exp-agg-opt *
|
||||
P 5a12db75d1da65daa92413a6b5892309e9d9479bb3610764e1015abe5bf28dbe
|
||||
R d1c973cef7dd338d2474c5f688523a12
|
||||
T *branch * exp-avoid-expensive-skipscan
|
||||
T *sym-exp-avoid-expensive-skipscan *
|
||||
T -sym-trunk *
|
||||
U dan
|
||||
Z 491386dd047a3b3fa6ba9455da7a08ff
|
||||
Z 68eb1d8d6b0bd6cc041bab15b5fea3f0
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
dce2dfbe1590deb3ef5661230ae2d232bd492441195defbf698ac56f9629211c
|
||||
32924446db0d07e5b2661a6626136a7bcdda629de23f98f3e1e862dd52d2f8a5
|
||||
+3
-3
@@ -74,7 +74,7 @@ static void renameTableFunc(
|
||||
zCsr += len;
|
||||
len = sqlite3GetToken(zCsr, &token);
|
||||
} while( token==TK_SPACE );
|
||||
assert( len>0 );
|
||||
assert( len>0 || !*zCsr );
|
||||
} while( token!=TK_LP && token!=TK_USING );
|
||||
|
||||
zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
|
||||
@@ -142,7 +142,7 @@ static void renameParentFunc(
|
||||
}
|
||||
}
|
||||
|
||||
zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput),
|
||||
zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput);
|
||||
sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
|
||||
sqlite3DbFree(db, zOutput);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ static void renameTriggerFunc(
|
||||
zCsr += len;
|
||||
len = sqlite3GetToken(zCsr, &token);
|
||||
}while( token==TK_SPACE );
|
||||
assert( len>0 );
|
||||
assert( len>0 || !*zCsr );
|
||||
|
||||
/* Variable 'dist' stores the number of tokens read since the most
|
||||
** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
|
||||
|
||||
@@ -485,6 +485,7 @@ static const FuncDef statInitFuncdef = {
|
||||
0, /* pNext */
|
||||
statInit, /* xSFunc */
|
||||
0, /* xFinalize */
|
||||
0, 0, /* xValue, xInverse */
|
||||
"stat_init", /* zName */
|
||||
{0}
|
||||
};
|
||||
@@ -801,6 +802,7 @@ static const FuncDef statPushFuncdef = {
|
||||
0, /* pNext */
|
||||
statPush, /* xSFunc */
|
||||
0, /* xFinalize */
|
||||
0, 0, /* xValue, xInverse */
|
||||
"stat_push", /* zName */
|
||||
{0}
|
||||
};
|
||||
@@ -952,6 +954,7 @@ static const FuncDef statGetFuncdef = {
|
||||
0, /* pNext */
|
||||
statGet, /* xSFunc */
|
||||
0, /* xFinalize */
|
||||
0, 0, /* xValue, xInverse */
|
||||
"stat_get", /* zName */
|
||||
{0}
|
||||
};
|
||||
|
||||
@@ -414,6 +414,7 @@ void sqlite3Detach(Parse *pParse, Expr *pDbname){
|
||||
0, /* pNext */
|
||||
detachFunc, /* xSFunc */
|
||||
0, /* xFinalize */
|
||||
0, 0, /* xValue, xInverse */
|
||||
"sqlite_detach", /* zName */
|
||||
{0}
|
||||
};
|
||||
@@ -433,6 +434,7 @@ void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
|
||||
0, /* pNext */
|
||||
attachFunc, /* xSFunc */
|
||||
0, /* xFinalize */
|
||||
0, 0, /* xValue, xInverse */
|
||||
"sqlite_attach", /* zName */
|
||||
{0}
|
||||
};
|
||||
|
||||
+3
-3
@@ -382,7 +382,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
|
||||
** before this function exits.
|
||||
*/
|
||||
if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
|
||||
rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
|
||||
rc = sqlite3BtreeBeginTrans(p->pSrc, 0, 0);
|
||||
bCloseTrans = 1;
|
||||
}
|
||||
|
||||
@@ -398,10 +398,10 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
|
||||
|
||||
/* Lock the destination database, if it is not locked already. */
|
||||
if( SQLITE_OK==rc && p->bDestLocked==0
|
||||
&& SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2))
|
||||
&& SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2,
|
||||
(int*)&p->iDestSchema))
|
||||
){
|
||||
p->bDestLocked = 1;
|
||||
sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);
|
||||
}
|
||||
|
||||
/* Do not allow backup if the destination database is in WAL mode
|
||||
|
||||
+38
-10
@@ -3300,7 +3300,7 @@ int sqlite3BtreeNewDb(Btree *p){
|
||||
** when A already has a read lock, we encourage A to give up and let B
|
||||
** proceed.
|
||||
*/
|
||||
int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
|
||||
int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
|
||||
BtShared *pBt = p->pBt;
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
@@ -3428,12 +3428,17 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
|
||||
|
||||
|
||||
trans_begun:
|
||||
if( rc==SQLITE_OK && wrflag ){
|
||||
/* This call makes sure that the pager has the correct number of
|
||||
** open savepoints. If the second parameter is greater than 0 and
|
||||
** the sub-journal is not already open, then it will be opened here.
|
||||
*/
|
||||
rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
|
||||
if( rc==SQLITE_OK ){
|
||||
if( pSchemaVersion ){
|
||||
*pSchemaVersion = get4byte(&pBt->pPage1->aData[40]);
|
||||
}
|
||||
if( wrflag ){
|
||||
/* This call makes sure that the pager has the correct number of
|
||||
** open savepoints. If the second parameter is greater than 0 and
|
||||
** the sub-journal is not already open, then it will be opened here.
|
||||
*/
|
||||
rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
|
||||
}
|
||||
}
|
||||
|
||||
btreeIntegrity(p);
|
||||
@@ -5180,6 +5185,20 @@ int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is a no-op if cursor pCur does not point to a valid row.
|
||||
** Otherwise, if pCur is valid, configure it so that the next call to
|
||||
** sqlite3BtreeNext() is a no-op.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
void sqlite3BtreeSkipNext(BtCursor *pCur){
|
||||
if( pCur->eState==CURSOR_VALID ){
|
||||
pCur->eState = CURSOR_SKIPNEXT;
|
||||
pCur->skipNext = 1;
|
||||
}
|
||||
}
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
|
||||
/* Move the cursor to the last entry in the table. Return SQLITE_OK
|
||||
** on success. Set *pRes to 0 if the cursor actually points to something
|
||||
** or set *pRes to 1 if the table is empty.
|
||||
@@ -5584,7 +5603,16 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){
|
||||
|
||||
pPage = pCur->pPage;
|
||||
idx = ++pCur->ix;
|
||||
assert( pPage->isInit );
|
||||
if( !pPage->isInit ){
|
||||
/* The only known way for this to happen is for there to be a
|
||||
** recursive SQL function that does a DELETE operation as part of a
|
||||
** SELECT which deletes content out from under an active cursor
|
||||
** in a corrupt database file where the table being DELETE-ed from
|
||||
** has pages in common with the table being queried. See TH3
|
||||
** module cov1/btree78.test testcase 220 (2018-06-08) for an
|
||||
** example. */
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
|
||||
/* If the database file is corrupt, it is possible for the value of idx
|
||||
** to be invalid here. This can only occur if a second cursor modifies
|
||||
@@ -10084,11 +10112,11 @@ int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){
|
||||
pBt->btsFlags &= ~BTS_NO_WAL;
|
||||
if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;
|
||||
|
||||
rc = sqlite3BtreeBeginTrans(pBtree, 0);
|
||||
rc = sqlite3BtreeBeginTrans(pBtree, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
u8 *aData = pBt->pPage1->aData;
|
||||
if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){
|
||||
rc = sqlite3BtreeBeginTrans(pBtree, 2);
|
||||
rc = sqlite3BtreeBeginTrans(pBtree, 2, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
|
||||
if( rc==SQLITE_OK ){
|
||||
|
||||
+4
-1
@@ -78,7 +78,7 @@ int sqlite3BtreeGetOptimalReserve(Btree*);
|
||||
int sqlite3BtreeGetReserveNoMutex(Btree *p);
|
||||
int sqlite3BtreeSetAutoVacuum(Btree *, int);
|
||||
int sqlite3BtreeGetAutoVacuum(Btree *);
|
||||
int sqlite3BtreeBeginTrans(Btree*,int);
|
||||
int sqlite3BtreeBeginTrans(Btree*,int,int*);
|
||||
int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
|
||||
int sqlite3BtreeCommitPhaseTwo(Btree*, int);
|
||||
int sqlite3BtreeCommit(Btree*);
|
||||
@@ -301,6 +301,9 @@ struct BtreePayload {
|
||||
int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
|
||||
int flags, int seekResult);
|
||||
int sqlite3BtreeFirst(BtCursor*, int *pRes);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
void sqlite3BtreeSkipNext(BtCursor*);
|
||||
#endif
|
||||
int sqlite3BtreeLast(BtCursor*, int *pRes);
|
||||
int sqlite3BtreeNext(BtCursor*, int flags);
|
||||
int sqlite3BtreeEof(BtCursor*);
|
||||
|
||||
+27
@@ -1695,6 +1695,31 @@ static int hasColumn(const i16 *aiCol, int nCol, int x){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Recompute the colNotIdxed field of the Index.
|
||||
**
|
||||
** colNotIdxed is a bitmask that has a 0 bit representing each indexed
|
||||
** columns that are within the first 63 columns of the table. The
|
||||
** high-order bit of colNotIdxed is always 1. All unindexed columns
|
||||
** of the table have a 1.
|
||||
**
|
||||
** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask
|
||||
** to determine if the index is covering index.
|
||||
*/
|
||||
static void recomputeColumnsNotIndexed(Index *pIdx){
|
||||
Bitmask m = 0;
|
||||
int j;
|
||||
for(j=pIdx->nColumn-1; j>=0; j--){
|
||||
int x = pIdx->aiColumn[j];
|
||||
if( x>=0 ){
|
||||
testcase( x==BMS-1 );
|
||||
testcase( x==BMS-2 );
|
||||
if( x<BMS-1 ) m |= MASKBIT(x);
|
||||
}
|
||||
}
|
||||
pIdx->colNotIdxed = ~m;
|
||||
assert( (pIdx->colNotIdxed>>63)==1 );
|
||||
}
|
||||
|
||||
/*
|
||||
** This routine runs at the end of parsing a CREATE TABLE statement that
|
||||
** has a WITHOUT ROWID clause. The job of this routine is to convert both
|
||||
@@ -1843,6 +1868,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
|
||||
}else{
|
||||
pPk->nColumn = pTab->nCol;
|
||||
}
|
||||
recomputeColumnsNotIndexed(pPk);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3276,6 +3302,7 @@ void sqlite3CreateIndex(
|
||||
** it as a covering index */
|
||||
assert( HasRowid(pTab)
|
||||
|| pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );
|
||||
recomputeColumnsNotIndexed(pIndex);
|
||||
if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
|
||||
pIndex->isCovering = 1;
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
|
||||
+1
-1
@@ -369,7 +369,7 @@ static int dbpageBegin(sqlite3_vtab *pVtab){
|
||||
int i;
|
||||
for(i=0; i<db->nDb; i++){
|
||||
Btree *pBt = db->aDb[i].pBt;
|
||||
if( pBt ) sqlite3BtreeBeginTrans(pBt, 1);
|
||||
if( pBt ) sqlite3BtreeBeginTrans(pBt, 1, 0);
|
||||
}
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
+36
-2
@@ -1063,6 +1063,9 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
|
||||
}else{
|
||||
sqlite3ExprListDelete(db, p->x.pList);
|
||||
}
|
||||
if( !ExprHasProperty(p, EP_Reduced) ){
|
||||
sqlite3WindowDelete(db, p->pWin);
|
||||
}
|
||||
}
|
||||
if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
|
||||
if( !ExprHasProperty(p, EP_Static) ){
|
||||
@@ -1111,7 +1114,7 @@ static int exprStructSize(Expr *p){
|
||||
** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size
|
||||
** (unreduced) Expr objects as they or originally constructed by the parser.
|
||||
** During expression analysis, extra information is computed and moved into
|
||||
** later parts of teh Expr object and that extra information might get chopped
|
||||
** later parts of the Expr object and that extra information might get chopped
|
||||
** off if the expression is reduced. Note also that it does not work to
|
||||
** make an EXPRDUP_REDUCE copy of a reduced expression. It is only legal
|
||||
** to reduce a pristine expression tree from the parser. The implementation
|
||||
@@ -1123,7 +1126,11 @@ static int dupedExprStructSize(Expr *p, int flags){
|
||||
assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
|
||||
assert( EXPR_FULLSIZE<=0xfff );
|
||||
assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
|
||||
if( 0==flags || p->op==TK_SELECT_COLUMN ){
|
||||
if( 0==flags || p->op==TK_SELECT_COLUMN
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
|| p->pWin
|
||||
#endif
|
||||
){
|
||||
nSize = EXPR_FULLSIZE;
|
||||
}else{
|
||||
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
|
||||
@@ -1263,6 +1270,13 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){
|
||||
*pzBuffer = zAlloc;
|
||||
}
|
||||
}else{
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( ExprHasProperty(p, EP_Reduced|EP_TokenOnly) ){
|
||||
pNew->pWin = 0;
|
||||
}else{
|
||||
pNew->pWin = sqlite3WindowDup(db, pNew, p->pWin);
|
||||
}
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
|
||||
if( pNew->op==TK_SELECT_COLUMN ){
|
||||
pNew->pLeft = p->pLeft;
|
||||
@@ -1469,6 +1483,10 @@ Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){
|
||||
pNew->addrOpenEphm[1] = -1;
|
||||
pNew->nSelectRow = p->nSelectRow;
|
||||
pNew->pWith = withDup(db, p->pWith);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
pNew->pWin = 0;
|
||||
pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
|
||||
#endif
|
||||
sqlite3SelectSetName(pNew, p->zSelName);
|
||||
*pp = pNew;
|
||||
pp = &pNew->pPrior;
|
||||
@@ -3200,6 +3218,13 @@ void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int iReg){
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
/* Add a SetTabCol opcode for run-time verification that the column
|
||||
** cache is working correctly.
|
||||
*/
|
||||
sqlite3VdbeAddOp3(pParse->pVdbe, OP_SetTabCol, iTab, iCol, iReg);
|
||||
#endif
|
||||
|
||||
/* If the cache is already full, delete the least recently used entry */
|
||||
if( pParse->nColCache>=SQLITE_N_COLCACHE ){
|
||||
minLru = 0x7fffffff;
|
||||
@@ -3373,6 +3398,9 @@ int sqlite3ExprCodeGetColumn(
|
||||
if( p->iTable==iTable && p->iColumn==iColumn ){
|
||||
p->lru = pParse->iCacheCnt++;
|
||||
sqlite3ExprCachePinRegister(pParse, p->iReg);
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
sqlite3VdbeAddOp3(v, OP_VerifyTabCol, iTable, iColumn, p->iReg);
|
||||
#endif
|
||||
return p->iReg;
|
||||
}
|
||||
}
|
||||
@@ -3778,6 +3806,12 @@ expr_code_doover:
|
||||
u8 enc = ENC(db); /* The text encoding used by this database */
|
||||
CollSeq *pColl = 0; /* A collating sequence */
|
||||
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) && pExpr->pWin ){
|
||||
return pExpr->pWin->regResult;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
|
||||
/* SQL functions can be expensive. So try to move constant functions
|
||||
** out of the inner loop, even if that means an extra OP_Copy. */
|
||||
|
||||
+119
-17
@@ -1513,6 +1513,31 @@ static void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){
|
||||
SumCtx *p;
|
||||
int type;
|
||||
assert( argc==1 );
|
||||
UNUSED_PARAMETER(argc);
|
||||
p = sqlite3_aggregate_context(context, sizeof(*p));
|
||||
type = sqlite3_value_numeric_type(argv[0]);
|
||||
if( p && type!=SQLITE_NULL ){
|
||||
p->cnt--;
|
||||
if( type==SQLITE_INTEGER ){
|
||||
i64 v = sqlite3_value_int64(argv[0]);
|
||||
p->rSum -= v;
|
||||
if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, -1*v) ){
|
||||
p->overflow = 1;
|
||||
}
|
||||
}else{
|
||||
p->rSum -= sqlite3_value_double(argv[0]);
|
||||
p->approx = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define sumInverse 0
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
static void sumFinalize(sqlite3_context *context){
|
||||
SumCtx *p;
|
||||
p = sqlite3_aggregate_context(context, 0);
|
||||
@@ -1547,6 +1572,9 @@ static void totalFinalize(sqlite3_context *context){
|
||||
typedef struct CountCtx CountCtx;
|
||||
struct CountCtx {
|
||||
i64 n;
|
||||
#ifdef SQLITE_DEBUG
|
||||
int bInverse; /* True if xInverse() ever called */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1564,7 +1592,7 @@ static void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||
** sure it still operates correctly, verify that its count agrees with our
|
||||
** internal count when using count(*) and when the total count can be
|
||||
** expressed as a 32-bit integer. */
|
||||
assert( argc==1 || p==0 || p->n>0x7fffffff
|
||||
assert( argc==1 || p==0 || p->n>0x7fffffff || p->bInverse
|
||||
|| p->n==sqlite3_aggregate_count(context) );
|
||||
#endif
|
||||
}
|
||||
@@ -1573,6 +1601,20 @@ static void countFinalize(sqlite3_context *context){
|
||||
p = sqlite3_aggregate_context(context, 0);
|
||||
sqlite3_result_int64(context, p ? p->n : 0);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
static void countInverse(sqlite3_context *ctx, int argc, sqlite3_value **argv){
|
||||
CountCtx *p;
|
||||
p = sqlite3_aggregate_context(ctx, sizeof(*p));
|
||||
if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){
|
||||
p->n--;
|
||||
#ifdef SQLITE_DEBUG
|
||||
p->bInverse = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define countInverse 0
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
|
||||
/*
|
||||
** Routines to implement min() and max() aggregate functions.
|
||||
@@ -1589,7 +1631,7 @@ static void minmaxStep(
|
||||
pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));
|
||||
if( !pBest ) return;
|
||||
|
||||
if( sqlite3_value_type(argv[0])==SQLITE_NULL ){
|
||||
if( sqlite3_value_type(pArg)==SQLITE_NULL ){
|
||||
if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);
|
||||
}else if( pBest->flags ){
|
||||
int max;
|
||||
@@ -1615,16 +1657,26 @@ static void minmaxStep(
|
||||
sqlite3VdbeMemCopy(pBest, pArg);
|
||||
}
|
||||
}
|
||||
static void minMaxFinalize(sqlite3_context *context){
|
||||
static void minMaxValueFinalize(sqlite3_context *context, int bValue){
|
||||
sqlite3_value *pRes;
|
||||
pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
|
||||
if( pRes ){
|
||||
if( pRes->flags ){
|
||||
sqlite3_result_value(context, pRes);
|
||||
}
|
||||
sqlite3VdbeMemRelease(pRes);
|
||||
if( bValue==0 ) sqlite3VdbeMemRelease(pRes);
|
||||
}
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
static void minMaxValue(sqlite3_context *context){
|
||||
return minMaxValueFinalize(context, 1);
|
||||
}
|
||||
#else
|
||||
# define minMaxValue 0
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
static void minMaxFinalize(sqlite3_context *context){
|
||||
return minMaxValueFinalize(context, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
** group_concat(EXPR, ?SEPARATOR?)
|
||||
@@ -1661,6 +1713,34 @@ static void groupConcatStep(
|
||||
if( zVal ) sqlite3_str_append(pAccum, zVal, nVal);
|
||||
}
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
static void groupConcatInverse(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
int n;
|
||||
assert( argc==1 || argc==2 );
|
||||
StrAccum *pAccum;
|
||||
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
||||
pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
|
||||
if( pAccum ){
|
||||
n = sqlite3_value_bytes(argv[0]);
|
||||
if( argc==2 ){
|
||||
n += sqlite3_value_bytes(argv[1]);
|
||||
}
|
||||
if( n>=pAccum->nChar ){
|
||||
pAccum->nChar = 0;
|
||||
}else{
|
||||
pAccum->nChar -= n;
|
||||
memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar);
|
||||
}
|
||||
if( pAccum->nChar==0 ) pAccum->mxAlloc = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define groupConcatInverse 0
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
static void groupConcatFinalize(sqlite3_context *context){
|
||||
StrAccum *pAccum;
|
||||
pAccum = sqlite3_aggregate_context(context, 0);
|
||||
@@ -1675,6 +1755,24 @@ static void groupConcatFinalize(sqlite3_context *context){
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
static void groupConcatValue(sqlite3_context *context){
|
||||
sqlite3_str *pAccum;
|
||||
pAccum = (sqlite3_str*)sqlite3_aggregate_context(context, 0);
|
||||
if( pAccum ){
|
||||
if( pAccum->accError==SQLITE_TOOBIG ){
|
||||
sqlite3_result_error_toobig(context);
|
||||
}else if( pAccum->accError==SQLITE_NOMEM ){
|
||||
sqlite3_result_error_nomem(context);
|
||||
}else{
|
||||
const char *zText = sqlite3_str_value(pAccum);
|
||||
sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define groupConcatValue 0
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
|
||||
/*
|
||||
** This routine does per-connection function registration. Most
|
||||
@@ -1712,10 +1810,10 @@ void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){
|
||||
}else{
|
||||
pInfo = (struct compareInfo*)&likeInfoNorm;
|
||||
}
|
||||
sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);
|
||||
sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);
|
||||
sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);
|
||||
sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);
|
||||
sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8,
|
||||
(struct compareInfo*)&globInfo, likeFunc, 0, 0, 0);
|
||||
(struct compareInfo*)&globInfo, likeFunc, 0, 0, 0, 0, 0);
|
||||
setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
|
||||
setLikeOptFlag(db, "like",
|
||||
caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
|
||||
@@ -1824,11 +1922,11 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
FUNCTION(trim, 2, 3, 0, trimFunc ),
|
||||
FUNCTION(min, -1, 0, 1, minmaxFunc ),
|
||||
FUNCTION(min, 0, 0, 1, 0 ),
|
||||
AGGREGATE2(min, 1, 0, 1, minmaxStep, minMaxFinalize,
|
||||
WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
|
||||
SQLITE_FUNC_MINMAX ),
|
||||
FUNCTION(max, -1, 1, 1, minmaxFunc ),
|
||||
FUNCTION(max, 0, 1, 1, 0 ),
|
||||
AGGREGATE2(max, 1, 1, 1, minmaxStep, minMaxFinalize,
|
||||
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
|
||||
SQLITE_FUNC_MINMAX ),
|
||||
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
|
||||
FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
|
||||
@@ -1859,14 +1957,17 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ),
|
||||
FUNCTION(substr, 2, 0, 0, substrFunc ),
|
||||
FUNCTION(substr, 3, 0, 0, substrFunc ),
|
||||
AGGREGATE(sum, 1, 0, 0, sumStep, sumFinalize ),
|
||||
AGGREGATE(total, 1, 0, 0, sumStep, totalFinalize ),
|
||||
AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ),
|
||||
AGGREGATE2(count, 0, 0, 0, countStep, countFinalize,
|
||||
SQLITE_FUNC_COUNT ),
|
||||
AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
|
||||
AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
|
||||
AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
|
||||
WAGGREGATE(sum, 1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0),
|
||||
WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0),
|
||||
WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0),
|
||||
WAGGREGATE(count, 0,0,0, countStep,
|
||||
countFinalize, countFinalize, countInverse, SQLITE_FUNC_COUNT ),
|
||||
WAGGREGATE(count, 1,0,0, countStep,
|
||||
countFinalize, countFinalize, countInverse, 0 ),
|
||||
WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep,
|
||||
groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
|
||||
WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
|
||||
groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
|
||||
|
||||
LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
|
||||
#ifdef SQLITE_CASE_SENSITIVE_LIKE
|
||||
@@ -1886,6 +1987,7 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
#ifndef SQLITE_OMIT_ALTERTABLE
|
||||
sqlite3AlterFunctions();
|
||||
#endif
|
||||
sqlite3WindowFunctions();
|
||||
#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
|
||||
sqlite3AnalyzeFunctions();
|
||||
#endif
|
||||
|
||||
@@ -1533,6 +1533,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
sqlite3VdbeVerifyAbortable(v, onError);
|
||||
sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
|
||||
VdbeCoverage(v);
|
||||
sqlite3ExprCachePush(pParse);
|
||||
|
||||
switch( onError ){
|
||||
default: {
|
||||
@@ -1609,6 +1610,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
break;
|
||||
}
|
||||
}
|
||||
sqlite3ExprCachePop(pParse);
|
||||
sqlite3VdbeResolveLabel(v, addrRowidOk);
|
||||
if( sAddr.ipkTop ){
|
||||
sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
|
||||
|
||||
+71
-26
@@ -1683,6 +1683,8 @@ int sqlite3CreateFunc(
|
||||
void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void (*xValue)(sqlite3_context*),
|
||||
void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
|
||||
FuncDestructor *pDestructor
|
||||
){
|
||||
FuncDef *p;
|
||||
@@ -1694,6 +1696,7 @@ int sqlite3CreateFunc(
|
||||
(xSFunc && (xFinal || xStep)) ||
|
||||
(!xSFunc && (xFinal && !xStep)) ||
|
||||
(!xSFunc && (!xFinal && xStep)) ||
|
||||
((xValue || xInverse) && (!xStep || !xFinal || !xValue || !xInverse)) ||
|
||||
(nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||
|
||||
(255<(nName = sqlite3Strlen30( zFunctionName))) ){
|
||||
return SQLITE_MISUSE_BKPT;
|
||||
@@ -1716,10 +1719,10 @@ int sqlite3CreateFunc(
|
||||
}else if( enc==SQLITE_ANY ){
|
||||
int rc;
|
||||
rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,
|
||||
pUserData, xSFunc, xStep, xFinal, pDestructor);
|
||||
pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,
|
||||
pUserData, xSFunc, xStep, xFinal, pDestructor);
|
||||
pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
@@ -1765,38 +1768,32 @@ int sqlite3CreateFunc(
|
||||
testcase( p->funcFlags & SQLITE_DETERMINISTIC );
|
||||
p->xSFunc = xSFunc ? xSFunc : xStep;
|
||||
p->xFinalize = xFinal;
|
||||
p->xValue = xValue;
|
||||
p->xInverse = xInverse;
|
||||
p->pUserData = pUserData;
|
||||
p->nArg = (u16)nArg;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Create new user functions.
|
||||
** Worker function used by utf-8 APIs that create new functions:
|
||||
**
|
||||
** sqlite3_create_function()
|
||||
** sqlite3_create_function_v2()
|
||||
** sqlite3_create_window_function()
|
||||
*/
|
||||
int sqlite3_create_function(
|
||||
static int createFunctionApi(
|
||||
sqlite3 *db,
|
||||
const char *zFunc,
|
||||
int nArg,
|
||||
int enc,
|
||||
void *p,
|
||||
void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context*)
|
||||
){
|
||||
return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xSFunc, xStep,
|
||||
xFinal, 0);
|
||||
}
|
||||
|
||||
int sqlite3_create_function_v2(
|
||||
sqlite3 *db,
|
||||
const char *zFunc,
|
||||
int nArg,
|
||||
int enc,
|
||||
void *p,
|
||||
void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xSFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void (*xDestroy)(void *)
|
||||
void (*xValue)(sqlite3_context*),
|
||||
void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
|
||||
void(*xDestroy)(void*)
|
||||
){
|
||||
int rc = SQLITE_ERROR;
|
||||
FuncDestructor *pArg = 0;
|
||||
@@ -1818,7 +1815,9 @@ int sqlite3_create_function_v2(
|
||||
pArg->xDestroy = xDestroy;
|
||||
pArg->pUserData = p;
|
||||
}
|
||||
rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, pArg);
|
||||
rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p,
|
||||
xSFunc, xStep, xFinal, xValue, xInverse, pArg
|
||||
);
|
||||
if( pArg && pArg->nRef==0 ){
|
||||
assert( rc!=SQLITE_OK );
|
||||
xDestroy(p);
|
||||
@@ -1831,6 +1830,52 @@ int sqlite3_create_function_v2(
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Create new user functions.
|
||||
*/
|
||||
int sqlite3_create_function(
|
||||
sqlite3 *db,
|
||||
const char *zFunc,
|
||||
int nArg,
|
||||
int enc,
|
||||
void *p,
|
||||
void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context*)
|
||||
){
|
||||
return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,
|
||||
xFinal, 0, 0, 0);
|
||||
}
|
||||
int sqlite3_create_function_v2(
|
||||
sqlite3 *db,
|
||||
const char *zFunc,
|
||||
int nArg,
|
||||
int enc,
|
||||
void *p,
|
||||
void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void (*xDestroy)(void *)
|
||||
){
|
||||
return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,
|
||||
xFinal, 0, 0, xDestroy);
|
||||
}
|
||||
int sqlite3_create_window_function(
|
||||
sqlite3 *db,
|
||||
const char *zFunc,
|
||||
int nArg,
|
||||
int enc,
|
||||
void *p,
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void (*xValue)(sqlite3_context*),
|
||||
void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*xDestroy)(void *)
|
||||
){
|
||||
return createFunctionApi(db, zFunc, nArg, enc, p, 0, xStep,
|
||||
xFinal, xValue, xInverse, xDestroy);
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_UTF16
|
||||
int sqlite3_create_function16(
|
||||
sqlite3 *db,
|
||||
@@ -1851,7 +1896,7 @@ int sqlite3_create_function16(
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
assert( !db->mallocFailed );
|
||||
zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
|
||||
rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0);
|
||||
rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0,0,0);
|
||||
sqlite3DbFree(db, zFunc8);
|
||||
rc = sqlite3ApiExit(db, rc);
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
@@ -4115,7 +4160,7 @@ int sqlite3_snapshot_get(
|
||||
if( iDb==0 || iDb>1 ){
|
||||
Btree *pBt = db->aDb[iDb].pBt;
|
||||
if( 0==sqlite3BtreeIsInTrans(pBt) ){
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0);
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
|
||||
}
|
||||
@@ -4153,7 +4198,7 @@ int sqlite3_snapshot_open(
|
||||
if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
|
||||
rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0);
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
|
||||
sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);
|
||||
}
|
||||
}
|
||||
@@ -4185,7 +4230,7 @@ int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb){
|
||||
if( iDb==0 || iDb>1 ){
|
||||
Btree *pBt = db->aDb[iDb].pBt;
|
||||
if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0);
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));
|
||||
sqlite3BtreeCommit(pBt);
|
||||
|
||||
@@ -410,9 +410,12 @@ int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
|
||||
** Unregister a VFS so that it is no longer accessible.
|
||||
*/
|
||||
int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
|
||||
#if SQLITE_THREADSAFE
|
||||
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
|
||||
MUTEX_LOGIC(sqlite3_mutex *mutex;)
|
||||
#ifndef SQLITE_OMIT_AUTOINIT
|
||||
int rc = sqlite3_initialize();
|
||||
if( rc ) return rc;
|
||||
#endif
|
||||
MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
|
||||
sqlite3_mutex_enter(mutex);
|
||||
vfsUnlink(pVfs);
|
||||
sqlite3_mutex_leave(mutex);
|
||||
|
||||
+135
-8
@@ -99,6 +99,8 @@
|
||||
*/
|
||||
struct TrigEvent { int a; IdList * b; };
|
||||
|
||||
struct FrameBound { int eType; Expr *pExpr; };
|
||||
|
||||
/*
|
||||
** Disable lookaside memory allocation for objects that might be
|
||||
** shared across database connections.
|
||||
@@ -209,11 +211,14 @@ columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,&A,&Y);}
|
||||
CONFLICT DATABASE DEFERRED DESC DETACH DO
|
||||
EACH END EXCLUSIVE EXPLAIN FAIL FOR
|
||||
IGNORE IMMEDIATE INITIALLY INSTEAD LIKE_KW MATCH NO PLAN
|
||||
QUERY KEY OF OFFSET PRAGMA RAISE RECURSIVE RELEASE REPLACE RESTRICT ROW
|
||||
QUERY KEY OF OFFSET PRAGMA RAISE RECURSIVE RELEASE REPLACE RESTRICT ROW ROWS
|
||||
ROLLBACK SAVEPOINT TEMP TRIGGER VACUUM VIEW VIRTUAL WITH WITHOUT
|
||||
%ifdef SQLITE_OMIT_COMPOUND_SELECT
|
||||
EXCEPT INTERSECT UNION
|
||||
%endif SQLITE_OMIT_COMPOUND_SELECT
|
||||
%ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
CURRENT FOLLOWING PARTITION PRECEDING RANGE UNBOUNDED
|
||||
%endif SQLITE_OMIT_WINDOWFUNC
|
||||
REINDEX RENAME CTIME_KW IF
|
||||
.
|
||||
%wildcard ANY.
|
||||
@@ -527,11 +532,22 @@ multiselect_op(A) ::= UNION ALL. {A = TK_ALL;}
|
||||
multiselect_op(A) ::= EXCEPT|INTERSECT(OP). {A = @OP; /*A-overwrites-OP*/}
|
||||
%endif SQLITE_OMIT_COMPOUND_SELECT
|
||||
oneselect(A) ::= SELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y)
|
||||
groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). {
|
||||
groupby_opt(P) having_opt(Q)
|
||||
%ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
windowdefn_opt(R)
|
||||
%endif
|
||||
orderby_opt(Z) limit_opt(L). {
|
||||
#if SELECTTRACE_ENABLED
|
||||
Token s = S; /*A-overwrites-S*/
|
||||
#endif
|
||||
A = sqlite3SelectNew(pParse,W,X,Y,P,Q,Z,D,L);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( A ){
|
||||
A->pWinDefn = R;
|
||||
}else{
|
||||
sqlite3WindowListDelete(pParse->db, R);
|
||||
}
|
||||
#endif // SQLITE_OMIT_WINDOWFUNC
|
||||
#if SELECTTRACE_ENABLED
|
||||
/* Populate the Select.zSelName[] string that is used to help with
|
||||
** query planner debugging, to differentiate between multiple Select
|
||||
@@ -1003,17 +1019,27 @@ expr(A) ::= CAST LP expr(E) AS typetoken(T) RP. {
|
||||
sqlite3ExprAttachSubtrees(pParse->db, A, E, 0);
|
||||
}
|
||||
%endif SQLITE_OMIT_CAST
|
||||
expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP. {
|
||||
expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP
|
||||
%ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
over_opt(Z)
|
||||
%endif
|
||||
. {
|
||||
if( Y && Y->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
|
||||
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X);
|
||||
}
|
||||
A = sqlite3ExprFunction(pParse, Y, &X);
|
||||
sqlite3WindowAttach(pParse, A, Z);
|
||||
if( D==SF_Distinct && A ){
|
||||
A->flags |= EP_Distinct;
|
||||
}
|
||||
}
|
||||
expr(A) ::= id(X) LP STAR RP. {
|
||||
expr(A) ::= id(X) LP STAR RP
|
||||
%ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
over_opt(Z)
|
||||
%endif
|
||||
. {
|
||||
A = sqlite3ExprFunction(pParse, 0, &X);
|
||||
sqlite3WindowAttach(pParse, A, Z);
|
||||
}
|
||||
term(A) ::= CTIME_KW(OP). {
|
||||
A = sqlite3ExprFunction(pParse, 0, &OP);
|
||||
@@ -1101,10 +1127,10 @@ expr(A) ::= NOT(B) expr(X).
|
||||
{A = sqlite3PExpr(pParse, @B, X, 0);/*A-overwrites-B*/}
|
||||
expr(A) ::= BITNOT(B) expr(X).
|
||||
{A = sqlite3PExpr(pParse, @B, X, 0);/*A-overwrites-B*/}
|
||||
expr(A) ::= MINUS expr(X). [BITNOT]
|
||||
{A = sqlite3PExpr(pParse, TK_UMINUS, X, 0);}
|
||||
expr(A) ::= PLUS expr(X). [BITNOT]
|
||||
{A = sqlite3PExpr(pParse, TK_UPLUS, X, 0);}
|
||||
expr(A) ::= PLUS|MINUS(B) expr(X). [BITNOT] {
|
||||
A = sqlite3PExpr(pParse, @B==TK_PLUS ? TK_UPLUS : TK_UMINUS, X, 0);
|
||||
/*A-overwrites-B*/
|
||||
}
|
||||
|
||||
%type between_op {int}
|
||||
between_op(A) ::= BETWEEN. {A = 0;}
|
||||
@@ -1570,3 +1596,104 @@ wqlist(A) ::= wqlist(A) COMMA nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
|
||||
A = sqlite3WithAdd(pParse, A, &X, Y, Z);
|
||||
}
|
||||
%endif SQLITE_OMIT_CTE
|
||||
|
||||
//////////////////////// WINDOW FUNCTION EXPRESSIONS /////////////////////////
|
||||
// These must be at the end of this file. Specifically, the rules that
|
||||
// introduce tokens WINDOW, OVER and FILTER must appear last. This causes
|
||||
// the integer values assigned to these tokens to be larger than all other
|
||||
// tokens that may be output by the tokenizer except TK_SPACE and TK_ILLEGAL.
|
||||
//
|
||||
%ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
%type windowdefn_list {Window*}
|
||||
%destructor windowdefn_list {sqlite3WindowDelete(pParse->db, $$);}
|
||||
windowdefn_list(A) ::= windowdefn(Z). { A = Z; }
|
||||
windowdefn_list(A) ::= windowdefn_list(Y) COMMA windowdefn(Z). {
|
||||
if( Z ) Z->pNextWin = Y;
|
||||
A = Z;
|
||||
}
|
||||
|
||||
%type windowdefn {Window*}
|
||||
%destructor windowdefn {sqlite3WindowDelete(pParse->db, $$);}
|
||||
windowdefn(A) ::= nm(X) AS window(Y). {
|
||||
if( Y ){
|
||||
Y->zName = sqlite3DbStrNDup(pParse->db, X.z, X.n);
|
||||
}
|
||||
A = Y;
|
||||
}
|
||||
|
||||
%type window {Window*}
|
||||
%destructor window {sqlite3WindowDelete(pParse->db, $$);}
|
||||
|
||||
%type frame_opt {Window*}
|
||||
%destructor frame_opt {sqlite3WindowDelete(pParse->db, $$);}
|
||||
|
||||
%type window_or_nm {Window*}
|
||||
%destructor window_or_nm {
|
||||
sqlite3WindowDelete(pParse->db, $$);}
|
||||
|
||||
%type part_opt {ExprList*}
|
||||
%destructor part_opt {sqlite3ExprListDelete(pParse->db, $$);}
|
||||
|
||||
%type filter_opt {Expr*}
|
||||
%destructor filter_opt {sqlite3ExprDelete(pParse->db, $$);}
|
||||
|
||||
%type range_or_rows {int}
|
||||
|
||||
%type frame_bound {struct FrameBound}
|
||||
%destructor frame_bound {sqlite3ExprDelete(pParse->db, $$.pExpr);}
|
||||
|
||||
window_or_nm(A) ::= window(Z). {A = Z;}
|
||||
window_or_nm(A) ::= nm(Z). {
|
||||
A = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
|
||||
if( A ){
|
||||
A->zName = sqlite3DbStrNDup(pParse->db, Z.z, Z.n);
|
||||
}
|
||||
}
|
||||
|
||||
window(A) ::= LP part_opt(X) orderby_opt(Y) frame_opt(Z) RP. {
|
||||
A = Z;
|
||||
if( A ){
|
||||
A->pPartition = X;
|
||||
A->pOrderBy = Y;
|
||||
}
|
||||
}
|
||||
|
||||
part_opt(A) ::= PARTITION BY exprlist(X). { A = X; }
|
||||
part_opt(A) ::= . { A = 0; }
|
||||
|
||||
frame_opt(A) ::= . {
|
||||
A = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
|
||||
}
|
||||
frame_opt(A) ::= range_or_rows(X) frame_bound(Y). {
|
||||
A = sqlite3WindowAlloc(pParse, X, Y.eType, Y.pExpr, TK_CURRENT, 0);
|
||||
}
|
||||
frame_opt(A) ::= range_or_rows(X) BETWEEN frame_bound(Y) AND frame_bound(Z). {
|
||||
A = sqlite3WindowAlloc(pParse, X, Y.eType, Y.pExpr, Z.eType, Z.pExpr);
|
||||
}
|
||||
|
||||
range_or_rows(A) ::= RANGE. { A = TK_RANGE; }
|
||||
range_or_rows(A) ::= ROWS. { A = TK_ROWS; }
|
||||
|
||||
frame_bound(A) ::= UNBOUNDED PRECEDING. { A.eType = TK_UNBOUNDED; A.pExpr = 0; }
|
||||
frame_bound(A) ::= expr(X) PRECEDING. { A.eType = TK_PRECEDING; A.pExpr = X; }
|
||||
frame_bound(A) ::= CURRENT ROW. { A.eType = TK_CURRENT ; A.pExpr = 0; }
|
||||
frame_bound(A) ::= expr(X) FOLLOWING. { A.eType = TK_FOLLOWING; A.pExpr = X; }
|
||||
frame_bound(A) ::= UNBOUNDED FOLLOWING. { A.eType = TK_UNBOUNDED; A.pExpr = 0; }
|
||||
|
||||
%type windowdefn_opt {Window*}
|
||||
%destructor windowdefn_opt {sqlite3WindowDelete(pParse->db, $$);}
|
||||
windowdefn_opt(A) ::= . { A = 0; }
|
||||
windowdefn_opt(A) ::= WINDOW windowdefn_list(B). { A = B; }
|
||||
|
||||
%type over_opt {Window*}
|
||||
%destructor over_opt {sqlite3WindowDelete(pParse->db, $$);}
|
||||
over_opt(A) ::= . { A = 0; }
|
||||
over_opt(A) ::= filter_opt(W) OVER window_or_nm(Z). {
|
||||
A = Z;
|
||||
if( A ) A->pFilter = W;
|
||||
}
|
||||
|
||||
filter_opt(A) ::= . { A = 0; }
|
||||
filter_opt(A) ::= FILTER LP WHERE expr(X) RP. { A = X; }
|
||||
%endif // SQLITE_OMIT_WINDOWFUNC
|
||||
|
||||
|
||||
+5
-3
@@ -1564,6 +1564,11 @@ void sqlite3Pragma(
|
||||
assert( sqlite3NoTempsInRange(pParse,1,7+j) );
|
||||
sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
|
||||
loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
|
||||
if( !isQuick ){
|
||||
/* Sanity check on record header decoding */
|
||||
sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
|
||||
}
|
||||
/* Verify that all NOT NULL columns really are NOT NULL */
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
char *zErr;
|
||||
@@ -1606,9 +1611,6 @@ void sqlite3Pragma(
|
||||
sqlite3ExprListDelete(db, pCheck);
|
||||
}
|
||||
if( !isQuick ){ /* Omit the remaining tests for quick_check */
|
||||
/* Sanity check on record header decoding */
|
||||
sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
|
||||
/* Validate index entries for the current row */
|
||||
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
|
||||
int jmp2, jmp3, jmp4, jmp5;
|
||||
|
||||
+2
-2
@@ -188,7 +188,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
|
||||
** will be closed before this function returns. */
|
||||
sqlite3BtreeEnter(pDb->pBt);
|
||||
if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){
|
||||
rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);
|
||||
rc = sqlite3BtreeBeginTrans(pDb->pBt, 0, 0);
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));
|
||||
goto initone_error_out;
|
||||
@@ -433,7 +433,7 @@ static void schemaIsValid(Parse *pParse){
|
||||
** on the b-tree database, open one now. If a transaction is opened, it
|
||||
** will be closed immediately after reading the meta-value. */
|
||||
if( !sqlite3BtreeIsInReadTrans(pBt) ){
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0);
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
|
||||
if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
|
||||
sqlite3OomFault(db);
|
||||
}
|
||||
|
||||
+85
-18
@@ -756,11 +756,40 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
|
||||
NC_IdxExpr|NC_PartIdx);
|
||||
}
|
||||
}
|
||||
if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
|
||||
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
|
||||
|| (pDef->xValue==0 && pDef->xInverse==0)
|
||||
|| (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
|
||||
);
|
||||
if( pDef && pDef->xValue==0 && pExpr->pWin ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"%.*s() may not be used as a window function", nId, zId
|
||||
);
|
||||
pNC->nErr++;
|
||||
}else if(
|
||||
(is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
|
||||
|| (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
|
||||
|| (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
|
||||
){
|
||||
const char *zType;
|
||||
if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
|
||||
zType = "window";
|
||||
}else{
|
||||
zType = "aggregate";
|
||||
}
|
||||
sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()", zType, nId,zId);
|
||||
pNC->nErr++;
|
||||
is_agg = 0;
|
||||
}
|
||||
#else
|
||||
if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
|
||||
sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
|
||||
pNC->nErr++;
|
||||
is_agg = 0;
|
||||
}else if( no_such_func && pParse->db->init.busy==0
|
||||
}
|
||||
#endif
|
||||
else if( no_such_func && pParse->db->init.busy==0
|
||||
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
|
||||
&& pParse->explain==0
|
||||
#endif
|
||||
@@ -772,24 +801,48 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
|
||||
nId, zId);
|
||||
pNC->nErr++;
|
||||
}
|
||||
if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;
|
||||
if( is_agg ){
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
|
||||
#else
|
||||
pNC->ncFlags &= ~NC_AllowAgg;
|
||||
#endif
|
||||
}
|
||||
sqlite3WalkExprList(pWalker, pList);
|
||||
if( is_agg ){
|
||||
NameContext *pNC2 = pNC;
|
||||
pExpr->op = TK_AGG_FUNCTION;
|
||||
pExpr->op2 = 0;
|
||||
while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
|
||||
pExpr->op2++;
|
||||
pNC2 = pNC2->pNext;
|
||||
}
|
||||
assert( pDef!=0 );
|
||||
if( pNC2 ){
|
||||
assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
|
||||
testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
|
||||
pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( pExpr->pWin ){
|
||||
Select *pSel = pNC->pWinSelect;
|
||||
sqlite3WalkExprList(pWalker, pExpr->pWin->pPartition);
|
||||
sqlite3WalkExprList(pWalker, pExpr->pWin->pOrderBy);
|
||||
sqlite3WalkExpr(pWalker, pExpr->pWin->pFilter);
|
||||
sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->pWin, pDef);
|
||||
if( 0==pSel->pWin
|
||||
|| 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->pWin)
|
||||
){
|
||||
pExpr->pWin->pNextWin = pSel->pWin;
|
||||
pSel->pWin = pExpr->pWin;
|
||||
}
|
||||
pNC->ncFlags |= NC_AllowWin;
|
||||
}else
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
{
|
||||
NameContext *pNC2 = pNC;
|
||||
pExpr->op = TK_AGG_FUNCTION;
|
||||
pExpr->op2 = 0;
|
||||
while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
|
||||
pExpr->op2++;
|
||||
pNC2 = pNC2->pNext;
|
||||
}
|
||||
assert( pDef!=0 );
|
||||
if( pNC2 ){
|
||||
assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
|
||||
testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
|
||||
pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
|
||||
|
||||
}
|
||||
pNC->ncFlags |= NC_AllowAgg;
|
||||
}
|
||||
pNC->ncFlags |= NC_AllowAgg;
|
||||
}
|
||||
/* FIX ME: Compute pExpr->affinity based on the expected return
|
||||
** type of the function
|
||||
@@ -1190,6 +1243,17 @@ static int resolveOrderGroupBy(
|
||||
}
|
||||
for(j=0; j<pSelect->pEList->nExpr; j++){
|
||||
if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( pE->pWin ){
|
||||
Window **pp;
|
||||
for(pp=&pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
|
||||
if( *pp==pE->pWin ){
|
||||
*pp = (*pp)->pNextWin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
pItem->u.x.iOrderByCol = j+1;
|
||||
}
|
||||
}
|
||||
@@ -1246,6 +1310,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
||||
*/
|
||||
memset(&sNC, 0, sizeof(sNC));
|
||||
sNC.pParse = pParse;
|
||||
sNC.pWinSelect = p;
|
||||
if( sqlite3ResolveExprNames(&sNC, p->pLimit) ){
|
||||
return WRC_Abort;
|
||||
}
|
||||
@@ -1294,12 +1359,13 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
||||
/* Set up the local name-context to pass to sqlite3ResolveExprNames() to
|
||||
** resolve the result-set expression list.
|
||||
*/
|
||||
sNC.ncFlags = NC_AllowAgg;
|
||||
sNC.ncFlags = NC_AllowAgg|NC_AllowWin;
|
||||
sNC.pSrcList = p->pSrc;
|
||||
sNC.pNext = pOuterNC;
|
||||
|
||||
/* Resolve names in the result set. */
|
||||
if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort;
|
||||
sNC.ncFlags &= ~NC_AllowWin;
|
||||
|
||||
/* If there are no aggregate functions in the result-set, and no GROUP BY
|
||||
** expression, do not allow aggregates in any of the other expressions.
|
||||
@@ -1348,7 +1414,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
||||
** outer queries
|
||||
*/
|
||||
sNC.pNext = 0;
|
||||
sNC.ncFlags |= NC_AllowAgg;
|
||||
sNC.ncFlags |= NC_AllowAgg|NC_AllowWin;
|
||||
|
||||
/* If this is a converted compound query, move the ORDER BY clause from
|
||||
** the sub-query back to the parent query. At this point each term
|
||||
@@ -1379,6 +1445,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
||||
if( db->mallocFailed ){
|
||||
return WRC_Abort;
|
||||
}
|
||||
sNC.ncFlags &= ~NC_AllowWin;
|
||||
|
||||
/* Resolve the GROUP BY clause. At the same time, make sure
|
||||
** the GROUP BY clause does not contain aggregate functions.
|
||||
|
||||
+117
-44
@@ -96,6 +96,11 @@ static void clearSelect(sqlite3 *db, Select *p, int bFree){
|
||||
sqlite3ExprDelete(db, p->pHaving);
|
||||
sqlite3ExprListDelete(db, p->pOrderBy);
|
||||
sqlite3ExprDelete(db, p->pLimit);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
|
||||
sqlite3WindowListDelete(db, p->pWinDefn);
|
||||
}
|
||||
#endif
|
||||
if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
|
||||
if( bFree ) sqlite3DbFreeNN(db, p);
|
||||
p = pPrior;
|
||||
@@ -162,6 +167,10 @@ Select *sqlite3SelectNew(
|
||||
pNew->pNext = 0;
|
||||
pNew->pLimit = pLimit;
|
||||
pNew->pWith = 0;
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
pNew->pWin = 0;
|
||||
pNew->pWinDefn = 0;
|
||||
#endif
|
||||
if( pParse->db->mallocFailed ) {
|
||||
clearSelect(pParse->db, pNew, pNew!=&standin);
|
||||
pNew = 0;
|
||||
@@ -529,14 +538,6 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Forward reference */
|
||||
static KeyInfo *keyInfoFromExprList(
|
||||
Parse *pParse, /* Parsing context */
|
||||
ExprList *pList, /* Form the KeyInfo object from this ExprList */
|
||||
int iStart, /* Begin with this column of pList */
|
||||
int nExtra /* Add this many extra columns to the end */
|
||||
);
|
||||
|
||||
/*
|
||||
** An instance of this object holds information (beyond pParse and pSelect)
|
||||
** needed to load the next result row that is to be added to the sorter.
|
||||
@@ -678,7 +679,7 @@ static void pushOntoSorter(
|
||||
memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */
|
||||
sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
|
||||
testcase( pKI->nAllField > pKI->nKeyField+2 );
|
||||
pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat,
|
||||
pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
|
||||
pKI->nAllField-pKI->nKeyField-1);
|
||||
addrJmp = sqlite3VdbeCurrentAddr(v);
|
||||
sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
|
||||
@@ -1348,7 +1349,7 @@ int sqlite3KeyInfoIsWriteable(KeyInfo *p){ return p->nRef==1; }
|
||||
** function is responsible for seeing that this structure is eventually
|
||||
** freed.
|
||||
*/
|
||||
static KeyInfo *keyInfoFromExprList(
|
||||
KeyInfo *sqlite3KeyInfoFromExprList(
|
||||
Parse *pParse, /* Parsing context */
|
||||
ExprList *pList, /* Form the KeyInfo object from this ExprList */
|
||||
int iStart, /* Begin with this column of pList */
|
||||
@@ -3676,6 +3677,10 @@ static void substSelect(
|
||||
** "SELECT x FROM (SELECT max(y), x FROM t1)" would not necessarily
|
||||
** return the value X for which Y was maximal.)
|
||||
**
|
||||
** (25) If either the subquery or the parent query contains a window
|
||||
** function in the select list or ORDER BY clause, flattening
|
||||
** is not attempted.
|
||||
**
|
||||
**
|
||||
** In this routine, the "p" parameter is a pointer to the outer query.
|
||||
** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
|
||||
@@ -3719,6 +3724,10 @@ static int flattenSubquery(
|
||||
pSub = pSubitem->pSelect;
|
||||
assert( pSub!=0 );
|
||||
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( p->pWin || pSub->pWin ) return 0; /* Restriction (25) */
|
||||
#endif
|
||||
|
||||
pSubSrc = pSub->pSrc;
|
||||
assert( pSubSrc );
|
||||
/* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
|
||||
@@ -4109,7 +4118,7 @@ static int flattenSubquery(
|
||||
** (2) The inner query is the recursive part of a common table expression.
|
||||
**
|
||||
** (3) The inner query has a LIMIT clause (since the changes to the WHERE
|
||||
** close would change the meaning of the LIMIT).
|
||||
** clause would change the meaning of the LIMIT).
|
||||
**
|
||||
** (4) The inner query is the right operand of a LEFT JOIN and the
|
||||
** expression to be pushed down does not come from the ON clause
|
||||
@@ -4128,6 +4137,10 @@ static int flattenSubquery(
|
||||
** But if the (b2=2) term were to be pushed down into the bb subquery,
|
||||
** then the (1,1,NULL) row would be suppressed.
|
||||
**
|
||||
** (6) The inner query features one or more window-functions (since
|
||||
** changes to the WHERE clause of the inner query could change the
|
||||
** window over which window functions are calculated).
|
||||
**
|
||||
** Return 0 if no changes are made and non-zero if one or more WHERE clause
|
||||
** terms are duplicated into the subquery.
|
||||
*/
|
||||
@@ -4143,6 +4156,10 @@ static int pushDownWhereTerms(
|
||||
if( pWhere==0 ) return 0;
|
||||
if( pSubq->selFlags & SF_Recursive ) return 0; /* restriction (2) */
|
||||
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( pSubq->pWin ) return 0;
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
/* Only the first term of a compound can have a WITH clause. But make
|
||||
** sure no other terms are marked SF_Recursive in case something changes
|
||||
@@ -4588,6 +4605,35 @@ static void selectPopWith(Walker *pWalker, Select *p){
|
||||
#define selectPopWith 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The SrcList_item structure passed as the second argument represents a
|
||||
** sub-query in the FROM clause of a SELECT statement. This function
|
||||
** allocates and populates the SrcList_item.pTab object. If successful,
|
||||
** SQLITE_OK is returned. Otherwise, if an OOM error is encountered,
|
||||
** SQLITE_NOMEM.
|
||||
*/
|
||||
int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){
|
||||
Select *pSel = pFrom->pSelect;
|
||||
Table *pTab;
|
||||
|
||||
assert( pSel );
|
||||
pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table));
|
||||
if( pTab==0 ) return SQLITE_NOMEM;
|
||||
pTab->nTabRef = 1;
|
||||
if( pFrom->zAlias ){
|
||||
pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias);
|
||||
}else{
|
||||
pTab->zName = sqlite3MPrintf(pParse->db, "subquery_%p", (void*)pTab);
|
||||
}
|
||||
while( pSel->pPrior ){ pSel = pSel->pPrior; }
|
||||
sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
|
||||
pTab->iPKey = -1;
|
||||
pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
|
||||
pTab->tabFlags |= TF_Ephemeral;
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** This routine is a Walker callback for "expanding" a SELECT statement.
|
||||
** "Expanding" means to do the following:
|
||||
@@ -4660,19 +4706,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
assert( pSel!=0 );
|
||||
assert( pFrom->pTab==0 );
|
||||
if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
|
||||
pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
|
||||
if( pTab==0 ) return WRC_Abort;
|
||||
pTab->nTabRef = 1;
|
||||
if( pFrom->zAlias ){
|
||||
pTab->zName = sqlite3DbStrDup(db, pFrom->zAlias);
|
||||
}else{
|
||||
pTab->zName = sqlite3MPrintf(db, "subquery_%p", (void*)pTab);
|
||||
}
|
||||
while( pSel->pPrior ){ pSel = pSel->pPrior; }
|
||||
sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
|
||||
pTab->iPKey = -1;
|
||||
pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
|
||||
pTab->tabFlags |= TF_Ephemeral;
|
||||
if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort;
|
||||
#endif
|
||||
}else{
|
||||
/* An ordinary table or view name in the FROM clause */
|
||||
@@ -4973,7 +5007,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
|
||||
struct SrcList_item *pFrom;
|
||||
|
||||
assert( p->selFlags & SF_Resolved );
|
||||
assert( (p->selFlags & SF_HasTypeInfo)==0 );
|
||||
if( p->selFlags & SF_HasTypeInfo ) return;
|
||||
p->selFlags |= SF_HasTypeInfo;
|
||||
pParse = pWalker->pParse;
|
||||
pTabList = p->pSrc;
|
||||
@@ -5076,7 +5110,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
|
||||
"argument");
|
||||
pFunc->iDistinct = -1;
|
||||
}else{
|
||||
KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList, 0, 0);
|
||||
KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pE->x.pList,0,0);
|
||||
sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,
|
||||
(char*)pKeyInfo, P4_KEYINFO);
|
||||
}
|
||||
@@ -5450,14 +5484,10 @@ int sqlite3Select(
|
||||
p->selFlags &= ~SF_Distinct;
|
||||
}
|
||||
sqlite3SelectPrep(pParse, p, 0);
|
||||
memset(&sSort, 0, sizeof(sSort));
|
||||
sSort.pOrderBy = p->pOrderBy;
|
||||
pTabList = p->pSrc;
|
||||
if( pParse->nErr || db->mallocFailed ){
|
||||
goto select_end;
|
||||
}
|
||||
assert( p->pEList!=0 );
|
||||
isAgg = (p->selFlags & SF_Aggregate)!=0;
|
||||
#if SELECTTRACE_ENABLED
|
||||
if( sqlite3SelectTrace & 0x104 ){
|
||||
SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
|
||||
@@ -5469,6 +5499,22 @@ int sqlite3Select(
|
||||
generateColumnNames(pParse, p);
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( sqlite3WindowRewrite(pParse, p) ){
|
||||
goto select_end;
|
||||
}
|
||||
#if SELECTTRACE_ENABLED
|
||||
if( sqlite3SelectTrace & 0x108 ){
|
||||
SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
|
||||
sqlite3TreeViewSelect(0, p, 0);
|
||||
}
|
||||
#endif
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
pTabList = p->pSrc;
|
||||
isAgg = (p->selFlags & SF_Aggregate)!=0;
|
||||
memset(&sSort, 0, sizeof(sSort));
|
||||
sSort.pOrderBy = p->pOrderBy;
|
||||
|
||||
/* Try to various optimizations (flattening subqueries, and strength
|
||||
** reduction of join operators) in the FROM clause up into the main query
|
||||
*/
|
||||
@@ -5798,7 +5844,8 @@ int sqlite3Select(
|
||||
*/
|
||||
if( sSort.pOrderBy ){
|
||||
KeyInfo *pKeyInfo;
|
||||
pKeyInfo = keyInfoFromExprList(pParse, sSort.pOrderBy, 0, pEList->nExpr);
|
||||
pKeyInfo = sqlite3KeyInfoFromExprList(
|
||||
pParse, sSort.pOrderBy, 0, pEList->nExpr);
|
||||
sSort.iECursor = pParse->nTab++;
|
||||
sSort.addrSortIndex =
|
||||
sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
|
||||
@@ -5832,9 +5879,9 @@ int sqlite3Select(
|
||||
if( p->selFlags & SF_Distinct ){
|
||||
sDistinct.tabTnct = pParse->nTab++;
|
||||
sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
|
||||
sDistinct.tabTnct, 0, 0,
|
||||
(char*)keyInfoFromExprList(pParse, p->pEList,0,0),
|
||||
P4_KEYINFO);
|
||||
sDistinct.tabTnct, 0, 0,
|
||||
(char*)sqlite3KeyInfoFromExprList(pParse, p->pEList,0,0),
|
||||
P4_KEYINFO);
|
||||
sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
|
||||
sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;
|
||||
}else{
|
||||
@@ -5843,9 +5890,16 @@ int sqlite3Select(
|
||||
|
||||
if( !isAgg && pGroupBy==0 ){
|
||||
/* No aggregate functions and no GROUP BY clause */
|
||||
u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0);
|
||||
u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0)
|
||||
| (p->selFlags & SF_FixedLimit);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
Window *pWin = p->pWin; /* Master window object (or NULL) */
|
||||
if( pWin ){
|
||||
sqlite3WindowCodeInit(pParse, pWin);
|
||||
}
|
||||
#endif
|
||||
assert( WHERE_USE_LIMIT==SF_FixedLimit );
|
||||
wctrlFlags |= p->selFlags & SF_FixedLimit;
|
||||
|
||||
|
||||
/* Begin the database scan. */
|
||||
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
|
||||
@@ -5874,15 +5928,34 @@ int sqlite3Select(
|
||||
sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);
|
||||
}
|
||||
|
||||
/* Use the standard inner loop. */
|
||||
assert( p->pEList==pEList );
|
||||
selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,
|
||||
sqlite3WhereContinueLabel(pWInfo),
|
||||
sqlite3WhereBreakLabel(pWInfo));
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( pWin ){
|
||||
int addrGosub = sqlite3VdbeMakeLabel(v);
|
||||
int iCont = sqlite3VdbeMakeLabel(v);
|
||||
int iBreak = sqlite3VdbeMakeLabel(v);
|
||||
int regGosub = ++pParse->nMem;
|
||||
|
||||
/* End the database scan loop.
|
||||
*/
|
||||
sqlite3WhereEnd(pWInfo);
|
||||
sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
|
||||
|
||||
sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
|
||||
sqlite3VdbeResolveLabel(v, addrGosub);
|
||||
selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);
|
||||
sqlite3VdbeResolveLabel(v, iCont);
|
||||
sqlite3VdbeAddOp1(v, OP_Return, regGosub);
|
||||
sqlite3VdbeResolveLabel(v, iBreak);
|
||||
}else
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
{
|
||||
/* Use the standard inner loop. */
|
||||
selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,
|
||||
sqlite3WhereContinueLabel(pWInfo),
|
||||
sqlite3WhereBreakLabel(pWInfo));
|
||||
|
||||
/* End the database scan loop.
|
||||
*/
|
||||
sqlite3WhereEnd(pWInfo);
|
||||
}
|
||||
}else{
|
||||
/* This case when there exist aggregate functions or a GROUP BY clause
|
||||
** or both */
|
||||
@@ -6011,7 +6084,7 @@ int sqlite3Select(
|
||||
** will be converted into a Noop.
|
||||
*/
|
||||
sAggInfo.sortingIdx = pParse->nTab++;
|
||||
pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0, sAggInfo.nColumn);
|
||||
pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pGroupBy,0,sAggInfo.nColumn);
|
||||
addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen,
|
||||
sAggInfo.sortingIdx, sAggInfo.nSortingColumn,
|
||||
0, (char*)pKeyInfo, P4_KEYINFO);
|
||||
|
||||
+14
-5
@@ -2033,8 +2033,16 @@ static int shell_callback(
|
||||
}else if( aiType && aiType[i]==SQLITE_FLOAT ){
|
||||
char z[50];
|
||||
double r = sqlite3_column_double(p->pStmt, i);
|
||||
sqlite3_snprintf(50,z,"%!.20g", r);
|
||||
raw_printf(p->out, "%s", z);
|
||||
sqlite3_uint64 ur;
|
||||
memcpy(&ur,&r,sizeof(r));
|
||||
if( ur==0x7ff0000000000000LL ){
|
||||
raw_printf(p->out, "1e999");
|
||||
}else if( ur==0xfff0000000000000LL ){
|
||||
raw_printf(p->out, "-1e999");
|
||||
}else{
|
||||
sqlite3_snprintf(50,z,"%!.20g", r);
|
||||
raw_printf(p->out, "%s", z);
|
||||
}
|
||||
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
|
||||
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
|
||||
int nBlob = sqlite3_column_bytes(p->pStmt, i);
|
||||
@@ -2567,8 +2575,7 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
|
||||
int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */
|
||||
int iOp; /* Index of operation in p->aiIndent[] */
|
||||
|
||||
const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext",
|
||||
"NextIfOpen", "PrevIfOpen", 0 };
|
||||
const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext", 0 };
|
||||
const char *azYield[] = { "Yield", "SeekLT", "SeekGT", "RowSetRead",
|
||||
"Rewind", 0 };
|
||||
const char *azGoto[] = { "Goto", 0 };
|
||||
@@ -2972,6 +2979,7 @@ static int shell_exec(
|
||||
/* Reprepare pStmt before reactiving trace modes */
|
||||
sqlite3_finalize(pStmt);
|
||||
sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
|
||||
if( pArg ) pArg->pStmt = pStmt;
|
||||
}
|
||||
restore_debug_trace_modes();
|
||||
}
|
||||
@@ -5284,7 +5292,8 @@ static int arExtractCommand(ArCommand *pAr){
|
||||
"SELECT "
|
||||
" ($dir || name),"
|
||||
" writefile(($dir || name), %s, mode, mtime) "
|
||||
"FROM %s WHERE (%s) AND (data IS NULL OR $dirOnly = 0)";
|
||||
"FROM %s WHERE (%s) AND (data IS NULL OR $dirOnly = 0)"
|
||||
" AND name NOT GLOB '*..[/\\]*'";
|
||||
|
||||
const char *azExtraArg[] = {
|
||||
"sqlar_uncompress(data, sz)",
|
||||
|
||||
+94
-22
@@ -511,6 +511,7 @@ int sqlite3_exec(
|
||||
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
|
||||
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
|
||||
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
|
||||
#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
|
||||
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
|
||||
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
|
||||
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
|
||||
@@ -3354,13 +3355,24 @@ sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
|
||||
** [database connection] D failed, then the sqlite3_errcode(D) interface
|
||||
** returns the numeric [result code] or [extended result code] for that
|
||||
** API call.
|
||||
** If the most recent API call was successful,
|
||||
** then the return value from sqlite3_errcode() is undefined.
|
||||
** ^The sqlite3_extended_errcode()
|
||||
** interface is the same except that it always returns the
|
||||
** [extended result code] even when extended result codes are
|
||||
** disabled.
|
||||
**
|
||||
** The values returned by sqlite3_errcode() and/or
|
||||
** sqlite3_extended_errcode() might change with each API call.
|
||||
** Except, there are some interfaces that are guaranteed to never
|
||||
** change the value of the error code. The error-code preserving
|
||||
** interfaces are:
|
||||
**
|
||||
** <ul>
|
||||
** <li> sqlite3_errcode()
|
||||
** <li> sqlite3_extended_errcode()
|
||||
** <li> sqlite3_errmsg()
|
||||
** <li> sqlite3_errmsg16()
|
||||
** </ul>
|
||||
**
|
||||
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
|
||||
** text that describes the error, as either UTF-8 or UTF-16 respectively.
|
||||
** ^(Memory to hold the error message string is managed internally.
|
||||
@@ -4514,11 +4526,25 @@ int sqlite3_data_count(sqlite3_stmt *pStmt);
|
||||
** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
|
||||
** [sqlite3_free()].
|
||||
**
|
||||
** ^(If a memory allocation error occurs during the evaluation of any
|
||||
** of these routines, a default value is returned. The default value
|
||||
** is either the integer 0, the floating point number 0.0, or a NULL
|
||||
** pointer. Subsequent calls to [sqlite3_errcode()] will return
|
||||
** [SQLITE_NOMEM].)^
|
||||
** As long as the input parameters are correct, these routines will only
|
||||
** fail if an out-of-memory error occurs during a format conversion.
|
||||
** Only the following subset of interfaces are subject to out-of-memory
|
||||
** errors:
|
||||
**
|
||||
** <ul>
|
||||
** <li> sqlite3_column_blob()
|
||||
** <li> sqlite3_column_text()
|
||||
** <li> sqlite3_column_text16()
|
||||
** <li> sqlite3_column_bytes()
|
||||
** <li> sqlite3_column_bytes16()
|
||||
** </ul>
|
||||
**
|
||||
** If an out-of-memory error occurs, then the return value from these
|
||||
** routines is the same as if the column had contained an SQL NULL value.
|
||||
** Valid SQL NULL returns can be distinguished from out-of-memory errors
|
||||
** by invoking the [sqlite3_errcode()] immediately after the suspect
|
||||
** return value is obtained and before any
|
||||
** other SQLite interface is called on the same [database connection].
|
||||
*/
|
||||
const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
|
||||
double sqlite3_column_double(sqlite3_stmt*, int iCol);
|
||||
@@ -4595,11 +4621,13 @@ int sqlite3_reset(sqlite3_stmt *pStmt);
|
||||
**
|
||||
** ^These functions (collectively known as "function creation routines")
|
||||
** are used to add SQL functions or aggregates or to redefine the behavior
|
||||
** of existing SQL functions or aggregates. The only differences between
|
||||
** these routines are the text encoding expected for
|
||||
** the second parameter (the name of the function being created)
|
||||
** and the presence or absence of a destructor callback for
|
||||
** the application data pointer.
|
||||
** of existing SQL functions or aggregates. The only differences between
|
||||
** the three "sqlite3_create_function*" routines are the text encoding
|
||||
** expected for the second parameter (the name of the function being
|
||||
** created) and the presence or absence of a destructor callback for
|
||||
** the application data pointer. Function sqlite3_create_window_function()
|
||||
** is similar, but allows the user to supply the extra callback functions
|
||||
** needed by [aggregate window functions].
|
||||
**
|
||||
** ^The first parameter is the [database connection] to which the SQL
|
||||
** function is to be added. ^If an application uses more than one database
|
||||
@@ -4645,7 +4673,8 @@ int sqlite3_reset(sqlite3_stmt *pStmt);
|
||||
** ^(The fifth parameter is an arbitrary pointer. The implementation of the
|
||||
** function can gain access to this pointer using [sqlite3_user_data()].)^
|
||||
**
|
||||
** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
|
||||
** ^The sixth, seventh and eighth parameters passed to the three
|
||||
** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
|
||||
** pointers to C-language functions that implement the SQL function or
|
||||
** aggregate. ^A scalar SQL function requires an implementation of the xFunc
|
||||
** callback only; NULL pointers must be passed as the xStep and xFinal
|
||||
@@ -4654,15 +4683,24 @@ int sqlite3_reset(sqlite3_stmt *pStmt);
|
||||
** SQL function or aggregate, pass NULL pointers for all three function
|
||||
** callbacks.
|
||||
**
|
||||
** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
|
||||
** then it is destructor for the application data pointer.
|
||||
** The destructor is invoked when the function is deleted, either by being
|
||||
** overloaded or when the database connection closes.)^
|
||||
** ^The destructor is also invoked if the call to
|
||||
** sqlite3_create_function_v2() fails.
|
||||
** ^When the destructor callback of the tenth parameter is invoked, it
|
||||
** is passed a single argument which is a copy of the application data
|
||||
** pointer which was the fifth parameter to sqlite3_create_function_v2().
|
||||
** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
|
||||
** and xInverse) passed to sqlite3_create_window_function are pointers to
|
||||
** C-lanugage callbacks that implement the new function. xStep and xFinal
|
||||
** must both be non-NULL. xValue and xInverse may either both be NULL, in
|
||||
** which case a regular aggregate function is created, or must both be
|
||||
** non-NULL, in which case the new function may be used as either an aggregate
|
||||
** or aggregate window function. More details regarding the implementation
|
||||
** of aggregate window functions are
|
||||
** [user-defined window functions|available here].
|
||||
**
|
||||
** ^(If the final parameter to sqlite3_create_function_v2() or
|
||||
** sqlite3_create_window_function() is not NULL, then it is destructor for
|
||||
** the application data pointer. The destructor is invoked when the function
|
||||
** is deleted, either by being overloaded or when the database connection
|
||||
** closes.)^ ^The destructor is also invoked if the call to
|
||||
** sqlite3_create_function_v2() fails. ^When the destructor callback is
|
||||
** invoked, it is passed a single argument which is a copy of the application
|
||||
** data pointer which was the fifth parameter to sqlite3_create_function_v2().
|
||||
**
|
||||
** ^It is permitted to register multiple implementations of the same
|
||||
** functions with the same name but with either differing numbers of
|
||||
@@ -4715,6 +4753,18 @@ int sqlite3_create_function_v2(
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void(*xDestroy)(void*)
|
||||
);
|
||||
int sqlite3_create_window_function(
|
||||
sqlite3 *db,
|
||||
const char *zFunctionName,
|
||||
int nArg,
|
||||
int eTextRep,
|
||||
void *pApp,
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void (*xValue)(sqlite3_context*),
|
||||
void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
|
||||
void(*xDestroy)(void*)
|
||||
);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Text Encodings
|
||||
@@ -4857,6 +4907,28 @@ SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
|
||||
**
|
||||
** These routines must be called from the same thread as
|
||||
** the SQL function that supplied the [sqlite3_value*] parameters.
|
||||
**
|
||||
** As long as the input parameter is correct, these routines can only
|
||||
** fail if an out-of-memory error occurs during a format conversion.
|
||||
** Only the following subset of interfaces are subject to out-of-memory
|
||||
** errors:
|
||||
**
|
||||
** <ul>
|
||||
** <li> sqlite3_value_blob()
|
||||
** <li> sqlite3_value_text()
|
||||
** <li> sqlite3_value_text16()
|
||||
** <li> sqlite3_value_text16le()
|
||||
** <li> sqlite3_value_text16be()
|
||||
** <li> sqlite3_value_bytes()
|
||||
** <li> sqlite3_value_bytes16()
|
||||
** </ul>
|
||||
**
|
||||
** If an out-of-memory error occurs, then the return value from these
|
||||
** routines is the same as if the column had contained an SQL NULL value.
|
||||
** Valid SQL NULL returns can be distinguished from out-of-memory errors
|
||||
** by invoking the [sqlite3_errcode()] immediately after the suspect
|
||||
** return value is obtained and before any
|
||||
** other SQLite interface is called on the same [database connection].
|
||||
*/
|
||||
const void *sqlite3_value_blob(sqlite3_value*);
|
||||
double sqlite3_value_double(sqlite3_value*);
|
||||
|
||||
+133
-37
@@ -367,6 +367,17 @@
|
||||
# undef NDEBUG
|
||||
#endif
|
||||
|
||||
/* SQLITE_DEBUG_COLUMNCACHE is synomous with SQLITE_DEBUG. The
|
||||
** SQLITE_DEBUG_COLUMNCACHE symbol only exists to provide a convenient
|
||||
** way to search for all code that deals with verifying correct behavior
|
||||
** of the column cache.
|
||||
*/
|
||||
#ifdef SQLITE_DEBUG
|
||||
# define SQLITE_DEBUG_COLUMNCACHE 1
|
||||
#else
|
||||
# undef SQLIT_DEBUG_COLUMNCACHE
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
|
||||
*/
|
||||
@@ -1107,8 +1118,35 @@ typedef struct VTable VTable;
|
||||
typedef struct VtabCtx VtabCtx;
|
||||
typedef struct Walker Walker;
|
||||
typedef struct WhereInfo WhereInfo;
|
||||
typedef struct Window Window;
|
||||
typedef struct With With;
|
||||
|
||||
|
||||
/*
|
||||
** The bitmask datatype defined below is used for various optimizations.
|
||||
**
|
||||
** Changing this from a 64-bit to a 32-bit type limits the number of
|
||||
** tables in a join to 32 instead of 64. But it also reduces the size
|
||||
** of the library by 738 bytes on ix86.
|
||||
*/
|
||||
#ifdef SQLITE_BITMASK_TYPE
|
||||
typedef SQLITE_BITMASK_TYPE Bitmask;
|
||||
#else
|
||||
typedef u64 Bitmask;
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The number of bits in a Bitmask. "BMS" means "BitMask Size".
|
||||
*/
|
||||
#define BMS ((int)(sizeof(Bitmask)*8))
|
||||
|
||||
/*
|
||||
** A bit in a Bitmask
|
||||
*/
|
||||
#define MASKBIT(n) (((Bitmask)1)<<(n))
|
||||
#define MASKBIT32(n) (((unsigned int)1)<<(n))
|
||||
#define ALLBITS ((Bitmask)-1)
|
||||
|
||||
/* A VList object records a mapping between parameters/variables/wildcards
|
||||
** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
|
||||
** variable number associated with that parameter. See the format description
|
||||
@@ -1583,11 +1621,13 @@ struct sqlite3 {
|
||||
*/
|
||||
struct FuncDef {
|
||||
i8 nArg; /* Number of arguments. -1 means unlimited */
|
||||
u16 funcFlags; /* Some combination of SQLITE_FUNC_* */
|
||||
u32 funcFlags; /* Some combination of SQLITE_FUNC_* */
|
||||
void *pUserData; /* User data parameter */
|
||||
FuncDef *pNext; /* Next function with same name */
|
||||
void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
|
||||
void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
|
||||
void (*xValue)(sqlite3_context*); /* Current agg value */
|
||||
void (*xInverse)(sqlite3_context*,int,sqlite3_value**); /* inverse agg-step */
|
||||
const char *zName; /* SQL name of the function. */
|
||||
union {
|
||||
FuncDef *pHash; /* Next with a different name but the same hash */
|
||||
@@ -1644,6 +1684,8 @@ struct FuncDestructor {
|
||||
** single query - might change over time */
|
||||
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
|
||||
#define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
|
||||
#define SQLITE_FUNC_WINDOW 0x10000 /* Built-in window-only function */
|
||||
#define SQLITE_FUNC_WINDOW_SIZE 0x20000 /* Requires partition size as arg. */
|
||||
|
||||
/*
|
||||
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
|
||||
@@ -1678,6 +1720,12 @@ struct FuncDestructor {
|
||||
** are interpreted in the same way as the first 4 parameters to
|
||||
** FUNCTION().
|
||||
**
|
||||
** WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
|
||||
** Used to create an aggregate function definition implemented by
|
||||
** the C functions xStep and xFinal. The first four parameters
|
||||
** are interpreted in the same way as the first 4 parameters to
|
||||
** FUNCTION().
|
||||
**
|
||||
** LIKEFUNC(zName, nArg, pArg, flags)
|
||||
** Used to create a scalar function definition of a function zName
|
||||
** that accepts nArg arguments and is implemented by a call to C
|
||||
@@ -1688,31 +1736,35 @@ struct FuncDestructor {
|
||||
*/
|
||||
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
|
||||
{nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
|
||||
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
|
||||
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
|
||||
#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
|
||||
{nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
|
||||
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
|
||||
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
|
||||
#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
|
||||
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \
|
||||
0, 0, xFunc, 0, #zName, {0} }
|
||||
0, 0, xFunc, 0, 0, 0, #zName, {0} }
|
||||
#define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \
|
||||
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
|
||||
(void*)&sqlite3Config, 0, xFunc, 0, #zName, {0} }
|
||||
(void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} }
|
||||
#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
|
||||
{nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
|
||||
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
|
||||
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
|
||||
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
|
||||
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
|
||||
pArg, 0, xFunc, 0, #zName, }
|
||||
pArg, 0, xFunc, 0, 0, 0, #zName, }
|
||||
#define LIKEFUNC(zName, nArg, arg, flags) \
|
||||
{nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
|
||||
(void *)arg, 0, likeFunc, 0, #zName, {0} }
|
||||
#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
|
||||
(void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
|
||||
#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \
|
||||
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
|
||||
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}
|
||||
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}}
|
||||
#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
|
||||
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
|
||||
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}
|
||||
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}}
|
||||
|
||||
#define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
|
||||
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
|
||||
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
|
||||
|
||||
/*
|
||||
** All current savepoints are stored in a linked list starting at
|
||||
@@ -2198,6 +2250,7 @@ struct Index {
|
||||
tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
|
||||
tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */
|
||||
#endif
|
||||
Bitmask colNotIdxed; /* 0 for unindexed columns in pTab */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -2413,6 +2466,9 @@ struct Expr {
|
||||
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
|
||||
Table *pTab; /* Table for TK_COLUMN expressions. Can be NULL
|
||||
** for a column of an index on an expression */
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
Window *pWin; /* Window definition for window functions */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -2543,31 +2599,6 @@ struct IdList {
|
||||
int nId; /* Number of identifiers on the list */
|
||||
};
|
||||
|
||||
/*
|
||||
** The bitmask datatype defined below is used for various optimizations.
|
||||
**
|
||||
** Changing this from a 64-bit to a 32-bit type limits the number of
|
||||
** tables in a join to 32 instead of 64. But it also reduces the size
|
||||
** of the library by 738 bytes on ix86.
|
||||
*/
|
||||
#ifdef SQLITE_BITMASK_TYPE
|
||||
typedef SQLITE_BITMASK_TYPE Bitmask;
|
||||
#else
|
||||
typedef u64 Bitmask;
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The number of bits in a Bitmask. "BMS" means "BitMask Size".
|
||||
*/
|
||||
#define BMS ((int)(sizeof(Bitmask)*8))
|
||||
|
||||
/*
|
||||
** A bit in a Bitmask
|
||||
*/
|
||||
#define MASKBIT(n) (((Bitmask)1)<<(n))
|
||||
#define MASKBIT32(n) (((unsigned int)1)<<(n))
|
||||
#define ALLBITS ((Bitmask)-1)
|
||||
|
||||
/*
|
||||
** The following structure describes the FROM clause of a SELECT statement.
|
||||
** Each table or subquery in the FROM clause is a separate element of
|
||||
@@ -2699,6 +2730,7 @@ struct NameContext {
|
||||
int nRef; /* Number of names resolved by this context */
|
||||
int nErr; /* Number of errors encountered while resolving names */
|
||||
u16 ncFlags; /* Zero or more NC_* flags defined below */
|
||||
Select *pWinSelect; /* SELECT statement for any window functions */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -2721,6 +2753,7 @@ struct NameContext {
|
||||
#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
|
||||
#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
|
||||
#define NC_Complex 0x2000 /* True if a function or subquery seen */
|
||||
#define NC_AllowWin 0x4000 /* Window functions are allowed here */
|
||||
|
||||
/*
|
||||
** An instance of the following object describes a single ON CONFLICT
|
||||
@@ -2788,6 +2821,10 @@ struct Select {
|
||||
Select *pNext; /* Next select to the left in a compound */
|
||||
Expr *pLimit; /* LIMIT expression. NULL means not used. */
|
||||
With *pWith; /* WITH clause attached to this select. Or NULL. */
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
Window *pWin; /* List of window functions */
|
||||
Window *pWinDefn; /* List of named window definitions */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -3401,6 +3438,7 @@ struct Walker {
|
||||
struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
|
||||
ExprList *pGroupBy; /* GROUP BY clause */
|
||||
Select *pSelect; /* HAVING to WHERE clause ctx */
|
||||
struct WindowRewrite *pRewrite; /* Window rewrite context */
|
||||
} u;
|
||||
};
|
||||
|
||||
@@ -3451,6 +3489,58 @@ struct TreeView {
|
||||
};
|
||||
#endif /* SQLITE_DEBUG */
|
||||
|
||||
/*
|
||||
** Object used to encode the OVER() clause attached to a window-function
|
||||
** invocation. And some fields used while generating VM code for the same.
|
||||
*/
|
||||
struct Window {
|
||||
char *zName; /* Name of window (may be NULL) */
|
||||
ExprList *pPartition; /* PARTITION BY clause */
|
||||
ExprList *pOrderBy; /* ORDER BY clause */
|
||||
u8 eType; /* TK_RANGE or TK_ROWS */
|
||||
u8 eStart; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
|
||||
u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
|
||||
Expr *pStart; /* Expression for "<expr> PRECEDING" */
|
||||
Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
|
||||
|
||||
Window *pNextWin; /* Next window function belonging to this SELECT */
|
||||
|
||||
Expr *pFilter;
|
||||
FuncDef *pFunc;
|
||||
|
||||
int iEphCsr; /* Temp table used by this window */
|
||||
int regAccum;
|
||||
int regResult;
|
||||
|
||||
int csrApp; /* Function cursor (used by min/max) */
|
||||
int regApp; /* Function register (also used by min/max) */
|
||||
|
||||
int regPart;
|
||||
Expr *pOwner; /* Expression object this window is attached to */
|
||||
int nBufferCol; /* Number of columns in buffer table */
|
||||
int iArgCol; /* Offset of first argument for this function */
|
||||
};
|
||||
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
void sqlite3WindowDelete(sqlite3*, Window*);
|
||||
void sqlite3WindowListDelete(sqlite3 *db, Window *p);
|
||||
Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);
|
||||
void sqlite3WindowAttach(Parse*, Expr*, Window*);
|
||||
int sqlite3WindowCompare(Parse*, Window*, Window*);
|
||||
void sqlite3WindowCodeInit(Parse*, Window*);
|
||||
void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
|
||||
int sqlite3WindowRewrite(Parse*, Select*);
|
||||
int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
|
||||
void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
|
||||
Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);
|
||||
Window *sqlite3WindowListDup(sqlite3 *db, Window *p);
|
||||
void sqlite3WindowFunctions(void);
|
||||
#else
|
||||
# define sqlite3WindowDelete(a,b)
|
||||
# define sqlite3WindowFunctions()
|
||||
# define sqlite3WindowAttach(a,b,c)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Assuming zIn points to the first byte of a UTF-8 character,
|
||||
** advance zIn to point to the first byte of the next UTF-8 character.
|
||||
@@ -4158,12 +4248,17 @@ KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
|
||||
void sqlite3KeyInfoUnref(KeyInfo*);
|
||||
KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
|
||||
KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
|
||||
KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3KeyInfoIsWriteable(KeyInfo*);
|
||||
#endif
|
||||
int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
|
||||
void (*)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
|
||||
void (*)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*)(sqlite3_context*),
|
||||
void (*)(sqlite3_context*),
|
||||
void (*)(sqlite3_context*,int,sqlite3_value **),
|
||||
FuncDestructor *pDestructor
|
||||
);
|
||||
void sqlite3NoopDestructor(void*);
|
||||
@@ -4204,6 +4299,7 @@ char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);
|
||||
void sqlite3ParserFree(void*, void(*)(void*));
|
||||
#endif
|
||||
void sqlite3Parser(void*, int, Token);
|
||||
int sqlite3ParserFallback(int);
|
||||
#ifdef YYTRACKMAXSTACKDEPTH
|
||||
int sqlite3ParserStackPeak(void*);
|
||||
#endif
|
||||
|
||||
@@ -7798,6 +7798,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
#ifdef SQLITE_ENABLE_FTS3
|
||||
extern int sqlite3_fts3_enable_parentheses;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(SQLITE_ENABLE_SELECTTRACE)
|
||||
extern int sqlite3SelectTrace;
|
||||
#endif
|
||||
|
||||
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
|
||||
@@ -7884,6 +7887,10 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
(char*)&sqlite3_sync_count, TCL_LINK_INT);
|
||||
Tcl_LinkVar(interp, "sqlite_fullsync_count",
|
||||
(char*)&sqlite3_fullsync_count, TCL_LINK_INT);
|
||||
#if defined(SQLITE_ENABLE_SELECTTRACE)
|
||||
Tcl_LinkVar(interp, "sqlite3SelectTrace",
|
||||
(char*)&sqlite3SelectTrace, TCL_LINK_INT);
|
||||
#endif
|
||||
#if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_TEST)
|
||||
Tcl_LinkVar(interp, "sqlite_fts3_enable_parentheses",
|
||||
(char*)&sqlite3_fts3_enable_parentheses, TCL_LINK_INT);
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ static int SQLITE_TCLAPI btree_begin_transaction(
|
||||
}
|
||||
pBt = sqlite3TestTextToPtr(argv[1]);
|
||||
sqlite3BtreeEnter(pBt);
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 1);
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 1, 0);
|
||||
sqlite3BtreeLeave(pBt);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
|
||||
|
||||
@@ -762,6 +762,12 @@ Tcl_SetVar2(interp, "sqlite_options", "mergesort", "1", TCL_GLOBAL_ONLY);
|
||||
Tcl_SetVar2(interp, "sqlite_options", "uri_00_error", "0", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_OMIT_WINDOWFUNC
|
||||
Tcl_SetVar2(interp, "sqlite_options", "windowfunc", "0", TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
Tcl_SetVar2(interp, "sqlite_options", "windowfunc", "1", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#define LINKVAR(x) { \
|
||||
static const int cv_ ## x = SQLITE_ ## x; \
|
||||
Tcl_LinkVar(interp, "SQLITE_" #x, (char *)&(cv_ ## x), \
|
||||
|
||||
@@ -105,6 +105,7 @@ const char *sqlite3TestInit(Tcl_Interp *interp){
|
||||
extern int Zipvfs_Init(Tcl_Interp*);
|
||||
#endif
|
||||
extern int TestExpert_Init(Tcl_Interp*);
|
||||
extern int Sqlitetest_window_Init(Tcl_Interp *);
|
||||
|
||||
Tcl_CmdInfo cmdInfo;
|
||||
|
||||
@@ -169,6 +170,7 @@ const char *sqlite3TestInit(Tcl_Interp *interp){
|
||||
Sqlitetestfts3_Init(interp);
|
||||
#endif
|
||||
TestExpert_Init(interp);
|
||||
Sqlitetest_window_Init(interp);
|
||||
|
||||
Tcl_CreateObjCommand(
|
||||
interp, "load_testfixture_extensions", load_testfixture_extensions,0,0
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
** 2018 June 17
|
||||
**
|
||||
** 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 "sqlite3.h"
|
||||
|
||||
#ifdef SQLITE_TEST
|
||||
|
||||
#include "sqliteInt.h"
|
||||
#include <tcl.h>
|
||||
|
||||
extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
|
||||
extern const char *sqlite3ErrName(int);
|
||||
|
||||
typedef struct TestWindow TestWindow;
|
||||
struct TestWindow {
|
||||
Tcl_Obj *xStep;
|
||||
Tcl_Obj *xFinal;
|
||||
Tcl_Obj *xValue;
|
||||
Tcl_Obj *xInverse;
|
||||
Tcl_Interp *interp;
|
||||
};
|
||||
|
||||
typedef struct TestWindowCtx TestWindowCtx;
|
||||
struct TestWindowCtx {
|
||||
Tcl_Obj *pVal;
|
||||
};
|
||||
|
||||
static void doTestWindowStep(
|
||||
int bInverse,
|
||||
sqlite3_context *ctx,
|
||||
int nArg,
|
||||
sqlite3_value **apArg
|
||||
){
|
||||
int i;
|
||||
TestWindow *p = (TestWindow*)sqlite3_user_data(ctx);
|
||||
Tcl_Obj *pEval = Tcl_DuplicateObj(bInverse ? p->xInverse : p->xStep);
|
||||
TestWindowCtx *pCtx = sqlite3_aggregate_context(ctx, sizeof(TestWindowCtx));
|
||||
|
||||
Tcl_IncrRefCount(pEval);
|
||||
if( pCtx ){
|
||||
const char *zResult;
|
||||
int rc;
|
||||
if( pCtx->pVal ){
|
||||
Tcl_ListObjAppendElement(p->interp, pEval, Tcl_DuplicateObj(pCtx->pVal));
|
||||
}else{
|
||||
Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj("", -1));
|
||||
}
|
||||
for(i=0; i<nArg; i++){
|
||||
Tcl_Obj *pArg;
|
||||
pArg = Tcl_NewStringObj((const char*)sqlite3_value_text(apArg[i]), -1);
|
||||
Tcl_ListObjAppendElement(p->interp, pEval, pArg);
|
||||
}
|
||||
rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);
|
||||
if( rc!=TCL_OK ){
|
||||
zResult = Tcl_GetStringResult(p->interp);
|
||||
sqlite3_result_error(ctx, zResult, -1);
|
||||
}else{
|
||||
if( pCtx->pVal ) Tcl_DecrRefCount(pCtx->pVal);
|
||||
pCtx->pVal = Tcl_DuplicateObj(Tcl_GetObjResult(p->interp));
|
||||
Tcl_IncrRefCount(pCtx->pVal);
|
||||
}
|
||||
}
|
||||
Tcl_DecrRefCount(pEval);
|
||||
}
|
||||
|
||||
static void doTestWindowFinalize(int bValue, sqlite3_context *ctx){
|
||||
TestWindow *p = (TestWindow*)sqlite3_user_data(ctx);
|
||||
Tcl_Obj *pEval = Tcl_DuplicateObj(bValue ? p->xValue : p->xFinal);
|
||||
TestWindowCtx *pCtx = sqlite3_aggregate_context(ctx, sizeof(TestWindowCtx));
|
||||
|
||||
Tcl_IncrRefCount(pEval);
|
||||
if( pCtx ){
|
||||
const char *zResult;
|
||||
int rc;
|
||||
if( pCtx->pVal ){
|
||||
Tcl_ListObjAppendElement(p->interp, pEval, Tcl_DuplicateObj(pCtx->pVal));
|
||||
}else{
|
||||
Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj("", -1));
|
||||
}
|
||||
|
||||
rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);
|
||||
zResult = Tcl_GetStringResult(p->interp);
|
||||
if( rc!=TCL_OK ){
|
||||
sqlite3_result_error(ctx, zResult, -1);
|
||||
}else{
|
||||
sqlite3_result_text(ctx, zResult, -1, SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
if( bValue==0 ){
|
||||
if( pCtx->pVal ) Tcl_DecrRefCount(pCtx->pVal);
|
||||
pCtx->pVal = 0;
|
||||
}
|
||||
}
|
||||
Tcl_DecrRefCount(pEval);
|
||||
}
|
||||
|
||||
static void testWindowStep(
|
||||
sqlite3_context *ctx,
|
||||
int nArg,
|
||||
sqlite3_value **apArg
|
||||
){
|
||||
doTestWindowStep(0, ctx, nArg, apArg);
|
||||
}
|
||||
static void testWindowInverse(
|
||||
sqlite3_context *ctx,
|
||||
int nArg,
|
||||
sqlite3_value **apArg
|
||||
){
|
||||
doTestWindowStep(1, ctx, nArg, apArg);
|
||||
}
|
||||
|
||||
static void testWindowFinal(sqlite3_context *ctx){
|
||||
doTestWindowFinalize(0, ctx);
|
||||
}
|
||||
static void testWindowValue(sqlite3_context *ctx){
|
||||
doTestWindowFinalize(1, ctx);
|
||||
}
|
||||
|
||||
static void testWindowDestroy(void *pCtx){
|
||||
ckfree(pCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_create_window_function DB NAME XSTEP XFINAL XVALUE XINVERSE
|
||||
*/
|
||||
static int SQLITE_TCLAPI test_create_window(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
TestWindow *pNew;
|
||||
sqlite3 *db;
|
||||
const char *zName;
|
||||
int rc;
|
||||
|
||||
if( objc!=7 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB NAME XSTEP XFINAL XVALUE XINVERSE");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||
zName = Tcl_GetString(objv[2]);
|
||||
pNew = ckalloc(sizeof(TestWindow));
|
||||
memset(pNew, 0, sizeof(TestWindow));
|
||||
pNew->xStep = Tcl_DuplicateObj(objv[3]);
|
||||
pNew->xFinal = Tcl_DuplicateObj(objv[4]);
|
||||
pNew->xValue = Tcl_DuplicateObj(objv[5]);
|
||||
pNew->xInverse = Tcl_DuplicateObj(objv[6]);
|
||||
pNew->interp = interp;
|
||||
|
||||
Tcl_IncrRefCount(pNew->xStep);
|
||||
Tcl_IncrRefCount(pNew->xFinal);
|
||||
Tcl_IncrRefCount(pNew->xValue);
|
||||
Tcl_IncrRefCount(pNew->xInverse);
|
||||
|
||||
rc = sqlite3_create_window_function(db, zName, -1, SQLITE_UTF8, (void*)pNew,
|
||||
testWindowStep, testWindowFinal, testWindowValue, testWindowInverse,
|
||||
testWindowDestroy
|
||||
);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static int SQLITE_TCLAPI test_create_window_misuse(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
sqlite3 *db;
|
||||
int rc;
|
||||
|
||||
if( objc!=2 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||
|
||||
rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0,
|
||||
0, testWindowFinal, testWindowValue, testWindowInverse,
|
||||
0
|
||||
);
|
||||
if( rc!=SQLITE_MISUSE ) goto error;
|
||||
rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0,
|
||||
testWindowStep, 0, testWindowValue, testWindowInverse,
|
||||
0
|
||||
);
|
||||
if( rc!=SQLITE_MISUSE ) goto error;
|
||||
rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0,
|
||||
testWindowStep, testWindowFinal, 0, testWindowInverse,
|
||||
0
|
||||
);
|
||||
if( rc!=SQLITE_MISUSE ) goto error;
|
||||
rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0,
|
||||
testWindowStep, testWindowFinal, testWindowValue, 0,
|
||||
0
|
||||
);
|
||||
if( rc!=SQLITE_MISUSE ) goto error;
|
||||
|
||||
return TCL_OK;
|
||||
|
||||
error:
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj("misuse test error", -1));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
** xStep for sumint().
|
||||
*/
|
||||
static void sumintStep(
|
||||
sqlite3_context *ctx,
|
||||
int nArg,
|
||||
sqlite3_value *apArg[]
|
||||
){
|
||||
sqlite3_int64 *pInt;
|
||||
|
||||
assert( nArg==1 );
|
||||
if( sqlite3_value_type(apArg[0])!=SQLITE_INTEGER ){
|
||||
sqlite3_result_error(ctx, "invalid argument", -1);
|
||||
return;
|
||||
}
|
||||
pInt = (sqlite3_int64*)sqlite3_aggregate_context(ctx, sizeof(sqlite3_int64));
|
||||
if( pInt ){
|
||||
*pInt += sqlite3_value_int64(apArg[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** xInverse for sumint().
|
||||
*/
|
||||
static void sumintInverse(
|
||||
sqlite3_context *ctx,
|
||||
int nArg,
|
||||
sqlite3_value *apArg[]
|
||||
){
|
||||
sqlite3_int64 *pInt;
|
||||
pInt = (sqlite3_int64*)sqlite3_aggregate_context(ctx, sizeof(sqlite3_int64));
|
||||
*pInt -= sqlite3_value_int64(apArg[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
** xFinal for sumint().
|
||||
*/
|
||||
static void sumintFinal(sqlite3_context *ctx){
|
||||
sqlite3_int64 res = 0;
|
||||
sqlite3_int64 *pInt;
|
||||
pInt = (sqlite3_int64*)sqlite3_aggregate_context(ctx, 0);
|
||||
if( pInt ) res = *pInt;
|
||||
sqlite3_result_int64(ctx, res);
|
||||
}
|
||||
|
||||
/*
|
||||
** xValue for sumint().
|
||||
*/
|
||||
static void sumintValue(sqlite3_context *ctx){
|
||||
sqlite3_int64 res = 0;
|
||||
sqlite3_int64 *pInt;
|
||||
pInt = (sqlite3_int64*)sqlite3_aggregate_context(ctx, 0);
|
||||
if( pInt ) res = *pInt;
|
||||
sqlite3_result_int64(ctx, res);
|
||||
}
|
||||
|
||||
static int SQLITE_TCLAPI test_create_sumint(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
sqlite3 *db;
|
||||
int rc;
|
||||
|
||||
if( objc!=2 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||
|
||||
rc = sqlite3_create_window_function(db, "sumint", 1, SQLITE_UTF8, 0,
|
||||
sumintStep, sumintFinal, sumintValue, sumintInverse,
|
||||
0
|
||||
);
|
||||
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static int SQLITE_TCLAPI test_override_sum(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
sqlite3 *db;
|
||||
int rc;
|
||||
|
||||
if( objc!=2 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||
|
||||
rc = sqlite3_create_function(db, "sum", -1, SQLITE_UTF8, 0,
|
||||
0, sumintStep, sumintFinal
|
||||
);
|
||||
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
int Sqlitetest_window_Init(Tcl_Interp *interp){
|
||||
static struct {
|
||||
char *zName;
|
||||
Tcl_ObjCmdProc *xProc;
|
||||
int clientData;
|
||||
} aObjCmd[] = {
|
||||
{ "sqlite3_create_window_function", test_create_window, 0 },
|
||||
{ "test_create_window_function_misuse", test_create_window_misuse, 0 },
|
||||
{ "test_create_sumint", test_create_sumint, 0 },
|
||||
{ "test_override_sum", test_override_sum, 0 },
|
||||
};
|
||||
int i;
|
||||
for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
|
||||
ClientData c = (ClientData)SQLITE_INT_TO_PTR(aObjCmd[i].clientData);
|
||||
Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, c, 0);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
#endif
|
||||
+130
-30
@@ -54,11 +54,12 @@
|
||||
#define CC_TILDA 25 /* '~' */
|
||||
#define CC_DOT 26 /* '.' */
|
||||
#define CC_ILLEGAL 27 /* Illegal character */
|
||||
#define CC_NUL 28 /* 0x00 */
|
||||
|
||||
static const unsigned char aiClass[] = {
|
||||
#ifdef SQLITE_ASCII
|
||||
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
|
||||
/* 0x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 7, 7, 27, 7, 7, 27, 27,
|
||||
/* 0x */ 28, 27, 27, 27, 27, 27, 27, 27, 27, 7, 7, 27, 7, 7, 27, 27,
|
||||
/* 1x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
/* 2x */ 7, 15, 8, 5, 4, 22, 24, 8, 17, 18, 21, 20, 23, 11, 26, 16,
|
||||
/* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6,
|
||||
@@ -188,6 +189,82 @@ const char sqlite3IsEbcdicIdChar[] = {
|
||||
int sqlite3IsIdChar(u8 c){ return IdChar(c); }
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
/*
|
||||
** Return the id of the next token in string (*pz). Before returning, set
|
||||
** (*pz) to point to the byte following the parsed token.
|
||||
*/
|
||||
static int getToken(const unsigned char **pz){
|
||||
const unsigned char *z = *pz;
|
||||
int t; /* Token type to return */
|
||||
do {
|
||||
z += sqlite3GetToken(z, &t);
|
||||
}while( t==TK_SPACE );
|
||||
if( t==TK_ID
|
||||
|| t==TK_STRING
|
||||
|| t==TK_JOIN_KW
|
||||
|| t==TK_WINDOW
|
||||
|| t==TK_OVER
|
||||
|| sqlite3ParserFallback(t)==TK_ID
|
||||
){
|
||||
t = TK_ID;
|
||||
}
|
||||
*pz = z;
|
||||
return t;
|
||||
}
|
||||
|
||||
/*
|
||||
** The following three functions are called immediately after the tokenizer
|
||||
** reads the keywords WINDOW, OVER and FILTER, respectively, to determine
|
||||
** whether the token should be treated as a keyword or an SQL identifier.
|
||||
** This cannot be handled by the usual lemon %fallback method, due to
|
||||
** the ambiguity in some constructions. e.g.
|
||||
**
|
||||
** SELECT sum(x) OVER ...
|
||||
**
|
||||
** In the above, "OVER" might be a keyword, or it might be an alias for the
|
||||
** sum(x) expression. If a "%fallback ID OVER" directive were added to
|
||||
** grammar, then SQLite would always treat "OVER" as an alias, making it
|
||||
** impossible to call a window-function without a FILTER clause.
|
||||
**
|
||||
** WINDOW is treated as a keyword if:
|
||||
**
|
||||
** * the following token is an identifier, or a keyword that can fallback
|
||||
** to being an identifier, and
|
||||
** * the token after than one is TK_AS.
|
||||
**
|
||||
** OVER is a keyword if:
|
||||
**
|
||||
** * the previous token was TK_RP, and
|
||||
** * the next token is either TK_LP or an identifier.
|
||||
**
|
||||
** FILTER is a keyword if:
|
||||
**
|
||||
** * the previous token was TK_RP, and
|
||||
** * the next token is TK_LP.
|
||||
*/
|
||||
static int analyzeWindowKeyword(const unsigned char *z){
|
||||
int t;
|
||||
t = getToken(&z);
|
||||
if( t!=TK_ID ) return TK_ID;
|
||||
t = getToken(&z);
|
||||
if( t!=TK_AS ) return TK_ID;
|
||||
return TK_WINDOW;
|
||||
}
|
||||
static int analyzeOverKeyword(const unsigned char *z, int lastToken){
|
||||
if( lastToken==TK_RP ){
|
||||
int t = getToken(&z);
|
||||
if( t==TK_LP || t==TK_ID ) return TK_OVER;
|
||||
}
|
||||
return TK_ID;
|
||||
}
|
||||
static int analyzeFilterKeyword(const unsigned char *z, int lastToken){
|
||||
if( lastToken==TK_RP && getToken(&z)==TK_LP ){
|
||||
return TK_FILTER;
|
||||
}
|
||||
return TK_ID;
|
||||
}
|
||||
#endif // SQLITE_OMIT_WINDOWFUNC
|
||||
|
||||
/*
|
||||
** Return the length (in bytes) of the token that begins at z[0].
|
||||
@@ -456,6 +533,10 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||
i = 1;
|
||||
break;
|
||||
}
|
||||
case CC_NUL: {
|
||||
*tokenType = TK_ILLEGAL;
|
||||
return 0;
|
||||
}
|
||||
default: {
|
||||
*tokenType = TK_ILLEGAL;
|
||||
return 1;
|
||||
@@ -509,47 +590,64 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
|
||||
assert( pParse->nVar==0 );
|
||||
assert( pParse->pVList==0 );
|
||||
while( 1 ){
|
||||
if( zSql[0]!=0 ){
|
||||
n = sqlite3GetToken((u8*)zSql, &tokenType);
|
||||
mxSqlLen -= n;
|
||||
if( mxSqlLen<0 ){
|
||||
pParse->rc = SQLITE_TOOBIG;
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
/* Upon reaching the end of input, call the parser two more times
|
||||
** with tokens TK_SEMI and 0, in that order. */
|
||||
if( lastTokenParsed==TK_SEMI ){
|
||||
tokenType = 0;
|
||||
}else if( lastTokenParsed==0 ){
|
||||
break;
|
||||
}else{
|
||||
tokenType = TK_SEMI;
|
||||
}
|
||||
n = 0;
|
||||
n = sqlite3GetToken((u8*)zSql, &tokenType);
|
||||
mxSqlLen -= n;
|
||||
if( mxSqlLen<0 ){
|
||||
pParse->rc = SQLITE_TOOBIG;
|
||||
break;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( tokenType>=TK_WINDOW ){
|
||||
assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
|
||||
|| tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
|
||||
);
|
||||
#else
|
||||
if( tokenType>=TK_SPACE ){
|
||||
assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
|
||||
#endif // SQLITE_OMIT_WINDOWFUNC
|
||||
if( db->u1.isInterrupted ){
|
||||
pParse->rc = SQLITE_INTERRUPT;
|
||||
break;
|
||||
}
|
||||
if( tokenType==TK_ILLEGAL ){
|
||||
if( tokenType==TK_SPACE ){
|
||||
zSql += n;
|
||||
continue;
|
||||
}
|
||||
if( zSql[0]==0 ){
|
||||
/* Upon reaching the end of input, call the parser two more times
|
||||
** with tokens TK_SEMI and 0, in that order. */
|
||||
if( lastTokenParsed==TK_SEMI ){
|
||||
tokenType = 0;
|
||||
}else if( lastTokenParsed==0 ){
|
||||
break;
|
||||
}else{
|
||||
tokenType = TK_SEMI;
|
||||
}
|
||||
n = 0;
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
}else if( tokenType==TK_WINDOW ){
|
||||
assert( n==6 );
|
||||
tokenType = analyzeWindowKeyword((const u8*)&zSql[6]);
|
||||
}else if( tokenType==TK_OVER ){
|
||||
assert( n==4 );
|
||||
tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
|
||||
}else if( tokenType==TK_FILTER ){
|
||||
assert( n==6 );
|
||||
tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
|
||||
#endif // SQLITE_OMIT_WINDOWFUNC
|
||||
}else{
|
||||
sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
|
||||
break;
|
||||
}
|
||||
zSql += n;
|
||||
}else{
|
||||
pParse->sLastToken.z = zSql;
|
||||
pParse->sLastToken.n = n;
|
||||
sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
|
||||
lastTokenParsed = tokenType;
|
||||
zSql += n;
|
||||
if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
|
||||
}
|
||||
pParse->sLastToken.z = zSql;
|
||||
pParse->sLastToken.n = n;
|
||||
sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
|
||||
lastTokenParsed = tokenType;
|
||||
zSql += n;
|
||||
if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
|
||||
}
|
||||
assert( nErr==0 );
|
||||
pParse->zTail = zSql;
|
||||
#ifdef YYTRACKMAXSTACKDEPTH
|
||||
sqlite3_mutex_enter(sqlite3MallocMutex());
|
||||
sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,
|
||||
@@ -571,10 +669,12 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
|
||||
assert( pzErrMsg!=0 );
|
||||
if( pParse->zErrMsg ){
|
||||
*pzErrMsg = pParse->zErrMsg;
|
||||
sqlite3_log(pParse->rc, "%s", *pzErrMsg);
|
||||
sqlite3_log(pParse->rc, "%s in \"%s\"",
|
||||
*pzErrMsg, pParse->zTail);
|
||||
pParse->zErrMsg = 0;
|
||||
nErr++;
|
||||
}
|
||||
pParse->zTail = zSql;
|
||||
if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
|
||||
sqlite3VdbeDelete(pParse->pVdbe);
|
||||
pParse->pVdbe = 0;
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
|
||||
*/
|
||||
rc = execSql(db, pzErrMsg, "BEGIN");
|
||||
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
||||
rc = sqlite3BtreeBeginTrans(pMain, 2);
|
||||
rc = sqlite3BtreeBeginTrans(pMain, 2, 0);
|
||||
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
||||
|
||||
/* Do not attempt to change the page size for a WAL database */
|
||||
|
||||
+158
-52
@@ -36,6 +36,18 @@
|
||||
# define memAboutToChange(P,M)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Given a cursor number and a column for a table or index, compute a
|
||||
** hash value for use in the Mem.iTabColHash value. The iTabColHash
|
||||
** column is only used for verification - it is omitted from production
|
||||
** builds. Collisions are harmless in the sense that the correct answer
|
||||
** still results. The only harm of collisions is that they can potential
|
||||
** reduce column-cache error detection during SQLITE_DEBUG builds.
|
||||
**
|
||||
** No valid hash should be 0.
|
||||
*/
|
||||
#define TableColumnHash(T,C) (((u32)(T)<<16)^(u32)(C+2))
|
||||
|
||||
/*
|
||||
** The following global variable is incremented every time a cursor
|
||||
** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test
|
||||
@@ -1264,10 +1276,12 @@ case OP_Copy: {
|
||||
pOut = &aMem[pOp->p2];
|
||||
assert( pOut!=pIn1 );
|
||||
while( 1 ){
|
||||
memAboutToChange(p, pOut);
|
||||
sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
|
||||
Deephemeralize(pOut);
|
||||
#ifdef SQLITE_DEBUG
|
||||
pOut->pScopyFrom = 0;
|
||||
pOut->iTabColHash = 0;
|
||||
#endif
|
||||
REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
|
||||
if( (n--)==0 ) break;
|
||||
@@ -1296,7 +1310,8 @@ case OP_SCopy: { /* out2 */
|
||||
assert( pOut!=pIn1 );
|
||||
sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;
|
||||
pOut->pScopyFrom = pIn1;
|
||||
pOut->mScopyFlags = pIn1->flags;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -2245,7 +2260,7 @@ case OP_Not: { /* same as TK_NOT, in1, out2 */
|
||||
}
|
||||
|
||||
/* Opcode: BitNot P1 P2 * * *
|
||||
** Synopsis: r[P1]= ~r[P1]
|
||||
** Synopsis: r[P2]= ~r[P1]
|
||||
**
|
||||
** Interpret the content of register P1 as an integer. Store the
|
||||
** ones-complement of the P1 value into register P2. If P1 holds
|
||||
@@ -3202,8 +3217,7 @@ case OP_AutoCommit: {
|
||||
*/
|
||||
case OP_Transaction: {
|
||||
Btree *pBt;
|
||||
int iMeta;
|
||||
int iGen;
|
||||
int iMeta = 0;
|
||||
|
||||
assert( p->bIsReader );
|
||||
assert( p->readOnly==0 || pOp->p2==0 );
|
||||
@@ -3216,7 +3230,7 @@ case OP_Transaction: {
|
||||
pBt = db->aDb[pOp->p1].pBt;
|
||||
|
||||
if( pBt ){
|
||||
rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);
|
||||
rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, &iMeta);
|
||||
testcase( rc==SQLITE_BUSY_SNAPSHOT );
|
||||
testcase( rc==SQLITE_BUSY_RECOVERY );
|
||||
if( rc!=SQLITE_OK ){
|
||||
@@ -3249,19 +3263,17 @@ case OP_Transaction: {
|
||||
p->nStmtDefCons = db->nDeferredCons;
|
||||
p->nStmtDefImmCons = db->nDeferredImmCons;
|
||||
}
|
||||
|
||||
/* Gather the schema version number for checking:
|
||||
}
|
||||
assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
|
||||
if( pOp->p5
|
||||
&& (iMeta!=pOp->p3
|
||||
|| db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i)
|
||||
){
|
||||
/*
|
||||
** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema
|
||||
** version is checked to ensure that the schema has not changed since the
|
||||
** SQL statement was prepared.
|
||||
*/
|
||||
sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
|
||||
iGen = db->aDb[pOp->p1].pSchema->iGeneration;
|
||||
}else{
|
||||
iGen = iMeta = 0;
|
||||
}
|
||||
assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
|
||||
if( pOp->p5 && (iMeta!=pOp->p3 || iGen!=pOp->p4.i) ){
|
||||
sqlite3DbFree(db, p->zErrMsg);
|
||||
p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
|
||||
/* If the schema-cookie from the database file matches the cookie
|
||||
@@ -3626,7 +3638,7 @@ case OP_OpenEphemeral: {
|
||||
rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
|
||||
BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1);
|
||||
rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
/* If a transient index is required, create it by calling
|
||||
@@ -4034,6 +4046,25 @@ seek_not_found:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: SeekHit P1 P2 * * *
|
||||
** Synopsis: seekHit=P2
|
||||
**
|
||||
** Set the seekHit flag on cursor P1 to the value in P2.
|
||||
** The seekHit flag is used by the IfNoHope opcode.
|
||||
**
|
||||
** P1 must be a valid b-tree cursor. P2 must be a boolean value,
|
||||
** either 0 or 1.
|
||||
*/
|
||||
case OP_SeekHit: {
|
||||
VdbeCursor *pC;
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
||||
pC = p->apCsr[pOp->p1];
|
||||
assert( pC!=0 );
|
||||
assert( pOp->p2==0 || pOp->p2==1 );
|
||||
pC->seekHit = pOp->p2 & 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: Found P1 P2 P3 P4 *
|
||||
** Synopsis: key=r[P3@P4]
|
||||
**
|
||||
@@ -4068,7 +4099,34 @@ seek_not_found:
|
||||
** advanced in either direction. In other words, the Next and Prev
|
||||
** opcodes do not work after this operation.
|
||||
**
|
||||
** See also: Found, NotExists, NoConflict
|
||||
** See also: Found, NotExists, NoConflict, IfNoHope
|
||||
*/
|
||||
/* Opcode: IfNoHope P1 P2 P3 P4 *
|
||||
** Synopsis: key=r[P3@P4]
|
||||
**
|
||||
** Register P3 is the first of P4 registers that form an unpacked
|
||||
** record.
|
||||
**
|
||||
** Cursor P1 is on an index btree. If the seekHit flag is set on P1, then
|
||||
** this opcode is a no-op. But if the seekHit flag of P1 is clear, then
|
||||
** check to see if there is any entry in P1 that matches the
|
||||
** prefix identified by P3 and P4. If no entry matches the prefix,
|
||||
** jump to P2. Otherwise fall through.
|
||||
**
|
||||
** This opcode behaves like OP_NotFound if the seekHit
|
||||
** flag is clear and it behaves like OP_Noop if the seekHit flag is set.
|
||||
**
|
||||
** This opcode is used in IN clause processing for a multi-column key.
|
||||
** If an IN clause is attached to an element of the key other than the
|
||||
** left-most element, and if there are no matches on the most recent
|
||||
** seek over the whole key, then it might be that one of the key element
|
||||
** to the left is prohibiting a match, and hence there is "no hope" of
|
||||
** any match regardless of how many IN clause elements are checked.
|
||||
** In such a case, we abandon the IN clause search early, using this
|
||||
** opcode. The opcode name comes from the fact that the
|
||||
** jump is taken if there is "no hope" of achieving a match.
|
||||
**
|
||||
** See also: NotFound, SeekHit
|
||||
*/
|
||||
/* Opcode: NoConflict P1 P2 P3 P4 *
|
||||
** Synopsis: key=r[P3@P4]
|
||||
@@ -4093,6 +4151,14 @@ seek_not_found:
|
||||
**
|
||||
** See also: NotFound, Found, NotExists
|
||||
*/
|
||||
case OP_IfNoHope: { /* jump, in3 */
|
||||
VdbeCursor *pC;
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
||||
pC = p->apCsr[pOp->p1];
|
||||
assert( pC!=0 );
|
||||
if( pC->seekHit ) break;
|
||||
/* Fall through into OP_NotFound */
|
||||
}
|
||||
case OP_NoConflict: /* jump, in3 */
|
||||
case OP_NotFound: /* jump, in3 */
|
||||
case OP_Found: { /* jump, in3 */
|
||||
@@ -4241,7 +4307,7 @@ case OP_NotExists: /* jump, in3 */
|
||||
pC = p->apCsr[pOp->p1];
|
||||
assert( pC!=0 );
|
||||
#ifdef SQLITE_DEBUG
|
||||
pC->seekOp = 0;
|
||||
pC->seekOp = OP_SeekRowid;
|
||||
#endif
|
||||
assert( pC->isTable );
|
||||
assert( pC->eCurType==CURTYPE_BTREE );
|
||||
@@ -4895,6 +4961,9 @@ case OP_NullRow: {
|
||||
assert( pC->uc.pCursor!=0 );
|
||||
sqlite3BtreeClearCursor(pC->uc.pCursor);
|
||||
}
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( pC->seekOp==0 ) pC->seekOp = OP_NullRow;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5013,7 +5082,7 @@ case OP_Sort: { /* jump */
|
||||
p->aCounter[SQLITE_STMTSTATUS_SORT]++;
|
||||
/* Fall through into OP_Rewind */
|
||||
}
|
||||
/* Opcode: Rewind P1 P2 * * *
|
||||
/* Opcode: Rewind P1 P2 * * P5
|
||||
**
|
||||
** The next use of the Rowid or Column or Next instruction for P1
|
||||
** will refer to the first entry in the database table or index.
|
||||
@@ -5021,6 +5090,10 @@ case OP_Sort: { /* jump */
|
||||
** If the table or index is not empty, fall through to the following
|
||||
** instruction.
|
||||
**
|
||||
** If P5 is non-zero and the table is not empty, then the "skip-next"
|
||||
** flag is set on the cursor so that the next OP_Next instruction
|
||||
** executed on it is a no-op.
|
||||
**
|
||||
** This opcode leaves the cursor configured to move in forward order,
|
||||
** from the beginning toward the end. In other words, the cursor is
|
||||
** configured to use Next, not Prev.
|
||||
@@ -5045,6 +5118,9 @@ case OP_Rewind: { /* jump */
|
||||
pCrsr = pC->uc.pCursor;
|
||||
assert( pCrsr );
|
||||
rc = sqlite3BtreeFirst(pCrsr, &res);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( pOp->p5 ) sqlite3BtreeSkipNext(pCrsr);
|
||||
#endif
|
||||
pC->deferredMoveto = 0;
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
}
|
||||
@@ -5081,12 +5157,7 @@ case OP_Rewind: { /* jump */
|
||||
** If P5 is positive and the jump is taken, then event counter
|
||||
** number P5-1 in the prepared statement is incremented.
|
||||
**
|
||||
** See also: Prev, NextIfOpen
|
||||
*/
|
||||
/* Opcode: NextIfOpen P1 P2 P3 P4 P5
|
||||
**
|
||||
** This opcode works just like Next except that if cursor P1 is not
|
||||
** open it behaves a no-op.
|
||||
** See also: Prev
|
||||
*/
|
||||
/* Opcode: Prev P1 P2 P3 P4 P5
|
||||
**
|
||||
@@ -5114,11 +5185,6 @@ case OP_Rewind: { /* jump */
|
||||
** If P5 is positive and the jump is taken, then event counter
|
||||
** number P5-1 in the prepared statement is incremented.
|
||||
*/
|
||||
/* Opcode: PrevIfOpen P1 P2 P3 P4 P5
|
||||
**
|
||||
** This opcode works just like Prev except that if cursor P1 is not
|
||||
** open it behaves a no-op.
|
||||
*/
|
||||
/* Opcode: SorterNext P1 P2 * * P5
|
||||
**
|
||||
** This opcode works just like OP_Next except that P1 must be a
|
||||
@@ -5133,10 +5199,6 @@ case OP_SorterNext: { /* jump */
|
||||
assert( isSorter(pC) );
|
||||
rc = sqlite3VdbeSorterNext(db, pC);
|
||||
goto next_tail;
|
||||
case OP_PrevIfOpen: /* jump */
|
||||
case OP_NextIfOpen: /* jump */
|
||||
if( p->apCsr[pOp->p1]==0 ) break;
|
||||
/* Fall through */
|
||||
case OP_Prev: /* jump */
|
||||
case OP_Next: /* jump */
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
||||
@@ -5147,17 +5209,17 @@ case OP_Next: /* jump */
|
||||
assert( pC->eCurType==CURTYPE_BTREE );
|
||||
assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
|
||||
assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
|
||||
assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );
|
||||
assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);
|
||||
|
||||
/* The Next opcode is only used after SeekGT, SeekGE, and Rewind.
|
||||
/* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
|
||||
** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
|
||||
assert( pOp->opcode!=OP_Next || pOp->opcode!=OP_NextIfOpen
|
||||
assert( pOp->opcode!=OP_Next
|
||||
|| pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
|
||||
|| pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);
|
||||
assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen
|
||||
|| pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
|
||||
|| pC->seekOp==OP_NullRow);
|
||||
assert( pOp->opcode!=OP_Prev
|
||||
|| pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
|
||||
|| pC->seekOp==OP_Last );
|
||||
|| pC->seekOp==OP_Last
|
||||
|| pC->seekOp==OP_NullRow);
|
||||
|
||||
rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
|
||||
next_tail:
|
||||
@@ -6226,24 +6288,24 @@ case OP_DecrJumpZero: { /* jump, in1 */
|
||||
}
|
||||
|
||||
|
||||
/* Opcode: AggStep0 * P2 P3 P4 P5
|
||||
/* Opcode: AggStep0 P1 P2 P3 P4 P5
|
||||
** Synopsis: accum=r[P3] step(r[P2@P5])
|
||||
**
|
||||
** Execute the step function for an aggregate. The
|
||||
** function has P5 arguments. P4 is a pointer to the FuncDef
|
||||
** structure that specifies the function. Register P3 is the
|
||||
** Execute the xStep (if P1==0) or xInverse (if P1!=0) function for an
|
||||
** aggregate. The function has P5 arguments. P4 is a pointer to the
|
||||
** FuncDef structure that specifies the function. Register P3 is the
|
||||
** accumulator.
|
||||
**
|
||||
** The P5 arguments are taken from register P2 and its
|
||||
** successors.
|
||||
*/
|
||||
/* Opcode: AggStep * P2 P3 P4 P5
|
||||
/* Opcode: AggStep P1 P2 P3 P4 P5
|
||||
** Synopsis: accum=r[P3] step(r[P2@P5])
|
||||
**
|
||||
** Execute the step function for an aggregate. The
|
||||
** function has P5 arguments. P4 is a pointer to an sqlite3_context
|
||||
** object that is used to run the function. Register P3 is
|
||||
** as the accumulator.
|
||||
** Execute the xStep (if P1==0) or xInverse (if P1!=0) function for an
|
||||
** aggregate. The function has P5 arguments. P4 is a pointer to the
|
||||
** FuncDef structure that specifies the function. Register P3 is the
|
||||
** accumulator.
|
||||
**
|
||||
** The P5 arguments are taken from register P2 and its
|
||||
** successors.
|
||||
@@ -6309,7 +6371,13 @@ case OP_AggStep: {
|
||||
assert( pCtx->pOut->flags==MEM_Null );
|
||||
assert( pCtx->isError==0 );
|
||||
assert( pCtx->skipFlag==0 );
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( pOp->p1 ){
|
||||
(pCtx->pFunc->xInverse)(pCtx,pCtx->argc,pCtx->argv);
|
||||
}else
|
||||
#endif
|
||||
(pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */
|
||||
|
||||
if( pCtx->isError ){
|
||||
if( pCtx->isError>0 ){
|
||||
sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
|
||||
@@ -6331,11 +6399,13 @@ case OP_AggStep: {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: AggFinal P1 P2 * P4 *
|
||||
/* Opcode: AggFinal P1 P2 P3 P4 *
|
||||
** Synopsis: accum=r[P1] N=P2
|
||||
**
|
||||
** Execute the finalizer function for an aggregate. P1 is
|
||||
** the memory location that is the accumulator for the aggregate.
|
||||
** P1 is the memory location that is the accumulator for an aggregate
|
||||
** or window function. If P3 is zero, then execute the finalizer function
|
||||
** for an aggregate and store the result in P1. Or, if P3 is non-zero,
|
||||
** invoke the xValue() function and store the result in register P3.
|
||||
**
|
||||
** P2 is the number of arguments that the step function takes and
|
||||
** P4 is a pointer to the FuncDef for this function. The P2
|
||||
@@ -6349,7 +6419,14 @@ case OP_AggFinal: {
|
||||
assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
|
||||
pMem = &aMem[pOp->p1];
|
||||
assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( pOp->p3 ){
|
||||
rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);
|
||||
pMem = &aMem[pOp->p3];
|
||||
}else
|
||||
#endif
|
||||
rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
|
||||
|
||||
if( rc ){
|
||||
sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
|
||||
goto abort_due_to_error;
|
||||
@@ -6944,6 +7021,7 @@ case OP_VUpdate: {
|
||||
|| pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
|
||||
);
|
||||
assert( p->readOnly==0 );
|
||||
if( db->mallocFailed ) goto no_mem;
|
||||
sqlite3VdbeIncrWriteCounter(p, 0);
|
||||
pVtab = pOp->p4.pVtab->pVtab;
|
||||
if( pVtab==0 || NEVER(pVtab->pModule==0) ){
|
||||
@@ -7278,6 +7356,34 @@ case OP_Abortable: {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
/* Opcode: SetTabCol P1 P2 P3 * *
|
||||
**
|
||||
** Set a flag in register REG[P3] indicating that it holds the value
|
||||
** of column P2 from the table on cursor P1. This flag is checked
|
||||
** by a subsequent VerifyTabCol opcode.
|
||||
**
|
||||
** This opcode only appears SQLITE_DEBUG builds. It is used to verify
|
||||
** that the expression table column cache is working correctly.
|
||||
*/
|
||||
case OP_SetTabCol: {
|
||||
aMem[pOp->p3].iTabColHash = TableColumnHash(pOp->p1,pOp->p2);
|
||||
break;
|
||||
}
|
||||
/* Opcode: VerifyTabCol P1 P2 P3 * *
|
||||
**
|
||||
** Verify that register REG[P3] contains the value of column P2 from
|
||||
** cursor P1. Assert() if this is not the case.
|
||||
**
|
||||
** This opcode only appears SQLITE_DEBUG builds. It is used to verify
|
||||
** that the expression table column cache is working correctly.
|
||||
*/
|
||||
case OP_VerifyTabCol: {
|
||||
assert( aMem[pOp->p3].iTabColHash == TableColumnHash(pOp->p1,pOp->p2) );
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Opcode: Noop * * * * *
|
||||
**
|
||||
** Do nothing. This instruction is often useful as a jump
|
||||
|
||||
@@ -243,6 +243,7 @@ void sqlite3VdbeResolveLabel(Vdbe*, int);
|
||||
int sqlite3VdbeCurrentAddr(Vdbe*);
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3VdbeAssertMayAbort(Vdbe *, int);
|
||||
int sqlite3VdbeAssertAggContext(sqlite3_context*);
|
||||
#endif
|
||||
void sqlite3VdbeResetStepResult(Vdbe*);
|
||||
void sqlite3VdbeRewind(Vdbe*);
|
||||
@@ -261,6 +262,7 @@ void sqlite3VdbeSetVarmask(Vdbe*, int);
|
||||
char *sqlite3VdbeExpandSql(Vdbe*, const char*);
|
||||
#endif
|
||||
int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
|
||||
int sqlite3BlobCompare(const Mem*, const Mem*);
|
||||
|
||||
void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
|
||||
int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
|
||||
@@ -342,4 +344,8 @@ void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
|
||||
# define sqlite3VdbeScanStatus(a,b,c,d,e)
|
||||
#endif
|
||||
|
||||
#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
|
||||
void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_VDBE_H */
|
||||
|
||||
+9
-4
@@ -85,6 +85,7 @@ struct VdbeCursor {
|
||||
Bool isEphemeral:1; /* True for an ephemeral table */
|
||||
Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */
|
||||
Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
|
||||
Bool seekHit:1; /* See the OP_SeekHit and OP_IfNoHope opcodes */
|
||||
Btree *pBtx; /* Separate file holding temporary table */
|
||||
i64 seqCount; /* Sequence counter */
|
||||
int *aAltMap; /* Mapping from table to index column numbers */
|
||||
@@ -208,7 +209,11 @@ struct sqlite3_value {
|
||||
void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
|
||||
#ifdef SQLITE_DEBUG
|
||||
Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
|
||||
void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */
|
||||
u16 mScopyFlags; /* flags value immediately after the shallow copy */
|
||||
#endif
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
u32 iTabColHash; /* Hash of table.column that is origin of this value */
|
||||
u32 iPadding; /* sqlite3_value objects must be 8-byte aligned */
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -448,9 +453,6 @@ void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
|
||||
void sqliteVdbePopStack(Vdbe*,int);
|
||||
int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);
|
||||
int sqlite3VdbeCursorRestore(VdbeCursor*);
|
||||
#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
|
||||
void sqlite3VdbePrintOp(FILE*, int, Op*);
|
||||
#endif
|
||||
u32 sqlite3VdbeSerialTypeLen(u32);
|
||||
u8 sqlite3VdbeOneByteSerialTypeLen(u8);
|
||||
u32 sqlite3VdbeSerialType(Mem*, int, u32*);
|
||||
@@ -495,6 +497,9 @@ void sqlite3VdbeMemCast(Mem*,u8,u8);
|
||||
int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
|
||||
void sqlite3VdbeMemRelease(Mem *p);
|
||||
int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
|
||||
#endif
|
||||
const char *sqlite3OpcodeName(int);
|
||||
int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
|
||||
int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
|
||||
|
||||
+16
-1
@@ -824,6 +824,18 @@ void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is only used within assert() statements to check that the
|
||||
** aggregate context has already been allocated. i.e.:
|
||||
**
|
||||
** assert( sqlite3VdbeAssertAggContext(p) );
|
||||
*/
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3VdbeAssertAggContext(sqlite3_context *p){
|
||||
return ((p->pMem->flags & MEM_Agg)!=0);
|
||||
}
|
||||
#endif /* SQLITE_DEBUG */
|
||||
|
||||
/*
|
||||
** Return the auxiliary data pointer, if any, for the iArg'th argument to
|
||||
** the user-function defined by pCtx.
|
||||
@@ -970,7 +982,10 @@ static const Mem *columnNullValue(void){
|
||||
/* .xDel = */ (void(*)(void*))0,
|
||||
#ifdef SQLITE_DEBUG
|
||||
/* .pScopyFrom = */ (Mem*)0,
|
||||
/* .pFiller = */ (void*)0,
|
||||
/* .mScopyFlags= */ 0,
|
||||
#endif
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
/* .iTabColHash= */ 0,
|
||||
#endif
|
||||
};
|
||||
return &nullMem;
|
||||
|
||||
+13
-11
@@ -689,7 +689,6 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
|
||||
break;
|
||||
}
|
||||
case OP_Next:
|
||||
case OP_NextIfOpen:
|
||||
case OP_SorterNext: {
|
||||
pOp->p4.xAdvance = sqlite3BtreeNext;
|
||||
pOp->p4type = P4_ADVANCE;
|
||||
@@ -699,8 +698,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
|
||||
assert( pOp->p2>=0 );
|
||||
break;
|
||||
}
|
||||
case OP_Prev:
|
||||
case OP_PrevIfOpen: {
|
||||
case OP_Prev: {
|
||||
pOp->p4.xAdvance = sqlite3BtreePrevious;
|
||||
pOp->p4type = P4_ADVANCE;
|
||||
/* The code generator never codes any of these opcodes as a jump
|
||||
@@ -1615,7 +1613,7 @@ void sqlite3VdbeLeave(Vdbe *p){
|
||||
/*
|
||||
** Print a single opcode. This routine is used for debugging only.
|
||||
*/
|
||||
void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){
|
||||
void sqlite3VdbePrintOp(FILE *pOut, int pc, VdbeOp *pOp){
|
||||
char *zP4;
|
||||
char zPtr[50];
|
||||
char zCom[100];
|
||||
@@ -1648,6 +1646,9 @@ static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
|
||||
p->szMalloc = 0;
|
||||
#ifdef SQLITE_DEBUG
|
||||
p->pScopyFrom = 0;
|
||||
#endif
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
p->iTabColHash = 0;
|
||||
#endif
|
||||
p++;
|
||||
}
|
||||
@@ -3914,7 +3915,7 @@ static int isAllZero(const char *z, int n){
|
||||
** is less than, equal to, or greater than the second, respectively.
|
||||
** If one blob is a prefix of the other, then the shorter is the lessor.
|
||||
*/
|
||||
static SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
|
||||
SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
|
||||
int c;
|
||||
int n1 = pB1->n;
|
||||
int n2 = pB2->n;
|
||||
@@ -4129,7 +4130,7 @@ int sqlite3VdbeRecordCompareWithSkip(
|
||||
u32 idx1; /* Offset of first type in header */
|
||||
int rc = 0; /* Return value */
|
||||
Mem *pRhs = pPKey2->aMem; /* Next field of pPKey2 to compare */
|
||||
KeyInfo *pKeyInfo = pPKey2->pKeyInfo;
|
||||
KeyInfo *pKeyInfo;
|
||||
const unsigned char *aKey1 = (const unsigned char *)pKey1;
|
||||
Mem mem1;
|
||||
|
||||
@@ -4224,7 +4225,7 @@ int sqlite3VdbeRecordCompareWithSkip(
|
||||
if( (d1+mem1.n) > (unsigned)nKey1 ){
|
||||
pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
|
||||
return 0; /* Corruption */
|
||||
}else if( pKeyInfo->aColl[i] ){
|
||||
}else if( (pKeyInfo = pPKey2->pKeyInfo)->aColl[i] ){
|
||||
mem1.enc = pKeyInfo->enc;
|
||||
mem1.db = pKeyInfo->db;
|
||||
mem1.flags = MEM_Str;
|
||||
@@ -4275,7 +4276,7 @@ int sqlite3VdbeRecordCompareWithSkip(
|
||||
}
|
||||
|
||||
if( rc!=0 ){
|
||||
if( pKeyInfo->aSortOrder[i] ){
|
||||
if( pPKey2->pKeyInfo->aSortOrder[i] ){
|
||||
rc = -rc;
|
||||
}
|
||||
assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
|
||||
@@ -4284,10 +4285,11 @@ int sqlite3VdbeRecordCompareWithSkip(
|
||||
}
|
||||
|
||||
i++;
|
||||
if( i==pPKey2->nField ) break;
|
||||
pRhs++;
|
||||
d1 += sqlite3VdbeSerialTypeLen(serial_type);
|
||||
idx1 += sqlite3VarintLen(serial_type);
|
||||
}while( idx1<(unsigned)szHdr1 && i<pPKey2->nField && d1<=(unsigned)nKey1 );
|
||||
}while( idx1<(unsigned)szHdr1 && d1<=(unsigned)nKey1 );
|
||||
|
||||
/* No memory allocation is ever used on mem1. Prove this using
|
||||
** the following assert(). If the assert() fails, it indicates a
|
||||
@@ -4299,7 +4301,7 @@ int sqlite3VdbeRecordCompareWithSkip(
|
||||
** value. */
|
||||
assert( CORRUPT_DB
|
||||
|| vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc)
|
||||
|| pKeyInfo->db->mallocFailed
|
||||
|| pPKey2->pKeyInfo->db->mallocFailed
|
||||
);
|
||||
pPKey2->eqSeen = 1;
|
||||
return pPKey2->default_rc;
|
||||
@@ -4625,7 +4627,7 @@ int sqlite3VdbeIdxKeyCompare(
|
||||
if( rc ){
|
||||
return rc;
|
||||
}
|
||||
*res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked);
|
||||
*res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, pUnpacked, 0);
|
||||
sqlite3VdbeMemRelease(&m);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
+52
-1
@@ -415,6 +415,34 @@ int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
|
||||
return ctx.isError;
|
||||
}
|
||||
|
||||
/*
|
||||
** Memory cell pAccum contains the context of an aggregate function.
|
||||
** This routine calls the xValue method for that function and stores
|
||||
** the results in memory cell pMem.
|
||||
**
|
||||
** SQLITE_ERROR is returned if xValue() reports an error. SQLITE_OK
|
||||
** otherwise.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){
|
||||
sqlite3_context ctx;
|
||||
Mem t;
|
||||
assert( pFunc!=0 );
|
||||
assert( pFunc->xValue!=0 );
|
||||
assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef );
|
||||
assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) );
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
memset(&t, 0, sizeof(t));
|
||||
t.flags = MEM_Null;
|
||||
t.db = pAccum->db;
|
||||
ctx.pOut = pOut;
|
||||
ctx.pMem = pAccum;
|
||||
ctx.pFunc = pFunc;
|
||||
pFunc->xValue(&ctx);
|
||||
return ctx.isError;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_WINDOWFUNC */
|
||||
|
||||
/*
|
||||
** If the memory cell contains a value that must be freed by
|
||||
** invoking the external callback in Mem.xDel, then this routine
|
||||
@@ -886,11 +914,28 @@ void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
|
||||
Mem *pX;
|
||||
for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){
|
||||
if( pX->pScopyFrom==pMem ){
|
||||
pX->flags |= MEM_Undefined;
|
||||
/* If pX is marked as a shallow copy of pMem, then verify that
|
||||
** no significant changes have been made to pX since the OP_SCopy.
|
||||
** A significant change would indicated a missed call to this
|
||||
** function for pX. Minor changes, such as adding or removing a
|
||||
** dual type, are allowed, as long as the underlying value is the
|
||||
** same. */
|
||||
u16 mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
|
||||
assert( (mFlags&MEM_Int)==0 || pMem->u.i==pX->u.i );
|
||||
assert( (mFlags&MEM_Real)==0 || pMem->u.r==pX->u.r );
|
||||
assert( (mFlags&MEM_Str)==0 || (pMem->n==pX->n && pMem->z==pX->z) );
|
||||
assert( (mFlags&MEM_Blob)==0 || sqlite3BlobCompare(pMem,pX)==0 );
|
||||
|
||||
/* pMem is the register that is changing. But also mark pX as
|
||||
** undefined so that we can quickly detect the shallow-copy error */
|
||||
pX->flags = MEM_Undefined;
|
||||
pX->pScopyFrom = 0;
|
||||
}
|
||||
}
|
||||
pMem->pScopyFrom = 0;
|
||||
#ifdef SQLITE_DEBUG_COLUMN_CACHE
|
||||
pMem->iTabColHash = 0;
|
||||
#endif
|
||||
}
|
||||
#endif /* SQLITE_DEBUG */
|
||||
|
||||
@@ -911,6 +956,9 @@ void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
|
||||
assert( pTo->db==pFrom->db );
|
||||
if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }
|
||||
memcpy(pTo, pFrom, MEMCELLSIZE);
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
pTo->iTabColHash = pFrom->iTabColHash;
|
||||
#endif
|
||||
if( (pFrom->flags&MEM_Static)==0 ){
|
||||
pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
|
||||
assert( srcType==MEM_Ephem || srcType==MEM_Static );
|
||||
@@ -928,6 +976,9 @@ int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
|
||||
assert( (pFrom->flags & MEM_RowSet)==0 );
|
||||
if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
|
||||
memcpy(pTo, pFrom, MEMCELLSIZE);
|
||||
#ifdef SQLITE_DEBUG_COLUMNCACHE
|
||||
pTo->iTabColHash = pFrom->iTabColHash;
|
||||
#endif
|
||||
pTo->flags &= ~MEM_Dyn;
|
||||
if( pTo->flags&(MEM_Str|MEM_Blob) ){
|
||||
if( 0==(pFrom->flags&MEM_Static) ){
|
||||
|
||||
@@ -880,48 +880,51 @@ static int walNextHash(int iPriorHash){
|
||||
return (iPriorHash+1)&(HASHTABLE_NSLOT-1);
|
||||
}
|
||||
|
||||
/*
|
||||
** An instance of the WalHashLoc object is used to describe the location
|
||||
** of a page hash table in the wal-index. This becomes the return value
|
||||
** from walHashGet().
|
||||
*/
|
||||
typedef struct WalHashLoc WalHashLoc;
|
||||
struct WalHashLoc {
|
||||
volatile ht_slot *aHash; /* Start of the wal-index hash table */
|
||||
volatile u32 *aPgno; /* aPgno[1] is the page of first frame indexed */
|
||||
u32 iZero; /* One less than the frame number of first indexed*/
|
||||
};
|
||||
|
||||
/*
|
||||
** Return pointers to the hash table and page number array stored on
|
||||
** page iHash of the wal-index. The wal-index is broken into 32KB pages
|
||||
** numbered starting from 0.
|
||||
**
|
||||
** Set output variable *paHash to point to the start of the hash table
|
||||
** in the wal-index file. Set *piZero to one less than the frame
|
||||
** Set output variable pLoc->aHash to point to the start of the hash table
|
||||
** in the wal-index file. Set pLoc->iZero to one less than the frame
|
||||
** number of the first frame indexed by this hash table. If a
|
||||
** slot in the hash table is set to N, it refers to frame number
|
||||
** (*piZero+N) in the log.
|
||||
** (pLoc->iZero+N) in the log.
|
||||
**
|
||||
** Finally, set *paPgno so that *paPgno[1] is the page number of the
|
||||
** first frame indexed by the hash table, frame (*piZero+1).
|
||||
** Finally, set pLoc->aPgno so that pLoc->aPgno[1] is the page number of the
|
||||
** first frame indexed by the hash table, frame (pLoc->iZero+1).
|
||||
*/
|
||||
static int walHashGet(
|
||||
Wal *pWal, /* WAL handle */
|
||||
int iHash, /* Find the iHash'th table */
|
||||
volatile ht_slot **paHash, /* OUT: Pointer to hash index */
|
||||
volatile u32 **paPgno, /* OUT: Pointer to page number array */
|
||||
u32 *piZero /* OUT: Frame associated with *paPgno[0] */
|
||||
WalHashLoc *pLoc /* OUT: Hash table location */
|
||||
){
|
||||
int rc; /* Return code */
|
||||
volatile u32 *aPgno;
|
||||
|
||||
rc = walIndexPage(pWal, iHash, &aPgno);
|
||||
rc = walIndexPage(pWal, iHash, &pLoc->aPgno);
|
||||
assert( rc==SQLITE_OK || iHash>0 );
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
u32 iZero;
|
||||
volatile ht_slot *aHash;
|
||||
|
||||
aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];
|
||||
pLoc->aHash = (volatile ht_slot *)&pLoc->aPgno[HASHTABLE_NPAGE];
|
||||
if( iHash==0 ){
|
||||
aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
|
||||
iZero = 0;
|
||||
pLoc->aPgno = &pLoc->aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
|
||||
pLoc->iZero = 0;
|
||||
}else{
|
||||
iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
|
||||
pLoc->iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
|
||||
}
|
||||
|
||||
*paPgno = &aPgno[-1];
|
||||
*paHash = aHash;
|
||||
*piZero = iZero;
|
||||
pLoc->aPgno = &pLoc->aPgno[-1];
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -967,9 +970,7 @@ static u32 walFramePgno(Wal *pWal, u32 iFrame){
|
||||
** actually needed.
|
||||
*/
|
||||
static void walCleanupHash(Wal *pWal){
|
||||
volatile ht_slot *aHash = 0; /* Pointer to hash table to clear */
|
||||
volatile u32 *aPgno = 0; /* Page number array for hash table */
|
||||
u32 iZero = 0; /* frame == (aHash[x]+iZero) */
|
||||
WalHashLoc sLoc; /* Hash table location */
|
||||
int iLimit = 0; /* Zero values greater than this */
|
||||
int nByte; /* Number of bytes to zero in aPgno[] */
|
||||
int i; /* Used to iterate through aHash[] */
|
||||
@@ -987,24 +988,24 @@ static void walCleanupHash(Wal *pWal){
|
||||
*/
|
||||
assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
|
||||
assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
|
||||
walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);
|
||||
walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
|
||||
|
||||
/* Zero all hash-table entries that correspond to frame numbers greater
|
||||
** than pWal->hdr.mxFrame.
|
||||
*/
|
||||
iLimit = pWal->hdr.mxFrame - iZero;
|
||||
iLimit = pWal->hdr.mxFrame - sLoc.iZero;
|
||||
assert( iLimit>0 );
|
||||
for(i=0; i<HASHTABLE_NSLOT; i++){
|
||||
if( aHash[i]>iLimit ){
|
||||
aHash[i] = 0;
|
||||
if( sLoc.aHash[i]>iLimit ){
|
||||
sLoc.aHash[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Zero the entries in the aPgno array that correspond to frames with
|
||||
** frame numbers greater than pWal->hdr.mxFrame.
|
||||
*/
|
||||
nByte = (int)((char *)aHash - (char *)&aPgno[iLimit+1]);
|
||||
memset((void *)&aPgno[iLimit+1], 0, nByte);
|
||||
nByte = (int)((char *)sLoc.aHash - (char *)&sLoc.aPgno[iLimit+1]);
|
||||
memset((void *)&sLoc.aPgno[iLimit+1], 0, nByte);
|
||||
|
||||
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
|
||||
/* Verify that the every entry in the mapping region is still reachable
|
||||
@@ -1014,10 +1015,10 @@ static void walCleanupHash(Wal *pWal){
|
||||
int j; /* Loop counter */
|
||||
int iKey; /* Hash key */
|
||||
for(j=1; j<=iLimit; j++){
|
||||
for(iKey=walHash(aPgno[j]); aHash[iKey]; iKey=walNextHash(iKey)){
|
||||
if( aHash[iKey]==j ) break;
|
||||
for(iKey=walHash(sLoc.aPgno[j]);sLoc.aHash[iKey];iKey=walNextHash(iKey)){
|
||||
if( sLoc.aHash[iKey]==j ) break;
|
||||
}
|
||||
assert( aHash[iKey]==j );
|
||||
assert( sLoc.aHash[iKey]==j );
|
||||
}
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
|
||||
@@ -1030,11 +1031,9 @@ static void walCleanupHash(Wal *pWal){
|
||||
*/
|
||||
static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
|
||||
int rc; /* Return code */
|
||||
u32 iZero = 0; /* One less than frame number of aPgno[1] */
|
||||
volatile u32 *aPgno = 0; /* Page number array */
|
||||
volatile ht_slot *aHash = 0; /* Hash table */
|
||||
WalHashLoc sLoc; /* Wal-index hash table location */
|
||||
|
||||
rc = walHashGet(pWal, walFramePage(iFrame), &aHash, &aPgno, &iZero);
|
||||
rc = walHashGet(pWal, walFramePage(iFrame), &sLoc);
|
||||
|
||||
/* Assuming the wal-index file was successfully mapped, populate the
|
||||
** page number array and hash table entry.
|
||||
@@ -1044,15 +1043,16 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
|
||||
int idx; /* Value to write to hash-table slot */
|
||||
int nCollide; /* Number of hash collisions */
|
||||
|
||||
idx = iFrame - iZero;
|
||||
idx = iFrame - sLoc.iZero;
|
||||
assert( idx <= HASHTABLE_NSLOT/2 + 1 );
|
||||
|
||||
/* If this is the first entry to be added to this hash-table, zero the
|
||||
** entire hash table and aPgno[] array before proceeding.
|
||||
*/
|
||||
if( idx==1 ){
|
||||
int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);
|
||||
memset((void*)&aPgno[1], 0, nByte);
|
||||
int nByte = (int)((u8 *)&sLoc.aHash[HASHTABLE_NSLOT]
|
||||
- (u8 *)&sLoc.aPgno[1]);
|
||||
memset((void*)&sLoc.aPgno[1], 0, nByte);
|
||||
}
|
||||
|
||||
/* If the entry in aPgno[] is already set, then the previous writer
|
||||
@@ -1061,18 +1061,18 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
|
||||
** Remove the remnants of that writers uncommitted transaction from
|
||||
** the hash-table before writing any new entries.
|
||||
*/
|
||||
if( aPgno[idx] ){
|
||||
if( sLoc.aPgno[idx] ){
|
||||
walCleanupHash(pWal);
|
||||
assert( !aPgno[idx] );
|
||||
assert( !sLoc.aPgno[idx] );
|
||||
}
|
||||
|
||||
/* Write the aPgno[] array entry and the hash-table slot. */
|
||||
nCollide = idx;
|
||||
for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){
|
||||
for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
|
||||
if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
aPgno[idx] = iPage;
|
||||
aHash[iKey] = (ht_slot)idx;
|
||||
sLoc.aPgno[idx] = iPage;
|
||||
sLoc.aHash[iKey] = (ht_slot)idx;
|
||||
|
||||
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
|
||||
/* Verify that the number of entries in the hash table exactly equals
|
||||
@@ -1081,7 +1081,7 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
|
||||
{
|
||||
int i; /* Loop counter */
|
||||
int nEntry = 0; /* Number of entries in the hash table */
|
||||
for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i] ) nEntry++; }
|
||||
for(i=0; i<HASHTABLE_NSLOT; i++){ if( sLoc.aHash[i] ) nEntry++; }
|
||||
assert( nEntry==idx );
|
||||
}
|
||||
|
||||
@@ -1093,10 +1093,12 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
|
||||
if( (idx&0x3ff)==0 ){
|
||||
int i; /* Loop counter */
|
||||
for(i=1; i<=idx; i++){
|
||||
for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){
|
||||
if( aHash[iKey]==i ) break;
|
||||
for(iKey=walHash(sLoc.aPgno[i]);
|
||||
sLoc.aHash[iKey];
|
||||
iKey=walNextHash(iKey)){
|
||||
if( sLoc.aHash[iKey]==i ) break;
|
||||
}
|
||||
assert( aHash[iKey]==i );
|
||||
assert( sLoc.aHash[iKey]==i );
|
||||
}
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
|
||||
@@ -1634,33 +1636,31 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){
|
||||
}
|
||||
|
||||
for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
|
||||
volatile ht_slot *aHash;
|
||||
u32 iZero;
|
||||
volatile u32 *aPgno;
|
||||
WalHashLoc sLoc;
|
||||
|
||||
rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);
|
||||
rc = walHashGet(pWal, i, &sLoc);
|
||||
if( rc==SQLITE_OK ){
|
||||
int j; /* Counter variable */
|
||||
int nEntry; /* Number of entries in this segment */
|
||||
ht_slot *aIndex; /* Sorted index for this segment */
|
||||
|
||||
aPgno++;
|
||||
sLoc.aPgno++;
|
||||
if( (i+1)==nSegment ){
|
||||
nEntry = (int)(iLast - iZero);
|
||||
nEntry = (int)(iLast - sLoc.iZero);
|
||||
}else{
|
||||
nEntry = (int)((u32*)aHash - (u32*)aPgno);
|
||||
nEntry = (int)((u32*)sLoc.aHash - (u32*)sLoc.aPgno);
|
||||
}
|
||||
aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];
|
||||
iZero++;
|
||||
aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[sLoc.iZero];
|
||||
sLoc.iZero++;
|
||||
|
||||
for(j=0; j<nEntry; j++){
|
||||
aIndex[j] = (ht_slot)j;
|
||||
}
|
||||
walMergesort((u32 *)aPgno, aTmp, aIndex, &nEntry);
|
||||
p->aSegment[i].iZero = iZero;
|
||||
walMergesort((u32 *)sLoc.aPgno, aTmp, aIndex, &nEntry);
|
||||
p->aSegment[i].iZero = sLoc.iZero;
|
||||
p->aSegment[i].nEntry = nEntry;
|
||||
p->aSegment[i].aIndex = aIndex;
|
||||
p->aSegment[i].aPgno = (u32 *)aPgno;
|
||||
p->aSegment[i].aPgno = (u32 *)sLoc.aPgno;
|
||||
}
|
||||
}
|
||||
sqlite3_free(aTmp);
|
||||
@@ -2673,16 +2673,14 @@ int sqlite3WalSnapshotRecover(Wal *pWal){
|
||||
}else{
|
||||
u32 i = pInfo->nBackfillAttempted;
|
||||
for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){
|
||||
volatile ht_slot *dummy;
|
||||
volatile u32 *aPgno; /* Array of page numbers */
|
||||
u32 iZero; /* Frame corresponding to aPgno[0] */
|
||||
WalHashLoc sLoc; /* Hash table location */
|
||||
u32 pgno; /* Page number in db file */
|
||||
i64 iDbOff; /* Offset of db file entry */
|
||||
i64 iWalOff; /* Offset of wal file entry */
|
||||
|
||||
rc = walHashGet(pWal, walFramePage(i), &dummy, &aPgno, &iZero);
|
||||
rc = walHashGet(pWal, walFramePage(i), &sLoc);
|
||||
if( rc!=SQLITE_OK ) break;
|
||||
pgno = aPgno[i-iZero];
|
||||
pgno = sLoc.aPgno[i-sLoc.iZero];
|
||||
iDbOff = (i64)(pgno-1) * szPage;
|
||||
|
||||
if( iDbOff+szPage<=szDb ){
|
||||
@@ -2883,21 +2881,20 @@ int sqlite3WalFindFrame(
|
||||
*/
|
||||
iMinHash = walFramePage(pWal->minFrame);
|
||||
for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
|
||||
volatile ht_slot *aHash; /* Pointer to hash table */
|
||||
volatile u32 *aPgno; /* Pointer to array of page numbers */
|
||||
u32 iZero; /* Frame number corresponding to aPgno[0] */
|
||||
WalHashLoc sLoc; /* Hash table location */
|
||||
int iKey; /* Hash slot index */
|
||||
int nCollide; /* Number of hash collisions remaining */
|
||||
int rc; /* Error code */
|
||||
|
||||
rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero);
|
||||
rc = walHashGet(pWal, iHash, &sLoc);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
nCollide = HASHTABLE_NSLOT;
|
||||
for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){
|
||||
u32 iFrame = aHash[iKey] + iZero;
|
||||
if( iFrame<=iLast && iFrame>=pWal->minFrame && aPgno[aHash[iKey]]==pgno ){
|
||||
for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
|
||||
u32 iFrame = sLoc.aHash[iKey] + sLoc.iZero;
|
||||
if( iFrame<=iLast && iFrame>=pWal->minFrame
|
||||
&& sLoc.aPgno[sLoc.aHash[iKey]]==pgno ){
|
||||
assert( iFrame>iRead || CORRUPT_DB );
|
||||
iRead = iFrame;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,14 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
|
||||
}else if( pExpr->x.pList ){
|
||||
if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
if( !ExprHasProperty(pExpr, EP_Reduced) && pExpr->pWin ){
|
||||
Window *pWin = pExpr->pWin;
|
||||
if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
|
||||
if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
|
||||
if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+102
-24
@@ -2043,6 +2043,29 @@ static WhereLoop **whereLoopFindLesser(
|
||||
return 0; /* Discard pTemplate */
|
||||
}
|
||||
|
||||
/* If pTemplate:
|
||||
**
|
||||
** (1) uses the same index as existing where-loop p,
|
||||
** (2) requires the same or a superset of tables to be scanned first,
|
||||
** (3) constraints the same or fewer columns with ==, and
|
||||
** (4) skips more leading columns (skip-scan optimization).
|
||||
**
|
||||
** the discard the template. This ensures that if stat4 data shows that:
|
||||
**
|
||||
** WHERE (a=1 AND b=2)
|
||||
**
|
||||
** is prohibitively expensive the planner does not instead do:
|
||||
**
|
||||
** WHERE (ANY(a) AND b=2)
|
||||
*/
|
||||
if( pTemplate->nSkip>p->nSkip /* (4) */
|
||||
&& pTemplate->u.btree.pIndex==p->u.btree.pIndex /* (1) */
|
||||
&& pTemplate->u.btree.nEq<=p->u.btree.nEq /* (3) */
|
||||
&& (pTemplate->prereq & p->prereq)==p->prereq /* (2) */
|
||||
){
|
||||
return 0; /* Discard pTemplate */
|
||||
}
|
||||
|
||||
/* If pTemplate is always better than p, then cause p to be overwritten
|
||||
** with pTemplate. pTemplate is better than p if:
|
||||
** (1) pTemplate has no more dependences than p, and
|
||||
@@ -2451,7 +2474,6 @@ static int whereLoopAddBtreeIndex(
|
||||
|
||||
if( eOp & WO_IN ){
|
||||
Expr *pExpr = pTerm->pExpr;
|
||||
pNew->wsFlags |= WHERE_COLUMN_IN;
|
||||
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
|
||||
/* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
|
||||
int i;
|
||||
@@ -2471,6 +2493,42 @@ static int whereLoopAddBtreeIndex(
|
||||
assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
|
||||
** changes "x IN (?)" into "x=?". */
|
||||
}
|
||||
if( pProbe->hasStat1 ){
|
||||
LogEst M, logK, safetyMargin;
|
||||
/* Let:
|
||||
** N = the total number of rows in the table
|
||||
** K = the number of entries on the RHS of the IN operator
|
||||
** M = the number of rows in the table that match terms to the
|
||||
** to the left in the same index. If the IN operator is on
|
||||
** the left-most index column, M==N.
|
||||
**
|
||||
** Given the definitions above, it is better to omit the IN operator
|
||||
** from the index lookup and instead do a scan of the M elements,
|
||||
** testing each scanned row against the IN operator separately, if:
|
||||
**
|
||||
** M*log(K) < K*log(N)
|
||||
**
|
||||
** Our estimates for M, K, and N might be inaccurate, so we build in
|
||||
** a safety margin of 2 (LogEst: 10) that favors using the IN operator
|
||||
** with the index, as using an index has better worst-case behavior.
|
||||
** If we do not have real sqlite_stat1 data, always prefer to use
|
||||
** the index.
|
||||
*/
|
||||
M = pProbe->aiRowLogEst[saved_nEq];
|
||||
logK = estLog(nIn);
|
||||
safetyMargin = 10; /* TUNING: extra weight for indexed IN */
|
||||
if( M + logK + safetyMargin < nIn + rLogSize ){
|
||||
WHERETRACE(0x40,
|
||||
("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
|
||||
saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
|
||||
continue;
|
||||
}else{
|
||||
WHERETRACE(0x40,
|
||||
("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
|
||||
saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
|
||||
}
|
||||
}
|
||||
pNew->wsFlags |= WHERE_COLUMN_IN;
|
||||
}else if( eOp & (WO_EQ|WO_IS) ){
|
||||
int iCol = pProbe->aiColumn[saved_nEq];
|
||||
pNew->wsFlags |= WHERE_COLUMN_EQ;
|
||||
@@ -2700,24 +2758,6 @@ static int indexMightHelpWithOrderBy(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a bitmask where 1s indicate that the corresponding column of
|
||||
** the table is used by an index. Only the first 63 columns are considered.
|
||||
*/
|
||||
static Bitmask columnsInIndex(Index *pIdx){
|
||||
Bitmask m = 0;
|
||||
int j;
|
||||
for(j=pIdx->nColumn-1; j>=0; j--){
|
||||
int x = pIdx->aiColumn[j];
|
||||
if( x>=0 ){
|
||||
testcase( x==BMS-1 );
|
||||
testcase( x==BMS-2 );
|
||||
if( x<BMS-1 ) m |= MASKBIT(x);
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* Check to see if a partial index with pPartIndexWhere can be used
|
||||
** in the current query. Return true if it can be and false if not.
|
||||
*/
|
||||
@@ -2933,7 +2973,7 @@ static int whereLoopAddBtree(
|
||||
pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
|
||||
m = 0;
|
||||
}else{
|
||||
m = pSrc->colUsed & ~columnsInIndex(pProbe);
|
||||
m = pSrc->colUsed & pProbe->colNotIdxed;
|
||||
pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;
|
||||
}
|
||||
|
||||
@@ -3500,7 +3540,7 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){
|
||||
{
|
||||
rc = whereLoopAddBtree(pBuilder, mPrereq);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){
|
||||
rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
|
||||
}
|
||||
mPrior |= pNew->maskSelf;
|
||||
@@ -4336,7 +4376,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){
|
||||
}
|
||||
if( j!=pIdx->nKeyCol ) continue;
|
||||
pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
|
||||
if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){
|
||||
if( pIdx->isCovering || (pItem->colUsed & pIdx->colNotIdxed)==0 ){
|
||||
pLoop->wsFlags |= WHERE_IDX_ONLY;
|
||||
}
|
||||
pLoop->nLTerm = j;
|
||||
@@ -5016,6 +5056,26 @@ whereBeginError:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Part of sqlite3WhereEnd() will rewrite opcodes to reference the
|
||||
** index rather than the main table. In SQLITE_DEBUG mode, we want
|
||||
** to trace those changes if PRAGMA vdbe_addoptrace=on. This routine
|
||||
** does that.
|
||||
*/
|
||||
#ifndef SQLITE_DEBUG
|
||||
# define OpcodeRewriteTrace(D,K,P) /* no-op */
|
||||
#else
|
||||
# define OpcodeRewriteTrace(D,K,P) sqlite3WhereOpcodeRewriteTrace(D,K,P)
|
||||
static void sqlite3WhereOpcodeRewriteTrace(
|
||||
sqlite3 *db,
|
||||
int pc,
|
||||
VdbeOp *pOp
|
||||
){
|
||||
if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
|
||||
sqlite3VdbePrintOp(0, pc, pOp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Generate the end of the WHERE loop. See comments on
|
||||
** sqlite3WhereBegin() for additional information.
|
||||
@@ -5083,10 +5143,17 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
|
||||
sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
|
||||
if( pIn->eEndLoopOp!=OP_Noop ){
|
||||
if( pIn->nPrefix ){
|
||||
assert( pLoop->wsFlags & WHERE_IN_EARLYOUT );
|
||||
sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
|
||||
sqlite3VdbeCurrentAddr(v)+2,
|
||||
pIn->iBase, pIn->nPrefix);
|
||||
VdbeCoverage(v);
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
|
||||
VdbeCoverage(v);
|
||||
VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
|
||||
VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
|
||||
VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev);
|
||||
VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Next);
|
||||
}
|
||||
sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
|
||||
}
|
||||
@@ -5177,6 +5244,11 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
){
|
||||
last = sqlite3VdbeCurrentAddr(v);
|
||||
k = pLevel->addrBody;
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( db->flags & SQLITE_VdbeAddopTrace ){
|
||||
printf("TRANSLATE opcodes in range %d..%d\n", k, last-1);
|
||||
}
|
||||
#endif
|
||||
pOp = sqlite3VdbeGetOp(v, k);
|
||||
for(; k<last; k++, pOp++){
|
||||
if( pOp->p1!=pLevel->iTabCur ) continue;
|
||||
@@ -5196,16 +5268,22 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
if( x>=0 ){
|
||||
pOp->p2 = x;
|
||||
pOp->p1 = pLevel->iIdxCur;
|
||||
OpcodeRewriteTrace(db, k, pOp);
|
||||
}
|
||||
assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0
|
||||
|| pWInfo->eOnePass );
|
||||
}else if( pOp->opcode==OP_Rowid ){
|
||||
pOp->p1 = pLevel->iIdxCur;
|
||||
pOp->opcode = OP_IdxRowid;
|
||||
OpcodeRewriteTrace(db, k, pOp);
|
||||
}else if( pOp->opcode==OP_IfNullRow ){
|
||||
pOp->p1 = pLevel->iIdxCur;
|
||||
OpcodeRewriteTrace(db, k, pOp);
|
||||
}
|
||||
}
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ struct WhereLevel {
|
||||
struct InLoop {
|
||||
int iCur; /* The VDBE cursor used by this IN operator */
|
||||
int addrInTop; /* Top of the IN loop */
|
||||
int iBase; /* Base register of multi-key index record */
|
||||
int nPrefix; /* Number of prior entires in the key */
|
||||
u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */
|
||||
} *aInLoop; /* Information about each nested IN operator */
|
||||
} in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */
|
||||
@@ -320,6 +322,7 @@ struct WhereClause {
|
||||
WhereInfo *pWInfo; /* WHERE clause processing context */
|
||||
WhereClause *pOuter; /* Outer conjunction */
|
||||
u8 op; /* Split operator. TK_AND or TK_OR */
|
||||
u8 hasOr; /* True if any a[].eOperator is WO_OR */
|
||||
int nTerm; /* Number of terms */
|
||||
int nSlot; /* Number of entries in a[] */
|
||||
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
|
||||
@@ -493,6 +496,7 @@ void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
|
||||
void sqlite3WhereClauseClear(WhereClause*);
|
||||
void sqlite3WhereSplit(WhereClause*,Expr*,u8);
|
||||
Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
|
||||
Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*);
|
||||
Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
|
||||
void sqlite3WhereExprAnalyze(SrcList*, WhereClause*);
|
||||
void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);
|
||||
@@ -555,3 +559,4 @@ void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);
|
||||
#define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
|
||||
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
|
||||
#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
|
||||
#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
|
||||
|
||||
+15
-1
@@ -591,7 +591,14 @@ static int codeEqualityTerm(
|
||||
sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
|
||||
if( i==iEq ){
|
||||
pIn->iCur = iTab;
|
||||
pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
|
||||
pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next;
|
||||
if( iEq>0 && (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
|
||||
pIn->iBase = iReg - i;
|
||||
pIn->nPrefix = i;
|
||||
pLoop->wsFlags |= WHERE_IN_EARLYOUT;
|
||||
}else{
|
||||
pIn->nPrefix = 0;
|
||||
}
|
||||
}else{
|
||||
pIn->eEndLoopOp = OP_Noop;
|
||||
}
|
||||
@@ -1658,6 +1665,9 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
** above has already left the cursor sitting on the correct row,
|
||||
** so no further seeking is needed */
|
||||
}else{
|
||||
if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
|
||||
sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);
|
||||
}
|
||||
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
|
||||
assert( op!=0 );
|
||||
sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
|
||||
@@ -1721,6 +1731,10 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
|
||||
}
|
||||
|
||||
if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
|
||||
sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1);
|
||||
}
|
||||
|
||||
/* Seek the table cursor, if required */
|
||||
if( omitTable ){
|
||||
/* pIdx is a covering index. No need to access the main table. */
|
||||
|
||||
+23
-11
@@ -256,11 +256,13 @@ static int isLikeOrGlob(
|
||||
|
||||
/* The optimization is possible only if (1) the pattern does not begin
|
||||
** with a wildcard and if (2) the non-wildcard prefix does not end with
|
||||
** an (illegal 0xff) character. The second condition is necessary so
|
||||
** an (illegal 0xff) character, or (3) the pattern does not consist of
|
||||
** a single escape character. The second condition is necessary so
|
||||
** that we can increment the prefix key to find an upper bound for the
|
||||
** range search.
|
||||
*/
|
||||
if( cnt!=0 && 255!=(u8)z[cnt-1] ){
|
||||
** range search. The third is because the caller assumes that the pattern
|
||||
** consists of at least one character after all escapes have been
|
||||
** removed. */
|
||||
if( cnt!=0 && 255!=(u8)z[cnt-1] && (cnt>1 || z[0]!=wc[3]) ){
|
||||
Expr *pPrefix;
|
||||
|
||||
/* A "complete" match if the pattern ends with "*" or "%" */
|
||||
@@ -672,7 +674,12 @@ static void exprAnalyzeOrTerm(
|
||||
** empty.
|
||||
*/
|
||||
pOrInfo->indexable = indexable;
|
||||
pTerm->eOperator = indexable==0 ? 0 : WO_OR;
|
||||
if( indexable ){
|
||||
pTerm->eOperator = WO_OR;
|
||||
pWC->hasOr = 1;
|
||||
}else{
|
||||
pTerm->eOperator = WO_OR;
|
||||
}
|
||||
|
||||
/* For a two-way OR, attempt to implementation case 2.
|
||||
*/
|
||||
@@ -1011,7 +1018,7 @@ static void exprAnalyze(
|
||||
pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
|
||||
}
|
||||
pMaskSet->bVarSelect = 0;
|
||||
prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);
|
||||
prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
|
||||
if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
|
||||
if( ExprHasProperty(pExpr, EP_FromJoin) ){
|
||||
Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
|
||||
@@ -1404,6 +1411,7 @@ void sqlite3WhereClauseInit(
|
||||
WhereInfo *pWInfo /* The WHERE processing context */
|
||||
){
|
||||
pWC->pWInfo = pWInfo;
|
||||
pWC->hasOr = 0;
|
||||
pWC->pOuter = 0;
|
||||
pWC->nTerm = 0;
|
||||
pWC->nSlot = ArraySize(pWC->aStatic);
|
||||
@@ -1440,17 +1448,18 @@ void sqlite3WhereClauseClear(WhereClause *pWC){
|
||||
** a bitmask indicating which tables are used in that expression
|
||||
** tree.
|
||||
*/
|
||||
Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
|
||||
Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
|
||||
Bitmask mask;
|
||||
if( p==0 ) return 0;
|
||||
if( p->op==TK_COLUMN ){
|
||||
return sqlite3WhereGetMask(pMaskSet, p->iTable);
|
||||
}else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
|
||||
assert( p->op!=TK_IF_NULL_ROW );
|
||||
return 0;
|
||||
}
|
||||
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
|
||||
assert( !ExprHasProperty(p, EP_TokenOnly) );
|
||||
if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
|
||||
if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
|
||||
if( p->pRight ){
|
||||
mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
|
||||
mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight);
|
||||
assert( p->x.pList==0 );
|
||||
}else if( ExprHasProperty(p, EP_xIsSelect) ){
|
||||
if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
|
||||
@@ -1460,6 +1469,9 @@ Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
|
||||
return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
|
||||
}
|
||||
Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){
|
||||
int i;
|
||||
Bitmask mask = 0;
|
||||
|
||||
+2119
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
# 2018-07-04
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set ::testprefix analyzeG
|
||||
|
||||
ifcapable {!stat4} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, b, c, d);
|
||||
CREATE INDEX t1abc ON t1(a, b, c);
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100000
|
||||
)
|
||||
INSERT INTO t1 SELECT 1,1,1,1 FROM s;
|
||||
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000
|
||||
)
|
||||
INSERT INTO t1 SELECT i%5,i,i,i FROM s;
|
||||
}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=1 AND b=1 AND c>0
|
||||
} {
|
||||
3 0 0 {SEARCH TABLE t1 USING INDEX t1abc (a=? AND b=? AND c>?)}
|
||||
}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
ANALYZE
|
||||
} {}
|
||||
|
||||
do_execsql_test 1.4 {
|
||||
EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=1 AND b=1 AND c>0
|
||||
} {
|
||||
2 0 0 {SCAN TABLE t1}
|
||||
}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,80 @@
|
||||
# 2018-06-07
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# A multi-key index that uses an IN operator on one of the keys other
|
||||
# than the left-most key is able to abort the IN-operator loop early
|
||||
# if key terms further to the left do not match.
|
||||
#
|
||||
# Call this the "multikey-IN-operator early-out optimization" or
|
||||
# just "IN-early-out" optimization for short.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix in6
|
||||
|
||||
do_test in6-1.1 {
|
||||
db eval {
|
||||
CREATE TABLE t1(a,b,c,d);
|
||||
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
|
||||
INSERT INTO t1(a,b,c,d)
|
||||
SELECT 100, 200+x/2, 300+x/5, x FROM c;
|
||||
CREATE INDEX t1abc ON t1(a,b,c);
|
||||
ANALYZE;
|
||||
UPDATE sqlite_stat1 SET stat='1000000 500000 500 50';
|
||||
ANALYZE sqlite_master;
|
||||
}
|
||||
set ::sqlite_search_count 0
|
||||
db eval {
|
||||
SELECT d FROM t1
|
||||
WHERE a=99
|
||||
AND b IN (200,205,201,204)
|
||||
AND c IN (304,302,309,308);
|
||||
}
|
||||
} {}
|
||||
do_test in6-1.2 {
|
||||
set ::sqlite_search_count
|
||||
} {0} ;# Without the IN-early-out optimization, this value would be 15
|
||||
|
||||
# The multikey-IN-operator early-out optimization does not apply
|
||||
# when the IN operator is on the left-most column of the index.
|
||||
#
|
||||
do_test in6-1.3 {
|
||||
db eval {
|
||||
EXPLAIN
|
||||
SELECT d FROM t1
|
||||
WHERE a IN (98,99,100,101)
|
||||
AND b=200 AND c=300;
|
||||
}
|
||||
} {~/(IfNoHope|SeekHit)/}
|
||||
|
||||
set sqlite_search_count 0
|
||||
do_execsql_test in6-1.4 {
|
||||
SELECT d FROM t1
|
||||
WHERE a=100
|
||||
AND b IN (200,201,202,204)
|
||||
AND c IN (300,302,301,305)
|
||||
ORDER BY +d;
|
||||
} {1 2 3 4 5 8 9}
|
||||
do_test in6-1.5 {
|
||||
set ::sqlite_search_count
|
||||
} {39}
|
||||
|
||||
do_execsql_test in6-2.1 {
|
||||
CREATE TABLE t2(e INT UNIQUE, f TEXT);
|
||||
SELECT d, f FROM t1 LEFT JOIN t2 ON (e=d)
|
||||
WHERE a=100
|
||||
AND b IN (200,201,202,204)
|
||||
AND c IN (300,302,301,305)
|
||||
ORDER BY +d;
|
||||
} {1 {} 2 {} 3 {} 4 {} 5 {} 8 {} 9 {}}
|
||||
|
||||
finish_test
|
||||
@@ -435,6 +435,19 @@ do_execsql_test insert-12.3 {
|
||||
SELECT * FROM t12c;
|
||||
} {one xyzzy two}
|
||||
|
||||
# 2018-06-11. From OSSFuzz. A column cache malfunction in
|
||||
# the constraint checking on an index of expressions causes
|
||||
# an assertion fault in a REPLACE. Ticket
|
||||
# https://www.sqlite.org/src/info/c2432ef9089ee73b
|
||||
#
|
||||
do_execsql_test insert-13.1 {
|
||||
DROP TABLE IF EXISTS t13;
|
||||
CREATE TABLE t13(a INTEGER PRIMARY KEY,b UNIQUE);
|
||||
CREATE INDEX t13x1 ON t13(-b=b);
|
||||
INSERT INTO t13 VALUES(1,5),(6,2);
|
||||
REPLACE INTO t13 SELECT b,0 FROM t13;
|
||||
SELECT * FROM t13 ORDER BY +b;
|
||||
} {2 0 6 2 1 5}
|
||||
|
||||
integrity_check insert-99.0
|
||||
|
||||
|
||||
@@ -65,6 +65,9 @@ foreach {tnum sql norm} {
|
||||
{/* IN list exactly 5 bytes long */
|
||||
SELECT * FROM t1 WHERE x IN (1,2,3);}
|
||||
{select*from t1 where x in(?,?,?);}
|
||||
180
|
||||
{ }
|
||||
{}
|
||||
} {
|
||||
do_test $tnum [list sqlite3_normalize $sql] $norm
|
||||
}
|
||||
|
||||
@@ -283,6 +283,12 @@ test_suite "fts5-light" -prefix "" -description {
|
||||
-exclude *corrupt* *fault* *big* *fts5aj*
|
||||
]
|
||||
|
||||
test_suite "window" -prefix "" -description {
|
||||
All window function related tests .
|
||||
} -files [
|
||||
test_set [glob -nocomplain $::testdir/window*.test]
|
||||
]
|
||||
|
||||
test_suite "lsm1" -prefix "" -description {
|
||||
All LSM1 tests.
|
||||
} -files [glob -nocomplain $::testdir/../ext/lsm1/test/*.test]
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
# 2018 May 19
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
package require sqlite3
|
||||
package require Pgtcl
|
||||
|
||||
set db [pg_connect -conninfo "dbname=postgres user=postgres password=postgres"]
|
||||
sqlite3 sqlite ""
|
||||
|
||||
proc execsql {sql} {
|
||||
|
||||
set lSql [list]
|
||||
set frag ""
|
||||
while {[string length $sql]>0} {
|
||||
set i [string first ";" $sql]
|
||||
if {$i>=0} {
|
||||
append frag [string range $sql 0 $i]
|
||||
set sql [string range $sql $i+1 end]
|
||||
if {[sqlite complete $frag]} {
|
||||
lappend lSql $frag
|
||||
set frag ""
|
||||
}
|
||||
} else {
|
||||
set frag $sql
|
||||
set sql ""
|
||||
}
|
||||
}
|
||||
if {$frag != ""} {
|
||||
lappend lSql $frag
|
||||
}
|
||||
#puts $lSql
|
||||
|
||||
set ret ""
|
||||
foreach stmt $lSql {
|
||||
set res [pg_exec $::db $stmt]
|
||||
set err [pg_result $res -error]
|
||||
if {$err!=""} { error $err }
|
||||
for {set i 0} {$i < [pg_result $res -numTuples]} {incr i} {
|
||||
if {$i==0} {
|
||||
set ret [pg_result $res -getTuple 0]
|
||||
} else {
|
||||
append ret " [pg_result $res -getTuple $i]"
|
||||
}
|
||||
# lappend ret {*}[pg_result $res -getTuple $i]
|
||||
}
|
||||
pg_result $res -clear
|
||||
}
|
||||
|
||||
set ret
|
||||
}
|
||||
|
||||
proc execsql_test {tn sql} {
|
||||
set res [execsql $sql]
|
||||
set sql [string map {string_agg group_concat} $sql]
|
||||
puts $::fd "do_execsql_test $tn {"
|
||||
puts $::fd " [string trim $sql]"
|
||||
puts $::fd "} {$res}"
|
||||
puts $::fd ""
|
||||
}
|
||||
|
||||
# Same as [execsql_test], except coerce all results to floating point values
|
||||
# with two decimal points.
|
||||
#
|
||||
proc execsql_float_test {tn sql} {
|
||||
set F "%.2f"
|
||||
set res [execsql $sql]
|
||||
set res2 [list]
|
||||
foreach r $res {
|
||||
if {$r != ""} { set r [format $F $r] }
|
||||
lappend res2 $r
|
||||
}
|
||||
|
||||
puts $::fd "do_test $tn {"
|
||||
puts $::fd " set myres {}"
|
||||
puts $::fd " foreach r \[db eval {[string trim $sql]}\] {"
|
||||
puts $::fd " lappend myres \[format $F \[set r\]\]"
|
||||
puts $::fd " }"
|
||||
puts $::fd " set myres"
|
||||
puts $::fd "} {$res2}"
|
||||
puts $::fd ""
|
||||
}
|
||||
|
||||
proc start_test {name date} {
|
||||
set dir [file dirname $::argv0]
|
||||
set output [file join $dir $name.test]
|
||||
set ::fd [open $output w]
|
||||
puts $::fd [string trimleft "
|
||||
# $date
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
####################################################
|
||||
# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
|
||||
####################################################
|
||||
"]
|
||||
puts $::fd {set testdir [file dirname $argv0]}
|
||||
puts $::fd {source $testdir/tester.tcl}
|
||||
puts $::fd "set testprefix $name"
|
||||
puts $::fd ""
|
||||
}
|
||||
|
||||
proc -- {args} {
|
||||
puts $::fd "# $args"
|
||||
}
|
||||
|
||||
proc ========== {args} {
|
||||
puts $::fd "#[string repeat = 74]"
|
||||
puts $::fd ""
|
||||
}
|
||||
|
||||
proc finish_test {} {
|
||||
puts $::fd finish_test
|
||||
close $::fd
|
||||
}
|
||||
|
||||
proc ifcapable {arg} {
|
||||
puts $::fd "ifcapable $arg { finish_test ; return }"
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ array set ::Configs [strip_comments {
|
||||
-DSQLITE_ENABLE_HIDDEN_COLUMNS
|
||||
-DSQLITE_MAX_ATTACHED=125
|
||||
-DSQLITE_MUTATION_TEST
|
||||
--enable-fts5 --enable-json1
|
||||
}
|
||||
"Fast-One" {
|
||||
-O6
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ do_execsql_test 5.0 {
|
||||
WITH i(i) AS (
|
||||
VALUES(1) UNION ALL SELECT i+1 FROM i WHERE i<1000
|
||||
)
|
||||
INSERT INTO d2 SELECT i/3, i%3, i/3 FROM i;
|
||||
INSERT INTO d2 SELECT i/100, i%100, i/100 FROM i;
|
||||
ANALYZE;
|
||||
}
|
||||
|
||||
|
||||
@@ -637,6 +637,19 @@ do_test shell1-3.23b.4 {
|
||||
catchcmd "test.db" ".stats OFF BAD"
|
||||
} {1 {Usage: .stats ?on|off?}}
|
||||
|
||||
# Ticket 7be932dfa60a8a6b3b26bcf7623ec46e0a403ddb 2018-06-07
|
||||
# Adverse interaction between .stats and .eqp
|
||||
#
|
||||
do_test shell1-3.23b.5 {
|
||||
catchcmd "test.db" [string map {"\n " "\n"} {
|
||||
CREATE TEMP TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(1),(2);
|
||||
.stats on
|
||||
.eqp full
|
||||
SELECT * FROM t1;
|
||||
}]
|
||||
} {/1\n2\n/}
|
||||
|
||||
# .tables ?TABLE? List names of tables
|
||||
# If TABLE specified, only list tables matching
|
||||
# LIKE pattern TABLE.
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# 2018 July 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
ifcapable !wal {finish_test ; return }
|
||||
|
||||
set testprefix walprotocol2
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# When recovering the contents of a WAL file, a process obtains the WRITER
|
||||
# lock, then locks all other bytes before commencing recovery. If it fails
|
||||
# to lock all other bytes (because some other process is holding a read
|
||||
# lock) it should retry up to 100 times. Then return SQLITE_PROTOCOL to the
|
||||
# caller. Test this (test case 1.3).
|
||||
#
|
||||
# Also test the effect of hitting an SQLITE_BUSY while attempting to obtain
|
||||
# the WRITER lock (should be the same). Test case 1.4.
|
||||
#
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE x(y);
|
||||
INSERT INTO x VALUES('z');
|
||||
} {wal}
|
||||
|
||||
db close
|
||||
|
||||
proc lock_callback {method filename handle lock} {
|
||||
# puts "$method $filename $handle $lock"
|
||||
}
|
||||
testvfs T
|
||||
T filter xShmLock
|
||||
T script lock_callback
|
||||
|
||||
sqlite3 db test.db -vfs T
|
||||
sqlite3 db2 test.db -vfs T
|
||||
|
||||
do_execsql_test 2.0 {
|
||||
SELECT * FROM x;
|
||||
} {z}
|
||||
do_execsql_test -db db2 2.1 {
|
||||
SELECT * FROM x;
|
||||
} {z}
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# Attempt a "BEGIN EXCLUSIVE" using connection handle [db]. This
|
||||
# causes SQLite to open a read transaction, then a write transaction.
|
||||
# Rig the xShmLock() callback so that just before the EXCLUSIVE lock
|
||||
# for the write transaction is taken, connection [db2] jumps in and
|
||||
# modifies the database. This causes the "BEGIN EXCLUSIVE" to throw
|
||||
# an SQLITE_BUSY_SNAPSHOT error.
|
||||
#
|
||||
proc lock_callback {method filename handle lock} {
|
||||
if {$lock=="0 1 lock exclusive"} {
|
||||
proc lock_callback {method filename handle lock} {}
|
||||
db2 eval { INSERT INTO x VALUES('y') }
|
||||
}
|
||||
}
|
||||
do_catchsql_test 2.2 {
|
||||
BEGIN EXCLUSIVE;
|
||||
} {1 {database is locked}}
|
||||
do_test 2.3 {
|
||||
sqlite3_extended_errcode db
|
||||
} {SQLITE_BUSY_SNAPSHOT}
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# Same again, but with a busy-handler. This time, following the
|
||||
# SQLITE_BUSY_SNAPSHOT error the busy-handler is invoked and then the
|
||||
# whole thing retried from the beginning. This time it succeeds.
|
||||
#
|
||||
proc lock_callback {method filename handle lock} {
|
||||
if {$lock=="0 1 lock exclusive"} {
|
||||
proc lock_callback {method filename handle lock} {}
|
||||
db2 eval { INSERT INTO x VALUES('x') }
|
||||
}
|
||||
}
|
||||
db timeout 10
|
||||
do_catchsql_test 2.4 {
|
||||
BEGIN EXCLUSIVE;
|
||||
} {0 {}}
|
||||
do_execsql_test 2.5 {
|
||||
SELECT * FROM x;
|
||||
COMMIT;
|
||||
} {z y x}
|
||||
|
||||
finish_test
|
||||
+2
-2
@@ -490,12 +490,12 @@ ifcapable subquery {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 5}
|
||||
} {2 1 9 4}
|
||||
do_test where-5.15 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,16) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 9}
|
||||
} {2 1 9 3 1 16 8}
|
||||
do_test where-5.100 {
|
||||
db eval {
|
||||
SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
# 2018 May 8
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix window1
|
||||
|
||||
ifcapable !windowfunc {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, b, c, d);
|
||||
INSERT INTO t1 VALUES(1, 2, 3, 4);
|
||||
INSERT INTO t1 VALUES(5, 6, 7, 8);
|
||||
INSERT INTO t1 VALUES(9, 10, 11, 12);
|
||||
}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
SELECT sum(b) OVER () FROM t1
|
||||
} {18 18 18}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
SELECT a, sum(b) OVER () FROM t1
|
||||
} {1 18 5 18 9 18}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
SELECT a, 4 + sum(b) OVER () FROM t1
|
||||
} {1 22 5 22 9 22}
|
||||
|
||||
do_execsql_test 1.4 {
|
||||
SELECT a + 4 + sum(b) OVER () FROM t1
|
||||
} {23 27 31}
|
||||
|
||||
do_execsql_test 1.5 {
|
||||
SELECT a, sum(b) OVER (PARTITION BY c) FROM t1
|
||||
} {1 2 5 6 9 10}
|
||||
|
||||
foreach {tn sql} {
|
||||
1 "SELECT sum(b) OVER () FROM t1"
|
||||
2 "SELECT sum(b) OVER (PARTITION BY c) FROM t1"
|
||||
3 "SELECT sum(b) OVER (ORDER BY c) FROM t1"
|
||||
4 "SELECT sum(b) OVER (PARTITION BY d ORDER BY c) FROM t1"
|
||||
5 "SELECT sum(b) FILTER (WHERE a>0) OVER (PARTITION BY d ORDER BY c) FROM t1"
|
||||
6 "SELECT sum(b) OVER (ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t1"
|
||||
7 "SELECT sum(b) OVER (ORDER BY c ROWS 45 PRECEDING) FROM t1"
|
||||
8 "SELECT sum(b) OVER (ORDER BY c RANGE CURRENT ROW) FROM t1"
|
||||
9 "SELECT sum(b) OVER (ORDER BY c RANGE BETWEEN UNBOUNDED PRECEDING
|
||||
AND CURRENT ROW) FROM t1"
|
||||
10 "SELECT sum(b) OVER (ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING
|
||||
AND UNBOUNDED FOLLOWING) FROM t1"
|
||||
} {
|
||||
do_test 2.$tn { lindex [catchsql $sql] 0 } 0
|
||||
}
|
||||
|
||||
foreach {tn sql} {
|
||||
1 "SELECT * FROM t1 WHERE sum(b) OVER ()"
|
||||
2 "SELECT * FROM t1 GROUP BY sum(b) OVER ()"
|
||||
3 "SELECT * FROM t1 GROUP BY a HAVING sum(b) OVER ()"
|
||||
} {
|
||||
do_catchsql_test 3.$tn $sql {1 {misuse of window function sum()}}
|
||||
}
|
||||
|
||||
do_execsql_test 4.0 {
|
||||
CREATE TABLE t2(a, b, c);
|
||||
INSERT INTO t2 VALUES(0, 0, 0);
|
||||
INSERT INTO t2 VALUES(1, 1, 1);
|
||||
INSERT INTO t2 VALUES(2, 0, 2);
|
||||
INSERT INTO t2 VALUES(3, 1, 0);
|
||||
INSERT INTO t2 VALUES(4, 0, 1);
|
||||
INSERT INTO t2 VALUES(5, 1, 2);
|
||||
INSERT INTO t2 VALUES(6, 0, 0);
|
||||
}
|
||||
|
||||
do_execsql_test 4.1 {
|
||||
SELECT a, sum(a) OVER (PARTITION BY b) FROM t2;
|
||||
} {
|
||||
0 12 2 12 4 12 6 12 1 9 3 9 5 9
|
||||
}
|
||||
|
||||
do_execsql_test 4.2 {
|
||||
SELECT a, sum(a) OVER (PARTITION BY b) FROM t2 ORDER BY a;
|
||||
} {
|
||||
0 12 1 9 2 12 3 9 4 12 5 9 6 12
|
||||
}
|
||||
|
||||
do_execsql_test 4.3 {
|
||||
SELECT a, sum(a) OVER () FROM t2 ORDER BY a;
|
||||
} {
|
||||
0 21 1 21 2 21 3 21 4 21 5 21 6 21
|
||||
}
|
||||
|
||||
do_execsql_test 4.4 {
|
||||
SELECT a, sum(a) OVER (ORDER BY a) FROM t2;
|
||||
} {
|
||||
0 0 1 1 2 3 3 6 4 10 5 15 6 21
|
||||
}
|
||||
|
||||
do_execsql_test 4.5 {
|
||||
SELECT a, sum(a) OVER (PARTITION BY b ORDER BY a) FROM t2 ORDER BY a
|
||||
} {
|
||||
0 0 1 1 2 2 3 4 4 6 5 9 6 12
|
||||
}
|
||||
|
||||
do_execsql_test 4.6 {
|
||||
SELECT a, sum(a) OVER (PARTITION BY c ORDER BY a) FROM t2 ORDER BY a
|
||||
} {
|
||||
0 0 1 1 2 2 3 3 4 5 5 7 6 9
|
||||
}
|
||||
|
||||
do_execsql_test 4.7 {
|
||||
SELECT a, sum(a) OVER (PARTITION BY b ORDER BY a DESC) FROM t2 ORDER BY a
|
||||
} {
|
||||
0 12 1 9 2 12 3 8 4 10 5 5 6 6
|
||||
}
|
||||
|
||||
do_execsql_test 4.8 {
|
||||
SELECT a,
|
||||
sum(a) OVER (PARTITION BY b ORDER BY a DESC),
|
||||
sum(a) OVER (PARTITION BY c ORDER BY a)
|
||||
FROM t2 ORDER BY a
|
||||
} {
|
||||
0 12 0
|
||||
1 9 1
|
||||
2 12 2
|
||||
3 8 3
|
||||
4 10 5
|
||||
5 5 7
|
||||
6 6 9
|
||||
}
|
||||
|
||||
do_execsql_test 4.9 {
|
||||
SELECT a,
|
||||
sum(a) OVER (ORDER BY a),
|
||||
avg(a) OVER (ORDER BY a)
|
||||
FROM t2 ORDER BY a
|
||||
} {
|
||||
0 0 0.0
|
||||
1 1 0.5
|
||||
2 3 1.0
|
||||
3 6 1.5
|
||||
4 10 2.0
|
||||
5 15 2.5
|
||||
6 21 3.0
|
||||
}
|
||||
|
||||
do_execsql_test 4.10.1 {
|
||||
SELECT a,
|
||||
count() OVER (ORDER BY a DESC),
|
||||
group_concat(a, '.') OVER (ORDER BY a DESC)
|
||||
FROM t2 ORDER BY a DESC
|
||||
} {
|
||||
6 1 6
|
||||
5 2 6.5
|
||||
4 3 6.5.4
|
||||
3 4 6.5.4.3
|
||||
2 5 6.5.4.3.2
|
||||
1 6 6.5.4.3.2.1
|
||||
0 7 6.5.4.3.2.1.0
|
||||
}
|
||||
|
||||
do_execsql_test 4.10.2 {
|
||||
SELECT a,
|
||||
count(*) OVER (ORDER BY a DESC),
|
||||
group_concat(a, '.') OVER (ORDER BY a DESC)
|
||||
FROM t2 ORDER BY a DESC
|
||||
} {
|
||||
6 1 6
|
||||
5 2 6.5
|
||||
4 3 6.5.4
|
||||
3 4 6.5.4.3
|
||||
2 5 6.5.4.3.2
|
||||
1 6 6.5.4.3.2.1
|
||||
0 7 6.5.4.3.2.1.0
|
||||
}
|
||||
|
||||
do_catchsql_test 5.1 {
|
||||
SELECT ntile(0) OVER (ORDER BY a) FROM t2;
|
||||
} {1 {argument of ntile must be a positive integer}}
|
||||
do_catchsql_test 5.2 {
|
||||
SELECT ntile(-1) OVER (ORDER BY a) FROM t2;
|
||||
} {1 {argument of ntile must be a positive integer}}
|
||||
do_catchsql_test 5.3 {
|
||||
SELECT ntile('zbc') OVER (ORDER BY a) FROM t2;
|
||||
} {1 {argument of ntile must be a positive integer}}
|
||||
do_execsql_test 5.4 {
|
||||
CREATE TABLE t4(a, b);
|
||||
SELECT ntile(1) OVER (ORDER BY a) FROM t4;
|
||||
} {}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
do_execsql_test 6.1 {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(7), (6), (5), (4), (3), (2), (1);
|
||||
|
||||
CREATE TABLE t2(x);
|
||||
INSERT INTO t2 VALUES('b'), ('a');
|
||||
|
||||
SELECT x, count(*) OVER (ORDER BY x) FROM t1;
|
||||
} {1 1 2 2 3 3 4 4 5 5 6 6 7 7}
|
||||
|
||||
do_execsql_test 6.2 {
|
||||
SELECT * FROM t2, (SELECT x, count(*) OVER (ORDER BY x) FROM t1);
|
||||
} {
|
||||
b 1 1 b 2 2 b 3 3 b 4 4 b 5 5 b 6 6 b 7 7
|
||||
a 1 1 a 2 2 a 3 3 a 4 4 a 5 5 a 6 6 a 7 7
|
||||
}
|
||||
|
||||
do_catchsql_test 6.3 {
|
||||
SELECT x, lag(x) FILTER (WHERE (x%2)=0) OVER w FROM t1
|
||||
WINDOW w AS (ORDER BY x)
|
||||
} {1 {FILTER clause may only be used with aggregate window functions}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Attempt to use a window function as an aggregate. And other errors.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 7.0 {
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
INSERT INTO t1 VALUES(5, 6);
|
||||
INSERT INTO t1 VALUES(7, 8);
|
||||
INSERT INTO t1 VALUES(9, 10);
|
||||
}
|
||||
|
||||
do_catchsql_test 7.1.1 {
|
||||
SELECT nth_value(x, 1) FROM t1;
|
||||
} {1 {misuse of window function nth_value()}}
|
||||
do_catchsql_test 7.1.2 {
|
||||
SELECT * FROM t1 WHERE nth_value(x, 1) OVER (ORDER BY y);
|
||||
} {1 {misuse of window function nth_value()}}
|
||||
do_catchsql_test 7.1.3 {
|
||||
SELECT count(*) FROM t1 GROUP BY y HAVING nth_value(x, 1) OVER (ORDER BY y);
|
||||
} {1 {misuse of window function nth_value()}}
|
||||
do_catchsql_test 7.1.4 {
|
||||
SELECT count(*) FROM t1 GROUP BY nth_value(x, 1) OVER (ORDER BY y);
|
||||
} {1 {misuse of window function nth_value()}}
|
||||
do_catchsql_test 7.1.5 {
|
||||
SELECT count(*) FROM t1 LIMIT nth_value(x, 1) OVER ();
|
||||
} {1 {no such column: x}}
|
||||
do_catchsql_test 7.1.6 {
|
||||
SELECT trim(x) OVER (ORDER BY y) FROM t1;
|
||||
} {1 {trim() may not be used as a window function}}
|
||||
do_catchsql_test 7.1.7 {
|
||||
SELECT max(x) OVER abc FROM t1 WINDOW def AS (ORDER BY y);
|
||||
} {1 {no such window: abc}}
|
||||
|
||||
do_execsql_test 7.2 {
|
||||
SELECT
|
||||
lead(y) OVER win,
|
||||
lead(y, 2) OVER win,
|
||||
lead(y, 3, 'default') OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY x)
|
||||
} {
|
||||
4 6 8 6 8 10 8 10 default 10 {} default {} {} default
|
||||
}
|
||||
|
||||
do_execsql_test 7.3 {
|
||||
SELECT row_number() OVER (ORDER BY x) FROM t1
|
||||
} {1 2 3 4 5}
|
||||
|
||||
do_execsql_test 7.4 {
|
||||
SELECT
|
||||
row_number() OVER win,
|
||||
lead(x) OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY x ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
|
||||
} {1 3 2 5 3 7 4 9 5 {}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Attempt to use a window function in a view.
|
||||
#
|
||||
do_execsql_test 8.0 {
|
||||
CREATE TABLE t3(a, b, c);
|
||||
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<6 )
|
||||
INSERT INTO t3 SELECT i, i, i FROM s;
|
||||
|
||||
CREATE VIEW v1 AS SELECT
|
||||
sum(b) OVER (ORDER BY c),
|
||||
min(b) OVER (ORDER BY c),
|
||||
max(b) OVER (ORDER BY c)
|
||||
FROM t3;
|
||||
|
||||
CREATE VIEW v2 AS SELECT
|
||||
sum(b) OVER win,
|
||||
min(b) OVER win,
|
||||
max(b) OVER win
|
||||
FROM t3
|
||||
WINDOW win AS (ORDER BY c);
|
||||
}
|
||||
|
||||
do_execsql_test 8.1.1 {
|
||||
SELECT * FROM v1
|
||||
} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
|
||||
do_execsql_test 8.1.2 {
|
||||
SELECT * FROM v2
|
||||
} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
|
||||
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
do_execsql_test 8.2.1 {
|
||||
SELECT * FROM v1
|
||||
} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
|
||||
do_execsql_test 8.2.2 {
|
||||
SELECT * FROM v2
|
||||
} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Attempt to use a window function in a trigger.
|
||||
#
|
||||
do_execsql_test 9.0 {
|
||||
CREATE TABLE t4(x, y);
|
||||
INSERT INTO t4 VALUES(1, 'g');
|
||||
INSERT INTO t4 VALUES(2, 'i');
|
||||
INSERT INTO t4 VALUES(3, 'l');
|
||||
INSERT INTO t4 VALUES(4, 'g');
|
||||
INSERT INTO t4 VALUES(5, 'a');
|
||||
|
||||
CREATE TABLE t5(x, y, m);
|
||||
CREATE TRIGGER t4i AFTER INSERT ON t4 BEGIN
|
||||
DELETE FROM t5;
|
||||
INSERT INTO t5
|
||||
SELECT x, y, max(y) OVER xyz FROM t4
|
||||
WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x);
|
||||
END;
|
||||
}
|
||||
|
||||
do_execsql_test 9.1.1 {
|
||||
SELECT x, y, max(y) OVER xyz FROM t4
|
||||
WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x) ORDER BY 1
|
||||
} {1 g g 2 i i 3 l l 4 g i 5 a l}
|
||||
|
||||
do_execsql_test 9.1.2 {
|
||||
INSERT INTO t4 VALUES(6, 'm');
|
||||
SELECT x, y, max(y) OVER xyz FROM t4
|
||||
WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x) ORDER BY 1
|
||||
} {1 g g 2 i i 3 l l 4 g i 5 a l 6 m m}
|
||||
|
||||
do_execsql_test 9.1.3 {
|
||||
SELECT * FROM t5 ORDER BY 1
|
||||
} {1 g g 2 i i 3 l l 4 g i 5 a l 6 m m}
|
||||
|
||||
do_execsql_test 9.2 {
|
||||
WITH aaa(x, y, z) AS (
|
||||
SELECT x, y, max(y) OVER xyz FROM t4
|
||||
WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x)
|
||||
)
|
||||
SELECT * FROM aaa ORDER BY 1;
|
||||
} {1 g g 2 i i 3 l l 4 g i 5 a l 6 m m}
|
||||
|
||||
do_execsql_test 9.3 {
|
||||
WITH aaa(x, y, z) AS (
|
||||
SELECT x, y, max(y) OVER xyz FROM t4
|
||||
WINDOW xyz AS (ORDER BY x)
|
||||
)
|
||||
SELECT *, min(z) OVER (ORDER BY x) FROM aaa ORDER BY 1;
|
||||
} {1 g g g 2 i i g 3 l l g 4 g l g 5 a l g 6 m m g}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_execsql_test 10.0 {
|
||||
CREATE TABLE sales(emp TEXT PRIMARY KEY, region, total);
|
||||
INSERT INTO sales VALUES
|
||||
('Alice', 'North', 34),
|
||||
('Frank', 'South', 22),
|
||||
('Charles', 'North', 45),
|
||||
('Darrell', 'South', 8),
|
||||
('Grant', 'South', 23),
|
||||
('Brad' , 'North', 22),
|
||||
('Elizabeth', 'South', 99),
|
||||
('Horace', 'East', 1);
|
||||
}
|
||||
|
||||
# Best two salespeople from each region
|
||||
#
|
||||
do_execsql_test 10.1 {
|
||||
SELECT emp, region, total FROM (
|
||||
SELECT
|
||||
emp, region, total,
|
||||
row_number() OVER (PARTITION BY region ORDER BY total DESC) AS rank
|
||||
FROM sales
|
||||
) WHERE rank<=2 ORDER BY region, total DESC
|
||||
} {
|
||||
Horace East 1
|
||||
Charles North 45
|
||||
Alice North 34
|
||||
Elizabeth South 99
|
||||
Grant South 23
|
||||
}
|
||||
|
||||
do_execsql_test 10.2 {
|
||||
SELECT emp, region, sum(total) OVER win FROM sales
|
||||
WINDOW win AS (PARTITION BY region ORDER BY total)
|
||||
} {
|
||||
Horace East 1
|
||||
Brad North 22
|
||||
Alice North 56
|
||||
Charles North 101
|
||||
Darrell South 8
|
||||
Frank South 30
|
||||
Grant South 53
|
||||
Elizabeth South 152
|
||||
}
|
||||
|
||||
do_execsql_test 10.3 {
|
||||
SELECT emp, region, sum(total) OVER win FROM sales
|
||||
WINDOW win AS (PARTITION BY region ORDER BY total)
|
||||
LIMIT 5
|
||||
} {
|
||||
Horace East 1
|
||||
Brad North 22
|
||||
Alice North 56
|
||||
Charles North 101
|
||||
Darrell South 8
|
||||
}
|
||||
|
||||
do_execsql_test 10.4 {
|
||||
SELECT emp, region, sum(total) OVER win FROM sales
|
||||
WINDOW win AS (PARTITION BY region ORDER BY total)
|
||||
LIMIT 5 OFFSET 2
|
||||
} {
|
||||
Alice North 56
|
||||
Charles North 101
|
||||
Darrell South 8
|
||||
Frank South 30
|
||||
Grant South 53
|
||||
}
|
||||
|
||||
do_execsql_test 10.5 {
|
||||
SELECT emp, region, sum(total) OVER win FROM sales
|
||||
WINDOW win AS (
|
||||
PARTITION BY region ORDER BY total
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
)
|
||||
} {
|
||||
Horace East 1
|
||||
Brad North 101
|
||||
Alice North 79
|
||||
Charles North 45
|
||||
Darrell South 152
|
||||
Frank South 144
|
||||
Grant South 122
|
||||
Elizabeth South 99
|
||||
}
|
||||
|
||||
do_execsql_test 10.6 {
|
||||
SELECT emp, region, sum(total) OVER win FROM sales
|
||||
WINDOW win AS (
|
||||
PARTITION BY region ORDER BY total
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) LIMIT 5 OFFSET 2
|
||||
} {
|
||||
Alice North 79
|
||||
Charles North 45
|
||||
Darrell South 152
|
||||
Frank South 144
|
||||
Grant South 122
|
||||
}
|
||||
|
||||
do_execsql_test 10.7 {
|
||||
SELECT emp, region, (
|
||||
SELECT sum(total) OVER (
|
||||
ORDER BY total RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) || outer.emp FROM sales
|
||||
) FROM sales AS outer;
|
||||
} {
|
||||
Alice North 254Alice
|
||||
Frank South 254Frank
|
||||
Charles North 254Charles
|
||||
Darrell South 254Darrell
|
||||
Grant South 254Grant
|
||||
Brad North 254Brad
|
||||
Elizabeth South 254Elizabeth
|
||||
Horace East 254Horace
|
||||
}
|
||||
|
||||
do_execsql_test 10.8 {
|
||||
SELECT emp, region, (
|
||||
SELECT sum(total) FILTER (WHERE sales.emp!=outer.emp) OVER (
|
||||
ORDER BY total RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM sales
|
||||
) FROM sales AS outer;
|
||||
} {
|
||||
Alice North 220
|
||||
Frank South 232
|
||||
Charles North 209
|
||||
Darrell South 246
|
||||
Grant South 231
|
||||
Brad North 232
|
||||
Elizabeth South 155
|
||||
Horace East 253
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Check that it is not possible to use a window function in a CREATE INDEX
|
||||
# statement.
|
||||
#
|
||||
do_execsql_test 11.0 { CREATE TABLE t6(a, b, c); }
|
||||
|
||||
do_catchsql_test 11.1 {
|
||||
CREATE INDEX t6i ON t6(a) WHERE sum(b) OVER ();
|
||||
} {1 {misuse of window function sum()}}
|
||||
do_catchsql_test 11.2 {
|
||||
CREATE INDEX t6i ON t6(a) WHERE lead(b) OVER ();
|
||||
} {1 {misuse of window function lead()}}
|
||||
|
||||
do_catchsql_test 11.3 {
|
||||
CREATE INDEX t6i ON t6(sum(b) OVER ());
|
||||
} {1 {misuse of window function sum()}}
|
||||
do_catchsql_test 11.4 {
|
||||
CREATE INDEX t6i ON t6(lead(b) OVER ());
|
||||
} {1 {misuse of window function lead()}}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
# 2018 May 19
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
source [file join [file dirname $argv0] pg_common.tcl]
|
||||
|
||||
#=========================================================================
|
||||
|
||||
|
||||
start_test window2 "2018 May 19"
|
||||
|
||||
ifcapable !windowfunc
|
||||
|
||||
execsql_test 1.0 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
|
||||
INSERT INTO t1 VALUES(1, 'odd', 'one', 1);
|
||||
INSERT INTO t1 VALUES(2, 'even', 'two', 2);
|
||||
INSERT INTO t1 VALUES(3, 'odd', 'three', 3);
|
||||
INSERT INTO t1 VALUES(4, 'even', 'four', 4);
|
||||
INSERT INTO t1 VALUES(5, 'odd', 'five', 5);
|
||||
INSERT INTO t1 VALUES(6, 'even', 'six', 6);
|
||||
}
|
||||
|
||||
execsql_test 1.1 {
|
||||
SELECT c, sum(d) OVER (PARTITION BY b ORDER BY c) FROM t1;
|
||||
}
|
||||
|
||||
execsql_test 1.2 {
|
||||
SELECT sum(d) OVER () FROM t1;
|
||||
}
|
||||
|
||||
execsql_test 1.3 {
|
||||
SELECT sum(d) OVER (PARTITION BY b) FROM t1;
|
||||
}
|
||||
|
||||
==========
|
||||
execsql_test 2.1 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1000 PRECEDING AND 1 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
execsql_test 2.2 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1000 PRECEDING AND 1000 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
execsql_test 2.3 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1000 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
execsql_test 2.4 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
execsql_test 2.5 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 0 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.6 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.7 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 0 PRECEDING AND 0 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.8 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.9 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.10 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.11 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.13 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.14 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 3 PRECEDING AND 1 PRECEDING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.15 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 0 PRECEDING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.16 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.17 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.18 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.19 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND 3 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.20 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.21 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.22 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.23 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.24 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY a%2
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.25 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.26 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.27 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.28 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.29 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
execsql_test 2.30 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 3.1 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b ORDER BY d
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 3.2 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 3.3 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 3.4 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d/2
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
#puts $::fd finish_test
|
||||
|
||||
==========
|
||||
|
||||
execsql_test 4.0 {
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
|
||||
INSERT INTO t2(a, b) VALUES
|
||||
(1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
|
||||
(10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
|
||||
(18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
|
||||
(26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
|
||||
(34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
|
||||
(42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
|
||||
(50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
|
||||
(58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
|
||||
(66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
|
||||
(74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
|
||||
(82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
|
||||
(90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
|
||||
(98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
|
||||
(106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
|
||||
(114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
|
||||
(121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
|
||||
(128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
|
||||
(135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
|
||||
(143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
|
||||
(150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
|
||||
(158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
|
||||
(166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
|
||||
(173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
|
||||
(181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
|
||||
(188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
|
||||
(195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
|
||||
}
|
||||
|
||||
execsql_test 4.1 {
|
||||
SELECT a, sum(b) OVER (
|
||||
PARTITION BY (b%10)
|
||||
ORDER BY b
|
||||
) FROM t2 ORDER BY a;
|
||||
}
|
||||
|
||||
execsql_test 4.2 {
|
||||
SELECT a, sum(b) OVER (
|
||||
PARTITION BY (b%10)
|
||||
ORDER BY b
|
||||
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY a;
|
||||
}
|
||||
|
||||
execsql_test 4.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY b
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY b;
|
||||
}
|
||||
|
||||
execsql_test 4.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY b;
|
||||
}
|
||||
|
||||
execsql_test 4.5 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY b;
|
||||
}
|
||||
|
||||
execsql_test 4.6.1 {
|
||||
SELECT b, sum(b) OVER (
|
||||
RANGE BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY b;
|
||||
}
|
||||
execsql_test 4.6.2 {
|
||||
SELECT b, sum(b) OVER () FROM t2 ORDER BY b;
|
||||
}
|
||||
execsql_test 4.6.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY b;
|
||||
}
|
||||
execsql_test 4.6.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY b;
|
||||
}
|
||||
|
||||
execsql_test 4.7.1 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
execsql_test 4.7.2 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
execsql_test 4.7.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
execsql_test 4.7.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
|
||||
execsql_test 4.8.1 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
execsql_test 4.8.2 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
execsql_test 4.8.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
execsql_test 4.8.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
@@ -0,0 +1,434 @@
|
||||
# 2018 May 19
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
####################################################
|
||||
# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
|
||||
####################################################
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix window2
|
||||
|
||||
ifcapable !windowfunc { finish_test ; return }
|
||||
do_execsql_test 1.0 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
|
||||
INSERT INTO t1 VALUES(1, 'odd', 'one', 1);
|
||||
INSERT INTO t1 VALUES(2, 'even', 'two', 2);
|
||||
INSERT INTO t1 VALUES(3, 'odd', 'three', 3);
|
||||
INSERT INTO t1 VALUES(4, 'even', 'four', 4);
|
||||
INSERT INTO t1 VALUES(5, 'odd', 'five', 5);
|
||||
INSERT INTO t1 VALUES(6, 'even', 'six', 6);
|
||||
} {}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
SELECT c, sum(d) OVER (PARTITION BY b ORDER BY c) FROM t1;
|
||||
} {four 4 six 10 two 12 five 5 one 6 three 9}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
SELECT sum(d) OVER () FROM t1;
|
||||
} {21 21 21 21 21 21}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
SELECT sum(d) OVER (PARTITION BY b) FROM t1;
|
||||
} {12 12 12 9 9 9}
|
||||
|
||||
#==========================================================================
|
||||
|
||||
do_execsql_test 2.1 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1000 PRECEDING AND 1 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 3 2 6 3 10 4 15 5 21 6 21}
|
||||
|
||||
do_execsql_test 2.2 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1000 PRECEDING AND 1000 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 21 3 21 4 21 5 21 6 21}
|
||||
|
||||
do_execsql_test 2.3 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1000 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 21 3 20 4 18 5 15 6 11}
|
||||
|
||||
do_execsql_test 2.4 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 3 2 6 3 9 4 12 5 15 6 11}
|
||||
|
||||
do_execsql_test 2.5 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 0 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 1 2 3 3 5 4 7 5 9 6 11}
|
||||
|
||||
do_execsql_test 2.6 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
|
||||
) FROM t1
|
||||
} {2 6 4 12 6 10 1 4 3 9 5 8}
|
||||
|
||||
do_execsql_test 2.7 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 0 PRECEDING AND 0 FOLLOWING
|
||||
) FROM t1
|
||||
} {2 2 4 4 6 6 1 1 3 3 5 5}
|
||||
|
||||
do_execsql_test 2.8 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 6 2 9 3 12 4 15 5 11 6 6}
|
||||
|
||||
do_execsql_test 2.9 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 6 2 10 3 15 4 21 5 21 6 21}
|
||||
|
||||
do_execsql_test 2.10 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 6 2 9 3 12 4 15 5 11 6 6}
|
||||
|
||||
do_execsql_test 2.11 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
|
||||
) FROM t1
|
||||
} {1 1 2 3 3 6 4 9 5 12 6 15}
|
||||
|
||||
do_execsql_test 2.13 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 21 3 21 4 20 5 18 6 15}
|
||||
|
||||
do_execsql_test 2.14 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 3 PRECEDING AND 1 PRECEDING
|
||||
) FROM t1
|
||||
} {1 {} 2 1 3 3 4 6 5 9 6 12}
|
||||
|
||||
do_execsql_test 2.15 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 0 PRECEDING
|
||||
) FROM t1
|
||||
} {2 2 4 6 6 10 1 1 3 4 5 8}
|
||||
|
||||
do_execsql_test 2.16 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
|
||||
) FROM t1
|
||||
} {2 {} 4 2 6 4 1 {} 3 1 5 3}
|
||||
|
||||
do_execsql_test 2.17 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING
|
||||
) FROM t1
|
||||
} {2 {} 4 {} 6 {} 1 {} 3 {} 5 {}}
|
||||
|
||||
do_execsql_test 2.18 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING
|
||||
) FROM t1
|
||||
} {2 {} 4 {} 6 2 1 {} 3 {} 5 1}
|
||||
|
||||
do_execsql_test 2.19 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND 3 FOLLOWING
|
||||
) FROM t1
|
||||
} {2 10 4 6 6 {} 1 8 3 5 5 {}}
|
||||
|
||||
do_execsql_test 2.20 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 5 2 7 3 9 4 11 5 6 6 {}}
|
||||
|
||||
do_execsql_test 2.21 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {1 20 2 18 3 15 4 11 5 6 6 {}}
|
||||
|
||||
do_execsql_test 2.22 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 10 4 6 6 {} 1 8 3 5 5 {}}
|
||||
|
||||
do_execsql_test 2.23 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 20 3 18 4 15 5 11 6 6}
|
||||
|
||||
do_execsql_test 2.24 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY a%2
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 12 4 10 6 6 1 9 3 8 5 5}
|
||||
|
||||
do_execsql_test 2.25 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 21 3 21 4 21 5 21 6 21}
|
||||
|
||||
do_execsql_test 2.26 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 12 4 12 6 12 1 9 3 9 5 9}
|
||||
|
||||
do_execsql_test 2.27 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t1
|
||||
} {1 1 2 2 3 3 4 4 5 5 6 6}
|
||||
|
||||
do_execsql_test 2.28 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t1
|
||||
} {2 2 4 4 6 6 1 1 3 3 5 5}
|
||||
|
||||
do_execsql_test 2.29 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 20 3 18 4 15 5 11 6 6}
|
||||
|
||||
do_execsql_test 2.30 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 21 4 21 6 21 1 9 3 9 5 9}
|
||||
|
||||
do_execsql_test 3.1 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b ORDER BY d
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 12 4 10 6 6 1 9 3 8 5 5}
|
||||
|
||||
do_execsql_test 3.2 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 21 4 21 6 21 1 9 3 9 5 9}
|
||||
|
||||
do_execsql_test 3.3 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 21 3 21 4 21 5 21 6 21}
|
||||
|
||||
do_execsql_test 3.4 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d/2
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t1
|
||||
} {1 1 2 3 3 6 4 10 5 15 6 21}
|
||||
|
||||
#==========================================================================
|
||||
|
||||
do_execsql_test 4.0 {
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
|
||||
INSERT INTO t2(a, b) VALUES
|
||||
(1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
|
||||
(10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
|
||||
(18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
|
||||
(26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
|
||||
(34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
|
||||
(42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
|
||||
(50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
|
||||
(58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
|
||||
(66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
|
||||
(74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
|
||||
(82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
|
||||
(90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
|
||||
(98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
|
||||
(106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
|
||||
(114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
|
||||
(121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
|
||||
(128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
|
||||
(135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
|
||||
(143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
|
||||
(150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
|
||||
(158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
|
||||
(166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
|
||||
(173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
|
||||
(181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
|
||||
(188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
|
||||
(195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
|
||||
} {}
|
||||
|
||||
do_execsql_test 4.1 {
|
||||
SELECT a, sum(b) OVER (
|
||||
PARTITION BY (b%10)
|
||||
ORDER BY b
|
||||
) FROM t2 ORDER BY a;
|
||||
} {1 0 2 754 3 251 4 754 5 101 6 1247 7 132 8 266 9 6 10 950 11 667 12 1052 13 535 14 128 15 428 16 250 17 336 18 1122 19 368 20 6 21 1247 22 1000 23 92 24 368 25 584 26 320 27 1000 28 24 29 478 30 133 31 1049 32 1090 33 632 34 101 35 54 36 54 37 1049 38 450 39 145 40 354 41 21 42 764 43 754 44 424 45 1122 46 930 47 42 48 930 49 352 50 535 51 42 52 118 53 536 54 6 55 1122 56 86 57 770 58 255 59 50 60 52 61 950 62 75 63 354 64 2 65 536 66 160 67 352 68 536 69 54 70 675 71 276 72 950 73 868 74 678 75 667 76 4 77 1184 78 160 79 120 80 584 81 266 82 133 83 405 84 468 85 6 86 806 87 166 88 500 89 1090 90 552 91 251 92 27 93 424 94 687 95 1215 96 450 97 32 98 360 99 1052 100 868 101 2 102 66 103 754 104 450 105 145 106 5 107 687 108 24 109 302 110 806 111 251 112 42 113 24 114 30 115 128 116 128 117 50 118 1215 119 86 120 687 121 683 122 672 123 178 124 24 125 24 126 299 127 178 128 770 129 535 130 1052 131 270 132 255 133 675 134 632 135 266 136 6 137 21 138 930 139 411 140 754 141 133 142 340 143 535 144 46 145 250 146 132 147 132 148 354 149 500 150 770 151 276 152 360 153 354 154 27 155 552 156 552 157 602 158 266 159 1049 160 675 161 384 162 667 163 27 164 101 165 166 166 32 167 42 168 18 169 336 170 1122 171 276 172 1122 173 266 174 50 175 178 176 276 177 1247 178 6 179 1215 180 604 181 360 182 212 183 120 184 210 185 1090 186 10 187 1090 188 266 189 66 190 250 191 266 192 360 193 120 194 128 195 178 196 770 197 92 198 634 199 38 200 21}
|
||||
|
||||
do_execsql_test 4.2 {
|
||||
SELECT a, sum(b) OVER (
|
||||
PARTITION BY (b%10)
|
||||
ORDER BY b
|
||||
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY a;
|
||||
} {1 0 2 754 3 251 4 754 5 101 6 1247 7 132 8 266 9 6 10 950 11 667 12 1052 13 535 14 128 15 428 16 250 17 336 18 1122 19 368 20 6 21 1247 22 1000 23 92 24 368 25 584 26 320 27 1000 28 24 29 478 30 133 31 1049 32 1090 33 632 34 101 35 54 36 54 37 1049 38 450 39 145 40 354 41 21 42 764 43 754 44 424 45 1122 46 930 47 42 48 930 49 352 50 535 51 42 52 118 53 536 54 6 55 1122 56 86 57 770 58 255 59 50 60 52 61 950 62 75 63 354 64 2 65 536 66 160 67 352 68 536 69 54 70 675 71 276 72 950 73 868 74 678 75 667 76 4 77 1184 78 160 79 120 80 584 81 266 82 133 83 405 84 468 85 6 86 806 87 166 88 500 89 1090 90 552 91 251 92 27 93 424 94 687 95 1215 96 450 97 32 98 360 99 1052 100 868 101 2 102 66 103 754 104 450 105 145 106 5 107 687 108 24 109 302 110 806 111 251 112 42 113 24 114 30 115 128 116 128 117 50 118 1215 119 86 120 687 121 683 122 672 123 178 124 24 125 24 126 299 127 178 128 770 129 535 130 1052 131 270 132 255 133 675 134 632 135 266 136 6 137 21 138 930 139 411 140 754 141 133 142 340 143 535 144 46 145 250 146 132 147 132 148 354 149 500 150 770 151 276 152 360 153 354 154 27 155 552 156 552 157 602 158 266 159 1049 160 675 161 384 162 667 163 27 164 101 165 166 166 32 167 42 168 18 169 336 170 1122 171 276 172 1122 173 266 174 50 175 178 176 276 177 1247 178 6 179 1215 180 604 181 360 182 212 183 120 184 210 185 1090 186 10 187 1090 188 266 189 66 190 250 191 266 192 360 193 120 194 128 195 178 196 770 197 92 198 634 199 38 200 21}
|
||||
|
||||
do_execsql_test 4.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY b
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY b;
|
||||
} {0 0 1 1 1 2 2 4 2 6 2 8 3 11 3 14 4 18 5 23 6 29 7 36 7 43 7 50 8 58 8 66 8 74 9 83 9 92 9 101 10 111 11 122 11 133 12 145 12 157 12 169 13 182 13 195 14 209 15 224 15 239 15 254 16 270 16 286 16 302 17 319 19 338 20 358 21 379 21 400 22 422 22 444 23 467 23 490 23 513 24 537 25 562 26 588 26 614 26 640 27 667 27 694 28 722 29 751 29 780 29 809 30 839 30 869 30 899 31 930 31 961 32 993 33 1026 33 1059 33 1092 33 1125 33 1158 34 1192 34 1226 34 1260 34 1294 35 1329 35 1364 36 1400 36 1436 36 1472 36 1508 37 1545 37 1582 38 1620 38 1658 39 1697 39 1736 39 1775 40 1815 41 1856 41 1897 41 1938 42 1980 43 2023 43 2066 44 2110 44 2154 46 2200 46 2246 47 2293 47 2340 47 2387 47 2434 49 2483 50 2533 51 2584 52 2636 53 2689 54 2743 55 2798 55 2853 56 2909 56 2965 56 3021 57 3078 58 3136 58 3194 58 3252 58 3310 59 3369 59 3428 59 3487 59 3546 60 3606 61 3667 61 3728 62 3790 62 3852 63 3915 64 3979 65 4044 65 4109 65 4174 66 4240 67 4307 68 4375 69 4444 70 4514 72 4586 72 4658 72 4730 73 4803 73 4876 73 4949 74 5023 74 5097 74 5171 74 5245 74 5319 75 5394 75 5469 75 5544 76 5620 77 5697 77 5774 78 5852 78 5930 79 6009 80 6089 80 6169 81 6250 81 6331 81 6412 82 6494 83 6577 84 6661 84 6745 84 6829 84 6913 85 6998 85 7083 85 7168 86 7254 87 7341 87 7428 88 7516 89 7605 89 7694 89 7783 90 7873 90 7963 90 8053 91 8144 91 8235 91 8326 91 8417 91 8508 93 8601 93 8694 93 8787 94 8881 95 8976 95 9071 95 9166 96 9262 96 9358 96 9454 97 9551 97 9648 98 9746 98 9844 99 9943 99 10042 99 10141}
|
||||
|
||||
do_execsql_test 4.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY b;
|
||||
} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141 98 10141 99 10141 99 10141 99 10141}
|
||||
|
||||
do_execsql_test 4.5 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY b;
|
||||
} {0 0 1 2 1 2 2 6 2 6 2 6 3 6 3 6 4 4 5 5 6 6 7 21 7 21 7 21 8 24 8 24 8 24 9 27 9 27 9 27 10 10 11 22 11 22 12 36 12 36 12 36 13 26 13 26 14 14 15 45 15 45 15 45 16 48 16 48 16 48 17 17 19 19 20 20 21 42 21 42 22 44 22 44 23 69 23 69 23 69 24 24 25 25 26 78 26 78 26 78 27 54 27 54 28 28 29 87 29 87 29 87 30 90 30 90 30 90 31 62 31 62 32 32 33 165 33 165 33 165 33 165 33 165 34 136 34 136 34 136 34 136 35 70 35 70 36 144 36 144 36 144 36 144 37 74 37 74 38 76 38 76 39 117 39 117 39 117 40 40 41 123 41 123 41 123 42 42 43 86 43 86 44 88 44 88 46 92 46 92 47 188 47 188 47 188 47 188 49 49 50 50 51 51 52 52 53 53 54 54 55 110 55 110 56 168 56 168 56 168 57 57 58 232 58 232 58 232 58 232 59 236 59 236 59 236 59 236 60 60 61 122 61 122 62 124 62 124 63 63 64 64 65 195 65 195 65 195 66 66 67 67 68 68 69 69 70 70 72 216 72 216 72 216 73 219 73 219 73 219 74 370 74 370 74 370 74 370 74 370 75 225 75 225 75 225 76 76 77 154 77 154 78 156 78 156 79 79 80 160 80 160 81 243 81 243 81 243 82 82 83 83 84 336 84 336 84 336 84 336 85 255 85 255 85 255 86 86 87 174 87 174 88 88 89 267 89 267 89 267 90 270 90 270 90 270 91 455 91 455 91 455 91 455 91 455 93 279 93 279 93 279 94 94 95 285 95 285 95 285 96 288 96 288 96 288 97 194 97 194 98 196 98 196 99 297 99 297 99 297}
|
||||
|
||||
do_execsql_test 4.6.1 {
|
||||
SELECT b, sum(b) OVER (
|
||||
RANGE BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY b;
|
||||
} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141 98 10141 99 10141 99 10141 99 10141}
|
||||
|
||||
do_execsql_test 4.6.2 {
|
||||
SELECT b, sum(b) OVER () FROM t2 ORDER BY b;
|
||||
} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141 98 10141 99 10141 99 10141 99 10141}
|
||||
|
||||
do_execsql_test 4.6.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY b;
|
||||
} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141 98 10141 99 10141 99 10141 99 10141}
|
||||
|
||||
do_execsql_test 4.6.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY b;
|
||||
} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141 98 10141 99 10141 99 10141 99 10141}
|
||||
|
||||
do_execsql_test 4.7.1 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 0 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4 5 5 6 6 7 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 10 10 11 11 11 11 12 12 12 12 12 12 13 13 13 13 14 14 15 15 15 15 15 15 16 16 16 16 16 16 17 17 19 19 20 20 21 21 21 21 22 22 22 22 23 23 23 23 23 23 24 24 25 25 26 26 26 26 26 26 27 27 27 27 28 28 29 29 29 29 29 29 30 30 30 30 30 30 31 31 31 31 32 32 33 33 33 33 33 33 33 33 33 33 34 34 34 34 34 34 34 34 35 35 35 35 36 36 36 36 36 36 36 36 37 37 37 37 38 38 38 38 39 39 39 39 39 39 40 40 41 41 41 41 41 41 42 42 43 43 43 43 44 44 44 44 46 46 46 46 47 47 47 47 47 47 47 47 49 49 50 50 51 51 52 52 53 53 54 54 55 55 55 55 56 56 56 56 56 56 57 57 58 58 58 58 58 58 58 58 59 59 59 59 59 59 59 59 60 60 61 61 61 61 62 62 62 62 63 63 64 64 65 65 65 65 65 65 66 66 67 67 68 68 69 69 70 70 72 72 72 72 72 72 73 73 73 73 73 73 74 74 74 74 74 74 74 74 74 74 75 75 75 75 75 75 76 76 77 77 77 77 78 78 78 78 79 79 80 80 80 80 81 81 81 81 81 81 82 82 83 83 84 84 84 84 84 84 84 84 85 85 85 85 85 85 86 86 87 87 87 87 88 88 89 89 89 89 89 89 90 90 90 90 90 90 91 91 91 91 91 91 91 91 91 91 93 93 93 93 93 93 94 94 95 95 95 95 95 95 96 96 96 96 96 96 97 97 97 97 98 98 98 98 99 99 99 99 99 99}
|
||||
|
||||
do_execsql_test 4.7.2 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 0 1 3379 1 5443 2 372 2 4473 2 7074 3 2916 3 9096 4 4049 5 5643 6 1047 7 2205 7 7081 7 10141 8 1553 8 5926 8 6422 9 4883 9 7932 9 8497 10 9544 11 5727 11 6433 12 2825 12 5918 12 8582 13 5190 13 8570 14 8596 15 3189 15 6023 15 8924 16 1942 16 1958 16 3590 17 10134 19 7474 20 5946 21 5464 21 9682 22 3029 22 6140 23 212 23 1926 23 8520 24 2626 25 3331 26 337 26 7539 26 7565 27 1270 27 10035 28 3217 29 1649 29 4355 29 7326 30 4215 30 9400 30 9853 31 5977 31 6008 32 2857 33 370 33 4326 33 8175 33 8909 33 9661 34 6414 34 6516 34 8958 34 9925 35 2151 35 5638 36 3701 36 7818 36 8785 36 8994 37 4597 37 8557 38 735 38 9891 39 842 39 7513 39 9721 40 3475 41 115 41 4874 41 5906 42 4185 43 2754 43 3518 44 7072 44 9765 46 1041 46 1316 47 2198 47 3378 47 7612 47 7923 49 6482 50 9450 51 5778 52 9370 53 4408 54 1448 55 3174 55 6876 56 2913 56 3435 56 3574 57 7223 58 5248 58 7876 58 9318 58 9823 59 697 59 2813 59 6665 59 7455 60 6821 61 2426 61 4944 62 904 62 8658 63 4471 64 8407 65 2116 65 5177 65 5603 66 8142 67 1620 68 803 69 9260 70 7396 72 4833 72 8004 72 8076 73 5017 73 5716 73 6213 74 74 74 189 74 2365 74 5538 74 7297 75 3665 75 6951 75 8343 76 3964 77 1903 77 7028 78 1394 78 4293 79 6292 80 4677 80 7692 81 542 81 4045 81 8488 82 10117 83 10008 84 1826 84 4761 84 9534 84 9628 85 2602 85 2711 85 7166 86 2291 87 4560 87 5865 88 6380 89 461 89 3306 89 3790 90 3119 90 6606 90 7782 91 995 91 2517 91 3007 91 8749 91 8876 93 1742 93 2051 93 8268 94 4143 95 5112 95 6118 95 9191 96 638 96 5344 96 6761 97 1243 97 1545 98 3888 98 5442 99 311 99 1146 99 9093}
|
||||
|
||||
do_execsql_test 4.7.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141 98 10141 99 10141 99 10141 99 10141}
|
||||
|
||||
do_execsql_test 4.7.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 10141 1 4699 1 6763 2 3069 2 5670 2 9771 3 1048 3 7228 4 6096 5 4503 6 9100 7 7 7 3067 7 7943 8 3727 8 4223 8 8596 9 1653 9 2218 9 5267 10 607 11 3719 11 4425 12 1571 12 4235 12 7328 13 1584 13 4964 14 1559 15 1232 15 4133 15 6967 16 6567 16 8199 16 8215 17 24 19 2686 20 4215 21 480 21 4698 22 4023 22 7134 23 1644 23 8238 23 9952 24 7539 25 6835 26 2602 26 2628 26 9830 27 133 27 8898 28 6952 29 2844 29 5815 29 8521 30 318 30 771 30 5956 31 4164 31 4195 32 7316 33 513 33 1265 33 1999 33 5848 33 9804 34 250 34 1217 34 3659 34 3761 35 4538 35 8025 36 1183 36 1392 36 2359 36 6476 37 1621 37 5581 38 288 38 9444 39 459 39 2667 39 9338 40 6706 41 4276 41 5308 41 10067 42 5998 43 6666 43 7430 44 420 44 3113 46 8871 46 9146 47 2265 47 2576 47 6810 47 7990 49 3708 50 741 51 4414 52 823 53 5786 54 8747 55 3320 55 7022 56 6623 56 6762 56 7284 57 2975 58 376 58 881 58 2323 58 4951 59 2745 59 3535 59 7387 59 9503 60 3380 61 5258 61 7776 62 1545 62 9299 63 5733 64 1798 65 4603 65 5029 65 8090 66 2065 67 8588 68 9406 69 950 70 2815 72 2137 72 2209 72 5380 73 4001 73 4498 73 5197 74 2918 74 4677 74 7850 74 10026 74 10141 75 1873 75 3265 75 6551 76 6253 77 3190 77 8315 78 5926 78 8825 79 3928 80 2529 80 5544 81 1734 81 6177 81 9680 82 106 83 216 84 597 84 691 84 5464 84 8399 85 3060 85 7515 85 7624 86 7936 87 4363 87 5668 88 3849 89 6440 89 6924 89 9769 90 2449 90 3625 90 7112 91 1356 91 1483 91 7225 91 7715 91 9237 93 1966 93 8183 93 8492 94 6092 95 1045 95 4118 95 5124 96 3476 96 4893 96 9599 97 8693 97 8995 98 4797 98 6351 99 1147 99 9094 99 9929}
|
||||
|
||||
do_execsql_test 4.8.1 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN CURRENT ROW AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 0 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4 5 5 6 6 7 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 10 10 11 11 11 11 12 12 12 12 12 12 13 13 13 13 14 14 15 15 15 15 15 15 16 16 16 16 16 16 17 17 19 19 20 20 21 21 21 21 22 22 22 22 23 23 23 23 23 23 24 24 25 25 26 26 26 26 26 26 27 27 27 27 28 28 29 29 29 29 29 29 30 30 30 30 30 30 31 31 31 31 32 32 33 33 33 33 33 33 33 33 33 33 34 34 34 34 34 34 34 34 35 35 35 35 36 36 36 36 36 36 36 36 37 37 37 37 38 38 38 38 39 39 39 39 39 39 40 40 41 41 41 41 41 41 42 42 43 43 43 43 44 44 44 44 46 46 46 46 47 47 47 47 47 47 47 47 49 49 50 50 51 51 52 52 53 53 54 54 55 55 55 55 56 56 56 56 56 56 57 57 58 58 58 58 58 58 58 58 59 59 59 59 59 59 59 59 60 60 61 61 61 61 62 62 62 62 63 63 64 64 65 65 65 65 65 65 66 66 67 67 68 68 69 69 70 70 72 72 72 72 72 72 73 73 73 73 73 73 74 74 74 74 74 74 74 74 74 74 75 75 75 75 75 75 76 76 77 77 77 77 78 78 78 78 79 79 80 80 80 80 81 81 81 81 81 81 82 82 83 83 84 84 84 84 84 84 84 84 85 85 85 85 85 85 86 86 87 87 87 87 88 88 89 89 89 89 89 89 90 90 90 90 90 90 91 91 91 91 91 91 91 91 91 91 93 93 93 93 93 93 94 94 95 95 95 95 95 95 96 96 96 96 96 96 97 97 97 97 98 98 98 98 99 99 99 99 99 99}
|
||||
|
||||
do_execsql_test 4.8.2 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 0 1 3379 1 5443 2 372 2 4473 2 7074 3 2916 3 9096 4 4049 5 5643 6 1047 7 2205 7 7081 7 10141 8 1553 8 5926 8 6422 9 4883 9 7932 9 8497 10 9544 11 5727 11 6433 12 2825 12 5918 12 8582 13 5190 13 8570 14 8596 15 3189 15 6023 15 8924 16 1942 16 1958 16 3590 17 10134 19 7474 20 5946 21 5464 21 9682 22 3029 22 6140 23 212 23 1926 23 8520 24 2626 25 3331 26 337 26 7539 26 7565 27 1270 27 10035 28 3217 29 1649 29 4355 29 7326 30 4215 30 9400 30 9853 31 5977 31 6008 32 2857 33 370 33 4326 33 8175 33 8909 33 9661 34 6414 34 6516 34 8958 34 9925 35 2151 35 5638 36 3701 36 7818 36 8785 36 8994 37 4597 37 8557 38 735 38 9891 39 842 39 7513 39 9721 40 3475 41 115 41 4874 41 5906 42 4185 43 2754 43 3518 44 7072 44 9765 46 1041 46 1316 47 2198 47 3378 47 7612 47 7923 49 6482 50 9450 51 5778 52 9370 53 4408 54 1448 55 3174 55 6876 56 2913 56 3435 56 3574 57 7223 58 5248 58 7876 58 9318 58 9823 59 697 59 2813 59 6665 59 7455 60 6821 61 2426 61 4944 62 904 62 8658 63 4471 64 8407 65 2116 65 5177 65 5603 66 8142 67 1620 68 803 69 9260 70 7396 72 4833 72 8004 72 8076 73 5017 73 5716 73 6213 74 74 74 189 74 2365 74 5538 74 7297 75 3665 75 6951 75 8343 76 3964 77 1903 77 7028 78 1394 78 4293 79 6292 80 4677 80 7692 81 542 81 4045 81 8488 82 10117 83 10008 84 1826 84 4761 84 9534 84 9628 85 2602 85 2711 85 7166 86 2291 87 4560 87 5865 88 6380 89 461 89 3306 89 3790 90 3119 90 6606 90 7782 91 995 91 2517 91 3007 91 8749 91 8876 93 1742 93 2051 93 8268 94 4143 95 5112 95 6118 95 9191 96 638 96 5344 96 6761 97 1243 97 1545 98 3888 98 5442 99 311 99 1146 99 9093}
|
||||
|
||||
do_execsql_test 4.8.3 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141 98 10141 99 10141 99 10141 99 10141}
|
||||
|
||||
do_execsql_test 4.8.4 {
|
||||
SELECT b, sum(b) OVER (
|
||||
ORDER BY a
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t2 ORDER BY 1, 2;
|
||||
} {0 10141 1 4699 1 6763 2 3069 2 5670 2 9771 3 1048 3 7228 4 6096 5 4503 6 9100 7 7 7 3067 7 7943 8 3727 8 4223 8 8596 9 1653 9 2218 9 5267 10 607 11 3719 11 4425 12 1571 12 4235 12 7328 13 1584 13 4964 14 1559 15 1232 15 4133 15 6967 16 6567 16 8199 16 8215 17 24 19 2686 20 4215 21 480 21 4698 22 4023 22 7134 23 1644 23 8238 23 9952 24 7539 25 6835 26 2602 26 2628 26 9830 27 133 27 8898 28 6952 29 2844 29 5815 29 8521 30 318 30 771 30 5956 31 4164 31 4195 32 7316 33 513 33 1265 33 1999 33 5848 33 9804 34 250 34 1217 34 3659 34 3761 35 4538 35 8025 36 1183 36 1392 36 2359 36 6476 37 1621 37 5581 38 288 38 9444 39 459 39 2667 39 9338 40 6706 41 4276 41 5308 41 10067 42 5998 43 6666 43 7430 44 420 44 3113 46 8871 46 9146 47 2265 47 2576 47 6810 47 7990 49 3708 50 741 51 4414 52 823 53 5786 54 8747 55 3320 55 7022 56 6623 56 6762 56 7284 57 2975 58 376 58 881 58 2323 58 4951 59 2745 59 3535 59 7387 59 9503 60 3380 61 5258 61 7776 62 1545 62 9299 63 5733 64 1798 65 4603 65 5029 65 8090 66 2065 67 8588 68 9406 69 950 70 2815 72 2137 72 2209 72 5380 73 4001 73 4498 73 5197 74 2918 74 4677 74 7850 74 10026 74 10141 75 1873 75 3265 75 6551 76 6253 77 3190 77 8315 78 5926 78 8825 79 3928 80 2529 80 5544 81 1734 81 6177 81 9680 82 106 83 216 84 597 84 691 84 5464 84 8399 85 3060 85 7515 85 7624 86 7936 87 4363 87 5668 88 3849 89 6440 89 6924 89 9769 90 2449 90 3625 90 7112 91 1356 91 1483 91 7225 91 7715 91 9237 93 1966 93 8183 93 8492 94 6092 95 1045 95 4118 95 5124 96 3476 96 4893 96 9599 97 8693 97 8995 98 4797 98 6351 99 1147 99 9094 99 9929}
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,337 @@
|
||||
# 2018 May 19
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
source [file join [file dirname $argv0] pg_common.tcl]
|
||||
|
||||
#=========================================================================
|
||||
|
||||
start_test window3 "2018 May 31"
|
||||
ifcapable !windowfunc
|
||||
|
||||
execsql_test 1.0 {
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
|
||||
INSERT INTO t2(a, b) VALUES
|
||||
(1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
|
||||
(10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
|
||||
(18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
|
||||
(26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
|
||||
(34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
|
||||
(42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
|
||||
(50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
|
||||
(58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
|
||||
(66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
|
||||
(74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
|
||||
(82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
|
||||
(90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
|
||||
(98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
|
||||
(106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
|
||||
(114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
|
||||
(121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
|
||||
(128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
|
||||
(135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
|
||||
(143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
|
||||
(150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
|
||||
(158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
|
||||
(166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
|
||||
(173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
|
||||
(181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
|
||||
(188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
|
||||
(195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
|
||||
}
|
||||
|
||||
execsql_test 1.1 {
|
||||
SELECT max(b) OVER (
|
||||
ORDER BY a
|
||||
) FROM t2
|
||||
}
|
||||
|
||||
foreach {tn window} {
|
||||
1 "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"
|
||||
2 "RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
|
||||
3 "RANGE BETWEEN CURRENT ROW AND CURRENT ROW"
|
||||
4 "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
|
||||
5 "ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING"
|
||||
6 "ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING"
|
||||
7 "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"
|
||||
8 "ROWS BETWEEN 4 PRECEDING AND CURRENT ROW"
|
||||
9 "ROWS BETWEEN CURRENT ROW AND CURRENT ROW"
|
||||
10 "ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING"
|
||||
11 "ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING"
|
||||
12 "ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING"
|
||||
13 "ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING"
|
||||
14 "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
|
||||
15 "ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING"
|
||||
16 "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
|
||||
17 "ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING"
|
||||
} {
|
||||
execsql_test 1.$tn.2.1 "SELECT max(b) OVER ( ORDER BY a $window ) FROM t2"
|
||||
execsql_test 1.$tn.2.2 "SELECT min(b) OVER ( ORDER BY a $window ) FROM t2"
|
||||
|
||||
execsql_test 1.$tn.3.1 "
|
||||
SELECT row_number() OVER ( ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.3.2 "
|
||||
SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.3.3 "
|
||||
SELECT row_number() OVER ( $window ) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.4.1 "
|
||||
SELECT dense_rank() OVER ( ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.4.2 "
|
||||
SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.4.3 "
|
||||
SELECT dense_rank() OVER ( ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.4.4 "
|
||||
SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.4.5 "
|
||||
SELECT dense_rank() OVER ( ORDER BY b%10 $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.4.6 "
|
||||
SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.5.1 "
|
||||
SELECT rank() OVER ( ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.5.2 "
|
||||
SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.5.3 "
|
||||
SELECT rank() OVER ( ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.5.4 "
|
||||
SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.5.5 "
|
||||
SELECT rank() OVER ( ORDER BY b%10 $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.5.6 "
|
||||
SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.6.1 "
|
||||
SELECT
|
||||
row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
|
||||
rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
|
||||
dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window )
|
||||
FROM t2
|
||||
"
|
||||
|
||||
execsql_float_test 1.$tn.7.1 "
|
||||
SELECT percent_rank() OVER ( ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.7.2 "
|
||||
SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.7.3 "
|
||||
SELECT percent_rank() OVER ( ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.7.4 "
|
||||
SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.7.5 "
|
||||
SELECT percent_rank() OVER ( ORDER BY b%10 $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.7.6 "
|
||||
SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
|
||||
execsql_float_test 1.$tn.8.1 "
|
||||
SELECT cume_dist() OVER ( ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.2 "
|
||||
SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.3 "
|
||||
SELECT cume_dist() OVER ( ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.4 "
|
||||
SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.5 "
|
||||
SELECT cume_dist() OVER ( ORDER BY b%10 $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.6 "
|
||||
SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
|
||||
"
|
||||
|
||||
execsql_float_test 1.$tn.8.1 "
|
||||
SELECT ntile(100) OVER ( ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.2 "
|
||||
SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.3 "
|
||||
SELECT ntile(102) OVER ( ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.4 "
|
||||
SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.5 "
|
||||
SELECT ntile(104) OVER ( ORDER BY b%10,a $window ) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.6 "
|
||||
SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
execsql_float_test 1.$tn.8.7 "
|
||||
SELECT ntile(105) OVER ( $window ) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.9.1 "
|
||||
SELECT last_value(a+b) OVER ( ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.9.2 "
|
||||
SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.9.3 "
|
||||
SELECT last_value(a+b) OVER ( ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.9.4 "
|
||||
SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.9.5 "
|
||||
SELECT last_value(a+b) OVER ( ORDER BY b%10,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.9.6 "
|
||||
SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.10.1 "
|
||||
SELECT nth_value(b,b+1) OVER (ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.10.2 "
|
||||
SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.10.3 "
|
||||
SELECT nth_value(b,b+1) OVER ( ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.10.4 "
|
||||
SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.10.5 "
|
||||
SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.10.6 "
|
||||
SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.11.1 "
|
||||
SELECT first_value(b) OVER (ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.11.2 "
|
||||
SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.11.3 "
|
||||
SELECT first_value(b) OVER ( ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.11.4 "
|
||||
SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.11.5 "
|
||||
SELECT first_value(b) OVER ( ORDER BY b%10,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.11.6 "
|
||||
SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.12.1 "
|
||||
SELECT lead(b,b) OVER (ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.12.2 "
|
||||
SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.12.3 "
|
||||
SELECT lead(b,b) OVER ( ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.12.4 "
|
||||
SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.12.5 "
|
||||
SELECT lead(b,b) OVER ( ORDER BY b%10,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.12.6 "
|
||||
SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.13.1 "
|
||||
SELECT lag(b,b) OVER (ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.13.2 "
|
||||
SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.13.3 "
|
||||
SELECT lag(b,b) OVER ( ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.13.4 "
|
||||
SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.13.5 "
|
||||
SELECT lag(b,b) OVER ( ORDER BY b%10,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.13.6 "
|
||||
SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.14.1 "
|
||||
SELECT string_agg(CAST(b AS TEXT), '.') OVER (ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.14.2 "
|
||||
SELECT string_agg(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.14.3 "
|
||||
SELECT string_agg(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.14.4 "
|
||||
SELECT string_agg(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.14.5 "
|
||||
SELECT string_agg(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a $window ) FROM t2
|
||||
"
|
||||
execsql_test 1.$tn.14.6 "
|
||||
SELECT string_agg(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.15.1 "
|
||||
SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
|
||||
FILTER (WHERE a%2=0) OVER win FROM t2
|
||||
WINDOW win AS (ORDER BY a $window)
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.15.2 "
|
||||
SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
|
||||
FILTER (WHERE 0=1) OVER win FROM t2
|
||||
WINDOW win AS (ORDER BY a $window)
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.15.3 "
|
||||
SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
|
||||
FILTER (WHERE 1=0) OVER win FROM t2
|
||||
WINDOW win AS (PARTITION BY (a%10) ORDER BY a $window)
|
||||
"
|
||||
|
||||
execsql_test 1.$tn.15.4 "
|
||||
SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
|
||||
FILTER (WHERE a%2=0) OVER win FROM t2
|
||||
WINDOW win AS (PARTITION BY (a%10) ORDER BY a $window)
|
||||
"
|
||||
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+6793
File diff suppressed because one or more lines are too long
@@ -0,0 +1,336 @@
|
||||
# 2018 May 19
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
source [file join [file dirname $argv0] pg_common.tcl]
|
||||
|
||||
#=========================================================================
|
||||
|
||||
start_test window4 "2018 June 04"
|
||||
ifcapable !windowfunc
|
||||
|
||||
execsql_test 1.0 {
|
||||
DROP TABLE IF EXISTS t3;
|
||||
CREATE TABLE t3(a TEXT PRIMARY KEY);
|
||||
INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
|
||||
INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
|
||||
}
|
||||
|
||||
for {set i 1} {$i < 20} {incr i} {
|
||||
execsql_test 1.$i "SELECT a, ntile($i) OVER (ORDER BY a) FROM t3"
|
||||
}
|
||||
|
||||
execsql_test 2.0 {
|
||||
DROP TABLE IF EXISTS t4;
|
||||
CREATE TABLE t4(a INTEGER PRIMARY KEY, b TEXT, c INTEGER);
|
||||
INSERT INTO t4 VALUES(1, 'A', 9);
|
||||
INSERT INTO t4 VALUES(2, 'B', 3);
|
||||
INSERT INTO t4 VALUES(3, 'C', 2);
|
||||
INSERT INTO t4 VALUES(4, 'D', 10);
|
||||
INSERT INTO t4 VALUES(5, 'E', 5);
|
||||
INSERT INTO t4 VALUES(6, 'F', 1);
|
||||
INSERT INTO t4 VALUES(7, 'G', 1);
|
||||
INSERT INTO t4 VALUES(8, 'H', 2);
|
||||
INSERT INTO t4 VALUES(9, 'I', 10);
|
||||
INSERT INTO t4 VALUES(10, 'J', 4);
|
||||
}
|
||||
|
||||
execsql_test 2.1 {
|
||||
SELECT a, nth_value(b, c) OVER (ORDER BY a) FROM t4
|
||||
}
|
||||
|
||||
execsql_test 2.2.1 {
|
||||
SELECT a, lead(b) OVER (ORDER BY a) FROM t4
|
||||
}
|
||||
execsql_test 2.2.2 {
|
||||
SELECT a, lead(b, 2) OVER (ORDER BY a) FROM t4
|
||||
}
|
||||
execsql_test 2.2.3 {
|
||||
SELECT a, lead(b, 3, 'abc') OVER (ORDER BY a) FROM t4
|
||||
}
|
||||
|
||||
execsql_test 2.3.1 {
|
||||
SELECT a, lag(b) OVER (ORDER BY a) FROM t4
|
||||
}
|
||||
execsql_test 2.3.2 {
|
||||
SELECT a, lag(b, 2) OVER (ORDER BY a) FROM t4
|
||||
}
|
||||
execsql_test 2.3.3 {
|
||||
SELECT a, lag(b, 3, 'abc') OVER (ORDER BY a) FROM t4
|
||||
}
|
||||
|
||||
execsql_test 2.4.1 {
|
||||
SELECT string_agg(b, '.') OVER (
|
||||
ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t4
|
||||
}
|
||||
|
||||
execsql_test 3.0 {
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
|
||||
INSERT INTO t5 VALUES(1, 'A', 'one', 5);
|
||||
INSERT INTO t5 VALUES(2, 'B', 'two', 4);
|
||||
INSERT INTO t5 VALUES(3, 'A', 'three', 3);
|
||||
INSERT INTO t5 VALUES(4, 'B', 'four', 2);
|
||||
INSERT INTO t5 VALUES(5, 'A', 'five', 1);
|
||||
}
|
||||
|
||||
execsql_test 3.1 {
|
||||
SELECT a, nth_value(c, d) OVER (ORDER BY b) FROM t5
|
||||
}
|
||||
|
||||
execsql_test 3.2 {
|
||||
SELECT a, nth_value(c, d) OVER (PARTITION BY b ORDER BY a) FROM t5
|
||||
}
|
||||
|
||||
execsql_test 3.3 {
|
||||
SELECT a, count(*) OVER abc, count(*) OVER def FROM t5
|
||||
WINDOW abc AS (ORDER BY a),
|
||||
def AS (ORDER BY a DESC)
|
||||
ORDER BY a;
|
||||
}
|
||||
|
||||
execsql_test 3.4 {
|
||||
SELECT a, max(a) FILTER (WHERE (a%2)=0) OVER w FROM t5
|
||||
WINDOW w AS (ORDER BY a)
|
||||
}
|
||||
|
||||
execsql_test 3.5.1 {
|
||||
SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING)
|
||||
FROM t5
|
||||
}
|
||||
execsql_test 3.5.2 {
|
||||
SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
|
||||
FROM t5
|
||||
}
|
||||
execsql_test 3.5.3 {
|
||||
SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 PRECEDING AND 0 PRECEDING)
|
||||
FROM t5
|
||||
}
|
||||
|
||||
execsql_test 3.6.1 {
|
||||
SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 1 FOLLOWING)
|
||||
FROM t5
|
||||
}
|
||||
execsql_test 3.6.2 {
|
||||
SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)
|
||||
FROM t5
|
||||
}
|
||||
execsql_test 3.6.3 {
|
||||
SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 FOLLOWING AND 0 FOLLOWING)
|
||||
FROM t5
|
||||
}
|
||||
|
||||
==========
|
||||
|
||||
execsql_test 4.0 {
|
||||
DROP TABLE IF EXISTS ttt;
|
||||
CREATE TABLE ttt(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER);
|
||||
INSERT INTO ttt VALUES(1, 1, 1);
|
||||
INSERT INTO ttt VALUES(2, 2, 2);
|
||||
INSERT INTO ttt VALUES(3, 3, 3);
|
||||
|
||||
INSERT INTO ttt VALUES(4, 1, 2);
|
||||
INSERT INTO ttt VALUES(5, 2, 3);
|
||||
INSERT INTO ttt VALUES(6, 3, 4);
|
||||
|
||||
INSERT INTO ttt VALUES(7, 1, 3);
|
||||
INSERT INTO ttt VALUES(8, 2, 4);
|
||||
INSERT INTO ttt VALUES(9, 3, 5);
|
||||
}
|
||||
|
||||
execsql_test 4.1 {
|
||||
SELECT max(c), max(b) OVER (ORDER BY b) FROM ttt GROUP BY b;
|
||||
}
|
||||
|
||||
execsql_test 4.2 {
|
||||
SELECT max(b) OVER (ORDER BY max(c)) FROM ttt GROUP BY b;
|
||||
}
|
||||
|
||||
execsql_test 4.3 {
|
||||
SELECT abs(max(b) OVER (ORDER BY b)) FROM ttt GROUP BY b;
|
||||
}
|
||||
|
||||
execsql_test 4.4 {
|
||||
SELECT sum(b) OVER (
|
||||
ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM ttt;
|
||||
}
|
||||
|
||||
set lPart [list "PARTITION BY b" "PARTITION BY b, a" "" "PARTITION BY a"]
|
||||
set lOrder [list "ORDER BY a" "ORDER BY a DESC" "" "ORDER BY b, a"]
|
||||
set lRange {
|
||||
"RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"
|
||||
"RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
|
||||
"RANGE BETWEEN CURRENT ROW AND CURRENT ROW"
|
||||
"RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
|
||||
}
|
||||
|
||||
set lRows {
|
||||
"ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING"
|
||||
"ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING"
|
||||
"ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING"
|
||||
"ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING"
|
||||
"ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING"
|
||||
}
|
||||
|
||||
set tn 1
|
||||
set SQL {
|
||||
SELECT max(c) OVER ($p1 $o1 $r1),
|
||||
min(c) OVER ($p2 $o2 $r2)
|
||||
FROM ttt ORDER BY a
|
||||
}
|
||||
set SQL2 {
|
||||
SELECT sum(c) OVER ($p1 $o1 $r1),
|
||||
sum(c) OVER ($p2 $o2 $r2)
|
||||
FROM ttt ORDER BY a
|
||||
}
|
||||
|
||||
set o1 [lindex $lOrder 0]
|
||||
set o2 [lindex $lOrder 0]
|
||||
set r1 [lindex $lRange 0]
|
||||
set r2 [lindex $lRange 0]
|
||||
foreach p1 $lPart { foreach p2 $lPart {
|
||||
execsql_test 4.5.$tn.1 [subst $SQL]
|
||||
execsql_test 4.5.$tn.2 [subst $SQL2]
|
||||
incr tn
|
||||
}}
|
||||
|
||||
set o1 [lindex $lOrder 0]
|
||||
set o2 [lindex $lOrder 0]
|
||||
set p1 [lindex $lPart 0]
|
||||
set p2 [lindex $lPart 0]
|
||||
foreach r1 $lRange { foreach r2 $lRange {
|
||||
execsql_test 4.5.$tn.1 [subst $SQL]
|
||||
execsql_test 4.5.$tn.2 [subst $SQL2]
|
||||
incr tn
|
||||
}}
|
||||
foreach r1 $lRows { foreach r2 $lRows {
|
||||
execsql_test 4.5.$tn.1 [subst $SQL]
|
||||
execsql_test 4.5.$tn.2 [subst $SQL2]
|
||||
incr tn
|
||||
}}
|
||||
|
||||
set r1 [lindex $lRange 0]
|
||||
set r2 [lindex $lRange 0]
|
||||
set p1 [lindex $lPart 0]
|
||||
set p2 [lindex $lPart 0]
|
||||
foreach o1 $lOrder { foreach o2 $lOrder {
|
||||
execsql_test 4.5.$tn.1 [subst $SQL]
|
||||
execsql_test 4.5.$tn.2 [subst $SQL2]
|
||||
incr tn
|
||||
}}
|
||||
|
||||
==========
|
||||
|
||||
execsql_test 7.0 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(x INTEGER, y INTEGER);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
INSERT INTO t1 VALUES(5, 6);
|
||||
INSERT INTO t1 VALUES(7, 8);
|
||||
INSERT INTO t1 VALUES(9, 10);
|
||||
}
|
||||
|
||||
execsql_test 7.1 {
|
||||
SELECT lead(y) OVER win FROM t1
|
||||
WINDOW win AS (ORDER BY x)
|
||||
}
|
||||
|
||||
execsql_test 7.2 {
|
||||
SELECT lead(y, 2) OVER win FROM t1
|
||||
WINDOW win AS (ORDER BY x)
|
||||
}
|
||||
|
||||
execsql_test 7.3 {
|
||||
SELECT lead(y, 3, -1) OVER win FROM t1
|
||||
WINDOW win AS (ORDER BY x)
|
||||
}
|
||||
|
||||
execsql_test 7.4 {
|
||||
SELECT
|
||||
lead(y) OVER win, lead(y) OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY x)
|
||||
}
|
||||
|
||||
execsql_test 7.5 {
|
||||
SELECT
|
||||
lead(y) OVER win,
|
||||
lead(y, 2) OVER win,
|
||||
lead(y, 3, -1) OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY x)
|
||||
}
|
||||
|
||||
==========
|
||||
|
||||
execsql_test 8.0 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER);
|
||||
INSERT INTO t1 VALUES(1, 2, 3, 4);
|
||||
INSERT INTO t1 VALUES(5, 6, 7, 8);
|
||||
INSERT INTO t1 VALUES(9, 10, 11, 12);
|
||||
}
|
||||
|
||||
execsql_test 8.1 {
|
||||
SELECT row_number() OVER win,
|
||||
nth_value(d,2) OVER win,
|
||||
lead(d) OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY a)
|
||||
}
|
||||
|
||||
execsql_test 8.2 {
|
||||
SELECT row_number() OVER win,
|
||||
rank() OVER win,
|
||||
dense_rank() OVER win,
|
||||
ntile(2) OVER win,
|
||||
first_value(d) OVER win,
|
||||
last_value(d) OVER win,
|
||||
nth_value(d,2) OVER win,
|
||||
lead(d) OVER win,
|
||||
lag(d) OVER win,
|
||||
max(d) OVER win,
|
||||
min(d) OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY a)
|
||||
}
|
||||
|
||||
==========
|
||||
|
||||
execsql_test 9.0 {
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t2(x INTEGER);
|
||||
INSERT INTO t2 VALUES(1), (1), (1), (4), (4), (6), (7);
|
||||
}
|
||||
|
||||
execsql_test 9.1 {
|
||||
SELECT rank() OVER () FROM t2
|
||||
}
|
||||
execsql_test 9.2 {
|
||||
SELECT dense_rank() OVER (PARTITION BY x) FROM t2
|
||||
}
|
||||
execsql_float_test 9.3 {
|
||||
SELECT x, percent_rank() OVER (PARTITION BY x ORDER BY x) FROM t2
|
||||
}
|
||||
|
||||
execsql_test 9.4 {
|
||||
SELECT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
|
||||
}
|
||||
|
||||
execsql_test 9.5 {
|
||||
SELECT DISTINCT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+1236
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
# 2018 May 8
|
||||
#
|
||||
# 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. Specifically,
|
||||
# it tests the sqlite3_create_window_function() API.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix window5
|
||||
|
||||
ifcapable !windowfunc {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
proc m_step {ctx val} {
|
||||
lappend ctx $val
|
||||
return $ctx
|
||||
}
|
||||
proc m_value {ctx} {
|
||||
set lSort [lsort $ctx]
|
||||
|
||||
set nVal [llength $lSort]
|
||||
set n [expr $nVal/2]
|
||||
|
||||
if {($nVal % 2)==0 && $nVal>0} {
|
||||
set a [lindex $lSort $n]
|
||||
set b [lindex $lSort $n-1]
|
||||
if {($a+$b) % 2} {
|
||||
set ret [expr ($a+$b)/2.0]
|
||||
} else {
|
||||
set ret [expr ($a+$b)/2]
|
||||
}
|
||||
} else {
|
||||
set ret [lindex $lSort $n]
|
||||
}
|
||||
return $ret
|
||||
}
|
||||
proc m_inverse {ctx val} {
|
||||
set ctx [lrange $ctx 1 end]
|
||||
return $ctx
|
||||
}
|
||||
proc w_value {ctx} {
|
||||
lsort $ctx
|
||||
}
|
||||
|
||||
sqlite3_create_window_function db median m_step m_value m_value m_inverse
|
||||
sqlite3_create_window_function db win m_step w_value w_value m_inverse
|
||||
|
||||
do_test 0.0 {
|
||||
test_create_window_function_misuse db
|
||||
} {}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, b);
|
||||
INSERT INTO t1 VALUES(4, 'a');
|
||||
INSERT INTO t1 VALUES(6, 'b');
|
||||
INSERT INTO t1 VALUES(1, 'c');
|
||||
INSERT INTO t1 VALUES(5, 'd');
|
||||
INSERT INTO t1 VALUES(2, 'e');
|
||||
INSERT INTO t1 VALUES(3, 'f');
|
||||
}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
SELECT win(a) OVER (ORDER BY b), median(a) OVER (ORDER BY b) FROM t1;
|
||||
} {4 4 {4 6} 5 {1 4 6} 4 {1 4 5 6} 4.5 {1 2 4 5 6} 4 {1 2 3 4 5 6} 3.5}
|
||||
|
||||
test_create_sumint db
|
||||
do_execsql_test 2.0 {
|
||||
SELECT sumint(a) OVER (ORDER BY rowid) FROM t1 ORDER BY rowid;
|
||||
} {4 10 11 16 18 21}
|
||||
|
||||
do_execsql_test 2.1 {
|
||||
SELECT sumint(a) OVER (ORDER BY rowid ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1 ORDER BY rowid;
|
||||
} {10 11 12 8 10 5}
|
||||
|
||||
test_override_sum db
|
||||
do_catchsql_test 3.0 {
|
||||
SELECT sum(a) OVER
|
||||
(ORDER BY b ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)
|
||||
FROM t1;
|
||||
} {1 {sum() may not be used as a window function}}
|
||||
do_execsql_test 3.1 {
|
||||
SELECT sum(a) FROM t1;
|
||||
} {21}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
# 2018 May 8
|
||||
#
|
||||
# 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. Specifically,
|
||||
# it tests the sqlite3_create_window_function() API.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix window6
|
||||
|
||||
ifcapable !windowfunc {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
set setup {
|
||||
CREATE TABLE %t1(%x, %y %typename);
|
||||
INSERT INTO %t1 VALUES(1, 'a');
|
||||
INSERT INTO %t1 VALUES(2, 'b');
|
||||
INSERT INTO %t1 VALUES(3, 'c');
|
||||
INSERT INTO %t1 VALUES(4, 'd');
|
||||
INSERT INTO %t1 VALUES(5, 'e');
|
||||
}
|
||||
|
||||
foreach {tn vars} {
|
||||
1 {}
|
||||
2 { set A(%t1) over }
|
||||
3 { set A(%x) over }
|
||||
4 {
|
||||
set A(%alias) over
|
||||
set A(%x) following
|
||||
set A(%y) over
|
||||
}
|
||||
5 {
|
||||
set A(%t1) over
|
||||
set A(%x) following
|
||||
set A(%y) preceding
|
||||
set A(%w) current
|
||||
set A(%alias) filter
|
||||
set A(%typename) window
|
||||
}
|
||||
|
||||
6 {
|
||||
set A(%x) window
|
||||
}
|
||||
} {
|
||||
set A(%t1) t1
|
||||
set A(%x) x
|
||||
set A(%y) y
|
||||
set A(%w) w
|
||||
set A(%alias) alias
|
||||
set A(%typename) integer
|
||||
eval $vars
|
||||
|
||||
set MAP [array get A]
|
||||
set setup_sql [string map $MAP $setup]
|
||||
reset_db
|
||||
execsql $setup_sql
|
||||
|
||||
do_execsql_test 1.$tn.1 [string map $MAP {
|
||||
SELECT group_concat(%x, '.') OVER (ORDER BY %y) FROM %t1
|
||||
}] {1 1.2 1.2.3 1.2.3.4 1.2.3.4.5}
|
||||
|
||||
do_execsql_test 1.$tn.2 [string map $MAP {
|
||||
SELECT sum(%x) OVER %w FROM %t1 WINDOW %w AS (ORDER BY %y)
|
||||
}] {1 3 6 10 15}
|
||||
|
||||
do_execsql_test 1.$tn.3 [string map $MAP {
|
||||
SELECT sum(%alias.%x) OVER %w FROM %t1 %alias WINDOW %w AS (ORDER BY %y)
|
||||
}] {1 3 6 10 15}
|
||||
|
||||
do_execsql_test 1.$tn.4 [string map $MAP {
|
||||
SELECT sum(%x) %alias FROM %t1
|
||||
}] {15}
|
||||
}
|
||||
|
||||
|
||||
proc winproc {args} { return "window: $args" }
|
||||
db func window winproc
|
||||
do_execsql_test 2.0 {
|
||||
SELECT window('hello world');
|
||||
} {{window: {hello world}}}
|
||||
|
||||
proc wincmp {a b} { string compare $b $a }
|
||||
db collate window wincmp
|
||||
do_execsql_test 3.0 {
|
||||
CREATE TABLE window(x COLLATE window);
|
||||
INSERT INTO window VALUES('bob'), ('alice'), ('cate');
|
||||
SELECT * FROM window ORDER BY x COLLATE window;
|
||||
} {cate bob alice}
|
||||
do_execsql_test 3.1 {
|
||||
DROP TABLE window;
|
||||
CREATE TABLE x1(x);
|
||||
INSERT INTO x1 VALUES('bob'), ('alice'), ('cate');
|
||||
CREATE INDEX window ON x1(x COLLATE window);
|
||||
SELECT * FROM x1 ORDER BY x COLLATE window;
|
||||
} {cate bob alice}
|
||||
|
||||
|
||||
do_execsql_test 4.0 { CREATE TABLE t4(x, y); }
|
||||
|
||||
# do_execsql_test 4.1 { PRAGMA parser_trace = 1 }
|
||||
do_execsql_test 4.1 {
|
||||
SELECT * FROM t4 window, t4;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
|
||||
do_execsql_test 5.0 {
|
||||
CREATE TABLE over(x, over);
|
||||
CREATE TABLE window(x, window);
|
||||
INSERT INTO over VALUES(1, 2), (3, 4), (5, 6);
|
||||
INSERT INTO window VALUES(1, 2), (3, 4), (5, 6);
|
||||
SELECT sum(x) over FROM over
|
||||
} {9}
|
||||
|
||||
do_execsql_test 5.1 {
|
||||
SELECT sum(x) over over FROM over WINDOW over AS ()
|
||||
} {9 9 9}
|
||||
|
||||
do_execsql_test 5.2 {
|
||||
SELECT sum(over) over over over FROM over over WINDOW over AS (ORDER BY over)
|
||||
} {2 6 12}
|
||||
|
||||
do_execsql_test 5.3 {
|
||||
SELECT sum(over) over over over FROM over over WINDOW over AS (ORDER BY over);
|
||||
} {2 6 12}
|
||||
|
||||
do_execsql_test 5.4 {
|
||||
SELECT sum(window) OVER window window FROM window window window window AS (ORDER BY window);
|
||||
} {2 6 12}
|
||||
|
||||
do_execsql_test 5.5 {
|
||||
SELECT count(*) OVER win FROM over
|
||||
WINDOW win AS (ORDER BY x ROWS BETWEEN +2 FOLLOWING AND +3 FOLLOWING)
|
||||
} {1 0 0}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
do_execsql_test 6.0 {
|
||||
SELECT LIKE('!', '', '!') x WHERE x;
|
||||
} {}
|
||||
|
||||
do_execsql_test 6.1 {
|
||||
SELECT LIKE("!","","!")""WHeRE"";
|
||||
} {}
|
||||
|
||||
do_catchsql_test 6.2 {
|
||||
SELECT LIKE("!","","!")""window"";
|
||||
} {1 {near "window": syntax error}}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 7.0 {
|
||||
CREATE TABLE t1(x TEXT);
|
||||
CREATE INDEX i1 ON t1(x COLLATE nocase);
|
||||
INSERT INTO t1 VALUES('');
|
||||
}
|
||||
|
||||
do_execsql_test 7.1 {
|
||||
SELECT count(*) FROM t1 WHERE x LIKE '!' ESCAPE '!';
|
||||
} {0}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_execsql_test 8.0 {
|
||||
CREATE TABLE IF NOT EXISTS "sample" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY,
|
||||
"counter" INTEGER NOT NULL,
|
||||
"value" REAL NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO "sample" (counter, value)
|
||||
VALUES (1, 10.), (1, 20.), (2, 1.), (2, 3.), (3, 100.);
|
||||
}
|
||||
|
||||
do_execsql_test 8.1 {
|
||||
SELECT "counter", "value", RANK() OVER w AS "rank"
|
||||
FROM "sample"
|
||||
WINDOW w AS (PARTITION BY "counter" ORDER BY "value" DESC)
|
||||
ORDER BY "counter", RANK() OVER w
|
||||
} {
|
||||
1 20.0 1 1 10.0 2 2 3.0 1 2 1.0 2 3 100.0 1
|
||||
}
|
||||
|
||||
do_execsql_test 8.2 {
|
||||
SELECT "counter", "value", SUM("value") OVER
|
||||
(ORDER BY "id" ROWS 2 PRECEDING)
|
||||
FROM "sample"
|
||||
ORDER BY "id"
|
||||
} {
|
||||
1 10.0 10.0 1 20.0 30.0 2 1.0 31.0 2 3.0 24.0 3 100.0 104.0
|
||||
}
|
||||
|
||||
do_execsql_test 8.3 {
|
||||
SELECT SUM("value") OVER
|
||||
(ORDER BY "id" ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)
|
||||
FROM "sample"
|
||||
ORDER BY "id"
|
||||
} {
|
||||
10.0 30.0 31.0 24.0 104.0
|
||||
}
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,133 @@
|
||||
# 2018 May 8
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix windowfault
|
||||
|
||||
ifcapable !windowfunc {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, b, c, d);
|
||||
INSERT INTO t1 VALUES(1, 2, 3, 4);
|
||||
INSERT INTO t1 VALUES(5, 6, 7, 8);
|
||||
INSERT INTO t1 VALUES(9, 10, 11, 12);
|
||||
}
|
||||
faultsim_save_and_close
|
||||
|
||||
do_faultsim_test 1 -start 1 -faults oom-* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
SELECT row_number() OVER win,
|
||||
rank() OVER win,
|
||||
dense_rank() OVER win,
|
||||
ntile(2) OVER win,
|
||||
first_value(d) OVER win,
|
||||
last_value(d) OVER win,
|
||||
nth_value(d,2) OVER win,
|
||||
lead(d) OVER win,
|
||||
lag(d) OVER win,
|
||||
max(d) OVER win,
|
||||
min(d) OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY a)
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 1 1 1 4 4 {} 8 {} 4 4 2 2 2 1 4 8 8 12 4 8 4 3 3 3 2 4 12 8 {} 8 12 4}}
|
||||
}
|
||||
|
||||
do_faultsim_test 1.1 -faults oom-t* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
SELECT row_number() OVER win,
|
||||
rank() OVER win,
|
||||
dense_rank() OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (PARTITION BY c<7 ORDER BY a)
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 1 1 2 2 2 1 1 1}}
|
||||
}
|
||||
|
||||
do_faultsim_test 1.2 -faults oom-t* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
SELECT ntile(105)
|
||||
OVER ( RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
|
||||
FROM t1
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 2 3}}
|
||||
}
|
||||
|
||||
do_faultsim_test 2 -start 1 -faults oom-* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
SELECT round(percent_rank() OVER win, 2),
|
||||
round(cume_dist() OVER win, 2)
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY a)
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {0.0 0.33 0.5 0.67 1.0 1.0}}
|
||||
}
|
||||
|
||||
do_faultsim_test 3 -faults oom-* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
SELECT min(d) OVER win, max(d) OVER win
|
||||
FROM t1
|
||||
WINDOW win AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {4 12 8 12 12 12}}
|
||||
}
|
||||
|
||||
do_faultsim_test 4 -faults oom-* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
CREATE VIEW aaa AS
|
||||
SELECT min(d) OVER w, max(d) OVER w
|
||||
FROM t1
|
||||
WINDOW w AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING);
|
||||
SELECT * FROM aaa;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {4 12 8 12 12 12}}
|
||||
}
|
||||
|
||||
do_faultsim_test 5 -start 1 -faults oom-* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
SELECT last_value(a) OVER win1,
|
||||
last_value(a) OVER win2
|
||||
FROM t1
|
||||
WINDOW win1 AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING),
|
||||
win2 AS (ORDER BY a)
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {5 1 9 5 9 9}}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+17
-2
@@ -90,6 +90,7 @@
|
||||
/************* Begin control #defines *****************************************/
|
||||
%%
|
||||
/************* End control #defines *******************************************/
|
||||
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
|
||||
|
||||
/* Define the yytestcase() macro to be a no-op if is not already defined
|
||||
** otherwise.
|
||||
@@ -519,11 +520,11 @@ static YYACTIONTYPE yy_find_shift_action(
|
||||
do{
|
||||
i = yy_shift_ofst[stateno];
|
||||
assert( i>=0 );
|
||||
assert( i+YYNTOKEN<=(int)sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
|
||||
/* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */
|
||||
assert( iLookAhead!=YYNOCODE );
|
||||
assert( iLookAhead < YYNTOKEN );
|
||||
i += iLookAhead;
|
||||
if( yy_lookahead[i]!=iLookAhead ){
|
||||
if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){
|
||||
#ifdef YYFALLBACK
|
||||
YYCODETYPE iFallback; /* Fallback token */
|
||||
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
|
||||
@@ -549,6 +550,7 @@ static YYACTIONTYPE yy_find_shift_action(
|
||||
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
|
||||
j<YY_ACTTAB_COUNT &&
|
||||
#endif
|
||||
j<sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) &&
|
||||
yy_lookahead[j]==YYWILDCARD && iLookAhead>0
|
||||
){
|
||||
#ifndef NDEBUG
|
||||
@@ -1057,3 +1059,16 @@ void Parse(
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the fallback token corresponding to canonical token iToken, or
|
||||
** 0 if iToken has no fallback.
|
||||
*/
|
||||
int ParseFallback(int iToken){
|
||||
#ifdef YYFALLBACK
|
||||
if( iToken<sizeof(yyFallback)/sizeof(yyFallback[0]) ){
|
||||
return yyFallback[iToken];
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -148,6 +148,11 @@ struct Keyword {
|
||||
#else
|
||||
# define UPSERT 0x00080000
|
||||
#endif
|
||||
#ifdef SQLITE_OMIT_WINDOWFUNC
|
||||
# define WINDOWFUNC 0
|
||||
#else
|
||||
# define WINDOWFUNC 0x00100000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** These are the keywords
|
||||
@@ -180,6 +185,7 @@ static Keyword aKeywordTable[] = {
|
||||
{ "CONSTRAINT", "TK_CONSTRAINT", ALWAYS },
|
||||
{ "CREATE", "TK_CREATE", ALWAYS },
|
||||
{ "CROSS", "TK_JOIN_KW", ALWAYS },
|
||||
{ "CURRENT", "TK_CURRENT", WINDOWFUNC },
|
||||
{ "CURRENT_DATE", "TK_CTIME_KW", ALWAYS },
|
||||
{ "CURRENT_TIME", "TK_CTIME_KW", ALWAYS },
|
||||
{ "CURRENT_TIMESTAMP","TK_CTIME_KW", ALWAYS },
|
||||
@@ -202,6 +208,8 @@ static Keyword aKeywordTable[] = {
|
||||
{ "EXISTS", "TK_EXISTS", ALWAYS },
|
||||
{ "EXPLAIN", "TK_EXPLAIN", EXPLAIN },
|
||||
{ "FAIL", "TK_FAIL", CONFLICT|TRIGGER },
|
||||
{ "FILTER", "TK_FILTER", WINDOWFUNC },
|
||||
{ "FOLLOWING", "TK_FOLLOWING", WINDOWFUNC },
|
||||
{ "FOR", "TK_FOR", TRIGGER },
|
||||
{ "FOREIGN", "TK_FOREIGN", FKEY },
|
||||
{ "FROM", "TK_FROM", ALWAYS },
|
||||
@@ -241,11 +249,15 @@ static Keyword aKeywordTable[] = {
|
||||
{ "OR", "TK_OR", ALWAYS },
|
||||
{ "ORDER", "TK_ORDER", ALWAYS },
|
||||
{ "OUTER", "TK_JOIN_KW", ALWAYS },
|
||||
{ "OVER", "TK_OVER", WINDOWFUNC },
|
||||
{ "PARTITION", "TK_PARTITION", WINDOWFUNC },
|
||||
{ "PLAN", "TK_PLAN", EXPLAIN },
|
||||
{ "PRAGMA", "TK_PRAGMA", PRAGMA },
|
||||
{ "PRECEDING", "TK_PRECEDING", WINDOWFUNC },
|
||||
{ "PRIMARY", "TK_PRIMARY", ALWAYS },
|
||||
{ "QUERY", "TK_QUERY", EXPLAIN },
|
||||
{ "RAISE", "TK_RAISE", TRIGGER },
|
||||
{ "RANGE", "TK_RANGE", WINDOWFUNC },
|
||||
{ "RECURSIVE", "TK_RECURSIVE", CTE },
|
||||
{ "REFERENCES", "TK_REFERENCES", FKEY },
|
||||
{ "REGEXP", "TK_LIKE_KW", ALWAYS },
|
||||
@@ -257,6 +269,7 @@ static Keyword aKeywordTable[] = {
|
||||
{ "RIGHT", "TK_JOIN_KW", ALWAYS },
|
||||
{ "ROLLBACK", "TK_ROLLBACK", ALWAYS },
|
||||
{ "ROW", "TK_ROW", TRIGGER },
|
||||
{ "ROWS", "TK_ROWS", ALWAYS },
|
||||
{ "SAVEPOINT", "TK_SAVEPOINT", ALWAYS },
|
||||
{ "SELECT", "TK_SELECT", ALWAYS },
|
||||
{ "SET", "TK_SET", ALWAYS },
|
||||
@@ -267,6 +280,7 @@ static Keyword aKeywordTable[] = {
|
||||
{ "TO", "TK_TO", ALWAYS },
|
||||
{ "TRANSACTION", "TK_TRANSACTION", ALWAYS },
|
||||
{ "TRIGGER", "TK_TRIGGER", TRIGGER },
|
||||
{ "UNBOUNDED", "TK_UNBOUNDED", WINDOWFUNC },
|
||||
{ "UNION", "TK_UNION", COMPOUND },
|
||||
{ "UNIQUE", "TK_UNIQUE", ALWAYS },
|
||||
{ "UPDATE", "TK_UPDATE", ALWAYS },
|
||||
@@ -275,6 +289,7 @@ static Keyword aKeywordTable[] = {
|
||||
{ "VALUES", "TK_VALUES", ALWAYS },
|
||||
{ "VIEW", "TK_VIEW", VIEW },
|
||||
{ "VIRTUAL", "TK_VIRTUAL", VTAB },
|
||||
{ "WINDOW", "TK_WINDOW", WINDOWFUNC },
|
||||
{ "WITH", "TK_WITH", CTE },
|
||||
{ "WITHOUT", "TK_WITHOUT", ALWAYS },
|
||||
{ "WHEN", "TK_WHEN", ALWAYS },
|
||||
|
||||
@@ -351,6 +351,7 @@ foreach file {
|
||||
wherecode.c
|
||||
whereexpr.c
|
||||
where.c
|
||||
window.c
|
||||
|
||||
parse.c
|
||||
|
||||
|
||||
@@ -369,6 +369,7 @@ foreach file {
|
||||
wherecode.c
|
||||
whereexpr.c
|
||||
where.c
|
||||
window.c
|
||||
|
||||
parse.c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user