Small. Fast. Reliable.
Choose any three.
Status color codes: Active Bugs Active Issues Fixed Tested Deferred Closed
# Type Status Created By Subsys Changed Assigned Svr Pri Title  
Description
Remarks
 
2915 build active 2008 Feb pweilbacher   2008 Feb   4 3 fix Makefile for platforms that need .exe extension edit
There are some targets that need a $(TEXE) added in Makefile.in. Otherwise a platform that needs a .exe extension cannot run e.g. tests.
 
2909 build active 2008 Jan aswift   2008 Jan aswift 4 4 Omit the _XOPEN_SOURCE 500 define on Mac OS-X (check for __APPLE__) edit
sqliteInt.h attempts to avoid setting _XOPEN_SOURCE on MacOSX by checking if __DARWIN__ is defined, however on Leopard (as of Mac OS X 10.5) this test fails and should be enhanced by testing for both __DARWIN__ and __APPLE__

Building sqlite succeeds with _XOPEN_SOURCE defined, but it causes _POSIX_C_SOURCE to be defined which leads to failing to define F_FULLFSYNC which prevents use of the fullfsync pragma.

 
2881 build active 2008 Jan anonymous   2008 Jan   1 1 Latest sqlite-3.5.4 build fail on latest Fedora 2.6.23.12-52.fc7 edit
Two test cases fail.

  io-4.1...
  Expected: [3]
     Got: [2]
  io-4.2.1... Ok
  io-4.2.2... Ok
  io-4.2.3...
  Expected: [3]
     Got: [2]
  io-4.3.1... Ok

Let me know how to run individual test cases and how this might be fixed.

Here's how I built sqlite using latest CVS. If something is wrong here, let me know and I'll rebuild/retest.

I'm building on latest Fedora fc7.

Thanks.

_______

  net1#uname -a
  Linux net1.coolsurf.com 2.6.23.12-52.fc7 #1 SMP Tue Dec 18 20:27:10 EST 2007 x86_64 x86_64 x86_64 GNU/Linux

  net1#build_sqlite
  mkdir -p /build/work/sqlite-3.5.4
  cd /build/work/sqlite-3.5.4
  unset CDPATH
  export CFLAGS='-pipe -O3 -g -DSQLITE_DISABLE_DIRSYNC=1 -Wall'
  rm -rf bld
  cvs -d :pserver:anonymous@www.sqlite.org:/sqlite -r update .
  mkdir bld
  cd bld
  ../configure --prefix=/common/pkgs/sqlite-3.5.4 --enable-tcl --with-tcl=/usr/lib64 --enable-threadsafe --enable-threads-override-locks
  make
  groupadd vuser || /bin/true
  useradd -M -g vuser -d /vhost/davidfavor.com/users/david -s /bin/zsh   david  || /bin/true
  useradd -M -g vuser -d /vhost/livefeast.com/users/yemiah -s /bin/zsh yemiah || /bin/true
  chown david:vuser -R ..
  su -c "make test" david
2008-Jan-11 17:18:52 by anonymous:
Same tests still fail with CVS of today around 11AM CST.


2008-Jan-11 17:41:55 by drh:
FWIW, both those test cases pass on SuSE 10.1. I do not understand why they are failing on Fedora. But in any event, the tests in question are verifying logic that implements an optimization that is not used on Fedora, ever. So the failures are of no consequence. If those are the only two tests that fail, then you can safely use the build for whatever it is you are trying to do.


2008-Jan-11 19:16:19 by anonymous:
Failures when 'make fulltest' built with CFLAGS of

  '-pipe -O3 -g -Wall -DSQLITE_DISABLE_DIRSYNC=1 -DSQLITE_MEMDEBUG'

   exclusive-malloc-1.transient.746...make: *** [fulltest]
      Segmentation fault

Failures when 'make fulltest' built with CFLAGS of

   '-pipe -O3 -g -Wall -DSQLITE_DISABLE_DIRSYNC=1'

   Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG...
   6 errors out of 61998 tests
   Failures on these tests: exclusive-ioerr-2.280.4
      exclusive-ioerr-2.281.4 exclusive-ioerr-2.282.4
      incrvacuum-ioerr-1.31.4 io-4.1 io-4.2.3
   All memory allocations freed - no leaks
   Maximum memory usage: 14376554 bytes

Pre 3.5.x builds work fine on Fedora. If you're open to debugging all these, I'd like to go through and resolve all these one by one, so Fedora has a clean build/fulltest.

Please let me know how to run each test individually and I'll try to figure out the problem with each.

Thanks.

 
2866 build active 2008 Jan anonymous   2008 Jan   1 3 Problems building Windows native in cygwin/mingw environment edit
Trying to build Windows native version using the Cygwin build environment.

$ gcc -v Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug Thread model: posix gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) $

$ CFLAGS=-mno-cygwin ./configure --disable-tcl --enable-threadsafe

$ make

A) The make appears to build sqlite3.exe just fine, without errors or warnings. This binary does work from cmd.exe, BUT not from within the bash cygwin shell for some reason, unlike other Windows native binaries I've built.

Next...

$ make install

B) The

cc sqlite3.c -o sqlite3

fails to rebuild sqlite3.exe correctly with the -mno-cygwin option. The output follows:

rm -rf tsrc mkdir -p tsrc cp ./src/alter.c ./src/analyze.c ./src/attach.c ./src/auth.c ./src/btmutex.c ./src/btree.c ./src/btree.h ./src/build.c ./src/callback.c ./src/complete.c ./src/date.c ./src/delete.c ./src/expr.c ./src/func.c ./src/hash.c ./src/hash.h ./src/insert.c ./src/journal.c ./src/legacy.c ./src/loadext.c ./src/main.c ./src/malloc.c ./src/mem1.c ./src/mem2.c ./src/mem3.c ./src/mutex.c ./src/mutex_os2.c ./src/mutex_unix.c ./src/mutex_w32.c ./src/os.c ./src/os_unix.c ./src/os_win.c ./src/os_os2.c ./src/pager.c ./src/pager.h ./src/parse.y ./src/pragma.c ./src/prepare.c ./src/printf.c ./src/random.c ./src/select.c ./src/shell.c ./src/sqlite.h.in ./src/sqliteInt.h ./src/table.c ./src/tclsqlite.c ./src/tokenize.c ./src/trigger.c ./src/utf.c ./src/update.c ./src/util.c ./src/vacuum.c ./src/vdbe.c ./src/vdbe.h ./src/vdbeapi.c ./src/vdbeaux.c ./src/vdbeblob.c ./src/vdbefifo.c ./src/vdbemem.c ./src/vdbeInt.h ./src/vtab.c ./src/where.c ./ext/fts1/fts1.c ./ext/fts1/fts1.h ./ext/fts1/fts1_hash.c ./ext/fts1/fts1_hash.h ./ext/fts1/fts1_porter.c ./ext/fts1/fts1_tokenizer.h ./ext/fts1/fts1_tokenizer1.c sqlite3.h ./src/btree.h ./src/btreeInt.h ./src/hash.h ./src/sqliteLimit.h ./src/mutex.h opcodes.h ./src/os.h ./src/os_common.h ./src/sqlite3ext.h ./src/sqliteInt.h ./src/vdbe.h parse.h ./ext/fts1/fts1.h ./ext/fts1/fts1_hash.h ./ext/fts1/fts1_tokenizer.h ./src/vdbeInt.h tsrc cp: warning: source file `./src/btree.h' specified more than once cp: warning: source file `./src/hash.h' specified more than once cp: warning: source file `./src/sqliteInt.h' specified more than once cp: warning: source file `./src/vdbe.h' specified more than once cp: warning: source file `./ext/fts1/fts1.h' specified more than once cp: warning: source file `./ext/fts1/fts1_hash.h' specified more than once cp: warning: source file `./ext/fts1/fts1_tokenizer.h' specified more than once cp: warning: source file `./src/vdbeInt.h' specified more than once rm tsrc/sqlite.h.in tsrc/parse.y cp parse.c opcodes.c keywordhash.h tsrc tclsh ./tool/mksqlite3c.tcl cc sqlite3.c -o sqlite3 /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain@16' collect2: ld returned 1 exit status make: *** [sqlite3] Error 1 $

 
558 build active 2004 Jan anonymous   2007 Dec   4 4 Makefile.in should honor libdir and bindir edit
Please support non-standard installation layouts by honoring configure's --libdir and --bindir flags rather than hard-coding $(exec_prefix)/lib and $(exec_prefix)/bin. (For instance, the layout we often use on Solaris has parallel "lib" and "lib64" directories under a common prefix.)
2007-Dec-18 17:29:26 by anonymous:
Why is this ticket not solved? The patch is trivial and solves a real problem.

Thank you.


2007-Dec-18 17:54:46 by drh:
The patch does not apply to the current makefile. And I do not understand what the -libdir or -bindir options are for or what they are suppose to do so I do not know how to fix it.
 
2844 build active 2007 Dec anonymous   2007 Dec   4 1 lemon is being built without respecting LDFLAGS edit
lemon is being built without respecting LDFLAGS. I'm attaching a patch which fixes this bug.

In other words, why should we fix this? What problem is it causing?

2007-Dec-17 16:22:19 by drh:
Why is this important? What LDFLAGS settings might a user want to carry through into lemon?


2007-Dec-17 18:00:59 by anonymous:
> Why is this important?

It is considered to be be good practice to respect user's LDFLAGS. A user might want to have all executables and libraries built with identical LDFLAGS.

> What LDFLAGS settings might a user want to carry through into lemon?

A user might have LDFLAGS="-Wl,-O1,--hash-style=gnu,--sort-common"

You can read http://lwn.net/Articles/192082/.

Users can also use some other flags.

> In other words, why should we fix this? What problem is it causing?

It slightly increases the size of lemon executable and it slightly decreases performance.


2007-Dec-17 18:04:31 by drh:
lemon is used as an intermediate build tool in part of the SQLite build process. It is not a deliverable. If it runs a little slower or uses a little more memory, nobody cares. We only care if it gets the wrong answer.

Is it ever possible that the lack of LDFLAGS support might result in lemon getting the wrong answer?


2007-Dec-17 18:27:33 by anonymous:
Can you comment on Lemon bug in #2835? It produces 2 different sqlite3.c files depending on your malloc implementation.


2007-Dec-17 19:19:01 by anonymous:
> lemon is used as an intermediate build tool in part of the

> SQLite build process. It is not a deliverable. If it runs a

> little slower or uses a little more memory, nobody cares.

CFLAGS are respected when lemon is being built, so for consistency LDFLAGS also should be respected.

(The comment above was not created by me.)

 
2813 build active 2007 Nov anonymous   2007 Nov   1 1 compile error on Windows CE edit
environment: visual c++ 2005 window ce 6.0 customize sdk sqlite-amalgamation-3_5_3

I get error:

Error 27 error C2040: 'localtime' : 'tm *(const time_t *)' differs in levels of indirection from 'int ()' d:\SubProjects\Sqlite\sqlite3.c 18574

but if I add code in line 7095:

struct tm *__cdecl localtime(const time_t *t);

then Success!

 
285 build active 2003 Apr anonymous Unknown 2007 Nov   2 2 Configure doesn't honour LDFLAGS during build edit
Right now the configure script in the 2.8.0 tar.gz and CVS can't quite build a working SQLite when Fink is installed - it gets confused with finding readline.

(I've not been able to find the right places to add these changes).

* if LDFLAGS is set it is used during the check phase of configure but it isn't used during the build, ie. LDFLAGS doesn't get into the Makefile, this leads to the readline support being turned on but the libraries not being available at link time

* paths searched for readline.h should include /sw

 
2787 build active 2007 Nov anonymous   2007 Nov   4 5 sqlite3.pc is not remade edit
the subject says it all, there is no make rule to rebuild the sqlite3.pc from the .in file. it is only possible by hand (./config.status sqlite3.pc)
2007-Nov-22 12:17:50 by drh:
I don't know what the sqlite3.pc file does. I certainly do not use it for any of my builds on Linux, Mac OSX, or windows. Why should I leave it in the source tree? Isn't the best solution to this problem to simply delete the file?


2007-Nov-22 17:14:27 by anonymous:
It is indirectly used by pkgconfig. Here's some info on pkgconfig:

http://pkg-config.freedesktop.org/wiki/


2007-Nov-23 15:22:32 by drh:
Could somebody who understands what the sqlite3.pc file is used for suggest a makefile rule for rebuilding it?
 
2763 build active 2007 Nov anonymous   2007 Nov   4 4 AIX build failure due to explicit _XOPEN_SOURCE definition edit
Our AIX machine has started having problems building the new sqlite 3.5.2 source. I'm no AIX expert, but I did some digging and I think it's due to sqliteInt.h defining _XOPEN_SOURCE without also defining _ALL_SOURCE.

AIX system header files usually define this themselves (in /usr/include/ standards.h) but only if _XOPEN_SOURCE was previously undefined.

Has anyone else come across this bug? I'm willing to believe it's our build system if not; we can work around it by setting _ALL_SOURCE on the command-line, but I thought it might be useful to raise a bug anyway.

See also tickets #2673, #2681, and #2741.

I do not have access to an AIX machine and so have no ability to debug this problem. If you have suggested patches we will consider them. Otherwise, there is not much we can do about this ticket.

 
2736 build active 2007 Oct anonymous   2007 Oct   2 2 build problems on freebsd edit
on freebsd:

--disable-threads does not work. it is accepted as a valid option but no defs are added to the makefile -lgcc needs to be included in SHLIB_LD_LIBS pkgIndex.tcl is not built when -DSQLITE_THREADSAFE=0 is added manually, this causes the install target to fail.

2007-Oct-17 21:16:23 by anonymous:
I forgot to mention this is with the TEA version
 
2727 build active 2007 Oct anonymous   2007 Oct   4 4 building with -malign-double causes strange behavior edit
sqlite 3.5.1 amalgamation has problems when enabling a wide set of compiler features on gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4) on linux/i686 /w glibc-2.5 strange behavior occurs.

typical strangeness is that SQLITE_FULL is returned from sqlite3_prepare_v2() (called immediately after a statement was created with sqlite3_mprintf). This happens even though there is a reasonable amount of disk space free (6G).

the compile line looks like:
cc -g -pg -O1 -march=i686 -msse2 -malign-double -m128bit-long-double -momit-leaf-frame-pointer -minline-all-stringops -D_XOPEN_SOURCE=520 '-DVERSION="0.10r276M"' -Isqlite/ -DSQLITE_OMIT_LOAD_EXTENSION -DTHREADSAFE=0 -DSQLITE_OMIT_EXPLAIN -DSQLITE_ENABLE_COLUMN_METADATA -c -o sqlite/sqlite3.o sqlite/sqlite3.c

and valgrind reports:
==15323== Use of uninitialised value of size 4
==15323== at 0x80585B7: insertElement (sqlite3.c:13072)
==15323== by 0x807366E: sqlite3HashInsert (sqlite3.c:13290)
==15323== by 0x809FE72: unixOpen (sqlite3.c:15403)
==15323== by 0x80579A7: sqlite3OsOpen (sqlite3.c:8210)
==15323== by 0x806B12F: sqlite3BtreeFactory (sqlite3.c:21317)
==15323== by 0x80767BA: openDatabase (sqlite3.c:71237)
==15323== by 0x8076BD1: sqlite3_open (sqlite3.c:71337)
==15323== by 0x804BEAE: db_init (dbmgr.c:81)
==15323== by 0x804CE64: main (main.c:59)

my dbmgr.c:81:db_init() is: res=sqlite3_open(filename, &system_db);

and system_db=NULL and filename="zomg.sqlite" (string literal). so the parameters seem normal. if I turn off -malign-double everything works fine. (this "bug" also seems to be on 3.4.1 amalgamation)

2007-Oct-14 04:35:16 by anonymous:
This is a compiler issue. -malign-double creates problems for most programs. What are you trying to accomplish?
 
2645 build active 2007 Sep anonymous   2007 Sep   5 4 Conflict between tclConfig.sh and tclinstaller.tcl edit
I'm using a non-standard location for Tcl:

  --with-tcl=/home/scott/lib

The build process finds and uses the tclConfig.sh file from /home/scott/lib just fine, but tclinstaller.tcl is called without an explicit path and uses the system's tclsh instead of the one in /home/scott/bin and thus tries to install that portion of code into the system's area.

While I can change my path to resolve this, I think it makes more sense for tclinstaller.tcl to use the path information that's embedded in tclConfig.sh to be consistent.

/s.

 
2587 build active 2007 Aug anonymous   2007 Aug   3 4 Build problem when using the SQLITE_OMIT_FLOATING_POINT define. edit
I apologize in advance if the values I chose above are not appropriate.

If I define SQLITE_OMIT_FLOATING_POINT=1 and try to build a Windows DLL, I get two errors in loadext.c, line 116 and 192. "error C4028: formal para meter 3 different from declaration"

I believe you want to change the include order at the top of loadext.c from:

#include "sqlite3ext.h"

#include "sqliteInt.h"

to:

#include "sqliteInt.h"

#include "sqlite3ext.h"

Reversing the order of include fixes my build.

Yes, I know there is no real reason to disable floating point for the Windows DLL. I'm actually porting SqLite for use in an NT kernel mode driver and avoiding floating point operations will save a lot of time if I don't really need them and I don't. So I made sure this was a problem with a supported platform like the Windows DLL and griped about that instead of my insanity. ;-)

You can email questons to mspiegel@vipmail.com. If you want to discuss this over the phone, shoot me an email and I'll send you phone numbers.

 
2567 build active 2007 Aug anonymous   2007 Aug   3 2 Build fails to install edit
I compile under MinGW with Msys. A build error occurs during 'make install'. After checking the makefile. The 'install' target depends on 'sqlite3', when it should be 'sqlite3$(TEXE)'.

The workaround is, after configure, edit makefile for target install, and replace 'sqlite3' with 'sqlite3${TEXE}' where needed. I did not have this problem with 3.3.17. I assume this could be fixed just by fixing the configure to produce correct makefile.

2007-Aug-12 04:41:12 by anonymous:
Do you have a patch?
 
2566 build active 2007 Aug anonymous   2007 Aug   2 1 fts2 broken after vacuum edit
Hi there, I'm testing your database and I'm having problems with fts2:
sqlite> select * from distB where distB match "MARIANO"; Assertion failed: *pData!='\0', file fts2amal.c, line 16790

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.


Steps: 1) Create a new .db 2) Import data in new distA table 3) Import data in new distB table 4) Create a new distC virtual table (dts2) 5) insert into distC (rowid, f1, f2, f3) select rowid, f1, f2, f3 from DistB

Everything working like a charm until here!!! The fts2 works very well, but after

6) vacuum;

the fts seems broken... doing a select throws the error I paste at the post of the topic

If you want the .db file I can send it to you (607MB)

Thanks.-

 
2469 build active 2007 Jun anonymous   2007 Jul   1 1 test fails on Solaris edit
I have a problem running the test suite on Solaris 9. Build was done using gcc 4.2.0. The build completes without error but many tests fail. I've created my own minimal test that exhibits the problem:

set testdir [file dirname $argv0]
source $testdir/tester.tcl

db close
file delete -force test.db test.db-journal
sqlite db test.db

do_test tdb-1 {
  execsql {
    PRAGMA auto_vacuum = 1;
    BEGIN;
    CREATE TABLE t1(a, b);
  }
  execsql {
    COMMIT;
  }
} {}
integrity_check tdb-2

finish_test
When running this test I get the following output:

tdb-1... Ok
tdb-2...
Expected: [ok]
     Got: [{*** in database main ***
List of tree roots: 2nd reference to page 1
Page 3 is never used}]
Thread-specific data deallocated properly
1 errors out of 3 tests
Failures on these tests: tdb-2
This error happens on lots of, but not all, tests.

I'm happy to do whatever is necessary to help debug this.

Thanks, Tim.

2007-Jun-27 10:44:14 by anonymous:
Further to this, it appears to be related to gcc 4.2.0. It works fine with gcc 3.4.6.


2007-Jun-28 09:54:35 by anonymous:
Further more, it doesn't appear to be specific to Solaris. The same problem occurs on Linux with gcc 4.2.0.

So I guess the subject of this ticket should be changed to "build/test problems with gcc 4.2.0".

This is probably a significant problem - the build completes find but the resultant code is broken. People may not notice this until it's too late.


2007-Jun-28 12:24:05 by drh:
I installed gcc 4.2.0 on my SuSE linux i686 desktop and built test harnesses under three different configurations:

     gcc420 -g -O0 -Wall -fstrict-aliasing
     gcc420 -g -O3 -Wall
     gcc420 -g -O3 -fstrict-aliasing -fomit-frame-pointer

The first two configurations used separate source files. The third configuration was built using the amalgamation. I ran the "quick" test under all configurations. All tests ran to completion with no errors.


2007-Jun-28 13:22:20 by anonymous:
Two ideas:

1. Compile with gcc 4.2.0 using -O0 instead of -O2 and see what happens. Disable any other optimizations you may have.

2. Run truss with full read/write buffer display on the gcc 3.4.6 compiled testfixture running your simple test case and compare its output to the gcc 4.2.0 compiled test case.


2007-Jul-01 19:00:40 by anonymous:
I've done tests with optimisation, and this appears to tickle the problem.

With no optimisation, -O, -O0, -O1 and -03 it works.

With -O2 and -Os it's broken.

I was compiling with -O2 when I submitted the initial report.

Tim.


2007-Jul-01 19:54:54 by drh:
I can reproduce the problem now on Linux when compiling as follows:

    gcc420 -g -O2 -Wall


2007-Jul-01 21:50:42 by drh:
This appears to be a bug in GCC 4.3.0. A work-around is to compile with the -fno-tree-vrp option.

GCC appears to miscompile a single loop within the logic that implements the integrity_check PRAGMA. The code that gets miscompiled is in the file vdbe.c (lines numbers added):

   4308    for(j=0; j<nRoot; j++){
   4309      aRoot[j] = pTos[-j].u.i;
   4310    }
   4311    aRoot[j] = 0;

It is line 4309 that appears to be miscompiled. The pTos pointer points to the top of the stack in virtual machine. The loop attempts to load the array with integer values that have been pushed onto the stack.

Running this code in GDB and setting a breakpoint on line 4311, we get the following output:

    Breakpoint 1, sqlite3VdbeExec (p=0x80ca708) at ../sqlite/src/vdbe.c:4311
    4311      aRoot[j] = 0;
    (gdb) print nRoot
    $1 = 2
    (gdb) print aRoot[0]@2
    $2 = {1, 1}
    (gdb) print pTos[0].u.i
    $3 = 1
    (gdb) print pTos[-1].u.i
    $4 = 2

As you can see above, two values have been pushed onto the virtual machine stack. (nRoot==2). But instead of loading each value into aRoot[], the top-most value is loaded multiple times. aRoot[] ends up holding {1, 1} instead of the correct values of {1, 2}.

I will submit a bug report to GCC shortly...


2007-Jul-01 22:09:23 by drh:
Bug reported filed with GCC:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32575


2007-Jul-05 13:33:09 by anonymous:
Could the test case at the top of this ticket be checked in with a comment pointing to this ticket? Other people may be experiencing this problem and not realizing it.


2007-Jul-21 10:00:56 by anonymous:
I can confirm this is still broken with gcc 4.2.1 and sqlite 3.4.1.

Tim.


2007-Jul-21 12:53:40 by drh:
The bug is in GCC, not SQLite The work-around is to compile without optimization. See the comments above.


2007-Jul-21 14:10:43 by anonymous:
The problem is that this is a compiler in widespread use, and you'll likely see randomly corrupted databases in the wild as result of this.

Are you able to create a smaller test case so that GCC will still exhibit this bug? (Assuming it is verified to be a compiler bug).


2007-Jul-21 16:12:42 by anonymous:
Yup - I know it's a GCC bug. I just wanted to note that the recent gcc 4.2.1 release doesn't fix the issue.


2007-Jul-21 18:55:33 by anonymous:
Simple way to detect if your copy of sqlite3 is broken:

  echo "CREATE TABLE t(x); pragma integrity_check;" | ./sqlite3

If it is broken it will output:

  *** in database main ***
  List of tree roots: 2nd reference to page 1
  Page 2 is never used

If fine:

  ok


2007-Jul-21 19:20:07 by anonymous:
This patch works around the problem with gcc-4.2.1 and sqlite 3.4.1 and allows "make test" to run cleanly. I'd appreciate if you'd apply it as gcc 4.2.x is a widely distributed compiler, and the default sqlite3 ./configure build will result in this bug.

Joe

RCS file: /sqlite/sqlite/src/vdbe.c,v
retrieving revision 1.636
diff -u -3 -p -r1.636 vdbe.c
--- src/vdbe.c  1 Jul 2007 21:18:40 -0000       1.636
+++ src/vdbe.c  21 Jul 2007 19:10:13 -0000
@@ -4306,7 +4306,8 @@ case OP_IntegrityCk: {
   pnErr = &p->aMem[j];
   assert( (pnErr->flags & MEM_Int)!=0 );
   for(j=0; j<nRoot; j++){
-    aRoot[j] = pTos[-j].u.i;
+    /* See Ticket #2469. Was: aRoot[j] = pTos[-j].u.i; */
+    aRoot[j] = (pTos-j)->u.i;
   }
   aRoot[j] = 0;
   popStack(&pTos, nRoot);

2007-Jul-21 20:31:01 by anonymous:
Not verified, but these debug trace lines follow the same pattern and may be problematic under gcc 4.2.x -O2.

  src/vdbe.c:          fprintf(p->trace, " si:%lld", pTos[i].u.i);
  src/vdbe.c:          fprintf(p->trace, " i:%lld", pTos[i].u.i);

This line's code appears to be generated okay under -O2:

  src/vdbe.c:  nArg = pTos[-1].u.i;


2007-Jul-23 13:33:55 by anonymous:
Two other GCC 4.2.1 -O2 bug workarounds are shown below which may help in the search for the optimization bug.

Joe.

(1)

  int ZZZ = 0; // must be a global variable

...

   for(j=0; j<nRoot; j++){
     aRoot[j] = pTos[ZZZ-j].u.i;
   }

(2)

  int ZZZ = 0; // must be a global variable

...

   for(j=ZZZ; j<nRoot; j++){
     aRoot[j] = pTos[-j].u.i;
   }
 
2377 build active 2007 May pweilbacher   2007 Jul   4 3 Allow easy DLL build on OS/2 edit
Makefile.in contains a target to build a DLL on Windows but unfortunately it doesn't work for OS/2. Current GCC versions use a calling convention that prepends underscores and these need to go into the .def file. To make a nice DLL header some extra lines in the .def file would be nice, too, that are probably incompatible with Windows linkers. Finally, to make the DLL usable we need to create an import library .lib.

As a nice-to-have feature I would like the DLL to be named after the VERSION but without the dot, as I expect DLLs from version 3.0.x to be imcompatible with 3.3.x or other future 3.x versions... I don't know a clever way to do that other than introducing a new variable into configure.ac and Makefile.in.

2007-Jul-03 23:42:20 by pweilbacher:
SQLite releases for OS/2 are now built from the amalgamation, so this is only useful for checks of the CVS code between releases.

Not sure if it still makes sense to check this in, but at least the patch can stay attached to the ticket for possible future reference.

 
2457 build active 2007 Jun anonymous   2007 Jun drh 1 2 Build fails with internal compiler error (Windows, MS VC++ 6.0) edit
I can't say much. Using the TEA tarball for sqlite 3.4.0 and trying to build this on a windows box using MS VC++ 6.0 the compilation aborts with an 'INTERNAL COMPILER ERROR'.

I will attach the log as a remark. There are lots of warnings as well, about double/int conversion, argument int size mismatches. Most worrying is a series of warnings with negative line numbers!. Given that I am actually not even sure if the location where it fails is correct.

... Yes, when I tried to exclude the reported line (25589, amalgamation) via -DSQLITE_OMIT_INCRBLOB the compiler still crashes, but now in line 25555 of the amalgamation.

Note: v3.3.17 builds fine (again tea tarball, amalgamation).

I wonder ... Is it possible to provide a TEA tarball without amalgamation ? I would like to see if that compiles, maybe the amalgamation has become so large that it is hitting some compiler limit.

2007-Jun-25 20:04:23 by anonymous:
Ok, reducing the size of the amalgamation by actually stripping out comments does not help. While the negative line numbers in the warnings go away, ditto the warnings about terminating line number generation, it still runs into the Internal Error.


2007-Jun-25 20:22:41 by anonymous:
Even a version of gcc chokes on the amalgamation when I compile with -g -O3. Try compiling without debug information. If that still fails, you have to build sqlite directly from the sources.


2007-Jun-25 21:16:07 by anonymous:
Which version of gcc is failing? It seems to work fine here:

  gcc -I. -g -O6 -c ./sqlite3.c
  gcc -I. -g -O6 -DHAVE_READLINE=1 -c ../src/shell.c
  gcc -I. -o amalg-sqlite -g ./shell.o ./sqlite3.o -ldl -lpthread -lreadline

works fine. It might be worth filing a gcc bug if you see something radically different with gcc.


2007-Jun-25 21:18:52 by anonymous:
AK Regarding GCC. We are here not using GCC on Windows, so the comment regarding 'gcc -O3' does not apply.


2007-Jun-25 21:20:47 by drh:
The comment above about being unable to compile using gcc -g -O3 is not from the originator of this problem report. I do not have any problem compiling with gcc -g -O3 here on SuSE Linux with gcc 4.1.0. Will the person who reports problems compiling the amalgamation with gcc -g -O3 please add details, such as the operating system and the version of gcc being used?


2007-Jun-25 21:22:31 by anonymous:
AK

Using the exploded sources the compiler error was still present, in the file btree.c. Same code line as in the amalgamation, just different line numbers.

So the thinking that this is a problem of the amalgamation is a red herring. It is something deeper.

Getting all the revisions of btree.c between releases 3.3.17 and 3.40, and bisecting I find that the trouble starts for me with revision 1.382 of that file. Some functions where replaced by macros.

Creating a revers patch and applying it to revision 3.88 (in release 3.4.0) gets this revisions to compile as well.

Which means I now have a workaround, sa a variant of the revers patch can be applied to the amalgamation as well.


2007-Jun-25 21:26:36 by drh:
Reversing patch [4015] results in a performance hit. I am unwilling to fold in a performance hit for all platforms in order to work around a bug in MSVC++ 6.0. Can anybody suggest a better fix?


2007-Jun-25 21:35:55 by anonymous:
AK

My specific built of MSVC++ 6.0 is

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86


2007-Jun-25 21:57:04 by anonymous:
Install Service pack 6 of Visual Studio 6.0. The KB article that I'm pretty sure covers this bug is:

http://support.microsoft.com/kb/890892


2007-Jun-25 22:16:32 by anonymous:
After hunting down and installing VC6 ServicePack 6 the compiler reports:

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86

So, it has changed. Even so, the internal compiler error is still present.


2007-Jun-25 22:33:38 by anonymous:
Reboot of the machine is no help.


2007-Jun-25 22:38:18 by anonymous:
VC 6.0 - what compile flags are you using?


2007-Jun-25 23:11:59 by anonymous:
I thought that cygwin gcc-3.4.4 fails with -O3 -g, but it's just 1800 warning messages. No error, as it turns out.

$ gcc -I`pwd` -O3 -g sqlite3.c src/shell.c -o sqlite3

  /cygdrive/c/tmp/cc2D7Vgb.s: Assembler messages:
  /cygdrive/c/tmp/cc2D7Vgb.s:30139: Warning: .stabn: description field '103ff' too big, try a different debug format
  /cygdrive/c/tmp/cc2D7Vgb.s:30145: Warning: .stabn: description field '103fa' too big, try a different debug format
  /cygdrive/c/tmp/cc2D7Vgb.s:30170: Warning: .stabn: description field '103fa' too big, try a different debug format
  /cygdrive/c/tmp/cc2D7Vgb.s:30174: Warning: .stabn: description field '103fc' too big, try a different debug format
  /cygdrive/c/tmp/cc2D7Vgb.s:30184: Warning: .stabn: description field '103fd' too big, try a different debug format
  /cygdrive/c/tmp/cc2D7Vgb.s:30190: Warning: .stabn: description field '103fe' too big, try a different debug format
  /cygdrive/c/tmp/cc2D7Vgb.s:30194: Warning: .stabn: description field
  ...1800 more lines of the same...


2007-Jun-25 23:25:41 by anonymous:
AK Compile Flags: -O2 -W2 -MD.

According to a poster on the sqlite ML the btree.c can be compiled using -Ow is instead of O2.

Went through the options and O1, O2, Ox, Og all run into the error, the others don't.


2007-Jun-26 02:00:23 by anonymous:
FYI, MinGW gcc version 3.4.2 also produces the same 1800 warnings when you compile with -O3 -g. Still produces an object file okay, it's just annoying. No warning when only -O3 used.

  gcc -c -I. -I.. -g -O3 sqlite3.c

  c:\tmp/ccuuaaaa.s: Assembler messages:
c:\tmp/ccuuaaaa.s:31474: Warning: .stabn: description field '1001c' too big, try a different debug format
c:\tmp/ccuuaaaa.s:31480: Warning: .stabn: description field '10017' too big, try a different debug format
c:\tmp/ccuuaaaa.s:31505: Warning: .stabn: description field '10017' too big, try a different debug format
c:\tmp/ccuuaaaa.s:31509: Warning: .stabn: description field '10019' too big, try a different debug format
c:\tmp/ccuuaaaa.s:31519: Warning: .stabn: description field '1001a' too big, try a different debug format
c:\tmp/ccuuaaaa.s:31525: Warning: .stabn: description field '1001b' too big, try a different debug format
c:\tmp/ccuuaaaa.s:31529: Warning: .stabn: description field '1001e' too big, try a different debug format
c:\tmp/ccuuaaaa.s:31615: Warning: .stabs: description field '10017' too big, try a different debug format
...1800 lines of this...
 
2419 build active 2007 Jun anonymous   2007 Jun   1 2 'CP_UTF8' : undeclared identifier when trying to build the dll edit
I am using Microsoft Visual C++ Development System (an old version - 4.0) on Windows XP, and trying to build the dll and associated lib file. The compiler chokes on line 15146 (and following) with an undeclared identifier 'CP_UTF8'.

I'm a newbie, so please be gentle if this is a stupid question. Thanks!

 
2397 build active 2007 Jun anonymous   2007 Jun   2 4 make install failed on Cygwin edit
  On WinXP Cygwin platform, `make install' failed.
  There are at least two problems.  I could not resolve them.

    (1) Makefile defect.
    (2) Tcl on Cygwin is not compatible with other platforms.

  (1) can be fixed as follows:

     -install:        sqlite3$ libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install}
     +install:        sqlite3$(TEXE) libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install}

  (2) can not be fixed.  There are at least two Tcl problems.

     (a) On Cygwin, an empty string can not be set to the
         environment variable.  So tclinstaller.tcl line 9:

            set env(DESTDIR) ""

         this statement has no effect, and Tcl failed at line 10.

     (b) On Cygwin, [info sharedlibextension] returns ".dll".
         But `make all' generates static library only, libsqlite.dll
         does not exist.

     As a workaround, commenting out HAVE_TCL in Makefile did the trick.
 
2313 build active 2007 Apr anonymous   2007 Apr   3 3 readline.h is not properly detected edit
This is actually an old issue i also had with 2.8.15.

configure says "checking for readline.h... no", but it really needs to look for readline/readline.h (or both?)

this is easily fixed with "--with-readline-inc=-I/path/to/include" although the actual syntax for this is a bit unusual/unintuitive) but such "fix" should not be needed as i had these in my environment:

CPPFLAGS="-I/path/to/include" CFLAGS="-I/path/to/include"

(The library was found by configure, thanks to my LDFLAGS environment setting which is similar to the above.)

 
2308 build active 2007 Apr anonymous   2007 Apr   4 3 make sqlite3.c recreates sqlite3.c even though nothing changed edit
When building the amalgamized sqlite3.c source file, make will recreate the sqlite3.c source file each time it's run. When using this as part of a larger build process, this is annoying, since it will result in unnecessary compilations.

The fix is to rename the makefile target target_source to tsrc to make sure make will be able to properly detect the dependencies. Below is a patch for Makefile.in that fixes this:

  --- Makefile.in 19 Apr 2007 10:20:59 -0000      1.167
  +++ Makefile.in 19 Apr 2007 11:08:50 -0000
  @@ -296,14 +296,14 @@
   # files are automatically generated.  This target takes care of
   # all that automatic generation.
   #
  -target_source: $(SRC) parse.c opcodes.c keywordhash.h $(VDBEHDR)
  +tsrc:  $(SRC) parse.c opcodes.c keywordhash.h $(VDBEHDR)
          rm -rf tsrc
          mkdir -p tsrc
          cp $(SRC) $(VDBEHDR) tsrc
          rm tsrc/sqlite.h.in tsrc/parse.y
          cp parse.c opcodes.c keywordhash.h tsrc

  -sqlite3.c:     target_source $(TOP)/tool/mksqlite3c.tcl
  +sqlite3.c:     tsrc $(TOP)/tool/mksqlite3c.tcl
          tclsh $(TOP)/tool/mksqlite3c.tcl

   # Rules to build the LEMON compiler generator
2007-Apr-20 06:01:23 by anonymous:
Make does not deal well with directories as dependencies (because their last modification time doesn't mean what Make thinks it means). It would be much better to use a stamp file.
 
2302 build active 2007 Apr anonymous   2007 Apr anonymous 4 4 sqlite3 does not honor configure --disable-threads anymore edit
In a non-threaded TCL build, the TEA configuration option --disable-threads is no longer honored. In version 3.3.12 this used to work:

  (test) 49 % packa req sqlite3
couldn't load file "/usr/local/tcl/8.5a5-1/lib/sqlite3.3.15/libsqlite3.3.15.so": /usr/local/tcl/8.5a5-1/lib/sqlite3.3.15/libsqlite3.3.15.so: undefined symbol: pthread_create
(test) 50 % packa req -exact sqlite3 3.3.12
3.3.12

In new file tclsqlite3.c, line 11734, threading is hard-coded with

  #define THREADSAFE 1

A workaround for non-threaded builds is to set this manually to

  #define THREADSAFE 0
2007-Apr-15 17:03:07 by anonymous:
I encountered the same problem and I agree that this change is problematic and should be reverted.


2007-Apr-15 18:03:05 by drh:
Why is it such a problem that the library is threadsafe? Just because it is threadsafe does not mean you are required to use threads, or anything like that. Everything continues to work normally in a single threaded application. There is no measurable performance impact. Why is it so important to you that the threading mutexes not be enabled?


2007-Apr-15 19:34:11 by anonymous:
In a shared library setting it's not such a big deal, but in a purely static binary it can pull in a fair bit of unwanted thread library code. Also, some embedded UNIX-like targets lack a pthreads implementation.

The autoconf default can be threadsafe instead of non-threadsafe. It would be nice if it respected the autoconf flag as it did before.

 
2299 build active 2007 Apr anonymous   2007 Apr   1 1 Cannot compile sqlite-3.3.15 on linux rhel edit
My platform: Linux 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:28:02 EDT 2006 i686 i686 i386 GNU/Linux

My gcc version: gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)

My problem: I'm (ultimately) trying to get svntrac built and installed on this machine, but cannot compile the sqlite dependency.

If I follow the documented build procedure, namely: 1) Create sibling directory to source directory 2) Run ../sqlite-3.3.15/configure from build directory 3) Run make from build directory

I get build errors, mostly:

undefined reference to `__getreent'

2007-Apr-13 17:20:23 by anonymous:
gcc -g -O2 -o lemon ../sqlite-3.3.15/tool/lemon.c /tmp/ccOClNK1.o(.text+0x7c): In function `Action_new': ../sqlite-3.3.15/tool/lemon.c:344: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x153): In function `acttab_alloc': ../sqlite-3.3.15/tool/lemon.c:440: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x1ed): In function `acttab_action': ../sqlite-3.3.15/tool/lemon.c:455: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x223): In function `myassert': ../sqlite-3.3.15/tool/lemon.c:567: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x4e4): In function `acttab_insert': ../sqlite-3.3.15/tool/lemon.c:497: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x68f):../sqlite-3.3.15/tool/lemon.c:1362: more undefined references to `__getreent' follow /tmp/ccOClNK1.o(.text+0x280f): In function `tplt_xfer': ../sqlite-3.3.15/tool/lemon.c:2980: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x299a): In function `tplt_open': ../sqlite-3.3.15/tool/lemon.c:3026: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x2a54): In function `tplt_linedir': ../sqlite-3.3.15/tool/lemon.c:3042: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x2a5d):../sqlite-3.3.15/tool/lemon.c:3042: undefined reference to `__swbuf_r' /tmp/ccOClNK1.o(.text+0x2a8b):../sqlite-3.3.15/tool/lemon.c:3041: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x2a93):../sqlite-3.3.15/tool/lemon.c:3041: undefined reference to `__swbuf_r' /tmp/ccOClNK1.o(.text+0x2b68): In function `tplt_print': ../sqlite-3.3.15/tool/lemon.c:3061: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x2b71):../sqlite-3.3.15/tool/lemon.c:3061: undefined reference to `__swbuf_r' /tmp/ccOClNK1.o(.text+0x2ba6):../sqlite-3.3.15/tool/lemon.c:3065: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x2bae):../sqlite-3.3.15/tool/lemon.c:3065: undefined reference to `__swbuf_r' /tmp/ccOClNK1.o(.text+0x3196): In function `print_stack_union': ../sqlite-3.3.15/tool/lemon.c:3366: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x3319):../sqlite-3.3.15/tool/lemon.c:3387: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x3ae0): In function `translate_code': ../sqlite-3.3.15/tool/lemon.c:3207: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x447c): In function `ReportTable': ../sqlite-3.3.15/tool/lemon.c:3534: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x44a3):../sqlite-3.3.15/tool/lemon.c:3535: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x55d4):../sqlite-3.3.15/tool/lemon.c:3575: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x5800): In function `Symbol_new': ../sqlite-3.3.15/tool/lemon.c:4259: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x5ba3): In function `Parse': ../sqlite-3.3.15/tool/lemon.c:2500: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x5c2c):../sqlite-3.3.15/tool/lemon.c:2407: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x619b):../sqlite-3.3.15/tool/lemon.c:1997: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x61eb):../sqlite-3.3.15/tool/lemon.c:2201: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x628e):../sqlite-3.3.15/tool/lemon.c:2027: more undefined references to `__ctype_ptr' follow /tmp/ccOClNK1.o(.text+0x65b8): In function `Parse': ../sqlite-3.3.15/tool/lemon.c:2439: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x6603):../sqlite-3.3.15/tool/lemon.c:2415: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x6628):../sqlite-3.3.15/tool/lemon.c:2415: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x6baa):../sqlite-3.3.15/tool/lemon.c:2164: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x7bad): In function `main': ../sqlite-3.3.15/tool/lemon.c:1419: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x7c65):../sqlite-3.3.15/tool/lemon.c:1445: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x7ca0):../sqlite-3.3.15/tool/lemon.c:1425: undefined reference to `__getreent' /tmp/ccOClNK1.o(.text+0x7d4c):../sqlite-3.3.15/tool/lemon.c:1457: undefined reference to `__ctype_ptr' /tmp/ccOClNK1.o(.text+0x7e4b):../sqlite-3.3.15/tool/lemon.c:1514: undefined reference to `__getreent' collect2: ld returned 1 exit status make: *** [lemon] Error 1


2007-Apr-15 13:51:08 by anonymous:
I am not real familiar with Red Hat, but that looks to me like a case of your C library headers being out of sync with the library proper. There are several different ways that could happen; I would guess that the most probable is that you installed a version of GCC by hand, it copied some of the C library headers to a private directory (GCC tends to do this when you build it from source, unfortunately) and then you installed a new version of the C library from packages.


2007-Apr-15 13:54:33 by anonymous:
To be clearer, I think this is a local installation problem, not a bug in SQLite.
 
2301 build active 2007 Apr anonymous   2007 Apr   1 1 Latest cvs 3.3.15 fails lock4-1.3 test edit
  export CFLAGS=-O3
  ./configure --prefix=/usr/local
  make
  make test

  produces a single failure...

  lock4-1.2... Ok
  lock4-1.3...
  Error: database is locked
  lock4-999.1... Ok
2007-Apr-15 02:47:15 by anonymous:
which OS?


2007-Apr-15 11:31:46 by drh:
To amplify the previous comment, I observe that the test works fine for me on both Linux (SuSE 10.1) and Mac OS-X x86.
 
1802 build active 2006 May anonymous Unknown 2007 Mar   4 4 sqlite.pc needs -lrt on Solaris for fdatasync() edit
sqlite 3.3.x correctly checks for fdatasync() in -lrt during its configure, so it will make use of fdatasync() on Solaris.

The problem is that the sqlite.pc doesn't record that -lrt is needed when other packages wish to link with sqlite, so other packages will fail to link using the Libs: entry from sqlite.pc.

I think this could be fixed by just adding

  @TARGET_LIBS@

to the end of the Libs: line in sqlite.pc.in, since TARGET_LIBS should only contain any necessary additional libraries. The later call to AC_SUBST(TARGET_LIBS) will then handle getting any libraries listed in TARGET_LIBS substituted in.

I will submit a patch, if you wish, if you think that's the correct fix.

2007-Mar-30 05:37:44 by anonymous:
#1802, #2041 and #2270 are the same basic issue: librt should get linked into libsqlite3.so
 
2270 build active 2007 Mar anonymous   2007 Mar   3 4 Build on Solaris 8 does not include other libs in .so build edit
Straightforward build on solaris: # uname -a SunOS ganga 5.8 Generic_108528-13 sun4u sparc SUNW,Sun-Blade-1000

    # ../sqlite-3.3.13/configure --enable-gcc
    # ../../tcl/8.4.14/bin/tclsh8.4
    % load  ./.libs/libtclsqlite3.so.0.8.6
    couldn't load file "./.libs/libtclsqlite3.so.0.8.6": ld.so.1: ../../tcl/8.4.14/bin/tclsh8.4: fatal: relocation error: file ./.libs/libtclsqlite3.so.0.8.6: symbol fdatasync: referenced symbol not found

Just rerun gcc for the libtclsqlite with the same options as what libtool printed and add the fdatasync library that configure found (which was -lrt):

    % exec gcc all-like-libtool -lrt

    % load  ./.libs/libtclsqlite3.so.0.8.6
    %

I don't know why the build calls the library .0.8.6 - but that's not holding me up - I just rename it to 3.so.3.13

2007-Mar-30 05:36:59 by anonymous:
#1802, #2041 and #2270 are the same basic issue: librt should get linked into libsqlite3.so
 
2133 build active 2006 Dec anonymous   2007 Mar   4 4 meta ticket for outstanding autoconf issues edit
Please add any outstanding autoconf issues to this ticket.

Ticket #2082: UNIX: configure script doesn't enable loading of extensions

Ticket #1906: HAVE_GMTIME_R and HAVE_LOCALTIME_R

Ticket #1814: Autoconf support for MacOSX univeral binaries

Ticket #2124: -ldl link issue

Ticket #1966: Add a --disable-readline option to configure

Ticket #2053: fdatasync unresolved symbol on solaris 10

Check-in [3709] : Add a new compile-time macro USE_PREAD64

 
2222 build active 2007 Feb anonymous   2007 Feb   4 4 Type mismatch in fts2.c [5091] when compile as fastcall or stdcall edit
I noticed a problem when compiling with Borland TurboC using either the -pr or -ps switches and I have a fix. The error is in reference to termDataCmp being passed to qsort. By changing the declaration of termDataCmp from:

static int termDataCmp(const void *av, const void *bv){

to:

static int __cdecl termDataCmp(const void *av, const void *bv){

the problem was resolved. I'm not sure this is a bug, but I thought I should report it just in case someone else runs into it.

Kind Regards,

Tom Olson

 
2205 build active 2007 Jan anonymous   2007 Jan anonymous 1 1 Problem while using with tcl on ARM edit
I am using the sqlite-3.3.12. I have compiled this version for ARM and mandrake linux. On PC it is working fine. But on the Hand Held device with tcl, it produce error after creating the database file that "database disk image is malformed" while executing query for creating table. Another problem is that on executing sqlite3 executable on PC it shows version 3.3.11 But on executing sqlite3 executable on hand held it shows version 3.3.12 though these both executables were compiled from same source that is sqlite 3.3.12.
 
2199 build active 2007 Jan anonymous   2007 Jan   1 1 configure doesn't find libreadline if its in uncommon place edit
configure doesn't find libreadline if its in uncommon place. I suggest to change configure to be able to deal with something like this: --with-readline=/path
 
2110 build active 2006 Dec anonymous   2006 Dec   4 3 Non-optional linking with readline makes sqlite3 binary GPL edit
Currently, the sqlite3 binary is linked with libreadline support if it happens to be available at compile time. This may not always be desirable, because readline is licensed under GPL, and therefore the sqlite3 binary becomes GPL.

Solution: There ought to be a configure script parameter --disable-readline (or something similar) to allow creating non-GPL binaries.

2006-Dec-17 16:11:21 by anonymous:
Another solution would be to use editline instead, which is BSD licensed, from NetBSD project. Here is an autotool- and libtoolized port of it: <http://www.thrysoee.dk/editline/>.

It seems to even have a readline.h wrapper.

Check the links there for upstream sources and related projects.


2006-Dec-17 16:34:45 by anonymous:
This might work:

  env CFLAGS="-UHAVE_READLINE" ./configure


2006-Dec-17 16:55:55 by anonymous:
The -UHAVE_READLINE thing does not work because it is hardcoded into Makefile.in:

  # Compiler options needed for programs that use the readline() library.
  #
  READLINE_FLAGS = -DHAVE_READLINE=@TARGET_HAVE_READLINE@ @TARGET_READLINE_INC@

  # The library that programs using readline() must link against.
  #
  LIBREADLINE = @TARGET_READLINE_LIBS@

...

  sqlite3$(TEXE): $(TOP)/src/shell.c libsqlite3.la sqlite3.h
        $(LTLINK) $(READLINE_FLAGS) $(LIBPTHREAD) \
                -o $@ $(TOP)/src/shell.c libsqlite3.la \
                $(LIBREADLINE) $(TLIBS)

You have to manually edit the generated Makefile to remove READLINE_FLAGS and LIBREADLINE.

 
2104 build active 2006 Dec anonymous   2006 Dec   2 3 manual link on Mac OS X fails due to common symbol edit
Attempting a manual link on OS X with fts1:

gcc -O -fPIC -dynamiclib -o mylib sqlite-3.3.8/*.o

Results in the error:

ld: common symbols not allowed with MH_DYLIB output format with the -multi_module option fts1.o definition of common _sqlite3_api (size 16) /usr/bin/libtool: internal link edit command failed

This error is described:

http://gcc.gnu.org/ml/gcc/2005-06/msg00199.html

And a fix:

  --- /tmp/sqlite-3.3.8/src/sqlite3ext.h  2006-09-23 21:28:30.000000000 +1000
  +++ sqlite3ext.h       2006-10-09 19:20:09.000000000 +1000
  @@ -276,7 +276,7 @@
  #define sqlite3_overload_function      sqlite3_api->overload_function
  #endif /* SQLITE_CORE */

  -#define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api;
  +#define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api = 0;
  #define SQLITE_EXTENSION_INIT2(v)  sqlite3_api = v;

  #endif /* _SQLITE3EXT_H_ */
 
2090 build active 2006 Nov anonymous   2006 Nov   4 3 Test corrupt2.test fails: Solaris edit
While running 'make test', I had come across the following errors:

  ...
corrupt2-1.1... Ok
corrupt2-1.2...
Expected: [1 {file is encrypted or is not a database}]
     Got: [0 {table abc abc 2 {CREATE TABLE abc(a, b, c)}}]
corrupt2-1.3...
Expected: [1 {file is encrypted or is not a database}]
     Got: [0 {table abc abc 2 {CREATE TABLE abc(a, b, c)}}]
corrupt2-1.4...
Expected: [1 {database disk image is malformed}]
     Got: [0 {table abc abc 2 {CREATE TABLE abc(a, b, c)}}]
corrupt2-1.5...
Expected: [1 {database disk image is malformed}]
     Got: [0 {table abc abc 2 {CREATE TABLE abc(a, b, c)}}]
  ...

Turns out that SQLite was working fine, but TCL was not corrupting the database correctly (who would ever have thought I would want to?). Apparently the 'a' mode for opening a file in Solaris was resetting the position of a write to the end of a file before actually writing (this appears to be a point of contention on the TCL bug tracker). From the way the test is written, it appears that portions of the file were to be overwritten, instead of appending to the end of the file.

I will attach a patch to corrupt2.test after posting this message which, instead of attempting an overwrite, writes individual portions of the database file at a time, with requested strings inserted (technically, replacing) into the file at the requested offsets.

2006-Nov-29 23:37:05 by anonymous:
I should mention that this is SunOS 5.8, and TCL version 8.4.14.


2006-Dec-05 10:22:08 by anonymous:
I also get these errors (same tcl version but not SunOS). Have you tried a simpler patch by replacing the 'a' in the open calls by a 'r+'? This solved the problem for me.


2007-Jan-23 19:55:08 by anonymous:
That worked! Thank you so much!
 
1998 build active 2006 Sep anonymous   2006 Sep   2 3 prefix option to configure ignored in tclinstaller.tcl edit
schliep@karlin:~/tmp/sqlite-3.3.7> configure --prefix=/some/dir ...

schliep@karlin:~/tmp/sqlite-3.3.7> make install tclsh ./tclinstaller.tcl 3.3 can't create directory "/usr/lib/tcl8.4/sqlite3": permission denied

After commenting out all the stuff in ./tclinstaller.tcl things work

 
1961 build active 2006 Sep anonymous   2006 Sep   3 3 3.3.7 : wrong readline.h path in Makefile edit
We have readline.h installed in /usr/local/include/readline. In SQLite it is accessed with :

#include <readline/readline.h>

But unfortunatly in Makefile, READLINE flags contains :

-I /usr/local/include/readline

instead of

-I /usr/local/include

 
1938 build active 2006 Aug anonymous   2006 Aug   4 5 Cygwin compilation of v3 fails edit
make install leads to this:

[UTEKLIFEBOOK] ~/MyDocuments/dl/sqlite-3.3.7 > make install tclsh ./tclinstaller.tcl 3.3 can't read "env(DESTDIR)": no such variable

2006-Aug-25 13:24:19 by anonymous:
Looking at your log file you can see that sqlite3.exe was built successfully. Tcl is an optional component of SQLite. All you need is:

  ./configure && make sqlite3.exe

Or install TCL via Cygwin setup.exe.


2006-Sep-26 17:02:54 by anonymous:
Why not build with this?

  • ./configure --disable-tcl
  • make
  • make install

It works for me.

 
1762 build active 2006 Apr anonymous Unknown 2006 Apr   3 4 sqlite3_clear_bindings not exported in windows dll edit
While documented sqlite3_clear_bindings is not exported in the def file for the windows dll. Therefore it is unable to link.
 
1698 build active 2006 Mar anonymous   2006 Mar   1 1 sqlite_4y6ngs9FlYvAMGO 0kb 3/1/2006 1:16 PM edit
  sqlite_4y6ngs9FlYvAMGO     0kb             3/1/2006 1:16 PM

I like to stop this file,don't know where is coming from

2006-Mar-02 03:50:33 by anonymous:
You might want to check the free tools on http://www.sysinternals.com to monitor file events and process state.

ProcessExplorer will tell you what files (and much more) are open per process and you can even find the process that has some file open.

FileMon will monitor all file accesses, so you can check which program is creating those files, if it doesn't let them open for enough time to use ProcessExplorer.

Hope this helps.

 
1591 build active 2006 Jan anonymous   2006 Jan   3 2 Missing TEXE suffix in linking and install rules for sqlite3 edit
Suffix $(TEXE) is missing at some places in Makefile.in. It makes dependencies and rules inconsistant, when TEXE is not null (e.g. .exe when compiling with MingW for MSWin target). Those rules has to be fixed:

  • When linking slqite3 executable: use -o sqlite3$(TEXE) instead of -o sqlite3 in linker command line to use (especially since $(TEXE) suffix is present in rule)
  • When installing: use
    $(LTINSTALL) sqlite3$(TEXE) $(DESTDIR)$(exec_prefix)/bin
    instead of
    $(LTINSTALL) sqlite3 $(DESTDIR)$(exec_prefix)/bin

Similar fixes need to be applied to tclsqlite3 (missing in both rule and linker command line), testfixture (in linker cmdline), crashtest (in linker cmdline), lemon (in linker cmdline, with $(BEXE) suffix).

 
1576 build active 2005 Dec anonymous   2005 Dec   4 4 PREFIX is not honored (cannot install as non-root) edit
Hi, sqliters!

A minor install problem in 3.2.7:

the tree cannot be installed as non-root because it does not completely honor the configure prefix. e.g.:

./configure --prefix=$HOME ... make install tclsh ./tclinstaller.tcl 3.2 can't create directory "/usr/lib/tcl8.4/sqlite3": permission denied while executing "file mkdir $LIBDIR/sqlite3" (file "./tclinstaller.tcl" line 15)

However, /usr/lib should presumably be $HOME/lib when --prefix=$HOME.

Doing the install as root works but of course copies most of the files under $HOME but owned by root (which of course isn't the desired behaviour).

Take care,

This is a dupe of 1549.
 
1577 build active 2005 Dec anonymous Unknown 2005 Dec drh 3 3 32bit compile on 64bit system fails to build sqlite3 edit
On a linux amd64 x86_64 system (dual core cpu, smp kernel) Recieve a ./libtool --mode=link gcc -m32 -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I../sqlite-3.2.8/src -DNDEBUG -DTHREADSAFE=1 -DSQLITE_OMIT_CURSOR -DHAVE_READLINE=1 -I/usr/include/readline -lpthread \ -o sqlite3 ../sqlite-3.2.8/src/shell.c libsqlite3.la -lncurses gcc -m32 -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I../sqlite-3.2.8/src -DNDEBUG -DTHREADSAFE=1 -DSQLITE_OMIT_CURSOR -DHAVE_READLINE=1 -I/usr/include/readline -o .libs/sqlite3 ../sqlite-3.2.8/src/shell.c ./.libs/libsqlite3.so -lpthread -lncurses /tmp/ccQ7Hvlw.o: In function `one_input_line': shell.c:(.text+0x35b): undefined reference to `readline' shell.c:(.text+0x36f): undefined reference to `add_history' /tmp/ccQ7Hvlw.o: In function `main': shell.c:(.text+0x4a38): undefined reference to `read_history' shell.c:(.text+0x4a63): undefined reference to `stifle_history' shell.c:(.text+0x4a71): undefined reference to `write_history'

--- Note that the CFLAGS=-m32 and CPPFLAGS=-m32 and LDFLAGS=-L/usr/lib prior to running configure

It would be nice to have configure have options for 32bit vs 64 bit compiles on 64bit systems. The plain 64bit compile works fine.

2006-Sep-29 01:12:00 by anonymous:
I have the same error with sqlite-3.3.5-r1 but compiling as 64bit not 32.


2006-Sep-29 01:35:55 by anonymous:
go into the generated Makefile and remove -DHAVE_READLINE, or just comment out:

  # READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
 
1564 build active 2005 Dec anonymous   2005 Dec   4 4 Need GNU awk edit
The autotools (esp. automake) need to be sure to use GNU awk. I attempted to build sqlite on the following system:

SunOS apache 5.10 Generic_118822-23 sun4u sparc SUNW,Sun-Fire-880

On this the system `which awk` is not a GNU awk. The build proceeds as follows (up to the first error):


sed -e s/--VERS--/3.2.7/ ./src/sqlite.h.in | \

sed -e s/--VERSION-NUMBER--/3002007/ >sqlite3.h

gcc -g -O2 -o lemon ./tool/lemon.c

cp ./tool/lempar.c .

cp ./src/parse.y .

./lemon -DSQLITE_OMIT_CURSOR parse.y

cat parse.h ./src/vdbe.c | awk -f ./mkopcodeh.awk >opcodes.h

awk: syntax error near line 36


Apparently this syntax is not available in the standard awk on this system. Making `which awk` point to a GNU awk resolves the issue.

Possible solutions:

0. Replace all instances of awk with gawk in the scripts

1. Use Autotools to request/use gawk instead of awk (maybe a hints file?)

Brady

 
1549 build active 2005 Dec anonymous   2005 Dec   5 4 install fails for non-root user when TCL active edit
Hi, guys!

Steps to reproduce:

As a non-root user on a system without TCL components, configure the tree with a --prefix under, e.g., your $HOME:

./configure --prefix=$HOME

Then make/make install:

If TCL is enabled, the installation of the tcl parts fail because they try to install under /usr/..., disregarding the $prefix:

Error:

tclsh ./tclinstaller.tcl 3.2 can't create directory "/usr/lib/tcl8.4/sqlite3": permission denied while executing "file mkdir $LIBDIR/sqlite3" (file "./tclinstaller.tcl" line 15)

i tried building with the --without-tcl option, but then configure fails:

checking for Tcl configuration... configure: error: no directory doesn't contain tclConfig.sh

 
1543 build active 2005 Nov anonymous   2005 Nov   2 1 File encrypted or corrupted while using french characters edit
Hi,

if we use the french characters in the database file path as i mentioned the characters above is throwing the error while creating a new database file or connecting with old one using realbasic as front end.

2005-Nov-29 18:33:20 by drh:
Why do you think this is a problem with SQLite and not with realbasic?


2005-Nov-29 20:16:12 by anonymous:
If this happens using the REALbasic wrapper for SQLite, then the bug is definitely in the wrapper and not in SQLite. The bug has been fixed and should appear in the next version of REALbasic.


2005-Nov-30 06:32:25 by anonymous:
Dear drh;

  In real basic folderitem is working fine with this french characters. i am getting this error in the line as "if db.connect then" it throws false and the error message shown as "File is encrypted or not a database file". Please confirm this problem is not with SqLite while using the following characters ÀàÁáÂâÃãäÄÅåÈèÉéÊêËëÌìÍíÎîÏïÒòÓóÔôÕÖö.

with Thanks, Vinoth. Vino_it@hotmail.com

 
1498 build active 2005 Oct anonymous   2005 Oct   4 3 SQLite Cygwin support edit
I'm attaching a patch to Makefile.in to support building sqlite3 on Cygwin, as well as the results of make test from 3.2.7.

Binary packages are available at: ftp://sunsite.dk/projects/cygwinports/release/sqlite3/

 
1427 build active 2005 Sep anonymous   2005 Sep   4 3 tclsqlite.lo target should define USE_TCL_STUBS edit
The Tcl_InitStubs routine is not called in Sqlite3_Init because USE_TCL_STUBS is never defined in the generated Makefile.

It appears that the tclsqlite.lo target is the one used in the TCL extension shared library and therefore this target should have -DUSE_TCL_STUBS defined. Below is a diff showing the changes I made to make this work properly in my environment.

There also appears to be some type of abortive effort to do this with the tclsqlite-stubs.lo target, but this target is never referenced in the Makefile and erroneously defines TCL_USE_STUBS rather than USE_TCL_STUBS.

  cvs diff Makefile.in
  Index: Makefile.in
  ===================================================================
  RCS file: /sqlite/sqlite/Makefile.in,v
  retrieving revision 1.134
  diff -r1.134 Makefile.in
  369c369
  <       $(LTCOMPILE) -c $(TOP)/src/tclsqlite.c
  ---
  >       $(LTCOMPILE) -DUSE_TCL_STUBS -c $(TOP)/src/tclsqlite.c
2005-Sep-19 21:05:50 by anonymous:
I was just going to report this Makefile bug and I see this reported a few days ago. I think that the correct fix is two-fold: use the correct -DUSE_TCL_STUBS=1 when building tclsqlite-stubs.lo, and then actually use tclsqlite-stubs.lo when building libtclsqlite3.la.

While the stub-version of tclsqlite.lo may work when linked into sqlite3_analyzer and the test drivers, it is not the proper way to do things.

The patch for Makefile.in that I used is appended.

Dave Bodenstab dave@bodenstab.org

  --- Makefile.in       2005/09/17 23:28:06     32.6
  +++ Makefile.in       2005/09/19 20:18:51
  @@ -235,8 +235,8 @@
        $(LTLINK) -o libsqlite3.la $(LIBOBJ) $(LIBPTHREAD) \
                ${ALLOWRELEASE} -rpath $(libdir) -version-info "8:6:8"

  -libtclsqlite3.la:    tclsqlite.lo libsqlite3.la
  -     $(LTLINK) -o libtclsqlite3.la tclsqlite.lo \
  +libtclsqlite3.la:    tclsqlite-stubs.lo libsqlite3.la
  +     $(LTLINK) -o libtclsqlite3.la tclsqlite-stubs.lo \
                $(LIBOBJ) @TCL_STUB_LIB_SPEC@ $(LIBPTHREAD) \
                   -rpath $(libdir)/sqlite \
                -version-info "8:6:8"
  @@ -412,7 +412,7 @@
        $(LTCOMPILE) -DTCLSH=1 -o $@ -c $(TOP)/src/tclsqlite.c

   tclsqlite-stubs.lo:  $(TOP)/src/tclsqlite.c $(HDR)
  -     $(LTCOMPILE) -DTCL_USE_STUBS=1 -o $@ -c $(TOP)/src/tclsqlite.c
  +     $(LTCOMPILE) -DUSE_TCL_STUBS=1 -o $@ -c $(TOP)/src/tclsqlite.c

   tclsqlite3:  tclsqlite-shell.lo libsqlite3.la
        $(LTLINK) -o tclsqlite3 tclsqlite-shell.lo \


2005-Sep-19 21:09:14 by drh:
I think that if you want to build a shared library for use with TCL, you ought to use the TEA-compatible tarball that is found on the website, not the standard source delivery. The Makefile in the TEA-compatible tarball is much, much more likely to work correctly.
 
676 build active 2004 Mar anonymous   2005 Aug   1 1 Problem with Makefile edit
On Solaris 8-patchlevel 21, after running configure with no problems, running make halts with the following message: make:make: fatal error in reader: Makefile, line 79: Unexpected end of line seen

Line 79 is part of an "ifeq" phrase. I do not know much about Makefile syntax or understand how configure could create a defective one. Thanks for your help.

Use gmake instead of make. I know nothing much about make or gmake, but gmake works and make does not. whoo hoo.
 
1318 build active 2005 Jul anonymous   2005 Jul   2 4 Build broken under Windows/MinGW edit
The current release doesn't build with GCC for Windows by www.mingw.org. The compiler error "No rule to make target 'sqlite3', needed by 'install'" can be worked around by replacing "$(TEXE)" by "@TARGET_EXEEXT@" in Makefile.in. To build a DLL, "make dll" has to be invoked manually. However, an import library (.dll.a) and a libtool library file (.la) are not generated for the DLL.

Everything was fine in 3.0.8

 
1293 build active 2005 Jun anonymous   2005 Jun   1 1 No file .LIB in sqlitedll-3_2_2.zip for links in Windows. edit
No file .LIB in sqlitedll-3_2_2.zip for links in Windows.
2005-Jun-18 22:48:55 by anonymous:
the idea is to generate a .lib from the .def, read your compiler docs on how. (vc++ comes with lib.exe)
 
1187 build active 2005 Mar anonymous Parser 2005 Mar drh 3 3 OMIT_TRIGGER OMIT_VIEW do not compile properly edit
SQLITE_OMIT_TRIGGER and SQLITE_OMIT_VIEW are needed by lemon to process parse.y
They are not passed from CFLAGS to Makefile.in OPTS.
 
1138 build active 2005 Feb anonymous   2005 Feb   4 3 make install fails on MinGW/MSYS trying to install into tclsh edit
I'm building SQLite on WinXP using MinGW/MSYS system. The makefile generated with:

  ../sqlite/configure --with-tcl=/c/Tcl/lib

works correctly to build the default target as well as the test suite, windows DLL, and import library using:

  make
  make test
  make implib

However, I get an error whe I try to install the new version using:

  make install

The error I get is:

  $ make install
  tclsh ../sqlite/tclinstaller.tcl 3.1
  can't read "env(DESTDIR)": no such variable
      while executing
  "set LIBDIR $env(DESTDIR)[lindex $auto_path 0]"
      (file "../sqlite/tclinstaller.tcl" line 10)
  make: *** [tcl_install] Error 1

This is because the makefile is trying to install the tcl library into tcl (I think) before it installs the shell and libraries into the system. In my case this fails, so the install step never completes. I don't really care if the tcl install works or not since I'm not using it.

It seems to me that the Makefile should be changed to ignore any error during this step by adding a '-' character to the beginning of the tclsh... line as shown below:

  tcl_install:	libtclsqlite3.la
	-tclsh $(TOP)/tclinstaller.tcl $(VERSION)

Or the install target should be split into 2 subtargets so that the normal installation subtarget is completed first as shown below:

  install:	sqlite_install ${HAVE_TCL:1=tcl_install}

  sqlite_install:	sqlite3 libsqlite3.la sqlite3.h
	$(INSTALL) -d $(DESTDIR)$(libdir)
	$(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir)
	$(INSTALL) -d $(DESTDIR)$(exec_prefix)/bin
	$(LTINSTALL) sqlite3 $(DESTDIR)$(exec_prefix)/bin
	$(INSTALL) -d $(DESTDIR)$(prefix)/include
	$(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(prefix)/include
	$(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig; 
	$(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(libdir)/pkgconfig; 

  tcl_install:	libtclsqlite3.la
	tclsh $(TOP)/tclinstaller.tcl $(VERSION)

This way if an error occurrs when doing the tcl_install it will not stop the normal sqlite installation.

 
1123 build active 2005 Feb anonymous TclLib 2005 Feb   3 4 cannot find tcl.h edit
Apparently in the new version the tcl.h (and maybe other files of tcl) is needed by default. So if you configure without any options, it will need tcl.h but the configuration script will not check for it. So the compilation will fail.

The workaround is one of two:

1. Install the tcl-devel (so you have the headers like tcl.h installed)

2. run configure with --disable-tclI could not find any documentation related to it.

This is new problem - I had no problems compile the former release just by running configure without options.

2005-Feb-21 11:19:55 by drh:
The change to compile TCL by default appeared in 3.1.0.


2005-Jul-28 02:50:05 by anonymous:
    I found another simple method to resolve the problem,if you needn't tcl interface.Just remove the tclsqlite.c from the project,then all is ok.
 
1070 build active 2005 Jan anonymous CodeGen 2005 Jan   1 1 error by compiling windows vcc / vc# <sqlite.h> not found edit
Cannot build sqlite.lib. reason sqlite.h not found
 
1034 build active 2004 Dec anonymous TclLib 2004 Dec   2 4 configure generated Makefile doesn't use TCL on MinGW on Windows edit
When using MinGW/MSYS on Windows XP, the Makefile generated by the configure script fails while building the testfixture. The makefile is generated using

  ../sqlite/configure --with-tcl=/c/mingw/lib

The configure script correctly locates the tclConfig.sh file in this directory and loads it.

When I try to run the test suite, the build fails while linking the testfixture as shown below:

  $ make test
  ./libtool --mode=link gcc -g -O2 -DOS_WIN=1 -I. -I../sqlite/src -DNDEBUG -I/mingw/include -DSQLITE_OMIT_CURSOR -DTCLSH=1 -DSQLITE_TEST=1\
                -DTHREADSAFE=0 -DTEMP_STORE=2\
                -o testfixture ../sqlite/src/btree.c ../sqlite/src/date.c ../sqlite/src/func.c ../sqlite/src/os_mac.c ../sqlite/src/os_unix.c ../sqlite/src/os_win.c ../sqlite/src/pager.c ../sqlite/src/pragma.c ../sqlite/src/printf.c ../sqlite/src/test1.c ../sqlite/src/test2.c ../sqlite/src/test3.c ../sqlite/src/test4.c ../sqlite/src/test5.c ../sqlite/src/utf.c ../sqlite/src/util.c ../sqlite/src/vdbe.c ../sqlite/src/md5.c ../sqlite/src/tclsqlite.c \
        libtclsqlite3.la 
  gcc -g -O2 -DOS_WIN=1 -I. -I../sqlite/src -DNDEBUG -I/mingw/include -DSQLITE_OMIT_CURSOR -DTCLSH=1 -DSQLITE_TEST=1 -DTHREADSAFE=0 -DTEMP_STORE=2 -o testfixture ../sqlite/src/btree.c ../sqlite/src/date.c ../sqlite/src/func.c ../sqlite/src/os_mac.c ../sqlite/src/os_unix.c ../sqlite/src/os_win.c ../sqlite/src/pager.c ../sqlite/src/pragma.c ../sqlite/src/printf.c ../sqlite/src/test1.c ../sqlite/src/test2.c ../sqlite/src/test3.c ../sqlite/src/test4.c ../sqlite/src/test5.c ../sqlite/src/utf.c ../sqlite/src/util.c ../sqlite/src/vdbe.c ../sqlite/src/md5.c ../sqlite/src/tclsqlite.c  ./.libs/libtclsqlite3.a -L/mingw/lib -ltclstub84
  C:/DOCUME~1/DennisC/LOCALS~1/Temp/cc2taaaa.o(.text+0x511): In function `sqlite3TestErrCode':
  c:/SQLite/SQLiteV3/build2/../sqlite/src/test1.c:77: undefined reference to `_imp__Tcl_ResetResult'

It looks like the code is being linked against the tclstub84 library which doesn't contain the needed code.

To work around this problem, I needed to modify the Makefile that configure generated. I modified the line:

  LIBTCL =  

to use the correct library like this:

  LIBTCL = -L/mingw/lib -ltcl84 

Now the testfixture builds correctly and I can run the test suite.

Someone more familiar with the automake tools will need to correct this problem on a more permanent basis.

2004-Dec-10 02:15:25 by drh:
You can help us to troubleshoot this by attaching the following files to the ticket:

  • tclConfig.sh
  • the complete output of configure and make


2004-Dec-10 16:08:05 by anonymous:
I have attached the requested files. Note, these files were generated from the latest CVS source after checkin 2162.

The tclConfig.sh file is exactly as is was installed by the MinGW tcltk binary package in the last stable version of MinGW/MSYS (I just checked and they have released a newer stable version of MinGW/MSYS since I installed mine. It seems the only package which is newer than my installation is the gcc compiler. I have the current version of the tcl/tk package.)

 
878 build active 2004 Aug anonymous Unknown 2004 Aug   5 5 Wrong shared library file-names edit
Shared libraries created by SQLite 3.0.5 build don't have '.so' extension. Therefore installation can be broken. Another bug is_ -lpthread is not linked to the library/executable when --enable-thread-safe is specified.

  /usr/bin/install -c       .libs/libsqlite3-3.0.5.0.8.6/usr/lib/libsqlite3-3.0.5.0.8.6
  (cd /usr/lib && rm -f libsqlite3-3.0.5.0 && ln -s   libsqlite3-3.0.5.0.8.6 libsqlite3-3.0.5.0)
  (cd /usr/lib && rm -f libsqlite3 && ln -s libsqlite3-3.0.5.0.8.6   libsqlite3)
  /usr/bin/install -c .libs/libsqlite3.lai /usr/lib/libsqlite3.la
 
865 build active 2004 Aug anonymous Unknown 2004 Aug   1 1 Building problems with v3.0.3 and v3.0.4 on Fedora Core 2 edit
SQLite is configured with: CFLAGS="-DNDEBUG=1" CXXFLAGS="-DNDEBUG=1" ./configure --enable-threadsafe --prefix=/usr

------------------8<------------------ .
.
.

./.libs/libsqlite3.so: undefined reference to `pthread_create'
./.libs/libsqlite3.so: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make: *** [sqlite3] Error 1
fel: D&#229;lig slutstatus fr&#229;n /var/tmp/rpm-tmp.33961 (%build)


RPM-byggfel:
D&#229;lig slutstatus fr&#229;n /var/tmp/rpm-tmp.33961 (%build)

------------------8<------------------

Some additional information:

[root@gnu SOURCES]# gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --disable-libunwind-exceptions --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) [root@gnu SOURCES]# uname -a Linux gnu.nu6.org 2.6.8-1.521 #1 Mon Aug 16 09:01:18 EDT 2004 i686 i686 i386 GNU/Linux

2004-Aug-21 17:36:56 by dougcurrie:
You can use the environment variable

  config_TARGET_LIBS

to add any libraries you need to the link. See configure.ac.

-- e

 
864 build active 2004 Aug anonymous Unknown 2004 Aug   2 2 3.0.4 uses readling edit
on netbsd, I was compiling sqlite. It tried to use the readline library even though it did not exist. I edited the makefile to not use readline and it works, but config should have done this. Also, the best fix on the *BSDs is to also detect and use libedit instead of libreadline.
2004-Sep-16 08:47:00 by anonymous:
I don't know how to add the logic to the config system, but on BSD systems with libedit, changing the makefile to read

LIBREADLINE = -ledit -ltermcap

allows it to compile and use libedit.

On some older versions of NetBSD it was also needed to ln the header files to where sqlite it looking for them. Newer versions worked with just the Makefile change above.

 
815 build active 2004 Jul anonymous   2004 Jul   2 1 SQLite3.dll exports edit
The SQLite3.dll does not export all of its documented api. I.e. SQLite_gettable/freetable is not exported. This is a similar error as before and can be easily fixed (I think) since I can download a correct dll from www.squeakycode.net (one of the other sqlite users). Since the exports are mentioned in the .def file I think there might be an error in the build of the windows dll. (without tcl bindings). I like to deploy my (freeware) delphi components for version 3, but they require the squeakycode dll. This is a nice temporarely solution but I need a more structural one before I can deploy.

Best regards, Albert Drent aducom software

 
734 build active 2004 May anonymous TclLib 2004 May   4 4 libtclsqlite.xxx not built by default make all target edit
Not a big deal but the Quickstart documentation assumes that the libtclsqllite.so (or dylib (macosx) in my case) is made & installed but the default make all target doesn't make it. You have to explicitly specify that to be made. Although, the 'Building from Source' documentation page does say that make all makes just sqlite and the basic libsqlite.{a, so, whatever} in the comment.

Just a bit confusing.

 
633 build active 2004 Feb anonymous   2004 Feb   1 1 new build system does not run correctly under MinGW/MSYS edit
The new build system added with checkin 1274 does not run correctly with MinGW/MSYS environment on Windows XP PC.

The sqlite library and shell exe are built correctly with the default make target, but the install and implib targets now fail.

I have attached a log of the build on my system showing the error messages produced.

 
609 build active 2004 Feb anonymous Unknown 2004 Feb   1 4 Makefile errors edit
bastion# make
"Makefile", line 73: Missing dependency operator
"Makefile", line 75: Need an operator
"Makefile", line 90: Missing dependency operator
"Makefile", line 92: Need an operator
Fatal errors encountered -- cannot continue

I followed the instructions as per the sqlite/README file -- I cannot build any of it. configure script complains of nothing. I'm available for testing if you need me to.

2004-Mar-14 11:19:09 by anonymous:
Also tried with 2.8.13, same exact error.


2004-Mar-15 00:34:54 by anonymous:
using OpenBSD's 'make' program fails. you MUST install gmake and run gmake to compile and gmake to install it.

The people here at sqlite may want to find how to get bsd's make to work.

Thanks, issue closed.


2004-Apr-13 18:24:04 by anonymous:
I've tried everything suggested in this forum and can't get SQlite to compile properly.

Any chance I can get someone to post the exact steps they used to get it to work.

Or provide a binary.

 
451 build active 2003 Sep anonymous   2004 Feb   1 1 Makefile fails on FreeBSD edit
Unless I am mistaken, I have previously built SQLite on FreeBSD. However, I now try to build version 2.8.4 and 2.8.6 on FreeBSD 5.0 and discover that the <B style="color:black;background-color:#ffff66">Makefile</B> apparently depends on the GNU make rather than a standard Unix make:

  "<B style="color:black;background-color:#ffff66">Makefile</B>", <B style="color:black;background-color:#99ff99">line</B> 72: Missing dependency operator
  "<B style="color:black;background-color:#ffff66">Makefile</B>", <B style="color:black;background-color:#99ff99">line </B><B style="color:black;background-color:#ff9999">74</B>: Need an operator
  "<B style="color:black;background-color:#ffff66">Makefile</B>", <B style="color:black;background-color:#99ff99">line</B> 89: Missing dependency operator
  "<B style="color:black;background-color:#ffff66">Makefile</B>", <B style="color:black;background-color:#99ff99">line</B> 91: Need an operator
  make: fatal errors encountered -- cannot continue

Isn't it possible to stick with a Unix make that way SQLite is more portable.

use gmake
 
445 build active 2003 Sep anonymous Unknown 2003 Dec anonymous 3 1 Compilation problem on MinGW edit
dejan@KLEENE ~/src/sqlite$ make; head config.log; gcc -v ./libtool gcc -g -O2 -DOS_UNIX=1 -DOS_WIN=0 -I. -I./src -c ./src/os.c rm -f .libs/os.lo gcc -g -O2 -DOS_UNIX=1 -DOS_WIN=0 -I. -I./src -c ./src/os.c -DDLL_EXPORT -DPIC -o .libs/os.lo src/os.c: In function `sqliteOsReadLock': src/os.c:1142: storage size of `lock' isn't known src/os.c:1144: `F_RDLCK' undeclared (first use in this function) src/os.c:1144: (Each undeclared identifier is reported only once src/os.c:1144: for each function it appears in.) src/os.c:1147: `F_SETLK' undeclared (first use in this function) src/os.c: In function `sqliteOsWriteLock': src/os.c:1246: storage size of `lock' isn't known src/os.c:1248: `F_WRLCK' undeclared (first use in this function) src/os.c:1251: `F_SETLK' undeclared (first use in this function) src/os.c: In function `sqliteOsUnlock': src/os.c:1358: storage size of `lock' isn't known src/os.c:1360: `F_UNLCK' undeclared (first use in this function) src/os.c:1363: `F_SETLK' undeclared (first use in this function) make: *** [os.lo] Error 1 This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was generated by GNU Autoconf 2.57. Invocation command line was

  $ ./configure --enable-utf8 --prefix=/usr/local

## --------- ## ## Platform. ## Reading specs from C:/GNU/MinGW/bin/../lib/gcc-lib/mingw32/3.2.3/specs Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c++,f77,objc --disable-win32-registry --disable-shared --enable-sjlj-exceptions Thread model: win32 gcc version 3.2.3 (mingw special 20030504-1)

See Ticket #433.

e

 
312 build active 2003 May anonymous Shell 2003 Dec   1 3 libreadline.so.0.0 causes unidentified token error edit
I am running OpenBSD 3.2. SQLite configures and builds just fine, but when I try to "sqlite test.db" I get "ld.so: unidentified symbol '_tgetent' in sqlite:/usr/lib/libreadline.so.0.0", and SQLite refuses to run. I grepped the source and couldn't find tgetent anywhere, then I tried man tgetent and found that it was part of the curses library. I'm not sure why this is happening, and thus I cannot give you details on how to reproduce the bug.

thanks, will

 
496 build active 2003 Nov anonymous   2003 Nov   1 1 SQLite Ignores Autoconf Options edit
When I entered the following command to configure SQLite before installation:

./configure \ --prefix=/home/adam02/bx3-in/xplc/miscres \ --bindir=/home/adam02/bx3-in/basics/bin \ --libexecdir=/home/adam02/bx3-in/bin-tools \ --libdir=/home/adam02/bx3-in/basics/library-directory \ --mandir=/home/adam02/bx3-docs/man

it seems as though all the options that I entered, with the exception of "--prefix", were ignored.

This is a serious problem that completely prevents any system of customized installation from working.

 
398 build active 2003 Jul anonymous Unknown 2003 Nov   3 3 configure.ac is wrong for Windows Mingw/Msys edit
On Windows Mingw/Msys, the 2.8.4 configure script produces a Makefile with

  TCC = gcc -g -O2 -DOS_UNIX=1 -DOS_WIN=0 -I. -I${TOP}/src

which I've traced to configure.ac

  if test "$TARGET_EXEEXT" = ".exe"; then
    OS_UNIX=0
    OS_WIN=1
    tclsubdir=win
  else
    OS_UNIX=1
    OS_WIN=0
    tclsubdir=unix
  fi
  TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=$OS_UNIX -DOS_WIN=$OS_WIN"

Now, os.h, when OS_UNIX is defined, and regardless of its value, ignores OS_WIN and redefines it to 0. So, there are two problems here: -DOS_UNIX=$OS_UNIX -DOS_WIN=$OS_WIN should not both appear in TARGET_CFLAGS, and for Windows -DOS_WIN=1.

The line that configure should produce is

  TCC = gcc -g -O2 -DOS_WIN=1 -I. -I${TOP}/src

Note that this would obviate the need for the workaround described on HowToCompile in step 6 of section "Win32 recompile with mingw32/msys."

 
339 build active 2003 Jun anonymous Shell 2003 Nov   2 3 readline headers not found (because of readline/ prefix) edit
Hi,

I have GNU readline in /usr/local/include/readline :

$ ls -l /usr/local/include/readline/{linebreak} total 32
-rw-r--r-- 1 root bin 1846 Mar 6 1996 chardefs.h
-rw-r--r-- 1 root bin 3200 Mar 6 1996 keymaps.h
-rw-r--r-- 1 root bin 9952 Mar 6 1996 readline.h

The shell program references the readline header-files as

# include <readline/readline.h>
# include <readline/history.h>

I believe that this is not the proper way to do it. readline.h and history.h may not be in a readline/ subdirectory. The configure script sets TARGET_READLINE_INC properly, namely to the directory where readline.h can be found (including on my machine, namely to /usr/local/include/readline). But since shell.c has the prefix readline/, it is not found.

Regards,

Ulrik Petersen, Denmark

Here is a patch against 2.8.6:

$ diff sqlite/src/shell.c sqlite-2.8.6-up-2/src/shell.c
40,41c40,41
< # include <readline/readline.h>
< # include <readline/history.h>
---
> # include <readline.h>
> # include <history.h>

Best regards,

Ulrik Petersen

 
456 build active 2003 Sep anonymous   2003 Nov anonymous 1 1 compilation problem under winnt 4 using Lcc-win32 edit
I was trying to compile a small C-programm which I copied from the document "quickstart.html". The linker says:"sqlite.dll:unknown file type". I took the binaries from your site without recompiling. I'm using the Lcc-Win32 compiler under Windows NT 4 (with Service Pack 5). Is anything wrong with the file sqlite.dll?
 
303 build active 2003 May anonymous Unknown 2003 Nov a.rottmann 4 4 Makefile issues edit
I pulled down an intermediate to test the fix for #284 and had a bit more trouble with the makefile than previously. Here are the versions from CVS/Entries:

    /config.guess/1.2/Mon Mar 24 09:40:35 2003//
    /config.sub/1.2/Mon Mar 24 09:40:35 2003//
    /configure/1.16/Tue Apr 22 08:04:49 2003//
    /configure.ac/1.5/Tue Apr 22 08:04:50 2003//

And I'll attache the diff between the generated Makefile and the one I ended up with, and the configure params I used.

I'm okay if you want to write off the TCL include & lib problems as due to my weird setup, and I know the double slash has been reported before, but the readline issue is probably fair game.

Lastly, it's useful to note that the generated Makefile is no longer compatible with SunWorkshop make - it really requires GNU make now.

2004-Feb-26 14:50:53 by anonymous:
There are several config_ variables that can be passed to the configure script; for example, the Debian package uses (from a Makefile):

./configure config_TARGET_TCL_INC="-I/usr/include/tcl8.4" config_BUILD_CFLAGS="$(CFLAGS) -DTHREADSAFE=1"

Do a grep for config_ on configure.ac to see what other variables are available for tweaking.


2004-Mar-09 12:46:40 by a.rottmann:
I should really switch the stuff to use automake, plus using the conventional --with-foo-includes flags instead of config_ environment variables.
 
473 build active 2003 Oct anonymous   2003 Nov drh 3 3 makefile's target_source fails to create opcodes.c edit
Configure on MinGW, run "make target_source", opcodes.c is not created. Don't know if this happens on other platforms.

Changing this line in Makefile.in...

opcodes.h: $(TOP)/src/vdbe.h

to...

opcodes.h: $(TOP)/src/vdbe.h opcodes.c

solves the problem, but I don't know if this is the desired fix.

 
483 build active 2003 Oct anonymous Shell 2003 Nov   2 3 history.h from readline library not checked for edit
Hi,

I have a system with a really old readline lying around in /usr/local/include/readline. This readline has no history.h, but src/shell.c looks for <readline/history.h>.

What I am suggesting is that the configure.ac script be extended so that it checks for history.h as well as readline.h. A patch appears below.

Best regards,

Ulrik Petersen

diff sqlite/configure.ac sqlite-2.8.6-up-2/configure.ac
494a495,497
> if test "$found" = "yes"; then
> AC_CHECK_HEADER(history.h, [found=yes], [found=no])
> fi
500,501c503,507
< TARGET_READLINE_INC="-I$dir/include"
< break
---
> AC_CHECK_FILE($dir/include/history.h, found=yes, found=no)
> if test "$found" = "yes"; then
> TARGET_READLINE_INC="-I$dir/include"
> break
> fi
505,506c511,515
< TARGET_READLINE_INC="-I$dir/include/readline"
< break
---
> AC_CHECK_FILE($dir/include/readline/history.h, found=yes, found=no)
> if test "$found" = "yes"; then
> TARGET_READLINE_INC="-I$dir/include/readline"
> break
> fi

 
484 build active 2003 Oct anonymous   2003 Nov   5 4 make clean cleans doc/ completely edit
Hi,

when doing a "make clean", the Makefile.in does this:

          rm -rf doc/

Wouldn't it be better to do

          if test -d doc/; then cd doc/; rm -f $(DOC); cd ..; fi

?

Best regards,

Ulrik Petersen, Denmark

 
495 build active 2003 Nov anonymous   2003 Nov   1 1 Makefile syntax errors edit
When I run make I get this:


  "Makefile", line 72: Missing dependency operator
  "Makefile", line 74: Need an operator
  "Makefile", line 89: Missing dependency operator
  "Makefile", line 91: Need an operator
  make: fatal errors encountered -- cannot continue


What operating system? What steps did you follow to get to this point?
 
2917 code active 2008 Feb anonymous   2008 Feb   4 4 Tcl interface - busy callback confusion script/procedure edit
In the Tcl interface the "busy" method doesn't work if a script is supplied instead of a procedure:

  %  package req sqlite3
  3.5.1
  % sqlite3 db hl7journal.db
  %  db busy {puts busy; expr 0}
  %  db eval {select count(*) from incoming}
  busy
  database is locked

Here the callback script is only invoked once, even though it returns 0. If we put this code in a procedure it works as desired/expected:

  % proc b args {puts busy; after 1000; expr 0}
  % db  busy b
  % db eval {select count(*) from incoming}
  busy
  busy
  busy
  ^C
2008-Feb-01 12:31:45 by anonymous:
After researching this a little it appears this happens because the busy callback is invoked with an extra argument. The extra argument leads to an error but that error is only visible through errorInfo, not the result.

I humbly suggest the following changes:

* mention the extra argument in the documentation of the Tcl interface

* forward the error from the busy callback to Tcl (replacing the "database is locked")

* enhance errorInfo to make the invokation of the busy callback apparent.

Currently, I'm getting this errorInfo:

  % db busy {puts hi; after 1000; return 0}
  %  db eval "select count(*) from incoming"
  hi
  database is locked
  %  set errorInfo
  bad option "0": must be -code, -errorcode, or -errorinfo
      while executing
  "return 0 0"
      invoked from within
  "db eval "select count(*) from incoming""

It would be nicer to get something like

  bad option "0": must be -code, -errorcode, or -errorinfo
      while executing
  "return 0 0"
      from busy callback
  "puts hi; after 1000; return 0 0"
      invoked from within
  "db eval "select count(*) from incoming""
 
2916 code active 2008 Feb anonymous   2008 Feb   1 1 sqlitedll-3_5_5.zip is older 3.5.4 binary edit
sqlitedll-3_5_5.zip in download section is same with old 3.5.4 binary.
2008-Feb-01 12:13:04 by anonymous:
Yes , I can confirm it
 
2914 code active 2008 Jan anonymous   2008 Jan   3 3 ATTACH returns SQLITE_ERROR when it means SQLITE_BUSY edit
I'm seeing the same behavior as in #2096, with SQLite 3.5.4. ATTACH DATABASE fails with SQLITE_ERROR rather than SQLITE_BUSY when the database to be attached, or the main database of the connection being attached to, is EXCLUSIVE-locked by another database connection. For added confusion, sqlite3_errmsg() says "database is locked" when the ATTACH is done via sqlite3_exec(), but "SQL logic error or missing database" when the ATTACH is done via sqlite3_step().

As a result of this bug, it is difficult to distinguish between fatal and transient ATTACH errors, particularly when sqlite3_step() is used.

I am attaching a test program that demonstrates the problem.

 
2905 code active 2008 Jan anonymous   2008 Jan pweilbacher 2 2 mutex_os2.c - incorrect mutex implementation edit
The OS/2 version of sqlite3_mutex_alloc() is badly broken.

It creates named mutexes which, by design, are global rather than process-specific as intended. This might be minimally acceptable except that the function reuses the same name every time it attempts to create a SQLITE_MUTEX_FAST or SQLITE_MUTEX_RECURSIVE.

The result is that every call returns the exact same semaphore to every thread in every process using sqlite3. Once this mutex is owned by one process, other processes calling sqlite3_mutex_enter() will be blocked. Much the same is true for the static mutexes. Every process ends up using the exact same SQLITE_MUTEX_STATIC_MASTER, SQLITE_MUTEX_STATIC_MEM, etc.

There's another flaw that is fairly minor compared with the above: in an attempt to avoid concurrency when creating the static mutexes, this function uses an API call that is thoroughly deprecated.

The attached patch remedies all of these issues. Since the logic that protects the creation of the static mutexes may not be self-evident, here's an explanation:

The existence (or non-existence) of a given named mutex is itself a semaphore. If the isInit flag is false, the code attempts to create a mutex whose name is unique to that process. If the attempt is successful, there are two possibilities: (1) either the current thread is the first to reach this code & may proceed; (2) or while the current thread was making its preparations, another thread created the mutex, did the init, then closed the mutex. Testing isInit immediately after creating the mutex determines which possibility is valid.

If mutex creation fails due to a duplicate name, then another thread is currently performing the init. In this case, the current thread simply has to wait a while until the other thread is done & isInit becomes true.

Submitted by Rich Walsh (richATe-vertise.com)

 
2902 code active 2008 Jan anonymous   2008 Jan drh 3 3 Add watch support to SQLite edit
SQLite currently provides only TRIGGERs and the update_hook() as a way for applications to stay informed about changes to the database. But both of these alternatives do not provide enough details about the actual changes to the underlying database file(s).

We've prepared a patch for SQLite 3.5.x to allow applications to install a watch_hook into the database, that will be invoked everytime the database is changed with exact details about the change that was performed.

2008-Jan-22 16:06:59 by anonymous:
Great idea and nice job. This functionality is very useful.


2008-Jan-31 18:27:16 by anonymous:
Any chance to get this committed for the next release (i.e. 3.5.6)?


2008-Jan-31 19:38:35 by drh:
Unlikely, for two reasons:

  1. I am unconvinced that this patch solves a problem that needs solving. It is vitally important to a project like SQLite that we work to avoid clutter and cruft. That means that any change must have a compelling rational or else it is rejected.

  2. The patches are against version 3.5.4. There were many changes to the core for 3.5.5 and the patches no longer work.


2008-Jan-31 20:58:55 by anonymous:
We can (and will) port the changes to 3.5.5, so the second point will be done. First the first point, I'm not sure how many projects will actually need this functionality, but I guess there are quite a lot of projects that would benefit, and for the others, there's zero overhead due to this patch.


2008-Jan-31 21:21:30 by drh:
There is a lot of overhead for me because if I accept this patch, that means I have to maintain it forever. Most of the work is in maintenance, not coming up with the original patch.
 
2903 code active 2008 Jan anonymous   2008 Jan   2 2 tclinstaller.tcl fails on path and permissions issue edit
When compiling using custom PREFIX, pointing to private directory, tclinstaller.tcl fails, because it tries to remove contents from /usr/share/tcl8.4/sqlite3.

./configure --prefix=/my/private/sqlite/sqlite-3.5.4
... # success
make
... # success
make install
...
tclsh ./tclinstaller.tcl 3.5
error deleting "/usr/share/tcl8.4/sqlite3": not owner
    while executing
"file delete -force $LIBDIR/sqlite3"
    (file "./tclinstaller.tcl" line 17)
make: *** [tcl_install] Error 1
I've found two work-arounds:

  1. If you run make install as root.
  2. If you use ./configure --disable-tcl
2008-Jan-28 17:47:39 by anonymous:
I also ran into this problem.

make install as root will end up copying files into the system's library directory and is almost certainly not what you want if you specified your own --prefix.

 
2911 code active 2008 Jan anonymous   2008 Jan   2 2 Adding parentheses to a FROM clause edit
Hi,

Parentheses in a FROM statement seem to mess with the ability to use table aliases in the "what" part. Here is an example:

Start SQLite:

    $ sqlite3 employee.db
    SQLite version 3.5.4
    Enter ".help" for instructions

create a couple of tables and populate them with test data:

    sqlite> create table person (id integer, name text, employerid integer);
    sqlite> create table employer (id integer, name text);
    sqlite> insert into person (id, name, employerid) values (1, "Dave", 1);
    sqlite> insert into employer (id, name) values (1, "ACME");

Run a simple query with no parentheses in the FROM statement:

    sqlite> select b.id from person as a inner join employer as b on a.employerid = b.id;
    1

Everything works as expected. Now, repeat that query with parentheses:

    sqlite> select b.id from (person as a inner join employer as b on a.employerid = b.id);
    SQL error: no such column: b.id

There you have it.

This may be related to ticket #1822, although that ticket deals with aliases and subqueries. This problem seems to be more fundamental.

Many thanks,

-- Dave

 
2613 code active 2007 Sep anonymous   2008 Jan drh 3 3 replace doesn't work with blobs containing \x0, otherwise it does edit
The replace expression function does not work with blobs in case of contained zero terminator character; but it does if there is not this special character included. I expected the function to work similar like substr with blob-safety in case of type is blob only. X'nnnn' is of type blob, so following example should have returned a blob type result X'0102FF0405' in the 2nd and 3rd line. How to get to this result?
SQLite version 3.4.2
Enter ".help" for instructions
sqlite> select hex(replace(X'0102030405',X'03',X'FF'));
0102FF0405
sqlite> select hex(replace(X'0102000405',X'00',X'FF'));

sqlite> select typeof(replace(X'0102000405',X'00',X'FF'));
null
sqlite>
2007-Sep-03 04:21:12 by anonymous:
Replace was designed to work with strings. However, working with blobs would be an interesting extension.


2007-Oct-18 06:13:10 by anonymous:
I've seen a similar situation where I can't reliably store stings with nulls in the middle of them as TEXT.

I can convert them to blobs, in which case length(...) works correctly. I if convert them back to strings, length(...) treats them as C-strings.

Is this the expected behavior? I notice the entire column is preserved even when it's has TEXT affinity, I can append data to it as a string, cast back to a blob and see everything (am I explaining this poorly?)

This all seems a bit counter intuitive in some ways. Perhaps strings shouldn't treat NULL characters as special?


2007-Oct-27 16:45:41 by anonymous:
Treatment of length operator is - as fas as I know - dependent on type:
As text it is the length number of UTF-8 characters and as blob it is the number of bytes. As long as all the UTF-8 characters out of the lower half ASCII char-set (127 of them), this is identical beside the fact of different 0-terminator interpretation.
To append is something different than using the replace operator. My suggestion would be to make the replace operator work with bytes (not UTF-8) in case of all 3 parameters are of type blob.
Another suggestion: the UTF aware functions are Private declared and not usable from within a loadable extension dll/so. This should be changed.


2008-Jan-28 19:36:39 by anonymous:
Will there come a solution for this with the next release? It is really not fair to handle a blob only like text which cannot contain a zero terminator. With this unique useful function a zero-containing blob could be formed into a normal text string without loosing the part behind the zero terminator. It would be really a step forward without too much effort.
 
2907 code active 2008 Jan anonymous   2008 Jan   1 1 Issues of sqlite3 with Windows Mobile 5/6 edit
hi. we are currently using sqlite3 for our mobile application. it has been running without a hitch on pocket pc 2003 and previous versions. come windows mobile 5 and 6 we have been getting errors, although not consistent yet. one example is 'EXCEPTION_DATATYPE_MISALIGNMENT'. another is 'SELECT STATMENTS TO THE LEFT AND RIGHT OF UNION ARE NOT EQUAL'. i was wondering if you have any known compatibility issues of your product with this version of windows mobile.

thanks in advance.

2008-Jan-28 13:26:26 by anonymous:
EXCEPTION_DATATYPE_MISALIGNMENT is thrown when you try to use and Odd pointer address. I wrote a custom allocator for WinCE/ARM platform, and I have to take care about memory alignment (I used to align at 2 bytes, and at that time it solved the problem)
 
2908 code active 2008 Jan anonymous   2008 Jan   3 3 Add support to examine whether statements modify the database edit
Currently there is no way to check whether a compiled statement will modify the database when being executed. Of course, there is the work-around of misusing the authorizer callback for this purpose, but this is kinda error prone and causes quite some overhead for such a simple purpose.
 
2898 code active 2008 Jan anonymous   2008 Jan   1 1 Latest CVS for 3.5.4 fails to build test1.c edit
gcc -pipe -O3 -g -Wall -DSQLITE_DISABLE_DIRSYNC=1 -I. -I../src -DNDEBUG -I/usr/include -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 -DSQLITE_NO_SYNC=1 -DTEMP_STORE=1 -o .libs/testfixture ../src/attach.c ../src/btree.c ../src/build.c ../src/date.c ../src/expr.c ../src/func.c ../src/insert.c ../src/malloc.c ../src/os.c ../src/os_os2.c ../src/os_unix.c ../src/os_win.c ../src/pager.c ../src/pragma.c ../src/prepare.c ../src/printf.c ../src/select.c ../src/test1.c ../src/test2.c ../src/test3.c ../src/test4.c ../src/test5.c ../src/test6.c ../src/test7.c ../src/test8.c ../src/test9.c ../src/test_autoext.c ../src/test_async.c ../src/test_btree.c ../src/test_config.c ../src/test_hexio.c ../src/test_malloc.c ../src/test_md5.c ../src/test_onefile.c ../src/test_schema.c ../src/test_server.c ../src/test_tclvar.c ../src/test_thread.c ../src/tokenize.c ../src/utf.c ../src/util.c ../src/vdbe.c ../src/vdbeapi.c ../src/vdbeaux.c ../src/vdbemem.c ../src/where.c parse.c ../src/tclsqlite.c ./.libs/libsqlite3.so -L/usr/lib64 -ltcl8.4 -ldl -lpthread -lieee -lm -Wl,--rpath -Wl,/common/pkgs/sqlite-3.5.4.3/lib ../src/build.c: In function 'sqlite3RefillIndex': ../src/build.c:2275: warning: cast to pointer from integer of different size ../src/func.c: In function 'trimFunc': ../src/func.c:919: warning: cast from pointer to integer of different size ../src/func.c: In function 'sqlite3RegisterBuiltinFunctions': ../src/func.c:1464: warning: cast to pointer from integer of different size ../src/func.c:1483: warning: cast to pointer from integer of different size ../src/insert.c: In function 'sqlite3GenerateConstraintChecks': ../src/insert.c:1200: warning: cast to pointer from integer of different size ../src/insert.c:1034: warning: 'j2' may be used uninitialized in this function ../src/insert.c: In function 'sqlite3Insert': ../src/insert.c:373: warning: 'regFromSelect' may be used uninitialized in this function ../src/test1.c: In function 'test_collate_func': ../src/test1.c:2085: warning: cast from pointer to integer of different size ../src/test1.c: In function 'test_collate_needed_cb': ../src/test1.c:2209: warning: cast to pointer from integer of different size ../src/test1.c: In function 'alignmentCollFunc': ../src/test1.c:2258: warning: cast from pointer to integer of different size ../src/test1.c:2259: warning: cast from pointer to integer of different size ../src/test8.c: In function 'echoBestIndex': ../src/test8.c:722: warning: 'nRow' may be used uninitialized in this function ../src/vdbe.c: In function 'sqlite3VdbeExec': ../src/vdbe.c:502: warning: 'pOut' may be used uninitialized in this function ../src/vdbe.c:501: warning: 'pIn3' may be used uninitialized in this function ../src/vdbe.c:501: warning: 'pIn2' may be used uninitialized in this function ../src/vdbe.c:501: warning: 'pIn1' may be used uninitialized in this function ../src/vdbeaux.c: In function 'sqlite3VdbeChangeP4': ../src/vdbeaux.c:529: warning: cast from pointer to integer of different size ../src/vdbemem.c: In function 'sqlite3ValueText': ../src/vdbemem.c:911: warning: cast from pointer to integer of different size /tmp/ccsuOeus.o: In function `reset_prng_state': /build/work/sqlite-3.5.4.3/bld/../src/test1.c:4280: undefined reference to `sqlite3ResetPrngState' /tmp/ccsuOeus.o: In function `restore_prng_state': /build/work/sqlite-3.5.4.3/bld/../src/test1.c:4267: undefined reference to `sqlite3RestorePrngState' /tmp/ccsuOeus.o: In function `save_prng_state': /build/work/sqlite-3.5.4.3/bld/../src/test1.c:4254: undefined reference to `sqlite3SavePrngState' collect2: ld returned 1 exit status make: *** [testfixture] Error 1
2008-Jan-17 23:54:58 by anonymous:
Problem appears to be here in libsqlite.3.so.0.8.6 as shown by:

   nm -A .libs/libsqlite3.so.0.8.6 | grep sqlite3ResetPrngState

which shows no entry point. And:

   nm -A .libs/random.o  | grep sqlite3ResetPrngState

which also shows no entry point.


2008-Jan-17 23:56:55 by anonymous:
Ah... It appears -DSQLITE_TEST should be passed when building test1.c and left off when building prior to install.


2008-Jan-21 20:16:00 by anonymous:
In the makefile the right flag appears to be set, it's just not making it through to the compile for some reason.


2008-Jan-21 20:16:24 by anonymous:
Still fails the same based on today's cvs update.


2008-Jan-23 03:14:49 by anonymous:
This bug fixed as of latest cvs pull
 
2901 code active 2008 Jan anonymous   2008 Jan   3 3 ROLLBACK and COMMIT statements should not expire edit
Currently, whenever a statement changes the schema of the database, all prepared statements will be expired, no matter whether they actually need to be prepared again or not. This is especially problematic for ROLLBACK statements in a multi-statement transaction. Currently there is no way to guaranty that a multi-statement transaction can at least be rolled back in case of an error, because one has to (re)prepare the ROLLBACK statement to roll back the transaction, which can fail because of OOM (in a multi-threaded application).
 
2899 code active 2008 Jan anonymous   2008 Jan   4 4 sqlite3_reset() after exec() takes > 100 ms to complete edit
I'm not entirely sure whether this is a bug or not... I'm not familiar enough with SQLite to know if this is way too unconventional, but I noticed today that running exec() in conjunction with a prepared statement really kills the performance of sqlite3_reset(), if it's called after exec():

// init sqlite3_prepare_v2( db,
"SELECT [file_id],[file_name],[file_mime],[file_type],"
"[file_size],[date_created],[date_accessed],[data] "
"FROM file_cache WHERE [file_id] = ? LIMIT 1;",
-1, &sqQueryStatement, &unused );

// query function -- called repeatedly (usually second or third run starts to cause big delays)

/* begin function */

sqlite3_reset( sqQueryStatement );
sqlite3_bind_int( sqQuerystatement, 1, 292 );
sqlite3_step( sqQueryStatement );

bla = sqlite3_column_int( sqQueryStatement, 0 );

/* ... */

char *erm;

sqlite3_exec( db, "UPDATE file_cache SET [date_accessed] = DATETIME( 'NOW', 'LOCALTIME' ) WHERE [file_id] = 292", NULL, NULL, &erm );

/* ... */

sqlite3_clear_bindings( sqQueryStatement );

/* end function */

If sqlite3_exec() is commented out, consecutive calls to the function run in less than a millisecond. With sqlite3_exec() included, sqlite3_reset() call in this function takes > 100 ms to complete.

Tested: Windows Vista Ultimate 32 bit, Visual Studio 2005 8.0.50727.876

 
2885 code active 2008 Jan anonymous   2008 Jan   4 4 (minor) fulltest failures edit
Minor noise in fulltest on a 64-bit machine (everything seems to work otherwise though):

  4 errors out of 61527 tests
  Failures on these tests: exclusive-ioerr-2.280.4
  exclusive-ioerr-2.281.4 exclusive-ioerr-2.282.4 incrvacuum-ioerr-1.31.4
  All memory allocations freed - no leaks

details:

  exclusive-ioerr-2.280.3... Ok
  exclusive-ioerr-2.280.4...
  Expected: [8ee59fe0b5bc391ecc5002539379b063]
       Got: [35e56178ad878809d4789c5797265a23]
  exclusive-ioerr-2.281.1... Ok
  exclusive-ioerr-2.281.2... Ok
  exclusive-ioerr-2.281.3... Ok
  exclusive-ioerr-2.281.4...
  Expected: [95762fb35ef83ddba65f681325346ef2]
       Got: [1c20c63d975ad85b395a5e7701d785c2]
  exclusive-ioerr-2.282.1... Ok
  exclusive-ioerr-2.282.2... Ok
  exclusive-ioerr-2.282.3... Ok
  exclusive-ioerr-2.282.4...
  Expected: [2c5ea7db8424f38d17cdff41056da0e0]
       Got: [c02841c40d3e6e0579922745bd9c0260]
  exclusive-ioerr-2.283.1... Ok

[...]

    incrvacuum-ioerr-1.31.4...
    Expected: [ea55042a449c3b4759730a882e8271a0]
	 Got: [9951814984696d0811cacbe862060af8]
    incrvacuum-ioerr-1.32.1... Ok
2008-Jan-19 00:56:30 by anonymous:
A test from 20 minutes ago passes cleanly. This could be closed.
 
2878 code active 2008 Jan anonymous   2008 Jan   1 1 Memory leaks with latest CVS [4693] edit
This SQL leaks memory with CVS [4693] :

  CREATE TABLE x(id integer primary key, a TEXT NULL);
  INSERT INTO x (a) VALUES ('first');
  CREATE TABLE tempx(id integer primary key, a TEXT NULL);
  INSERT INTO tempx (a) VALUES ('t-first');
  CREATE VIEW tv1 AS SELECT x.id, tx.id FROM x JOIN tempx tx ON tx.id=x.id;

One leak is caused by "CREATE TABLE tempx", a second one by "CREATE VIEW tv1".

The above SQL is a digest of select7.test, select7-2.1.

2008-Jan-14 17:51:11 by anonymous:
I have tested again with CVS [4711] and it does no longer show the original leaks.

I therefore consider this issue fixed and I will now close this ticket.


2008-Jan-14 23:56:34 by anonymous:
Doing a fulltest with -MSQLITE_MEMDEUG I see reports of memory leaks. I assume these are of little or minimal interest at present because of the amount of code flux.

If you do want details, please let me know (I'll recheck this ticket tomorrow I guess).


2008-Jan-15 08:23:56 by anonymous:
Thanks for the follow-up. I am not running the original test-suite but have have ported a great number of them to Delphi.

If you could just let me know which tests caused the leaks you fixed in [4712] I'd be more than glad the port these test as well and let you know my findings.


2008-Jan-19 00:56:17 by anonymous:
A test from 20 minutes ago passes cleanly. This could be closed.
 
2897 code active 2008 Jan anonymous   2008 Jan   1 1 String or BLOB exceed size limit edit
This error was shown after attemp to read script from SQLite 3.5.4 shell in order to recreate old DB. Details:

1. Database was created with SQLite 3.3.4. Around 20 standard fieds and one BLOB.

2. The only one existed table was dumped with shell of SQLite 3.5.4. SQL script seems to be coorrect.

3. Opened SQLite 3.5.4 and read script in new DB. The error "String or BLOB exceed size limit" are sown for several lines. Many records missing.

4. Attempted to dump table with shell of version 3.3.6 (have no more 3.3.4 shell) and read into new DB with 3.5.4 shell The same errors are shown.

The same steps was attempted with 3.3.6. shell only. All seems to be correct.

2008-Jan-17 20:23:25 by drh:
This size limit on BLOBs in SQLite version 3.5.4 is 1GB. How big is your blob, exactly?


2008-Jan-17 22:22:24 by anonymous:
BLOB in each record is no more than few MB. Mostly it is few KB (e-client and news application). Whole DB have around 200MB.


2008-Jan-18 02:28:11 by drh:
This issue is probably resolved by check-in [4636] , then.


2008-Jan-18 14:28:13 by anonymous:
If directive SQLITE_MAX_SQL_LENGTH is not defined it is set to 1,000,000 (10^6) in amalgamation code of 3.5.4.
 
2893 code active 2008 Jan anonymous   2008 Jan   1 1 incorrect integer range tests edit
recently a function that performs integer range tests was added to the cvs (check-in [4706] ), but if i am correct there is a problem in the return value of the function in the file vdbemem.c:

  static i64 doubleToInt64(double r){
    ...
    if( r<(double)minInt ){
      return minInt;
    }else if( r>(double)maxInt ){
      return minInt;     <-- is this correct, shouldn't it be maxInt?
    }else{
      return (i64)r;
    }
  }
2008-Jan-16 17:33:56 by drh:
See the remarks on ticket #2280. The code duplicates the behavior of the FPU on x86.


2008-Jan-16 18:21:28 by anonymous:
did you mean ticket #2880? didn't read that ticket before, but since there was no comment regarding that behavior in the function it seemed (to my eyes) that it was a mistake.

maybe adding a small comment in there would clarify this issue


2008-Jan-16 18:39:42 by anonymous:
Just because the double to int overflow behavior happens to be that way with GCC on x86, is it desirable?
 
2886 code active 2008 Jan anonymous   2008 Jan   3 3 testfixture: -fPIC needed when building extension(s) edit
(this fix/change is probably needed in older versions too, i meant to send this in earlier)

-fPIC is needed when building extensions (some platforms don't need this or don't care --- x86-64 does)

  diff --git a/test/loadext.test b/test/loadext.test
  index 81e152f..2a7fa2e 100644
  --- a/test/loadext.test
  +++ b/test/loadext.test
  @@ -64,7 +64,7 @@ if {![file exists $testextension]} {
     set srcdir [file dir $testdir]/src
     set testextsrc $srcdir/test_loadext.c
     if {[catch {
  -    exec gcc -Wall -I$srcdir -I. -g -shared $testextsrc -o $testextension
  +    exec gcc -Wall -fPIC -I$srcdir -I. -g -shared $testextsrc -o $testextension
     } msg]} {
       puts "Skipping loadext tests: Test extension not built..."
       puts $msg
 
2882 code active 2008 Jan anonymous   2008 Jan   3 3 fulltest failure: ./testfixture: wrong # args: should be "cksum db" edit
  exclusive-ioerr-2.2.1... Ok

  ./testfixture: wrong # args: should be "cksum db"
      while executing
  "ifcapable vacuum {
    do_ioerr_test ioerr-2 -cksum true -sqlprep {
      BEGIN;
      CREATE TABLE t1(a, b, c);
      INSERT INTO t1 VALUES(1, randstr(50,..."
      (file "../test/ioerr.test" line 58)
      invoked from within
  "source $testdir/ioerr.test"
      (file "../test/exclusive3.test" line 50)
      invoked from within
  "source $testfile"
      ("foreach" body line 5)
      invoked from within
  "foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
      set tail [file tail $testfile]
      if {[lsearch -exact $EXCLUDE $tail]>=0} continue
  ..."
      ("for" body line 7)
      invoked from within
  "for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
    if {$Counter%2} {
      set ::SETUP_SQL {PRAGMA default_synchronous=off;}
    } else ..."
      (file "..//test/all.test" line 85)
2008-Jan-14 23:25:49 by anonymous:
The latest code seems to have fixed this. I would close this but I don't see how to do that.
 
2879 code active 2008 Jan anonymous   2008 Jan anonymous 4 3 VACUUM enters temporary sequence numbers in sqlite_sequence edit
I have two TEMPORARY tables added to a database, that both contain an INTEGER PRIMARY KEY AUTOINCREMENT field. After issuing a VACUUM command, the maximum value of these fields is added to the sqlite_sequence table. And stay there after the connection closes.
 
2875 code active 2008 Jan anonymous   2008 Jan   3 2 LIKE does not work with lowercase swedish characters edit
Swedish letters &aring;,&auml;,&ouml; is not supported by the LIKE statement. When trying to perform a query like

SELECT * FROM table WHERE name LIKE "&aring;%"

we will not get a match for names starting on &Aring; (which is uppercase for &aring;).

To recreate:


SQLite version 3.5.4 Enter ".help" for instructions sqlite> CREATE TABLE TestingTable(Name varchar(20)); sqlite> INSERT INTO TestingTable values ('Sweden'); sqlite> INSERT INTO TestingTable values ('sweden'); sqlite> INSERT INTO TestingTable values ('&Aring;land'); sqlite> INSERT INTO TestingTable values ('&aring;land'); sqlite> SELECT * FROM TestingTable; Sweden sweden &Aring;land &aring;land sqlite> SELECT * FROM TestingTable WHERE Name LIKE "swe%"; Sweden sweden sqlite> SELECT * FROM TestingTable WHERE Name LIKE &aring;la%"; &aring;land
 
2874 code active 2008 Jan anonymous   2008 Jan   1 1 THREADSAFE #define HAVE_LOCALTIME_R, HAVE_GMTIME_R in os_unix.c edit
The precompiled shared sqlite3 library for Linux on sqlite.org which appears to be built with pthread support is using localtime and gmtime which are not threadsafe.

For THREADSAFE builds could either configure be changed to detect the functions gmtime_r and localtime_r or change os_unix.c to explicitly #define HAVE_LOCALTIME_R and HAVE_GMTIME_R?

 
2873 code active 2008 Jan anonymous   2008 Jan   1 1 HAVE_USLEEP, HAVE_FDATASYNC=1 detected but not used by configure; make edit
I noticed that a couple of open source projects were not picking up usleep() for recent sqlite builds and used the coarser grained sleep() instead. Around 11 months ago something changed in sqlite's build process.

It seems that both -DHAVE_USLEEP=1, -DHAVE_FDATASYNC=1 and -DOS_UNIX=1 are detected correctly by configure but not used by the generated Makefile. As result, UNIX builds of sqlite3 via ./configure do not use usleep() and fdatasync() and do not define OS_UNIX.

I don't know whether the lack of fdatasync() versus the default fsync() affects anyone.

Please apply the following patch which corrects the problem with "./configure && make". Thank you.

Index: configure
===================================================================
RCS file: /sqlite/sqlite/configure,v
retrieving revision 1.45
diff -u -3 -p -r1.45 configure
--- configure	27 Nov 2007 14:50:07 -0000	1.45
+++ configure	5 Jan 2008 07:41:00 -0000
@@ -18520,9 +18520,9 @@ if test "$TARGET_EXEEXT" = ".exe"; then
     OS_UNIX=0
     OS_WIN=0
     OS_OS2=1
-    TARGET_CFLAGS="$TARGET_CFLAGS -DOS_OS2=1"
+    CFLAGS="$CFLAGS -DOS_OS2=1"
     if test "$ac_compiler_gnu" == "yes" ; then
-      TARGET_CFLAGS="$TARGET_CFLAGS -Zomf -Zexe -Zmap"
+      CFLAGS="$CFLAGS -Zomf -Zexe -Zmap"
       BUILD_CFLAGS="$BUILD_CFLAGS -Zomf -Zexe"
     fi
   else
@@ -18530,14 +18530,14 @@ if test "$TARGET_EXEEXT" = ".exe"; then
     OS_WIN=1
     OS_OS2=0
     tclsubdir=win
-    TARGET_CFLAGS="$TARGET_CFLAGS -DOS_WIN=1"
+    CFLAGS="$CFLAGS -DOS_WIN=1"
   fi
 else
   OS_UNIX=1
   OS_WIN=0
   OS_OS2=0
   tclsubdir=unix
-  TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=1"
+  CFLAGS="$CFLAGS -DOS_UNIX=1"
 fi


@@ -19392,7 +19392,7 @@ fi
 echo "$as_me:$LINENO: result: $ac_cv_func_usleep" >&5
 echo "${ECHO_T}$ac_cv_func_usleep" >&6
 if test $ac_cv_func_usleep = yes; then
-  TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_USLEEP=1"
+  CFLAGS="$CFLAGS -DHAVE_USLEEP=1"
 fi


@@ -19491,7 +19491,7 @@ fi
 echo "$as_me:$LINENO: result: $ac_cv_func_fdatasync" >&5
 echo "${ECHO_T}$ac_cv_func_fdatasync" >&6
 if test $ac_cv_func_fdatasync = yes; then
-  TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_FDATASYNC=1"
+  CFLAGS="$CFLAGS -DHAVE_FDATASYNC=1"
 fi


Index: configure.ac
===================================================================
RCS file: /sqlite/sqlite/configure.ac,v
retrieving revision 1.31
diff -u -3 -p -r1.31 configure.ac
--- configure.ac	27 Nov 2007 14:50:07 -0000	1.31
+++ configure.ac	5 Jan 2008 07:41:00 -0000
@@ -310,9 +310,9 @@ if test "$TARGET_EXEEXT" = ".exe"; then
     OS_UNIX=0
     OS_WIN=0
     OS_OS2=1
-    TARGET_CFLAGS="$TARGET_CFLAGS -DOS_OS2=1"
+    CFLAGS="$CFLAGS -DOS_OS2=1"
     if test "$ac_compiler_gnu" == "yes" ; then
-      TARGET_CFLAGS="$TARGET_CFLAGS -Zomf -Zexe -Zmap"
+      CFLAGS="$CFLAGS -Zomf -Zexe -Zmap"
       BUILD_CFLAGS="$BUILD_CFLAGS -Zomf -Zexe"
     fi
   else
@@ -320,14 +320,14 @@ if test "$TARGET_EXEEXT" = ".exe"; then
     OS_WIN=1
     OS_OS2=0
     tclsubdir=win
-    TARGET_CFLAGS="$TARGET_CFLAGS -DOS_WIN=1"
+    CFLAGS="$CFLAGS -DOS_WIN=1"
   fi
 else
   OS_UNIX=1
   OS_WIN=0
   OS_OS2=0
   tclsubdir=unix
-  TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=1"
+  CFLAGS="$CFLAGS -DOS_UNIX=1"
 fi

 AC_SUBST(BUILD_EXEEXT)
@@ -565,13 +565,13 @@ AC_SUBST(TARGET_DEBUG)
 #########
 # Figure out whether or not we have a "usleep()" function.
 #
-AC_CHECK_FUNC(usleep, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_USLEEP=1"])
+AC_CHECK_FUNC(usleep, [CFLAGS="$CFLAGS -DHAVE_USLEEP=1"])

 #--------------------------------------------------------------------
 # Redefine fdatasync as fsync on systems that lack fdatasync
 #--------------------------------------------------------------------

-AC_CHECK_FUNC(fdatasync, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_FDATASYNC=1"])
+AC_CHECK_FUNC(fdatasync, [CFLAGS="$CFLAGS -DHAVE_FDATASYNC=1"])

 #########
 # Generate the output files.
2008-Jan-05 08:24:29 by anonymous:
It appears that http://www.sqlite.org/sqlite3-3.5.4.bin.gz and http://www.sqlite.org/sqlite-3.5.4.so.gz use sleep and fsync even though usleep and fdatasync are available on Linux.

On the Linux man page, it claims that fdatasync is more efficient than fsync:

"Unfortunately, fsync() will always initiate two write operations: one for the newly written data and another one in order to update the modification time stored in the inode. If the modification time is not a part of the transaction concept fdatasync() can be used to avoid unnecessary inode disk write operations."

 
2872 code active 2008 Jan anonymous   2008 Jan   4 4 Some table scan operations could use an index for better data density edit
If a suitable index covers a column being during a table scan, it makes sense to use the index for IO not the table pages themselves for speed.

As (contrived) example:

  CREATE TABLE t1 ( c1 blob, c2 integer, c3 integer );
  CREATE INDEX i1 on t1(c2,c3);
  CREATE INDEX i2 on t1(c3);

T1 populated with 4096 rows, c1 being 64K random blobs (to make c2, c3 access slower in this case), c2 and c3 being small random integers.

Now:

  sqlite> select sum(c3) from t1;
  sum(c3)
  ----------
  519895

is very slow (several seconds). A table scan is done.

Forcing use of an index, in a way that I know all rows will be included:

  sqlite> select sum(c3) from t1 where c2<1000;
  sum(c3)
  ----------
  519895

This is instantaneous.

It seems to me that if a table scan has to be performance, it makes sense to grab the data from an index whenever possible. ideally the most densely packed index.

(BTW; this is contrived, I know putting the blob as the last column will greatly speed things up).

 
2867 code active 2008 Jan anonymous   2008 Jan   2 2 doesn't build on Cygwin - wrong sqlite3 exe suffix edit
The new Makefile used $(EXE), which doesn't seem to be defined (typo?)
2008-Jan-02 11:12:39 by anonymous:
Same on mingw:

Following patch fixes things:

--- sqlite-3.5.4/Makefile.in    Thu Dec 13 19:17:42 2007
+++ sqlite-3.5.4-mingw-fix/Makefile.in  Wed Jan  2 11:37:50 2008
@@ -322,7 +322,7 @@
                -o $@ $(TOP)/src/shell.c libsqlite3.la \
                $(LIBREADLINE) $(TLIBS)

-sqlite3$(EXE): $(TOP)/src/shell.c sqlite3.c sqlite3.h
+sqlite3$(TEXE):        $(TOP)/src/shell.c sqlite3.c sqlite3.h
        $(LTLINK) $(READLINE_FLAGS) -o $@                          \
                -DSQLITE_MAX_SQL_LENGTH=1000000000                  \
                -USQLITE_THREADSAFE -DSQLITE_THREADSAFE=0           \
@@ -577,7 +577,7 @@
          -e 's,$$,\\n",' \
          $(TOP)/tool/spaceanal.tcl >spaceanal_tcl.h
        $(LTLINK) -DTCLSH=2 -DSQLITE_TEST=1 $(TEMP_STORE)\
-                -o sqlite3_analyzer$(EXE) $(TESTSRC) $(TOP)/src/tclsqlite.c \
+                -o sqlite3_analyzer$(TEXE) $(TESTSRC) $(TOP)/src/tclsqlite.c \
                libtclsqlite3.la $(LIBTCL)
 
2865 code active 2007 Dec anonymous   2007 Dec   1 2 FTS3 does not build with amalgamation in CVS edit
Grab the latest CVS sources, then run:

  ./configure
  make sqlite3.c

  grep sqlite3Fts3Init sqlite3.c

    extern int sqlite3Fts3Init(sqlite3*);
    rc = sqlite3Fts3Init(db);

If you compile sqlite3.c with -DSQLITE_ENABLE_FTS3, then sqlite3Fts3Init is unresolved.

For some reason, sqlite3Fts3Init and fts3.c was not included in the sqlite3.c amalg.

It used to work correctly in 3.5.4.

2007-Dec-30 18:17:57 by anonymous:
Nevermind, "make sqlite3.c" has never built with the fts3 sources in 3.5.4 or before.

You have to run ext/fts3/mkfts3amal.tcl


2007-Dec-30 18:20:56 by anonymous:
It seems that the sqlite3+fts3 amalg can only be built from main.mk, not Makefile.
 
2863 code active 2007 Dec anonymous   2007 Dec   2 3 test cast-3.14, cast-3.18 and cast-3.24 fail edit
  test cast-3.{14,18,24} fail on freebsd-6.3-PRERELEASE2:
  cast-3.14...^M
  Expected: [9223372036854774784]^M
       Got: [9223372036854773760]^M
  cast-3.18...^M
  Expected: [-9223372036854774784]^M
       Got: [-9223372036854773760]^M
  cast-3.24...^M
  Expected: [9223372036854774784]^M
       Got: [9223372036854773760]^M
  I used tcl8.4 from ports with no threads and here was the config line:
  ../sqlite-3.5.4/configure --prefix=/home/marc/local --with-tcl=/usr/local/lib/tcl8.4/

This was built on an ibm t30 laptop

 
2859 code active 2007 Dec anonymous   2007 Dec drh 3 2 Inconsistent column names with DISTINCT edit
Given the following SQL:

  CREATE TABLE foo(a,b);
  INSERT INTO foo (a, b) VALUES (1,2);

SQLite returns inconsistent column names when using the DISTINCT clause:

  SELECT DISTINCT foo.A, foo.B FROM foo;
  foo.A|foo.B
  1|2

  SELECT DISTINCT a, b FROM foo;
  a|b
  1|2

  SELECT DISTINCT * FROM foo;
  a|b
  1|2

  SELECT DISTINCT foo.* FROM foo;
  a|b
  1|2

Compared with SELECT without DISTINCT:

  SELECT foo.A, foo.B FROM foo;
  a|b
  1|2

  SELECT a, b FROM foo;
  a|b
  1|2

  SELECT * FROM foo;
  a|b
  1|2

  SELECT foo.* FROM foo;
  a|b
  1|2
 
2761 code active 2007 Nov anonymous   2007 Dec   3 3 CLI (shell.c) should be bundled with amalgamation edit
The CLI (shell.c) should be bundled with the amalgamation for database administrative purposes without downloading the matching shell.c from the full source tree.
I second that! Qt ships with the amalgamated source files, but we also ship shell.c, whch we have to retrieve from the non-amalgamated source files.


2007-Dec-26 15:20:04 by anonymous:
I also agree. It is inconvenient to retrieve the matching shell.c from the source tree.
 
2857 code active 2007 Dec anonymous   2007 Dec   2 2 GROUP BY cost estimate wrong with WHERE clause edit
There seems to be an issue with the sqlite cost heuristic with an INDEX present on GROUP BY with certain types of WHERE clauses.

Given the database formed by running these statements:

  create table stuff(a,b,c,d);
  insert into stuff values(1,2,3,4);
  create temp view v1 as select random()%100,
    random()%100, random()%1000, random()%10000
     from stuff x, stuff y;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  create index stuff_b on stuff(b);
  create index stuff_c on stuff(c);
  create index stuff_d on stuff(d);
  analyze;

Using sqlite.org's sqlite3-3.5.4.bin, this query takes 47 seconds:

  select c from stuff where a=23 group by c;

while this query takes just 2 seconds:

  select c from stuff where a=23 group by +c;

It is more efficient in this case to do a full table scan instead of using the INDEX on column c.

2007-Dec-23 23:14:06 by anonymous:
The queries above both run in a couple of seconds with this naive patch:

--- src/where.c 12 Dec 2007 17:42:53 -0000      1.266
+++ src/where.c 23 Dec 2007 22:48:37 -0000
@@ -1514,6 +1514,12 @@ static double bestIndex(
     flags = 0;
   }

+  if( pWC && pWC->nTerm>0 && pOrderBy ){
+    /* Reduce cost if both an ORDER/GROUP BY exists with a WHERE. */
+    cost /= 100; /* A very rough guess. */
+    WHERETRACE(("... WHERE + ORDER BY decreases cost to: %.9g\n", cost));
+  }
+
   /* If the table scan does not satisfy the ORDER BY clause, increase
   ** the cost by NlogN to cover the expense of sorting. */
   if( pOrderBy ){
But it has not been tested on queries with more than one table. Its logic could be flawed.


2007-Dec-24 00:09:00 by drh:
The complaint is centered around these two queries:

    /* 1 */  SELECT c FROM stuff WHERE a=23 GROUP BY c;
    /* 2 */  SELECT c FROM stuff WHERE a=23 GROUP BY +c;

Query 1 runs in about 40 seconds and query 2 in about 1.5 seconds on my macbook. But with the patch, both queries run in about 1.5 seconds. Fair enough. But now consider these two queries:

    /* 3 */  SELECT c FROM stuff WHERE a!=23 GROUP BY c;
    /* 4 */  SELECT c FROM stuff WHERE a!=23 GROUP BY +c;

In this case, query 3 runs in 42 seconds on an unpatched version of 3.5.4 and query 4 runs in about 109 seconds. So in cases where the WHERE clause is not particularly selective, the first version is faster than the second by a good margin. On a patched version of 3.5.4, both queries 3 and 4 run in about 110 seconds.

So it seems to me that the patch is robbing Peter to pay Paul. It makes ORDER BY queries with very selective WHERE clauses run faster but at the expense of making queries with unselective WHERE clauses running slower.

But notice this: in the current (unpatched) implementation, the programmer at least has the ability to select a different algorithm by the judicious placement of a "+" sign. After the patch, this is no longer possible. The patch forces the second algorithm to be used in all cases, even cases where it is slower.

It seems to me to be better to leave things as they are since the current approach at least allows the programmer to override SQLite's algorithm selection if SQLite chooses incorrectly.

The only way, it seems to me, to automatically choose the correct algorithm is to devise some test that will determine (in advance) whether or not the WHERE clause weeds out many or few rows from the result set. I'm thinking that determination is going to be very hard (or impossible) to do without first doing a full table scan.


2007-Dec-24 05:40:47 by anonymous:
It think it would be surprising to average users that adding an index (on column C in this case) may significantly decrease query performance for some queries. It was surprising to me, at least. In my opinion, a query being 20 times slower in a default bad guess situation is worse than a query only being 2.5 times slower with a default bad guess in a worst case scenario. It's a question of relative magnitude of the difference. This is why I think that the database should err on the side of the WHERE clause having a more selective bias.

(Side note: the query timings difference is less pronounced if you use PRAGMA temp_store=memory, in which case query 3 running on an unpatched 3.5.4 takes just 50% more time to run than query 4 on my machine.)

But you raise a good point in that if there's a wrong guess in the selectivity bias it would be nice to be able to manually override it.

How much do you hate this type of syntax that some other databases use?

  select c from stuff where a!=23 group by /*+stuff_c*/ c;

SQLite does not currently offer a way to pick a specific index. I think it would be quite useful.


2007-Dec-24 17:05:16 by anonymous:
Another option is to collect WHERE clause statistics in a table like

  create table sqlite_stat2(
    where_clause_md5 BLOB primary key,
    where_clause     TEXT,
    rows_examined    INT,
    rows_true        INT
  );

where the last 2 columns are cumulative for each query. The statistics option could be enabled/disabled via a PRAGMA sqlite_collect_statistics.

The where_clause column could be a string generated fairly easily from the walking the parse tree of the resolved Select statement's pWhere. This way the where_clause is normalized and a single query with many subselects could generate more than 1 where_clause, and different queries that happen to use the same normalized where clause would update the same entry in the stat2 table. where_clause normalization would strip off aliases and only refer to the original table and column names.

For example the 2 queries below:

  -- CREATE TABLE t1(a, b);
  -- CREATE TABLE t2(b, c);
  SELECT t1.a*c as AC, t2.b-a as BA FROM t1, t2 WHERE AC>BA;
  SELECT *, t1.a Foo FROM t2, t1 WHERE Foo*c > t2.b - t1.a;

would generate the same normalized where_clause string "(T1.A*T2.C)>(T2.B-T1.A)". The table information is already encoded within it.

The generated VDBE code would have to generate Mem counters that would be incremented by each WHERE test, and lazily updated at the end of transactions or periodically written to the stat2 table to minimize disk use, as this information is not critical.

One could also manually set the stat2 table with statistical values they would like their queries to use even if PRAGMA sqlite_collect_statistics=off;

Any time the schema is changed, the entire sqlite_stat2 table would be cleared.

 
2508 code active 2007 Jul anonymous   2007 Dec   1 1 utf8ToUnicode() does not work on some WinCE devices edit
On some WinCE devices first call to MultiByteToWideChar() in utf8ToUnicode() always fails. Tried calling GetLastError() after it fails and it returns error code 87 -- ERROR_INVALID_PARAMETER.

To fix this had to change code page from CP_UTF8 to CP_ACP -- no idea why this works.

Original utf8ToUnicode()


static WCHAR *utf8ToUnicode(const char *zFilename) { int nChar; WCHAR *zWideFilename;

  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
  zWideFilename = sqliteMalloc( nChar*sizeof(zWideFilename[0]) );
  if( zWideFilename==0 ){
    return 0;
  }
  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar);
  if( nChar==0 ){
    sqliteFree(zWideFilename);
    zWideFilename = 0;
  }
  return zWideFilename;
}


Fixed utf8ToUnicode()
static WCHAR *utf8ToUnicode(const char *zFilename) { int nChar; WCHAR *zWideFilename;

  nChar = MultiByteToWideChar(CP_ACP, 0, zFilename, -1, NULL, 0);
  if( nChar == 0 )
  {
    DWORD dwError = GetLastError();
    OSTRACE2("MultiByteToWideChar() failed, last error: %d\n", dwError);
    return 0;
  }
  zWideFilename = sqliteMalloc( nChar*sizeof(zWideFilename[0]) );
  if( zWideFilename==0 ){
    return 0;
  }
  nChar = MultiByteToWideChar(CP_ACP, 0, zFilename, -1, zWideFilename, nChar);
  if( nChar==0 ){
    sqliteFree(zWideFilename);
    zWideFilename = 0;
  }
  return zWideFilename;
}


2007-Jul-17 23:56:10 by anonymous:
unicodeToUtf8() needs to be fixed the same way.

Before:


static char *unicodeToUtf8(const WCHAR *zWideFilename){ int nByte; char *zFilename;

  nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0);
  zFilename = sqliteMalloc( nByte );
  if( zFilename==0 ){
    return 0;
  }
  nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte,
                              0, 0);
  if( nByte == 0 ){
    sqliteFree(zFilename);
    zFilename = 0;
  }
  return zFilename;
}


After:
static char *unicodeToUtf8(const WCHAR *zWideFilename){ int nByte; char *zFilename;

  nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, NULL, 0, NULL, NULL);
  if ( nByte == 0 )
  {
    DWORD dwError = GetLastError();
    OSTRACE2("WideCharToMultiByte() failed, last error = %d\n", dwError);
    return 0;
  }
  zFilename = sqliteMalloc( nByte );
  if( zFilename==0 ){
    return 0;
  }
  nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, zFilename, nByte,
                              0, 0);
  if( nByte == 0 ){
    sqliteFree(zFilename);
    zFilename = 0;
  }
  return zFilename;
}


Note that while original code with CP_UTF8 works on Windows and SOME WinCE devices, this modified code works well and Windows and all WinCE devices I've tested so far.


2007-Jul-18 16:01:21 by anonymous:
Why not using the conversions from SQLite internals ? It can change a UTF-16 to UTF-8 and vice-versa.

Or using UTF-16 variants in windows ce should be the best case.


2007-Aug-09 20:47:04 by anonymous:

  Why not using the conversions from SQLite internals ? It can change a UTF-16 to UTF-8 and vice-versa.

  Or using UTF-16 variants in windows ce should be the best case.

Not so simple. unicodeToUtf8() is used a lot internally regardless of what whether you use UTF-16 or UTF-8 yourself. For example, unicodeToUtf8() is used by sqlite3WinTempFileName() which is in turn used by sqlite3PagerOpentemp() -- I think you get the idea.


2007-Dec-20 00:29:33 by anonymous:
We've found that using CP_UTF8 fails on WinCE kernels that don't include SYSGEN_CORELOC (http://msdn2.microsoft.com/en-us/library/ms903883.aspx). To make the code handle any device it should be changed to:

  static WCHAR *utf8ToUnicode(const char *zFilename)
  {
    int nChar;
    WCHAR *zWideFilename;

    nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
    if( nChar == 0 )
    {
      nChar = MultiByteToWideChar(CP_ACP, 0, zFilename, -1, NULL, 0);
      if( nChar == 0 )
      {
        DWORD dwError = GetLastError();
        OSTRACE2("MultiByteToWideChar() failed, last error: %d\n", dwError);
        return 0;
      }
    }
    zWideFilename = sqliteMalloc( nChar*sizeof(zWideFilename[0]) );
    if( zWideFilename==0 )
    {
      return 0;
    }
    nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar);
    if( nChar==0 )
    {
      nChar = MultiByteToWideChar(CP_ACP, 0, zFilename, -1, zWideFilename, nChar);
      if( nChar==0 )
      {
        sqliteFree(zWideFilename);
        zWideFilename = 0;
      }
    }
    return zWideFilename;
  }
 
368 code active 2003 Jun anonymous   2007 Dec   3 4 UPDATE trigger doesn't fire on INSERT OR REPLACE edit
After executing the following SQL, there will be nothing in table T2. I expect to see '1' there:

   CREATE TABLE T1 ( id, name );
   CREATE TABLE T2 ( id );
   CREATE TRIGGER T1A AFTER UPDATE ON T1
	BEGIN
	INSERT INTO T2 VALUES( new.id );
	END;

   INSERT INTO T1 VALUES (1, 'Hi');
   INSERT INTO T1 VALUES (2, 'There');
   INSERT OR REPLACE INTO T1 VALUES (1,'Me');
An INSERT trigger does fire on INSERT OR REPLACE if the item exists already -- I would expect an UPDATE trigger.


2004-Sep-21 17:15:37 by anonymous:
Still repros in 3.0.7 :-(


2007-Dec-17 21:45:03 by anonymous:
I would say that ON DELETE and ON INSERT better describes what really happens (and not ON UPDATE), because if there would be another columns in the '1' row, their values would not be preserved after INSERT OR REPLACE takes place, as the documentation of the ON REPLACE algorithm states: "When a UNIQUE constraint violation occurs, the pre-existing rows that are causing the constraint violation are removed prior to inserting or updating the current row". However, neither ON UPDATE nor ON DELETE trigger occurs, which still is a bug. Thank you.
 
2842 code active 2007 Dec anonymous   2007 Dec   1 1 .import does not recongnise NULL values edit
.import function fails to see NULL values in csv files as NULL values...instead they are treated as the string "NULL".

This is with .mode list and separator , But behaves similarly for .mode csv

Also if one outputs a table with NULL values to a file, then re-imports that file, again .import does not recognise the values as NULL, but as "NULL".

Everything here also applies to empty strings in files, e.g. instead of "NULL" using nothing...

This is a showstopper for us since we want to import a large amount of data with many tables containing NULL values. I can't see any valid reason for .import not to recognise the same syntax as the command line.

Note that something like:

sqlite3 my.db insert into MY_TABLE values (1,"foo","bar",NULL)

..works fine. It is just .import that appears to be broken.

2007-Dec-14 16:39:51 by rdc:
.import only inserts string values into database tables. If your column has a declared type that changes the columns affinity to numeric or integer, then those strings will be converted to numeric values by the SQLIte library.

The workaround is to simply insert a unique string where ever you want a NULL value, and then run an update that replaces those strings with real NULL values. If you inserted the string 'NULL' then do this after the .import

update t set field = null where field = 'NULL';

You will have to repeat this for each field in your table that might contain the 'NULL' string.

 
2721 code active 2007 Oct anonymous   2007 Dec   2 1 if db file is in a folder with non-ansi character some functions fail edit
If database file is located in directory with some non-ANSI characters (in my case with a Russian subdirectory c:\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\Data_Jobs), or it's name is non-ansi. Some functions fail to execute sql.

For example (with defined UNICODE):

TCHAR sql[512];
_stprintf(sql, _T("INSERT INTO tab_SurveyedPoints (name, comment, code,")
		_T("coordinatetype, b, l, h, solutiontype, sigmah, sigmav)")
		_T(" VALUES ('%s','%s','%s',0,%lf,%lf,%lf,0,%lf,%lf);"),
		point.m_name.c_str(), point.m_description.c_str(), point.m_code.c_str(),
		point.m_coordinates.b, point.m_coordinates.l, point.m_coordinates.h,
		point.m_sigmah, point.m_sigmav);
int rc1 = sqlite3_prepare16(m_db, sqlfmt, -1, &stmt, (const void**)&pszTail);
rc != SQLITE_OK

But if I move the file to c:\My documents\Data_Jobs this works ok.

It's improbable behaviour, but I can't work around yet. Although, prepare() functions work ok as well in both cases.

Yuri Noyanov.

2007-Oct-11 19:33:34 by drh:
All string arguments to SQLite, and especially filename arguments, must be UTF-8 or UTF-16 (depending on the function). If you use string parameters which are not UTF-8 or UTF-16 (as appropriate) then the behavior of SQLite is undefined and probably not what you want.


2007-Oct-12 04:25:56 by anonymous:
but ALL programs to handle SQLite DBs (SQLIteBrowser, SQLite Control) fail to handle the files as well. Till I move the file to different directory !!!


2007-Oct-12 04:27:54 by anonymous:
Also I must note, that I CAN open the database, I CAN execute some SQLs with sqlite_prepare function OK. But sqlite_prepare16 FAILS if I just rename my database !!!


2007-Oct-12 04:31:46 by anonymous:
Also note to make my issue clearer:

sqlite_prepare16() with the same code either works OK either doesn't work. depends on database filename or folder path. The database is opened OK in both cases (I used utf8 conversion). sql_prepare() works ok in both cases.


2007-Oct-13 06:37:43 by anonymous:
That appears to be only with INSERT sql statement. Both SELECT and UPDATE work fine with sqlite_prepare16.
 
2825 code active 2007 Dec anonymous   2007 Dec   3 3 FormatMessage (win32) should use extra flag and convert from Unicode edit
The call to FormatMessageA in the win32 source code needs to have the flags changed from: FORMAT_MESSAGE_FROM_SYSTEM to FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS

This ensures that any system messages that expect arguments do not try to grab the argument from some random memory location.

ref: http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx

2007-Dec-06 14:07:53 by anonymous:
I also noticed that the result is NOT converted to UTF-8.

FormatMessageA returns the text in the local ANSI codepage. FormatMessageW should be used on NT systems, and either result should be converted to the SQLite UTF-8 default.


2007-Dec-11 00:34:37 by anonymous:
to simplify what is meant even more...

http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/os_win.c&v=1.118

Search for FormatMessageA (only 1 instance)

  -    FORMAT_MESSAGE_FROM_SYSTEM,
  +    FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,

No breakage, ensures that no crashes with some messages (e.g. filesystem errors). The encoding issue should be addressed separately.


2007-Dec-11 01:27:07 by anonymous:
The function should be changed to the following to correctly handle the conversion from Unicode/MBCS.

static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){
  int error = GetLastError();
#if OS_WINCE
  if( error>0x7FFFFFF ){
    sqlite3_snprintf(nBuf, zBufOut, "OsError 0x%x", error);
  }else{
    sqlite3_snprintf(nBuf, zBufOut, "OsError %d", error);
  }
#else
  if( isNT() ){
    LPWSTR zWinTemp = NULL;
    DWORD dwLen = FormatMessageW(
      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
      NULL,
      error,
      0,
      (LPWSTR) &zWinTemp,
      0,
      0
    );
    if (dwLen > 0) {
      char * zOut = unicodeToUtf8(zWinTemp);
      LocalFree(zWinTemp);
      sqlite3_snprintf(nBuf, zBufOut, "%s", zOut);
      free(zOut);
    }
  }else{
    LPSTR zWinTemp = NULL;
    DWORD dwLen = FormatMessageA(
      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
      NULL,
      error,
      0,
      (LPSTR) &zWinTemp,
      0,
      0
    );
    if (dwLen > 0) {
      char * zOut = mbcsToUtf8(zWinTemp);
      LocalFree(zWinTemp);
      sqlite3_snprintf(nBuf, zBufOut, "%s", zOut);
      free(zOut);
    }
  }
#endif
}
 
2814 code active 2007 Nov anonymous   2007 Dec   3 3 _XOPEN_SOURCE again edit
Ideally setting _XOPEN_SOURCE should be an opt-in detected by configure, rather than a hardcoded opt-out as it is now. I find you create more problems in setting it than just leaving it out on modern platforms.

Can you please give users the option of not defining _XOPEN_SOURCE at all?

+#ifndef SQLITE_DONT_DEFINE_XOPEN_SOURCE
 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && SQLITE_THREADSAFE
 #  define _XOPEN_SOURCE 500  /* Needed to enable pthread recursive mutexes */
 #endif
+#endif
2007-Dec-01 09:23:15 by anonymous:
Also when using Python, it sets _XOPEN_SOURCE to 600. No idea what the 500 vs 600 difference is about.


2007-Dec-01 15:58:28 by anonymous:
I've used a couple of different Linux OSes and _XOPEN_SOURCE is not needed. Maybe it's for OSes more than 5 years old. Recursive mutexes are pretty much standard these days since the popularity of Java which uses them extensively.


2007-Dec-01 17:21:05 by drh:
See also tickets #2673, #2681, and #2741.


2007-Dec-02 02:08:26 by anonymous:
On Linux, PTHREAD_MUTEX_RECURSIVE is the same as PTHREAD_MUTEX_RECURSIVE_NP:

    PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,

Since PTHREAD_MUTEX_RECURSIVE_NP is always available, you could avoid defining _XOPEN_SOURCE and use this code instead:

-        pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE);
+        pthread_mutexattr_settype(&recursiveAttr,
+#ifdef linux
+          PTHREAD_MUTEX_RECURSIVE_NP
+#else
+          PTHREAD_MUTEX_RECURSIVE
+#endif
+        );

2007-Dec-02 02:17:22 by anonymous:
A quick google search reveals how various projects deal with this recursive mutex declaration problem (in no particular order):

  • #define _XOPEN_SOURCE 500 and use PTHREAD_MUTEX_RECURSIVE
  • #define _XOPEN_SOURCE 600 and use PTHREAD_MUTEX_RECURSIVE
  • #define _GNU_SOURCE and use PTHREAD_MUTEX_RECURSIVE
  • don't define anything and use PTHREAD_MUTEX_RECURSIVE_NP on linux, and PTHREAD_MUTEX_RECURSIVE elsewhere.

Unfortunately, since PTHREAD_MUTEX_RECURSIVE is an enum on Linux, so you can't use the #ifdef PTHREAD_MUTEX_RECURSIVE compile-time technique.

 
2809 code active 2007 Nov anonymous   2007 Nov   1 1 PRAGMA collation_list shows unregistered collations edit
As presented on the mailing list:

Imagine that a SQLite3 database opened in a custom application with a registered a collation sequence named "unknown" has created the following table:

  CREATE TABLE a (b COLLATE unknown);

Now open this table in the default SQLite3 CLI. Up to here, everything works as expected.

Next issue "PRAGMA collation_list;" and notice that "unknown" lists next to the other registered collations, even though "unknown" is not registered with the default SQLite3 CLI:

  sqlite> PRAGMA collation_list;
  0|unknown
  1|NOCASE
  2|BINARY

Responses from the mailing list indicate that this is not the expected behaviour. "PRAGMA collation_list;" should list registered collations only.

2007-Nov-28 16:12:17 by anonymous:
I don't think this is a bug. If the CLI is not aware of the collation, it should not process the query that makes use of the collation because it would certainly be wrong if it simply ignored the collation. This is not unlike a user-registered SQL function that does not exist in the CLI. I would not expect or want the sqlite3 CLI to ignore the unknown function, nor would I want the CLI to process queries ignoring the custom collation.
 
2810 code active 2007 Nov anonymous   2007 Nov   1 1 Unregistered collation problems with simple subselects edit
As discussed on the mailing-list:

Imagine that a SQLite3 database opened in a custom application with a registered a collation sequence named "unknown" has created the following table:

  CREATE TABLE a (b COLLATE unknown);

Now open this table in the default SQLite3 CLI. Up to here, everything works as expected. Simple queries like "SELECT * FROM a;" work fine.

But subselects, in their most basic form and with no sorting or comparisons, result in an error:

  sqlite> INSERT INTO a VALUES ('one');

  sqlite> SELECT * FROM a, (SELECT * FROM a);
  SQL error: no such collation sequence: unknown

  sqlite> SELECT * FROM (SELECT * FROM a);
  SQL error: no such collation sequence: unknown

  sqlite> SELECT *, * FROM a;
  one|one

This is surprising because the collation sequence should not matter to the queries. In fact, the union without the subselect works just fine and without errors.

To demonstrate, here is the explain output of a table with a registered collation sequence. No mention of the collation name here:

  sqlite> CREATE TABLE b (b collate nocase);
  sqlite> EXPLAIN SELECT * FROM b, (SELECT * FROM b);
  0|Goto|0|17|
  1|Integer|0|0|
  2|OpenRead|0|3|
  3|SetNumColumns|0|1|
  4|Integer|0|0|
  5|OpenRead|2|3|
  6|SetNumColumns|2|1|
  7|Rewind|0|14|
  8|Rewind|2|13|
  9|Column|0|0|
  10|Column|2|0|
  11|Callback|2|0|
  12|Next|2|9|
  13|Next|0|8|
  14|Close|0|0|
  15|Close|2|0|
  16|Halt|0|0|
  17|Transaction|0|0|
  18|VerifyCookie|0|4|
  19|TableLock|0|3|b
  20|Goto|0|1|
  21|Noop|0|0|
 
2223 code active 2007 Feb scouten   2007 Nov   3 3 pragma auto_vacuum doesn't survive .dump & reconstitute edit
When you run sqlite3 path/to/database .dump, it does not contain pragma auto_vacuum even if that option was chosen when creating the source database.
2007-Feb-08 18:13:27 by scouten:
We wonder if other pragmas are also not being propogated.


2007-Feb-08 18:53:42 by anonymous:
No pragmas are output from .dump. SQLite should have a .dump_with_pragmas command or equivalent.


2007-Nov-27 02:11:05 by anonymous:
auto_vacuum is especially important since you need to specify it before loading the tables in the dump; if you notice that it's missing after loading a dump, it's too late.

I'd also appreciate user_version surviving.

Would patches be welcome for these? I would be happy to contribute one: mail glasser@davidglasser.net.

 
2793 code active 2007 Nov anonymous   2007 Nov   3 3 fts3 lacks scoping edit
It would be nice if the fts3 symbols could optionally be made private/static as the rest of the sqlite3 library. Not sure why sqlite3_api becomes public when used with the amalgamation, for that matter.

  make TOP=`pwd` BCC=gcc TCC=gcc AR=ar RANLIB=echo NAWK=gawk -f \
    main.mk sqlite3.h sqlite3.c fts3amal.c
  cat fts3amal.c >> sqlite3.c
  gcc -DSQLITE_THREADSAFE -DSQLITE_API=static -DSQLITE_PRIVATE=static \
    -DSQLITE_EXTERN=static -DSQLITE_ENABLE_FTS3 -c sqlite3.c
  nm sqlite3.o | grep -v ' [trUbd] '

  00000004 C sqlite3_api
  00064da2 T sqlite3Fts3HashClear
  000652a4 T sqlite3Fts3HashFind
  00064d60 T sqlite3Fts3HashInit
  0006533b T sqlite3Fts3HashInsert
  00064b4c T sqlite3Fts3Init
  00066b34 T sqlite3Fts3InitHashTable
  000669bd T sqlite3Fts3PorterTokenizerModule
  0006702d T sqlite3Fts3SimpleTokenizerModule
 
2791 code active 2007 Nov anonymous   2007 Nov   1 1 Allow building FTS[123] as part of sqlite library with configure edit
See attached patch.
 
2770 code active 2007 Nov anonymous   2007 Nov   1 1 Problem with BLOB in 3.5.x ? edit
After I've switched from 3.3.18 to 3.5.2, selecting from table which contains BLOB LONGER THAN ABOUT 990 BYTES returns error "SQL logic error or missing database" after call to _sqlite3_step().

I'm using preprocessed sources downloaded from here. DEBUG build of preprocessed sources works correctly, problem is only in RELEASE build. I'm using VC6.0 to compile.

Any idea what could be wrong? Thank you!

Can you try to reproduce this with the sqlite shell tool? Thanks.

Large blobs work for me with both release and debug builds (not msvc though, gcc/linux).


2007-Nov-12 18:41:37 by anonymous:
sqlite3.exe provided here works with the database. Problem is only with release build (static library linked into test application). Here is test app which exits with "Error 1" in release build:

  int main(int argc, char* argv[])
  {
	int rc;
	sqlite3* db;
	sqlite3_stmt* stmt;

	rc = sqlite3_open("n2.db3", &db);

	rc = sqlite3_prepare(db, "CREATE TABLE [ttt] ([bbb] BLOB)", -1, &stmt, 0 );
	rc = sqlite3_step(stmt);
	rc = sqlite3_reset(stmt);

	char text[10000],query[20000];
	strnset(text,'a',sizeof(text)-1);
	sprintf(query,"insert into [ttt] values (?)");

	rc = sqlite3_prepare(db, query, -1, &stmt, 0 );

	rc = sqlite3_bind_blob(stmt,1,text,sizeof(text), SQLITE_TRANSIENT);

	rc = sqlite3_step(stmt);
	rc = sqlite3_reset(stmt);

	rc = sqlite3_prepare(db, "select * from ttt", -1, &stmt, 0 );

	rc = sqlite3_step(stmt);

	if (rc == SQLITE_ROW)
	{
		printf("%s: OK",sqlite3_column_text(stmt,1));
	}
	else
	if (rc == SQLITE_DONE)
	{
		printf("DONE");
	}
	else
	{
		printf("Error %d",rc);
	}

	return 0;
}


2007-Nov-12 18:56:24 by drh:
You should be using sqlite3_finalize() instead of sqlite3_reset(). You are leaking memory. Also, you should use sqlite3_prepare_v2() to avoid problems with changing schemas.

But even without those fixes, I cannot reproduce the problem on Linux.


2007-Nov-12 19:39:31 by anonymous:
Suggested fixes didn't help.

I've tried to debug it. It fails in btree.c, line 3056:

if( offset+amt > nKey+pCur->info.nData ){ /* Trying to read or write past the end of the data is an error */ return SQLITE_ERROR; }

there seems to be different values in release mode. My debugger does not show values of variables in release mode, so I can be wrong, but it seems in release offset is 5 and in debug it is 4. There can be something wrong with compilation, I'll try to figure this out tomorrow.

BTW compilation of static libraty in VC6.0 gives 185 warnings. I don't know if it is ok, it haven't caused problems in older sqlite


2007-Nov-13 08:47:28 by anonymous:
I've turned off "Maximize Speed" option - this is causing the problem. No optimizations and optimize for size seems to be working. But it still makes me nervous :(( I really don't need corrupted database and now I hope it won't slow down too much. Unfortunately old library does not implement replace function so I don't want to switch back. This could be warning to others, I'm using VC++ 6.0 SP 6.

Thank you for your time.


2007-Nov-22 17:20:31 by anonymous:
I have exactly the same problem here (win XP, vc6 SP2) when I link against my sqlite static or dynamic library in release.

I have also used boundschecker to check sqlite, and it detects many dangling pointers ! But the strange thing is that I cannot find why these pointers are dangling, here an example:

  In prepare.c@188
  pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);

Boundchecker say that zMasterName is a dangling pointer, previously released here:

  in build.c@711:
  void sqlite3StartTable(
    Parse *pParse,   /* Parser context */
    Token *pName1,   /* First part of the name of the table or view */
    Token *pName2,   /* Second part of the name of the table or view */
    int isTemp,      /* True if this is a TEMP table */
    int isView,      /* True if this is a VIEW */
    int isVirtual,   /* True if this is a VIRTUAL table */
    int noErr        /* Do nothing if table already exists */
  ){
  }

It does not make sens for me, maybe it a false positive from boundchecker, but it is weird.

I don't know if these "errors" are related to the "blob" bug in release mode. I will try to debug these error with some "printf" in release mode.

Note: The provided dll (the one from the sqlite site) does not have this "bug".


2007-Nov-22 18:27:35 by anonymous:
More info: It seems that there is a bug in the VC6 (SP6) compiler.

In btree.c, line 3056:

  if( offset+amt > nKey+pCur->info.nData ){
    /* Trying to read or write past the end of the data is an error */
    return SQLITE_ERROR;
  }

After adding some printf around, It seems that the "speed optimization" compilation flag of VC6 changes the code order in a way that the offset variable is miss incremented !!

Two remarks:

  • I've traced the calling function, sqlite3BtreeData, and the it call accessPayload with the good offset value
  • VC6 produces an internal error: "fatal error C1001: INTERNAL COMPILER ERROR" in the accessPayload function, if I try to access the offset value before this line:

  aPayload = pCur->info.pCell + pCur->info.nHeader;

A dirty workaround could be to change the code order or the local var usage. I'm trying ....

 
2771 code active 2007 Nov anonymous   2007 Nov   4 4 Lemon: Generated parser needs stdlib.h (not in default template) edit
I tested a simple do-nothing parser just to get lemon output, and this doesn't compile (if warnings treated as errors) because of non declaration of the memset() function for the following statment:

memset(&yygotominor, 0, sizeof(yygotominor));

(added for the resolution of SQLite ticket #2172).

The lempar.c just include stdio.h, it would suffice to add stdlib.h to get the memset() declaration (even if all real parsers must include stdlib.h to get something really working).

2007-Nov-14 21:02:25 by anonymous:
Sorry, the needed header is string.h, not stdlib.h :-)
 
2766 code active 2007 Nov drh   2007 Nov   1 1 TCL transaction started from within a query does not commit edit
This is a problem with the TCL interface. Consider the following TCL script:

   file delete -force test.db test.db-journal
   sqlite3 db test.db
   db eval {
     CREATE TABLE t1(x,y);
     INSERT INTO t1 VALUES(1,2);
     CREATE TABLE t2(a,b);
     INSERT INTO t2 VALUES(8,9);
   }
   db eval {SELECT * FROM t1} {
     db transaction {
       db eval {UPDATE t2 SET a=a*2}
     }
   }

The [db transaction] statement starts a transaction and it is suppose to commit the tranaction at the end of the code block. But because the transaction started while a query was active, the tranaction is unable to commit. The TCL interface never commits the tranaction nor does it give any kind of error indication.

It is unclear if an error should be returned or if the commit should be deferred until outer query finishes.

If the code within the [db transaction] block throws an error, we really need the transaction to rollback right away. Perhaps there should be a new API that cancels all pending queries. Perhaps a call to sqlite3_interrupt() would suffice for this. Need to investigate further....

 
2755 code active 2007 Nov anonymous   2007 Nov   3 3 trace interfere with transaction Tcl interface edit
When using the transaction method of the Tcl interface to the SQLite with a registered "trace" function, the stack trace is lost in case an error occurs inside the transaction.

As an example I provide two outputs, the first one without a registered trace function and the second one with one (in which it cannot be seen where the exception cames from):


First:

   > ./a.tcl
vorher
BUMMM
    while executing
"a"
    invoked from within
"db transaction {
        puts "vorher"
        a
        puts "nachher"
    }"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [list db transaction {
        puts "vorher"
        a
        puts "nachher"
    }]"
    (procedure "b" line 2)
    invoked from within
"b"
    (file "./a.tcl" line 28)


Second:

   > ./a.tcl
BEGIN
vorher
ROLLBACK

    while executing
"db transaction {
        puts "vorher"
        a
        puts "nachher"
    }"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [list db transaction {
        puts "vorher"
        a
        puts "nachher"
    }]"
    (procedure "b" line 2)
    invoked from within
"b"
    (file "./a.tcl" line 28)

********

A scritp that demostrates this behaviour is attached. The only workaround is not to trace.

Thanks

 
2753 code active 2007 Nov anonymous   2007 Nov drh 3 3 Master journal files sometimes not deleted edit
In the 3.4.1 amalgamation, in vdbeCommit, the master journal file is created, and deleted at the end or if there is an error. But it looks like there is one case where it gets closed but not deleted. The code is:

    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
      Btree *pBt = db->aDb[i].pBt;
      if( pBt && sqlite3BtreeIsInTrans(pBt) ){
        rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);
      }
    }
    sqlite3OsClose(&master);
    if( rc!=SQLITE_OK ){
      sqliteFree(zMaster);
      return rc;
    }

It seems like that last bit should be:

    if( rc!=SQLITE_OK ){
      sqlite3OsDelete(zMaster);
      sqliteFree(zMaster);
      return rc;
    }
2007-Nov-01 19:26:28 by anonymous:
Should have read the comment above that code segment closer. Looks like this was by design. Trying to figure out what to do with the client that has hundreds of orphaned master journal files...
 
2392 code active 2007 May anonymous   2007 Oct   4 4 Reduce MemPage and PgHdr struct sizes. Better page memory utilization. edit
Patch to reduce sizeof(MemPage) below. It saves 8 bytes per cached page or in-memory page on Linux.

sizeof(MemPage) on Linux:

  original: 84
  patched:  76

Patched "make test" runs without regressions on Linux and Windows. Timings for "make test" (elapsed):

  original: 1:20.74
  patched:  1:20.22

Size of sqlite3.o when compiled from almalogmation with all sqlite features enabled with gcc flags -O3 -fomit-frame-pointer:

  original: 586976 bytes
  patched:  587880 bytes

Patched sqlite3.o is 904 bytes larger.

  Index: src/btreeInt.h
  ===================================================================
  RCS file: /sqlite/sqlite/src/btreeInt.h,v
  retrieving revision 1.4
  diff -u -3 -p -r1.4 btreeInt.h
  --- src/btreeInt.h      16 May 2007 17:28:43 -0000      1.4
  +++ src/btreeInt.h      30 May 2007 16:26:03 -0000
  @@ -269,15 +269,15 @@ typedef struct BtLock BtLock;
   */
   struct MemPage {
     u8 isInit;           /* True if previously initialized. MUST BE FIRST! */
  -  u8 idxShift;         /* True if Cell indices have changed */
     u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */
  -  u8 intKey;           /* True if intkey flag is set */
  -  u8 leaf;             /* True if leaf flag is set */
  -  u8 zeroData;         /* True if table stores keys only */
  -  u8 leafData;         /* True if tables stores data on leaves only */
  -  u8 hasData;          /* True if this page stores data */
  -  u8 hdrOffset;        /* 100 for page 1.  0 otherwise */
  -  u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */
  +  u8 hdrOffset:7;        /* 100 for page 1.  0 otherwise */
  +  u8 zeroData:1;         /* True if table stores keys only */
  +  u8 childPtrSize:3;     /* 0 if leaf==1.  4 if leaf==0 */
  +  u8 leaf:1;             /* True if leaf flag is set */
  +  u8 idxShift:1;         /* True if Cell indices have changed */
  +  u8 intKey:1;           /* True if intkey flag is set */
  +  u8 leafData:1;         /* True if tables stores data on leaves only */
  +  u8 hasData:1;          /* True if this page stores data */
     u16 maxLocal;        /* Copy of Btree.maxLocal or Btree.maxLeaf */
     u16 minLocal;        /* Copy of Btree.minLocal or Btree.minLeaf */
     u16 cellOffset;      /* Index in aData of first cell pointer */
2007-Sep-07 05:58:45 by anonymous:
Any word on applying this patch?

It saves 8 bytes per MemPage. For the default 2000 page cache it would save 16000 bytes. Larger page caches would save considerably more memory.


2007-Oct-26 21:08:03 by anonymous:
With this patch sizeof(PgHdr) is reduced by 4 bytes (from 48 bytes to 44 bytes) for gcc. No regressions. "make test" runs in the same amount of time.

Index: src/pager.c
===================================================================
RCS file: /sqlite/sqlite/src/pager.c,v
retrieving revision 1.393
diff -u -3 -p -r1.393 pager.c
--- src/pager.c 20 Oct 2007 13:17:55 -0000      1.393
+++ src/pager.c 26 Oct 2007 21:00:33 -0000
@@ -261,11 +261,11 @@ struct PgHdr {
   PgHdr *pNextHash, *pPrevHash;  /* Hash collision chain for PgHdr.pgno */
   PagerLruLink free;             /* Next and previous free pages */
   PgHdr *pNextAll;               /* A list of all pages */
-  u8 inJournal;                  /* TRUE if has been written to journal */
-  u8 dirty;                      /* TRUE if we need to write back changes */
-  u8 needSync;                   /* Sync journal before writing this page */
-  u8 alwaysRollback;             /* Disable DontRollback() for this page */
-  u8 needRead;                   /* Read content if PagerWrite() is called */
+  u8 inJournal:1;                /* TRUE if has been written to journal */
+  u8 dirty:1;                    /* TRUE if we need to write back changes */
+  u8 needSync:1;                 /* Sync journal before writing this page */
+  u8 alwaysRollback:1;           /* Disable DontRollback() for this page */
+  u8 needRead:1;                 /* Read content if PagerWrite() is called */
   short int nRef;                /* Number of users of this page */
   PgHdr *pDirty, *pPrevDirty;    /* Dirty pages */
 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT

2007-Oct-26 21:20:09 by anonymous:
How about a compromise. What about some optional setting like?

  #ifndef OMIT_SQLITE_BITFIELDS
  # define SQLITE_BITFIELD(X) : X
  #else
  # define SQLITE_BITFIELD(X)
  #endif

...

  u8 inJournal SQLITE_BITFIELD(1); /* TRUE if has been written to journal */
 
2728 code active 2007 Oct anonymous   2007 Oct   4 4 Some indexes could contain pointers not the data edit
It would be nice if there was a class of index(-column) that would contain a reference to the data in (in the table) rather than a copy of the data.

This is useful where you have a need to index large strings or blobs and the size penalty of having 2+ copies ends up being very expensive.

Consider the cost of the implied index on:

create table t1 ( c1 BLOB UNIQUE);

and store 100s of 1MB objects. The raw file ends up being twice as large as you ideally would like it to be.

WHEN to use such indexes isn't entirely clear to me, not is the syntax for doing it in general, 30s of thought I can come up with:

  create table t1 ( c1 BLOB &UNIQUE);

and say

  create index idx1 on t2(c1, &c2, c3);

(meaning c2 would be done via reference, c1 & c3 as copies of the data). It's FAR from clear what other databases do here (I didn't look).

This would also be useful in cases where I have multiple indexes on tables like email (headers) and values which can be very large (100s of bytes in some cases (Subject:) and I might have 5 or more indexes, means a 100-byte column will take over 600 bytes (+ padding)). Allowing for references would be slower in some cases but faster in others because of the smaller footprint and much grater CPU cache utilization.

2007-Oct-14 15:27:12 by anonymous:
This enhacement has been discussed on the mailing list before, and would break sqlite3 file format compatability.


2007-Oct-15 02:42:02 by anonymous:
This is non standard sql.

Also, the random access to pages to check indexes constraints (unique indexes, also primary keys) will trash the entire database performance.

If you need small index disk usage, consider using hashes to your data keys. it&#180;s the best that you could do to solve your problem.


2007-Oct-18 06:07:58 by anonymous:
Using a hash is what I've tried doing in a couple of cases. It's not very ideal. For one thing is ordering is messed up.

I wonder about a virtual index concept, where you can define a function that takes the column value and returns something to actually store in the index?

I'm told oracle has this feature, so whilst it's non-standard there is some precedent (albeit in a very different space).

 
2715 code active 2007 Oct anonymous   2007 Oct   1 1 no authorization needed to remove authorizer edit
there should be a new auth code created and the auth function should be consulted for permission for removal.
2007-Oct-10 01:08:48 by drh:
I'm assuming that this feature request comes from RockShox and that the development language is Tcl.

No. If your adversary has the ability to invoke the interface that removes an authorizer, then you system is already pwned.

What you really need is the ability to [interp alias] the eval method into a safe interpreter. That way you can:

  • Open the database in the main interpreter
  • Set up the authorizer in the main interpreter to invoke a script in the main interpreter
  • Set up the [interp alias] so that the safe interpreter can do [db eval ...] but not [db auth ...]

It seems like an "-interp" option on the "eval" method of the database connection object would likely be the right interface. Or perhaps there should be separate "safeeval" method. Either way, it has been years and years since I have done anything with safe interpreters so I will have to look into what needs to be done to make that happen.


2007-Oct-17 20:11:23 by anonymous:
ok i think i agree with that.

currently you cannot use an interp alias since the target command runs in the target interp and all your variables and commands are in the wrong scope. this means one needs to load sqlite again in the new interp, and sqlite will not load in a safe interp so a regular interp is required.

to be useful, a -interp flag would need to execute in the current scope of the interp and not the global scope.

 
2714 code active 2007 Oct anonymous   2007 Oct drh 3 4 Shell cannot import large files greater than 2 GB [patch] edit
If I issue an .import command within the SQLite shell and the file size is larger than 2 GB, the shell gives the error message "cannot open file: foo.txt".

Putting #define _FILE_OFFSET_BITS 64 before the #include statements in shell.c fixes this problem under Linux.

I tested this solution with a 2.6 GB file under Ubuntu Feisty Fawn 7.04 with Linux kernel 2.6.20-16-generic.

2007-Oct-12 18:48:35 by drh:
I'm not convinced SQLite should be able to import files larger than 2GiB. Does anybody really ever need to read more than 2GiB of SQL text? That is a lot of SQL, don't you think? Is this really a desirable feature? Can you not split it up into two or more smaller files?


2007-Oct-14 09:25:42 by anonymous:
I'm not 100% certain about this but:

  #define _FILE_OFFSET_BITS 64

isn't necessarily correct, better to tweak the makefile(s):

  CFLAGS += $(shell getconf LFS_CLFAGS)

(similar for LDFLAGS) should work on 32/64 bit machines and different platforms.

For shell.c I really wouldn't bother and think this should be left alone. Using .import for load more than 2GB makes me things the shell should be fleshed out and extended for this sort of abuse, handy as it is right now, it's not a full SQL shell but a minimalist shell and a useful example).


2007-Oct-16 14:08:09 by anonymous:
I am the original poster. I use the shell to import CSV files in the 3-4 GiB range on a daily basis. I don't see the point of splitting the files or writing my own importer when the shell does a perfectly fine job once large file support has been activated.

With all due respect, I don't understand the reluctance to enable a useful feature. Shouldn't the user decide whether it is reasonable for his application to import big files? I work in the health care industry processing insurance claims for several very large companies. There's nothing broken or wrong with my application -- big files are just the nature of the data I'm handling.

Neither of you has proposed any disadvantage to enabling LFS in the shell. If there are no drawbacks, why not turn it on? If the core library can open large database files, why shouldn't the shell be able to import large ones?


2007-Oct-16 16:24:22 by anonymous:
For reasons also unknown to me, the authors appear to regard the shell as a largely unused sample program. Based on my personal experience in talking to various sqlite library users, it is the primary administrative front-end for sqlite. In particular, doing backups and merging databases.
 
2725 code active 2007 Oct anonymous   2007 Oct   1 1 memory leak in sqlite3_open_v2() when it fails edit
only happens with

flags = SQLITE_OPEN_READWRITE;

and when

  res = sqlite3_open_v2(sourcename, &conn, flags, NULL);

seems to leak 674 bytes per call

2007-Oct-15 07:07:07 by danielk1977:
Are you calling sqlite3_close(conn) after the error occurs?

All calls to sqlite3_open_v2() need to be matched by a call to sqlite3_close(), even if an error occurs.

 
2708 code active 2007 Oct anonymous   2007 Oct   4 2 SQL error:disk I/O error edit
I cross-compile sqlite to embedded Linux,but after I insert data to the table ,it failed.the warning is "SQL error:disk I/O error".
2007-Oct-09 05:12:28 by anonymous:

  Why do you think it is SQLite error ??


2007-Oct-09 05:46:06 by danielk1977:
We'll need a bit more data than that to figure this out. Did earlier SQLite versions work? Can you post the entire output of the compile process so that we can see if there are any clues there? Can you run strace so that we can see if there really is an IO error, or at least when SQLite believes there to be one?
 
2705 code active 2007 Oct anonymous   2007 Oct   4 4 testfixture unresolved externals with SQLITE_OMIT_GET_TABLE edit
Cannot build/run "make test" with -DSQLITE_OMIT_GET_TABLE due to testfixture link error:

In function `test_get_table_printf':
./src/test1.c:526: undefined reference to `sqlite3_get_table'
./src/test1.c:541: undefined reference to `sqlite3_free_table'
collect2: ld returned 1 exit status
make: *** [testfixture] Error 1
 
2704 code active 2007 Oct anonymous   2007 Oct   4 4 "make test" aborts before completion with SQLITE_OMIT_BLOB_LITERAL edit
When compiled with -DSQLITE_OMIT_BLOB_LITERAL make test aborts with this error:

substr-2.5.2... Ok
./testfixture: near "'61626364656667'": syntax error
    while executing
"db eval "
    DELETE FROM t1;
    INSERT INTO t1(b) VALUES(x'$hex')
  ""
    (procedure "subblob-test" line 2)
    invoked from within
"subblob-test 3.1 61626364656667 1 1 61"
    (file "./test/substr.test" line 86)
    invoked from within
"source $testfile"
    ("foreach" body line 5)
    invoked from within
"foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
  set tail [file tail $testfile]
  if {[lsearch -exact $EXCLUDE $tail]>=0} continue
  if..."
    (file "./test/quick.test" line 93)
make: *** [test] Error 1
 
2703 code active 2007 Oct anonymous   2007 Oct   3 4 make test does not work with SQLITE_OMIT_FLOATING_POINT edit
make test cannot run with SQLITE_OMIT_FLOATING_POINT. Shouldn't these tests be skipped?

./src/test1.c:1255: warning: passing argument 3 of ‘Tcl_GetDouble’ from incompatible pointer type
./src/test1.c: In function ‘sqlite3_mprintf_scaled’:
./src/test1.c:1284: warning: passing argument 3 of ‘Tcl_GetDouble’ from incompatible pointer type
./src/test1.c: In function ‘test_bind_double’:
./src/test1.c:2607: warning: passing argument 3 of ‘Tcl_GetDoubleFromObj’ from incompatible pointer type
./src/tclsqlite.c: In function ‘tclSqlFunc’:
./src/tclsqlite.c:728: warning: passing argument 3 of ‘Tcl_GetDoubleFromObj’ from incompatible pointer type
./src/tclsqlite.c: In function ‘DbObjCmd’:
./src/tclsqlite.c:1609: warning: passing argument 3 of ‘Tcl_GetDoubleFromObj’ from incompatible pointer type

...

$ ./testfixture test/select1.test
select1-1.1... Ok
select1-1.2... Ok
select1-1.3... Ok
select1-1.4... Ok
select1-1.5... Ok
select1-1.6... Ok
select1-1.7... Ok
select1-1.8... Ok
select1-1.8.1... Ok
select1-1.8.2... Ok
select1-1.8.3... Ok
./testfixture: near ".": syntax error
    while executing
"db eval {INSERT INTO test2(r1,r2) VALUES(1.1,2.2)}"
    ("uplevel" body line 1)
    invoked from within
"uplevel [list $db eval $sql]"
    (procedure "execsql" line 3)
    invoked from within
"execsql {INSERT INTO test2(r1,r2) VALUES(1.1,2.2)}"
    (file "test/select1.test" line 69)
 
2684 code active 2007 Oct anonymous   2007 Oct   1 1 Accessing sqlite from an NT service will lock the complete databse. edit
Accessing sqlite from a NT service (application 1) will lock the complete database. Any other process trying to open an sqlite db (application 2) will get error "80004005 unable to lock database"

If application 1 runs as normal application, started by local user, this problem doesnt occur and both applications can open the db.

2007-Oct-02 15:48:05 by anonymous:
SQLite has no knowledge of Windows services. How do you propose to work around this Windows anachronism?


2007-Oct-02 17:20:38 by anonymous:
Suggesion: Try running the service in the same account as the other program that needs to access the database.

Anachronism? Service is just another word for daemon.

-knu-


2007-Oct-02 17:33:56 by anonymous:
Re: Anachronism, the OP suggested there was something fundamentally different about file access using a service. You've pointed out that it's just a file permissions issue.


2007-Oct-05 14:45:07 by drh:
Two points:

  1. The error message "80004005 unable to lock database" is not generated by SQLite. There must be some middleware someplace that is producing this message. The problem might be in that middleware and not in SQLite.

  2. None of the SQLite developers run windows. Consequently any fixes for this problem will need to come from the community. Please append patches to this ticket if you find a fix. Or close the ticket if you discover that the problem is outside of SQLite.
 
2674 code active 2007 Sep anonymous   2007 Sep   3 4 NFS fails without lock manager edit
Problem:

SQLite fails entirely if the NFS lock manager is not running on the share hosting the DB -- even when all access to the DB is serialized.

Under these circumstances, it becomes difficult to create applications that are capable of running in a multitude of environments because restrictions are now imposed upon the storage location.


Reproduction:

  • setup an NFS share
  • disable the lock manager
  • attempt to perform any transactions on a db on that share
  • start the lock manager
  • perform the same operations


Request:

  • Make a change to the error handling, as necessary, to allow processes to access a DB over an NFS share without use of a lock manager.

  • Make a big bold flashing sign in the FAQ about this failure-mode. The wording of the current FAQ led us to believe that the transaction would go through, but protection from other processes was not guaranteed.


Shameless Fanmail:

Love the product!


Screenshot:

  dev-srs08 ~ # <cmd>
  [__db_init <file>.c:384] Statement:
  CREATE TABLE
  versions (
    id       INTEGER PRIMARY KEY AUTOINCREMENT,
    version  INTEGER,
    tbl      CHAR(256)
  );
  Failed with error:
  database is locked
  [main <file>.c:1096] Unable to init output DB: /mnt/nfs/o
  dev-srs08 ~ # /etc/init.d/nfslock start
  Starting NFS statd:                                        [  OK  ]
  dev-srs08 ~ # <cmd>
  dev-srs08 ~ #
2007-Sep-28 04:35:00 by anonymous:
Yet another reason to avoid using SQLite on remote shares.


2007-Sep-29 18:04:19 by anonymous:
Make a change to the error handling, as necessary, to allow processes to access a DB over an NFS share without use of a lock manager.

By design the SQLite library guarantees ACID. It can't provide that without file locks. In my opinion a non-ACID version would be a custom version, which you can (should) build yourself. The source is available, or there might already be a compilation option to accomplish that.

Make a big bold flashing sign in the FAQ about this failure-mode. The wording of the current FAQ led us to believe that the transaction would go through, but protection from other processes was not guaranteed.

FAQ (5) "When any process wants to write, it must lock the entire database file for the duration of its update." seems to be quite clear.

-knu-

 
2671 code active 2007 Sep shess   2007 Sep shess 2 4 Fts field-based queries are not correctly case-insensitive. edit
  CREATE VIRTUAL TABLE t USING fts2(A, B);
  -- At the SQL level, things are case-insensitive:
  INSERT INTO t (A, b) VALUES ('Test', 'Columns');
  INSERT INTO T (a, B) VALUES ('Second', 'Test');
  -- Unfortunately, fts cannot do field-level queries:
  SELECT rowid FROM t WHERE t MATCH 'test';  -- works
  SELECT rowid FROM t WHERE b MATCH 'test';  -- works
  SELECT rowid FROM t WHERE t MATCH 'b:test';  -- no results
  SELECT rowid FROM t WHERE t MATCH 'B:test';  -- no results

It doesn't work because fts is keeping the column name as 'B', but the query parsing uses the results from the tokenizer, which are case-folded, and 'b' != 'B'.

I'm thinking on the solution. A quick fix would be to make the azColumn storage be lowercase, but the core problem is that field names probably shouldn't be run through the tokenizer in the first place.

 
2664 code active 2007 Sep danielk1977   2007 Sep   1 1 attaching the same db twice in shared-cache mode fails edit
The following SQL script can cause an assert() to fail in shared-cache mode.

  ATTACH 'db' AS aux1;
  ATTACH 'db' AS aux2;
  CREATE TABLE aux1.abc(a, b, c);
  CREATE TABLE aux2.abc(a, b, c);
See also #2653
 
2294 code active 2007 Apr anonymous   2007 Sep   2 1 segfault when destroying lock on WinCE with threads edit
DestroyLock emulation on WinCE platform releases the zDeleteOnClose file outside the mutex acquire section. This lead to frequent segfault when working with several databases concurrently.

Patch simply consists in moving code:

    if( pFile->zDeleteOnClose ){
      DeleteFileW(pFile->zDeleteOnClose);
      sqliteFree(pFile->zDeleteOnClose);
      pFile->zDeleteOnClose=NULL;
    }

from winClose() (os_win.c:980) to winceDestroyLock(), inside scope of winceMutexAcquire(pFile->hMutex):

    /* De-reference and close our copy of the shared memory handle */
    UnmapViewOfFile(pFile->shared);
    CloseHandle(pFile->hShared);

    + if( pFile->zDeleteOnClose ){
    +   DeleteFileW(pFile->zDeleteOnClose);
    +   sqliteFree(pFile->zDeleteOnClose);
    +   pFile->zDeleteOnClose=NULL;
    + }

    /* Done with the mutex */
    winceMutexRelease(pFile->hMutex);
    CloseHandle(pFile->hMutex);
    pFile->hMutex = NULL;
2007-Apr-13 00:21:33 by anonymous:
Check in [3836] fixes it for me. eTcl regression tests, related to running several sqlite database concurrently in several threads, are now passed while they were frequently segfaulting without it.

To help being confident with this blind commit, let's mention that exactly same patch has been introduced in eTcl built since a couple of monthes, to fix issue reported by WM2003 users, and all reported a correct fix. However, I did suggest the patch, so testing and feedback from others may help :-)

Also, note that [3836] has a typo, requesting feedback in ticket #2249 instead of #2294


2007-Sep-25 03:24:09 by anonymous:
The fix doesn't work and should be reverted. Temporary files do not create locks, so when they are closed and hMutex is null, the winceDestroyLock() file is never called and the temporary files are not cleaned up properly.
 
2652 code active 2007 Sep drh   2007 Sep   1 1 Aggregate function cannot be used from within a subquery edit
The following SQL fails:

   CREATE TABLE t1(x,y);
   INSERT INTO t1 VALUES(1,2);
   CREATE TABLE t2(z);
   INSERT INTO t2 VALUES(1);
   SELECT (SELECT y FROM t1 WHERE x=min(z)) FROM t2;

Problem reported on the mailing list.

2007-Sep-23 16:01:09 by anonymous:
Your syntax appears to be incorrect.

  SQLite v3.4.2
  CREATE TABLE t1(x,y);
  CREATE TABLE t2(z);
  INSERT INTO t1 VALUES(1,21);
  INSERT INTO t1 VALUES(2,22);
  INSERT INTO t1 VALUES(3,23);
  INSERT INTO t2 VALUES(3);
  INSERT INTO t2 VALUES(2);
  INSERT INTO t2 VALUES(1);

What you wanted to do:

  SELECT y FROM t1 WHERE x=(SELECT min(z) FROM t2);
  21    -- works as expected

What you did:

  SELECT (SELECT y FROM t1 WHERE x=min(z)) FROM t2;
  SQL error near line []: misuse of aggregate function min()
 
2539 code active 2007 Jul anonymous   2007 Sep   2 2 WinCE: Temporary etilqs_ files are not removed from temporary folder edit
Hi, when temporary etilqs_* files are created during SQLite work on Windows CE devices, they are not removed at all.

Temporary folder at CE devices: /Application Data/Volatile

I've research that it winClose(os_win.c) function has been changed at do not remove this file, assuming it to be removed at winceDestroyLock(os_win.c), so if no lock was happened then files will stay here forever.

Has fixed it in my local copy, with hope that it will be fixed when new cool versions of SQLite will be available.

My fix at os_win.c:

static int winClose(OsFile **pId){
  winFile *pFile;
  int rc = 1;
  if( pId && (pFile = (winFile*)*pId)!=0 ){
    int rc, cnt = 0;
    OSTRACE2("CLOSE %d\n", pFile->h);
    do{
      rc = CloseHandle(pFile->h);
    }while( rc==0 && cnt++ < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
#if OS_WINCE
    winceDestroyLock(pFile);
// fix begin
	if( pFile->zDeleteOnClose ){
		DeleteFileW(pFile->zDeleteOnClose);
		sqliteFree(pFile->zDeleteOnClose);
	}
// fix end
#endif
    OpenCounter(-1);
    sqliteFree(pFile);
    *pId = 0;
  }
  return rc ? SQLITE_OK : SQLITE_IOERR;
}
Thanks,

Fedor

2007-Jul-28 16:41:41 by anonymous:
The solution is to revert checkin 3836 and re-open ticket #2294.

Looking at the wince locking mechanism, the only time we ever use the zDeleteOnClose flag is when we've opened a database for exclusive access in sqlite3WinOpenExclusive. To save time and resources (and because its not necessary) we never bother creating a locking mechanism for exclusively-opened files. So pFile->hMutex is NULL when hitting winceDestroyLock(), and the file is never deleted.

Is it possible that the original poster of #2294 was trying to close the same connection on multiple threads at the same time?


2007-Jul-31 05:32:39 by anonymous:
This is actually a duplicate of #2533


2007-Sep-21 14:20:05 by anonymous:
So when the fix of [3836] was applied, the code to delete the file was only put in the section that is called when we have a mutex. I wonder, if the deletion of the file should also take place if there was no mutex. Works for me at least:

	static void winceDestroyLock(winFile *pFile){
	  if (pFile->hMutex){
	    /* Acquire the mutex */
	    winceMutexAcquire(pFile->hMutex);

	    /* The following blocks should probably assert in debug mode, but they
	       are to cleanup in case any locks remained open */
 	   if (pFile->local.nReaders){
 	     pFile->shared->nReaders --;
 	   }
 	   if (pFile->local.bReserved){
 	     pFile->shared->bReserved = FALSE;
 	   }
 	   if (pFile->local.bPending){
 	     pFile->shared->bPending = FALSE;
 	   }
 	   if (pFile->local.bExclusive){
 	     pFile->shared->bExclusive = FALSE;
 	   }

	    /* De-reference and close our copy of the shared memory handle */
	    UnmapViewOfFile(pFile->shared);
	    CloseHandle(pFile->hShared);

	*    if( pFile->zDeleteOnClose ){
 	*     DeleteFileW(pFile->zDeleteOnClose);
 	*     sqliteFree(pFile->zDeleteOnClose);
 	*     pFile->zDeleteOnClose = 0;
 	*   }

	    /* Done with the mutex */
	    winceMutexRelease(pFile->hMutex);
	    CloseHandle(pFile->hMutex);
	    pFile->hMutex = NULL;
	  }
	+ else
	+ {
	+   if( pFile->zDeleteOnClose ){
	+      DeleteFileW(pFile->zDeleteOnClose);
	+      sqliteFree(pFile->zDeleteOnClose);
	+      pFile->zDeleteOnClose = 0;
	+    }
	+  }
	}

The code marked with * was put there in

 
2653 code active 2007 Sep anonymous   2007 Sep   3 4 Exclusive Transactions do not work with a Database File attached twice edit
Regarding the docs, it is possible to attach the same database file multiple times.

After doing so, I wanted to begin an exclusive transaction. Unfortunately, this fails ("database is locked") and surprises me as I did not find any notice on this particular situation and possible side-effects neither in the attach nor in the transaction/locking documentation.

If this behaviour is seen as an error, It would be useful to have it error fixed, because if one reads a list of (possibly duplicate) database files but with unique identifiers, it would be helpful to use these defined identifiers when accessing the databases (and that in an exclusive transaction).

Real-world case: Each "module" uses its own database file. Some modules share a database file. So there is a list of module -> database file assignments. Now an update process gets some database update scripts from the modules. Every module wants its changes to be done in the right database, so it relies on having its own database attached with an unique identifier - the module's name. On the other hand, the update process need exclusive access to the databases and starts a transaction -- bummer.

 
2627 code active 2007 Sep anonymous   2007 Sep   3 2 Improper parsing of nested JOIN edit
SQLite has a problem with multiple nested JOINs. The only way to get it workig is to remove the surrounding brackets. Removing the brackets unfortunately do not work in other DB systems such as MS SQL, mysql etc.

This does not work:

Select ContactPhone.* From (ContactPhone LEFT OUTER JOIN ContactLocation ON ContactPhone.PHNLCT_ID = ContactLocation.LCT_ID) LEFT OUTER JOIN ContactItem ON ContactLocation.LCTITM_ID = ContactItem.ITM_ID

(It complains about LCT_ID or similar)

This works after removing the brackets:

Select ContactPhone.* From ContactPhone LEFT OUTER JOIN ContactLocation ON ContactPhone.PHNLCT_ID = ContactLocation.LCT_ID LEFT OUTER JOIN ContactItem ON ContactLocation.LCTITM_ID = ContactItem.ITM_ID

All other major DB systems require the surrounding brackets. Do you think it is possible to fix it? Apart from this little little SQLite is an awesome project.

Thank you Jakub Klos

2007-Sep-06 13:07:32 by anonymous:
I don't have access to MS SQL Server, but MySQL and Oracle have no issue with the query without parentheses:

create table x1(a int, b int);
create table x2(c int, d int);
create table x3(e int, f int);

mysql> select x1.* from x1 left join x2 on x1.a=x2.c left join x3 on x2.d=x3.e;
Empty set (0.00 sec)

2007-Sep-06 19:03:33 by anonymous:
MSSQL also has no problems without the parens. As a matter of fact, the only DB that I know of that requires them is MS Access (JET).


2007-Sep-06 20:11:31 by anonymous:
I guess he had no luck filing a JET bug.


2007-Sep-11 17:22:28 by anonymous:
True, MS access requires the parens but all other major DBs support the query syntax with the parens. So why SQLite does not like it? It should simply ignore them if possible. Thank you
 
2634 code active 2007 Sep anonymous   2007 Sep   3 3 .schema uses incorrect ORDER BY giving wrong dependency order edit
When the schema is exported, views are sorted by name instead of by dependency. If there are nested views, the schema may be invalid when used to re-create the database.

  sqlite3
  create table t ( f text );
  create view v2 as select f from t;
  create view v1 as select f from v2;
  .output test.txt
  .schema
  .exit

  sqlite3
  .read test.txt
  SQL error near line 2: no such table: main.v2
2007-Sep-07 15:33:06 by anonymous:
Use .dump instead as a workaround. Unlike .schema, .dump does not use ORDER BY in its queries on sqlite_master and it outputs its rows in order of entry.

SQLite version 3.5.0
Enter ".help" for instructions
sqlite> create table t ( f text );
sqlite> create view v2 as select f from t;
sqlite> create view v1 as select f from v2;
sqlite>
sqlite> .schema
CREATE TABLE t ( f text );
CREATE VIEW v1 as select f from v2;
CREATE VIEW v2 as select f from t;
sqlite>
sqlite> .dump
BEGIN TRANSACTION;
CREATE TABLE t ( f text );
CREATE VIEW v2 as select f from t;
CREATE VIEW v1 as select f from v2;
COMMIT;
Suggested patch:

Index: src/shell.c
===================================================================
RCS file: /sqlite/sqlite/src/shell.c,v
retrieving revision 1.167
diff -u -3 -p -r1.167 shell.c
--- src/shell.c 7 Sep 2007 01:12:32 -0000       1.167
+++ src/shell.c 7 Sep 2007 15:28:24 -0000
@@ -1411,8 +1411,7 @@ static int do_meta_command(char *zLine,
           "SELECT sql FROM "
           "  (SELECT * FROM sqlite_master UNION ALL"
           "   SELECT * FROM sqlite_temp_master) "
-          "WHERE tbl_name LIKE shellstatic() AND type!='meta' AND sql NOTNULL "
-          "ORDER BY substr(type,2,1), name",
+          "WHERE tbl_name LIKE shellstatic() AND type!='meta' AND sql NOTNULL",
           callback, &data, &zErrMsg);
         zShellStatic = 0;
       }
@@ -1421,8 +1420,7 @@ static int do_meta_command(char *zLine,
          "SELECT sql FROM "
          "  (SELECT * FROM sqlite_master UNION ALL"
          "   SELECT * FROM sqlite_temp_master) "
-         "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'"
-         "ORDER BY substr(type,2,1), name",
+         "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'",
          callback, &data, &zErrMsg
       );
     }
after patch:

SQLite version 3.5.0
Enter ".help" for instructions
sqlite>  create table t ( f text );
sqlite>   create view v2 as select f from t;
sqlite>   create view v1 as select f from v2;
sqlite> .schema
CREATE TABLE t ( f text );
CREATE VIEW v2 as select f from t;
CREATE VIEW v1 as select f from v2;
sqlite> .q
 
2559 code active 2007 Aug anonymous   2007 Aug   4 4 "make clean" does not delete sqlite3.c and tsrc/ edit
Index: Makefile.in
===================================================================
RCS file: /sqlite/sqlite/Makefile.in,v
retrieving revision 1.179
diff -u -3 -p -r1.179 Makefile.in
--- Makefile.in 27 Aug 2007 23:38:43 -0000      1.179
+++ Makefile.in 28 Aug 2007 01:25:55 -0000
@@ -724,7 +724,7 @@ clean:
        rm -f testfixture$(TEXE) test.db
        rm -rf doc
        rm -f common.tcl
-       rm -f sqlite3.dll sqlite3.lib sqlite3.def
+       rm -rf sqlite3.dll sqlite3.lib sqlite3.def sqlite3.c tsrc

 distclean:     clean
        rm -f config.log config.status libtool Makefile config.h sqlite3.pc
 
1242 code active 2005 May anonymous Shell 2007 Aug   3 4 EXPLAIN causes segmentation fault on OSX (and linux) edit
Under Mac OS X, EXPLAIN causes a segmentation fault:

  [jacob@046] ~$ sqlite3 foo.db
  SQLite version 3.2.1
  Enter ".help" for instructions
  sqlite> CREATE TABLE test (a int, b int);
  sqlite> EXPLAIN SELECT * FROM test;
  Segmentation fault

The crash dump follows:

    Host Name:      jacobian
    Date/Time:      2005-05-13 09:17:04.860 -0500
    OS Version:     10.4 (Build 8A428)
    Report Version: 3

    Command: sqlite3
    Path:    /usr/local/bin/sqlite3
    Parent:  bash [15421]

    Version: ??? (???)

    PID:    15544
    Thread: 0

    Exception:  EXC_BAD_ACCESS (0x0001)
    Codes:      KERN_INVALID_ADDRESS (0x0001) at 0x1400fffc

    Thread 0 Crashed:
    0   libSystem.B.dylib  	0x90003228 strlen + 8
    1   libsqlite3.0.dylib 	0x002387c8 sqlite3VdbeList + 284 (vdbeaux.c:609)
    2   libsqlite3.0.dylib 	0x002376e0 sqlite3_step + 312 (vdbeapi.c:207)
    3   libsqlite3.0.dylib 	0x0023e5d8 sqlite3_exec + 260 (legacy.c:82)
    4   sqlite3            	0x00005b64 process_input + 808 (shell.c:1504)
    5   sqlite3            	0x000062bc main + 1528 (shell.c:1790)
    6   sqlite3            	0x00001db4 _start + 348 (crt.c:272)
    7   sqlite3            	0x00001c54 start + 60

    Thread 0 crashed with PPC Thread State:
      srr0: 0x90003228 srr1: 0x0000d030                vrsave: 0x00000000
        cr: 0x22444428  xer: 0x00000006   lr: 0x002387c8  ctr: 0x90003220
        r0: 0x002387c8   r1: 0xbfffef40   r2: 0x00249a00   r3: 0x1400fffe
        r4: 0x00000028   r5: 0x00000000   r6: 0x00000001   r7: 0xffffffff
        r8: 0x00000001   r9: 0x1400fffc  r10: 0x00000086  r11: 0x00249180
       r12: 0x90003220  r13: 0x00000000  r14: 0x00000000  r15: 0x00000000
       r16: 0x00000000  r17: 0xbffff0f8  r18: 0x00000000  r19: 0xbffff17c
       r20: 0x00000000  r21: 0x000036d0  r22: 0x00303d90  r23: 0x00303d74
       r24: 0x01805700  r25: 0x01807e00  r26: 0x00000001  r27: 0x00000004
       r28: 0x01805640  r29: 0x01805600  r30: 0x01805200  r31: 0x002386bc

    Binary Images Description:
        0x1000 -     0x7fff sqlite3 	/usr/local/bin/sqlite3
      0x205000 -   0x248fff libsqlite3.0.dylib 	/usr/local/lib/libsqlite3.0.dylib
    0x8fe00000 - 0x8fe50fff dyld 43	/usr/lib/dyld
    0x90000000 - 0x901a6fff libSystem.B.dylib 	/usr/lib/libSystem.B.dylib
    0x901fe000 - 0x90202fff libmathCommon.A.dylib 	/usr/lib/system/libmathCommon.A.dylib
    0x91d33000 - 0x91d53fff libmx.A.dylib 	/usr/lib/libmx.A.dylib
    0x9680c000 - 0x9683afff libncurses.5.4.dylib 	/usr/lib/libncurses.5.4.dylib
    0x969a3000 - 0x969b9fff libedit.2.dylib 	/usr/lib/libedit.2.dylib
Happening to me as well on FC6 sqlite3 version 3.3.6


2007-Aug-21 17:09:34 by anonymous:
Try to upgrade to 3.4.2.
 
2580 code active 2007 Aug anonymous   2007 Aug anonymous 1 2 Can't open a query if text to search is Greek edit
for example:

SELECT * FROM mytable WHERE mycolumn LIKE '%some greek text%'

I get wrong results, using the 3.4.2 version. No problem instead using other earlier version. I tested only in Windows.

 
2558 code active 2007 Aug anonymous   2007 Aug   2 3 Multiple JOIN USING() gives incorrect results edit
I'm having a problem joining multiple tables with USING. It appears to work, but the results are incorrect. Here is an example to illustrate the problem. I believe the three SELECT statements should be equivalent, but they produce three different results.

  .header on
  .mode column

  CREATE TABLE Main (pk INTEGER PRIMARY KEY, name VARCHAR);
  CREATE TABLE OptA (pk INTEGER PRIMARY KEY, alpha VARCHAR);
  CREATE TABLE OptB (pk INTEGER PRIMARY KEY, beta VARCHAR);

  INSERT INTO Main VALUES (1, 'One');
  INSERT INTO Main VALUES (2, 'Two');
  INSERT INTO Main VALUES (3, 'Three');
  INSERT INTO Main VALUES (4, 'Four');

  INSERT INTO OptA VALUES (1, 'Alpha1');
  INSERT INTO OptA VALUES (4, 'Alpha4');

  INSERT INTO OptB VALUES (2, 'Beta2');
  INSERT INTO OptB VALUES (4, 'Beta4');

  SELECT * FROM Main LEFT JOIN OptA USING (pk) LEFT JOIN OptB USING (pk);

  SELECT * FROM Main LEFT JOIN OptB USING (pk) LEFT JOIN OptA USING (pk);

  SELECT Main.pk, name, alpha, beta
    FROM Main LEFT JOIN OptA ON Main.pk = OptA.pk
              LEFT JOIN OptB ON Main.pk = OptB.pk;

Joining Main, OptA, and OptB omits Beta2:

  pk          name        alpha       beta
  ----------  ----------  ----------  ----------
  1           One         Alpha1
  2           Two
  3           Three
  4           Four        Alpha4      Beta4

Joining Main, OptB, and OptA omits Alpha1:

  pk          name        beta        alpha
  ----------  ----------  ----------  ----------
  1           One
  2           Two         Beta2
  3           Three
  4           Four        Beta4       Alpha4

Only by using ON instead of USING do we get the correct results:

  pk          name        alpha       beta
  ----------  ----------  ----------  ----------
  1           One         Alpha1
  2           Two                     Beta2
  3           Three
  4           Four        Alpha4      Beta4

I think this is basically the same issue as ticket #1637, but it's a more serious example. In that one, the query simply failed to compile. In this case, it seems to work, but gives you the wrong results.

I've also tried this script in PostgreSQL 8.0.13. All three queries give (the same) correct results.

2007-Aug-08 17:34:27 by anonymous:
The problem is that SQLite is transforming

  SELECT * FROM Main LEFT JOIN OptA USING (pk) LEFT JOIN OptB USING (pk);

into

  SELECT Main.pk, name, alpha, beta
    FROM Main LEFT JOIN OptA ON Main.pk = OptA.pk
              LEFT JOIN OptB ON OptA.pk = OptB.pk;

Here is a workaround to this bug that makes use of a subquery:

  select * from (SELECT * FROM Main LEFT JOIN OptA USING (pk))
    LEFT JOIN OptB USING (pk);

Conceivably all LEFT JOIN chains could be transformed into the above form, but that would decrease performance due to the intermediate result set of the subquery. Having it work without the subquery is tricky since sqlite must deduce that the last USING (pk) is equivalent to the first pk in the chain of joined tables, namely Main.pk, and not OptA.pk.

Joe Wilson

 
2547 code active 2007 Aug danielk1977   2007 Aug   5 3 Changing db encoding of an attached db can confuse shared cache mode. edit
This is quite obscure, but in shared-cache mode:

  1) Open db A, attach empty db B.
  2) Using another connection from the same thread, set the
     encoding of B to be different from that of A. Add some
     data to B.
  3) Using the original connection, access database B. It assumes
     the encoding of A (and therefore mangling any text data).

The correct response is to return an error - "attached databases must use the same text encoding as main database".

 
2545 code active 2007 Jul anonymous   2007 Jul   1 4 Group by returns table name with field name edit
imaginate a table:
create table test (
id INTEGER PRIMARY KEY,
name varchar(50) not null,
age integer not null
);

Then:

insert into test (name,age) values ('foo',22);
insert into test (name,age) values ('foo',23);
insert into test (name,age) values ('bar',22);
insert into test (name,age) values ('bar',35);
insert into test (name,age) values ('bar',72);

Now try this;

sqlite> .headers on
sqlite> select test.name, test.age from test order by name;
name|age
bar|22
bar|35
bar|72
foo|22
foo|23
sqlite> select test.name, test.age from test group by name;
test.name|test.age
bar|72
foo|23

You see ? if i use "GROUP BY", the field name contains tablename. Because i use "SELECT test.name" and not "SELECT name".

If i set an alias, i get alias, that's ok.

The trouble appears to be very high on Copix (http://wwW.copix.org). We create some DAO (Data Access Objects) automatically. The "groupBy" method doesn't works with SQLite...

Is this normal ? Mysql, PostgreSql, Oracle... doesn't need to create alias.

2007-Jul-31 15:54:52 by anonymous:
There's probably 4 other tickets reporting this. I don't think it will get fixed. The workaround is to use aliases (AS "whatever") for the selected columns.


2007-Jul-31 23:02:19 by anonymous:
Ok, we have created a special support for SQLite.

PS: I love this database :) Simple, nice, usefull, quick and easy

Regards

 
2543 code active 2007 Jul anonymous   2007 Jul   1 1 Chinese charset not support?? edit
when i create a table. the table name is " " (chinese) after this "alter table   add column aaa text null" error why??/ thank you
 
2540 code active 2007 Jul anonymous   2007 Jul   5 4 Display dlopen() errors for errors when loading modules on Unix system edit
If there is an error loading a module the message "unable to open shared library..." is displayed. In the Unix world the dlopen() error could be display to help diagnose the problem (e.g. missing external refs, etc). I have implemented it in our install of SQLite, I'm sure there is a Windows analog. Here is the patch for loadext.c.

- Chris - Christopher Hailey Sr. Software Engineer Maxim Systems

   ::::::::::::::
   loadext.c.patch
   ::::::::::::::
   *** ./src/loadext.c.orig        2007-07-22 00:11:35.000000000 -0700
   --- ./src/loadext.c     2007-07-22 00:12:07.000000000 -0700
   ***************
   *** 292,298 ****
       handle = sqlite3OsDlopen(zFile);
       if( handle==0 ){
         if( pzErrMsg ){
   !       *pzErrMsg = sqlite3_mprintf("unable to open shared library [%s]", zFile);
         }
         return SQLITE_ERROR;
       }
   --- 292,298 ----
       handle = sqlite3OsDlopen(zFile);
       if( handle==0 ){
         if( pzErrMsg ){
   !       *pzErrMsg = sqlite3_mprintf("unable to open shared library [%s]: %s", zFile,dlerror());
         }
         return SQLITE_ERROR;
 
2530 code active 2007 Jul anonymous   2007 Jul   2 3 Unable to write to windows share, even with exclusive lock edit
It has been mentioned that the file locking does not work on windows shared network drives (Samba or SMB drives from Windows or Linux). It seems that an exclusive lock should be a workaround for this problem if you need to write to a shared drive. Currently a more complicated locking is being attempted and failing on network drives.

With an exclusive lock, SQLite could resort to simply holding a open write or append enabled file handle to the database as a more primitive locking system that is more likely to work on network drive. No other process could open the database but that would be expected with an exclusive lock. The following case should then function:

  grudy@gamma:~$ mount | grep Files
  //winserver/FileDump on /mnt/Files type cifs (rw,mand,noexec,nosuid,nodev)
  grudy@gamma:~$ touch /mnt/Files/i_have_write_permissions.txt; rm /mnt/Files/i_have_write_permissions.txt
  grudy@gamma:~$ sqlite3 /mnt/Files/foo.sqlite
  SQLite version 3.3.17
  Enter ".help" for instructions
  sqlite> PRAGMA locking_mode = EXCLUSIVE;
  exclusive
  sqlite> create table bar (foobar);
  SQL error: database is locked
  sqlite>
 
2517 code active 2007 Jul anonymous   2007 Jul dflam 1 1 exception on reading text in vista but not xp edit
My companies sqlite 3.1 db works perfectly on Win XP but when we moved to Vista (I'm using Vista 64)it is trowing an exception when I access a text field that contains this data:

'A/C Pressure Sensor, raw1 = A/C on, 0 = A/C off (A/C status determines which IACTx cell is used)'

Interestingly when I view data I've inserted using sqliteman3 it has unprintable characters added to it.

(A/C status determines which IACTx cell is used)9

If I define the field as Char[512] this artifact goes away. But reading your literature this isn't supposed to make a difference because everything is char.

I've changed the values in the error column, but the error seems to be depending on length rather than value.

Any help appreciatied!

Jim

2007-Jul-19 15:13:41 by drh:
We will be better able to help you with your problem on the SQLite mailing list. See http://www.sqlite.org/support.html for instructions on joining the mailing list.
 
2510 code active 2007 Jul anonymous   2007 Jul   1 1 Vacuum modified FTS2 rowids edit
VACUUM modifies FTS2 rowids. Here is the test:

  drop table if exists a;

  create virtual table a using fts2 (t);

  insert into a (t) values ('one');
  insert into a (t) values ('two');
  insert into a (t) values ('three');

  select rowid, * from a;

  delete from a where t = 'two';
  vacuum;

  select rowid, * from a;

Unfortunately there is no workaround since table a is auto-generated by the FTS2 module.

2007-Jul-17 14:05:58 by anonymous:
http://www.sqlite.org/cvstrac/chngview?cn=4157


2007-Jul-17 14:24:29 by anonymous:
Yes, this behavior has been recently documented, but there is no user workaround like PRIMARY KEY for FTS2 rowids. Therefore I consider this as a bug which should be fixed in fts2.c.


2007-Jul-17 14:55:57 by anonymous:
Should virtual tables be VACUUMable? What exactly is being vacuumed here - an internal table?


2007-Jul-17 16:34:55 by shess:
I agree, I think this is a bug. Rather severe, too, the entire fts system implicitely depends on rowids not changing, this means that vacuum will break fts tables (fts1 or fts2).

drop table if exists t;
create virtual table t using fts2;
insert into t (content) values ('This is a test');
insert into t (content) values ('This is a string');
insert into t (content) values ('That was a test');
insert into t (content) values ('A random string');
select content from t where t MATCH 'test';
delete from t where content = 'This is a string';
vacuum;
select content from t where t MATCH 'test';
The first select outputs 'This is a test' and 'That was a test'. The second select outputs 'This is a test', and 'A random string'.


2007-Jul-17 17:27:21 by anonymous:
This patch seems to address the FTS2 VACUUM problem and passes all fts2 tests.

It adds an INTEGER PRIMARY KEY docid column to the hidden %_content table.

Note: this new table format is not backwards compatible with existing FTS2 databases.

-Joe Wilson

Index: ext/fts2/fts2.c
===================================================================
RCS file: /sqlite/sqlite/ext/fts2/fts2.c,v
retrieving revision 1.40
diff -u -3 -p -r1.40 fts2.c
--- ext/fts2/fts2.c	2 Jul 2007 10:16:50 -0000	1.40
+++ ext/fts2/fts2.c	17 Jul 2007 17:19:49 -0000
@@ -1769,9 +1769,9 @@ typedef enum fulltext_statement {
 */
 static const char *const fulltext_zStatement[MAX_STMT] = {
   /* CONTENT_INSERT */ NULL,  /* generated in contentInsertStatement() */
-  /* CONTENT_SELECT */ "select * from %_content where rowid = ?",
+  /* CONTENT_SELECT */ "select * from %_content where docid = ?",
   /* CONTENT_UPDATE */ NULL,  /* generated in contentUpdateStatement() */
-  /* CONTENT_DELETE */ "delete from %_content where rowid = ?",
+  /* CONTENT_DELETE */ "delete from %_content where docid = ?",

   /* BLOCK_INSERT */ "insert into %_segments values (?)",
   /* BLOCK_SELECT */ "select block from %_segments where rowid = ?",
@@ -1860,14 +1860,14 @@ static struct fulltext_vtab *cursor_vtab
 static const sqlite3_module fts2Module;   /* forward declaration */

 /* Return a dynamically generated statement of the form
- *   insert into %_content (rowid, ...) values (?, ...)
+ *   insert into %_content (docid, ...) values (?, ...)
  */
 static const char *contentInsertStatement(fulltext_vtab *v){
   StringBuffer sb;
   int i;

   initStringBuffer(&sb);
-  append(&sb, "insert into %_content (rowid, ");
+  append(&sb, "insert into %_content (docid, ");
   appendList(&sb, v->nColumn, v->azContentColumn);
   append(&sb, ") values (?");
   for(i=0; i<v->nColumn; ++i)
@@ -1878,7 +1878,7 @@ static const char *contentInsertStatemen

 /* Return a dynamically generated statement of the form
  *   update %_content set [col_0] = ?, [col_1] = ?, ...
- *                    where rowid = ?
+ *                    where docid = ?
  */
 static const char *contentUpdateStatement(fulltext_vtab *v){
   StringBuffer sb;
@@ -1893,7 +1893,7 @@ static const char *contentUpdateStatemen
     append(&sb, v->azContentColumn[i]);
     append(&sb, " = ?");
   }
-  append(&sb, " where rowid = ?");
+  append(&sb, " where docid = ?");
   return stringBufferData(&sb);
 }

@@ -2027,15 +2027,15 @@ static int sql_step_leaf_statement(fullt
   return rc;
 }

-/* insert into %_content (rowid, ...) values ([rowid], [pValues]) */
-static int content_insert(fulltext_vtab *v, sqlite3_value *rowid,
+/* insert into %_content (docid, ...) values ([docid], [pValues]) */
+static int content_insert(fulltext_vtab *v, sqlite3_value *docid,
                           sqlite3_value **pValues){
   sqlite3_stmt *s;
   int i;
   int rc = sql_get_statement(v, CONTENT_INSERT_STMT, &s);
   if( rc!=SQLITE_OK ) return rc;

-  rc = sqlite3_bind_value(s, 1, rowid);
+  rc = sqlite3_bind_value(s, 1, docid);
   if( rc!=SQLITE_OK ) return rc;

   for(i=0; i<v->nColumn; ++i){
@@ -2047,7 +2047,7 @@ static int content_insert(fulltext_vtab
 }

 /* update %_content set col0 = pValues[0], col1 = pValues[1], ...
- *                  where rowid = [iRowid] */
+ *                  where docid = [iRowid] */
 static int content_update(fulltext_vtab *v, sqlite3_value **pValues,
                           sqlite_int64 iRowid){
   sqlite3_stmt *s;
@@ -2075,7 +2075,7 @@ static void freeStringArray(int nString,
   free((void *) pString);
 }

-/* select * from %_content where rowid = [iRow]
+/* select * from %_content where docid = [iRow]
  * The caller must delete the returned array and all strings in it.
  * null fields will be NULL in the returned array.
  *
@@ -2101,10 +2101,10 @@ static int content_select(fulltext_vtab

   values = (const char **) malloc(v->nColumn * sizeof(const char *));
   for(i=0; i<v->nColumn; ++i){
-    if( sqlite3_column_type(s, i)==SQLITE_NULL ){
+    if( sqlite3_column_type(s, i+1)==SQLITE_NULL ){
       values[i] = NULL;
     }else{
-      values[i] = string_dup((char*)sqlite3_column_text(s, i));
+      values[i] = string_dup((char*)sqlite3_column_text(s, i+1));
     }
   }

@@ -2120,7 +2120,7 @@ static int content_select(fulltext_vtab
   return rc;
 }

-/* delete from %_content where rowid = [iRow ] */
+/* delete from %_content where docid = [iRow ] */
 static int content_delete(fulltext_vtab *v, sqlite_int64 iRow){
   sqlite3_stmt *s;
   int rc = sql_get_statement(v, CONTENT_DELETE_STMT, &s);
@@ -2870,7 +2870,7 @@ static int fulltextCreate(sqlite3 *db, v
   if( rc!=SQLITE_OK ) return rc;

   initStringBuffer(&schema);
-  append(&schema, "CREATE TABLE %_content(");
+  append(&schema, "CREATE TABLE %_content(docid INTEGER PRIMARY KEY, ");
   appendList(&schema, spec.nColumn, spec.azContentColumn);
   append(&schema, ")");
   rc = sql_exec(db, spec.zDb, spec.zName, stringBufferData(&schema));
@@ -3731,8 +3731,8 @@ static int fulltextFilter(

   TRACE(("FTS2 Filter %p\n",pCursor));

-  zSql = sqlite3_mprintf("select rowid, * from %%_content %s",
-                          idxNum==QUERY_GENERIC ? "" : "where rowid=?");
+  zSql = sqlite3_mprintf("select * from %%_content %s",
+                          idxNum==QUERY_GENERIC ? "" : "where docid=?");
   sqlite3_finalize(c->pStmt);
   rc = sql_prepare(v->db, v->zDb, v->zName, &c->pStmt, zSql);
   sqlite3_free(zSql);

2007-Jul-18 00:13:56 by shess:
BTW, AFAICT this only happens for sqlite3.4. Older versions don't seem to have the problem.


2007-Jul-18 01:31:49 by anonymous:
The rowid changing after VACUUM predates 3.4.0...

SQLite version 3.3.7
Enter ".help" for instructions
sqlite> CREATE TABLE t(a);
sqlite> INSERT INTO "t" VALUES('one');
sqlite> INSERT INTO "t" VALUES('two');
sqlite> INSERT INTO "t" VALUES('three');
sqlite> select rowid, * from t;
1|one
2|two
3|three
sqlite> delete from t where a = 'one';
sqlite> select rowid, * from t;
2|two
3|three
sqlite> vacuum;
sqlite> select rowid, * from t;
1|two
2|three

SQLite version 3.2.0
Enter ".help" for instructions
sqlite> CREATE TABLE t(a);
sqlite> INSERT INTO "t" VALUES('one');
sqlite> INSERT INTO "t" VALUES('two');
sqlite> INSERT INTO "t" VALUES('three');
sqlite> select rowid, * from t;
1|one
2|two
3|three
sqlite> delete from t where a = 'one';
sqlite> select rowid, * from t;
2|two
3|three
sqlite> vacuum;
sqlite> select rowid, * from t;
1|two
2|three

2007-Jul-18 15:59:24 by anonymous:
As you may know, INTEGER PRIMARY KEY indexes are the ROWID, so I must supect they would change after a VACUUM.

The best workaround is to put docid as INTEGER, then adding a PRIMARY KEY index for the docid column.

 
2503 code active 2007 Jul anonymous   2007 Jul   3 4 sqlite3PagerReleaseMemory does not decrement page count edit
When cached pages are released by sqlite3PagerReleaseMemory the number of pages (pPager->nPage) is not decremented. This also subsequently affects the maximum value at pPager->nMaxPage.

This does not affect the operation of sqlite (but does upset my statistic gathering).

Although only tested with 3.3.8, the problem does not appear to have been corrected in version 3.4.0

Actually this will affect the handling of cache_size as the pager will think there are more pages cached than is the case, and may unnecessarily release some.


2007-Jul-18 15:54:29 by anonymous:
Do you have a simple test case that demonstrates this? Put a print statement in pager.c if necessary.
 
2512 code active 2007 Jul shess   2007 Jul   1 1 FTS virtual table name quoting problem edit
All table names should be quoted in the FTS module code.

with TRACE enabled in ext/fts2/fts2.c:

sqlite> create virtual table "a b c" using fts2 (t);
FTS2 Create
FTS2 sql: CREATE TABLE main.a b c_content(c0t)
SQL error: vtable constructor failed: a b c
2007-Jul-18 06:44:21 by anonymous:
A similar problem shows if a FTS column has the same name as the FTS table:

  CREATE VIRTUAL TABLE a USING fts2 (a);

Returns "vtable constructor failed: a.".

 
2511 code active 2007 Jul anonymous   2007 Jul drh 3 2 Inconsistent Pragma output edit
Pragma output is inconsistent when setting the value. Most do not generate any output and silently set the value, while others generate a singleton row with the set value. Here is a list of pragmas that generate output while setting the values:

sqlite> PRAGMA locking_mode = NORMAL; normal sqlite> PRAGMA max_page_count = 100000; 100000

The following do not generate any output upon query: PRAGMA case_sensitive_like; PRAGMA incremental_vacuum;

Sqlite was built from almagamation using the following configuration flags: --enable-threadsafe --disable-tcl --enable-tempstore

 
2509 code active 2007 Jul anonymous   2007 Jul   1 1 SQLITE_DATE edit
SELECT CAST(MyDate AS DATE), CAST(MyTime AS TIME) FROM MyData

I hope, it will result/return DATE, TIME. Please support to SQLITE_DATE and SQLITE_TIME. Thanks.

 
2498 code active 2007 Jul anonymous   2007 Jul   3 2 sqlite memory org on linux edit
(related ticket #2473)... he sample programme that I run(wrote) in tty1 and there I operate the command of ps at tty2, there seems two items from the programme of ps command. This error was not at the version 3.3.13 but now it is happening at sqlite versions although i change nothing from the programme, If I turn to old versions, there is seen only one item again. When I upgrade to version 3.3.13 or later, there is seen two items again Is it normal or there is any mistake? (excuse my poor english)
2007-Jul-11 16:44:22 by anonymous:
So you are seeing 2 processes instead of 1 on Linux? Linux 2.4 and earlier kernels show threads as seperate processes with unique process IDs. Is your program creating any threads?

The only place where SQLite creates threads is the function below - but it joins with the thread right away.

/*
** This procedure attempts to determine whether or not threads
** can override each others locks then sets the
** threadsOverrideEachOthersLocks variable appropriately.
*/
static void testThreadLockingBehavior(int fd_orig){
  int fd;
  struct threadTestData d[2];
  pthread_t t[2];

  fd = dup(fd_orig);
  if( fd<0 ) return;
  memset(d, 0, sizeof(d));
  d[0].fd = fd;
  d[0].lock.l_type = F_RDLCK;
  d[0].lock.l_len = 1;
  d[0].lock.l_start = 0;
  d[0].lock.l_whence = SEEK_SET;
  d[1] = d[0];
  d[1].lock.l_type = F_WRLCK;
  pthread_create(&t[0], 0, threadLockingTest, &d[0]);
  pthread_create(&t[1], 0, threadLockingTest, &d[1]);
  pthread_join(t[0], 0);
  pthread_join(t[1], 0);
  close(fd);
  threadsOverrideEachOthersLocks =  d[0].result==0 && d[1].result==0;
}
If you post a small C program demonstrating what you're seeing, someone may be able to offer a suggestion.


2007-Jul-11 16:47:10 by anonymous:
I suppose it's not inconceivable that the join failed. Perhaps these pthread_join calls' return codes should be examined for errors.


2007-Jul-11 18:53:36 by anonymous:
If you're playing games with tty's and you've got an early Linux 2.6 kernel, it's possible that processes are dying because of http://lkml.org/lkml/2004/10/21/119. It was, last I checked, fixed in 2.6.10.

The SIGHUP being generated might also interfer with a pthread_join(), although pthread_join() doesn't say anything about ever generating EINTR...

c.


2007-Jul-12 06:12:28 by anonymous:
my example program is very simple, i not use threading-multithreading structure... If I turn to old versions of sqlite, there is seen only one item again, when I upgrade to version 3.3.13 or later, there is seen two items again Is it.

note: /lib/libpthread.so.0 linked to /lib/libpthread-0.10.so (size 55468 byte)


2007-Jul-12 11:36:37 by anonymous:
Your description of the problem isn't clear enough, so the answers you're getting are just guesses.

You may have more luck by describing the problem (with as much detail as possible) in your native language and hoping someone in the SQLite community can add a translation. I know you're doing your best with the english you speak, but it's not working well enough for someone to help with your problem.

Adding code samples and command-line output would also help considerably, since that sort of this is mostly language independent.

 
2496 code active 2007 Jul anonymous   2007 Jul   5 4 "No such column" error should include table information edit
It'd be nice if the "no such column" error included the table/view that SQLite was searching for the column.

no such column: ChecklistID

Thanks,

Sam

 
2491 code active 2007 Jul anonymous   2007 Jul   1 1 Mingw Warnings w/ 3.4.0 Amalgamation edit
When compiling the 3.4.0 amalgamation sqlite3.c file w/ no defines, you get the following warnings:

sqlite3/sqlite3.c: In function `sqlite3BtreeFindCell':
sqlite3/sqlite3.c:23249: warning: unused variable `data'
sqlite3/sqlite3.c: In function `vxprintf':
sqlite3/sqlite3.c:8488: warning: 'xtype' might be used uninitialized in this function
sqlite3/sqlite3.c: In function `sqlite3BtreeOpen':
sqlite3/sqlite3.c:19488: warning: 'nameLen' might be used uninitialized in this function
sqlite3/sqlite3.c: In function `getOverflowPage':
sqlite3/sqlite3.c:25386: warning: 'rc' might be used uninitialized in this function
sqlite3/sqlite3.c: In function `sqlite3Select':
sqlite3/sqlite3.c:56300: warning: 'pEList' might be used uninitialized in this function
sqlite3/sqlite3.c:56301: warning: 'pTabList' might be used uninitialized in this function
sqlite3/sqlite3.c: At top level:
sqlite3/sqlite3.c:16020: warning: 'sqlite3GenericAllocationSize' defined but not used
sqlite3/sqlite3.c:6188: warning: 'sqlite3Utf16Substr' declared `static' but never defined
sqlite3/sqlite3.c:6307: warning: 'sqlite3Get2byte' declared `static' but never defined
sqlite3/sqlite3.c:6309: warning: 'sqlite3Put2byte' declared `static' but never defined
sqlite3/sqlite3.c:23248: warning: 'sqlite3BtreeFindCell' defined but not used
sqlite3/sqlite3.c:63547: warning: 'sqlite3ParserAlloc' defined but not used
sqlite3/sqlite3.c:63673: warning: 'sqlite3ParserFree' defined but not used
sqlite3/sqlite3.c:65286: warning: 'sqlite3Parser' defined but not used

I know the uninitialized warnings are false warnings but the defined functions that aren't used seem to be an error in building the amalgamation.

 
2487 code active 2007 Jul anonymous   2007 Jul   1 1 SQLite database locked error on NFS mounted home dir edit
I have a c program using the provided API. My home directory is NFS mounted, Im using SQLite 3.3.17. I open a new database using "sqlite3_open", then strcpy () a SQL command to create a table, and run "sqlite3_exec" with this string. I get a return code of 5=database locked. I then tried to manually (command line using sqlite3) create a table within a database in my home dir, that fails too.

   ===========
   x@y> sqlite3 db2
   SQLite version 3.3.17
   Enter ".help" for instructions
   sqlite> create table test (Lastname varchar);
   SQL error: database is locked
   sqlite>
   ==============

If I try this on my local machine (a Mac), it works fine, but I need it to work in my home directory mounted via NFS as that is where the output of our program goes

2007-Jul-06 19:04:15 by anonymous:
If you're using a Mac, compile sqlite with SQLITE_ENABLE_LOCKING_STYLE in os_unix.c


2007-Jul-07 11:51:10 by drh:
This is a problem with your NFS implementation - it does not appear to support posix advisory locking. There is nothing much that SQLite can do about this.

Anonymous above suggests making use of the dot-locking mechanism contributed by Apple. This might be an effective work-around. But remember that there is performance impact. Also remember that an SQLite database that uses dot-locking is subtly imcompatible with a standard SQLite database. The file format itself is the same, but if two processes try to access the database file at the same time and one uses dot-locks and the other uses posix advisory locks, you will end up with corruption.


2007-Jul-07 12:44:09 by anonymous:
It's very odd that Apple does not fix their Mac OSX POSIX locks for NFS given their resources.
 
2459 code active 2007 Jun anonymous   2007 Jun   4 4 changes() not reporting correctly after "failed" multiline INSERT edit
I have described this bug at http://www.php.net/manual/en/function.sqlite-exec.php#75962.
2007-Jun-25 23:37:22 by drh:
The bug reports says "If you run a multiline ... and there is a SQL error in any of the lines..." but in the accompanying example code, there are no errors. So I do not understand what the problem is.

I do not know what SQLite function the PDO method changes() is bound to. Let us assume that it is bound to sqlite3_changes(). In that case, it returns the number rows that changed in the most recent SQL statement - the last line of the multiline input. This is what SQLite is suppose to do. If you want to know the total number of changes across all the lines in your multiline input, then you have to call sqlite3_total_changes() before and after the multiline SQL and take the difference.


2007-Jun-26 00:10:08 by anonymous:
The error is in the $ins_query variable. The third INSERT is incorrectly spelled as "INSECT". This will cause an error. If you correct the spelling and run the code, changes() will return the integer result "3" to indicate that 3 records have been changed.


2007-Jun-26 00:29:56 by drh:
OK. I generated the following test case:

   CREATE TABLE t1(x INTEGER PRIMARY KEY, name CHAR(255));
   SELECT total_changes();
   INSERT INTO t1(name) VALUES('Ilia1');
   INSERT INTO t1(name) VALUES('Ilia2');
   INSECT INTO t1(name) VALUES('Ilia3');
   SELECT total_changes(), changes();
   SELECT * from t1;

Notice the changes of R->C in the last INSERT. This script appears to do the correct thing when handed in batch to sqlite3_exec() by the command-line shell.

   0
   SQL error near line 5: near "INSECT": syntax error
   2|1
   1|Ilia1
   2|Ilia2

Can you suggest revisions to this script that might induce the error? Do you know how PHP implements its "changes()" method? What is the "changes()" method suppose to show? Do you know that the "changes()" method is implemented correctly in PHP?


2007-Jun-26 05:52:57 by anonymous:
I am not using a command-line interface, and I am not using SQLite 3 (so would sqlite3_exec and my exec operate differently?). I am running these commands from PHP on a web server.

phpinfo() returns this information:

PHP Version: 5.1.6
System: SunOS snail 5.9 sun4u
Server API: Apache

I have created a working version of my initial example, as well as ported your example to my environment:

EDIT: I am aware that my port of your example produces a warning for "no such function". What I do not know is why; I was hoping that you could tell me if total_changes() is something supported only in a command line (TCL, C, C++, or other) environment, if it is not supported in SQLite 2.8.17, or if there is another reason you may be aware of.

EDIT2: I have provided an additional live example of what the server I'm using does with changes() when there is not an error. To clarify, if a multiline query contains no errors, changes() will show that multiple records have been changed, not just the one record affected by the last line of the statement. What I had expected is that, in this scenario, either changes() would report that there HAVE been rows changed, or that a multiline query with an error would not run, or that sqlite would undo the statements that DID execute in a multiline statement once it encountered an error. If there are ways that this CAN be done in SQLite 2.8.17, let me know. Otherwise, I will probably write up some logic in PHP to create the same functionality.


2007-Jun-27 00:25:10 by drh:
I did not notice before that you were talking about 2.8.17.

That version of SQLite is in maintenance mode. We will leave this ticket open for reference, but because 2.8.17 is so very very old and because this is not a serious bug, the problem will likely not be fixed anytime soon. Had this been a bug that was a security vulnerability or could lead to database corruption, we would look into it. But the policy with 2.8.17 is that minor things like this go unfixed. We feel that it is better to focus our efforts on the 3.x series.

You are encouraged to find a work-around. In this case, a good work-around seems to be to not enter invalid SQL...


2007-Jun-27 04:02:33 by anonymous:
Naturally, not entering invalid SQL would be a great idea, but I do not expect everyone to enter perfect SQL statements every time, so I want to try to anticipate possible errors and write in logic that would handle such errors. However, I will find some way to get this to work without changes() working as I desired it to.

Thank you for your help.


2007-Jun-27 11:04:11 by anonymous:
"What I had expected is that, in this scenario, either changes() would report that there HAVE been rows changed, or that a multiline query with an error would not run, or that sqlite would undo the statements that DID execute in a multiline statement once it encountered an error. If there are ways that this CAN be done in SQLite 2.8.17, let me know. Otherwise, I will probably write up some logic in PHP to create the same functionality."

I have determined that I can prevent a multiline query with an error from having its correct statements prior to the one with the error affecting the database by using "BEGIN TRANSACTION", "COMMIT TRANSACTION", and "ROLLBACK TRANSACTION" statements manually in combination with the queryExec method and PHP IF statements. There is a live example with source here:

I could also produce a way to calculate rows changed in such a transaction, by storing the number of records before and after the transaction and doing a simple subtraction. However, this would require me to not use ROLLBACK, so I do not see a benefit to writing such a function.


2007-Jun-30 07:45:12 by anonymous:
Oh, I just realized that I never mentioned what I was wanting this functionality for. I was writing an SQL command-line interface in PHP so that I could work with SQLite that was installed on a remote server. I needed a way to execute SQL commands or batch files without having to put it in a PHP page just to get an error and need to reupload everything.
 
2479 code active 2007 Jun anonymous   2007 Jun   1 1 WinCE regression on some systems. Any db open fails. edit
Because Windows CE is a modular system, meaning many parts of it can be optionally ommited by the system builder, some don't include the CP_UTF8 conversion algorithms for MultiByteToWideChar and family. I believe Windows 95 and early 98 systems can also lack this encoding if not updated with a later Internet Explorer version.

Solution is to just use the sqlite internal functions that already know how to do the same thing.

Attached is an untested patch to os_win.c (I don't have a windows machine nor a cross-compiler set up) to show where the problem is and a possible (sub-optimal) solution.

I believe the right thing to do would be to just drop the utf8ToUnicode and unicodeToUtf8 functions, add the sqlite3Utf8to16 equivalent to utf.c and use them instead.

~Nuno Lucas

2007-Jun-29 14:54:11 by anonymous:
The title is wrong. It should say "Any db open using the UTF-8 API", as using the open16 API will work.
 
2467 code active 2007 Jun anonymous   2007 Jun   4 4 changes() not reporting correctly after DELETE FROM table edit
Similar to the problem reported in #2459, this was originally reported by someone else in the PHP manual for sqlite_changes(). I looked into the description, and produced a live example of the bug here:

The original bug description is here:

EDIT: I found this "bug" noted on the site while browsing random documentation. It seems that this is, in fact, just how the method was designed. Please do correct me if I am wrong. Also, does specifying "WHERE 1" in the "DELETE FROM" statement cause it to delete records individually? Documentation noting this is here:

2007-Jun-27 20:32:31 by anonymous:
yeah. delete from [table_name] drops and reconstructs the table again.
 
2440 code active 2007 Jun rse   2007 Jun   2 2 pkg-config(1) script "sqlite.pc" does not provide Autoconf's LIBS edit
On some platforms it isn't sufficient to link a library just against "-lsqlite". For instance under Solaris one needs "-lsqlite -lrt" because of the use of "fdatasync()". The SQLite Autoconf glue already contains the necessary check for this in order to correctly build SQLite and especially link its sqlite(1). But this information is not passed through to the applications which use pkg-config(1) to build against SQLite. Possible fix from OpenPKG's "sqlite" package is following:

Index: sqlite3.pc.in
--- sqlite3.pc.in.orig  2004-07-19 06:25:47 +0200
+++ sqlite3.pc.in   2007-06-20 18:09:00 +0200
@@ -8,5 +8,5 @@
 Name: SQLite^M
 Description: SQL database engine^M
 Version: @VERSION@^M
-Libs: -L${libdir} -lsqlite3^M
+Libs: -L${libdir} -lsqlite3 @LIBS@^M
 Cflags: -I${includedir}^M
 
2414 code active 2007 Jun anonymous   2007 Jun   1 1 Unable t edit
I designed a tool in C# using the Sqlite.Net.dll and sqlite3.dll v 3.2.5. The call to sqlite3_step after the sqlite3_prepare function, causes a huge delay to return (~7MINS), sometimes it doesn't return at all. This happens when I'm using v3.2.5 but when I replace it with v 3.3.7, everything works normal. I have tried so many combination of things to get it to work on v3.2.5 (this is the version of the libraries the hardware uses), which includes setting the PRAGMA legacy_file_format to 1, but after every save it reverts back to 0. i will appreciate if I can get a response with any suggestions. Thanks in advance.
2007-Jun-13 15:58:00 by anonymous:
Please post the schema and the SELECT command that is slow under 3.2.5 and is fast under 3.3.7 so it can be reproduced using the sqlite3 commandline shell.
 
2409 code active 2007 Jun anonymous   2007 Jun drh 1 1 Database malformed with SQLite3.3.17 on WindowsXP edit
I encountered a problem with SQLite3.3.17 on Windows XP. Under certain situation, database file got seriously corrupted.

SQLite version: 3.3.17 Windows Binary Platform:Windows XP SP2(Japanese) Code wrtten in: Visual C++ 6.0

Here are the procedures to reproduce the problem:

1) Run a program SQLiteCrush.exe. This program updates 'test.db' repeatedly. Insert data to work table, copy them into items table, then delete records from work.

2) Open 'test.db' from sqlite3.exe.

3) Do '.read check.sql' repeatedly. check.sql is made from many lines of 'pragma integrity_check;'.

4) Keep doing 1 -3 for several minuites, and 'pragma integrity_check' starts to report something like "rowid 91667 missing from index sqlite_autoindex_link_1".

So far, I didn't see the database corrupted with SQLite 3.3.7. Also, without 3), the database was not corrupted. Instead of 'pragma integrity_check', issueing many select statements also make it currupted.

2007-Jun-12 02:51:26 by anonymous:
I did more tests to make it clear from which version it happens.

With 3.3.8, I couldn't reproduce the problem. With 3.3.9, I can reproduce the problem.

It seems there's some change between these two that causes the problem...


2007-Jun-12 03:06:47 by anonymous:
Can you try it against the latest version in CVS, or 3.3.17? A lot of code has changed since 3.3.9.


2007-Jun-12 05:00:50 by anonymous:
I Already tried 3.3.17. It happenes.

Where can I get the latest CVS precompiled binary for windows platform ?

tamagawa


2007-Jun-13 14:25:47 by drh:
The problem was introduced in SQLite version 3.3.0, specifically check-in [2848] . There are related problems that go back even further in time, we believe. The root of the problem is a logic error in my design of the pager layer. We are working on a fix now, as well as a set of test cases that will ensure that similar errors do not reappear in the future. I will also soon publish instructions on how to work around the problem in effected versions of SQLite.

The problem can be easily reproduced by running the script below using the "testfixture" program that we use for testing SQLite.

# Prepare the database:
#
file delete -force test.db test.db-journal
sqlite3 db test.db
db eval {
  CREATE TABLE t1 (
    x TEXT UNIQUE NOT NULL,
    y BLOB
  );
}

# Open a second connection to the database that will be
# used to lock the database file.
#
set DB2 [sqlite3 db2 test.db]
if {$DB2==""} {
  set DB2 [sqlite3_connection_pointer db2]
}

# A small cache will cause an early cache spill.
#
db eval {PRAGMA cache_size=10}

# Acquire read lock on the database file using the second connection.
#
set STMT [sqlite3_prepare $DB2 {SELECT rowid FROM sqlite_master} -1 TAIL]
sqlite3_step $STMT

# Insert a short record into the index (10 bytes) and a large record
# into the table (15K).  The index record goes in Ok, but during the
# insert into the table, SQLite attempts to upgrade to an EXCLUSIVE
# lock to do a cache flush. When this happens, the cache is left in
# an inconsistent state.
#
set zShort [string repeat 0123456789 1]
set zLong  [string repeat 0123456789 1500]
db eval {BEGIN}
set rc [catch { db eval {INSERT INTO t1 VALUES($zShort, $zLong)} } msg]
puts "rc=$rc msg=$msg"
sqlite3_finalize $STMT
db eval {COMMIT}
db close
sqlite3 db test.db
puts [db eval {PRAGMA integrity_check}]
 
2413 code active 2007 Jun anonymous   2007 Jun drh 1 1 1 bug and 2 suggestions in lemon edit
Hello, ...
Sorry for my english :-) and if i post this with Severity/Priority error.
I found some not serious bug and have some suggetions.
=============================================================================
BUG FIX:
lemon.c for Win32. It not found lempar.c - backslash-bug.
function:
PRIVATE char *pathsearch(argv0,name,modemask);

PATCH:

---- CUT --------------------------------------------------------------------

--- C:/lemon.c Wed Jun 13 15:02:37 2007
+++ D:/Den/Lemon/lemon.c Wed Jun 13 16:25:22 2007
@@ -2911,7 +2911,11 @@
c = *cp;
*cp = 0;
path = (char *)malloc( strlen(argv0) + strlen(name) + 2 );
- if( path ) sprintf(path,"%s/%s",argv0,name);
+ #ifdef __WIN32__
+ if( path ) sprintf(path,"%s\\%s",argv0,name);
+ #else
+ if( path ) sprintf(path,"%s/%s",argv0,name);
+ #endif
*cp = c;
}else{
extern char *getenv();
@@ -2920,11 +2924,19 @@
path = (char *)malloc( strlen(pathlist)+strlen(name)+2 );
if( path!=0 ){
while( *pathlist ){
- cp = strchr(pathlist,':');
+ #ifdef __WIN32__
+ cp = strchr(pathlist,';');
+ #else
+ cp = strchr(pathlist,':');
+ #endif
if( cp==0 ) cp = &pathlist[strlen(pathlist)];
c = *cp;
*cp = 0;
- sprintf(path,"%s/%s",pathlist,name);
+ #ifdef __WIN32__
+ sprintf(path,"%s\\%s",pathlist,name);
+ #else
+ sprintf(path,"%s/%s",pathlist,name);
+ #endif
*cp = c;
if( c==0 ) pathlist = "";
else pathlist = &cp[1];

---- CUT --------------------------------------------------------------------

=============================================================================
SUGGESTION 1:

Why we allocate parser with mallocProc parameter of ParseAlloc function
and free with freeProc of ParseFree function?

We do this because we want what parser is user-allocatable
with USER-DEFINED-MEMORY-ALOCATION-WAY but not with "malloc"/"free" from stdlib... am i right?

If so... why we still allocate memory for parser stack with "realloc" function?

It's bad for solutions where is no stdlib.

My suggestion is

FIRST WAY:

To add to yyParser struct 3 variables like

void *mem_alloc_fn;
void *mem_realloc_fn;
void *mem_free_fn;

and add 3 directives like

%memory_alloc
%memory_realloc
%memory_free

and if it declared - use it for allocating/free/reallocating memory in parser.

and
- void ParseAlloc(void *(*mallocProc)(size_t));
will now as void *ParseAlloc();
- void ParseFree(void *pParser, void (*freeProc)(void
));
will now as void ParseFree(void *pParser);

OR SECOND WAY (very simple):

To add to yyParser struct 1 variable like
void *mem_realloc_fn;

- void *ParseAlloc(void *(*mallocProc)(size_t));
will now as void *ParseAlloc(void *(*mallocProc)(size_t), void *(*reallocProc)(void *, size_t));

store reallocProc in mem_realloc_fn in yyParser

and in yyGrowStack something like this:
... yyGrowStack (...)
{
....
if(pParser->mem_realloc_fn != NULL)
{
pNew = pParser->mem_realloc_fn(p->yystack, newSize*sizeof(pNew[0]));
}
else
{
pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
}
....
}

and use it for reallocating memory in parser.

In this ways - memory allocating in parser is under FULL user control.

=============================================================================
SUGGESTION 2:

I build lemon with VC 8.0 with option /Wp64 (Detect 64-Bit Portability Issues)
and have warnings. Type int, size_t, pointer and unsigned long have diferent size on x32 and x64 platforms.

Can you fix type difference, please?

Only you can choice better way for this - type conversion OR change type of 'warning' variables.

WARNINGS:

d:\den\lemon\lemon.c(1331) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(1337) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(1455) : warning C4113: 'int (__cdecl )()' differs in parameter lists from 'int (__cdecl *)(const void *,const void *)'
d:\den\lemon\lemon.c(1578) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1578) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1581) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1581) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1586) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1586) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1588) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1588) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1590) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1590) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1592) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1592) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1595) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1595) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1596) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1596) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1624) : warning C4311: 'type cast' : pointer truncation from 'char **' to 'unsigned long'
d:\den\lemon\lemon.c(1624) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1628) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1628) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1629) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1629) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size
d:\den\lemon\lemon.c(1658) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(1661) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(1774) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1774) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1785) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1785) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long'
d:\den\lemon\lemon.c(1883) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(2722) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(3171) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(3173) : warning C4018: '>=' : signed/unsigned mismatch
d:\den\lemon\lemon.c(3184) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(3340) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(3346) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
d:\den\lemon\lemon.c(3542) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data

Ups ... drh, sorry - title change.
 
2408 code active 2007 Jun anonymous   2007 Jun   2 1 BLOBs not output correctly in .mode insert (shell.c - isnumber) edit
The method
static int isNumber(const char *z, int *realnum)

from shell.c is wrong.
Steps to reproduce:
1. Get the file www.smatei.3x.ro/project1.zip
2. extract project1.db from the zip file
3. execute
sqlite3 project1.db
sqlite>.mode insert
sqlite> select ID, Name, Color, Active, Priority, PrioritySource, IndexOrder, Language, 0 from Keywords;
INSERT INTO Keywords VALUES(42,#####,0,1,0,0,42,'',0);
INSERT INTO Keywords VALUES(41,'######',0,1,0,0,43,'',0);

If you look at the 42 item, the string next to 42 is not enclosed by the string delimiter '.
This is because the method isnumber returns that the string is number. It is not a number, it is a string in Hebrew (I inserted ### instead of the real strings).
A fix for this might be to set the first parameter unsigned char
static int isNumber(unsigned const char *z, int *realnum)
but I am not sure, because I haven't written C code for a long time.
If you have any more questions, please ask.
Best Regards,
Stefan

2007-Jun-11 14:46:03 by drh:
Please show me what you get from the following query:

    SELECT ID, quote(cast(Name AS BLOB)) FROM Keywords
     WHERE ID IN (41,42);

I need this information in order to track down the problem.


2007-Jun-11 14:50:33 by anonymous:
The output is

41|X'D791D7A8D799D799D7A7D793D790D7A0D7A1'
42|X'D7A1D798D7A4D7A1'


2007-Jun-11 16:29:46 by drh:
When I do this:

  CREATE TABLE t1(x);
  INSERT INTO t1 VALUES(cast(X'D791D7A8D799D799D7A7D793D790D7A0D7A1' as text));
  INSERT INTO t1 VALUES(cast(X'D7A1D798D7A4D7A1' AS text));
  .mode insert xyz
  SELECT * FROM t1;

I see the Hebrew characters, properly quoted. Can you suggest another way to reproduce the problem?


2007-Jun-11 16:34:55 by anonymous:

  SQLite version 3.3.17
  Enter ".help" for instructions
  sqlite> create table t1(b blob);
  sqlite> insert into t1 values(X'0102030405060708090a0dABCD');
  sqlite> .dump
  BEGIN TRANSACTION;
  CREATE TABLE t1(b blob);
  INSERT INTO "t1" VALUES(X'0102030405060708090A0DABCD');
  COMMIT;
  sqlite> .mode insert
  sqlite> select * from t1;
  INSERT INTO table VALUES('
  &#171;&#205;');
  sqlite>


2007-Jun-11 20:07:09 by anonymous:
If I recall correctly, sqlite3.exe assumes all I/O to and from the console is UTF-8. Windows consoles are either MBCS or UNICODE depending on the build settings. Sqlite3.exe was not compiled as UNICODE so anything inserted into a sqlite3 database will be inserted as MBCS. So if you insert into a database using a 3rd party application that does proper UTF-8, and then query it from the command-line, it will look wrong. Likewise, anything you insert from the command-line will look wrong when queried from an application that uses UTF-8.


2007-Jun-11 20:42:18 by anonymous:
.mode insert treats BLOBs as strings, which is a problem since it stops outputting at the first nil character.

  CREATE TABLE t1(a blob);
  INSERT INTO t1 VALUES(X'00000008090A0D0D0A00');
  .mode insert whatever
  select * from t1;


2007-Jun-12 07:39:12 by anonymous:
Hi,

My problem is not the way the string is displayed in the console. The application that reads the database reads it correctly. The problem is when I try to dump a certain table in a file using the following sequence:

.output "file.txt"
.mode insert whatever
select f1, f2, f3 from t1;

The result is a file that some Hebrew strings are not enclosed in ' (apostrophe). After debugging the code, I saw that the method isnumber does not return 0 for that string. It considers all the characters digits.

This problem occurs only on Windows. We tried this on Mac and Linux, and it worked fine.

Best Regards,
Stefan

 
2398 code active 2007 Jun anonymous   2007 Jun   2 3 systemcalls should be restarted when they return EINTR edit
Introduction: I'm a developer for Alcatel-Lucent, where I program softswitches. I'm a bit of a code-correctness nazi, because I've programmed several systems that have to be very reliable (5 figures), or I've corrected them if they didn't. I was browsing thru the source code of SQLite, to become familiar with it, and to see how reliable it was. Not that we currently use it in a product, but you may never known.

The very first thing I noticed was that none of the systemcalls in os_unix.c was checked for EINTR. From experience, I know that a systemcall can be interrupted while inside the kernel, and return EINTR in errno. The correct reaction is to repeat the system call, just as if nothing happened. This is not an error, just a temporary situation which will be fixed the next time you call it again. One reason is that you call was interrupted by a higher priority interrupt (incoming IO for instance), or to avoid a deadlock in the kernel (returning your syscall will release any locks you might have). It's pretty rare in most usage, but I've seen it lots of times when testing a server under load.

Example of the solution for seekAndWrite (this only shows write, but pwrite is similar) :

   got = write(id->h, pBuf, cnt);

should be :

   do {
      got = write(id->h, pBuf, cnt);
   } while ( (got < 0) && (errno == EINTR) );

This has to be done for every systemcall that mentions it on its manpage (but please note, not every OS is the same). This includes many calls where everyone assumes that the call is safe to use, for instance close(). Almost nobody seems to realize that a close can fail, and often there's not even a check for the return code. But I can assure you, it can fail.

2007-Jun-05 13:39:08 by anonymous:
I prefer the current SQLite behavior NOT to retry in the event of EINTR. I've seen too many UNIX OSes with bugs related to EINTR for system calls within threads over the years, including the most popular ones. Most of these OS bugs have since been fixed, but it's still not worth the trouble in case you come across an unpatched platform. Getting an infinite loop of EINTR errnos in a tight loop due to an OS bug is no fun in a production application.

Technically, POSIX requires that you only read errno if -1 is returned by the system call. QNX is picky about this sort of thing.


2007-Jun-05 17:02:55 by anonymous:
Read my introduction again : I help make systems reliable in my daytime job. Ignoring a read- or write-error is not how you achieve 99.999% availability, especially not when it's easily correctable (a disk-full message or a I/O error due to a corrupt harddisk is another matter ofcourse).

>Technically, POSIX requires that you only read errno if -1 is returned by the system call. QNX is picky about this sort of thing.

well yes, that's what I mean.


2007-Jun-05 17:20:07 by anonymous:
All of SQLite's operations can also be retried if they fail.

SQLite has an extensive test suite for disk failures, malloc failures and many other types of failures that you've likely never considered. I tend to trust the judgement of the authors of SQLite more than an anonymous guy puffing his chest out in this ticket tracking system.


2007-Jun-05 22:24:09 by anonymous:
hi. instead of blaming in this ticket, the ticket author could place a patch like:
got = write(id->h, pBuf, cnt);
to do things like:
#ifdef SQLITE3_RETRY_EINTR_SYSCALLS
   do {
#endif // SQLITE3_RETRY_EINTR_SYSCALLS
      got = write(id->h, pBuf, cnt);
#ifdef SQLITE3_RETRY_EINTR_SYSCALLS
   } while ( (got < 0) && (errno == EINTR) );
#endif // SQLITE3_RETRY_EINTR_SYSCALLS
by leaving SQLITE3_RETRY_EINTR_SYSCALLS undefined, this should not affect the current code behaviour and should address the issues ticket author says and he can compile with those 'paranoic' checks. []'s


2007-Jun-05 22:25:06 by anonymous:
I did pass my name (visible for the developers), but I'm not logged in. That why it's shown as anonymous (just as you are).

Note that my co-workers have already decided it would be seen up as a negative point for this DBMS. At least for us, because it's a requirement for us to survive these errors. So if we ever are going to use SQLite, we're definitely going to use those changes.

Hey, I'm a code-review nazi, don't blame me. It's just my job :-)


2007-Jun-06 00:58:16 by anonymous:
I think that the retrying would destroy the function expected of sqlite3_interrupt.

Is there a problem in the following methods?

  • Re-execute the SQLite API.
  • Mask the signals while calling the API of SQLite.
  • Mask the signals in the threads that call the API of SQLite.


2007-Jun-06 01:04:47 by anonymous:
As long as #ifdef SQLITE3_RETRY_EINTR_SYSCALLS is not enabled by default, knock yourselves out.


2007-Jun-06 06:38:51 by anonymous:
sqlite3_interrupt() knows nothing about UNIX signals. It just sets a flag that sqlite's VDBE checks from time to time to see if it should gracefully abort an SQL operation.

shell.c happens to install an SIGINT signal handler that happens to call sqlite3_interrupt(), but that's unrelated. sqlite3_interrupt() could be called via any other means.


2007-Jun-06 10:47:27 by anonymous:
See also the SA_RESTART flag for sigaction(), which automatically will restart the systemcall instead of returning EINTR.

Unfortunately not available everywhere, and not very consistent either : see Linus reply at http://lkml.org/lkml/2005/7/23/119 . Applications should still be able to handle EINTR returns gracefully. They're not errors per se (that would be EIO or similar), you can safely restart the system call. I haven't seen endless loops yet, but it's true that on some OS you might want this solution. But you still have to deal with the error (which might cause a rollback in SQLite).


2007-Jun-06 14:51:14 by anonymous:
I would be in favor of optionally compiling SQLite with a #define SQLITE_USE_SA_RESTART or #define SQLITE_RETRY_ON_EINTR, where they are mutually exclusive and disabled by default. SQLITE_RETRY_ON_EINTR should have a maximum retry limit on buggy OSes, though.
 
2396 code active 2007 Jun anonymous   2007 Jun   1 3 -column output truncates characters from varchar field. edit
  CREATE TABLE unix (unix_id integer primary key, ip_address varchar(16) unique, status enum, updated timestamp);

  INSERT INTO unix VALUES (NULL,'172.26.242.92','in use',timestamp('now'));
  INSERT INTO unix VALUES (NULL,'172.26.242.129','in use',timestamp('now'));
  INSERT INTO unix VALUES (NULL,'172.26.242.131','in use',timestamp('now'));
  INSERT INTO unix VALUES (NULL,'172.26.242.132','in use',timestamp('now'));
  INSERT INTO unix VALUES (NULL,'172.26.242.136','in use',timestamp('now'));
  INSERT INTO unix VALUES (NULL,'172.26.242.213','in use',timestamp('now'));
  INSERT INTO unix VALUES (NULL,'10.193.33.7','in use',timestamp('now'));
  INSERT INTO unix VALUES (NULL,'10.193.32.239','in use',timestamp('now'));

Now: sqlite3 -column test.db "SELECT ip_address, status, updated FROM unix";

  172.26.242.92  in use      2007-05-31 22:11:39
  172.26.242.12  in use      2007-05-31 22:11:47
  172.26.242.13  in use      2007-05-31 22:11:51
  172.26.242.13  in use      2007-05-31 22:11:59
  172.26.242.13  in use      2007-05-31 22:12:04
  172.26.242.21  in use      2007-05-31 22:12:11
  10.193.33.7    in use      2007-05-31 23:27:09
  10.193.32.239  in use      2007-05-31 23:27:17

The output of the varchar column is always truncated regardless of which column it is placed in. Even if it's the only column.

  sqlite3 -column test.db "SELECT ip_address FROM unix";

  172.26.242.92
  172.26.242.12
  172.26.242.13
  172.26.242.13
  172.26.242.13
  172.26.242.21
  10.193.33.7
  10.193.32.239
2007-Jun-01 18:54:42 by anonymous:
Smaller test case:

  sqlite> CREATE TABLE t9(a);
  sqlite> INSERT INTO "t9" VALUES('a234567890');
  sqlite> INSERT INTO "t9" VALUES('a23456789012345');
  sqlite> select * from t9;
  a234567890
  a23456789012345
  sqlite> .mode column
  sqlite> select * from t9;
  a234567890
  a234567890
  sqlite> select * from t9 order by a desc;
  a23456789012345
  a234567890

.mode column seems to be remembering the first row's column lengths and using them as the maximum column lengths for subsequent rows.


2007-Jun-01 19:11:11 by anonymous:
.mode column could only work correctly if the outputting of the rows took place only after the maximum column width of each column for each row was determined in advance. This would require buffering alls rows in memory before any data rows would be output.

I recommend to remove MODE_Column functionality from shell.c completely, as it never worked correctly.


2007-Jun-05 14:54:30 by anonymous:
Column mode works fine for most applications. It bases it column widths on the width of the title or a minimum width of 10. If this is not suitable, you can set the column widths manually using the .width command in the shell. If you set your IP address column width to 16 or more everything will be fine.
 
154 code active 2002 Sep drh Pager 2007 Jun drh 3 3 Prohibit links on database files. edit
If a database file is aliased using either hard or symbolic links, it can happen that an aborted transaction will not roll back correctly.

Consider this scenario. The database file is named both a.db and a.db. Application one opens a.db and starts to make a change. This creates a journal file a.db-journal. But application one crashes without completing the transaction. Later, application two attempts to open the database as b.db. App two looks for a journal file to rollback, but it thinks the journal should be named b.db-journal. So it fails to see the a.db-journal that app one left and fails to rollback the transaction.

The only way I can think of to prevent this kind of thing it to refuse to open any database file that contains two or more hard links and to refuse to open a file through a symbolic link.

2004-Mar-16 20:46:17 by anonymous:
What if the journal file name wasn't based on the database name, but instead was based on the starting inode of the database file? For instance, "journal-10293" would be used if the starting inode for the associated database file was 10293.


2004-Mar-20 17:17:41 by anonymous:
Using Inode-numbers to solve this problem is a dangerous proposition, as disk defragmenters can alter the inode the db starts at in between a crash and a subsequent roll-back attempt.


2007-Jun-05 03:57:17 by anonymous:
On unix, you can use ftok() to solve this problem. It guarantees to return the same key for all paths to the same file, including symbolic and hard links.

I have to experience programming in Windows, but have no doubt a similar function call exists in that API.

 
2393 code active 2007 May anonymous   2007 May   4 4 pragma cache_size not accurate when set to less than 10 edit
It seems that the smallest the cache_size can be is 10 pages, despite what can be set and is reported by the cache_size and default_cache_size pragmas:

  /*
  ** Change the maximum number of in-memory pages that are allowed.
  */
  void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){
    if( mxPage>10 ){
      pPager->mxPage = mxPage;
    }else{
      pPager->mxPage = 10;
    }
  }

...

  static int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){
    BtShared *pBt = p->pBt;
    sqlite3PagerSetCachesize(pBt->pPager, mxPage);
    return SQLITE_OK;
  }

...

    if( sqlite3StrICmp(zLeft,"cache_size")==0 ){
      if( sqlite3ReadSchema(pParse) ) goto pragma_out;
      if( !zRight ){
        returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
      }else{
        int size = atoi(zRight);
        if( size<0 ) size = -size;
        pDb->pSchema->cache_size = size;
        sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);

...

    if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){
      static const VdbeOpList getCacheSize[] = {
        { OP_ReadCookie,  0, 2,        0},  /* 0 */
        { OP_AbsValue,    0, 0,        0},
        { OP_Dup,         0, 0,        0},
        { OP_Integer,     0, 0,        0},
        { OP_Ne,          0, 6,        0},
        { OP_Integer,     0, 0,        0},  /* 5 */
        { OP_Callback,    1, 0,        0},
      };
      int addr;
      if( sqlite3ReadSchema(pParse) ) goto pragma_out;
      if( !zRight ){
        sqlite3VdbeSetNumCols(v, 1);
        sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", P3_STATIC);
        addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
        sqlite3VdbeChangeP1(v, addr, iDb);
        sqlite3VdbeChangeP1(v, addr+5, SQLITE_DEFAULT_CACHE_SIZE);
      }else{
        int size = atoi(zRight);
        if( size<0 ) size = -size;
        sqlite3BeginWriteOperation(pParse, 0, iDb);
        sqlite3VdbeAddOp(v, OP_Integer, size, 0);
        sqlite3VdbeAddOp(v, OP_ReadCookie, iDb, 2);
        addr = sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
        sqlite3VdbeAddOp(v, OP_Ge, 0, addr+3);
        sqlite3VdbeAddOp(v, OP_Negative, 0, 0);
        sqlite3VdbeAddOp(v, OP_SetCookie, iDb, 2);
        pDb->pSchema->cache_size = size;
        sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);

The information reported is not accurate:

  SQLite version 3.3.17
  Enter ".help" for instructions
  sqlite> pragma cache_size;
  2000
  sqlite> pragma default_cache_size;
  2000
  sqlite> pragma default_cache_size=3;
  sqlite> pragma cache_size=7;
  sqlite> pragma default_cache_size;
  3                                    (should be 10)
  sqlite> pragma cache_size;
  7                                    (should be 10)
 
2388 code active 2007 May anonymous   2007 May   1 3 ORDER BY fails on compound select edit
The query below was known to be working as late as 3.3.14, but in 3.3.17 it errors with "ORDER BY term number 1 does not match any result column".

Debugging with GDB shows that sqlite3NameFromToken(&pE->token) doesn't return anything, and pE->token looks pretty empty, so possibly this could be a parsing issue?

The query is:

  SELECT 	docs.guid, docs.info, conversations.subject, conversations.date
  FROM	conversations
  JOIN 	docs	ON 	docs.guid = conversations.guid
  WHERE 	conversations.guid IN (
  	SELECT	docs.guid
  	FROM 	conversations
  	JOIN 	docs 	ON 	docs.guid = conversations.guid
  	WHERE 	conversations.date >= (SELECT date FROM conversations WHERE guid = ?6)
  		AND 	docs.collection = ?1
  		AND 	((?2 == 0) OR (conversations.sources & ?2) !=   0)
  		AND 	((conversations.sources & ?3) == 0)
  		AND 	test_info_flags(docs.info, ?7, ?8)
  	LIMIT 	(?5 + 1)
  	)
  UNION
  SELECT 	docs.guid, docs.info, conversations.subject,   conversations.date
  FROM 	conversations
  JOIN 	docs   	ON 	docs.guid = conversations.guid
  WHERE 	conversations.guid IN (
  	SELECT 	docs.guid
  	FROM 	conversations
  	JOIN 	docs 	ON docs.guid = conversations.guid
  	WHERE 	conversations.date < (SELECT date FROM conversations WHERE guid = ?6)
  		AND 	docs.collection = ?1
  		AND 	((?2 == 0) OR (conversations.sources & ?2) != 0)
  		AND 	((conversations.sources & ?3) == 0)
  		AND 	test_info_flags(docs.info, ?7, ?8)
  	LIMIT ?4
  	)
  ORDER BY conversations.date DESC, docs.guid DESC;
2007-May-27 16:27:23 by anonymous:
2 workarounds:

  ORDER BY 4 DESC, 1 DESC;

or

  SELECT docs.guid             as "guid",
         docs.info             as "info",
         conversations.subject as "subject",
         conversations.date    as "date"
  ...
  ORDER BY date DESC, guid DESC;

Smaller test case:

  create table x1(a);

  select x1.a from x1 union select x1.a from x1 order by x1.a;
  -- SQL error: ORDER BY term number 1 does not match any result column
  -- error in latest 3.3.17+ CVS, but works in SQLite 3.2.2, 3.3.13

  select x1.a from x1 union select x1.a from x1 order by a;
  -- SQL error: ORDER BY term number 1 does not match any result column
  -- has never worked in previous versions

  select x1.a from x1 union select x1.a from x1 order by 1;
  -- ok in all versions

  select x1.a as a from x1 union select x1.a from x1 order by a;
  -- ok in all versions


2007-May-27 16:46:19 by anonymous:
Does this query work on other popular databases?

  create table x1(a integer);
  select x1.a from x1 union select x1.a from x1 order by x1.a;

I'd expect "order by a" to work on most databases, but not "order by x1.a" because the table name would have been lost by the UNION.

 
2383 code active 2007 May anonymous   2007 May   3 3 Inconsistent conversion of BLOB revisited edit
BLOBs of function results are converted as UTF-8 even if the encoding is UTF-16.

  $ ./sqlite3
  SQLite version 3.3.17
  Enter ".help" for instructions
  sqlite> pragma encoding = 'UTF-16BE';
  sqlite> select quote(cast(cast('ab' as blob) as text));             -- OK
  'ab'
  sqlite> select quote(cast(a as text)) from (select X'00610062' a);  -- OK
  'ab'
  sqlite> select quote(cast(X'00610062' as text));                    -- fixed by [3975]
  'ab'
  sqlite> select quote(cast(substr(X'110061006222', 2, 4) as text));  -- NG
  ''
  sqlite> select quote(cast(substr(X'11616222', 2, 2) as text));
  'ab'
  sqlite> select quote(upper(substr(X'11616222', 2, 2)));
  'AB'
 
2363 code active 2007 May anonymous   2007 May   3 3 Couldn't build 3.3.17 on Cygwin/Vista edit
I didn't see anything quite resembling this on a cursory scan thru the buglist; pardon my goof if it's a duplicate.

When I tried to build on Cygwin on Vista, things got to the install phase, and then the Makefile tried to execute

  cc sqlite3.c -o sqlite3

which didn't appear to be a defined rule in the Makefile. This then failed because of a lack of a main program, and the install failed.

After a quick scan through the Makefile, I decided to change the target for the install rule to

    install:	sqlite3$(TEXE) libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install}

which seemed to remedy the problem.

Suggested fix: modify Makefile as shown above.

2007-May-23 14:29:20 by anonymous:
Another vote for this
 
2378 code active 2007 May anonymous   2007 May   2 2 Quoted fields come back corrupted, using GROUP BY edit
Description:

When executing a query, where field names are quoted, and using GROUP BY, the field names are returned with quotes around.

SQLite version:

  SQLite support => enabled
  PECL Module version => 2.0-dev $Id: sqlite.c,v 1.166.2.13.2.7 2007/03/06 02:17:13 stas Exp $
  SQLite Library => 2.8.17
  SQLite Encoding => iso8859

Reproduce code

  <?php
  $db = sqlite_open(":memory:");
  sqlite_query($db, '
    CREATE TABLE test (
      id INTEGER PRIMARY KEY
    )
  ');
  sqlite_query($db, "INSERT INTO test (id) VALUES (1)");
  $result = sqlite_query($db, 'SELECT "id" FROM "test" GROUP BY "id"');
  var_dump(sqlite_fetch_array($result, SQLITE_ASSOC));

Expected result

  array(1) {
    ["id"]=>
    string(1) "1"
  }

Actual result

  array(1) {
    [""id""]=>
    string(1) "1"
  }
2007-May-21 18:14:27 by anonymous:
Corrupted is probably not the right term, but the fields are returned with quotes around them in sqlite3 as well when group by is used on a quoted column:

  SQLite version 3.3.17
  Enter ".help" for instructions
  sqlite> .header on
  sqlite> create table t1(a);
  sqlite> insert into t1 values(1);
  sqlite> select "a" from t1;
  a
  1
  sqlite> select "a" from t1 order by 1;
  a
  1
  sqlite> select "a" from t1 group by 1;
  "a"
  1
  sqlite> select "a" from t1 group by 1 order by 1;
  "a"
  1
  sqlite> select "a" from t1 group by a;
  "a"
  1
 
2376 code active 2007 May anonymous   2007 May   3 3 -batch doesn't work soon enough edit
on Microsoft XP, given any.db and a batch file bug.bat containing

sqlite3 -batch -init bug.rc any.db "select 1;"

and bug.rc containing

.mode column

Running bug.bat gives the message "Loading resources from bug.rc"

I put in "-batch" so that the "Loading..." message would be suppressed, but it printed anyway.

 
2374 code active 2007 May anonymous   2007 May   5 5 "ALTER TABLE foo RENAME TO bar" will quote bar (ie. 'bar') edit
Cosmetic issue.

When a table is renamed, its representation in the schema ends up being quoted. Whilst this is harmless it also seems to be unnecessary?

  sqlite> create table foo ( c1 integer );
  sqlite> .sc
  CREATE TABLE foo ( c1 integer );

  sqlite> alter table foo rename to bar;

  sqlite> .sc
  CREATE TABLE 'bar' ( c1 integer );

  sqlite> select oid,sql from sqlite_master;
  rowid       sql
  ----------  ---------------------------------
  1           CREATE TABLE 'bar' ( c1 integer )
 
2372 code active 2007 May anonymous   2007 May   4 4 sqlite3TestLockingStyle not used if SQLITE_FIXED_LOCKING_STYLE defined edit
static function sqlite3TestLockingStyle() is not used if SQLITE_FIXED_LOCKING_STYLE is defined. It should probably be wrapped in: #ifndef SQLITE_FIXED_LOCKING_STYLE
 
2371 code active 2007 May anonymous   2007 May   2 2 sqlite3_errcode() and sqlite3_errmsg() return unexpected results edit
The manual says that sqlite3_step() directly returns explicit error code if the query has been prepared with the new API sqlite3_prepare_v2().

Subsequently, the functions sqlite3_errcode() and sqlite3_errmsg() should return the correct appropriate error values as well, which they don't - instead something not matching the error is returned. One has to call sqlite3_reset() to get the correct values which should be unnecessary.

See the example output below :

  sqlite3_step: result rc = 19, errcode = 1, errmsg = SQL logic error or missing database
  sqlite3_reset: result rc = 19, errcode = 19, errmsg = PRIMARY KEY must be unique

Code for this example:

  #include <stdio.h>
  #include <stdlib.h>
  #include <unistd.h>
  #include <string.h>
  #include <sqlite3.h>

  int
  main(int argc, char **argv)
  {
      sqlite3 *db;
      int rc, errcode;
      sqlite3_stmt *stmt;
      const char *pztail;
      char *query;
      const char *errmsg;

      rc = sqlite3_open("test.db", &db);
      rc = sqlite3_exec(db, "create table t (x integer not null primary key)", NULL, NULL, NULL);
      rc = sqlite3_exec(db, "insert into t values(1)", NULL, NULL, NULL);
      query = "insert into t values(?)";
      rc = sqlite3_prepare_v2(db, query, strlen(query), &stmt, &pztail);
      if( rc!=SQLITE_OK ){
          fprintf(stderr, "SQL error: %d\n", rc);
          exit(1);
      }
      rc = sqlite3_bind_int(stmt, 1, 1);
      if( rc!=SQLITE_OK ){
          fprintf(stderr, "SQL error: %d\n", rc);
          exit(1);
      }
      rc = sqlite3_step(stmt);
      errcode = sqlite3_errcode(db);
      errmsg = sqlite3_errmsg(db);
      printf("sqlite3_step: result rc = %d, errcode = %d, errmsg = %s\n",
          rc, errcode, errmsg);
      rc = sqlite3_reset(stmt);
      errcode = sqlite3_errcode(db);
      errmsg = sqlite3_errmsg(db);
      printf("sqlite3_reset: result rc = %d, errcode = %d, errmsg = %s\n",
          rc, errcode, errmsg);
  }
 
2350 code active 2007 May anonymous   2007 May   1 1 Temp files not deleted on WinCE edit
When using SQLite 3.3.17 on WinCE device temp files end up being accumulated in Temp directory, eventually filling up device's open file quota (999?) and making further operation that requires creation of files impossible.

I have noticed that after a while all queries start failing on the device although if I copied the database to PC and tried the same query I had no problems with it. Started tracing through the code and noticed that sqlite3WinOpenExclusive() is consistently failing to create a file (CreateFileW() would always fail). It turned out that Temp directory was full of 0 length temp files -- after deleting all of them device started working again for a while.

Then started looking for the cause -- winceDestroyLock() never gets to execute DeleteFileW() and delete the file even though pFile->zDeleteOnClose is set because check on the top of the winceDestroyLock() function (if (pFile->hMutex)) always fails thanks to pFile->hMutex being 0.

sqlite3WinOpenReadWrite() calls winceCreateLock() on temporary file (zFilename) but sqlite3WinOpenExclusive() doesn't hence winceDestroyLock() cannot delete temporary file.

sqlite3PagerClose() contains this piece of commented out code:

  /* Temp files are automatically deleted by the OS
  ** if( pPager->tempFile ){
  **   sqlite3OsDelete(pPager->zFilename);
  ** }
  */

Comment is not true for WinCE as WinCE doesn't support FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE flags. Perhaps it should be surrounded with #if OS_WINCE/#endif instead of being commented out?


2007-May-14 00:09:20 by anonymous:
Tried re-enabling that piece of code in sqlite3PagerClose() and it doesn't help.

Looks like even file handles for temporary files never get closed on WinCE so not only number of temporary file in Temp directory just keeps growing but also filed descriptor for each of them remains open, draining system resources (consistent with observed behavior of rapid and nasty system performance deterioration).

It appears that sqlite3VdbeFreeCursor() always exits immediately because pCx is always NULL and thus sqlite3BtreeClose() never gets called:

	void sqlite3VdbeFreeCursor(Vdbe *p, Cursor *pCx){
	  if( pCx==0 ){
	    return;
	  }
	  if( pCx->pCursor ){
	    sqlite3BtreeCloseCursor(pCx->pCursor);
	  }
	  if( pCx->pBt ){
	    sqlite3BtreeClose(pCx->pBt);
	  }

sqlite3BtreeClose() then calls sqlite3PagerClose() which probably explains why re-enabling that code doesn't help -- sqlite3PagerClose() itself never gets called.


2007-May-14 05:16:59 by anonymous:
Did some comparison between operation of the SQLite on WinXP and WinCE.

Comment in previous remark about sqlite3VdbeFreeCursor() always exiting immediately because pCx is always NULL is not correct. pCX is NULL most of the time but this is true for both WinXP and WinCE. WinXP has no problems getting rid of its temp files thanks to its support for FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE flags. WinCE also does get its temp file descriptors closed (previous statement incorrect on that account too), it's just that its temp files do not get cleaned up automatically. Initial statement that this was caused because of winceDestroyLock() actually is correct.

Temp files are opened with sqlite3WinOpenExclusive() which DOESN'T use mutex (instead of with sqlite3WinOpenReadWrite() which DOES use mutex) so part of winClose() that was supposed to take care of deleting files after handle is closed (i.e. calling winceDestroyLock()) doesn't work:

	static int winClose(OsFile **pId){
	  winFile *pFile;
	  int rc = 1;
	  if( pId && (pFile = (winFile*)*pId)!=0 ){
	    int rc, cnt = 0;
	    OSTRACE2("CLOSE %d\n", pFile->h);
	    do{
	      rc = CloseHandle(pFile->h);
	    }while( rc==0 && cnt++ < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
	#if OS_WINCE
	    winceDestroyLock(pFile);
	#endif

OS_WINCE part should go something like this (although probably not exactly like this as this feels like an ugly hack):

	#if OS_WINCE
	    if (pFile->hMutex){
	      winceDestroyLock(pFile);
	    }else{
	      if( pFile->zDeleteOnClose ){
	        DeleteFileW(pFile->zDeleteOnClose);
	        sqliteFree(pFile->zDeleteOnClose);
	        pFile->zDeleteOnClose = 0;
	      }
	    }
	#endif


2007-May-14 05:20:33 by anonymous:
Tried the code from the previous remark and it does clean up Temp directory!

I also tried uncommenting that piece of code in sqlite3PagerClose() mentioned in the first remark and it looks like that temp files it tries to delete are never there. I'm guessing that that piece of code can remain commented out. Will keep an eye on it -- in case temp files still eventually start accumulating again even after the fix from previous remark is applied I'll reconsider.

 
2352 code active 2007 May anonymous   2007 May   5 3 timeout just 500 msec to soon edit
After upgrading from 3.3.12 to 3.3.17, the setting of a timeout behaves differently. It occurs exactly 500 msecs sooner. Of course assuming the database is locked and the timeout is set to a value larger than 500 msecs.
 
2340 code active 2007 May anonymous   2007 May   3 3 "./configure && make testfixture" link problem edit
Until the (extremely welcome) sqlite3 blob I/O functionality was checked in, it was possible to run this command on a clean source tree:

  ./configure && make testfixture

But it now produces these unresolved externals:

  ./src/tclsqlite.c:297: warning: excess elements in struct initializer
  ./src/tclsqlite.c:297: warning: (near initialization for `IncrblobChannelType')
  /tmp/ccmyzR97.o: In function `test_blob_read':
  /sqlite/cvs/sqlite/./src/test1.c:1545: undefined reference to `_sqlite3_blob_read'
  /tmp/ccmyzR97.o: In function `test_blob_write':
  /sqlite/cvs/sqlite/./src/test1.c:1592: undefined reference to `_sqlite3_blob_write'
  /tmp/ccb5dcDK.o: In function `incrblobClose':
  /sqlite/cvs/sqlite/./src/tclsqlite.c:156: undefined reference to `_sqlite3_blob_close'
  /tmp/ccb5dcDK.o: In function `incrblobInput':
  /sqlite/cvs/sqlite/./src/tclsqlite.c:194: undefined reference to `_sqlite3_blob_bytes'
  /sqlite/cvs/sqlite/./src/tclsqlite.c:202: undefined reference to `_sqlite3_blob_read'
  /tmp/ccb5dcDK.o: In function `incrblobOutput':
  /sqlite/cvs/sqlite/./src/tclsqlite.c:226: undefined reference to `_sqlite3_blob_bytes'
  /sqlite/cvs/sqlite/./src/tclsqlite.c:235: undefined reference to `_sqlite3_blob_write'
  /tmp/ccb5dcDK.o: In function `incrblobSeek':
  /sqlite/cvs/sqlite/./src/tclsqlite.c:264: undefined reference to `_sqlite3_blob_bytes'
  /tmp/ccb5dcDK.o: In function `DbObjCmd':
  /sqlite/cvs/sqlite/./src/tclsqlite.c:322: undefined reference to `_sqlite3_blob_open'
  collect2: ld returned 1 exit status
  make: *** [testfixture.exe] Error 1

The 2 warnings related to src/tclsqlite.c:297 also seem to indicate a problem.

I'm using Tcl 8.4.

2007-May-06 21:16:01 by anonymous:
Workaround - hack the generated Makefile to use:

  # Compiler options needed for programs that use the TCL library.
  #
  TCC += -I/usr/local/include -DSQLITE_OMIT_INCRBLOB=1
 
2328 code active 2007 Apr anonymous   2007 Apr   1 1 Makefile sqlite3.c target breakage for C++ edit
This is generated by "make sqlite3.c":

  #if 0
  extern "C" {
  #endif
2007-Apr-29 06:02:20 by anonymous:
If the entire sqlite3.c almalgomation is wrapped with:

  #ifdef __cplusplus
  extern "C" {
  #endif

  ...

  #ifdef __cplusplus
  }
  #endif

then it could be compiled with a C++ compiler.

Please close this ticket if you did not intend to have this capability.

 
2322 code active 2007 Apr anonymous   2007 Apr   1 1 Windows error: datetime('2000-10-29 06:00:00','localtime') edit
NY time zone.

Windows (from http://sqlite.org/sqlite-3_3_17.zip)

  SELECT coalesce(datetime('2000-10-29 06:00:00','localtime'),'NULL');
  2000-10-29 02:00:00

Linux (from latest CVS, same TZ)

  SELECT coalesce(datetime('2000-10-29 06:00:00','localtime'),'NULL');
  2000-10-29 01:00:00

make test errors on Windows only:

  date-6.2...
  Expected: [{2000-10-29 01:00:00}]
       Got: [{2000-10-29 02:00:00}]

  date-6.3...
  Expected: [{2000-04-02 01:59:00}]
       Got: [{2000-04-02 02:59:00}]

  date-6.6...
  Expected: [{2000-10-29 07:00:00}]
       Got: [{2000-10-29 06:00:00}]

  date-6.7...
  Expected: [{2000-04-02 06:59:00}]
       Got: [{2000-04-02 05:59:00}]
2007-Apr-26 23:09:12 by anonymous:
Confirmed Windows bug on Windows 2000 in NY time zone with Y2K7DST OS patch.


2007-Apr-27 22:03:25 by drh:
Do I correctly understand the previous remark to say that this is confirmed to be a bug in Windows, not a bug in SQLite? It is identical code in SQLite for both operating systems, so I would certainly suspect that the problem is in windows and not in SQLite. But it would be nice to have confirmation of this before closing the ticket.


2007-Apr-28 03:19:06 by anonymous:
I meant to write "This erroneous SQLite datetime() output can also be seen on my Windows 2000 machine."

Does it work correctly for you under Windows XP or 2000 with the DST patch?

OS bug or not, it would be strange to not have the datetime() function correctly on a primary platform. If that were the case, it would be better to #ifdef it out of the Windows compile altogether.


2007-Apr-28 03:59:27 by anonymous:
This is a bigger mess than I thought.

http://groups.google.com/group/perl.perl5.porters/msg/e632557614474014?hl=en&

Key phrase:

"This API only provides the transition times according to the current DST rules. There is no database of historical transition times. That means that localtime() applied to previous years will use the new transition times even for old timestamps."

Please don't close this bug. Perhaps some industrious Windows programmer will have a correct solution for it one day. But in the meantime, Windows SQLite users should be aware of it.

 
2320 code active 2007 Apr anonymous   2007 Apr drh 1 1 sqlite3_open(sFN_with_umlaut) edit
Do it in a standard MS Visual Studio Project:

0. CString sFnWithUmlaut = "c:\\long path\\path with umlauts äÄ\\db";
1. call sqlite3_open(sFnWithUmlaut);
2. db cannot be opened, because the transformation functions utf8ToUnicode/unicodeToUtf8 work incorrect

Is there a way to correct this error on win32?
Is there a workaround?

For a solution thanks in advance...
2007-Apr-25 20:21:24 by anonymous:
The functions work correctly, but you are not using them in the correct way. The parameter to sqlite3_open function should be UTF8 string, but you are passing one that is specific to your code page.
 
2282 code active 2007 Apr anonymous   2007 Apr   3 4 Update on view with no matching trigger does not raise error edit
Attempting to update a view with no triggers properly fails with the error

  sqlite> update foo set key=key+1;
  SQL error: cannot modify foo because it is a view

However, if a single trigger is added that contains a WHEN clause, then UPDATE statements that do not satisfy that WHEN clause silently succeed without raising any error.

  sqlite> select 'Before:'; select * from foo; update foo set key=key+1; select 'After:'; select * from foo;
  Before:
  1|42|forty-two|42.0
  2|69|sixty-nine|69.0
  After:
  1|42|forty-two|42.0
  2|69|sixty-nine|69.0
2007-Apr-18 21:50:00 by anonymous:
Your desired behavior can be accomplished by changing your trigger to:

  create trigger foo_update instead of update on foo
  begin
	select raise(ABORT, 'invalid key')
	where old.key <> new.key;

	update foo_backing set num=new.num, str=new.str, float=new.float, dirty=1
		where key=new.key;
  end;


2007-Apr-24 20:26:46 by anonymous:
I have come up with a sample patch that partially fixes this problem -- specifically, it raises an error if any rows affected by an update/delete against a view are not caught by any triggers. It does not handle uncaught inserts, however, because I couldn't quite figure out how to make that work (much of the logic for updates and deletes is almost identical, whereas the code for inserts is quite different.)

This patch adds/updates 76 lines across 4 files. I disclaim all copyright to these 76 lines.

 
2303 code active 2007 Apr anonymous   2007 Apr   1 1 Encrypted databases: No page cache due to problem in pagerSharedLock edit
With codec encryption enabled, pagerSharedLock always invalidates the page cache, even if no changes have occured since the cache was last valid and it would be safe to retain the cached pages. This in fact disables the newly improved page cache for encrypted databases and slows down performance.

The problem occurs because pagerSharedLock reads the change counter directly from the database file without codec decryption. Since the codec always encrypts full pages, the 4 bytes at offset 24 are read as encrypted data and do not match Pager->iChangeCount.

To solve, codecs would be required to store the 4 bytes at offset 24 of page 1 unencrypted. This would, however, render those 4 bytes vulnerable to attacks. It would therefore be more secure if pagerSharedLock could decrypt page one prior to extracting the change counter.

Check-in [3844] does not fix the problem to reset the cache if the codec is changed but the database file is not. The following procedure for opening an encrypted database no longer works with the improved page cache:

  • Open an encrypted database. Do not set a key yet as we (pretend to) believe that the database is not encrypted.

  • Access the DB for reading. This returns SQLITE_NOTADB, so we conclude that the DB is encrypted.

  • Attach the proper codec using sqlite3CodecAttach.

  • Access the DB again. Problem: This still returns SQLITE_NOTADB because the old page cache is still in use and is not reloaded.

The codec change is not detected because the pager checks the unencrypted DB file instead of the decrypted page. The file of course did not change, but the decrypted page did because of the new codec. The cache should therefore be cleared.

A workaround would be possible if sqlite3CodecAttach could reset the page cache. Unfortunately, the method to do so (pager_reset) is static to pager.c. It seems that there once was an external function sqlite3PagerReset (it is still defined in pager.h), but its implementation is unfortunately no longer available.

Could this be fixed in a way that pagerSharedLock checks the decrypted page 1 to see if the database has been modified or, alternatively, by reverting the static pager_reset back to the external sqlite3PagerReset?

 
2310 code active 2007 Apr anonymous   2007 Apr anonymous 4 4 Problem installing on AIX 5.3, ML5 after successful compile with xlc edit
After performing the suggested edits to the Makefile (from Tom Poindexter 2003-12-17):

     edit Makefile, change the TCC macro:

     TCC = xlc -q32 -qlonglong -D_LARGE_FILE=1 -D_LARGE_FILES=1 -DUSE_TCL_STUBS=1 -O2 -DOS_UNIX=1 -DOS_WIN=0 -DHAVE_USLEEP=1 -I. -I${TOP}/src

Version 3.3.15 compiled perfectly. However, a make install gave me this:

<root@tailinn 14:41:21>: /data/bld --> make install tclsh ../sqlite-3.3.15/tclinstaller.tcl 3.3 couldn't open ".libs/libtclsqlite3.so": no such file or directory while executing "open $LIBFILE" invoked from within "set in [open $LIBFILE]" (file "../sqlite-3.3.15/tclinstaller.tcl" line 23) make: 1254-004 The error code from the last command is 1.

I had to edit line 8 of ../sqlite-3-3-15/tclinstaller.tcl by adding a ".0" to the end. Then it installed perfectly.

2007-Apr-19 20:47:24 by anonymous:
Haven't used AIX or xLC for 15 years - does IBM still make UNIX machines?
 
2297 code active 2007 Apr anonymous   2007 Apr drh 3 3 uninitialized var (with patch) edit
Warnings with amalgamation and NDEBUG.
2007-Apr-12 21:21:29 by drh:
I looked at the suggested changes and I didn't find any cases where it really was possible to use an uninitialized variable, at least not in a harmful way. Did I overlook something, or is this ticket just a request to silence compiler warnings?


2007-Apr-13 00:08:36 by anonymous:
vdbe.c with n, n64, payloadSize and payloadSize64
sqlite3BtreeKeySize,sqlite3BtreeLast return are not checked. You can not be sure the pointer passed as second argument will be init depending on the return of restoreOrClearCursorPosition (btree.c).

page.c with ro
Compiled with -DNDEBUG, the return of sqlite3OsOpenReadWrite is not checked before making a move with 'ro'.

For sContext.zAuthContext in delete.c/update.c, you're the one.

gcc (compiler in general) warnings are quite usefull, i don't think it's a good idea to ignore them and accumulate danger. Perhaps one day, one line in a subroutine will modify some tricky behavior and (re)raise a previous checked warning, making it completely normal and 'under control'.

 
2288 code active 2007 Apr anonymous   2007 Apr   4 2 FTS does not support REPLACE edit
Simple to replicate:

CREATE VIRTUAL TABLE fts_table USING fts2(text);

INSERT OR REPLACE INTO fts_table (rowid, text) VALUES (1, 'text1');

INSERT OR REPLACE INTO fts_table (rowid, text) VALUES (1, 'text2');

The first insert succeeds, the second fails. Also occurs with fts1.

2007-Apr-10 15:27:10 by anonymous:
http://www.mail-archive.com/sqlite-users%40sqlite.org/msg23865.html
 
2041 code active 2006 Oct anonymous   2007 Mar   4 4 sqlite3.pc on Solaris needs -lrt in "Libs:" entry edit
On Solaris, to get fdatasync(), it's necessary to link with -lrt (the realtime library). I reported that issue a while back, and sqlite's configure has since become smart enough to look for fdatasync() in -lrt, and some of the sqlite Makefile targets know to at $(TLIBS) to the link line, to pick up any addtional libraries (like -lrt) that may be needed.

The problem is that -lrt isn't added to the sqlite3.pc file that's generated, so other applications that use pkg-config and the sqlite3.pc to determine how to link against libsqlite3 don't know that they need to add -lrt.

One fairly easy fix for the problem is to modify sqlite3.pc.in to also include @TARGET_LIBS@ in the Libs: line. That way, if anything is added to TARGET_LIBS by configure, it's automatically substituted into both the Makefile and sqlite3.pc.

Still, I don't understand why libsqlite3 isn't directly linked against -lrt. It's the libsqlite.3.so.* that has the dependency on librt, not the sqlite3 shell, so I don't understand why $(TLIBS) is mentioned for the sqlite3 target instead of the libsqlite3.la target.

I can provide a patch that adds @TARGET_LIBS@ to the Libs line for sqlite3.pc, or I can provide a patch that adds $(TLIBS) to the link line for libsqlite3.la and removes it from sqlite3. I just need to know which the developers prefer.

Thanks!

Tim

2006-Nov-22 15:09:25 by anonymous:
I was having similar problems, but my build failures didn't occur until 'make test'. Unfortunately, <code>@TARGET_LIBS@</code> did not work for me... Thankfully, adding <code>$(TLIBS)</code> to the libsqlite3.la rule in the Makefile did.

Thank you for reporting your fix! You've helped me greatly!

-- Brett


2007-Mar-30 05:37:16 by anonymous:
#1802, #2041 and #2270 are the same basic issue: librt should get linked into libsqlite3.so
 
2241 code active 2007 Feb scouten   2007 Mar   3 3 pragma integrity_check no longer affects command-line tool's exit code edit
With the 3.3.5 build, if you did the following:

   sqlite3 /path/to/db "PRAGMA integrity_check;"

You seemed get a 1 result back on the command line if the check failed in any way (and 0 if it was "ok").

With 3.3.13, this doesn't seem to be the case, even if you specify the -bail command line parameter. (I also tried "PRAGMA integrity_check=1;", which is all I care about in this case.) I have a database with errors that returns 0 to the calling process (that is, the sqlite command line's main function returns 0).

We would like to see the 3.3.5 behavior return.

2007-Mar-29 18:32:54 by drh:
I pulled versions of SQLite going back to 2006-01-01 and I could not find one where the shell returned a non-zero exit code when PRAGMA integrity_check failed. Are you sure that you do not have a customized version of the 3.3.5 shell?
 
2075 code active 2006 Nov anonymous   2007 Feb   3 3 Improve VACUUM speed and INDEX page locality edit
In testing several 100 Meg - 1 Gig databases (including the Monotone OpenEmbedded database) I found that changing the order of the SQL commands executed by VACUUM to create indexes after table inserts results in 15% faster VACUUM times, and up to 25% faster cold-file-cache queries when indexes are used. This patch effectively makes the pages of each index contiguous in the database file after a VACUUM, as opposed to being scattered throughout the pages of the table related to the index. Your results may vary, but I think this is a very safe change that can potentially boost average database performance.

  Index: src/vacuum.c
  ===================================================================
  RCS file: /sqlite/sqlite/src/vacuum.c,v
  retrieving revision 1.65
  diff -u -3 -p -r1.65 vacuum.c
  --- src/vacuum.c      18 Nov 2006 20:20:22 -0000      1.65
  +++ src/vacuum.c      20 Nov 2006 21:09:27 -0000
  @@ -143,14 +143,6 @@ int sqlite3RunVacuum(char **pzErrMsg, sq
         "   AND rootpage>0"
     );
     if( rc!=SQLITE_OK ) goto end_of_vacuum;
  -  rc = execExecSql(db,
  -      "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14,100000000)"
  -      "  FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' ");
  -  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  -  rc = execExecSql(db,
  -      "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21,100000000) "
  -      "  FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'");
  -  if( rc!=SQLITE_OK ) goto end_of_vacuum;

     /* Loop through the tables in the main database. For each, do
     ** an "INSERT INTO vacuum_db.xxx SELECT * FROM xxx;" to copy
  @@ -162,10 +154,22 @@ int sqlite3RunVacuum(char **pzErrMsg, sq
         "FROM sqlite_master "
         "WHERE type = 'table' AND name!='sqlite_sequence' "
         "  AND rootpage>0"
  -
     );
     if( rc!=SQLITE_OK ) goto end_of_vacuum;

  +  /* Create indexes after the table inserts so that their pages
  +  ** will be contiguous resulting in (hopefully) fewer disk seeks.
  +  */
  +  rc = execExecSql(db,
  +      "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21,100000000) "
  +      "  FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'");
  +  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  +
  +  rc = execExecSql(db,
  +      "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14,100000000)"
  +      "  FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' ");
  +  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  +
     /* Copy over the sequence table
     */
     rc = execExecSql(db,
2007-Feb-11 00:49:50 by drh:
My alternative plan is to modify insert.c so that it recognizes the special case of

    INSERT INTO table1 SELECT * FROM table2;

when table1 and table2 have identical schemas, including all the same indices. When this special case is recognized, the generated bytecode will first transfer all table entries from table2 to table1, using a row by row transfer without decoding each row into its constituient columns. Then it will do the same for each index.

There will be two benefits here. First, when the above construct occurs during the course of a VACUUM, the table and each index, including intrisic indices associated with UNIQUE and PRIMARY KEY constraints, will be transferred separately so that all of there pages will be adjacent in the database file. The second benefit will occur when trying to load large quantities of data into an indexed table. Loading indexed data into a very large table is currently slow because the index entries are scattered haphazardly around in the file. But if data is first loaded into a smaller temporary table with the same schema, it can then be transferred to the main table using an INSERT statement such as the above in what amounts to a merge operation.


2007-Feb-11 06:58:36 by anonymous:
There's no question that your proposal will greatly improve VACUUM speed which relies on the "INSERT INTO table1 SELECT * from table2" construct. But would it be possible for you to relax the restriction on having identical indexes for table1 and table2? For that matter it would be nice if table2 could be any subselect or view. Then "REPLACE INTO table1 SELECT ...anything..." could also be optimized. Since you can detect that SQLite is doing a bulk insert anyway, it could generate code to make a temporary staging table with automatically generated identical indexes to table1 which could be periodically merged into table1 and truncated every X rows. X could be either set via pragma or be a function of the size of the page cache. The temporary staging table would be dropped after the bulk INSERT INTO ... SELECT. Every user inserting large volumes of data would have to perform this procedure anyway. Manually recreating all the indexes for a given temporary table to match the original table and performing the looping logic is cumbersome and error-prone. It would be very conveniant if SQLite were to do it on the user's behalf. This scheme could only work if there are no triggers on table1, of course.


2007-Feb-11 09:16:25 by drh:
My initial enhancement does nothing to preclude the more agressive enhancement described by anonymous. In order to avoid subtle bugs, and in view of my limited time available to work on this, I think it best to take the more conservative approach first and defer the more elaborate optimization suggested by anonymous until later.


2007-Feb-11 13:54:34 by anonymous:
It should be possible to identify contiguous blocks of individual "INSERT INTO table1 VALUES(...)" statements to the same table within a large transaction and perform the same proposed optimization as with "INSERT INTO table1 SELECT ...". This would require higher level coordination by the parser. Anytime a read operation (SELECT, UPDATE) occurs on such a table marked for bulk INSERT within the large transaction, its temp staging table could be merged into the INSERT destination table and the staging table truncated. The process could be repeated for the remainder of the transaction.

Such an optimization would be a huge benefit to SQLite users since they would need not know the idiosynchracies of the implementation of "INSERT INTO table1 SELECT ..." in order to have efficient table and index population.

Alternatively, if you wish to avoid the complexity of re-assembling and staging individual INSERT statements, it might be a good opportunity for SQLite to support the multi-row variant of the INSERT command:

  INSERT INTO table1 (a,b,c) VALUES(1,2,3), (4,5,6), (7,8,9);

Which is essentially a transform of:

  CREATE TEMP TABLE table1_staging (a,b,c);
  INSERT INTO table1_staging VALUES(1,2,3);
  INSERT INTO table1_staging VALUES(4,5,6);
  INSERT INTO table1_staging VALUES(7,8,9);
  INSERT INTO table1 SELECT * FROM table1_staging;
  -- TRUNCATE OR DROP table1_staging as necessary

which could use the same bulk staging optimization.


2007-Feb-13 02:42:41 by anonymous:
Any harm in checking in the simple patch above for the 3.3.13 release?


2007-Feb-13 12:51:47 by drh:
I have a much better fix standing by that I intend to check-in as soon as I get 3.3.13 out the door. I don't want this in 3.3.13 for stability reasons.


2007-Feb-18 23:07:08 by anonymous:
Some related analysis and an .import patch using a :memory: staging table with the "INSERT INTO table1 SELECT FROM table2" construct can be found here:

http://www.mail-archive.com/sqlite-users%40sqlite.org/msg22143.html

 
2237 code active 2007 Feb anonymous   2007 Feb   4 4 Test suite regressions using Tcl 8.5 edit
Tcl 8.5, SQLite 3.3.13 CVS

  printf-1.7.6...
  Expected: [Three integers: (1000000) ( f4240) (3641100)]
       Got: [Three integers: ( 1000000) ( f4240) (3641100)]

  printf-1.8.6...
  Expected: [Three integers: (999999999) (3b9ac9ff) (7346544777)]
       Got: [Three integers: ( 999999999) (3b9ac9ff) (7346544777)]

  printf-1.9.7...
  Expected: [Three integers: (     0) (   0x0) (     0)]
       Got: [Three integers: (     0) (     0) (     0)]

  tcl-1.6...
  Expected: [1 {syntax error in expression "x*"}]
       Got: [1 {invalid bareword "x"
  in expression "x*";
  should be "$x" or "{x}" or "x(...)" or ...}]
 
2060 code active 2006 Nov anonymous   2007 Feb   1 1 Table references enclosed in parenthesis become "invisible" edit
Hi,

I'm developing an RDF-based system, which translates queries from SPARQL into SQL. While trying to add support for SQLite (MySQL is already supported) I came across the following problem: when table references in a FROM clause are enclosed in parenthesis, they cannot be referenced from outside the parenthesized expression. For example, given the table definitions

  CREATE TABLE IF NOT EXISTS t1 (a, b);
  CREATE TABLE IF NOT EXISTS t2 (c, d);
  CREATE TABLE IF NOT EXISTS t3 (e, f);

The following queries all fail with "no such column" errors:

  SELECT t1.a, t3.f
  FROM (t1 CROSS JOIN t2 ON t1.b = t2.c) LEFT JOIN t3 ON t2.d = t3.e;

  SELECT t1.a, t3.f
  FROM t1 CROSS JOIN (t2 LEFT JOIN t3 ON t2.d = t3.e) ON t1.b = t2.c;

  SELECT t1.a, t2.d
  FROM (t1), (t2)
  WHERE t1.b = t2.c;

I'm not sure if it is always possible to reformulate the queries in such a way that the extra parenthesis aren't necessary, but I suspect that complex expressions involving joins may require them to achieve the intended semantics. In any case, my system would require large changes to be able to get rid of the parenthesized subjoins, so it would be nice if this problem could be fixed. :-)

2006-Nov-10 03:56:46 by anonymous:
For what it's worth, here's the parse trees of two similar queries ("SELECT t1.a, t2.d FROM t1, t2 WHERE t1.b = t2.c" and "SELECT t1.a, t2.d FROM (t1), (t2) WHERE t1.b = t2.c"), as well as one of the other more complicated join queries previously listed.

  SELECT t1.a, t2.d FROM t1, t2 WHERE t1.b = t2.c;
  Select {
    op: TK_SELECT
    isResolved: 1
    pSrc: {
      a[0]: {
        zName: t1
        iCursor: 0
        colUsed: 0x00000003
        pTab: t1
        jointype: JT_INNER
      }
      a[1]: {
        zName: t2
        iCursor: 1
        colUsed: 0x00000003
        pTab: t2
      }
    }
    pEList: {
      a[0]: {
        pExpr: {
          op: TK_COLUMN
          span: {t1.a}
          affinity: SQLITE_AFF_NONE
          iTable: 0
          iColumn: 0
          pTab: t1
        }
      }
      a[1]: {
        pExpr: {
          op: TK_COLUMN
          span: {t2.d}
          affinity: SQLITE_AFF_NONE
          iTable: 1
          iColumn: 1
          pTab: t2
        }
      }
    }
    pWhere: {
      op: TK_EQ
      span: {t1.b = t2.c}
      pLeft: {
        op: TK_COLUMN
        span: {t1.b}
        affinity: SQLITE_AFF_NONE
        iTable: 0
        iColumn: 1
        pTab: t1
      }
      pRight: {
        op: TK_COLUMN
        span: {t2.c}
        affinity: SQLITE_AFF_NONE
        iTable: 1
        iColumn: 0
        pTab: t2
      }
    }
  }

  SELECT t1.a, t2.d FROM (t1), (t2) WHERE t1.b = t2.c;
  Select {
    op: TK_SELECT
    isResolved: 1
    pSrc: {
      a[0]: {
        zAlias: sqlite_subquery_5C0A10_
        iCursor: 0
        pTab: sqlite_subquery_5C0A10_
        pSelect: {
          op: TK_SELECT
          isResolved: 1
          pSrc: {
            a[0]: {
              zName: t1
              iCursor: 1
              colUsed: 0x00000003
              pTab: t1
            }
          }
          pEList: {
            a[0]: {
              zName: a
              pExpr: {
                op: TK_COLUMN
                token: {a}
                span: {a}
                affinity: SQLITE_AFF_NONE
                iTable: 1
                iColumn: 0
                pTab: t1
              }
            }
            a[1]: {
              zName: b
              pExpr: {
                op: TK_COLUMN
                token: {b}
                span: {b}
                affinity: SQLITE_AFF_NONE
                iTable: 1
                iColumn: 1
                pTab: t1
              }
            }
          }
        }
        jointype: JT_INNER
      }
      a[1]: {
        zAlias: sqlite_subquery_5BE4F0_
        iCursor: 2
        pTab: sqlite_subquery_5BE4F0_
        pSelect: {
          op: TK_SELECT
          isResolved: 1
          pSrc: {
            a[0]: {
              zName: t2
              iCursor: 3
              colUsed: 0x00000003
              pTab: t2
            }
          }
          pEList: {
            a[0]: {
              zName: c
              pExpr: {
                op: TK_COLUMN
                token: {c}
                span: {c}
                affinity: SQLITE_AFF_NONE
                iTable: 3
                iColumn: 0
                pTab: t2
              }
            }
            a[1]: {
              zName: d
              pExpr: {
                op: TK_COLUMN
                token: {d}
                span: {d}
                affinity: SQLITE_AFF_NONE
                iTable: 3
                iColumn: 1
                pTab: t2
              }
            }
          }
        }
      }
    }
    pEList: {
      a[0]: {
        pExpr: {
          op: TK_COLUMN
          span: {t1.a}
          flags: EP_Resolved EP_Error
          iTable: -1
          iColumn: 0
        }
      }
      a[1]: {
        pExpr: {
          op: TK_DOT
          span: {t2.d}
          pLeft: {
            op: TK_ID
            token: {t2}
            span: {t2}
          }
          pRight: {
            op: TK_ID
            token: {d}
            span: {d}
          }
        }
      }
    }
    pWhere: {
      op: TK_EQ
      span: {t1.b = t2.c}
      pLeft: {
        op: TK_DOT
        span: {t1.b}
        pLeft: {
          op: TK_ID
          token: {t1}
          span: {t1}
        }
        pRight: {
          op: TK_ID
          token: {b}
          span: {b}
        }
      }
      pRight: {
        op: TK_DOT
        span: {t2.c}
        pLeft: {
          op: TK_ID
          token: {t2}
          span: {t2}
        }
        pRight: {
          op: TK_ID
          token: {c}
          span: {c}
        }
      }
    }
  }
  SQL error: no such column: t1.a

  SELECT t1.a, t3.f FROM (t1 CROSS JOIN t2 ON t1.b = t2.c) LEFT JOIN t3 ON t2.d = t3.e;
  Select {
    op: TK_SELECT
    isResolved: 1
    pSrc: {
      a[0]: {
        zAlias: sqlite_subquery_5BFA30_
        iCursor: 0
        pTab: sqlite_subquery_5BFA30_
        pSelect: {
          op: TK_SELECT
          isResolved: 1
          pSrc: {
            a[0]: {
              zName: t1
              iCursor: 1
              colUsed: 0x00000003
              pTab: t1
              jointype: JT_INNER JT_CROSS
            }
            a[1]: {
              zName: t2
              iCursor: 2
              colUsed: 0x00000003
              pTab: t2
            }
          }
          pEList: {
            a[0]: {
              zName: a
              pExpr: {
                op: TK_COLUMN
                span: {t1.a}
                affinity: SQLITE_AFF_NONE
                iTable: 1
                iColumn: 0
                pTab: t1
              }
            }
            a[1]: {
              zName: b
              pExpr: {
                op: TK_COLUMN
                span: {t1.b}
                affinity: SQLITE_AFF_NONE
                iTable: 1
                iColumn: 1
                pTab: t1
              }
            }
            a[2]: {
              zName: c
              pExpr: {
                op: TK_COLUMN
                span: {t2.c}
                affinity: SQLITE_AFF_NONE
                iTable: 2
                iColumn: 0
                pTab: t2
              }
            }
            a[3]: {
              zName: d
              pExpr: {
                op: TK_COLUMN
                span: {t2.d}
                affinity: SQLITE_AFF_NONE
                iTable: 2
                iColumn: 1
                pTab: t2
              }
            }
          }
          pWhere: {
            op: TK_EQ
            span: {t1.b = t2.c}
            flags: EP_FromJoin EP_Resolved
            iRightJoinTable: 2
            pLeft: {
              op: TK_COLUMN
              span: {t1.b}
              affinity: SQLITE_AFF_NONE
              flags: EP_FromJoin EP_Resolved
              iTable: 1
              iColumn: 1
              iRightJoinTable: 2
              pTab: t1
            }
            pRight: {
              op: TK_COLUMN
              span: {t2.c}
              affinity: SQLITE_AFF_NONE
              flags: EP_FromJoin EP_Resolved
              iTable: 2
              iColumn: 0
              iRightJoinTable: 2
              pTab: t2
            }
          }
        }
        jointype: JT_LEFT JT_OUTER
      }
      a[1]: {
        zName: t3
        iCursor: 3
        pTab: t3
      }
    }
    pEList: {
      a[0]: {
        pExpr: {
          op: TK_COLUMN
          span: {t1.a}
          flags: EP_Resolved EP_Error
          iTable: -1
          iColumn: 0
        }
      }
      a[1]: {
        pExpr: {
          op: TK_DOT
          span: {t3.f}
          pLeft: {
            op: TK_ID
            token: {t3}
            span: {t3}
          }
          pRight: {
            op: TK_ID
            token: {f}
            span: {f}
          }
        }
      }
    }
    pWhere: {
      op: TK_EQ
      span: {t2.d = t3.e}
      flags: EP_FromJoin
      iRightJoinTable: 3
      pLeft: {
        op: TK_DOT
        span: {t2.d}
        flags: EP_FromJoin
        iRightJoinTable: 3
        pLeft: {
          op: TK_ID
          token: {t2}
          span: {t2}
          flags: EP_FromJoin
          iRightJoinTable: 3
        }
        pRight: {
          op: TK_ID
          token: {d}
          span: {d}
          flags: EP_FromJoin
          iRightJoinTable: 3
        }
      }
      pRight: {
        op: TK_DOT
        span: {t3.e}
        flags: EP_FromJoin
        iRightJoinTable: 3
        pLeft: {
          op: TK_ID
          token: {t3}
          span: {t3}
          flags: EP_FromJoin
          iRightJoinTable: 3
        }
        pRight: {
          op: TK_ID
          token: {e}
          span: {e}
          flags: EP_FromJoin
          iRightJoinTable: 3
        }
      }
    }
  }
  SQL error: no such column: t1.a


2006-Nov-11 18:29:33 by anonymous:
The resolving bug appears to be that unique column names or column aliases are searched across all subqueries, but table names and table aliases are only searched at their current SELECT level only.

With this in mind, here are mechanical workarounds without using column aliases (assumes the column names in all joined tables are unique):

  SELECT a, f FROM (t1 CROSS JOIN t2 ON t1.b = t2.c) LEFT JOIN t3 ON d = e;

  SELECT t1.a, f FROM t1 CROSS JOIN (t2 LEFT JOIN t3 ON t2.d = t3.e) ON t1.b = c;

  SELECT a, d FROM (t1), (t2) WHERE b = c;

And here are mechanical workarounds using column aliases (assumes the column names are not unique between tables):

  SELECT t1.a, t3f FROM t1 CROSS JOIN (select t3.f t3f, t2.c t2c from t2 LEFT JOIN t3 ON t2.d = t3.e) ON t1.b = t2c;

  SELECT t1a, t3.f FROM (select t1.a t1a, t2.d t2d from t1 CROSS JOIN t2 ON t1.b = t2.c) LEFT JOIN t3 ON t2d = t3.e;

  SELECT t1a, t2d FROM (select t1.a t1a, t1.b t1b from t1), (select t2.c t2c, t2.d t2d from t2) WHERE t1b = t2c;

Notice that t3.f in the second query did not require an alias because the table "t3" was part of its immediate SELECT. You could make an alias for every column just in case, I just wanted to highlight the difference.


2007-Feb-13 15:40:31 by anonymous:
Fixing this issue would slow down SELECT parsing and column resolution for all queries (more specifically all prepared statements) due to the recursion required for column resolution. It would be easier to change your SQL code generator to accomodate SQLite. Just make aliases for every table at every subselect level and have the SELECT at any given level only work with the table aliases at that level.
 
2225 code active 2007 Feb scouten   2007 Feb   5 4 Request count of number of inserts and deletes from the free page list edit
As a rough indication of potential fragmentation in the database, we'd like to know how many pages have been added and removed from the free page list.
2007-Feb-10 19:24:13 by drh:
The issue of database fragmentation is also addressed by ticket #2075 (a ticket which I had overlooked prior to today.)
 
2226 code active 2007 Feb scouten   2007 Feb   5 4 Report on unused indices (and tables?) edit
After exercising a particular database heavily, it would be nice to know which indices (and possibly tables) have not been used at all.
 
2219 code active 2007 Feb shess   2007 Feb shess 2 2 Creating an fts table in an attached database works wrong. edit
   ATTACH DATABASE 'test2.db' AS two;
   CREATE VIRTUAL TABLE two.t2 USING fts2(content);

will put t2_content, t2_segments, and t2_segdir in database 'main' rather than database 'two'. In some cases everything will appear to work, because the tables will be defaults for that name.

 
2218 code active 2007 Feb anonymous   2007 Feb   3 4 select columns from views with table prefix edit
I have a table and a view on the table, defined like this:

  create table mytable (mycolumn varchar);
  create view myview as select mytable.mycolumn from mytable;

Now

  select "mycolumn" from myview;

does work, but

  select mycolumn from myview;

gives "unknown column"!

 
2215 code active 2007 Feb anonymous   2007 Feb   1 2 error messages in virtual table are not propagated edit
I'm trying to return a customized error message in xBestIndex in my virtual table implementation. Rather than copying my implementation here the problem can be reproduced by changing the fulltextBestIndex method from fts1.

For example:

    /* Decide how to handle an SQL query. */
    static int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
      int i;
      TRACE(("FTS1 BestIndex\n"));

      pVTab->zErrMsg = sqlite3_mprintf ("THIS IS AN ERROR MESSAGE");
      return SQLITE_ERROR;

      for(i=0; i<pInfo->nConstraint; ++i){
        const struct sqlite3_index_constraint *pConstraint;

If I run the following I do not see the error message reported when using the shell.

    $ ./sqlite3
    SQLite version 3.3.12
    Enter ".help" for instructions
    sqlite> create virtual table foo using fts1(name, address);
    sqlite> insert into foo (name, address) values ('amanda', '43 elm avenue');
    sqlite> select * from foo;
    SQL error: SQL logic error or missing database
 
2214 code active 2007 Feb anonymous   2007 Feb   5 4 lemon generates bad error messages for %destructor edit
When using incorrect syntax for %destructor, lemon generates a bad error message. When I wanted to use %default_destructor, but used %destructor instead:

  %destructor { ... }

I got this error message:

  Symbol name missing after 134583560estructor keyword

This is trivially fixed by replacing "Symbol name missing after %destructor keyword" with "Symbol name missing after %%destructor keyword" twice in lemon.c

 
2203 code active 2007 Jan anonymous   2007 Jan   2 3 table_info pragma "default" column format changed? edit
Beginning with SQLite3 3.3.8, it looks like the format of the 'default' value returned by the table_info pragma has changed. Before, it used to be a bare string:

  dev:~> sqlite3
  SQLite version 3.3.7
  Enter ".help" for instructions
  sqlite> create table testings (a integer primary key, b string default 'Tester', c string default NULL);
  sqlite> pragma table_info(testings);
  0|a|integer|0||1
  1|b|string|0|Tester|0
  2|c|string|0||0

After 3.3.8, the 'defaults' column is now a SQL-quoted string:

  dev:~> sqlite3
  SQLite version 3.3.11
  Enter ".help" for instructions
  sqlite> create table testings (a integer primary key, b string default 'Tester', c string default NULL);
  sqlite> pragma table_info(testings);
  0|a|integer|0||1
  1|b|string|0|'Tester'|0
  2|c|string|0|NULL|0

Now, I think I do prefer the latter, where the default is a SQL-quoted string. However, this seems a rather significant change to make mid-stream, in a minor point release. It broke all Ruby on Rails applications that use sqlite3, for instance, because Rails reads that default value to determine how to default the value of each new record.

Was this intentional? Or is this a bug? I'd love to see this behavior reverted and saved for a release with a more significant release number.

2007-Jan-29 22:01:54 by anonymous:
One of your fellow Railers requested this change: Ticket #2078


2007-Jan-29 22:10:55 by drh:
See also ticket #1919 which might also be an issue here.


2007-Jan-29 22:33:19 by anonymous:
Anonymous, you make it sound as if anyone associated with Rails can make a request of the sqlite3 team and have it be automatically assumed to be sanctioned by the Rails core team. Whoever did the original request did not do so under the umbrella of Rails core. If that change was the one that resulted in this behavior, it most definitely should not have been recommended, and would not have been blessed by any of the core team.

At this point, though, I'm not interested in blame. I just want to see what can be done to make sqlite3 work with Rails again, preferably in a way that is backwards compatible with previous sqlite3 releases.


2007-Jan-30 05:20:56 by anonymous:
I agree the feature should be fixed due to backwards compatability, but Rails should try to accomodate both pragma variants since they are both "in the wild". You could base your decision on the sqlite version string, for instance.


2007-Jan-30 18:39:44 by anonymous:
Just FYI, there's another related ticket at the Rails trac at http://dev.rubyonrails.org/ticket/6523, and a Debian bug report with a patch at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=397531.
 
2183 code active 2007 Jan anonymous   2007 Jan drh 1 1 OMIT_SHARED_CACHE: AV and crash with FTS2 INSERT edit
Given that SQLite is compiled with

  -DSQLITE_ENABLE_FTS2=1
  -DSQLITE_OMIT_SHARED_CACHE=1

the following code crashes after about 273 insertions with

  Access violation: Read of address 0x00000014

at

  btree.c, line 3451: if( pCur->idx>=pPage->nCell ){

Here is the code to reproduce:

  int main(int argc, char* argv[])
  {
     sqlite3_stmt *pStmt;
     int i;

     check( sqlite3_open( "test_fts2.db3", &db) );

     check( sqlite3_exec( db, "CREATE VIRTUAL TABLE FTS USING FTS2 (Content);", 0, 0, 0));
     check( sqlite3_exec( db, "BEGIN TRANSACTION;", 0, 0, 0));

     check( sqlite3_prepare( db, "INSERT INTO FTS (Content) VALUES ('Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy lies a small unregarded yellow sun.');", -1, &pStmt, NULL));
     for( i = 1; i < 1000; i++) {
        printf( "%d\n", i);
        check( sqlite3_step( pStmt) );
        check( sqlite3_reset( pStmt) );
     }

     check( sqlite3_exec( db, "COMMIT;", 0, 0, 0));
     check( sqlite3_finalize( pStmt ));
     check( sqlite3_close( db ));

     printf ("Done");
     scanf ("*%s");

    return 0;
  }

Could this be related to ticket #2032?

 
2182 code active 2007 Jan anonymous   2007 Jan   4 4 sqlite3BtreeGetMeta does not check the file format edit
sqlite3BtreeGetMeta reads database page 1 directly from the pager layer, skipping all of the format checks in lockBtree. Thus, if the very first query you do against a database is "PRAGMA user_version" and the database isn't valid (in particular, if it is an sqlite 2 database) you will get a garbage result rather than an SQLITE_NOTADB or SQLITE_CORRUPT error.

Demonstration:

  $ touch bug1.db                              # empty file
  $ dd if=/dev/zero of=bug2.db bs=100 count=1  # file header all zeroes
  $ sqlite2 bug3.db 'create table a(b);'       # old-format database

  $ sqlite3 bug1.db 'pragma user_version' ; echo $?
  0
  0
  $ sqlite3 bug2.db 'pragma user_version' ; echo $?
  0
  0
  $ sqlite3 bug3.db 'pragma user_version' ; echo $?
  1795162112
  0

Contrast the sensible behavior if you do a SELECT:

  $ sqlite3 bug1.db 'select * from a'; echo $?
  SQL error: no such table: a
  1
  $ sqlite3 bug2.db 'select * from a'; echo $?
  SQL error: file is encrypted or is not a database
  1
  $ sqlite3 bug3.db 'select * from a'; echo $?
  SQL error: file is encrypted or is not a database
  1
2007-Jan-21 22:05:14 by anonymous:
(Submitter:) Is there a reason why the file format check doesn't happen in sqlite3_open?
 
2165 code active 2007 Jan anonymous   2007 Jan drh 4 3 pager performance and checksum edit
pager.c

Embedd the 2 byte pager_pagehash() result into the page, near the beginning of the page. Use the intire page to calculate the pager_pagehash exclusive of the two byte page_hash data embedded in the page. That way a simple xor as in CHECK_PAGE of the entire page including the 2 byte pager_pagehash is all that is needed to validate a page. Also you could include the "4 byte" random at the beginning and at the end... But that would be a bit of overkill. The sampling of only every 200 bytes is interesting.

Review change the SQLITE_CHECK_PAGES ifdef to a SQLITE_OMIT_PAGE_CHECK.. As on disk page validity is very important. Could this be integrated into a pragma setting?

2007-Jan-12 18:08:49 by anonymous:
uint16_t pg_chkval(Dpage *pg, uint32_t pg_size) { register int i; register uint16_t val = 0; register uint16_t *bw = (uint16_t *) pg;

  for(i= 0; i < pg_size;i=i+2  )
      val= val^ *bw++  ;

  return val;
}

uint16_t pg_calcval(Dpage *pg, uint32_t page_size) { int i; register uint16_t val = 0; register uint16_t *bw = (uint16_t *) pg;

  /* Scan up to location where chk val is stored */
  for(i= 0; i < 8;i=i+2  )
       val= val^ *bw++  ;

  val = val^ 0;
  bw ++ ;

  /* Now scan the tail of the block */
  for(i=10; i < page_size;i=i+2 )
      val= val^ *bw++  ;

  return val;
}
 
2140 code active 2007 Jan anonymous   2007 Jan   3 1 sqlite doesn't link to readline edit
sqlite relies on another library to link to libreadline, causing this error with LDFLAGS=-Wl,--as-needed:

gcc -O2 -march=i686 -pipe -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src -DNDEBUG -DTHREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_CURSOR -DHAVE_READLINE=1 -I/usr/include/readline -o .libs/sqlite3 ./src/shell.c ./.libs/libsqlite3.so -lpthread -lncurses /tmp/cclOD1M7.o: In function `process_input': shell.c:(.text+0x37a5): undefined reference to `readline' shell.c:(.text+0x37c0): undefined reference to `add_history' /tmp/cclOD1M7.o: In function `main': shell.c:(.text+0x3f01): undefined reference to `read_history' shell.c:(.text+0x3f1a): undefined reference to `stifle_history' shell.c:(.text+0x3f22): undefined reference to `write_history' collect2: ld returned 1 exit status

 
2132 code active 2006 Dec anonymous   2006 Dec   3 4 table_info, index_list, index_info & friends should be virtual tables edit
The following meta data should be accessible via read-only virtual tables in some sort of sqlite_meta_info table:

  PRAGMA database_list;
  PRAGMA foreign_key_list(table-name);
  PRAGMA index_info(index-name);
  PRAGMA index_list(table-name);
  PRAGMA table_info(table-name);

This would allow complex querying and joins of the meta data of the database. (Pragmas cannot be used as a subquery).

The underlying introspection mechanism can actually be PRAGMA-based for backwards compatability.

 
2131 code active 2006 Dec anonymous   2006 Dec   2 3 Add substring() function (Part of SQL 99) edit
sqlite> SELECT substring('foobar.class',-6,6) = '.class'; SQL error: no such function: substring sqlite> SELECT SUBSTRING('foobar.class',-6,6) = '.class'; SQL error: no such function: SUBSTRING sqlite> SELECT SUBSTR('foobar.class',-6,6) = '.class'; 1 sqlite> SELECT substring('foobar.class' FROM -6 FOR 6) = '.class'; SQL error: near "FROM": syntax error

Looking at: http://www.oreilly.com/catalog/sqlnut/chapter/ch04.html

SQL99 Syntax

SUBSTRING(extraction_string FROM starting_position [FOR length] [COLLATE collation_name])

It would be useful for sqlite to support this syntax too to make the SQL more portable.

2006-Dec-28 16:03:03 by anonymous:
sqlite has the substr() routine (func.c code):

    { "substr",             3, 0, SQLITE_UTF8,    0, substrFunc },
#ifndef SQLITE_OMIT_UTF16
    { "substr",             3, 0, SQLITE_UTF16LE, 0, sqlite3utf16Substr },
#endif
this could be 'aliased' to help you using the substring() SQL99 std just doing:

    { "substr",             3, 0, SQLITE_UTF8,    0, substrFunc },
    { "substring",          3, 0, SQLITE_UTF8,    0, substrFunc },
#ifndef SQLITE_OMIT_UTF16
    { "substr",             3, 0, SQLITE_UTF16LE, 0, sqlite3utf16Substr },
    { "substring",          3, 0, SQLITE_UTF16LE, 0, sqlite3utf16Substr },
#endif
 
2130 code active 2006 Dec anonymous   2006 Dec   4 4 replace "long long int" type with "sqlite_int64" defined in sqlite3.h edit
As the typedef "typedef long long int sqlite_int64" is available in sqlite3.h. Please ensure that remaining references to "long long" use this typedef (for 32bit compilers):

Searching for 'long long int'... sqlite3.h(89): typedef long long int sqlite_int64;

sqlite3.h(90): typedef unsigned long long int sqlite_uint64;

os_common.h(67):__inline__ unsigned long long int hwtime(void){

os_common.h(68): unsigned long long int x;

os_common.h(74):static unsigned long long int g_start;

sqliteInt.h(185):** cc '-DUINTPTR_TYPE=long long int'

vdbe.c(365):__inline__ unsigned long long int hwtime(void){

vdbe.c(366): unsigned long long int x; 8 occurrence(s) have been found.

thanks

 
2125 code new 2006 Dec anonymous   2006 Dec   4 4 SQLite strings/blobs limited to 1GB/2GB due to 'int' in api edit
In several places it is claimed that SQLite doesn't have arbitrary limits - eg http://www.tcl.tk/community/tcl2004/Papers/D.RichardHipp/drh.html

However the size of strings and blobs is limited due to using int in the APIs. Since int is 32 bit even on 64 bit platforms, that limits the size of individual strings to 2GB. For strings with a UTF16 database that means 1 billion characters. UTF8 strings are anywhere from 2 billion characters to 250 million worst case.

When integrating SQLite into 64 bit code, I have to verify the sizes of all strings and blobs being passed in to ensure they don't overflow the signed 32 bit int.

It would be nice if SQLite supported larger objects on 64 bit platforms. There may also be internal problems with the use of int everywhere. For example I could store a 1.5 billion byte UTF8 string and then request it back via the UTF16 api.

2006-Dec-21 23:47:22 by drh:
On a 64-bit platform "int" is 64-bits. So apparently you can store blobs and strings larger than 2GiB. But SQLite is not designed for this and you would do much better to store such massive objects in a separate file then store the filename in the database.


2006-Dec-22 08:37:46 by anonymous:
On a 64-bit platform "int" is 64-bits

This is not true for all platforms. On MS Platforms: "int" is always 32 bit.


2006-Dec-23 11:55:45 by anonymous:
I don't know of any 64 bit platform where int is 64 bits (ie ILP64). Here are the sizes on x64 Linux with gcc:

sizeof(int) = 4 sizeof(short) = 2 sizeof(long) = 8 sizeof(long long) = 8 sizeof(void*) = 8

There is a good list of what is supported on which platforms on Wikipedia. http://en.wikipedia.org/wiki/64-bit#64-bit_data_models Note "Most 64 bit compilers today use the LP64 model (including Solaris, AIX, HP, Linux, MacOS native compilers), Microsoft however decided to use the LLP64 model."

Note that this means it is impossible to use sizes larger than 2GB with SQLite using int in the API. And while I agree that SQLite isn't the ideal solution for this much data, you do claim no arbitrary limits! Additionally 64 bit code has to ensure that it never gives more than a signed int worth of data. I also suspect that wierd things would happen if too large values are given.

The usual way this is solved in other libraries is to use the size_t and ssize_t types which will always be sized appropriately for the platform. You could even define your own size types such as sqlite3_size_t (that is what Python did).


2006-Dec-25 12:25:57 by anonymous:
Actually I can categorically prove that the current SQLite code is broken and that bad things will happen. The front page of the site says "Sizes of strings and BLOBs limited only by available memory."

Using a simple example, I looked at the implementation of sqlite3_value_text which takes an int. Lets assume -1 is passed in. That calls bindText which calls sqlite3VdbeMemSetStr. That ultimately executes this code:

      if( n<0 ){
        pMem->n = strlen(z);

pMem->n is of integer type, ie signed 32 bits on all current platforms (32 bit and 64 bit). The memory being pointed to could be more than 2GB on a 64 bit platform. strlen's return type is size_t which is 64 bits on 64 bit platforms. Consequently the strlen returned will have the top 32 bits ignore in the code above and SQLite will store a negative number or a number smaller than the actual length of the string.

This means that data will be lost (positive truncation) or that wierd things will happen (negative truncation, several assert failures).

Note that there is the potential for problems even on 32 bit machines. For example a 1.1GB UTF8 string can be supplied and then be requested in UTF16 which will be 2.2GB and make the ints go negative.

I suggest one or more of the following fixes:

  • Remove the claim on the front page about only being limited by memory since this isn't true
  • Document that strings larger than 500MB (UTF8) should not be used and will result in undefined behaviour (worst case UTF8 to UTF16 expansion could be 4 bytes?)
  • Document that blobs larger than 2GB should not be used and will result in undefined behaviour
  • Switch to using size_t and ssize_t in the APIs. If using a signed type (eg ssize_t) for the string APIs then the 500MB limit still remains on 32 bit machines.
 
2128 code active 2006 Dec anonymous   2006 Dec   4 3 virtual table code doesn't verify type of rowid (calling xUpdate) edit
The virtual tables code doesn't verify the type of rowid when calling update. For example I used the following query:

UPDATE foo SET rowid='a string' WHERE 1

This results in a call to xUpdate with argv[0] equal the current rowid but argv[1] is 'a string'. While I'd be quite happy for rowids to be any SQLite type, the xRowid call only allows 64 bit integers. I believe SQLite should check the new rowid in a case like this is an integer and reject it, rather than calling xUpdate with the bad value. (I also just checked with rowid=3.4 and rowid=NULL and they get passed through as is as well)

A workaround is to document that the xUpdate method must check the new rowid is an integer type.

 
2127 code active 2006 Dec anonymous   2006 Dec   2 3 Virtual tables do not always free zErrmsg edit
The documentation for virtual tables and in particular the sqlite3_vtab structure says "The SQLite core will free and zero the content of zErrMsg when it delivers the error message text to the client application or when it destroys the virtual table."

The latter part does not appear to be true ("when it destroys the virtual table"). I can't find any code that does actually that. (eg vtab.c:496 definitely doesn't, nor does vtab.c:76)

Usually the former case happens. However some operations have their error codes ignored (eg xClose). This can result in the zErrMsg pointing to a message but no error code returned upstream (which would clear the message). Finally as far as I can tell the responsibility for freeing sqlite3_vtab is with the xDisconnect/xDestroy callbacks since the corresponding xCreate/xConnect callbacks allocated it. Consequently there is no way for SQLite to even access zErrmsg since it would be a member of a freed structure after xDisconnect/xDestroy returned.

 
2126 code active 2006 Dec anonymous   2006 Dec   3 1 Update hook not invoked when deleteing all rows from table edit
I was testing the update hook feature of SQLite and incidentally I noticed that hook is not invoked for "DELETE FROM" statement with no WHERE clause. Hook works well for "DELETE FROM ... WHERE ..." statement.

Steps to reproduce:

  1. Open database, setup update hook
  2. Execute:
    CREATE TABLE Test(Test INTEGER);
  3. Insert some data:
    INSERT INTO TEST (Test) VALUES (1); -- update hook invoked for INSERT
    INSERT INTO TEST (Test) VALUES (2); -- update hook invoked for INSERT
    INSERT INTO TEST (Test) VALUES (3); -- update hook invoked for INSERT
  4. Execute:
    DELETE FROM TEST; -- update hook IS NOT INVOKED(!) for each row.
2006-Dec-22 15:38:44 by drh:
Triggers don't work either. This is a feature not a bug. When you do "DELETE FROM table" with no WHERE clause, SQLite drops and recreates the table. Doing it this way have a huge speed boost.

If you really need the update hook to work add a "WHERE 1" to the end of the query.


2006-Dec-22 16:11:11 by anonymous:
I don't really need it, maybe other users. You should update the documentation of sqlite3_update_hook() and triggers mentioning this behaviour.

Another solution is to perform "DELETE FROM" as if it was with WHERE clause, if there is an update hook regitered.

 
2112 code active 2006 Dec anonymous   2006 Dec   5 4 code compatibility with C++ edit
I need to compile SQLite with C++ compiler (GCC 3.4.5 from MingW). I also compiled the code as single translation unit, by including all relevant source files into single *.cpp file. To make it working I needed to make several dozens of small fixes.

    Problems I found:
  • 1. <vdbeInt.h> does not have guarding macros
  • 2. <os_common.h> does not have guarding macros
  • 3. parser.y used symbol"not" which is reserved in C++ and transformed to "!"
  • 4. pager.c redefines macros TRACE1 ... TRACE5 which are already defined elsewhere. With several files in one TU this clashes.
  • 5. Inner structures and name lookup. With structures like
      struct SrcList {
        ...
        struct SrcList_item {
        ...
    

C++ requires full qualification, e.g.

  struct SrcList::SrcList_item* p = ... // OK
  struct SrcList_item* p = ... // ERROR

  • 6. Code like
    char* p = sqlite3Malloc(...)
    

fails to compile without cast.

  • 7. There are few dozens of places where a signed value is compared with unsigned one and compiler emits a warning.

If some of the points above get eliminated than the porting should be much easier - it was few boring hours of change-try compile-fix cycle for me.

2006-Dec-19 16:42:35 by anonymous:
this software is written in C with a lemon grammar parser (parser.y), and it&#180;s compiled with GCC compiler suite (GCC, not G++). Also, the source code is not C++ compliant, and isn't structured for a single source file, so avoid reporting tickets like this in the trac, use mailing list to ask things, only report errors here.


2006-Dec-19 17:21:15 by anonymous:
It's fine to ask for reasonable features like making the code C++ clean. Just use a lower priority (4 or 5), as the original ticket poster did.
 
1946 code new 2006 Aug anonymous Unknown 2006 Dec   2 2 .read file fails on blob fields with end-of-file char edit
I've a table with a blob fields. I put there binary data that contains 0x1a (end of file) symbol. It's alright until i try to dump table to file and then trying to import that file.

sqlite3 my_db
>.output my_file
>.dump table_with_blob
>.exit
del my_db

sqlite3 my_db
>.read my_file

Fails with "Incomplete SQL: ..." SQL break before 0x1a char

I'm on windows. Possibly solving with opening file as binary file.

Sorry for my English

 
2100 code active 2006 Dec anonymous   2006 Dec   1 1 Fixes for SQL lower() and upper() edit
As acknowledged in the documentation, the SQL lower() and upper() functions might not work correctly on UTF-8 characters. This bug might show if a country specific locale is used instead of the standard C locale. Under certain circumstances, SQL lower() or upper() can even corrupt the UTF-8 string into invalid UTF-8 if the tolower() and toupper() C functions convert character values starting from 0x80.

Below I propose implementations of lowerFunc() and upperFunc() which work correctly with UTF-8 characters, regardless of the implementation of the C library tolower() and toupper() functions. If these C functions are implemented to support high ASCII or even Unicode case conversion, the new SQL lower() and upper() will support them as well.

The proposed C implementation applies a technique also found in sqlite3VdbeMemTranslate() in utf.c and makes use of some macros contained in that unit. To avoid duplicating existing code, it could make sense to move lowerFunc() and lowerFunc() to utf.c, just as it has been done with sqlite3utf16Substr().

Finally, here is the code:

  /*
  ** Implementation of the upper() and lower() SQL functions.
  */
  static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
    const unsigned char *zIn, *zInTerm;
    unsigned char *z, *zOut;
    int c, l;
    if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
    zIn = sqlite3_value_text(argv[0]);
    if( zIn==0 ) return;
    l = sqlite3_value_bytes(argv[0]);
    zInTerm = &zIn[l];
    /* When converting case, the maximum growth results from
    ** translating a 1-byte UTF-8 character to a 4-byte UTF-8 character.
    */
    zOut = sqliteMalloc( l * 4 );
    z = zOut;
     while( zIn<zInTerm ){
       READ_UTF8(zIn, c);
       c = toupper(c);
       WRITE_UTF8(z, c);
     }
    sqlite3_result_text(context, zOut, z-zOut, sqlite3FreeX);
  }

  static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
    const unsigned char *zIn, *zInTerm;
    unsigned char *z, *zOut;
    int c, l;
    if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
    zIn = sqlite3_value_text(argv[0]);
    if( zIn==0 ) return;
    l = sqlite3_value_bytes(argv[0]);
    zInTerm = &zIn[l];
    /* When converting case, the maximum growth results from
    ** translating a 1-byte UTF-8 character to a 4-byte UTF-8 character.
    */
    zOut = sqliteMalloc( l * 4 );
    z = zOut;
     while( zIn<zInTerm ){
       READ_UTF8(zIn, c);
       c = tolower(c);
       WRITE_UTF8(z, c);
     }
    sqlite3_result_text(context, zOut, z-zOut, sqlite3FreeX);
  }
2006-Dec-05 19:07:32 by anonymous:
I'm not sure this is an improvement. The argument to the ctype.h functions tolower(int C) and toupper(int C) is only defined when C is an integer in the range `EOF' to `255'. The compiler implementation may return garbage for values outside this range.


2006-Dec-06 16:17:23 by anonymous:
The integer in the range 'EOF' to '255' is exactly the problem with the existing implementation: This range will (and does, in some cases) modify UTF-8 bytes (not a character) starting from 128, which can lead to invalid UTF-8 sequences.

If the result of tolower() is indeed undefined for values greater than 255 in some C-implementations then I agree that adding this check to the new code will probably be a good thing:

  if( c < 256 ){
    c = tolower(c);
  }

If, on the other hand, tolower() just returns the character unchanged for values greater than 255, then this check is not necessary.

I want to emphasize once more that the proposed new SQL lower() and upper() implementations never return invalid UTF-8, whereas the current implementation sometimes does. This is, by itself, already a great improvement.


2006-Dec-07 15:29:07 by anonymous:
This modified patch does better than previous if SQLITE_UNICODE_UPPERLOWERFUNCS is defined at compile time, because it uses libc _wcsupr / _wcslwr routines.

  #ifdef SQLITE_UNICODE_UPPERLOWERFUNCS
    #define WCHAR_T_SIZE		sizeof(wchar_t)
    #if (WCHAR_T_SIZE == 2)
    #define MAXUPPERLOWERCHAR_AVAIL 	0x0000ffff
    #else // (WCHAR_T_SIZE == 4)
    #define MAXUPPERLOWERCHAR_AVAIL 	0x7fffffff
    #endif // (WCHAR_T_SIZE == 2)
    #define TOLOWERSQLFUNC(c) unicode_tolower
    #define TOUPPERSQLFUNC(c) unicode_toupper
    int unicode_tolower(const int c) {
      wchar_t buff [2];
      if (c > MAXUPPERLOWERCHAR_AVAIL)
        return c;
      buff[0] = (wchar_t) c;
      buff[1] = 0;
      _wcslwr(buff);
      return (int) buff[0];
    }
    int unicode_toupper(const int c) {
      wchar_t buff [2];
      if (c > MAXUPPERLOWERCHAR_AVAIL)
        return c;
      buff[0] = (wchar_t) c;
      buff[1] = 0;
      _wcsupr(buff);
      return (int) buff[0];
    }
  #else // SQLITE_UNICODE_UPPERLOWERFUNCS
    #define TOLOWERSQLFUNC(c) (c > 255 ? c : tolower(c))
    #define TOUPPERSQLFUNC(c) (c > 255 ? c : toupper(c))
  #endif // SQLITE_UNICODE_UPPERLOWERFUNCS

  /*
  ** Implementation of the upper() and lower() SQL functions.
  */
  static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
    const unsigned char *zIn, *zInTerm;
    unsigned char *z, *zOut;
    int c, l;
    if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
    zIn = sqlite3_value_text(argv[0]);
    if( zIn==0 ) return;
    l = sqlite3_value_bytes(argv[0]);
    zInTerm = &zIn[l];
    /* When converting case, the maximum growth results from
    ** translating a 1-byte UTF-8 character to a 4-byte UTF-8 character.
    */
    zOut = sqliteMalloc( l * 4 );
    z = zOut;
     while( zIn<zInTerm ){
       READ_UTF8(zIn, c);
       c = TOUPPERSQLFUNC(c);
       WRITE_UTF8(z, c);
     }
    sqlite3_result_text(context, zOut, z-zOut, sqlite3FreeX);
  }

  static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
    const unsigned char *zIn, *zInTerm;
    unsigned char *z, *zOut;
    int c, l;
    if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
    zIn = sqlite3_value_text(argv[0]);
    if( zIn==0 ) return;
    l = sqlite3_value_bytes(argv[0]);
    zInTerm = &zIn[l];
    /* When converting case, the maximum growth results from
    ** translating a 1-byte UTF-8 character to a 4-byte UTF-8 character.
    */
    zOut = sqliteMalloc( l * 4 );
    z = zOut;
     while( zIn<zInTerm ){
       READ_UTF8(zIn, c);
       c = TOLOWERSQLFUNC(c);
       WRITE_UTF8(z, c);
     }
    sqlite3_result_text(context, zOut, z-zOut, sqlite3FreeX);
  }
 
2096 code active 2006 Dec anonymous   2006 Dec   3 3 ATTACH DATABASE returns SQLITE_ERROR when database is locked edit
From an email sent to DRH:

I am working on a problem surrounding the inability to ATTACH to a database file. The error text being returned is "database is locked", which should be SQLITE_BUSY, however, the error code being returned by sqlite3_exec is SQLITE_ERROR. Is sqlite3_exec wrong in returning SQLITE_ERROR rather than SQLITE_BUSY? I have some nagging feeling that I determined or read that the attachFunc function does not return a truly-relevant status code, but I can't see why offhand nor can I find any evidence to support that theory. If sqlite3_exec is doing the right thing, however, then the question becomes one of identifying when to retry the ATTACH statement; we're currently keying off SQLITE_BUSY or SQLITE_LOCKED, as appropriate, and I'd rather not be trying to trap errors based on error text.

 
2093 code active 2006 Dec anonymous   2006 Dec   2 3 sqlite3_vtab_cursor doesn't have errMsg edit
The sqlite3_vtab_cursor structure doesn't have a zErrMsg pointer. Only the containing vtable does. This means that operations on cursor objects that have an error have to set the error on the vtable not the cursor. Unfortunately this means that there are race conditions since two different cursors on the same vtable could have errors at the same time. If the cursors are in different threads then a crash or worse can happen.
 
2046 code active 2006 Oct anonymous   2006 Nov shess 1 1 FTS1 - Error closing database due to unfinished statements edit
The following script causes an error in SQLite3.exe with FTS1. The error will surface only AFTER the script has finished AND you have typed .exit at the sqlite> prompt to quit SQLite3.

The problem seems that the SELECT statement is not properly finalized due to an internal error.

  -- The next line is for Windows only, please adopt it
  -- if running Linux or use a FTS1-enabled SQLite3 binary.
  select load_extension ('fts1.dll');

  CREATE TABLE Snippets(
    SnippetID INTEGER PRIMARY KEY,
    SnippetTitle TEXT,
    FtsID INTEGER);

  CREATE VIRTUAL TABLE SnippetsFts USING FTS1 (SnippetTitle, SnippetText);

  INSERT INTO Snippets (SnippetTitle) VALUES ('one');
  INSERT INTO Snippets (SnippetTitle) VALUES ('two');

  SELECT SnippetID FROM Snippets JOIN SnippetsFts ON FtsID = +SnippetsFts.RowID
    WHERE SnippetsFts MATCH 'one';

  -- After the script is done, type .exit at the prompt to close the database.
  --
  -- SQLite3 will close, but report the following error before doing so:
  --
  --   "error closing database: Unable to close due to unfinalised statements"
  --
  --  Does this qualify for a bug?

The script is also attached to this ticket.

2006-Nov-27 22:58:49 by shess:
Attached tighter version of the replication script, generated in isolating what mattered to the bug.
 
2089 code active 2006 Nov anonymous   2006 Nov   3 3 Decouple sqlite_int64 from other 64bit datatypes edit
Currently sqlite3 makes the (valid) assumption that sqlite_int64 (or i64, u64) is 64 bit wide, matches with Tcl_WideInt and has the same datasize (and byte order) than double. The following patch fixes this and allows sqlite_int64 to be any integral type, e.g. a 32bit int (with the limitations of the reduced datatype size).

The use case for this is for systems that do not support 64bit integers (e.g. lack of compiler feature, embedded system), db's of small data size, and systems without large file support. The patch allows compiling with -DSQLITE_INT64_TYPE=int -DSQLITE_32BIT_ROWID for such a system.

2006-Nov-29 01:13:07 by anonymous:
Hm, now I wanted to add the patch file but I don't get the formatting right without editing the file and removing empty lines. How am I supposed to add a patch file (created with diff -ru)?
 
2086 code active 2006 Nov anonymous   2006 Nov   5 4 Alias in update edit
Aliases at UPDATE clause doesn't work, i.e.:

UPDATE table1 t1 SET uid=(SELECT rowid FROM table2 WHERE uid=t1.uid AND data=t1.data);

Code whithout aliases work fine.

 
2084 code active 2006 Nov anonymous   2006 Nov   4 3 Add API function mapping column decl string to SQLite type edit
This is an API feature request.

It would be nice to be able to obtain the SQLite type (e.g. SQLITE_INTEGER) from the declared column type string as returned by sqlite3_column_decltype.

This was discussed briefly on the mailing list here: http://marc.10east.com/?l=sqlite-users&m=116422872301957&w=2

The function I have in mind is:

int sqlite3_decltype_to_type(const char *decl) { Token decl_token; char aff_type; int col_type;

    decl_token.z = decl;
    if( decl_token.z ){
        decl_token.n = strlen(decl_token.z);
        aff_type = sqlite3AffinityType(&decl_token);
        switch( aff_type ){
        case SQLITE_AFF_INTEGER:
            col_type = SQLITE_INTEGER;
            break;
        case SQLITE_AFF_NUMERIC: /* falls through */
        case SQLITE_AFF_REAL:
            col_type = SQLITE_FLOAT;
            break;
        case SQLITE_AFF_TEXT:
            col_type = SQLITE_TEXT;
            break;
        case SQLITE_AFF_NONE:
            col_type = SQLITE_BLOB;
            break;
        default:
            col_type = 0; /* unknown */
            break;
        }
    }
    return col_type;
}

If this seems agreeable, I would be willing to put together a real patch. However, I would need some guidance on where it should go. I'm not sure what should happen when no type can be determined.

2006-Nov-26 22:32:45 by anonymous:
According to the comment above the function sqlite3AffinityType: "If none of the substrings in the above table are found, SQLITE_AFF_NUMERIC is returned". The default condition in sqlite3_decltype_to_type will not be reached.


2006-Nov-26 23:04:23 by anonymous:
Thanks for pointing to that comment. Looks like SQLITE_AFF_NUMERIC is, for these purposes, unknown. So the case statement could be:

        switch( aff_type ){
        case SQLITE_AFF_INTEGER:
            col_type = SQLITE_INTEGER;
            break;
        case SQLITE_AFF_REAL:
            col_type = SQLITE_FLOAT;
            break;
        case SQLITE_AFF_TEXT:
            col_type = SQLITE_TEXT;
            break;
        case SQLITE_AFF_NONE:
            col_type = SQLITE_BLOB;
            break;
        case SQLITE_AFF_NUMERIC: /* falls through */
        default:
            col_type = 0; /* unknown */
            break;
        }


2006-Nov-27 02:43:06 by anonymous:
Your first function was correct, it just had some unreachable code. There's no unknown affinity, in the absence of a match the affinity is assumed to be numeric:

  int sqlite3_decltype_to_type(const char *decl) {
    int type = SQLITE_FLOAT;
    if( decl ){
        Token token;
        token.z = decl;
        token.n = strlen(token.z);
        switch( sqlite3AffinityType(&token) ){
        case SQLITE_AFF_INTEGER:
            type = SQLITE_INTEGER;
            break;
        case SQLITE_AFF_TEXT:
            type = SQLITE_TEXT;
            break;
        case SQLITE_AFF_NONE:
            type = SQLITE_BLOB;
            break;
        default:
            break;
        }
    }
    return type;
  }
 
2083 code active 2006 Nov anonymous   2006 Nov   4 4 Give more detailed extension loading error information with dlerror edit
When using loadable extensions. if dlopen returns an error then SQLite just gives a generic "unable to open shared library" message back. This makes it quite hard to diagnose problems.

I suggest that on Unix platforms you append %s/dlerror() to the message and on Windows append %d/GetLastError()

 
2082 code active 2006 Nov anonymous   2006 Nov   3 4 UNIX: configure script doesn't enable loading of extensions edit
The code in loadext.c:234 looks for HAVE_DLOPEN being #defined in order to enable library loading on Linux. However as best I can tell, the configure script never looks for dlopen. It does look for dlfcn.h. (Based on examining the output of configure and config.log)

Consequently extension loading isn't available on Unixen that do support it if you build using ./configure

Work around is to use this commmand:

   env CFLAGS="-DHAVE_DLOPEN" ./configure
2006-Nov-26 20:53:59 by drh:
The "autoconf" command is busted in SuSE 10.2, which is the OS I am currently running. So I am unable to rebuild configure after editing configure.ac. Until the autoconf problem is resolved, I am unable to address the request in this ticket. Sorry.


2006-Nov-26 22:36:48 by anonymous:
What happens when you upgrade to the latest version of autoconf for SuSE? I'm sure someone on the list could help you resolve this issue.


2006-Nov-27 07:05:27 by anonymous:
I am actually using Gentoo.

There is a trivial workaround as I noted so there is no need for a solution for 3.3.8. It would be nice to have it fixed for whatever version comes next so that I don't need to document the workaround.


2006-Nov-27 18:32:11 by anonymous:
Another open autoconf ticket:

Check-in [3397] : Add HAVE_GMTIME_R and HAVE_LOCALTIME_R flags and use them if defined. Unable to modify the configure script to test for gmtime_r and localtime_r, however, because on my SuSE 10.2 system, autoconf generates a configure script that does not work. Bummer. Ticket #1906

 
2081 code active 2006 Nov anonymous   2006 Nov doughenry 1 1 sqlite3_column_decltype throws exception, if selection is grouped edit
If I "group by" a selection over several columns I can't find out the orgin type of these columns using sqlite3_column_decltype(..). An exception is thrown.
2006-Nov-23 18:37:47 by anonymous:
You also get no decl type from a subselect. This goes to the typeless nature of SQLite - I don't think a type can even be derived in this case.
 
2080 code active 2006 Nov anonymous   2006 Nov   4 4 Tranfering large BLOB data not efficient edit
The current approach for tranfering BLOB data (sqlite3_bind_blob, sqlite3_column_blob) is not efficent for large BLOBs, since the whole BLOB data needs to be kept (multiple times?) in memory.

It would be nice to have (additional) methods for streaming the (large) BLOB data to/from the database. Alternatively we could have methods for transfering the BLOB data in chunks.

Same holds to some extend for large text fields.

2006-Dec-03 09:53:02 by anonymous:
What is your definition of large? (1MB, 100MB, 1GB?)

Note also that SQLite has an upper limit of 2GB on a field due to the use of signed int in the apis which is 32 bit even on 64 bit platforms. That will limit you to 2GB for blobs, 1GB for UTF-16 strings and somewhere inbetween for UTF-8 strings

 
2077 code active 2006 Nov anonymous   2006 Nov   2 1 Problems with using ASCII symbols 0x80 - 0xFF in database path edit
Platform: Windows.

The SQLite library and executable doesn't see database files that are placed into folders named using ASCII symbols with codes 0x80-0xFF. That symbols are used to represent language-specific symbols (for example, Russian). In result, database cannot be placed into folder with name in Russian language. This bug is "unstable": it doesn't appear in all cases. Below are logs from my experiments with this problem. In all cases the path I requested exists, and database file is placed there. I have noticed that problem depends on filename path and name lengths. =========================================================
// creating test database
E:\!DISTRIB\sqlite-3_3_7>sqlite3.exe test.sqb
SQLite version 3.3.7
Enter ".help" for instructions
sqlite> create table a(id int);
sqlite> insert into a values (1);
sqlite> ^C

E:\!DISTRIB\sqlite-3_3_7>copy test.sqb e:\test.sqb
'3'\'`'a'Z'b'`'S'Q'_'` 'f'Q'[']'`'S: 1. //This means that 1 file was copied

E:\!DISTRIB\sqlite-3_3_7>sqlite3 e:\test.sqb
SQLite version 3.3.7
Enter ".help" for instructions
sqlite> select * from a;
1
sqlite> ^C
// Works!

E:\!DISTRIB\sqlite-3_3_7>mkdir e:\'/

//Using ASCII symbol "'/" (0x8D) to represent cyrillic letter which can be entered in the command line by using Alt+(141) combination

E:\!DISTRIB\sqlite-3_3_7>copy test.sqb E:\'/\test.sqb
'3'\'`'a'Z'b'`'S'Q'_'` 'f'Q'[']'`'S: 1.

E:\!DISTRIB\sqlite-3_3_7>sqlite3 e:\'/\test.sqb
SQLite version 3.3.7
Enter ".help" for instructions
sqlite> select * from a;
1
sqlite> ^C
// That is works too!

E:\!DISTRIB\sqlite-3_3_7>mkdir E:\'/\1
E:\!DISTRIB\sqlite-3_3_7>copy test.sqb E:\'/\1\test.sqb
'3'\'`'a'Z'b'`'S'Q'_'` 'f'Q'[']'`'S: 1.
E:\!DISTRIB\sqlite-3_3_7>sqlite3 E:\'/\1\test.sqb
Unable to open database "E:\(T\1\test.sqb": unable to open database file
// Doesn't work, and writes the wrong symbol "(T" in place of "'/"! I've noticed that if we convert symbol "'/" from DOS encoding to Windows encoding and then write it in DOS encoding, then we'll get "(T".

E:\!DISTRIB\sqlite-3_3_7>copy test.sqb E:\'/\tst.sqb
'3'\'`'a'Z'b'`'S'Q'_'` 'f'Q'[']'`'S: 1.

E:\!DISTRIB\sqlite-3_3_7>sqlite3 E:\'/\tst.sqb
SQLite version 3.3.7
Enter ".help" for instructions
sqlite> select * from a;
SQL error: no such table: a
sqlite> ^C

// It seems to work, i don't get an error, but doesn't see the tables! =(
=================================
 
2076 code active 2006 Nov anonymous   2006 Nov a.rottmann 1 1 % exists as value in varchar edit
abnormal abend of client application (C++) when sqlite returns stream of data containing "%" value. Is % a special character?
2006-Nov-21 14:14:25 by anonymous:
% is not a special character. Can you post a small C program demonstrating the problem?
 
2074 code active 2006 Nov anonymous   2006 Nov   4 4 feature request: .dump with page_size edit
It would be useful for sqlite shell users to have a .dump command variant that would cause .dump to output the current database setting of "PRAGMA page_size;". Something similar to:

  sqlite> .dump2
  PRAGMA page_size=16364;
  ...rest of dump...

This way they can trivially preserve the page size when exporting/importing data from/to SQLite:

  sqlite3 old.db .dump2 | sqlite3 new.db

without resorting to non-portable shell gymnastics:

  (echo -n "PRAGMA page_size=" ; sqlite3 old.db "PRAGMA page_size;" ; echo ";" ; ./sqlite3.exe old.db .dump) | sqlite3 new.db

Perhaps other PRAGMA settings could also optionally be exported (legacy_file_format, cache size, etc).

 
2070 code active 2006 Nov anonymous   2006 Nov   4 4 No error for ambiguous result alias in WHERE clause edit
This SELECT should result in an error since 'x' is ambiguous:

  select a x, 2*a x from (select 3 a union select 4 a) where x>3;
  4|8

The current heuristic seems to be the first matching result set expression alias from left-to-right "wins".

2006-Nov-17 19:38:15 by anonymous:
In this test case, the right-most ambiguous expression wins:

  CREATE TABLE t1(a);
  INSERT INTO t1 VALUES(3);
  INSERT INTO t1 VALUES(4);
  INSERT INTO t1 VALUES(5);
  select a*2 a, a from t1 where a>4;
  10|5

It appears that table values take precedence over result set aliases in where clauses.

 
2068 code active 2006 Nov anonymous   2006 Nov   4 4 pkgIndex.tcl contains incomplete version number edit
The pkgIndex.tcl file generated by sqlite 3.3.8 contains the line:

  package ifneeded sqlite3 3.3 ...

Whereas the library actually provides version 3.3.8. In a 8.5 Tcl interpreter, this results in an error message when package require'd:

  attempt to provide package sqlite3 3.3 failed: package sqlite3 3.3.8 provided instead

The solution seems to be to adjust the Makefile.in tcl_install target to pass $(RELEASE) rather than $(VERSION) to the tclinstaller.tcl script.

 
2066 code active 2006 Nov anonymous   2006 Nov   2 2 Incorrect error message in the case of ENOLCK edit
If you're trying to open a sqlite database that is stored on a filesystem that doesn't support locking, then you'll get the error when you try to execute any commands on it:

    Error: file is encrypted or is not a database

If you run sqlite under strace, you see:

   read(0, ".schema\n.quit\n", 4096)       = 14
   fcntl64(3, F_SETLK64, {type=F_RDLCK, whence=SEEK_SET, start=1073741824, len=1}, 0xafa5cd70) = 0
   fcntl64(3, F_SETLK64, {type=F_RDLCK, whence=SEEK_SET, start=1073741826, len=510}, 0xafa5cd70) = 0
   fcntl64(3, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=1073741824, len=1}, 0xafa5cd70) = 0
   access("/mnt/www/zzz_old_sites/trac.db-journal", F_OK) = -1 ENOENT (No such file or directory)
   fstat64(3, {st_mode=S_IFREG|0644, st_size=584704, ...}) = 0
   _llseek(3, 0, [0], SEEK_SET)            = 0
   read(3, "** This file contains an SQLite "..., 1024) = 1024
   fcntl64(3, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}, 0xafa5cdd0) = -1 ENOLCK (No locks available)
   write(2, "Error: file is encrypted or is n"..., 46Error: file is encrypted or is not a database

Sqlite should really check the exact error code, and give a more helpful error (eg "Locking not available on this filesystem. Databases may only be stored on filesystems that support locking")

 
1992 code active 2006 Sep anonymous   2006 Nov shess 1 1 FTS1: Problems after dropping utility tables edit
There are problems if FTS1 utilities tables are dropped from a database. See following SQL for details.

  drop table if exists x;

  -- Create a FTS1 table.

  create virtual table x using fts1 ('content');

  -- Drop table x_content: Works fine, but should this be allowed?
  -- The same errors below also show if table x_term is dropped.

  drop table x_content;

  -- All attempts to access table x now result in errors,
  -- including dropping table x. There seems to be no way out
  -- except of recreating the database. All three commands below
  -- cause the same error, regardless if executed in sequence
  -- or individually:

  insert into x (content) values ('one two three'); -- Error!

  delete from x; -- Error!

  drop table x; -- Error!
Added "not exists" to allow dropping an fts table with corrupted backing. Allowing updates to such tables is unlikely to happen (not even clear what it would mean, in most cases!).
 
2063 code active 2006 Nov anonymous   2006 Nov   4 4 vtab_err.test fails if sqlite is compiled without -DSQLITE_MEMDEBUG edit
I noticed that when running `make fulltest', vtab_err.test fails with an error message like this one (repeated over and over) if sqlite has been compiled without the option -DSQLITE_MEMDEBUG

	vtab_err-2.1...
	Error: invalid command name "sqlite_malloc_fail"

altermalloc.test also has the same "sqlite_malloc_fail" command in it, but it doesn't cause an error because it skips the test if it detects that -DSQLITE_MEMDEBUG isn't available. I'll attach a patch that should fix it. The code is pretty much copied directly from altermalloc.test.

 
2062 code active 2006 Nov anonymous   2006 Nov   4 4 document 'pk' column of PRAGMA table_info() edit
Comment in pragma.c and sqlite.org/pragma.html does not mention the sixth column of PRAGMA table_info().
 
2061 code active 2006 Nov anonymous   2006 Nov anonymous 5 5 cleanup for quickstart.html edit
just compiled the C example from quickstart.html (gcc/glibc Debian SID) a small hint (a bit pea-counting): to avoid warnings either #include<stdlib.h> for the exit() function or (maybe better) use return instead of calling exit().
 
2059 code active 2006 Nov anonymous   2006 Nov   1 1 Still missing .DEF file from Windows 3.3.8 source code distribution edit
The file sqlite3.def is missing from the zip archive of sources used to build sqlite3 on Windows. Ticket number 2031 was closed with a remark that this file is generated during the build process. That is true if one is building on Linux with MinGW32 configured as a cross-compiler. If one were building using that method then I assume one would not be downloading the src.zip archive anyway.

My impression is that the src.zip archive is prepared once the build has been performed on Linux so Windows developers can directly build sqlite (and the generated files) without need of the other tools that the build process depends on. If this is accurate, then it would be very helpful if the src.zip archive could also include the sqlite3.def file. Without this file it is not possible for Windows developers to create a DLL from the src.zip archive.

Thanks

2006-Nov-09 20:05:23 by anonymous:
Works fine as is with MinGW ./configure && make sqlite3.exe
 
2057 code active 2006 Nov anonymous   2006 Nov   3 1 full_column_names when 2 or more tables are joined is not working edit
Version 2.8 has the behavior described in the documentation in respect to full_column_names when 2 or more tables are present with (table/alias).*, but 3.3.8 doesn't, mixing the pragmas "full_column_names" and "short_column_names" can only force to have full_column_names allways or never, some programs expect the behavior described in the documentation to remain working.
2006-Nov-08 20:10:13 by anonymous:
Version 3.3.3 as well has the same problem.


2006-Nov-09 09:34:52 by anonymous:
Changing the line 977 of select.c (3.3.8) from:

if( pEList->a[i].zName){

to:

if( pEList->a[i].zName && pTabList->nSrc==1){

with pragma short_column_names = 0 behaves like 2.8 series.

 
2051 code active 2006 Nov anonymous   2006 Nov   5 5 minor documentation bug edit
On the page http://www.sqlite.org/lang_attach.html you wrote:

If an attached table doesn't have a duplicate table name in the main database, it doesn't require a database name prefix. When a database is attached, all of its tables which don't have duplicate names become the default table of that name. Any tables of that name attached afterwards require the table prefix. If the default table of a given name is detached, then the last table of that name attached becomes the new default.

I think the right form should be: Any tables of that name attached afterwards require the database prefix. Am I right?

Thank you, Dim Zegebart

 
2048 code active 2006 Oct anonymous   2006 Oct drh 1 1 table_info on columns with no default value are returned as string edit
On line 486, noDflt is declared as
static const Token noDflt = { (unsigned char*)"", 0, 0 };

And on line 493:
if( pDflt->z ){
sqlite3VdbeOp3(v, OP_String8, 0, 0, (char*)pDflt->z, pDflt->n);
}else{
sqlite3VdbeAddOp(v, OP_Null, 0, 0);

So columns with no default value aren't being set to null because the (pDflt->z) condition is non-null.
 
2043 code active 2006 Oct anonymous   2006 Oct   1 1 Spaces in view statement edit
If you have a table defined with fields that contain spaces.

create table table1 ("field one", "field two", "field three");

Then you do a select

select "field one" from table1;

That works fine. However if you save it as a view

create view view_one as select "field one" from table1;

Then if you run a select on the view it fails.

select * from view_one;

 
2037 code active 2006 Oct anonymous   2006 Oct   1 1 Sqlite3 can't use datafile in Chinese path with Win2000 and WindowsXP. edit
Sqlite3 can't use datafile in Chinese path with Win2000 and WindowsXP. This is a bug in os_win.c . My firend modify code to so , it work right.

/* ** Convert a UTF-8 string to UTF-32. Space to hold the returned string ** is obtained from sqliteMalloc. */ static WCHAR *utf8ToUnicode(const char *zFilename){ int nChar; WCHAR *zWideFilename;

  if( !isNT() ){
    return 0;
  }
  nChar = MultiByteToWideChar(CP_THREAD_ACP, MB_COMPOSITE, zFilename, -1, NULL, 0);
  zWideFilename = sqliteMalloc( nChar*sizeof(zWideFilename[0]) );
  if( zWideFilename==0 ){
    return 0;
  }
  nChar = MultiByteToWideChar(CP_THREAD_ACP, MB_COMPOSITE, zFilename, -1, zWideFilename, nChar);
  if( nChar==0 ){
    sqliteFree(zWideFilename);
    zWideFilename = 0;
  }
  return zWideFilename;
}

/* ** Convert UTF-32 to UTF-8. Space to hold the returned string is ** obtained from sqliteMalloc(). */ static char *unicodeToUtf8(const WCHAR *zWideFilename){ int nByte; char *zFilename;

  nByte = WideCharToMultiByte(CP_THREAD_ACP, WC_COMPOSITECHECK, zWideFilename, -1, 0, 0, 0, 0);
  zFilename = sqliteMalloc( nByte );
  if( zFilename==0 ){
    return 0;
  }
  nByte = WideCharToMultiByte(CP_THREAD_ACP, WC_COMPOSITECHECK, zWideFilename, -1, zFilename, nByte,
                              0, 0);
  if( nByte == 0 ){
    sqliteFree(zFilename);
    zFilename = 0;
  }
  return zFilename;
}
2006-Oct-20 10:26:46 by anonymous:
The proposed fix is completely wrong, but the bug exists nonetheless. The problem is that SQLite expects file names in UTF-8 encoding (and there is probably bug in your application too guessing from the proposed fix). While this works fine on NT systems where the UTF-8 encoding is converted to UTF-16 and passed to system wide-character APIs, the code path for non-NT systems (Win 9x) with ANSI-only APIs doesn't convert the UTF-8 file names into the ANSI code page which is expected by the system APIs.
 
2032 code active 2006 Oct anonymous   2006 Oct   1 1 AV in btree.c running FTS2 compiled with SQLITE_OMIT_SHARED_CACHE edit
If compiled with FTS2 support as well as SQLITE_OMIT_SHARED_CACHE=1, the sqlite console application causes an

  Access Violation: btree.c, line 3538: Read of address x00000014
    if( pCur->idx>=pPage->nCell ){

if the SQL (attatched) is executed.

I believe that this is a bug in btree.c, for the following reasons:

  • The AV does not show if the #ifndef SQLITE_OMIT_SHARED_CACHE (lines 3514 and 3525) are commentet out.

  • From my reading, all virtual tables use the extension API only and do not access the btree directly.
2006-Oct-25 06:30:43 by shess:
Note that the attached SQL has exactly 273 INSERT statements. 273==256+16+1, so this is kicking in at a merge point. Don't know how that's relevant, but it seems suspicious.


2006-Oct-25 16:31:34 by anonymous:
Many thanks for looking into this - it was driving me mad until I came up with the rather simple SQL to reproduce it.

I am not sure if the number of INSERTS is 100% the number needed to cause the problem, but the crash always happens after the exact same number of inserts. I did not count them but added roughly enough of them to cause the error.

Sidenote: I can also make FTS2 to crash at another point, which I thought was related to the sizeof() bug I also reported. But apprarently it is not. Unfortunately I can not provide a test case for this since I can reproduce it only after adding some 3000 or so copyrighted documents to an empty database. At the time of the crash the DB is about 250 MB in size. However, I will run a test after the next commits to FTS2.


2006-Oct-26 08:57:41 by anonymous:
My previious comments from yesterday seem to be invalidated by the latest checkins [3486] , [3488] and [3489] . Many thanks for those!

However, the problem with SQLITE_OMIT_SHARED_CACHE still persists.

 
2028 code active 2006 Oct anonymous   2006 Oct   4 2 FTS1: UNIQUE() expression and UPDATE command not working edit
I'm working with tables, containing around 1,4 million entries (1GB file size). To allow faster fulltext search I tried FTS1 now.

What I saw is: creating the virtual FTS1 table with one keyword "UNIQUE(code), reference, text, ..." I had the idea to have faster access to "code", because this entry is only one time existing in table. In my actual SQLITE table "UNIQUE" was good idea, because "UPDATE"ing of entries was much faster as without "UNIQUE" expression. Unfortunately, in that moemnt I use "UNIQUE" expression in fulltext table, the FTS1 table doesn't accept insertion of entries like "INSERT into receipe (code, reference, text) values ('4711', 'RefnotAvailable', 'Test');"

So I removed the "UNIQUE" keyword, knowing that later "UPDATE" command to modify entries will be slower.

So I built new table with additional FTS1 fulltext table. Then I tried to "UPDATE" one entry. In that moment the program stopped immediately working (WIN XP system), what means that the application stopped without comment and returned to desktop. I tried the same in SQLITE3.exe (command line program) but also that program suspended immediately after the UPDATE command (like "UPDATE Volltext SET code = '4710', reference = 'RefChanged', text = 'notext';"

That seems to me to be a bug.

By the way, creating fulltext table to search inside my whole database increased the filesize a lot (4 times). May be that is solved in FTS2? Last wish: Fulltext search like "foo*" to find "fool" and "foot" would be a really great improvement.

Best regards Ingo

2006-Oct-23 13:56:59 by anonymous:
Ooops, as I saw today, also "DELETE" statements are causing SQLITE to stop working (crash). Program returns to Desktop on WIN XP after DELETE command.
 
2027 code active 2006 Oct anonymous   2006 Oct   1 1 FTS: Phrase searches return Offsets for individual phrase words edit
With FTS (one as well as two), phrase searches return offsets for all individual words instead of the phrase as a whole, like in

  select name, ingredients from recipe where ingredients match '"broccoli cheese"';

Offsets() returns at least two matches for both individual words:

  • broccoli
  • cheese
 
2026 code active 2006 Oct anonymous   2006 Oct   4 5 \n in .output is not allowed even with quote edit
.output drive:\nabc.txt
.output e:\new0.txt
.output z:\new1.txt
.output "c:\new2.txt"

will result an error

omitting the \ will just put the file in the same folder to the sqlite3.exe (doesnt help)

solve it by replace \ by /

2006-Oct-15 21:28:55 by anonymous:
How about c:\\new.txt?


2006-Oct-16 11:49:58 by anonymous:
How about "c:/new.txt"?
 
2025 code active 2006 Oct anonymous   2006 Oct drh 5 5 Add pragama command to return loaded extension list edit
How about add a new pragama command to return loaded extension list?
 
2024 code active 2006 Oct anonymous   2006 Oct drh 5 5 Add If not exist syntax to Create Virtual Table edit
Parser Enhancement request: is it possible to add If not exist syntax to Create Virtual Table? all other create schema support such syntax.
 
2022 code active 2006 Oct anonymous   2006 Oct   1 1 .import command is not working edit
I have a windows system running version 3.3.6 and a linux system running 3.3.3 when I run .import catalog.csv TEMPDATA on the windows system, it works fine. On the linux system, no data gets imported. There are no error messages.

Is this a known issue in 3.3.3?

2006-Oct-14 01:15:07 by anonymous:
A sample SQL schema and a 3 line import file demonstrating the problem would be helpful.


2006-Nov-08 15:48:28 by anonymous:
Schema: CREATE TABLE Catalog ( UPC text , SKU text primary key , DESC text , PACK text , PRICE text , SIZE text );

test.csv contents 00000000103,103,EFFEM CHOCOLATE FUNSIZE 75PPK 1 X1EA,1,$155.94,1 EA 00000000152,414317,CLEARLIGHT SLUSH CUP 16OZ CDL16 1X50EA,1,$5.04,50 EA 00000000152,56880,CLEARLIGHT SLUSH CUP 16OZ CDL16 20X50EA,20,$96.31,50 EA

Command that does nothing: .import test.csv Catalog


2006-Nov-08 15:52:40 by anonymous:
Sorry, I'll try this again:

  Schema:
CREATE TABLE Catalog (
UPC text
, SKU text primary key
, DESC text
, PACK text
, PRICE text
, SIZE text );

  test.csv contents
00000000103,103,EFFEM CHOCOLATE FUNSIZE 75PPK 1 X1EA,1,$155.94,1 EA
00000000152,414317,CLEARLIGHT SLUSH CUP 16OZ CDL16 1X50EA,1,$5.04,50 EA
00000000152,56880,CLEARLIGHT SLUSH CUP 16OZ CDL16 20X50EA,20,$96.31,50 EA

  Command that does nothing:
.import test.csv Catalog
 
2019 code active 2006 Oct anonymous   2006 Oct   1 1 FTS1: Create table in transaction raises Out of Sequence error (21) edit
This error:

  SQL error: library routine called out of sequence

is caused if the following script is executed by the Windows version of the SQLite3 console application with .load fts1.dll extension. If it does not show immediately, it will eventually surface if the script is run multiple times.

The cause of the problem seems to be related to the transaction, the create virtual table as well as the amount of data inserted.

Finally, the script is attached.

 
2017 code active 2006 Oct anonymous   2006 Oct   1 1 DROP TABLE fails on FTS1 utility tables with certain OMIT_s defined edit
The following SQL fails when SQLite is compiled with the SQLITE_OMIT_ defines stated below:

  create virtual table foo using fts1 (content);
  drop table foo;
  create virtual table foo using fts1 (content);

Cause: The foo_content and foo_term tables are not deleted.

To verify, please define these SQLITE_OMIT_s:

  OPTS += -DSQLITE_OMIT_ALTERTABLE
  OPTS += -DSQLITE_OMIT_ANALYZE
  OPTS += -DSQLITE_OMIT_AUTHORIZATION
  OPTS += -DSQLITE_OMIT_AUTOINCREMENT
  OPTS += -DSQLITE_OMIT_AUTOVACUUM
  OPTS += -DSQLITE_OMIT_BETWEEN_OPTIMIZATION
  OPTS += -DSQLITE_OMIT_BLOB_LITERAL
  OPTS += -DSQLITE_OMIT_CAST
  OPTS += -DSQLITE_OMIT_CHECK
  OPTS += -DSQLITE_OMIT_COMPLETE
  OPTS += -DSQLITE_OMIT_COMPOUND_SELECT
  OPTS += -DSQLITE_OMIT_EXPLAIN
  OPTS += -DSQLITE_OMIT_FLAG_PRAGMAS
  OPTS += -DSQLITE_OMIT_FOREIGN_KEY
  OPTS += -DSQLITE_OMIT_GET_TABLE
  OPTS += -DSQLITE_OMIT_GLOBALRECOVER
  OPTS += -DSQLITE_OMIT_INTEGRITY_CHECK
  OPTS += -DSQLITE_OMIT_LIKE_OPTIMIZATION
  OPTS += -DSQLITE_OMIT_MEMORYDB
  OPTS += -DSQLITE_OMIT_OR_OPTIMIZATION
  OPTS += -DSQLITE_OMIT_ORIGIN_NAMES
  OPTS += -DSQLITE_OMIT_PAGER_PRAGMAS
  OPTS += -DSQLITE_OMIT_PROGRESS_CALLBACK
  OPTS += -DSQLITE_OMIT_QUICKBALANCE
  OPTS += -DSQLITE_OMIT_REINDEX
  OPTS += -DSQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
  OPTS += -DSQLITE_OMIT_SHARED_CACHE
  OPTS += -DSQLITE_OMIT_SUBQUERY
  OPTS += -DSQLITE_OMIT_TCL_VARIABLE
  OPTS += -DSQLITE_OMIT_TEMPDB
  OPTS += -DSQLITE_OMIT_TRACE
  OPTS += -DSQLITE_OMIT_TRIGGER
  OPTS += -DSQLITE_OMIT_UTF16
  OPTS += -DSQLITE_OMIT_VACUUM
  OPTS += -DSQLITE_OMIT_VIEW

Without the SQLITE_OMIT_s, everything works just fine.

 
2015 code active 2006 Oct anonymous   2006 Oct anonymous 5 4 Enhancement Req: "EXPRn" PRAGMA for result set expression column names edit
I would like to propose a new PRAGMA command that could be set to control how expression column names are represented in result sets.

The current behavior appears to be that the expression that generated the column becomes the column name. For example, "SELECT COLUMN1, COLUMN 2, COLUMN1 + COLUMN2 FROM MYTABLE" yields:

[COLUMN1] | [COLUMN2] | [COLUMN1 + COLUMN2]

I propose a PRAGMA to remove the expression itself and replace it with 'EXPRn', where n is an ordinal based on the number of expression columns in the result set. (First expression is 0, second is 1, and so on):

[COLUMN1] | [COLUMN2] | [EXPR0]

2006-Oct-12 09:17:25 by anonymous:
Maybe you can just use

  SELECT COLUMN1, COLUMN 2, COLUMN1 + COLUMN2 AS EXPR0 FROM MYTABLE

instead.

 
2014 code active 2006 Oct anonymous   2006 Oct anonymous 4 3 Enhancement Req: CREATE [TEMP | TEMPORARY] VIRTUAL TABLE edit
Regarding the experimental VIRTUAL TABLE implementation, I believe it would of benefit to provide a "temp", or volatile construct when working with them.

-- From a SQL syntax perspective, adding an optional keyword "TEMP" to the declaration: CREATE [TEMP | TEMPORARY] VIRTUAL TABLE.

-- From a code perspective, I would envision this to invoke xCreate as it does now, but when the database is closed, the table is automatically dropped like any temp table, and xDestroy invoked rather than xDisconnect.

One sticky point I can picture is behavior when multiple opens exist to a single database from the same process space. Since virtual tables are already reference counted (in SQLite 3.3.8), perhaps the reference count could be made to span database handles and be bubbled up to the process level instead. That would allow the table to be CREATEd on one handle, CONNECTed on a second handle, then DISCONNECTed/DESTROYed based on the process-wide reference count.

I feel that there are numerous implementation possibilities for this. Having no option to auto-drop a virtual table can lead to stray module references, creating SQLite database files that cannot be properly utilized if the vtable module is not available.

Of course this can be implemented by the application calling DROP TABLE on it's own, but an embedded solution that takes care of it seems more 'proper' given the thought that goes into SQLite as a whole.

 
2013 code active 2006 Oct anonymous   2006 Oct drh 4 3 Autoincrement increments on failing INSERT OR IGNORE edit
  % package require sqlite3
  3.3.8
  % sqlite3 db ""
  % db eval "CREATE TABLE test (counter INTEGER PRIMARY KEY AUTOINCREMENT, value text NOT NULL UNIQUE)"
  % db eval "INSERT INTO test VALUES(4, 'hallo')"
  % db eval "SELECT * FROM sqlite_sequence"
  test 4
  % db eval "INSERT OR IGNORE INTO test(value) VALUES('hallo')"
  % db eval "SELECT * FROM sqlite_sequence"
  test 5
---> there has no dataset been inserted but the AUTOINCREMENT-counter is incremented

  % db eval "INSERT OR IGNORE INTO test VALUES(4, 'hallo')"
  % db eval "SELECT * FROM sqlite_sequence"
  test 5
---> right behavior: no inserted dataset and no incrementation

This maybe could be a problem if the "INSERT OR IGNORE" happens very often.

 
2012 code active 2006 Oct anonymous   2006 Oct   4 3 trigger4.test aborts "make test" on Windows edit
The failure to remove these files causes "make test" to abort without completing remaining tests:

  trigger4-99.9... Ok
  ./testfixture: error deleting "trigtest.db": permission denied
      while executing
  "file delete -force trigtest.db trigtest.db-journal"
      (file "test/trigger4.test" line 199)

fix:

  Index: test/trigger4.test
  ===================================================================
  RCS file: /sqlite/sqlite/test/trigger4.test,v
  retrieving revision 1.9
  diff -u -3 -p -r1.9 trigger4.test
  --- test/trigger4.test        4 Oct 2006 11:55:50 -0000       1.9
  +++ test/trigger4.test        9 Oct 2006 14:09:07 -0000
  @@ -195,6 +195,6 @@ do_test trigger4-7.2 {

   integrity_check trigger4-99.9

  -file delete -force trigtest.db trigtest.db-journal
  +catch {file delete -force trigtest.db trigtest.db-journal}

   finish_test
Not sure why this ticket was set to Fixed_in_3.0, but I can reproduce the "make test" abort on Windows.


2006-Oct-11 00:27:16 by drh:
I do not know why the resolution was set to "Fixed_In_3.0" either. It seems to have been set that why by the original submitter.

I will fix this eventually, but since it does not represent a real malfunction, it has a lower priority.

 
2011 code active 2006 Oct anonymous   2006 Oct   3 2 Escaping Porblem with .mode insert (double apostrophe) edit
select * from messages where message_id="74B23AAF-5FFD6BF2";

74B23AAF-5FFD6BF2|75|0|0|0|0|Europe talks, acts tough on Iran||http://www.ncr-iran.org/index.php?option=com_content&task=view&id=1052&Itemid=71|1140529235.0|By Gareth HardingThe United Press International, BRUSSELS -- Europeans are supposed to prefer soft to hard power, jaw-jaw to war-war and appeasement to confrontation. In short, in the words of neo-conservative scholar Robert Kagan: \'Americans are from Mars; Europeans are from Venus.\'

The ".mode insert / .output" file looks like this.

INSERT INTO messages VALUES('74B23AAF-5FFD6BF2',75,0,0,0,0,'Europe talks, acts tough on Iran','','http://www.ncr-iran.org/index.php?option=com_content&task=view&id=1052&Itemid=71',1140529235.0,'By Gareth HardingThe United Press International, BRUSSELS -- Europeans are supposed to prefer soft to hard power, jaw-jaw to war-war and appeasement to confrontation. In short, in the words of neo-conservative scholar Robert Kagan: \''Americans are from Mars; Europeans are from Venus.\''');

Now there are two apostrophe and the Escaping is broken.

 
2010 code active 2006 Oct anonymous   2006 Oct   3 3 Timeout ignored in Shared-Cache locking model edit
With shared cache enabled, the busy timeout seems to be ignored. SQLITE_BUSY comes immediately. This occurs at least for locking situations within one shared cache.

My server (if i may call the cache sharing thread that way) has its own timeout handling. But I thought that a small timeout in sqlite3 might help to distinguish locks from deadlocks.

This was reproduced with both Python wrappers. These just call sqlite3_enable_shared_cache and sqlite3_busy_timeout and then execute BEGIN IMMEDIATE from two connections.

2006-Oct-06 13:56:21 by anonymous:
Weird, I thought it's my fault, but I see exactly the same behaviour with the C# ADO.NET 2.0 wrapper w/ the shared cache patch.
 
1822 code active 2006 May anonymous   2006 Sep   3 3 Table Alias together with Subquery seems not to work proper edit
SELECT * FROM auth AS a LEFT JOIN (SELECT tm.team FROM teammbs AS tm) AS tr ON a.ateam=tr.team;

Error message: No such colum tr.team

But if I run the sub-query itself, it works fine. Of course, this example can be expressed different, so no subquery required. But the complete expression looks like this:

SELECT a.auth, a.avalue FROM auth a LEFT JOIN (SELECT tm.member, tm.team FROM teammbs tm, team t WHERE tm.team=t.teamid AND (t._state<64 or (t._state>120 AND t._state<192)) AND (tm._state<64 or (tm._state>120 AND tm._state<192))) AS tr ON a.ateam=tr.team WHERE (a._state<64 or (a._state>120 AND a._state<192)) AND (a.auser='test' OR tr.member='test') ORDER BY a.auth;

It works fine with MySQL 5, and brings the same error on SQLite 3: No such column tr.team.

Any idea?

 
1994 code active 2006 Sep anonymous Parser 2006 Sep   1 3 Columns from nested joins aren't properly propagated edit
When using this query:

    SELECT * FROM ROLE_ATTRIBUTE INNER JOIN (ROLE INNER JOIN PERSON ON ROLE.PERSON_ID=PERSON.ID) ON ROLE_ATTRIBUTE.PERSON_ID=ROLE.PERSON_ID AND ROLE_ATTRIBUTE.PROJECT_ID=ROLE.PROJECT_ID WHERE ((PERSON.FIRSTNAME = "bob"));

the parser fails with an error "no such column: ROLE.PROJECT_ID". It seems that doing an inner join with more than one subexpression doesn't work.

2006-Sep-25 22:41:52 by anonymous:
Your query will run without the brackets.

  SELECT *
  FROM PERSON P INNER JOIN ROLE_ATTRIBUTE RA
       ON P.ID = RA.PERSON_ID
       INNER JOIN ROLE R
       ON RA.PROJECT_ID = R.PROJECT_ID AND
          P.ID          = R.PERSON_ID
  WHERE P.FIRSTNAME = 'bob';


2006-Sep-25 23:03:28 by navaraf:
Hm, you're right. So actually the thing SQLite chokes on is the parenthesis syntax as JOIN parameter. I can try to modify the generator to produce the expanded form, but since the same code is used for MSSQL, MySQL and Oracle I still think it would be handy to allow it in SQLite too. Also it's not my code that generates these horrible expressions and I'd rather try to avoid modifying it.


2006-Sep-26 09:59:13 by anonymous:
I changed the title to correctly describe the problem. Also I found another thread on the mailing list that describes exactly the same problem: http://marc.10east.com/?t=115378699000001


2006-Sep-26 11:42:38 by navaraf:
I believe the "lookupName" function in src/expr.c should do recursion for ephemeral tables found in the pSrcList (at least those that were created as subqueries in the FROM clause of the SELECT statement).
 
1990 code active 2006 Sep anonymous   2006 Sep   1 1 sqlite3_close doesn't release always the file handle edit
I think that sqlite3_close behave strangly.

I use version 3.3.7 on Linux (Fedora Core 5).

What I do is to open a database, and start a transaction in it. Then, without ending the transaction, open again the database and simply close it. I found out, that the inner sqlite3_close return 0 (SQLITE_OK), but the file handle is not released. So if I do it too many times, I run out of file handles.

You are free to ask why I open and close that many times the same database while it is already in transaction. This is my mistake. Actually, it is already fixed. But I still wonder - shouldn't the sqlite3_close return other thing then just SQLITE_OK? Especially if the file handle is not released? If it did, I would find my mistake much earlier.

Here is my script that demonstrate it (you can use /usr/sbin/lsof in linux to see how many times the file is opened):

  #include <sqlite3.h>
  int main(int argc, char **argv) {
    sqlite3* db;
    sqlite3* db_inner;
    int rc;
    int i;
    system("rm -f open_many_test.db");

    rc = sqlite3_open("open_many_test.db", &db);
    sqlite3_exec(db, "begin", 0, 0, 0);
    sqlite3_stmt *pStmt;
    rc = sqlite3_prepare(db,
                         "create table a (id varchar)",
                         -1,
                         &pStmt,
                         0);
    rc = sqlite3_step(pStmt);
    sqlite3_finalize(pStmt);

    rc = sqlite3_prepare(db,
                         "insert into a values('bla')",
                         -1,
                         &pStmt,
                         0);
    rc = sqlite3_step(pStmt);
    sqlite3_finalize(pStmt);

    for (i = 0; i < 10000; i++) {
      rc = sqlite3_open("open_many_test.db", &db_inner);
      printf("sqlite3_open gives %d\n", rc);

      rc = sqlite3_close(db_inner);
      printf("sqlite3_close gives %d\n", rc);
    }

    sqlite3_exec(db, "commit", 0, 0, 0);
    rc = sqlite3_close(db);
  }
2006-Sep-23 15:29:46 by drh:
This behavior is intentional. It is there to work around bugs in the design of posix advistory locks. See ticket #561 and check-in [1171] .

Under posix, if you have the same file open multiple times and you close one of the file descriptors, all locks on that file for all file descriptors are cleared. To prevent this from occurring, SQLite defers closing file descriptors until all locks on the file have been released.

One possible work-around would be to reuse file descriptors that waiting to be closed for the next open, rather than creating a new file descriptor.


2006-Sep-23 15:35:21 by anonymous:
The inner call should to sqlite3_open() should simply fail in that case, rather than set up a condition where by a file descriptor is leaked (which no one wants). This is unfortunate because sqlite3_open()'s behavior would not be uniform across platforms.


2006-Sep-23 16:43:32 by anonymous:
SQLite should do a lookup via stat()'s st_dev/st_ino fields prior to open() and if found to be the same as an already opened database file, it should use the same (refcounted) file descriptor, eliminating the need for open() in this case.

...upon reflection, having two sqlite connections using the same file descriptor would be a bad thing. stat() could be used to decide if a fd pending close() is recyclable, though.


2006-Sep-23 18:17:34 by drh:
Two points:

  1. SQLite does not and has never leaked file descriptors. All file descriptors are eventually closed. The close is merely deferred until the pending transaction COMMITs.

  2. I will be taking a very caution and careful approach toward resolving this issue. The issue itself is minor (it has only just now been reported but the behavior has been there for 3 years) but the consequences of getting the fix wrong are severe (database corruption.) And there are abundant opportunities for getting the fix wrong.
 
1983 code active 2006 Sep anonymous   2006 Sep   2 2 I/O Error at a size of 4GB and auto_vacuum=1 edit
when i'm building a database with auto_vacuum=1 and page_size=8192, i get an I/O error at a size of about 4GB. All tables are still readable but then it isn't possible to insert any more data.

The table is filled with a column of BLOBs and some columns with numbers. I use the 3.3.7 binary with Windows 2000 Server.

 
1980 code active 2006 Sep drh   2006 Sep   1 1 Initializing FTS1 twice causes it to fail. edit
If you try to load the shared module twice, it causes the module to no longer work.
 
1972 code active 2006 Sep anonymous   2006 Sep   2 4 segfault on empty query edit
SQLite 2.8.17 used in latest versions of PHP segfaults with empty query (i.e. " ", 1 whitespace).

PHP reproduce code: <?php $dbh = new PDO('sqlite2:pdo_sqlite2'); var_dump($dbh->query(" ")); ?>

GDB backrace:

  Program received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 1077220512 (LWP 3909)]
  0x0814d227 in sqlite_step (pVm=0x0, pN=0x40364218, pazValue=0x40364210, pazColName=0x40364214) at /local/dev/php-src_5_2/ext/sqlite/libsqlite/src/vdbe.c:117
  117       if( p->magic!=VDBE_MAGIC_RUN ){
  (gdb) bt
  #0  0x0814d227 in sqlite_step (pVm=0x0, pN=0x40364218, pazValue=0x40364210, pazColName=0x40364214) at /local/dev/php-src_5_2/ext/sqlite/libsqlite/src/vdbe.c:117
  #1  0x0812556a in pdo_sqlite2_stmt_execute (stmt=0x40364094) at /local/dev/php-src_5_2/ext/sqlite/pdo_sqlite2.c:102
  #2  0x080bf4d5 in zim_PDO_query (ht=1, return_value=0x40363110, return_value_ptr=0x0, this_ptr=0x40363178, return_value_used=1)
    at /local/dev/php-src_5_2/ext/pdo/pdo_dbh.c:1033
  #3  0x0824c1d6 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfffca90) at /local/dev/php-src_5_2/Zend/zend_vm_execute.h:200
  #4  0x0824c722 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER (execute_data=0xbfffca90) at /local/dev/php-src_5_2/Zend/zend_vm_execute.h:322
  #5  0x0824bde9 in execute (op_array=0x403637e4) at /local/dev/php-src_5_2/Zend/zend_vm_execute.h:92
  #6  0x0822e66a in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /local/dev/php-src_5_2/Zend/zend.c:1095
  #7  0x081e7993 in php_execute_script (primary_file=0xbfffef00) at /local/dev/php-src_5_2/main/main.c:1759
  #8  0x082933de in main (argc=2, argv=0xbfffefe4) at /local/dev/php-src_5_2/sapi/cli/php_cli.c:1102
  (gdb) f 0
  #0  0x0814d227 in sqlite_step (pVm=0x0, pN=0x40364218, pazValue=0x40364210, pazColName=0x40364214) at /local/dev/php-src_5_2/ext/sqlite/libsqlite/src/vdbe.c:117
  117       if( p->magic!=VDBE_MAGIC_RUN ){
  (gdb) p p
  $1 = (Vdbe *) 0x0

Proposed patch: http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite/libsqlite/src/vdbe.c?r1=1.7.4.1&r2=1.7.4.1.2.1

2006-Sep-10 11:10:26 by drh:
PHP is calling sqlite_step() with a NULL sqlite_stmt pointer. This seems more like a bug in PHP than SQLite. I suggest patching PHP, somewhere in pdo_sqlite2.c I'm guessing, so that it checks to see if the statement pointer returned by sqlite_prepare() is NULL and skips the sqlite_step() and sqlite_finalize() calls if it is. The proposed patch above seems to confirm this strategy: The proposed patch would cause PHP to receive an SQLITE_MISUSE error. An SQLITE_MISUSE error indicates that the API is begin used incorrectly. The right fix, it seems to me, would be to use the API correctly.


2006-Sep-10 15:40:46 by anonymous:
"An SQLITE_MISUSE error indicates that the API is begin used incorrectly". I agree - and this simple NULL check would be the perfect place for SQLite to issue such a MISUSE error. Having SQLite recover from such a relatively common type of NULL input error would be beneficial to its users. SQLite already goes to great lengths to recover from out of memory situations. I don't see any reason not to add a simple "if NULL" check here to avoid crashing the the user's application.


2006-Sep-10 16:56:12 by drh:
I would quickly add such a change to SQLite version 3. And in fact I have already done so. See Ticket #870 and check-in [1906] . But we are talking about SQLite version 2, here, which is in maintenance mode and should not be used for new development.


2006-Sep-10 20:05:41 by anonymous:
>I suggest patching PHP, somewhere in pdo_sqlite2.c

That's possible too, but currently I see no reasons to do it.

>I'm guessing, so that it checks to see if the statement pointer returned by > sqlite_prepare() is NULL and skips the sqlite_step() and sqlite_finalize() calls if it is.

The statement pointer in this case is (not) returned by sqlite_compile() call. Here is the piece of code:

    ...
    S->einfo.errcode = sqlite_compile(S->H->db, stmt->active_query_string, &tail, &S->vm, &errmsg);
    if (S->einfo.errcode != SQLITE_OK) {
        pdo_sqlite2_error_stmt(errmsg, stmt);
        return 0;
    }

    S->done = 0;
    S->einfo.errcode = sqlite_step(S->vm, &S->ncols, &S->rowdata, &S->colnames);
    ...

From what I see, sqlite_compile() considers " " query as valid and doesn't return error, but in the same time the statement pointer remains NULL, which is clearly wrong. As I've said, it's easy to check if it's NULL or not in PHPs code, but I really think that the problem is in sqlite_compile().

 
1974 code active 2006 Sep anonymous Unknown 2006 Sep   1 1 column type not consistent in views edit
package require sqlite3

sqlite3 db test.db

db eval {

create table one ( size FLOAT );

create view two as select size from one; }

db eval {insert into one values(50.0)}

puts [db eval {select size from one}]

puts [db eval {select size from two}]

outputs:

50.0

50

 
1445 code active 2005 Sep anonymous   2006 Sep   3 3 Errors testing sqlite 3.2.6 (& v3.3.7) edit
  $ make test
  [...]
  conflict-6.0... Ok
  conflict-6.1... Ok
  conflict-6.2...
  Expected: [0 {7 6 9} 1 1]
       Got: [0 {7 6 9} 1 0]
  conflict-6.3...
  Expected: [0 {6 7 3 9} 1 1]
       Got: [0 {6 7 3 9} 1 0]
  conflict-6.4... Ok
  conflict-6.5... Ok
  conflict-6.6... Ok
  conflict-6.7...
  Expected: [0 {6 7 3 9} 1 1]
       Got: [0 {6 7 3 9} 1 0]
  conflict-6.8...
  Expected: [0 {7 6 9} 1 1]
       Got: [0 {7 6 9} 1 0]
  conflict-6.9...
  Expected: [0 {6 7 3 9} 1 1]
       Got: [0 {6 7 3 9} 1 0]
  conflict-6.10...
  Expected: [0 {7 6 9} 1 1]
       Got: [0 {7 6 9} 1 0]
  conflict-6.11...
  Expected: [0 {6 7 3 9} 1 1]
       Got: [0 {6 7 3 9} 1 0]
  conflict-6.12...
  Expected: [0 {6 7 3 9} 1 1]
       Got: [0 {6 7 3 9} 1 0]
  conflict-6.13...
  Expected: [0 {7 6 9} 1 1]
       Got: [0 {7 6 9} 1 0]
  conflict-6.14... Ok
  conflict-6.15... Ok
  conflict-6.16... Ok
  [...]
  date-3.12... Ok
  date-3.13... Ok
  date-3.14... Ok
  date-3.15... Ok
  date-3.16... Ok
  date-3.17... Ok
  /tmp/sqlite-3.2.6/.libs/lt-testfixture: invalid command name "clock"
      while executing
  "clock seconds"
      invoked from within
  "clock format [clock seconds] -format "%Y-%m-%d" -gmt 1"
      invoked from within
  "set now [clock format [clock seconds] -format "%Y-%m-%d" -gmt 1]"
      (file "./test/date.test" line 142)
      invoked from within
  "source $testfile"
      ("foreach" body line 4)
      invoked from within
  "foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
    set tail [file tail $testfile]
    if {[lsearch -exact $EXCLUDE $tail]>=0} continue
    so..."
      (file "./test/quick.test" line 45)
  make: *** [test] Error 1
2005-Sep-19 23:03:56 by drh:
The test scripts do not (yet) work with Tcl 8.5. Use Tcl 8.4.


2005-Sep-20 01:59:42 by anonymous:
FYI, The conflict failures occur even when using tcl-8.4. The problem was reported on the mailing list:

  http://www.mail-archive.com/sqlite-users%40sqlite.org/msg10203.html

Curiously, the failures correspond exactly to the test cases that were changed by the following patch:

  http://www.sqlite.org/cvstrac/filediff?f=sqlite/test/conflict.test&v1=1.24&v2=1.25


2006-Aug-31 23:49:40 by anonymous:
building v337 on OSX 10.4.7 w/ TCL8.5 installed as Framework, 'make test' still fails w/:

  date-3.16... Ok
  date-3.17... Ok
  /usr/ports/sqlite-3.3.7/build/.libs/testfixture: invalid command name "clock"
      while executing
  "clock seconds"
      invoked from within
  "clock format [clock seconds] -format "%Y-%m-%d" -gmt 1"
      invoked from within
  "set now [clock format [clock seconds] -format "%Y-%m-%d" -gmt 1]"
      (file "../test/date.test" line 142)
      invoked from within
  "source $testfile"
      ("foreach" body line 4)
      invoked from within
  "foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
    set tail [file tail $testfile]
    if {[lsearch -exact $EXCLUDE $tail]>=0} continue
    so..."
      (file "../test/quick.test" line 66)
  make: *** [test] Error 1

any resolution for this, other than revert to TCL 8.4?


2006-Sep-01 01:26:37 by anonymous:
SQLite under Cygwin fails all tests that involve integers larger than 32 bits. Sqlite produces the correct 64 bit values, but Tcl as distributed with Cygwin cannot grok 64 bit ints, so the comparisons fail. Would it be possible to change Sqlite's test harness to compare SQL results as strings rather than as integers? Then it would not matter if Tcl worked in 64 bit or not.


2006-Sep-01 15:50:48 by drh:
The test suite has been revised so that it now works with Tcl8.5. But, no, it is not practical to rewrite the tests to compare the results using strings instead of integers in order to work with the (broken) tcl implementation that comes with cygwin.


2006-Sep-06 02:39:24 by anonymous:

  updating to latest cvs-checkout to get the aforementioned fix for:

      date-3.17... Ok
      /usr/ports/sqlite-3.3.7/build/.libs/testfixture: invalid command name "clock"
          while executing

  i can verify that _that_ is now ok:

      ...
      date-3.14... Ok
      date-3.15... Ok
      date-3.16... Ok
      date-3.17... Ok
      date-4.1...
      Expected: [2006-09-01]
           Got: [2006-09-06]
      date-5.1... Ok
      date-5.2... Ok
      date-5.3... Ok
      ...

  but now, 'make test' fails next @:

      delete-8.4... Ok
      delete-8.5... Ok
      delete-8.6... Ok
      delete-8.7... Ok
      /usr/ports/sqlite-cvs/build/.libs/testfixture: error deleting "test.db": not owner
          while executing
      "file delete -force test.db"
          (file "../test/tester.tcl" line 62)
          invoked from within
      "source $testdir/tester.tcl"
          (file "../test/delete2.test" line 36)
          invoked from within
      "source $testfile"
          ("foreach" body line 4)
          invoked from within
      "foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
        set tail [file tail $testfile]
        if {[lsearch -exact $EXCLUDE $tail]>=0} continue
        so..."
          (file "../test/quick.test" line 66)
      make: *** [test] Error 1


2006-Sep-06 11:11:19 by drh:
Run the build starting from an empty directory as a non-root user.


2006-Sep-06 13:27:18 by anonymous:
per INSTALL instructions, i did:

  cvs -d :pserver:anonymous@www.sqlite.org:/sqlite checkout -d sqlite-cvs sqlite
  cd /usr/ports/sqlite-cvs

  mkdir build
  cd build

  ../configure \
  ...

  make

  chown -R myuser:wheel /usr/ports/sqlite-cvs
  sudo -u myuser make test

and, as reported, the error was the result.


2006-Sep-30 21:43:45 by anonymous:
bump.

anyone?


2006-Sep-30 22:19:24 by anonymous:
If you don't happen to be testing on Linux/gcc or Windows/VC++ I find that the Tcl test results have more than a few failures. It is not always easy to discern which failures are due to some odd quirk of Tcl or whether it is a legitimate SQLite issue on a given platform. Be prepared to change test scripts and tinker with the code.
 
1960 code active 2006 Sep anonymous   2006 Sep   4 2 Issues with .import in sqlite.exe edit
I ran into two possible problems when using the .import operation in sqlite3:

- .import seems to be confused by NULLs; in the file NullTest.dat the null is at the end of the line

- .import chokes on empty field when importing to field of type: integer PRIMARY KEY AUTOINCREMENT

For example line like:

~2~3~4~5~6

Example:

Schema:

--Table with autoincrement

CREATE TABLE test1( id integer PRIMARY KEY AUTOINCREMENT, c1 integer NULL , c2 integer NULL , c3 text NULL, c4 text NULL, c5 text NULL );

-- Table with no autoincrement field

CREATE TABLE test2( id integer NULL, c1 integer NULL , c2 integer NULL , c3 text NULL, c4 text NULL, c5 text NULL );

.separator ~

.import NullTest.dat test1

.import NullTest.dat test2

.import NoNullTest.dat test2

I have short test files that I can email to the person who is looking at this.

 
1958 code active 2006 Sep anonymous   2006 Sep   4 4 some printf tests fail with Tcl 8.5a5, ok with Tcl 8.4 edit
Tcl 8.5a5:

  printf-1.7.6...
  Expected: [Three integers: (1000000) ( f4240) (3641100)]
       Got: [Three integers: ( 1000000) ( f4240) (3641100)]

  printf-1.8.6...
  Expected: [Three integers: (999999999) (3b9ac9ff) (7346544777)]
       Got: [Three integers: ( 999999999) (3b9ac9ff) (7346544777)]

  printf-1.9.7...
  Expected: [Three integers: (     0) (   0x0) (     0)]
       Got: [Three integers: (     0) (     0) (     0)]

Tcl 8.4:

  printf-1.7.6... Ok
  printf-1.8.6... Ok
  printf-1.9.7... Ok
2006-Sep-05 02:27:00 by anonymous:
This is not directly related to the ticket, but concerns the same test file... Why are these tests not run on windows? I thought sqlite3_mprintf() is platform independent.

  if {$::tcl_platform(platform)!="windows"} {

  set m 1
  foreach {a b} {1 1 5 5 10 10 10 5} {
    set n 1
    foreach x {0.001 1.0e-20 1.0 0.0 100.0 9.99999 -0.00543 -1.0 -99.99999} {
      do_test printf-2.$m.$n.1 [subst {
        sqlite3_mprintf_double {A double: %*.*f} $a $b $x
      }] [format {A double: %*.*f} $a $b $x]
      do_test printf-2.$m.$n.2 [subst {
        sqlite3_mprintf_double {A double: %*.*e} $a $b $x
      }] [format {A double: %*.*e} $a $b $x]
      do_test printf-2.$m.$n.3 [subst {
        sqlite3_mprintf_double {A double: %*.*g} $a $b $x
      }] [format {A double: %*.*g} $a $b $x]
      do_test printf-2.$m.$n.4 [subst {
        sqlite3_mprintf_double {A double: %d %d %g} $a $b $x
      }] [format {A double: %d %d %g} $a $b $x]
      do_test printf-2.$m.$n.5 [subst {
        sqlite3_mprintf_double {A double: %d %d %#g} $a $b $x
      }] [format {A double: %d %d %#g} $a $b $x]
      do_test printf-2.$m.$n.6 [subst {
        sqlite3_mprintf_double {A double: %d %d %010g} $a $b $x
      }] [format {A double: %d %d %010g} $a $b $x]
      incr n
    }
    incr m
  }

  }  ;# endif not windows
 
1953 code active 2006 Sep anonymous TclLib 2006 Sep   4 3 Fix for false 64-bit comparisons "make test" failures on Cygwin edit
The trivial patch below allows Cygwin to correctly pass all (two dozen or so) 64-bit integer-related tests in "make test". It does so by treating all 64-bit integer SQL results as strings. (Note: SQLite has always produced correct 64-bit integer results, it's just that the test harness on Cygwin produces false failures without this patch.) There is no impact to other platforms, and allows us unfortunate Windows users to be useful members of society.

  RCS file: /sqlite/sqlite/src/tclsqlite.c,v
  retrieving revision 1.172
  diff -u -r1.172 tclsqlite.c
  --- src/tclsqlite.c     31 Aug 2006 15:07:15 -0000      1.172
  +++ src/tclsqlite.c     1 Sep 2006 17:27:44 -0000
  @@ -432,7 +432,12 @@
             if( v>=-2147483647 && v<=2147483647 ){
               pVal = Tcl_NewIntObj(v);
             }else{
  +#ifndef __CYGWIN__
               pVal = Tcl_NewWideIntObj(v);
  +#else
  +            int bytes = sqlite3_value_bytes(pIn);
  +            pVal = Tcl_NewStringObj((char *)sqlite3_value_text(pIn), bytes);
  +#endif
             }
             break;
           }
  @@ -1420,7 +1425,11 @@
                 if( v>=-2147483647 && v<=2147483647 ){
                   pVal = Tcl_NewIntObj(v);
                 }else{
  +#ifndef __CYGWIN__
                   pVal = Tcl_NewWideIntObj(v);
  +#else
  +                pVal = dbTextToObj((char *)sqlite3_column_text(pStmt, i));
  +#endif
                 }
                 break;
               }

Example test failures before patch:

  $ ./testfixture.exe test/misc2.testmisc2-1.1... Ok
  misc2-1.2... Ok
  misc2-2.1... Ok
  misc2-2.2... Ok
  misc2-2.3... Ok
  misc2-3.1... Ok
  misc2-4.1...
  Expected: [4000000000]
       Got: [-294967296]
  misc2-4.2...
  Expected: [4000000000 2147483648]
       Got: [-294967296 -2147483648]
  misc2-4.3... Ok
  misc2-4.4...
  Expected: [1 2147483648 2147483647]
       Got: [1 -2147483648 2147483647]
  misc2-4.5...
  Expected: [1 4000000000 2147483648 2147483647]
       Got: [1 -294967296 -2147483648 2147483647]
  misc2-4.6...
  Expected: [1 2147483647 2147483648 4000000000]
       Got: [1 2147483647 -2147483648 -294967296]
  misc2-5.1... Ok
  misc2-6.1... Ok
  misc2-7.1... Ok
  misc2-7.2... Ok
  misc2-7.3... Ok
  misc2-7.4... Ok
  misc2-7.5... Ok
  misc2-7.6... Ok
  misc2-7.7... Ok
  misc2-7.8... Ok
  misc2-8.1... Ok
  misc2-9.1... Ok
  misc2-9.2... Ok
  misc2-9.3... Ok
  misc2-10.1... Ok
  Thread-specific data deallocated properly
  5 errors out of 28 tests
  Failures on these tests: misc2-4.1 misc2-4.2 misc2-4.4 misc2-4.5 misc2-4.6

After patch applied:

  $ ./testfixture.exe test/misc2.testmisc2-1.1... Ok
  misc2-1.2... Ok
  misc2-2.1... Ok
  misc2-2.2... Ok
  misc2-2.3... Ok
  misc2-3.1... Ok
  misc2-4.1... Ok
  misc2-4.2... Ok
  misc2-4.3... Ok
  misc2-4.4... Ok
  misc2-4.5... Ok
  misc2-4.6... Ok
  misc2-5.1... Ok
  misc2-6.1... Ok
  misc2-7.1... Ok
  misc2-7.2... Ok
  misc2-7.3... Ok
  misc2-7.4... Ok
  misc2-7.5... Ok
  misc2-7.6... Ok
  misc2-7.7... Ok
  misc2-7.8... Ok
  misc2-8.1... Ok
  misc2-9.1... Ok
  misc2-9.2... Ok
  misc2-9.3... Ok
  misc2-10.1... Ok
  Thread-specific data deallocated properly
  0 errors out of 28 tests
  Failures on these tests:

The only new regression on Cygwin is this test, which is expected:

  types3-2.3...
  Expected: [wideInt]
       Got: []
2006-Sep-01 18:55:25 by drh:
The TCL interface is more than just part of the test harness. A lot of people use the TCL interface as part of their applications.

I believe what this patch does is mask a real problem.

I would prefer to fix the underlying problem, not just treat the symptom.


2006-Sep-02 02:48:57 by anonymous:
I have no interest in fixing bugs in Tcl itself on Cygwin. I just want to reliably build and test SQLite. The proposed fix is purely pragmatic and is intended only for the test harness. Indeed, when dealing with testing only, the fix is not Cygwin-specific and would work on any platform. The test harness under stock Cygwin as it stands simply does not work for 64 bit values. When you see such a failure you assume that SQLite is in error. Perhaps a compromise can be made and the code fix in question can be wrapped in #ifdef SQLITE_TESTFIXTURE or equivalent instead of #ifdef __CYGWIN__. I would hate to see someone else waste any time on this trivially fixable issue.


2006-Sep-02 13:27:08 by drh:
Perhaps you could put an "if" statement in the test scripts that skipped over the tests that do not work if running under cygwin. You can probably figure out if you are running under cygwin by looking at elements of the tcl_platform array.


2006-Sep-02 13:48:56 by drh:
I retract my previous suggestion. I do not want such patches in the SQLite source tree.

I will resist any patches such as shown here because they are really hacks to work around a faulty Tcl build on Cygwin. The correct way to fix this is to fix the Tcl build for Cygwin. This is probably as simple as download a copy of Tcl and recompiling. I'm curious to know why the default Tcl build for Cygwin only supports 32-bit integers. Is there some problem with 64-bit integer support on Cygwin?

The patch shown in the Description section above is not good because it presumes that Cygwin will always be broken. I think a better assumption is that Cygwin will get fixed. And I do not want to cripple the TCL interface to work around a bug that is not related to SQLite and which might not exist on every system. That is so wrong.

I will be willing to put in a test that checks for the cygwin brokenness and prints a warning to the user. Perhaps something like this:

   if {"*[db eval {SELECT 10000000000}]*"!="*10000000000*"} {
      puts "*********** WARNING *************"
      puts "Your build of TCL only supports 32-bit integers."
      puts "This will cause many test failures.  To run these"
      puts "tests you must install a version of TCL that supports"
      puts "64-bit integers."
      exit
   }

The question is, does that test correctly detect the broken Cygwin? Since I have no ready access to a windows machine, I have no way of testing it.


2006-Sep-02 14:06:28 by anonymous:
Then you would have an on-going maintenance issue with future tests. If'ing out valid tests just masks the problem and defeats the purpose of having a test regression suite. If a test fails legitimately, it should be reported as such. But these particular 64-bit tests work correctly if the simple proposed patch to the test harness is checked in. There is nothing wrong with the tests themselves - just the test harness on certain platforms for which Tcl does support 64-bit integers for whatever reason. Is the purpose of the test suite to test SQLite or Tcl implementations?

I know that Cygwin is a considered a tier "C" platform for SQLite, but appreciate that from a Cygwin environment me and many others have reported at least couple of dozen non-platform-specific SQLite bugs over the past year. You probably have as many or more Cygwin users on the mailing list than Mac OSX users. Why put up artificial ideological roadblocks?


2006-Sep-02 14:10:35 by anonymous:
Please do not check the "Your build of TCL only supports 32-bit integers". It is couter-productive to exit when the great majority of tests will pass. Such a check will basically exclude stock Cygwin installs from testing SQLite. Given the choice between having a broken test harness and this TCL 32-bit check, it is more useful to have a broken test harness.


2006-Sep-04 01:25:00 by anonymous:
Cygwin Tcl 8.5 64-bit integer math bug report

Cygwin Tcl 8.5a5 64-bit integer math fix

 
1954 code active 2006 Sep anonymous Unknown 2006 Sep   1 1 Dual Core Processor Lockup edit
I seem to be seeing a problem with dual core processors in the the Open call is locking and does not release or throw an exception. It does not occur every time, but occurs around 50% of the time. I have not seen the problem on non dual core processors.
2006-Sep-02 21:06:38 by anonymous:
This ticket is way too vague to be actionable. What operating system? AMD or Intel? What specific version of SQLite? Was the library precompiled or did you compile it yourself?

Personally, I can report no errors or problems with dual-core CPU's on Windows XP using an AMD X2 4400+ dual-core CPU. Tested with both a 32-bit build and a 64-bit build of SQLite on x64 Windows.

 
1948 code active 2006 Aug anonymous Shell 2006 Aug   2 3 Double quotes are not escaped in csv mode edit
If text is exported using "csv" mode, double quotes in strings are not escaped. Generally double-quotes in a quoted field in CSV should be escaped by repeate. I.e., 'This is a "test".' could be about as "This is a ""test""."

This doesn't appear to be the behavior SQLite uses, so, in the meantime, I'll have to export my data using another method and then transform that data into CSV for my import script.

 
1947 code active 2006 Aug anonymous Shell 2006 Aug   3 3 ".mode insert" works bad with BLOBs edit
.mode insert displays BLOBs as strings, which isn't very good for embedded NULs.

Having output more like the one from .dump would be better, IMO.

  sqlite> select * from t;
  INSERT INTO table VALUES('');
  sqlite> .dump
  BEGIN TRANSACTION;
  CREATE TABLE t(f BLOB);
  INSERT INTO "t" VALUES(X'0041');
  COMMIT;
 
518 code active 2003 Dec anonymous Unknown 2006 Aug   3 4 PRIMARY KEY does not imply UNIQUE and NOT NULL edit
According to SQL92 and Dr. Hipp, PRIMARY KEY should imply both NOT NULL and UNIQUE. It does not. The following statements exhibit the problem:

        CREATE TABLE User (     Name VARCHAR (40),
                                UID INTEGER,
                                DeviceID VARCHAR (64),
                                PRIMARY KEY (Name, UID, DeviceID) );
        INSERT INTO User (Name,DeviceID) VALUES ('Michael','Test');
        INSERT INTO User (Name,DeviceID) VALUES ('Michael','Test');

Gets me two rows with ('Michael',NULL,'Test').

2005-Jan-03 01:46:01 by drh:
See http://www.sqlite.org/nulls.html. SQLite considers NULLs to be distinct. PostgreSQL, Oracle, MySQL, and Firebird all work this way. Informix and MS-SQL work differently.

Works as designed.


2006-Aug-26 07:29:58 by anonymous:

as far as I can see, the closing remark applies to the UNIQUEness of NULL values, not the NOT NULLness of PRIMARY KEYs (or part of that).

let's see what some engines do:

PostgreSQL:

biblioteca=> CREATE TABLE test (
    Name VARCHAR (40),
    UID INTEGER,
    DeviceID VARCHAR (64),
    PRIMARY KEY (Name, UID, DeviceID) );
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test"
CREATE TABLE
biblioteca=> insert into test(Name, DeviceID) values ('Michael', 'test');
ERROR:  null value in column "uid" violates not-null constraint

MySQL:

mysql> CREATE TABLE test (
    Name VARCHAR (40),
    UID INTEGER,
    DeviceID VARCHAR (64),
    PRIMARY KEY (Name, UID, DeviceID) );
Query OK, 0 rows affected (0.07 sec)

mysql> insert into test(Name, DeviceID) values ('Michael', 'test');
Query OK, 1 row affected (0.11 sec)

mysql> insert into test(Name, DeviceID) values ('Michael', 'test');
ERROR 1062 (23000): Duplicate entry 'Michael-0-test' for key 1
that is: it MySQL is also not allowing NULL primary keys and is silently replacing NULL values with 0.

Oracle:

CREATE TABLE test (
    Name VARCHAR (40),
    UniqueID INTEGER,
    DeviceID VARCHAR (64),
    PRIMARY KEY (Name, UniqueID, DeviceID) );
insert into test(Name, DeviceID) values ('Michael', 'test');
ORA-01400: impossibile inserire NULL in ("IBOTEST"."TEST"."UNIQUEID")
I hope no-one will disagree if I reopen the ticket.


2006-Aug-29 11:51:00 by anonymous:
behaviour with the patch:

  sqlite> CREATE TABLE User ( Name VARCHAR (40),
   ...>                       UID INTEGER,
   ...>                       DeviceID VARCHAR (64),
   ...>                       PRIMARY KEY (Name, UID, DeviceID) );
  sqlite> INSERT INTO User (Name,DeviceID) VALUES ('Michael','Test');
  SQL error: User.UID may not be NULL
  sqlite> INSERT INTO User (Name,DeviceID) VALUES ('Michael','Test');
  SQL error: User.UID may not be NULL


2006-Aug-29 13:10:37 by drh:
To my great surprise, I discovered that SQLite has allowed NULL values in PRIMARY KEY columns for a very long time. This is a bug. But the bug has been in the code for so long, that we fear fixing it might break legacy applications. So for now we have chosen to merely document the fact that the bug exists and to warn developers not to depend on it since it might be fixed at some unspecified point in the future.


2006-Aug-29 19:54:12 by anonymous:
Can you put a SQLITE_ENABLE_NOTNULL_PRIMARYKEYS #ifdef and apply this patch to the official tree? This may solve the problems with legacy code and solve the SQL issue
 
1941 code active 2006 Aug anonymous   2006 Aug   1 1 Unrevolved _sqlite3ExprCodeAndCache with SQLITE_OMIT_TRIGGER edit
If SQLITE_OMIT_TRIGGER is set, linker complains about an unresolved _sqlite3ExprCodeAndCache symbol.

sqlite3ExprCodeAndCache is defined in expr.c and wrapped with #ifndef SQLITE_OMIT_TRIGGER.

However, references in

  insert.c, line 536
  update.c, line 348 and 362

are not wrapped with #ifndef SQLITE_OMIT_TRIGGER.

I followed the suggestion quoted below (posted earlier to this list) without avail.

Is it safe (or even required?) to change sqliteInt.h to

  #ifndef SQLITE_OMIT_TRIGGER
  void sqlite3ExprCodeAndCache(Parse*, Expr*);
  #else
  # define sqlite3ExprCodeAndCache(A,B)
  #endif

In the mailing list, DRH argued that the above change will probably fail and suggested that a safer fix would be to remove the #ifndef SQLITE_OMIT_TRIGGER from around the sqlite3ExprCodeAndCache function.

2006-Oct-12 17:35:32 by anonymous:
The problem is still present in 3.3.8. Removing the

  #ifndef SQLITE_OMIT_TRIGGER

from around the

  sqlite3ExprCodeAndCache

function seems to fix it. Could you commit this?

 
1893 code active 2006 Jul anonymous   2006 Aug   3 3 sqlite doesn't use indexes containing primary key in prim. key selects edit
I have table:

    CREATE TABLE IF NOT EXISTS 'customers' (
       'rowid'      INTEGER       PRIMARY KEY AUTOINCREMENT NOT NULL,
       'fname'      CHAR(40)      NOT NULL,
       'sname'      CHAR(40)      NOT NULL,
       'birthno'    CHAR(11)      NULL)

And index:

    CREATE UNIQUE INDEX IF NOT EXISTS 'idx_customers_sname'
       ON 'customers' (
       'sname'  ASC,
       'fname'  ASC,
       'rowid'  ASC
       );

Command

   SELECT * FROM customers ORDER BY sname ASC, fname ASC, rowid ASC;

doesn't use created index.

Command

   SELECT * FROM customers ORDER BY sname ASC, fname ASC;

uses index idx_customers_sname.

I think this is a bug, but maybe (i don't know), it is by desing. If I don't specify rowid in ORDER BY, is the resultset ordered by rowid anyway?

2006-Jul-24 16:02:29 by anonymous:
In SQL single quotes are used around string literals, and double quotes are used around identifiers where required to enclose keywords and/or embedded spaces. In your case no quotes are required at all because your table and column identifiers are continuos (i.e. do not contain embedded spaces) non-keyword names. If you are going to include unnecessary quotes then you should at least use the correct ones.

    CREATE TABLE IF NOT EXISTS "customers" (
       "rowid"      INTEGER       PRIMARY KEY AUTOINCREMENT NOT NULL,
       "fname"      CHAR(40)      NOT NULL,
       "sname"      CHAR(40)      NOT NULL,
       "birthno"    CHAR(11)      NULL);

    CREATE UNIQUE INDEX IF NOT EXISTS "idx_customers_sname" ON "customers" ( "sname" ASC, "fname" ASC, "rowid" ASC );

Aside from that, this does look like a bug. SQLite is doing an unnecessary sort for the first query, and correctly using the index for the second.

I suspected that it might be related to handling of the special column name rowid, but it does the same thing if rowid is replaced with a more generic name like id as shown below.

    SQLite version 3.3.6
    Enter ".help" for instructions
    sqlite> CREATE TABLE IF NOT EXISTS "customers" (
       ...>    "id"      INTEGER       PRIMARY KEY AUTOINCREMENT NOT NULL,
       ...>    "fname"      CHAR(40)      NOT NULL,
       ...>    "sname"      CHAR(40)      NOT NULL,
       ...>    "birthno"    CHAR(11)      NULL);
    sqlite>
    sqlite> CREATE UNIQUE INDEX IF NOT EXISTS "idx_customers_sname"
       ...>    ON "customers" ( "sname" ASC, "fname" ASC, "id" ASC );
    sqlite>
    sqlite>
    sqlite> explain query plan SELECT * FROM customers ORDER BY sname ASC, fname ASC
    , id ASC;
    0|0|TABLE customers
    sqlite> explain query plan SELECT * FROM customers ORDER BY sname ASC, fname ASC
    ;
    0|0|TABLE customers WITH INDEX idx_customers_sname ORDER BY
    sqlite>
    sqlite> .explain on
    sqlite>
    sqlite> explain SELECT * FROM customers ORDER BY sname ASC, fname ASC, id ASC;
    addr  opcode          p1          p2          p3
    ----  --------------  ----------  ----------  ---------------------------------
    0     OpenVirtual     1           5           keyinfo(3,BINARY,BINARY)
    1     Goto            0           34
    2     Integer         0           0
    3     OpenRead        0           2
    4     SetNumColumns   0           4
    5     Rewind          0           19
    6     Rowid           0           0
    7     Column          0           1
    8     Column          0           2
    9     Column          0           3
    10    MakeRecord      4           0
    11    Column          0           2
    12    Column          0           1
    13    Rowid           0           0
    14    Sequence        1           0
    15    Pull            4           0
    16    MakeRecord      5           0
    17    IdxInsert       1           0
    18    Next            0           6
    19    Close           0           0
    20    OpenPseudo      2           0
    21    SetNumColumns   2           4
    22    Sort            1           32
    23    Integer         1           0
    24    Column          1           4
    25    Insert          2           0
    26    Column          2           0
    27    Column          2           1
    28    Column          2           2
    29    Column          2           3
    30    Callback        4           0
    31    Next            1           23
    32    Close           2           0
    33    Halt            0           0
    34    Transaction     0           0
    35    VerifyCookie    0           2
    36    Goto            0           2
    37    Noop            0           0
    sqlite> explain SELECT * FROM customers ORDER BY sname ASC, fname ASC;
    addr  opcode          p1          p2          p3
    ----  --------------  ----------  ----------  ---------------------------------
    0     Noop            0           0
    1     Goto            0           21
    2     Integer         0           0
    3     OpenRead        0           2
    4     SetNumColumns   0           4
    5     Integer         0           0
    6     OpenRead        2           4           keyinfo(3,BINARY,BINARY)
    7     Rewind          2           18
    8     RowKey          2           0
    9     IdxIsNull       0           17
    10    IdxRowid        2           0
    11    MoveGe          0           0
    12    Rowid           0           0
    13    Column          0           1
    14    Column          0           2
    15    Column          0           3
    16    Callback        4           0
    17    Next            2           8
    18    Close           0           0
    19    Close           2           0
    20    Halt            0           0
    21    Transaction     0           0
    22    VerifyCookie    0           2
    23    Goto            0           2
    24    Noop            0           0
    sqlite>


2006-Aug-03 17:33:51 by anonymous:
Thank you for clarification of single and double quotes usage. I will drop the quotes completely since using double quotes is little bit annoying inside C string literals...

It seems that the problem with index and sorting on primary key is independent of primary key column name. In fact, previously I was using "id" :-) and the result was the same as you mentioned.

 
1901 code active 2006 Jul anonymous Unknown 2006 Jul adamd 2 2 problem in select request with a alias table edit
I have a table with 3 columns : c0, c1 and c2

My request is: select * from (select *, 'test' as new_col from table) as tmp inner join (select 'test' as new_col) as tmp1 on tmp.new_col = tmp1.new_col;

The column's name as a result of this request (sqlite 3-3.3.6) is: |tmp.table.c0|tmp.table.c1|tmp.table.c2|tmp.new_col|tmp1.new_col

In sqlite 3-3.2.7, the column's name is: |c0|c1|c2|collected|new_col|new_col

Before this version, my request ran on mysql, postgresql and sqlite. Now I don't have the possibility of using this request with the new sqlite version.

2006-Jul-31 10:11:59 by anonymous:
sorry in In sqlite 3-3.2.7, the column's name is: |c0|c1|c2|new_col|new_col


2007-Jan-08 14:52:43 by anonymous:
I had a similar problem with SQLite in PHP, see my bug report here: http://bugs.php.net/bug.php?id=40064
 
1900 code active 2006 Jul anonymous Unknown 2006 Jul a.rottmann 1 1 CURRENT_TIMESTAMP keyword not inserting UTC date in column edit
This is the schema for my table.

create table char (player varchar(64) NOT NULL default '~', name varchar(64) NOT NULL default '~', date timestamp NOT NULL default current_timestamp)

Whenever an insert is made to the table the column 'date' does get a UTC timestamp, it gets a string value 'current_timestamp'. Is my schema wrong?

2006-Jul-30 22:31:06 by anonymous:
*doesnt get a UTC timestap


2006-Jul-31 00:38:49 by anonymous:
Works fine for me. What's the exact syntax of your INSERT statement?
 
1890 code active 2006 Jul anonymous Unknown 2006 Jul   3 4 double quotes ("") in a query are ambiguous edit
sqlite> SELECT "uuid" FROM objects LIMIT 1;
b43c9cdc-0dc8-11db-9475-080020a846a9
sqlite> SELECT "uuidx" FROM objects LIMIT 1;
uuidx

The objects table has a column named uuid; it does not have a column named uuidx. The behaviour of "" depends on whether the contents are a valid column name, and I cannot see when this is desirable behaviour.

(I know that `` and '' are the right quotes to use, by the way - I'm just pointing out that "" can surprise people a lot and should probably be fixed or removed)

2006-Jul-13 13:39:37 by anonymous:
The current behaviour is an SQL standard thing, so SQLite implements it for the sake of compatibility.

Certainly most people agree with you that it's a bad thing.


2006-Jul-13 16:56:05 by anonymous:
Perhaps what we need then is a big fat warning in the manual :) - Peter


2006-Jul-17 00:06:41 by drh:
Please suggest a specific location in the documentation where I should put a warning about the use of " instead of ' and I will add it.


2006-Jul-27 10:30:12 by anonymous:
lang_expr.html seems like an obvious choice; perhaps also a sidenote on FAQ question 16 - Peter
 
1885 code active 2006 Jul anonymous Shell 2006 Jul   2 3 sqlite3 .mode insert and .dump do not list column names for selects edit
In sqlite3 .mode insert does not list column names for selects - it should. This makes dumping selected columns from tables when intending to add or delete columns problematic. .dump doesn't list column names either, IMHO it should. Consider

sqlite> .mode tabs
sqlite> select * from users;
ed 2006-07-05 52
sqlite> .mode insert
sqlite> select abs_tgt from users;
INSERT INTO table VALUES(52);
sqlite>

Obviously the workaround is to hand edit the output SQL

2006-Jul-11 10:20:08 by anonymous:
I've just noticed it doesn't include the table name in the INSERT statements either.
 
1884 code active 2006 Jul anonymous   2006 Jul   3 2 pragma table_info caches results from previous query edit
this problem is observed with pysqlite's latest windows build 2.3.2 and others. it does not occur on unix-based builds, which is why I suspect the issue is in sqlite, since pysqlite's code is platform-neutral.

if you get a result from a "pragma table_info()" call, and do not consume all the results, then a subsequent call to the same statement does not return up-to-date results, i.e. if the table had been dropped in between. it behaves as though the results of "pragma table_info" are globally cached somewhere, ignoring the fact that is was executed again.

this test program illustrates the problem:

	from pysqlite2 import dbapi2 as sqlite

	connection = sqlite.connect(':memory:')

	# check for a nonexistent table
	c = connection.execute("pragma table_info(users)")
	row = c.fetchone()
	assert row is None   # its good.

	# now create the table
	connection.execute("""
	create table users (
		foo VARCHAR(10),
		name VARCHAR(40)
	)
	""")

	# do the table_info pragma.  returns two rows
	c = connection.execute("pragma table_info(users)")

	# get the first row
	row = c.fetchone()
	print row

	# but then dont get the second, close out the cursor instead.

	#row2 = c.fetchone()  # uncomment to fully consume both rows, then it works

	c.close()
	c = None

	# rollback too.
	connection.rollback()

	# now drop the table
	connection.execute("DROP TABLE users")

	print "dropped"

	# now it should be gone, right? well it is, but the pragma
	# call starts off with the former result set
	c = connection.execute("pragma table_info(users)")
	row = c.fetchone()
	print row
	assert row is None  # fails.
 
1882 code active 2006 Jul anonymous   2006 Jul   1 1 Wrong algorithm of SQLITE_VERSION_NUMBER calculation edit
The sqlite3.h comment describing how numeric version number is calculated is as follows:

"The SQLITE_VERSION_NUMBER is an integer with the value (X*100000 + Y*1000 + Z). For example, for version "3.1.1beta", SQLITE_VERSION_NUMBER is set to 3001001."

But the value of SQLITE_VERSION_NUMBER is greater than the equation above suggests. The value X*100000 should be changed to X*1000000 (one milion).

 
1878 code active 2006 Jun anonymous CodeGen 2006 Jun   2 3 No index used when specifying alias name in ORDER BY clause edit
Using an alias name in the ORDER BY clause prevents indices from being used in the query for sorting purposes:

For this schema:

  CREATE TABLE t1 (c1, c2);
  CREATE TABLE t2 (c3, c4);
  CREATE INDEX t1_idx ON t1(c2);

the following select query:

  EXPLAIN QUERY PLAN
  SELECT t1.c2 AS col2, t2.c4 AS col4
    FROM t1 LEFT JOIN t2 ON t1.c1=t2.c3 ORDER BY t1.c2;

will indeed use index t1_idx:

  sqlite> EXPLAIN QUERY PLAN
          SELECT t1.c2 AS col2, t2.c4 AS col4
            FROM t1 LEFT JOIN t2 ON t1.c1=t2.c3
           ORDER BY t1.c2;
  0|0|TABLE t1 WITH INDEX t1_idx
  1|1|TABLE t2

However, when using the alias name col2 in the ORDER BY clause, the index won't be used:

  sqlite> EXPLAIN QUERY PLAN
          SELECT t1.c2 AS col2, t2.c4 AS col4
            FROM t1 LEFT JOIN t2 ON t1.c1=t2.c3
           ORDER BY col2;
  0|0|TABLE t1
  1|1|TABLE t2

IMHO, the same index should be used in both queries?

2006-Jun-30 13:54:10 by anonymous:
Not sure whether it's a different issue, but when using a second column in the ORDER BY clause, also no index will be used:

  sqlite> EXPLAIN QUERY PLAN
          SELECT t1.c2 AS col2, t2.c4 AS col4
            FROM t1 LEFT JOIN t2 ON t1.c1=t2.c3 ORDER BY t1.c2, t2.c4;
  0|0|TABLE t1
  1|1|TABLE t2

Personally, I'd expect sqlite to use the t1_idx index as well to fulfill the primary ordering?


2006-Jun-30 16:04:31 by anonymous:
As a workaround try "ORDER BY 1"


2006-Jul-03 08:41:01 by anonymous:
Sorry, I'm not sure how "ORDER BY 1" would be a workaround, when I really need the results to be sorted by table column data...

(I don't want to start a discussion in the bug tracker, so you're welcome to take any suggestions/answers to the sqlite-user mailing list, which I also monitor.)

2006-Jul-03 15:51:11 by anonymous:
I'm not the poster of previous comment, but ORDER BY (n) order by result column index. In your case, using ORDER BY 1, it will be ordered by the first column.


2006-Jul-04 07:33:30 by anonymous:
Thanks for the clarification. This would be a workaround for the first problem mentioned, but when sorting by two columns, still no index will be used, even if using ORDER BY 1,2


2006-Jul-04 21:34:24 by anonymous:
SQLite really needs a way to explicitly state which index(es) to use. Perhaps something similar to Oracle's comment hints.
 
1872 code active 2006 Jun anonymous   2006 Jun   4 3 sqlite3_open doesn't support RFC1738 format for filename edit
sqlite3_open only supports UTF-8 encoding as a format for its filename argument (http://www.sqlite.org/capi3ref.html#sqlite3_open).

If your application receives a RFC1738 encoded URL for filename, that has to be UTF-8-encoded for use in SQLite. It would be nice if that could be instead passed directly to sqlite3_open.

Is RFC1738 URL decoding support planned for SQLite?

(RFC1738 link: http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc1738.html)

 
1867 code active 2006 Jun anonymous BTree 2006 Jun   1 3 Access Violation after set a new page_size edit
An access violation occured on W2K when I try to create a new table in the empty database. There was a following sequence of SQL commands

select count(*)==2 as cnt from sqlite_master where type='table' and tbl_name in ('tbl1', 'tbl2');

so if cnt is equal 0 then I execute command pragma page_size=4096; and then create a new table.

I gess that some of internal structures by this time have been initialized and so when I try to create new table the page_size is lower then needed.

we overwrite memory in the function zeroPage in instruction: memset(&data[hdr], 0, pBt->usableSize - hdr); Size of structure data less then pBt->usableSize

Below result after memset

0:000> dt MemPage 004c3cf0
+0x000 isInit : 0 ''
+0x001 idxShift : 0 ''
+0x002 nOverflow : 0 ''
+0x003 intKey : 0x1 ''
+0x004 leaf : 0x1 ''
+0x005 zeroData : 0 ''
+0x006 leafData : 0x1 ''
+0x007 hasData : 0 ''
+0x008 hdrOffset : 0 ''
+0x009 childPtrSize : 0 ''
+0x00a maxLocal : 0
+0x00c minLocal : 0
+0x00e cellOffset : 0
+0x010 idxParent : 0
+0x012 nFree : 0xf94
+0x014 nCell : 0
+0x018 aOvfl : [5] _OvflCell
+0x040 pBt : (null)
+0x044 aData : (null)
+0x048 pgno : 0
+0x04c pParent : (null)

0012ea50 10006861 004c3cf0 0000000d 00000064 dblited!decodeFlags+0x80 [D:\sqllite\sqlite-3.3.6\btree.c @ 1349]
0012ea70 10006710 004c3cf0 0000000d 004c3cf0 dblited!zeroPage+0xd0 [D:\sqllite\sqlite-3.3.6\btree.c @ 1466]
0012ea8c 10006215 002fd390 002fd390 00000000 dblited!newDatabase+0xf9 [D:\sqllite\sqlite-3.3.6\btree.c @ 2061]
0012eaa0 10052ba0 002f7c30 00000001 0012f0e4 dblited!sqlite3BtreeBeginTrans+0xd6 [D:\sqllite\sqlite-3.3.6\btree.c @ 2141]
0012f0a4 10057cf5 004c3d80 0012f13c 0012f478 dblited!sqlite3VdbeExec+0x2c6d [D:\sqllite\sqlite-3.3.6\vdbe.c @ 2386]
0012f0e4 00412801 004c3d80 0012f1d4 0012f478 dblited!sqlite3_step+0x1db [D:\sqllite\sqlite-3.3.6\vdbeapi.c @ 223]
 
1862 code active 2006 Jun anonymous TclLib 2006 Jun tclguy 1 1 SQLite cannot load/import data from file edit
I found the problem when I tried to load a data file into a table. To reproduce the problem, I got a mini testcase.

DATA FILE - test.dat


    1       0       0
    2       90000   0
    3       366000  0
---------------------------

Log from SQLite:


    khronos-yajun>sqlite3 test
    SQLite version 3.3.6
    Enter ".help" for instructions
    sqlite> create table test (id INT, x1 INT, x2 INT);
    sqlite> .import test.dat test
    test.dat line 1: expected 3 columns of data but found 1
    sqlite> .exit


The problem also exists when I use tcl wrapper (sql copy abort test test.dat).

I looked into the code in src/tclsqlite.c,

In Lines

   1045     nByte = strlen(zSql);
   1046     rc = sqlite3_prepare(pDb->db, zSql, 0, &pStmt, 0);
   1047     sqlite3_free(zSql);

Is the third argument of sqlite3_prepare supposed to be the length of zSql, hence nByte?

Also in lines

   1070     zSql[j++] = ')';
   1071     zSql[j] = 0;
   1072     rc = sqlite3_prepare(pDb->db, zSql, 0, &pStmt, 0);
   1073     free(zSql);

If I change these two places to reflect the length of zSql, I seem to succeed.

Yajun

2006-Sep-27 16:25:47 by anonymous:
This is a duplicate of #1797
 
1861 code active 2006 Jun anonymous Pager 2006 Jun   1 1 Problem in using Triggers and multithreading edit
I am using SQLite3 database with triggers . This database is used by my processing engine which is having 10 threads accessing the same database. Trigger is used to updata and insert records in a table and that very table is also updated by threads.

Processing engine crashes whenever a trigger updates or inserts a record in the table.

Can you tell me how to configure my existing engine to avoid crashing? Is it safe to use trigger?

 
1857 code active 2006 Jun anonymous   2006 Jun   3 4 Can't use ISO 8601 dates with time zone designator 'Z' edit
Date-times of the format 'YYYY-MM-DDTHH:MM:SS.sssZ' do not return a valid date. e.g. datetime('2006-06-19T15:44:07.466940Z').

The 'Z' indicates UTC.
This is the format generated by 'svn log --xml'.

More details of the format at http://www.w3.org/TR/NOTE-datetime.

This 'svn diff' fixes the problem:

--- date.c      (revision 656)
+++ date.c      (working copy)
@@ -136,7 +136,7 @@
 **
 ** If the parse is successful, write the number of minutes
 ** of change in *pnMin and return 0.  If a parser error occurs,
-** return 0.
+** return 1.
 **
 ** A missing specifier is not considered an error.
 */
@@ -200,7 +200,10 @@
   p->h = h;
   p->m = m;
   p->s = s + ms;
-  if( parseTimezone(zDate, p) ) return 1;
+  if (*zDate == 'Z')
+       p->tz = 0;
+  else if( parseTimezone(zDate, p) )
+    return 1;
   p->validTZ = p->tz!=0;
   return 0;
 }

PS Should probably add a test case to 'sqlite/test/date.test'.

 
1856 code active 2006 Jun anonymous   2006 Jun   2 3 SQLITE_OMIT_UTF16 breaks 'make test' edit
When compiling sqlite 3.3.6 with -DSQLITE_OMIT_UTF16 and you say 'make test' it fails:

  make test
./libtool --mode=link gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src -DSQLITE_DEBUG=2 -DSQLITE_MEMDEBUG=2 -DSQLITE_OMIT_UTF16  -I/usr/include -DTHREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_CURSOR -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 \
        -DTEMP_STORE=1 -o testfixture ./src/btree.c ./src/date.c ./src/func.c ./src/os.c ./src/os_unix.c ./src/os_win.c ./src/os_os2.c ./src/pager.c ./src/pragma.c ./src/printf.c ./src/test1.c ./src/test2.c ./src/test3.c ./src/test4.c ./src/test5.c ./src/test6.c ./src/test7.c ./src/test_async.c ./src/test_md5.c ./src/test_server.c ./src/utf.c ./src/util.c ./src/vdbe.c ./src/where.c ./src/tclsqlite.c \
        libsqlite3.la -L/usr/lib -ltcl8.4 -ldl  -lpthread -lieee -lm
gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src -DSQLITE_DEBUG=2 -DSQLITE_MEMDEBUG=2 -DSQLITE_OMIT_UTF16 -I/usr/include -DTHREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_CURSOR -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 -DTEMP_STORE=1 -o .libs/testfixture ./src/btree.c ./src/date.c ./src/func.c ./src/os.c ./src/os_unix.c ./src/os_win.c ./src/os_os2.c ./src/pager.c ./src/pragma.c ./src/printf.c ./src/test1.c ./src/test2.c ./src/test3.c ./src/test4.c ./src/test5.c ./src/test6.c ./src/test7.c ./src/test_async.c ./src/test_md5.c ./src/test_server.c ./src/utf.c ./src/util.c ./src/vdbe.c ./src/where.c ./src/tclsqlite.c  ./.libs/libsqlite3.so -L/usr/lib -ltcl8.4 -ldl -lpthread -lieee -lm -Wl,--rpath -Wl,/home/cla/proj/caissadb/sqlite/sqlite/lib
./src/test1.c: In function 'Sqlitetest1_Init':
./src/test1.c:3742: error: 'unaligned_string_counter' undeclared (first use in this function)
./src/test1.c:3742: error: (Each undeclared identifier is reported only once
./src/test1.c:3742: error: for each function it appears in.)
make: *** [testfixture] Error 1

Maybe there is a '#ifndef SQLITE_OMIT_UTF16' / '#endif' needed around

  Tcl_LinkVar(interp, "unaligned_string_counter",
      (char*)&unaligned_string_counter, TCL_LINK_INT);

in Line 3742 in file src/test1.c?

Regards.

 
1853 code active 2006 Jun anonymous   2006 Jun   3 4 sqlite3_analyzer-3.3.4 integer overflows on large database edit
sqlite3_analyzer-3.3.4 reports senseless values (negative bytes and percents) for some fields of my 28 GB database:

Examples:

   Bytes of storage consumed............. 291456000
   Bytes of payload...................... -1382746251 -474.4%
   Average payload per entry............. -3.80

(I'll attached the full output separatly.)

I'm using the pre-built Linux binary of sqlite3_analyzer-3.3.4 from the sqlite homepage. My system is

cn@jehova:~/misc/jibladze> uname -a Linux jehova 2.6.13-15.10-smp #1 SMP Fri May 12 16:11:24 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux

2006-Jun-18 17:28:20 by anonymous:
Here's the full output:

  cn@jehova:~> du -ah /playground/cn/yacop-data/gfr/steenrod-5-E-1Rfull
  28G     /playground/cn/yacop-data/gfr/steenrod-5-E-1Rfull
  cn@jehova:~> sqlite-analyzer /playground/cn/yacop-data/gfr/steenrod-5-E-1Rfull
  Analyzing table chartinfo...
  Analyzing table complog...
  Analyzing table fragments...
  Analyzing table generators...
  Analyzing table header...
  Analyzing table sqlite_master...
  Analyzing table worklog...
  Analyzing index sdegind of table fragments...
  Analyzing index sqlite_autoindex_header_1 of table header...
  Analyzing index sqlite_autoindex_worklog_1 of table worklog...
  /** Disk-Space Utilization Report For /playground/cn/yacop-data/gfr/steenrod-5-E-1Rfull
  *** As of 2006-Jun-18 18:55:01

  Page size in bytes.................... 1024
  Pages in the whole file (measured).... 28439973
  Pages in the whole file (calculated).. 28439972
  Pages that store data................. 28439972   100.000%
  Pages on the freelist (per header).... 0            0.0%
  Pages on the freelist (calculated).... 1            0.0%
  Pages of auto-vacuum overhead......... 0            0.0%
  Number of tables in the database...... 7
  Number of indices..................... 3
  Number of named indices............... 1
  Automatically generated indices....... 2
  Size of the file in bytes............. 29122532352
  Bytes of user payload stored.......... -1818729787  -6.2%

  *** Page counts for all tables with their indices ********************

  FRAGMENTS............................. 28409448    99.89%
  COMPLOG............................... 13559        0.048%
  CHARTINFO............................. 11151        0.039%
  GENERATORS............................ 5797         0.020%
  WORKLOG............................... 10           0.0%
  SQLITE_MASTER......................... 5            0.0%
  HEADER................................ 2            0.0%

  *** All tables and indices *******************************************

  Percentage of total database.......... 100.000%
  Number of entries..................... 728140955
  Bytes of storage consumed............. -942239744
  Bytes of payload...................... 1093495310 -116.1%
  Average payload per entry............. 1.50
  Average unused bytes per entry........ -2.73
  Average fanout........................ 88.00
  Maximum payload per entry............. 1157
  Entries that use overflow............. 351          0.0%
  Index pages used...................... 270372
  Primary pages used.................... 28169249
  Overflow pages used................... 351
  Total pages used...................... 28439972
  Unused bytes on index pages........... 32954241    11.9%
  Unused bytes on primary pages......... -2022053395 165.815%
  Unused bytes on overflow pages........ 37488       10.4%
  Unused bytes on all pages............. -1989061666 211.099%

  *** All tables *******************************************************

  Percentage of total database..........  84.3%
  Number of entries..................... 364670985
  Bytes of storage consumed............. -1233700864
  Bytes of payload...................... -1818727376 147.420%
  Average payload per entry............. -4.99
  Average unused bytes per entry........ 4.87
  Average fanout........................ 88.00
  Maximum payload per entry............. 1157
  Entries that use overflow............. 351          0.0%
  Index pages used...................... 270372
  Primary pages used.................... 23690315
  Overflow pages used................... 351
  Total pages used...................... 23961038
  Unused bytes on index pages........... 32954241    11.9%
  Unused bytes on primary pages......... 1742865277 -115.4%
  Unused bytes on overflow pages........ 37488       10.4%
  Unused bytes on all pages............. 1775857006 -143.9%

  *** All indices ******************************************************

  Percentage of total database..........  15.7%
  Number of entries..................... 363469970
  Bytes of storage consumed............. 291461120
  Bytes of payload...................... -1382744610 -474.4%
  Average payload per entry............. -3.80
  Average unused bytes per entry........ 1.46
  Maximum payload per entry............. 17
  Entries that use overflow............. 0            0.0%
  Primary pages used.................... 4478934
  Overflow pages used................... 0
  Total pages used...................... 4478934
  Unused bytes on primary pages......... 530048624  181.859%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 530048624  181.859%

  *** Table CHARTINFO **************************************************

  Percentage of total database..........   0.039%
  Number of entries..................... 560603
  Bytes of storage consumed............. 11418624
  Bytes of payload...................... 7708145     67.5%
  Average payload per entry............. 13.75
  Average unused bytes per entry........ 0.31
  Average fanout........................ 99.00
  Maximum payload per entry............. 14
  Entries that use overflow............. 0            0.0%
  Index pages used...................... 112
  Primary pages used.................... 11039
  Overflow pages used................... 0
  Total pages used...................... 11151
  Unused bytes on index pages........... 14280       12.5%
  Unused bytes on primary pages......... 160371       1.4%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 174651       1.5%

  *** Table COMPLOG ****************************************************

  Percentage of total database..........   0.048%
  Number of entries..................... 322413
  Bytes of storage consumed............. 13884416
  Bytes of payload...................... 11350473    81.7%
  Average payload per entry............. 35.20
  Average unused bytes per entry........ 1.20
  Average fanout........................ 98.00
  Maximum payload per entry............. 45
  Entries that use overflow............. 0            0.0%
  Index pages used...................... 138
  Primary pages used.................... 13421
  Overflow pages used................... 0
  Total pages used...................... 13559
  Unused bytes on index pages........... 19411       13.7%
  Unused bytes on primary pages......... 367295       2.7%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 386706       2.8%

  *** Table FRAGMENTS and all its indices ******************************

  Percentage of total database..........  99.89%
  Number of entries..................... 726939530
  Bytes of storage consumed............. -973496320
  Bytes of payload...................... 1070540938 -110.0%
  Average payload per entry............. 1.47
  Average unused bytes per entry........ -2.74
  Average fanout........................ 88.00
  Maximum payload per entry............. 1157
  Entries that use overflow............. 351          0.0%
  Index pages used...................... 270061
  Primary pages used.................... 28139036
  Overflow pages used................... 351
  Total pages used...................... 28409448
  Unused bytes on index pages........... 32910337    11.9%
  Unused bytes on primary pages......... -2022636857 161.759%
  Unused bytes on overflow pages........ 37488       10.4%
  Unused bytes on all pages............. -1989689032 204.386%

  *** Table FRAGMENTS w/o any indices **********************************

  Percentage of total database..........  84.1%
  Number of entries..................... 363469765
  Bytes of storage consumed............. -1264952320
  Bytes of payload...................... -1841680107 145.593%
  Average payload per entry............. -5.07
  Average unused bytes per entry........ 4.88
  Average fanout........................ 88.00
  Maximum payload per entry............. 1157
  Entries that use overflow............. 351          0.0%
  Index pages used...................... 270061
  Primary pages used.................... 23660107
  Overflow pages used................... 351
  Total pages used...................... 23930519
  Unused bytes on index pages........... 32910337    11.9%
  Unused bytes on primary pages......... 1742284627 -113.0%
  Unused bytes on overflow pages........ 37488       10.4%
  Unused bytes on all pages............. 1775232452 -140.3%

  *** Indices of table FRAGMENTS ***************************************

  Percentage of total database..........  15.7%
  Number of entries..................... 363469765
  Bytes of storage consumed............. 291456000
  Bytes of payload...................... -1382746251 -474.4%
  Average payload per entry............. -3.80
  Average unused bytes per entry........ 1.46
  Maximum payload per entry............. 9
  Entries that use overflow............. 0            0.0%
  Primary pages used.................... 4478929
  Overflow pages used................... 0
  Total pages used...................... 4478929
  Unused bytes on primary pages......... 530045812  181.861%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 530045812  181.861%

  *** Table GENERATORS *************************************************

  Percentage of total database..........   0.020%
  Number of entries..................... 317989
  Bytes of storage consumed............. 5936128
  Bytes of payload...................... 3889213     65.5%
  Average payload per entry............. 12.23
  Average unused bytes per entry........ 0.18
  Average fanout........................ 98.00
  Maximum payload per entry............. 14
  Entries that use overflow............. 0            0.0%
  Index pages used...................... 59
  Primary pages used.................... 5738
  Overflow pages used................... 0
  Total pages used...................... 5797
  Unused bytes on index pages........... 8350        13.8%
  Unused bytes on primary pages......... 49171        0.84%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 57521        0.97%

  *** Table HEADER and all its indices *********************************

  Percentage of total database..........   0.0%
  Number of entries..................... 10
  Bytes of storage consumed............. 2048
  Bytes of payload...................... 187          9.1%
  Average payload per entry............. 18.70
  Average unused bytes per entry........ 180.70
  Maximum payload per entry............. 50
  Entries that use overflow............. 0            0.0%
  Primary pages used.................... 2
  Overflow pages used................... 0
  Total pages used...................... 2
  Unused bytes on primary pages......... 1807        88.2%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 1807        88.2%

  *** Table HEADER w/o any indices *************************************

  Percentage of total database..........   0.0%
  Number of entries..................... 5
  Bytes of storage consumed............. 1024
  Bytes of payload...................... 124         12.1%
  Average payload per entry............. 24.80
  Average unused bytes per entry........ 173.80
  Maximum payload per entry............. 50
  Entries that use overflow............. 0            0.0%
  Primary pages used.................... 1
  Overflow pages used................... 0
  Total pages used...................... 1
  Unused bytes on primary pages......... 869         84.9%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 869         84.9%

  *** Indices of table HEADER ******************************************

  Percentage of total database..........   0.0%
  Number of entries..................... 5
  Bytes of storage consumed............. 1024
  Bytes of payload...................... 63           6.2%
  Average payload per entry............. 12.60
  Average unused bytes per entry........ 187.60
  Maximum payload per entry............. 17
  Entries that use overflow............. 0            0.0%
  Primary pages used.................... 1
  Overflow pages used................... 0
  Total pages used...................... 1
  Unused bytes on primary pages......... 938         91.6%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 938         91.6%

  *** Table SQLITE_MASTER **********************************************

  Percentage of total database..........   0.0%
  Number of entries..................... 10
  Bytes of storage consumed............. 5120
  Bytes of payload...................... 2411        47.1%
  Average payload per entry............. 241.10
  Average unused bytes per entry........ 249.70
  Average fanout........................ 4.00
  Maximum payload per entry............. 483
  Entries that use overflow............. 0            0.0%
  Index pages used...................... 1
  Primary pages used.................... 4
  Overflow pages used................... 0
  Total pages used...................... 5
  Unused bytes on index pages........... 891         87.0%
  Unused bytes on primary pages......... 1606        39.2%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 2497        48.8%

  *** Table WORKLOG and all its indices ********************************

  Percentage of total database..........   0.0%
  Number of entries..................... 400
  Bytes of storage consumed............. 10240
  Bytes of payload...................... 3943        38.5%
  Average payload per entry............. 9.86
  Average unused bytes per entry........ 10.46
  Average fanout........................ 5.00
  Maximum payload per entry............. 13
  Entries that use overflow............. 0            0.0%
  Index pages used...................... 1
  Primary pages used.................... 9
  Overflow pages used................... 0
  Total pages used...................... 10
  Unused bytes on index pages........... 972         94.9%
  Unused bytes on primary pages......... 3212        34.9%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 4184        40.9%

  *** Table WORKLOG w/o any indices ************************************

  Percentage of total database..........   0.0%
  Number of entries..................... 200
  Bytes of storage consumed............. 6144
  Bytes of payload...................... 2365        38.5%
  Average payload per entry............. 11.82
  Average unused bytes per entry........ 11.55
  Average fanout........................ 5.00
  Maximum payload per entry............. 13
  Entries that use overflow............. 0            0.0%
  Index pages used...................... 1
  Primary pages used.................... 5
  Overflow pages used................... 0
  Total pages used...................... 6
  Unused bytes on index pages........... 972         94.9%
  Unused bytes on primary pages......... 1338        26.1%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 2310        37.6%

  *** Indices of table WORKLOG *****************************************

  Percentage of total database..........   0.0%
  Number of entries..................... 200
  Bytes of storage consumed............. 4096
  Bytes of payload...................... 1578        38.5%
  Average payload per entry............. 7.89
  Average unused bytes per entry........ 9.37
  Maximum payload per entry............. 9
  Entries that use overflow............. 0            0.0%
  Primary pages used.................... 4
  Overflow pages used................... 0
  Total pages used...................... 4
  Unused bytes on primary pages......... 1874        45.8%
  Unused bytes on overflow pages........ 0
  Unused bytes on all pages............. 1874        45.8%

  *** Definitions ******************************************************

  Page size in bytes

      The number of bytes in a single page of the database file.
      Usually 1024.

  Number of pages in the whole file

      The number of 1024-byte pages that go into forming the complete
      database

  Pages that store data

      The number of pages that store data, either as primary B*Tree pages or
      as overflow pages.  The number at the right is the data pages divided by
      the total number of pages in the file.

  Pages on the freelist

      The number of pages that are not currently in use but are reserved for
      future use.  The percentage at the right is the number of freelist pages
      divided by the total number of pages in the file.

  Pages of auto-vacuum overhead

      The number of pages that store data used by the database to facilitate
      auto-vacuum. This is zero for databases that do not support auto-vacuum.

  Number of tables in the database

      The number of tables in the database, including the SQLITE_MASTER table
      used to store schema information.

  Number of indices

      The total number of indices in the database.

  Number of named indices

      The number of indices created using an explicit CREATE INDEX statement.

  Automatically generated indices

      The number of indices used to implement PRIMARY KEY or UNIQUE constraints
      on tables.

  Size of the file in bytes

      The total amount of disk space used by the entire database files.

  Bytes of user payload stored

      The total number of bytes of user payload stored in the database. The
      schema information in the SQLITE_MASTER table is not counted when
      computing this number.  The percentage at the right shows the payload
      divided by the total file size.

  Percentage of total database

      The amount of the complete database file that is devoted to storing
      information described by this category.

  Number of entries

      The total number of B-Tree key/value pairs stored under this category.

  Bytes of storage consumed

      The total amount of disk space required to store all B-Tree entries
      under this category.  The is the total number of pages used times
      the pages size.

  Bytes of payload

      The amount of payload stored under this category.  Payload is the data
      part of table entries and the key part of index entries.  The percentage
      at the right is the bytes of payload divided by the bytes of storage
      consumed.

  Average payload per entry

      The average amount of payload on each entry.  This is just the bytes of
      payload divided by the number of entries.

  Average unused bytes per entry

      The average amount of free space remaining on all pages under this
      category on a per-entry basis.  This is the number of unused bytes on
      all pages divided by the number of entries.

  Maximum payload per entry

      The largest payload size of any entry.

  Entries that use overflow

      The number of entries that user one or more overflow pages.

  Total pages used

      This is the number of pages used to hold all information in the current
      category.  This is the sum of index, primary, and overflow pages.

  Index pages used

      This is the number of pages in a table B-tree that hold only key (rowid)
      information and no data.

  Primary pages used

      This is the number of B-tree pages that hold both key and data.

  Overflow pages used

      The total number of overflow pages used for this category.

  Unused bytes on index pages

      The total number of bytes of unused space on all index pages.  The
      percentage at the right is the number of unused bytes divided by the
      total number of bytes on index pages.

  Unused bytes on primary pages

      The total number of bytes of unused space on all primary pages.  The
      percentage at the right is the number of unused bytes divided by the
      total number of bytes on primary pages.

  Unused bytes on overflow pages

      The total number of bytes of unused space on all overflow pages.  The
      percentage at the right is the number of unused bytes divided by the
      total number of bytes on overflow pages.

  Unused bytes on all pages

      The total number of bytes of unused space on all primary and overflow
      pages.  The percentage at the right is the number of unused bytes
      divided by the total number of bytes.

  **********************************************************************
  The entire text of this report can be sourced into any SQL database
  engine for further analysis.  All of the text above is an SQL comment.
  The data used to generate this report follows:
  */
  BEGIN;
  CREATE TABLE space_used(
     name clob,        -- Name of a table or index in the database file
     tblname clob,     -- Name of associated table
     is_index boolean, -- TRUE if it is an index, false for a table
     nentry int,       -- Number of entries in the BTree
     leaf_entries int, -- Number of leaf entries
     payload int,      -- Total amount of data stored in this table or index
     ovfl_payload int, -- Total amount of data stored on overflow pages
     ovfl_cnt int,     -- Number of entries that use overflow
     mx_payload int,   -- Maximum payload size
     int_pages int,    -- Number of interior pages used
     leaf_pages int,   -- Number of leaf pages used
     ovfl_pages int,   -- Number of overflow pages used
     int_unused int,   -- Number of unused bytes on interior pages
     leaf_unused int,  -- Number of unused bytes on primary pages
     ovfl_unused int   -- Number of unused bytes on overflow pages
  );
  INSERT INTO space_used VALUES('chartinfo','chartinfo',0,571641,560603,7708145,0,0,14,112,11039,0,14280,160371,0);
  INSERT INTO space_used VALUES('complog','complog',0,335833,322413,11350473,0,0,45,138,13421,0,19411,367295,0);
  INSERT INTO space_used VALUES('fragments','fragments',0,387129871,363469765,19633156373,320532,351,1157,270061,23660107,351,32910337,1742284627,37488);
  INSERT INTO space_used VALUES('generators','generators',0,323726,317989,3889213,0,0,14,59,5738,0,8350,49171,0);
  INSERT INTO space_used VALUES('header','header',0,5,5,124,0,0,50,0,1,0,0,869,0);
  INSERT INTO space_used VALUES('sqlite_master','sqlite_master',0,13,10,2411,0,0,483,1,4,0,891,1606,0);
  INSERT INTO space_used VALUES('worklog','worklog',0,204,200,2365,0,0,13,1,5,0,972,1338,0);
  INSERT INTO space_used VALUES('sdegind','fragments',1,363469765,363469765,2912221045,0,0,9,0,4478929,0,0,530045812,0);
  INSERT INTO space_used VALUES('sqlite_autoindex_header_1','header',1,5,5,63,0,0,17,0,1,0,0,938,0);
  INSERT INTO space_used VALUES('sqlite_autoindex_worklog_1','worklog',1,200,200,1578,0,0,9,0,4,0,0,1874,0);
  COMMIT;
 
1851 code active 2006 Jun anonymous Unknown 2006 Jun   2 1 USE "ORDER BY" error on uClinux edit
when I use "ORDER BY" function in a "select" on uClinux 2.4.24, I get a error:"SQL error or missing database" but the same program run on windows or Linux OK.
2006-Jun-16 11:20:15 by drh:
This is certainly a strange error. Combined with #1850, it suggests a problem with your build, not a problem in SQLite.

I have no ability to use or run uCLinux. So if the error cannot be reproduced on a desktop system, there is not much I can do to address the problem. I am afraid you are on your own on this one.


2006-Jun-19 03:12:31 by anonymous:
I'm just wondering that SQLite 3.2.8 runs on this uClinux system OK but SQLite 3.3.5 is error.
 
1850 code active 2006 Jun anonymous Unknown 2006 Jun   2 1 NUMERIC data type ERROE when read on uClinux edit
I have update some data of a tables's NUMERIC TYPE column on Windows or Linux,but when I use "select *......." to read on uClinux 2.4.24,I get the wrong value,example:the date I've written is 12.5,but readback is 2.3534826093695e -18.5(use the sqlite3_column_text API). I tried to get the value used "sqlite3_column_double" API,but the result is also wrong;

But when I update some data with this column on uClinux,I can read the data right!

2006-Jun-16 01:53:24 by drh:
What CPU is this happening on?

SQLite assumes that floating point values are stored as IEEE 64-bit floats in the same byte order as a 64-bit integer. If your chip does not match this expectation, then floating point won't work.

 
1838 code active 2006 Jun anonymous   2006 Jun   5 5 test types3-1.3 fails on 64-bit Linux edit
I just compiled 3.3.6 on my 64-bit Linux system (OpenSuse 10, using a self-compiled Tcl 8.4.11) and got one failure from "make test":

  types3-1.3...
  Expected: [wideInt integer]
       Got: [int integer]

This seems to be an error in the test suite itself: Changing

    set V [expr {1+123456789012345}]

to

    set V [expr {wide(1+123456789012345)}]

gets rid of the failure.

 
1816 code active 2006 May anonymous VDBE 2006 May   1 2 Database corruption with pragma auto_vacuum edit
We had a database created with PRAGMA auto_vacuum=1, that started returning the following message on a DELETE statement.

  SQL error: database disk image is malformed

Running the VACUUM command and running the same DELETE statement succeeds.

  Running PRAGMA integrity_check on the database (before the VACUUM command is issued) results in the following output:
sqlite> PRAGMA integrity_check;
*** in database main ***
Page 3393 is never used
Page 3398 is never used
Page 3400 is never used
Page 3401 is never used
Page 3402 is never used
Page 3405 is never used
Page 3406 is never used
sqlite> VACUUM;
sqlite> PRAGMA integrity_check;
ok

We tried as a temporary workaround, running PRAGMA integrity_check and, based on the result, deciding whether or not to run VACUUM, but this can consume too much time.

If needed, I can send a small database that exhibits this problem.

2006-May-22 21:45:47 by drh:
The database is probably not helpful. What I need to know is:

  • What sequence of SQL statements do you issue to cause this to occur?
  • What operating system you are using.
  • Is the application multi-threaded?
  • Is the problem reproducible?
  • Are you using a precompiled binary or did you compile it yourself?
  • Does the problem go away if you turn off autovacuum?


2006-May-22 22:11:09 by anonymous:
  • What sequence of SQL statements do you issue to cause this to occur? It is unknown exactly what all of the the statements are leading up to the corruption. I can send the possible statements via private e-mail.

  • What operating system you are using. Windows XP Professional w/ Service Pack 2.

  • Is the application multi-threaded? Yes.

  • Is the problem reproducible? The corruption happens on occasion -- so far it is not known to be easily reproducable in a finite number of steps.

  • Are you using a precompiled binary or did you compile it yourself? Self-compiled library. When we use the database in our application, it is contained in abstracted classes with concurrency control.

  • Does the problem go away if you turn off autovacuum? We have not seen database corruption if auto_vacuum is off when the database is initially created. Is it possible to turn off auto vacuum after the database tables have been created (no when using pragma auto_vacuum, according to the docs)?


2006-May-22 22:28:46 by anonymous:
Rather than relying on trial and error to reproduce the bug, one technique the bug reporter might try to reproduce the problem is to take a snapshot of the database when it is in a known good state and save it somewhere and then have every process that comes into contact with the database file log every SQLite command (and pragma) complete with millisecond-resolution timestamp and process/thread ID as follows:

  SELECT * FROM WHATEVER;         -- 2006-05-23 14:44:45.237 PID 345 Thread 0
  insert into blah values(3,4,5); -- 2006-05-23 14:50:15.345 PID 345 Thread 0
  update foo set v=5 where y>4;   -- 2006-05-23 15:05:12.930 PID 239 Thread 0

Should the problem happen again, each command could easily be replayed in an appropriate thread in the same order from the last known "good" state, greatly increasing the chances of repeating the bug. If repeating these commands does not lead to database corruption, it is fairly likely that the bug is in your multithreaded code, and not in SQLite.

Perhaps SQLite already has such a command tracing facility already. I don't know.


2006-May-22 22:42:04 by anonymous:

  sqlite3_trace();

It passes all the caller-generated SQL statements to a callback (although it doesn't fill in bindings).

It also outputs a lot of "internal" SQL statements (VACUUM, for example, is a collection of operations on a temp table), but you should be able to recognize that stuff as something your app would never generate.

 
1815 code active 2006 May anonymous Parser 2006 May   3 3 Support of W3C-DTF(ISO8601 subset) is incomplete edit
"Z" of a time zone is ignored.

Reference: http://www.w3.org/TR/NOTE-datetime

  CREATE table test(dt);
  INSERT INTO "test" VALUES('2006-05-20T01:10:20+00:00');
  INSERT INTO "test" VALUES('2006-05-20T01:10:20Z');
  INSERT INTO "test" VALUES('2006-05-20T10:10:20+09:00');
  SELECT datetime(dt) from test;
  2006-05-20 01:10:20

  2006-05-20 01:10:20
 
1797 code active 2006 May anonymous TclLib 2006 May drh 1 1 COPY command doesn't work in tclsqlite 3.3.5 edit
The COPY command doesn't seem to work in the tcl sqlite lib. This same script and datafile works in version 3.2.7.

load ./lib/libtclsqlite[info sharedlibextension] sqlite MEMORY_DB :memory: MEMORY_DB onecolumn "PRAGMA empty_result_callbacks=1" puts [MEMORY_DB version] MEMORY_DB eval "create table xyz (col1,col2)" MEMORY_DB copy ignore win_pol /home/centadm/win_pol4.csv \t MEMORY_DB eval "select * from xyz" sqlite_array { puts "Here in the callback" foreach sqlite_value $sqlite_array(*) { puts "$sqlite_value $sqlite_array($sqlite_value)" } }

The data file win_pol4.csv consists of two columns, tab seperated. DATA1 DATA2

And the output: -bash-3.00$ tclsh test_sqlite.tcl

3.3.5

    while executing
"MEMORY_DB copy ignore win_pol /home/centadm/win_pol4.csv \t"
    (file "test_sqlite.tcl" line 5)
-bash-3.00$ pwd
/home/centadm
-bash-3.00$ ls -l /home/centadm/win_pol4.csv
-rw-r--r--  1 centadm centadm 12 May  5 14:21 /home/centadm/win_pol4.csv
-bash-3.00$ more /home/centadm/win_pol4.csv
DATA1   DATA2

A TCL Error is returned from the copy command, no message tho. I have used catch to capture the command and verified that there is no data going into the table.

Also, PRAGMA empty_result_callbacks=1 still doesn't seem to work in the tcllib. If you catch the COPY command above, you still never see the "Here in the callback" message.

2006-May-05 17:57:42 by anonymous:
Clarification:

The line MEMORY_DB copy ignore win_pol /home/centadm/win_pol4.csv \t

should read

MEMORY_DB copy ignore xyz /home/centadm/win_pol4.csv \t

However the result is the same:

-bash-3.00$ tclsh test_sqlite.tcl 3.3.5

    while executing
"MEMORY_DB copy ignore xyz /home/centadm/win_pol4.csv \t"
    (file "test_sqlite.tcl" line 7)
-bash-3.00$


2006-May-05 19:46:56 by anonymous:
I have narrowed it down to the code here in tclsqlite.c:

    zSql = sqlite3_mprintf("SELECT * FROM '%q'", zTable);
    if( zSql==0 ){
      Tcl_AppendResult(interp, "Error: no such table: ", zTable, 0);
      return TCL_ERROR;
    }
    nByte = strlen(zSql);
    rc = sqlite3_prepare(pDb->db, zSql, 0, &pStmt, 0);
    sqlite3_free(zSql);
    if( rc ){
      Tcl_AppendResult(interp, "Error: ", sqlite3_errmsg(pDb->db), 0);
      nCol = 0;
    }else{
      nCol = sqlite3_column_count(pStmt); <--- RETURNING 0 FOR COLUMN COUNT, HAVE VERIFIED TABLE HAS TWO COLUMNS
    }
    sqlite3_finalize(pStmt);
    if( nCol==0 ) {
      return TCL_ERROR;       <--- NO ERROR MESSAGE RETURNED
    }


2006-May-16 17:51:28 by anonymous:
I found the problem. The first sqlite3_prepare under DB_COPY should have -1 as it's third argument. When this was change from a 0 to -1 the copy command works in tclsqlite.

rc = sqlite3_prepare(pDb->db, zSql,0, &pStmt, 0);

should be

rc = sqlite3_prepare(pDb->db, zSql,-1, &pStmt, 0);


2006-May-16 18:01:11 by anonymous:
There is also another reference (the insert statement) to the prepare statement under DB_COPY that needs to change it's third argument from 0 to -1.


2006-Sep-27 16:24:53 by anonymous:
The same problem is present with version 3.3.7 over here. However, the indicated patch seem to work.
 
1809 code active 2006 May anonymous CodeGen 2006 May   1 3 Huge slowdown/increased memory use when using GROUP BY on big dataset edit
This seemingly nonsensical query is a greatly reduced test case taken from several queries I use with SQLite 3.2.1. The real example joins various huge tables and much more complicated views. I'd like to upgrade beyond SQLite 3.2.1, but this is a showstopper.

It takes 13 seconds to run on SQLite 3.2.1 and uses just 1.2M of memory. With 3.3.5+ from CVS it takes 185 seconds and uses 230M of memory.

  PRAGMA temp_store=MEMORY;

  CREATE TABLE n1(a integer primary key);
  INSERT INTO "n1" VALUES(1);
  INSERT INTO "n1" VALUES(2);
  INSERT INTO "n1" VALUES(3);
  INSERT INTO "n1" VALUES(4);
  INSERT INTO "n1" VALUES(5);
  INSERT INTO "n1" VALUES(6);
  INSERT INTO "n1" VALUES(7);
  INSERT INTO "n1" VALUES(8);
  INSERT INTO "n1" VALUES(9);
  INSERT INTO "n1" VALUES(10);
  INSERT INTO "n1" VALUES(11);
  INSERT INTO "n1" VALUES(12);
  INSERT INTO "n1" VALUES(13);
  INSERT INTO "n1" VALUES(14);
  INSERT INTO "n1" VALUES(15);
  CREATE VIEW vu as select v3.a a, v5.a-v2.a*v7.a b
                      from n1 v1,n1 v2,n1 v3,n1 v4,n1 v5,n1 v6,n1 v7;

  select a a, sum(b) T from vu where a=7 group by a;

It seems that SQLite 3.2.1 had a much more efficient GROUP BY algorithm that discarded unnecessary data as the view was traversed.

2006-May-13 03:01:28 by anonymous:
Seeing as this ticket concerns the GROUP BY statement it would make more sense to have an example like this:

  select a a, sum(b) T from vu where a<4 group by a;

But both queries exhibit the same slowdown and memory increase, in any event.


2006-May-13 15:09:39 by anonymous:
This GROUP BY slowdown/memory increase is not specific to VIEWs. I repeated the test against a comparably sized table with the same results. You'll see this effect for any SELECT operating on a large number of rows using GROUP BY.


2006-May-13 16:44:04 by anonymous:
The slowdown first appears in SQLite 3.2.6 in check-in [2662] .


2006-May-24 13:19:29 by anonymous:
Here's an example to show an actual real-life use of GROUP BY in SQLite <= 3.2.5... Imagine performing mathematical operations on every combination of rows in several large tables for statistical analysis. The GROUP BY algorithm change in 3.2.6 now makes using GROUP BY on huge cross joins not usable for this purpose because it creates an intermediate result set of the product of all cross joins - several times larger than the size of the (already huge) database itself. Indexing is not useful in this case because there is nothing to index by design. All table rows must be traversed.

Older versions of SQLite performed this operation extremely efficiently because grouping took place in the main traversal loop. I would think that the old algorithm could be used, but instead of keeping the intermediate results in memory, an index and a table in temp store could be used.

 
1804 code active 2006 May anonymous Unknown 2006 May   4 3 Inconsistent value type returned by SUM when using a GROUP BY edit
Using a schema with test table:

  CREATE TABLE Tbl1 (Key1 INTEGER, Num1 REAL)

And test data:

  INSERT INTO Tbl1 (Key1,Num1) VALUES (1,5.0)

The query:

  SELECT SUM(Tbl1.Num1) AS Num1Sum FROM Tbl1

Returns a column with the value type correctly reported as FLOAT (2).

However, the query:

  SELECT Tbl1.Key1, SUM(Tbl1.Num1) AS Num1Sum FROM Tbl1 GROUP BY Tbl1.Key1

Returns two columns with value types INT (1) and INT (1).

The SUM function is returning a different value type for these two queries when both should return FLOAT (2).

This problem does not occur when any SUMmed value is not a whole number in which case, both queries return a value type of FLOAT for the SUM column.

I have applied the patch from Check In 3169 (relating to #1726 and #1755) to select.c but this does not resolve the problem.

2006-May-10 09:34:11 by anonymous:
I should have added that this problem was seen in a Windows CE build running on Pocket PC 2003 and built using eMbedded Visual C++ 4.0.


2006-May-10 11:24:47 by anonymous:
I can confirm that exactly the same behaviour is exhibited when built under Windows XP (32-bit).


2006-May-10 12:40:21 by drh:
The answer you are getting back is exactly correct. Why do you care what its datatype is? If you don't like the datatype, cast it.


2006-May-10 13:42:14 by anonymous:
For maximum compatibility with other SQL databases, both

  SELECT SUM(field2) FROM table

and

  SELECT field1, SUM(field2) FROM table GROUP BY field1

should return the same data type for the SUM column. All other databases I have worked with do this. I understand that SQLite uses manifest typing but believe that it should be consistent.

The problem I have is that in my query function (which takes an SQL string and returns a page of results as a 2D array of objects), I don't know whether to use sqlite3_column_double or sqlite3_column_int because I don't know what the calling function requires this column to be returned as. I am currently using the sqlite3_column_decltype call to switch which sqlite3_column_* function I use (and falling back on sqlite3_column_type when the declared type is not known e.g. for aggregate functions like SUM). If the return type of SUM is unpredictable, my calling functions can't assume returned values will be of the same type as the field that is being SUMmed (as is the case with other SQL databases).

If you don't consider this to be a problem with SQLite, then I think my only option will be for calling functions to pass in an array of return types so that I always return objects of the correct type.

 
1799 code active 2006 May anonymous Pager 2006 May   2 3 temp_store=MEMORY slower than FILE for large intermediate result sets edit
(This ticket was split off from #1790 because that ticket was becoming too broad.)

When temp_store=MEMORY it can negatively effect the performance of queries with large intermediate result sets generated from SELECTs of either file-based tables or memory-based tables. This is true when sufficient RAM is available to the SQLite process to completely hold the intermediate results in memory without swapping to disk.

In the example below, "big" is a file-based table in foo.db with 10 million rows. It was created with "create table big(x,y)".

  # unmodified stock SQLite built from May 5 2006 CVS (after check-in [3178])
  # compiled with default settings for SQLITE_DEFAULT_PAGE_SIZE and N_PG_HASH
  $ time ./may5-sqlite/sqlite3 foo.db "PRAGMA temp_store = MEMORY; select x, y from big order by y, x" >/dev/null
  real    13m23.828s
  user    13m18.452s
  sys     0m0.811s

  # SQLite built from May 5 2006 CVS, but compiled with proposed change of
  # SQLITE_DEFAULT_PAGE_SIZE set to 4096, and N_PG_HASH set to 16384
  $ time ./may5-sqlite-hash-opt/sqlite3 foo.db "PRAGMA temp_store = MEMORY; select x, y from big order by y, x" >/dev/null
  real    6m16.031s
  user    6m13.108s
  sys     0m0.811s

Compiling with SQLITE_DEFAULT_PAGE_SIZE = 1024, and N_PG_HASH = 32768 resulted in the same timing as the may5-sqlite-hash-opt test run above.

If temp_store=FILE (with default SQLite values for SQLITE_DEFAULT_PAGE_SIZE and N_PG_HASH), the timings are comparable to temp_store=MEMORY with SQLITE_DEFAULT_PAGE_SIZE=4096, and N_PG_HASH=16384.

Large intermediate results sets can cause SQLite to spend more than half of its CPU time in the function pager_lookup(). By increasing the value of N_PG_HASH and SQLITE_DEFAULT_PAGE_SIZE, the time spent in pager_lookup can be reduced to near zero, thus doubling performance in such cases.

    %   cumulative   self               self     total
   time   seconds   seconds     calls  ms/call  ms/call  name
   51.97    118.31   118.31 119658386     0.00     0.00  pager_lookup
    4.36    128.25     9.94   4000009     0.00     0.06  sqlite3VdbeExec
    3.06    135.21     6.96 315629923     0.00     0.00  parseCellPtr
    3.05    142.16     6.95 171797186     0.00     0.00  sqlite3VdbeRecordCompare
    2.67    148.22     6.07  12000005     0.00     0.01  sqlite3BtreeMoveto
    2.14    153.10     4.88 343594380     0.00     0.00  sqlite3VdbeSerialGet
    1.68    156.93     3.83 171797188     0.00     0.00  sqlite3MemCompare
    1.63    160.65     3.72  77995781     0.00     0.00  sqlite3pager_get
    1.60    164.29     3.65 169734946     0.00     0.00  sqlite3pager_unref
    1.58    167.88     3.59 654100795     0.00     0.00  get2byte
2006-May-07 18:37:50 by anonymous:
Timings on same Windows machine with check-in [3180] applied:

  # FILE
  $ time ./may7-sqlite/sqlite3 foo.db "PRAGMA temp_store = FILE; select x, y from big order by y, x" >/dev/null
  real    5m7.157s
  user    4m19.905s
  sys     0m20.827s

  # MEMORY
  $ time ./may7-sqlite/sqlite3 foo.db "PRAGMA temp_store = MEMORY; select x, y from big order by y, x" >/dev/null
  real    5m12.328s
  user    5m9.781s
  sys     0m0.984s

Much better.

temp_store=MEMORY is now competitive with FILE, although temp_store=FILE (when the OS is able to cache the file entirely in memory) is marginally faster.

I still think the MEMORY time can be reduced further by another 20 seconds judging by the sys time of 20.827s in the FILE test. The MEMORY subsystem of SQLite ought to have an advantage over the FILE subsystem because it does not incur any system call overhead. I'll see if a profile turns up anything obvious.

 
1790 code active 2006 May anonymous Pager 2006 May   3 3 :memory: performance difference between v2 and v3 edit
Please see the following link for details: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg14937.html

Possible fix?

  RCS file: /sqlite/sqlite/src/pager.c,v
  retrieving revision 1.266
  diff -u -r1.266 pager.c
  --- pager.c     7 Apr 2006 13:54:47 -0000       1.266
  +++ pager.c     3 May 2006 19:02:17 -0000
  @@ -1663,7 +1663,7 @@
     pPager->memDb = memDb;
     pPager->readOnly = readOnly;
     /* pPager->needSync = 0; */
  -  pPager->noSync = pPager->tempFile || !useJournal;
  +  pPager->noSync = pPager->tempFile || !pPager->useJournal;
     pPager->fullSync = (pPager->noSync?0:1);
     /* pPager->pFirst = 0; */
     /* pPager->pFirstSynced = 0; */
2006-May-03 19:32:12 by drh:
The suggested change makes no difference in performance when I try it.


2006-May-03 21:41:24 by anonymous:
If transactions are not used, 85% of the time of this memory database benchmark is spent in pager_get_all_dirty_pages().

  Each sample counts as 0.01 seconds.
    %   cumulative   self              self     total
   time   seconds   seconds    calls  ms/call  ms/call  name
   85.25     31.20    31.20   100002     0.31     0.31  pager_get_all_dirty_pages
    1.39     31.71     0.51   100011     0.01     0.20  sqlite3VdbeExec
    1.17     32.14     0.43 10487713     0.00     0.00  parseCellPtr
    0.63     32.37     0.23 12943618     0.00     0.00  sqlite3VdbeSerialGet
    0.61     32.59     0.23  3432951     0.00     0.00  pager_lookup
    0.52     32.78     0.19  4849544     0.00     0.00  sqlite3VdbeRecordCompare
    0.44     32.95     0.16   400006     0.00     0.00  sqlite3BtreeMoveto
    0.41     33.09     0.15  2064924     0.00     0.00  sqlite3pager_get
    0.40     33.24     0.14  6471807     0.00     0.00  sqlite3MemCompare

                  0.06   31.25  100002/100002      sqlite3BtreeCommit [4]
  [5]     85.6    0.06   31.25  100002         sqlite3pager_commit [5]
                 31.20    0.00  100002/100002      pager_get_all_dirty_pages [6]
                  0.05    0.00  389365/389365      clearHistory [65]
  -----------------------------------------------
                 31.20    0.00  100002/100002      sqlite3pager_commit [5]
  [6]     85.2   31.20    0.00  100002         pager_get_all_dirty_pages [6]


2006-May-03 21:51:30 by anonymous:
Stats with BEGIN/COMMIT enabled:

  Each sample counts as 0.01 seconds.
    %   cumulative   self              self     total
   time   seconds   seconds    calls  ms/call  ms/call  name
   11.88      0.34     0.34  4849544     0.00     0.00  sqlite3VdbeRecordCompare
    8.16      0.56     0.23 10487713     0.00     0.00  parseCellPtr
    7.80      0.79     0.22 12943618     0.00     0.00  sqlite3VdbeSerialGet
    6.38      0.96     0.18   100013     0.00     0.03  sqlite3VdbeExec
    4.26      1.08     0.12    29816     0.00     0.02  balance_nonroot
    3.90      1.20     0.11  6471807     0.00     0.00  sqlite3MemCompare
    3.19      1.28     0.09  1964925     0.00     0.00  sqlite3pager_get
    3.19      1.38     0.09   400006     0.00     0.00  sqlite3BtreeMoveto
    2.84      1.46     0.08 19170231     0.00     0.00  get2byte
    2.66      1.53     0.07   700015     0.00     0.00  sqlite3VdbeSerialPut
    2.13      1.59     0.06   600993     0.00     0.00  sqlite3Malloc
    1.77      1.64     0.05  4400155     0.00     0.00  sqlite3pager_unref
    1.77      1.69     0.05  3332952     0.00     0.00  pager_lookup
    1.77      1.74     0.05  1418379     0.00     0.00  decodeFlags
    1.77      1.79     0.05  1332302     0.00     0.00  initPage
    1.60      1.83     0.04  5270826     0.00     0.00  findOverflowCell
    1.42      1.88     0.04 12181181     0.00     0.00  findCell
    1.42      1.92     0.04  4849549     0.00     0.00  fetchPayload
    1.42      1.96     0.04   359548     0.00     0.00  insertCell
    1.24      1.99     0.04  4896877     0.00     0.00  parseCell
    1.06      2.02     0.03  5284245     0.00     0.00  cellSizePtr
    1.06      2.05     0.03  3227291     0.00     0.00  binCollFunc
    1.06      2.08     0.03  2616113     0.00     0.00  _page_ref
    1.06      2.11     0.03  1368027     0.00     0.00  reparentPage
    1.06      2.14     0.03   934205     0.00     0.00  sqlite3GenericMalloc
    1.06      2.17     0.03   300010     0.00     0.00  sqlite3BtreeCursor
    0.89      2.19     0.03  2536689     0.00     0.00  get4byte
    0.89      2.22     0.03  1864920     0.00     0.00  getPage
...
    0.00      2.82     0.00        3     0.00     0.00  pager_get_all_dirty_pages

                  0.00    0.00       3/3           sqlite3BtreeCommit [116]
  [119]    0.0    0.00    0.00       3         sqlite3pager_commit [119]
                  0.00    0.00    6551/6551        clearHistory [118]
                  0.00    0.00       3/3           pager_get_all_dirty_pages [370]
  -----------------------------------------------
                  0.00    0.00       3/3           sqlite3pager_commit [119]
  [370]    0.0    0.00    0.00       3         pager_get_all_dirty_pages [370]


2006-May-03 22:27:35 by anonymous:
with the outer BEGIN/COMMIT disabled, the memory database benchmark stats:

  static PgHdr *pager_get_all_dirty_pages(Pager *pPager){
    // this point is reached 100,002 times
    PgHdr *p, *pList;
    pList = 0;
    for(p=pPager->pAll; p; p=p->pNextAll){
      // this point is reached 322,956,271 times
      if( p->dirty ){
        // this point is reached 389,365 times
        p->pDirty = pList;
        pList = p;
      }
    }
    return pList;
  }


2006-May-04 05:23:08 by anonymous:
This patch makes the test (with transaction) run 7% faster for gcc 3.4.4 with -O2. At -O3, gcc performs the inlining of these functions even without the inline hint, so this patch has no effect.

  RCS file: /sqlite/sqlite/src/btree.c,v
  retrieving revision 1.324
  diff -u -3 -p -r1.324 btree.c
  --- btree.c     4 Apr 2006 01:54:55 -0000       1.324
  +++ btree.c     4 May 2006 05:12:35 -0000
  @@ -439,17 +439,17 @@ static int checkReadLocks(BtShared*,Pgno
   /*
   ** Read or write a two- and four-byte big-endian integer values.
   */
  -static u32 get2byte(unsigned char *p){
  +inline static u32 get2byte(unsigned char *p){
     return (p[0]<<8) | p[1];
   }
  -static u32 get4byte(unsigned char *p){
  +inline static u32 get4byte(unsigned char *p){
     return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
   }
  -static void put2byte(unsigned char *p, u32 v){
  +inline static void put2byte(unsigned char *p, u32 v){
     p[0] = v>>8;
     p[1] = v;
   }
  -static void put4byte(unsigned char *p, u32 v){
  +inline static void put4byte(unsigned char *p, u32 v){
     p[0] = v>>24;
     p[1] = v>>16;
     p[2] = v>>8;


2006-May-04 19:44:57 by anonymous:
I just want to confirm that a file database is faster than a memory database for 3.3.5+. Are these numbers correct? 43,478 inserts/second best case for file for 3.3.5+ and 40,000 inserts/second best case for memory? Even with the OS caching the entire database file entirely in RAM, this finding is quite surprising.

  Test    DB      IDX TX  RC      3.3.5+  3.3.5   2.8.17
  1       mem     n   y   1000000 40000   33333   76923
  2       mem     y   y   1000000 27027   22727   58824
  3       mem     n   n   1000000 35714   5263    83333
  4       mem     y   n   1000000 24390   2778    62500
  5       file    n   y   1000000 43478   35714   40000
  6       file    y   y   1000000 28571   24390   23256
  7       file    n   n   1000    11      11      13
  8       file    y   n   1000    9       10      13

http://www.sqlite.org/cvstrac/attach_get/256/sqlite_speed.txt


2006-May-04 20:19:18 by anonymous:
I'm seeing slightly different results. The memory database using a transaction is (slightly) faster than the file-based database using a transaction.

Timings on 3.3.5+ on Windows XP, gcc 3.4.4 -O3 -fomit-frame-pointer

        IDX  TX   # inserts   wall time  inserts/sec
        ---  ---  ---------  ----------  -----------
  mem   no   no     100,000        4.8s       20,833
  mem   no   yes    100,000        4.3s       23,255
  file  no   yes    100,000        4.7s       21,276
  file  no   no       1,000       99.8s           10

...things get worse for :memory: as you increase the number of inserts, while the file database numbers remain constant:

        IDX  TX   # inserts   wall time  inserts/sec
        ---  ---  ---------  ----------  -----------
  mem   no   yes  1,000,000       48.5s       20,638
  mem   no   yes  2,000,000      118.6s       16,863
  mem   no   yes  4,000,000      364.7s       10,967
  file  no   yes  1,000,000       46.8s       21,354
  file  no   yes  2,000,000       93.8s       21,321
  file  no   yes  4,000,000      187.5s       21,333

Do Linux users get similar results?

Considering I have 512K CPU L2 cache, I wonder if there's some CPU cache effect going on here with the way the :memory: db is allocated.


2006-May-04 21:35:07 by anonymous:
It seems there is some quadratic behavior in pager_lookup (latest CVS). 52% of the time is spent in that function. Profile data from :memory: db, TX on, no IDX, 4 million inserts:

  /*
  ** Find a page in the hash table given its page number.  Return
  ** a pointer to the page or NULL if not found.
  */
  static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){
    PgHdr *p = pPager->aHash[pager_hash(pgno)];
    while( p && p->pgno!=pgno ){
      p = p->pNextHash;
    }
    return p;
  }

    %   cumulative   self               self     total
   time   seconds   seconds     calls  ms/call  ms/call  name
   51.97    118.31   118.31 119658386     0.00     0.00  pager_lookup
    4.36    128.25     9.94   4000009     0.00     0.06  sqlite3VdbeExec
    3.06    135.21     6.96 315629923     0.00     0.00  parseCellPtr
    3.05    142.16     6.95 171797186     0.00     0.00  sqlite3VdbeRecordCompare
    2.67    148.22     6.07  12000005     0.00     0.01  sqlite3BtreeMoveto
    2.14    153.10     4.88 343594380     0.00     0.00  sqlite3VdbeSerialGet
    1.68    156.93     3.83 171797188     0.00     0.00  sqlite3MemCompare
    1.63    160.65     3.72  77995781     0.00     0.00  sqlite3pager_get
    1.60    164.29     3.65 169734946     0.00     0.00  sqlite3pager_unref
    1.58    167.88     3.59 654100795     0.00     0.00  get2byte
    1.30    170.84     2.95    973877     0.00     0.07  balance_nonroot
    1.27    173.74     2.90  56939555     0.00     0.00  initPage
    1.24    176.56     2.83 171797188     0.00     0.00  binCollFunc
    0.93    178.69     2.12 386371475     0.00     0.00  findCell
    0.86    180.65     1.96  96207437     0.00     0.00  pageDestructor
    0.83    182.53     1.89  95976540     0.00     0.00  _page_ref
    0.80    184.36     1.83   2708031     0.00     0.00  assemblePage
    0.80    186.19     1.82  41662605     0.00     0.00  reparentPage
    0.74    187.88     1.70 171797188     0.00     0.00  fetchPayload
    0.73    189.55     1.67  73995778     0.00     0.00  getPage
    0.67    191.07     1.52  59647596     0.00     0.00  decodeFlags
    0.63    192.51     1.44 132945443     0.00     0.00  findOverflowCell
    0.62    193.93     1.41  40148167     0.00     0.00  sqlite3PutVarint
    0.59    195.27     1.34 134687272     0.00     0.00  releasePage
    0.59    196.62     1.34  73764879     0.00     0.00  getAndInitPage
    0.54    197.84     1.22   8000003     0.00     0.02  sqlite3BtreeInsert
    0.52    199.01     1.18  60000030     0.00     0.00  sqlite3VdbeSerialType
    0.52    200.19     1.18  24000011     0.00     0.00  moveToRoot
    0.49    201.30     1.10 179797130     0.00     0.00  getCellInfo
    0.43    202.28     0.98   9882306     0.00     0.00  insertCell
    0.42    203.22     0.94  47288132     0.00     0.00  moveToChild
    0.40    204.15     0.92 173434760     0.00     0.00  parseCell
    0.40    205.06     0.91  95806930     0.00     0.00  get4byte
    0.34    205.83     0.78  41662605     0.00     0.00  sqlite3pager_lookup
    0.33    206.57     0.74 165099370     0.00     0.00  sqlite3MallocFailed
    0.32    207.31     0.73  20000010     0.00     0.00  sqlite3VdbeSerialPut
    0.31    208.02     0.71   8000015     0.00     0.00  sqlite3VdbeHalt
    0.30    208.70     0.68  27052986     0.00     0.00  sqlite3GetVarint
    0.28    209.33     0.63 174637767     0.00     0.00  put2byte
    0.27    209.96     0.62   8000006     0.00     0.00  sqlite3BtreeCursor
    0.26    210.54     0.59   8148152     0.00     0.00  fillInCell
    0.25    211.12     0.57   3385610     0.00     0.01  reparentChildPages
    0.25    211.69     0.57  16000006     0.00     0.00  checkReadLocks
    0.22    212.19     0.51  48000093     0.00     0.00  sqlite3VdbeFreeCursor
    0.22    212.69     0.50 133898861     0.00     0.00  cellSizePtr
    0.22    213.19     0.50  24000010     0.00     0.00  popStack
    0.20    213.65     0.46  50076560     0.00     0.00  sqlite3pager_ref
    0.20    214.10     0.45                              pager_reset
    0.19    214.54     0.44   8000024     0.00     0.00  closeAllCursors
    0.19    214.97     0.42  12000024     0.00     0.00  sqlite3VdbeMemMakeWriteable
    0.18    215.38     0.41  32000052     0.00     0.00  sqlite3VdbeMemSetStr
    0.18    215.78     0.40  11616158     0.00     0.00  allocateSpace
    0.17    216.16     0.39   8000000     0.00     0.00  bindText
    0.16    216.51     0.35  25098767     0.00     0.00  sqlite3MallocRaw
    0.16    216.87     0.35   8000005     0.00     0.00  sqlite3BtreeCloseCursor
    0.15    217.22     0.34  45560699     0.00     0.00  sqlite3FreeX
    0.15    217.56     0.34  36000014     0.00     0.00  sqlite3VarintLen
    0.15    217.90     0.34  36000009     0.00     0.00  sqlite3VdbeMemShallowCopy
    0.14    218.22     0.33  47999969     0.00     0.00  sqlite3VdbeSerialTypeLen
    0.14    218.54     0.33   4000008     0.00     0.00  sqlite3VdbeMakeReady

  -----------------------------------------------
                 41.19    0.00 41662605/119658386     sqlite3pager_lookup [15]
                 77.12    0.00 77995781/119658386     sqlite3pager_get [8]
  [5]     52.0  118.31    0.00 119658386         pager_lookup [5]
  -----------------------------------------------
                  0.19    4.02 4000003/77995781     sqlite3BtreeGetMeta [28]
                  3.53   74.30 73995778/77995781     getPage [9]
  [8]     36.0    3.72   78.31 77995781         sqlite3pager_get [8]
                 77.12    0.00 77995781/119658386     pager_lookup [5]
                  1.12    0.00 56939550/95976540     _page_ref [40]
                  0.03    0.00  230897/230897      page_remove_from_stmt_list [139]
                  0.03    0.00  230897/230897      makeClean [138]
                  0.01    0.00  230897/461804      sqlite3pager_pagecount [150]
                  0.00    0.00  230897/25098767     sqlite3MallocRaw [58]
  -----------------------------------------------
                  1.82   44.94 41662605/41662605     reparentChildPages [13]
  [14]    20.5    1.82   44.94 41662605         reparentPage [14]
                  0.78   41.96 41662605/41662605     sqlite3pager_lookup [15]
                  2.21    0.00 41672966/131189801     sqlite3pager_unref <cycle 2> [31]
                  0.00    0.00   93099/50076560     sqlite3pager_ref [75]

  -----------------------------------------------
                  0.78   41.96 41662605/41662605     reparentPage [14]
  [15]    18.8    0.78   41.96 41662605         sqlite3pager_lookup [15]
                 41.19    0.00 41662605/119658386     pager_lookup [5]
                  0.77    0.00 39036990/95976540     _page_ref [40]
  -----------------------------------------------
                  0.77    0.00 39036990/95976540     sqlite3pager_lookup [15]
                  1.12    0.00 56939550/95976540     sqlite3pager_get [8]
  [40]     0.8    1.89    0.00 95976540         _page_ref [40]


2006-May-04 21:41:37 by anonymous:
I guess increasing this array size is in order:

  PgHdr *aHash[N_PG_HASH];    /* Hash table to map page number to PgHdr */

Too many hash collisions leading to growing linked lists in buckets.

Or perhaps pager_hash has to be replaced with a better hash function.


2006-May-04 22:04:47 by anonymous:
Increasing the size of N_PG_HASH to 8192 seems to help the "4 million insert in a transaction into a memory database" benchmark. It now runs in 203.5 seconds (19656 inserts/sec), as opposed to 364.7 seconds (10967 inserts/sec) previously. This is closer to the 187.5 seconds for the file-based database timing.


2006-May-04 22:13:16 by anonymous:
Increasing N_PG_HASH to 16384 yields 21,052 inserts/second for a 4 million insert single-transaction :memory: database no-index run. This is very close to the file database figure of 21,333 inserts/second.


2006-May-04 22:23:19 by anonymous:
Setting N_PG_HASH to 32768 yields 21,621 inserts/second in the 4M insert s in a single-transaction in a memory db test. This is marginally faster than the file based database timing. Increasing N_PG_HASH has diminishing returns after 16384.


2006-May-05 15:33:31 by anonymous:
You should get the same effect if you increase the page size instead of increasing the size of the hash table. With a larger page size there will be fewer pages to be managed by the hash table. This might be a better solution for many applications. A hash table with 32K entries occupies 128K of RAM, whether it is used or not.


2006-May-05 19:37:51 by anonymous:
128K of RAM when dealing with a 230M :memory: database is not terribly significant.

Here's the timings for various N_PG_HASH and SQLITE_DEFAULT_PAGE_SIZE values for 4 million inserts into a :memory: database in a single transaction:

  N_PG_HASH  SQLITE_DEFAULT_PAGE_SIZE  inserts/sec
  ---------  ------------------------  -----------
      16384                      4096       21,622
      32768                      1024       21,621
       8192                      8192       20,513
       4096                      4096       20,101
       4096                      8192       19,417
       2048                      4096       16,878
       2048                      8192       16,598
       2048                     16384       15,038
       2048                     32768       13,937
       2048                      1024       10,782

So it seems the default values of N_PG_HASH and SQLITE_DEFAULT_PAGE_SIZE should be raised.


2006-May-05 21:34:01 by anonymous:
My point was that most users do not have 230 MB memory databases, so having a large hash table which is fixed at that size may be a burden. 128K for the hash table is a lot if you only have 128K in your memmory database.

I agree that increasing these values would seem to provide a substantial performance increase at little cost. I would suggest using the 4K hash table and the 4K page size. These values are close to the current values. Many users have reported a general speed improvement using a page size of 4K which matches the value used by WinXP (and think many other Os's as well) for disk I/O blocks. These values nearly double the insert rate over the current default values. The fixed size hash table only takes twice the space.


2006-May-06 14:54:32 by anonymous:
Memory page speed should be as fast as possible as it effects the general performance of SQLite. Perhaps a static hash table is not the best data structure here. Don't temp tables and intermediate select results on file-based tables use memory-based pages? Making memory page speed as fast as possible will improve overall SQLite performance whether you are using a file or memory based database. For example, when ordering result sets from a file-based database select this routine is used to generate the code:

  static void pushOntoSorter(
    Parse *pParse,         /* Parser context */
    ExprList *pOrderBy,    /* The ORDER BY clause */
    Select *pSelect        /* The whole SELECT statement */
  ){
    Vdbe *v = pParse->pVdbe;
    sqlite3ExprCodeExprList(pParse, pOrderBy);
    sqlite3VdbeAddOp(v, OP_Sequence, pOrderBy->iECursor, 0);
    sqlite3VdbeAddOp(v, OP_Pull, pOrderBy->nExpr + 1, 0);
    sqlite3VdbeAddOp(v, OP_MakeRecord, pOrderBy->nExpr + 2, 0);
    sqlite3VdbeAddOp(v, OP_IdxInsert, pOrderBy->iECursor, 0);

For those of us who have very complicated nested sub-selects of file-based tables in many queries or even ORDER BYs on huge result sets, speeding up the memory page performance should be a performance win for SQLite in general.


2006-May-06 17:37:32 by anonymous:
The following test demonstrates that this memory page issue can greatly effect the performance of queries against file-based tables if temp_store is set to MEMORY.

"big" is a file-based table in foo.db with 10 million rows. It was created with "create table big(x,y)".

  # unmodified stock SQLite built from May 5 2006 CVS (after check-in [3178])
  # compiled with default settings for SQLITE_DEFAULT_PAGE_SIZE and N_PG_HASH
  $ time ./may5-sqlite/sqlite3 foo.db "PRAGMA temp_store = MEMORY; select x, y from big order by y, x" >/dev/null
  real    13m23.828s
  user    13m18.452s
  sys     0m0.811s

  # SQLite built from May 5 2006 CVS, but compiled with proposed change of
  # SQLITE_DEFAULT_PAGE_SIZE set to 4096, and N_PG_HASH set to 16384
  $ time ./may5-sqlite-hash-opt/sqlite3 foo.db "PRAGMA temp_store = MEMORY; select x, y from big order by y, x" >/dev/null
  real    6m16.031s
  user    6m13.108s
  sys     0m0.811s

This is not even what I would consider to be a big table.

I should mention that compiling with SQLITE_DEFAULT_PAGE_SIZE = 1024, and N_PG_HASH = 32768 resulted in same timing as the may5-sqlite-hash-opt test run above. A pretty good return for an extra 126K.


2006-May-08 04:07:25 by anonymous:
You now get 20,725 inserts/second as of the latest check-in [3180] for 4 million inserts into a :memory: database in a single transaction (using the default SQLITE_DEFAULT_PAGE_SIZE of 1K). This is nearly twice as fast as SQLite prior to the check-in [3180] (10,782 inserts/second). However, it is 4% slower than the best timing prior to [3180] when compiled with N_PG_HASH=32768 and SQLITE_DEFAULT_PAGE_SIZE=1024 which got 21,622 inserts/second (see table above). Increasing the size of SQLITE_DEFAULT_PAGE_SIZE with the latest CVS either has no effect or makes the memory insert benchmark timings slightly worse.
 
1791 code active 2006 May anonymous Unknown 2006 May   1 1 Native threads support for BeOS edit
BeOS ports lacks native thread support. BeOS has very powerful but lightweight threading system, being throughout multithreaded, but it differs from posix-thread ideology, thus our pthreads implementation atm looks more like flacky workaround. Ideally will be to have separate implementation for thread-support, like for Win16/32 versions.

At the moment this problem caused bustage of BeOS Mozilla port, https://bugzilla.mozilla.org/show_bug.cgi?id=330340 nearest workaround might be pthreads usage, inspite its flackyness, but it also causes mess for Mozilla build/configure system, because for other parts in Mozilla we use nspr-threads, which, for BeOS, use native version

2006-Oct-27 05:48:51 by anonymous:
BeOS locking extensions (using native bthreads) have been written and are included in the SQLite3 built into Mozilla Firefox. Is there some process wherein these changes might be incorporated into the SQLite tree?


2006-Oct-27 12:48:11 by anonymous:
Follow the example of OS/2 and propose a patch against the latest SQLite CVS that has proper #ifdef's around BeOS code so it won't break other platforms. Since you're probably the only one interested in this patch, you'll have to do the diffing/merging/testing work yourself.


2006-Nov-07 03:55:36 by anonymous:
Thanks for the advice. We've completed updates to code so it works with the sqlite 3.3.8 patches proposed for Firefox. Current implementation has a parallel os-specific file (os_beos.c). However, with the latest round of locking enhancements to os_unix.c, we're now wondering if it makes more sense to simply enhance this file to support BeOS locking. (yes, we. surprisingly, there is more than one BeOS user left on the planet.) :)
 
1783 code active 2006 Apr anonymous Unknown 2006 Apr   3 2 insert times increase with growing table size (when indexed) edit
The time needed to insert (or update) entries in a table with an index on one of the fields increases with the size of the table. For large databases inserts become very slow (which I suppose is likely the problem in ticket #1547). sqlite2 does not have this scaling problem on inserts. (Some of our queries do not scale on sqlite2 however, making its use also impossible.)

  ----- example code -----
  package require dbi
  package require dbi_sqlite3
  dbi_sqlite3 db
  db create /tmp/test.db
  db open /tmp/test.db
  db exec {create table "region" (
  	"id" integer not null primary key,
  	"start" integer,
  	"end" integer
  )}
  db exec {create index "region_index" on "region"("start")}
  set num 1
  for {set j 1} {$j < 20} {incr j} {
  	puts [lindex [time {
  		db begin
  		for {set i 1} {$i < 100000} {incr i} {
  			set s [expr {round(rand()*1000000)}]
  			set e [expr {round(rand()*1000000)}]
  			db exec {
  				insert into "region"("id","start","end")
  				values(?,?,?)
  			} $num $s $e
  			incr num
  		}
  		db commit
  	}] 0]
  }

----- timings -----

5712186 6621934 9492997 13234978 14881322 19119044 25296162 26670866 35378986 35877042 44383517 54576510 53317621 63516664 76587973 73791188 88460462 101650099

 
1633 code active 2006 Jan anonymous VDBE 2006 Apr   3 3 sqlite3_step returns SQLITE_ERROR when interrupted edit
When interrupting an execution of sqlite3_step, sqlite3_step will return a generic SQLITE_ERROR instead of the SQLITE_INTERRUPT error code I'd expect. This is because although in vdbe.c:4427 the SQLITE_INTERRUPT result code is set to the internal 'rc' field of the database connection, a plain SQLITE_ERROR is returned:

   vdbe_halt:
     if( rc ){
       p->rc = rc;
       rc = SQLITE_ERROR;
     }else{
       rc = SQLITE_DONE;
     }

The SQLITE_ERROR returned is then also stored as the errCode inside the db handle by the calling function, so there's no way to find out whether the error occured due to an interrupt or some other error (since sqlite3_error() will return SQLITE_ERROR as well).

I'd like to ignore interrupt errors where I call sqlite3_step, since those are not of importance to my users, but with the current scheme, I have no way of finding out whether an sqlite3_interrupt causes the error or whether it's a serious error...

You get a more specific error-code (for example SQLITE_INTERRUPT) when you call sqlite3_finalize() or sqlite3_reset() on the statement.

There shouldn't be any reason not to call one of these functions after sqlite3_step() returns SQLITE_ERROR, as you cannot do anything else with the statement handle at that point anyway.


2006-Apr-26 11:58:01 by anonymous:
Well, I get SQLITE_ERROR in sqlite3_finalize(), too after I interrupted the query, so I can't even find out at finalize time.

However, it might be interesting to see the real error when stepping: in our C++ wrapper, the finalize occurs very late and we usually raise database exceptions when errors occur while stepping. I would really like to raise the proper exception (some sqlite_execution_interrupted exception) when the query was interrupted instead of raising some generic "sql error" exception...


2006-Apr-26 12:24:02 by anonymous:
Sorry, my previous comment was a bit too quick: I have to admit that most of the time, I do in fact get SQLITE_INTERRUPTED as result from sqlite3_finalize, but every now and then, I do get SQL_ERROR. Maybe this happens when I try to interrupt just before the actual statement execution has started or when execution has just finished?


2006-Jul-26 13:26:19 by anonymous:
This might, of course, be related to my incorrect usage of sqlite3_interrupt from a different thread (Ticket #1897) ?
 
1782 code active 2006 Apr anonymous Unknown 2006 Apr   1 1 journal file exclusion edit
I have a long running process which opens a connection to a sqlite3 database, let's called it a.rdb. The connection is never closed during the life time of the process, and it's set to auto commit mode. Now, if I delete a.rdb, and re-create it again(the long running process is still holding a fd to the deleted file at this point), the long running process is still creating a.rdb-journal from time to time. To make it worse, if at that time, I use the sqlite3 command line to modify the database when the file a.rdb-journal exists, the file in a.rdb-journal is also played back into the new a.rdb file, which doesn't seem to be the correct behavior.

Is it the intended design?

Thanks, John

 
1777 code active 2006 Apr anonymous   2006 Apr   2 4 Cygwin should be OS_UNIX target, not OS_WIN edit
Cygwin, a UNIX emulation layer on Windows, should be an OS_UNIX target (not an OS_WIN target) in order to use the UNIX filesystem calls and paths. The Cygwin GNU debugger gdb will not work correctly with a Cygwin sqlite3 built with -DOS_WIN=1 (trust me - I wasted an hour on determining why database files cannot open under cygwin/gdb).

MinGW, on the other hand should remain an OS_WIN target.

All references to cygwin should be removed from os.h, and configure.ac should have something like this pseudo-code:

  if test "$CYGWIN" = "yes"; then
    OS_UNIX=1
    OS_WIN=0
    tclsubdir=unix
    TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=1"
  elif test "$TARGET_EXEEXT" = ".exe"; then
    OS_UNIX=0
    OS_WIN=1
    tclsubdir=win
    TARGET_CFLAGS="$TARGET_CFLAGS -DOS_WIN=1"
  else
    OS_UNIX=1
    OS_WIN=0
    tclsubdir=unix
    TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=1"
  fi

Once sqlite3 thinks it is an OS_UNIX library under cygwin, all the strange problems I've been experiencing go away.

2006-Apr-19 12:07:34 by anonymous:
Although gdb sqlite3.exe debugging is functional and cygwin file paths work better with OS_UNIX=1, it seems that some cygwin file locking primitives only work with OS_WIN=1.
 
1775 code active 2006 Apr anonymous Unknown 2006 Apr   1 1 strftime() not working in Windows Mobile 2005 edit
The strftime() is not working in windows mobile 2005 pocket pc. I am using the beta version of visual studio 2005.
2006-Apr-17 13:10:20 by anonymous:
Is it a compile/link problem or a runtime problem?


2006-Apr-18 07:26:08 by anonymous:
It's a runtime problem. I am not able to get the dates formated using strftime(). datetime(), date() and time() are working properly.
 
1754 code active 2006 Apr anonymous Pager 2006 Apr anonymous 2 2 Version 3.3.5 error if SQLITE_OMIT_MEMORYDB is defined edit
My solution is to move the following code to de line the the syncJournal is "forwarded" at line 1809.

#ifndef SQLITE_OMIT_MEMORYDB
/*
** Clear a PgHistory block
*/
static void clearHistory(PgHistory *pHist){
  sqliteFree(pHist->pOrig);
  sqliteFree(pHist->pStmt);
  pHist->pOrig = 0;
  pHist->pStmt = 0;
}
#else
#define clearHistory(x)
#endif
 
1743 code active 2006 Mar anonymous Parser 2006 Mar   3 3 A very very deep IN statement failure edit
Ok the problem is simple. I need to create a VERY VERY large IN statement. The problem is SQLite seems to have a limit on either query length or depth of an IN statement. Here is my example

See attached 1

That would be a 2 levels deep In statement. I can only get up to 9 with SQLite but I need to get to 20. Since it works for 9 I can only assume that my 10 is correct even though the error is a syntax error. Below is the code that creates the select statement.

See attached 4

Attachment 2 and 3 show a 9 and 10 level respectively.

Thanks for your help

2006-Mar-30 21:30:51 by anonymous:

  Select "Wow !!" from "Wow !!"
  :-)
  Maybe VIEWs could help ??


2006-Mar-30 21:37:50 by anonymous:
This may be a work around for your problem. From looking at your sample SQL:

    SELECT * FROM xs
    where classname like '%Bonus_Pay_Weight_Entry%'
    or classname in
        (
        select parentname from xs
        where classname in
            (
            select parentname from xs
            where classname in
                (
                select parentname from xs
                where classname like '%Bonus_Pay_Weight_Entry%'
                )
            )
        )
    or classname in
        (
        select parentname from xs
        where classname in
            (
            select parentname from xs
            where classname like '%Bonus_Pay_Weight_Entry%'
            )
        )
    or classname in
        (
        select parentname from xs
        where classname like '%Bonus_Pay_Weight_Entry%'
        )
    ;

It seems you are trying to find all the parent classes of all the classes with this magic string in their name. If so, I think there is another way to do this. Instead of using a C program to build a huge SQL statement and then collect the results, use a different C program to execute a series of small SQL commands that generate the same result set.

The following series of SQL statements should generate the same set of results.

    create temp table xt as
        select classname from xs
        where classname like '%Bonus_Pay_Weight_Entry%';
    insert into xt select parentname from xs where classname in xt and parentname not in xt;
    select changes();
    insert into xt select parentname from xs where classname in xt and parentname not in xt;
    select changes();
    insert into xt select parentname from xs where classname in xt and parentname not in xt;
    select changes();
    ... repeat until changes returns zero
    select * from xs where classname in xt;
    drop table xt;

This can be execute by code that looks something like the following pseudo-C code.

    string sql;
    sql = "create temp table xt as select classname from xs where classname like '%Bonus_Pay_Weight_Entry%'";
    sqlite3_exec(db, sql);

    sql = "insert into xt select parentname from xs where classname in xt and parentname not in xt";
    sqlite3_stmt* extend = sqlite3_prepare(db, sql);

    sql = "select changes()"
    sqlite3_stmt* check = sqlite3_prepare(db, sql);

    int changes = 0;
    do {
        sqlite3_step(extend);
        sqlite3_reset(extend);
        sqlite3_step(check);
        changes = sqlite3_column_int(check, 0);
        sqlite3_reset(check);
    } while (changes > 0);

    sqlite3_finalize(extend);
    sqlite3_finalize(check);

    sql = "select * from xs where classname in xt";
    sqlite3_stmt* get = sqlite3_prepare(db, sql);

    int rc;
    do {
        rc = sqlite3_step(get);
        if (rc == SQLITE_DONE) break;
        // process a result row
    } while (1);

    sqlite3_finalize(get);

    sql = "drop table xt";
    sqlite3_exec(db, sql);


2006-Apr-05 17:25:30 by anonymous:
Where did you find the select changes(); function? I would like to find all the functions that SQLite has and their uses.

(and no I dont want the C API. I found that)


2006-Apr-05 18:53:08 by anonymous:
There is no complete listing of the functions in the documentation that I am aware of. Most are documented on this page http://www.sqlite.org/lang_expr.html but some are missing.

The ultimate list of the predefined functions is the source file func.c which implements all the functions. You can view it here http://www.sqlite.org/cvstrac/rlog?f=sqlite/src/func.c

 
1742 code active 2006 Mar anonymous Unknown 2006 Mar drh 2 3 ORDER BY on more than one column causes a big slowdown edit
Put simply, any query which contains an ORDER BY clause that sorts on more than one column incurs a strange slowdown.

Running SQLite 3.3.4 on WindowsXPSP2 and on OS X 1.4.5, the behavior is similar; if the ORDER BY clause contains one column, the query is very fast; on two or more columns, it is terribly slow.

2006-Mar-28 23:58:15 by anonymous:
Also worth noting that this behavior seems to start with SQLite 3.3.x; earlier versions of SQLite handle multiple ORDER BY columns much faster.


2006-Mar-29 01:22:11 by anonymous:
Note also that this behavior is being exhibited when sorting on indexed columns


2006-Mar-29 01:50:38 by drh:
Some examples would be helpful.


2006-Mar-29 18:11:43 by anonymous:
Most definitely! I will attach a sample 3.3.4 database dump, that displays this behavior.
 
1735 code active 2006 Mar anonymous Unknown 2006 Mar   1 3 Encoding problem edit
I use latin2 (iso-8859-2) encoding in my system. When operating on sqlite 3 I can insert data that contains national characters into a database (for example using sqlite3 console) and then when I select them back, I am given the proper result. But when I use sqlite driver from Qt4, which uses sqlite3_column_text16() to fetch data from the database, I don't get the expected result (meaning the conversion to UTF-16 probably messed things up). Now the problem can be in one of two places -- either sqlite3 console application doesn't use a proper conversion to convert from my locale encoding into its internal encoding or the database internal mechanisms mess some things up.

In short: sqlite3(somelatin2string) ==> SQLITE DMBS ==> sqlite3_column_text16() ==> garbage != somelatin2string

At first I thought this was Qt problem as data stored through sqlite console and retrieved from it was correct and data stored by Qt and retrieved by Qt was also correct whereas data stored by Qt and retrieved by sqlite3 console or stored by the console and retrieved by Qt was not correct. I contacted Qt support guys @ trolltech and talked about it and it looks like Qt side if fine -- it expects a UTF-16 encoded data (because it uses the function mentioned earlier) and it converts from UTF-16 to whatever encoding it needs (and vice versa). So the error is probably somewhere in the line between the console and the database itself or in the database internally. It could be that sqlite3 expects UTF-8 (or UTF-16) encoded data on input but is given ISO-8859-2 data (entered manually by me at the console).

2006-Mar-27 16:36:26 by anonymous:
The console app doesn't convert from your local code page to UTF-8 (or UTF-16).


2006-Mar-27 22:45:21 by anonymous:
It probably should, in the documentation of sqlite a suggested method of converting databases between versions 2 and 3 is:

  sqlite OLD.DB .dump | sqlite3 NEW.DB

Now sqlite outputs the data in "local" format and if sqlite3 doesn't encode it properly, such a conversion will be invalid because the incoming data won't be utf encoded.

A solution could be to do:

  sqlite OLD.DB .dump | iconv -f <something> -t UTF-8 | sqlite3 NEW.DB

But it is the console which should be responsible for the conversion. Also because otherwise using sqlite3 console on a non-utf system with a perfectly well UTF-8 encoded database will result in improper output too.

 
1733 code active 2006 Mar anonymous VDBE 2006 Mar drh 4 3 Unaligned Access on ia64: aggregate_context ptr isn't 16-bytes aligned edit
There is a problem on ia64 with pointer returned by sqlite3_aggregate_context function. If the size requested is less than NBFS bytes, then the pointer returned is 8 bytes aligned while every pointer returned by allocator function must be 16-bytes aligned (the specification requires that the pointer is aligned so that every basic typed can be stored there and long double is 16 bytes on Itanium).

So if a user allocates, say, 24 bytes for his context, and the first member in his context happens to be a long double, he will get unaligned access exception. This will lead to performance hit on Linux and to crash on HP-UX, since no default SIGBUS handler is present on HP-UX (IIRC).

2006-Mar-27 10:37:37 by anonymous:
Additional details can be found in this mailing list thread: http://thread.gmane.org/gmane.comp.db.sqlite.general/18144
 
1700 code active 2006 Mar anonymous Parser 2006 Mar   2 2 Handling column names for aliased queries is broken edit
The following query does not work,

SELECT DISTINCT * FROM (SELECT t1.ID FROM GR_ADDRESS t1 WHERE t1.ID > 1 UNION ALL SELECT t1.ID FROM PERSON t1) t1 ORDER BY t1.ID DESC

but this one does,

SELECT DISTINCT * FROM (SELECT t1.ID FROM GR_ADDRESS t1 WHERE t1.ID > 1 UNION ALL SELECT t1.ID FROM PERSON t1 ORDER BY t1.ID DESC)

Dennis Cote responded with:

I think you have found another example of the problems SQLite has handling columns names.

The following log first shows what SQLite thinks the column name is for the query without the order by clause (i.e. t1.ID). Then we try to order by that column name, with or without the table alias. Both cases result in an error. Finally there is a work around that you could use that applies an alias to the selected columns in the two tables that are combined by the union operation.

		SQLite version 3.3.2
		Enter ".help" for instructions
		sqlite> create table GR_ADDRESS(id, data);
		sqlite> create table PERSON(id, data);
		sqlite> .mode column
		sqlite> .header on
		sqlite> insert into gr_address values(1, 10);
		sqlite> insert into person values(2, 20);
		sqlite> insert into gr_address values(3, 30);
		sqlite> SELECT DISTINCT *
		   ...> FROM
		   ...>     (SELECT t1.ID
		   ...>     FROM GR_ADDRESS t1
		   ...>     WHERE t1.ID > 1
		   ...> UNION ALL
		   ...>     SELECT t1.ID
		   ...>     FROM PERSON t1)
		   ...> t1;
		t1.ID
		----------
		3
		2
		sqlite> SELECT DISTINCT *
		   ...> FROM
		   ...>     (SELECT t1.ID
		   ...>     FROM GR_ADDRESS t1
		   ...>     WHERE t1.ID > 1
		   ...> UNION ALL
		   ...>     SELECT t1.ID
		   ...>     FROM PERSON t1)
		   ...> t1 ORDER BY t1.ID DESC;
		SQL error: no such column: t1.ID
		sqlite> SELECT DISTINCT *
		   ...> FROM
		   ...>     (SELECT t1.ID
		   ...>     FROM GR_ADDRESS t1
		   ...>     WHERE t1.ID > 1
		   ...> UNION ALL
		   ...>     SELECT t1.ID
		   ...>     FROM PERSON t1)
		   ...> t1 ORDER BY ID DESC;
		SQL error: no such column: ID
		sqlite> SELECT DISTINCT *
		   ...> FROM
		   ...>     (SELECT t1.ID as ID
		   ...>     FROM GR_ADDRESS t1
		   ...>     WHERE t1.ID > 1
		   ...> UNION ALL
		   ...>     SELECT t1.ID as ID
		   ...>     FROM PERSON t1)
		   ...> t1 ORDER BY t1.ID DESC;
		ID
		----------
		3
		2

You may also be interested in the discussion of a similar problem under ticket #1688.

 
1719 code active 2006 Mar anonymous   2006 Mar   4 4 Solaris 8(SQL: bus error while creating temporary file edit
The problem occours since we using gcc 4.0.2 (with gcc 3.4.3 there was no problem). This problem has the same root as Ticket #1584, with the same solution (but only needed for SQLite <= 2.8.17):

  --- src/os.c.orig   2006-03-17 14:02:53.759531000 +0100
  +++ src/os.c        2006-03-17 14:03:18.529535000 +0100
  @@ -1652,7 +1652,9 @@
   #if OS_UNIX && !defined(SQLITE_TEST)
     {
       int pid;
  -    time((time_t*)zBuf);
  +    time_t t;
  +    time(&t);
  +    memcpy(zBuf, &t, sizeof(t));
       pid = getpid();
       memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid));
     }
 
1714 code active 2006 Mar anonymous CodeGen 2006 Mar   4 4 Slow query when tables in 2 different files edit
This slow query seems to be sped up by using an explicit CROSS JOIN. ANALYZE apparently does not help. The tables span 2 different database files.

Taken from the SQLite mailing list:

  -- table1.schema (file 1)

  ATTACH DATABASE './table1.db' AS t1 ;

  CREATE TABLE t1.table1
  (
          i_id INT4,
          b_id INT4,
          d_id INT4,
          c_id INT2,
          data_in REAL,
          data_out REAL
  );
  CREATE INDEX t1.ix_table1_b_id ON table1( b_id );

  DETACH DATABASE t1 ;

  -- table2.schema (file 2)

  ATTACH DATABASE './table2.db' AS t2 ;

  CREATE TABLE t2.table2
  (
          d_id INT4 PRIMARY KEY,
          r_id INT2,
          m_id INT2,
          i TEXT,
          ct TEXT,
          cc TEXT,
          type TEXT,
          notes TEXT
  );

  DETACH DATABASE t2 ;

  -- the slow query (does not use indexes on both tables?)

  select    t1.b_id, t1.c_id, t2.r_id, t2.m_id,
            sum( t1.data_in ) as data_in,
            sum( t1.data_out ) as data_out
  from      table1 t1
  join      table2 t2
  on        t2.d_id = t1.d_id and t1.b_id >= 100 and t1.b_id < 200
  group by  t1.b_id, t1.c_id, t2.m_id, t2.r_id;

  -- the fast query (seems to use both tables' indices)

  select    t1.b_id, t1.c_id, t2.r_id, t2.m_id,
            sum( t1.data_in ) as data_in,
            sum( t1.data_out ) as data_out
  from        table1 t1
  cross join  table2 t2
  where     t2.d_id = t1.d_id and t1.b_id >= 100 and t1.b_id < 200
  group by  t1.b_id, t1.c_id, t2.m_id, t2.r_id;

More information can be found here: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg13648.html

 
1637 code active 2006 Jan anonymous Parser 2006 Jan   4 4 Multiple JOIN USING() doesn't work. edit
CREATE TABLE T1(T1Id, Name);
INSERT INTO T1(T1Id, Name) VALUES (0,"titi");
INSERT INTO T1(T1Id, Name) VALUES (1,"toto");
INSERT INTO T1(T1Id, Name) VALUES (2,"tutu");
INSERT INTO T1(T1Id, Name) VALUES (3,"hat");
INSERT INTO T1(T1Id, Name) VALUES (4,"socks");

CREATE TABLE T2(T2Id, Name);
INSERT INTO T2(T2Id, Name) VALUES(0,"Black");
INSERT INTO T2(T2Id, Name) VALUES(1,"Red");
INSERT INTO T2(T2Id, Name) VALUES(2,"Blue");
INSERT INTO T2(T2Id, Name) VALUES(3,"Green");
INSERT INTO T2(T2Id, Name) VALUES(4,"Yellow");
INSERT INTO T2(T2Id, Name) VALUES(5,"Brown");
INSERT INTO T2(T2Id, Name) VALUES(6,"White");

CREATE TABLE T3(T3Id,T1Id,T2Id,Number);
INSERT INTO T3(T3Id,T1Id,T2Id,Number) VALUES (1,4,0,5);
INSERT INTO T3(T3Id,T1Id,T2Id,Number) VALUES (2,4,1,4);
INSERT INTO T3(T3Id,T1Id,T2Id,Number) VALUES (3,4,2,3);
INSERT INTO T3(T3Id,T1Id,T2Id,Number) VALUES (4,4,3,2);
INSERT INTO T3(T3Id,T1Id,T2Id,Number) VALUES (5,4,4,1);
INSERT INTO T3(T3Id,T1Id,T2Id,Number) VALUES (6,4,5,0);
INSERT INTO T3(T3Id,T1Id,T2Id,Number) VALUES (7,3,0,10);

SELECT main.Number AS Number,
	prod.Name AS product,
	col.Name AS color,
	Main.T3Id AS Id
FROM T3 AS main
	LEFT JOIN T1 AS prod USING(T1Id)
	LEFT JOIN T2 AS col USING(T2Id);
The second USING doesn't work.
2006-Jan-23 16:03:17 by drh:
SQLite only looks for columns to satisfy the USING clause in the two tables immediately tot he left and right of the join. In the example above, it is trying to resolve "USING(t2id)" by looking for columns t1.t2id and t2.t2id.


2006-Jan-23 23:12:32 by anonymous:
I'm not sure if you are saying that is the way SQLite should work, or just explaining the source of the error.

I believe that JOINS are supposed to combine two tables to produce a third table in a left associative manner. The sample query should join T3 and T1 using T1Id to produce an intermediate table, lets call it simply T. Then T should be joined with T2 using T2Id to produce the final result table.

As shown below, T does in fact have a column named T2Id, and this column should be used for the second join.

  sqlite> CREATE table t AS SELECT *
     ...> FROM T3 AS main
     ...>         LEFT JOIN T1 AS prod USING(T1Id);
  sqlite>
  sqlite> PRAGMA table_info(t);
  0|T3Id|numeric|0||0
  1|T1Id|numeric|0||0
  2|T2Id|numeric|0||0
  3|Number|numeric|0||0
  4|Name|numeric|0||0
  sqlite>
  sqlite> SELECT T2ID from t;
  0
  1
  2
  3
  4
  5
  0

One area where SQLite may have a standards compliance problem is with the name of the result set columns with column name joins (i.e. joins with a USING() clause). The standard says that the result set column that was used to join the two tables can not have a qualifier. That means it is NOT the column from either of the two input tables, and can't be qualified using either table name. The USING clause "projects out" the columns from both of the input tables and replaces them with a single column with the same name. The two columns could have different types for example, and the result set column could be yet another type.

The first two otuput columns below should generate an error. Only the third is legal according to the SQL standard.

  sqlite> SELECT T3.T2Id, T2.T2Id, T2Id from T3 LEFT JOIN T2 USING(T2Id);
  T2Id|T2Id|T2Id
  0|0|0
  1|1|1
  2|2|2
  3|3|3
  4|4|4
  5|5|5
  0|0|0

The type differences between the different columns are displayed in the following example. In one table the values of column a are integers and in the other they are text. The type of the result column depends upon the order of the tables in the join.

  sqlite> select a from tt1 join tt2 using(a);
  a
  1
  2
  sqlite> select typeof(a) from tt1 join tt2 using(a);
  typeof(a)
  integer
  integer
  sqlite> select typeof(a), typeof(tt1.a), typeof(tt2.a) from tt1 join tt2 using(a);
  typeof(a)|typeof(tt1.a)|typeof(tt2.a)
  integer|integer|text
  integer|integer|text
  sqlite> select * from tt1 join tt2 using(a);
  a|b|c
  1|1|-1
  2|4|-2
  sqlite> select typeof(a), typeof(tt1.a), typeof(tt2.a) from tt2 join tt1 using(a);
  typeof(a)|typeof(tt1.a)|typeof(tt2.a)
  text|integer|text
  text|integer|text

The same rules also apply to NATURAL joins. The result columns cannot legally be qualified by either table name.


2006-Jan-23 23:45:04 by drh:
My previous remark is describe what SQLite does. You are probably right in pointing out that what it currently does is not correct and ought to be fixed. I merely observet that SQLite has never worked that way and has (up until now) caused no serious concern. So, I'm not going to consider this a high-priority bug. I will get to it as I am able. But I need to get 3.3.x out the door first.
 
1622 code active 2006 Jan danielk1977   2006 Jan   1 1 Compiling with OMIT_PRAGMA causes an error in the test suite edit
Compiling with OMIT_PRAGMA causes an error in the test suite. The error is a Tcl level error thrown by a [db eval] command when it encounters the unknown SQL keyword "PRAGMA".
 
1621 code active 2006 Jan danielk1977   2006 Jan   5 5 Compiling with OMIT_FLOATING_POINT causes a segfault in the test suite edit
Compiling with OMIT_FLOATING_POINT causes a segfault in the test suite.
 
1573 code active 2005 Dec anonymous Shell 2005 Dec   3 3 Bad CSV output when data contains double quotes edit
SQLite 3.2.7 emits invalid CSV when a field value contains double quotes (or at least, it's CSV that Gnumeric cannot parse). Here's an example:

  sqlite> create table foo (a text, b text);
  sqlite> insert into foo values ("hello", "world");
  sqlite> insert into foo values ("mr.", "o'reilly");
  sqlite> insert into foo values ('12" EP', 'blah');
  sqlite> .mode csv
  sqlite> .output foo.csv
  sqlite> select * from foo;

Here's what foo.csv looks like:

  $ cat foo.csv
  "hello","world"
  "mr.","o'reilly"
  "12" EP","blah"

Note the ambiguous quoting on line 3. If I load this file into Gnumeric, it parses the first two lines just fine. But the last line confuses it.

It appears that doubling the quote works -- at least for Gnumeric's CSV parser. That is, if I edit foo.csv to

  "hello","world"
  "mr.","o'reilly"
  "12"" EP","blah"

then it's OK.

This is basically a duplicate of [1312] and related shell problem reports, though it provides a better test case than the previous reports.
 
1546 code active 2005 Nov anonymous   2005 Nov   1 1 Creating unique index on non-unique column leads to corr. on SQLite2 edit
Like ticket #1115, SQLite version 2 suffer too from the bug where :

  BEGIN;
  CREATE TABLE t1(a);
  INSERT INTO t1 VALUES(1);
  INSERT INTO t1 VALUES(1);
  CREATE UNIQUE INDEX i1 ON t1(a);
  COMMIT;
  PRAGMA integrity_check

fails.

When "CREATE UNIQUE INDEX" fails within a transaction, (and within a transaction only), the index is still created.

 
1542 code active 2005 Nov anonymous Unknown 2005 Nov   2 4 wrong field names in views with quoted table name qualifiers edit
SQLite returns wrong field names in views using quoted table name qualifiers.

Examples:

The following statement

create view custview as select [customer].company from customer

creates a view with one field: customer (should be company)

The next one:

create view custview as select [customer].company, [customer].address from customer

creates a view with two fields: customer and customer:1 (should be company and address)

Reproduced with version 3.2.7 on Win32.

 
1541 code active 2005 Nov anonymous Unknown 2005 Nov   1 1 Ticket #924 not fixed in the 2.8 branch edit
Ticket 924: http://www.sqlite.org/cvstrac/tktview?tn=924

This problem seams to have been fixed on the 3.2 branch but is still in the 2.8.16

 
1522 code active 2005 Nov anonymous Unknown 2005 Nov   1 3 Make test fails in manydb 1.82-3.299 mac os x 10.4.3 ppc edit
OS: Mac OS X 10.4.3 ppc

Compiler: powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5247)

While running "make test" from a cvs checkout on Sun Nov 13 19:01:54 PST 2005, I get these errors:

653 errors out of 23390 tests

Failures on these tests: manydb-1.82 manydb-1.83 manydb-1.84 ................. manydb-3.296 manydb-3.297 manydb-3.298 manydb-3.299

2005-Nov-15 01:13:13 by drh:
These failures likely result from running out of file descriptors. The manydb tests need about 1000 file descriptors. Linux provides this many (on most distributions). But perhaps Mac OS X does not. Does anybody know?
 
1521 code active 2005 Nov anonymous Unknown 2005 Nov   3 2 ORDER BY sorts incorrectly with aliased fields edit
When executing a SELECT call and aliasing fields that already exist in the table, sorting does not work correctly on the aliased fields.

Here's a quick example:

  CREATE TABLE sort_table (name, name_alt);
  INSERT INTO sort_table (name, name_alt) VALUES ("a", "z");
  INSERT INTO sort_table (name, name_alt) VALUES ("b", "y");
  INSERT INTO sort_table (name, name_alt) VALUES ("c", "x");

This simple query works correctly:

  sqlite> SELECT name_alt FROM sort_table ORDER BY name_alt;
  name_alt
  x
  y
  z

Aliasing name_alt as name throws off the sorter:

  sqlite> SELECT name_alt AS name FROM sort_table ORDER BY name;
  name
  z
  y
  x

The results should be the same as in the first query and it works correctly in MySql. I'm trying to use this kind of query for a translation library. The only workaround I can think of is something like this:

  SELECT name_alt AS name, name_alt FROM sort_table ORDER BY name_alt;

This works, but is not ideal.

2005-Nov-12 17:28:20 by anonymous:
In cases like this you can use ordinal numbers as arguments to ORDER BY; replacing the last 'name' with '1' (no quotes) returns the correct results.


2005-Nov-12 19:20:24 by anonymous:
Yes, this does indeed work, and it makes for a simpler hack than my original one. This is still not the correct behavior though, and should be fixed so that a hack is not required at all.


2005-Nov-13 15:36:22 by anonymous:
Citing one database's behavior is interesting, but can you quote the paragraph in the SQL standard that shows the behavior you seek is correct?


2005-Nov-13 17:19:37 by anonymous:
Whether or not its in the SQL standard is somewhat irrelevent if you keep up to date with the mailing list. "Expected behavior", "how do all the other databases do it" and "makes sense" are often the governing factors in implementing changes to SQLite. In this case, proposing this change meets all 3 criteria.


2005-Nov-13 18:03:49 by anonymous:
SQLite does it one way. MySQL does it another way. Both behaviors could be argued to be correct. The SQL standard is certainly a good way to decide on a valid behavior. Besides, the way MySQL does it is not necessarily representative of "all other databases". At least list the output of a few major databases before making such an assumption.


2005-Nov-13 20:22:40 by anonymous:
I'm the guy who originally filed the ticket. I'm just an average guy, without the time or resources to run this on lots of different databases. The sql standards are not free, and I don't have a copy of any of them. I've also had very little luck finding information on the internet.

All that said, I believe it would be difficult to argue that the current behavior in SQLite is correct. In all other cases, the aliased column is accepted as an ORDER BY field. If I didn't want to override the original field for the purposes of the query, why would I explicitly do so? On the other hand, there are good reasons for wanting to explicitly override the column, for goals that cannot otherwise be achieved without hacks. If I didn't want to override the field, I could get the desired effect by doing nothing.


2005-Nov-14 00:08:30 by anonymous:
This should really be taken to the mailing list; there are people there with access to many different databases and some of them own copies of the SQL standard. This issue of name resolution also touches on the concerns expressed in #1111, #1213, and #1228.


2005-Nov-14 03:40:28 by anonymous:
What should the following query return?

  SELECT name_alt AS name, * FROM sort_table ORDER BY name;

Who knows - it is ambiguous.


2005-Nov-14 03:57:44 by anonymous:
I don't understand your point. Your example is ambiguous because there are two columns with the same name in the result set. The example in the original ticket is not ambiguous and should give the expected result.


2005-Nov-14 05:08:06 by anonymous:
The original query is ambiguous because you can refer to columns not explicitly mentioned in the SELECT to ORDER BY. No different from:

   select a, b, c from foo order by d;


2005-Nov-14 13:41:32 by anonymous:
Not true: SELECT name_alt AS name FROM sort_table ORDER BY name. The field referenced by ORDER BY does appear in the SELECT clause, after the AS. This is perfectly legitimate and the preferred way of sorting expressions.


2005-Nov-14 14:33:21 by anonymous:
"ORDER BY name" is abmiguous because it can refer to the name_alt column via the alias OR the original name column from sort_table. You can ORDER BY things not mentioned in the SELECT.

  SELECT name_alt AS name FROM sort_table ORDER BY name


2005-Nov-14 16:26:42 by anonymous:
Yeah, true -- but it's pretty obvious which one we're referring to, since we explicitly aliased the original field for the purposes of this query.


2005-Nov-14 16:48:43 by anonymous:
It's only obvious that you explicitly created an ambiguous column and that is undefined behaviour. Whether it happens to appear in the SELECT is not relevant. If you can demonstrate that the majority of databases support MySQL's behaviour, then that's another matter.


2005-Nov-14 19:35:25 by anonymous:
I just verified that this works as I expected on MySQL, PostgreSQL, and MS SQL Server. I don't have access to Oracle.
 
1519 code active 2005 Nov anonymous Unknown 2005 Nov   3 4 Size double with blob data on UPDATE ? edit
I've a table with some fields and a blob field. I execute an INSERT INTO with NULL value on the blob field and then use the sqlite3_prepare with an UPDATE statement, to load a file into the blob field. The first time I execute an UPDATE over the record (without updating the blob field) the database size is doubled. Next UPDATEs over the same record doesn't seem to show the same problem. Temporary solving with a VACUUM at the end of the program.
 
1515 code active 2005 Nov anonymous Unknown 2005 Nov   4 3 Quotes incorrect included in colum names. edit
The names of columns returns by sqlite_exec has the quotes which has written in the query. I will try to show with examples in the sqlite command line.

  create table test("Full Name" varchar(30), "Login" varchar(15), Age integer);
  insert into test ("Full Name", "Login", Age) values ("Enrique Esquivel", "the_kique", 24);
  .headers on
  select * from test;

SQLite returns:

  Full Name|Login|Age
  Enrique Esquivel|the_kique|24

But when write:

  select "Full Name", "Login", Age from test;

returns:

  "Full Name"|"Login"|Age
  Enrique Esquivel|the_kique|24

Moreover when quote all fields:

  select "Full Name", "Login", "Age" from test;

returns:

  "Full Name"|"Login"|"Age"
  Enrique Esquivel|the_kique|24

Also:

  select [Full Name], [Login], [Age] from test;

SQLite returns wrong:

  [Full Name]|[Login]|[Age]
  Enrique Esquivel|the_kique|24

The quotes should be used for SQLite only for understand the identifiers, the fields in result must be unquoted. Try to test with other dbms and anyone has this behavior.

 
1508 code active 2005 Nov anonymous BTree 2005 Nov   1 3 sqlite 2.8.16 crashes on 64-bit / strict memory alignment archs edit
A few months ago, sqlite3 was fixed on 64-bit / strict memory alignment architectures. Would it be possible for those fixes to be backported to the version_2 code? I have an OpenBSD/sparc64 machine which I can provide ssh access to (as I did before to drh). I know sqlite2 is mostly unsupported, but as php5 uses sqlite2, it would be nice to have these fixes backported.
2006-Jan-05 02:28:23 by anonymous:
with the attached patch, sqlite 2.8.17 passes all the regressions tests on openbsd/amd64 and openbsd/sparc64.
 
1504 code active 2005 Nov anonymous Pager 2005 Nov   1 3 Multithreaded DB lock not released using Begin/Commit between threads edit
When using transaction-based insertion of rows in v3.2.7 in a multi-threaded environment, one thread appears not to release the database lock for any competing threads to be able to issue an "INSERT" statement (the thread issuing the "COMMIT" apparently). This problem does not appear in v2.8.16. The problem also appears in Linux (RH-9) as well.

I'm attaching "testsqlite.c", a test application (compiled in a WIN32 environment) that will duplicate the issue (Define SQLITE_2_8_16 or SQLITE_3_2_7 depending on the version of SQLite library to test against).

Direct any questions to Erik -> lonepenguin@hotmail.com

Thank You.

 
1494 code active 2005 Oct anonymous Unknown 2005 Oct   1 2 intermittent null reference exception in sqlite3_open edit
Doing a c# (.net 1.1 / visual studio 2003 / winxp) project with a (so far) small db (5 tables, max 1000 lines per table). About 10% of startups will fail with a NullReferenceException in sqlite3_open().

This is on a dell optiplex, win xp pro sp 2, 1G ram, P4@2.6GHz, using c# in visual studio 2003 version 7.1.3088 with .net framework 1.1.4322 sp 1.

Methods in Sqlite3.dll are imported with dllimport like this:

  [DllImport("Sqlite3.Dll", EntryPoint="sqlite3_open")]
  public static extern int sqlite3_open( string filename, out IntPtr dbhandle );

This would seem to be an error on my part or .net, except that this is the first sqlite call in the entire application and it fails only sometimes and the file name parameter is hard-coded. 90% of the time the application works fine. Of course, it could be .net messing things up. Anyway I can't find this on the web, sorry for taking up your time if it's not a bug. And no, I haven't got a program specifically for testing this thing.

Below is the stack trace for the System.NullReferenceException, the top line is the call into sqlite3.dll. The filename parameter is not null, it is "C:\DOCUMENTS AND SETTINGS\MARTIN.WANGEL\MY DOCUMENTS\VISUAL STUDIO PROJECTS\SOLUTION\BIN\DEBUG\SOLUTIONDATA.SQLITE" and it is thoroughly checked for null and for emptiness.

  at Solution.mwDatabaseSQLite.sqlite3_open(String filename, IntPtr& dbhandle)\r\n

  at Solution.mwDatabaseSQLite.Open() in c:\\documents and settings\\martin\\my documents\\visual studio projects\\solution\\mwdatabaseclasses.cs:line 149\r\n

  at Solution.DBUtils.VerifyDatabase(Type t, String connstr, dbtype dbtyp) in c:\\documents and settings\\martin\\my documents\\visual studio projects\\solution\\dbutils.cs:line 287\r\n

  at Solution.FrmMain..ctor() in c:\\documents and settings\\martin\\my documents\\visual studio projects\\solution\\form1.cs:line 1499\r\n

  at Solution.FrmMain.Main() in c:\\documents and settings\\martin\\my documents\\visual studio projects\\solution\\form1.cs:line 1285

/Martin

2005-Oct-27 21:12:22 by anonymous:
Maybe you should look at "Wiki", "SQLite wrappers", ".NET Framework" for an other way to do this.


2005-Oct-28 00:39:27 by anonymous:
the calling conventions of standard built DLL are __cdecl, not __stdcall (or WINAPI)... check if .NET Framework is able to call __cdecl import functions... in my mind it will call only STDCALL routines (which is the default on WIN32 API)
 
1502 code active 2005 Oct anonymous Unknown 2005 Oct anonymous 2 3 When selected in a union, view column names are incorrect. edit
When used in a union, a view transfers an underlying table's column names into the result set. The expected result is that column names in the second half (or further) of the union needn't match those in the first. Problem is also visible in TCL binding.
.mode columns
.headers on

select 'Create two tables, with nasty column names.' as remark;
create table t_a (c_a integer);
create table t_b (c_a integer);

select 'Create two views which each alias the column names of the above tables.' as remark;
create view v_a as select c_a as pretty from t_a;
create view v_b as select c_a as pretty from t_b;

select 'Insert some data' as remark;
insert into t_a values (1);
insert into t_b values (2);

select 'Notice that the views work fine by themselves.' as remark;
select 'The column names are both as we asked.' as remark;
select pretty from v_a;
select pretty from v_b;

select 'Notice that used in concert, with a join, the column name is now wrong.' as remark;
select pretty from v_a
 union select pretty from v_b;

select 'Aliasing the name of the column in the first half of the join is no help.' as remark;
select pretty as pretty from v_a
 union select pretty from v_b;

select 'Alias the name of the column in the second half of the join "fixes" the result.' as remark;
select pretty from v_a
 union select pretty as pretty from v_b;
2005-Oct-25 03:05:27 by anonymous:
same as ticket 1228


2005-Oct-26 07:59:17 by anonymous:
see also #1327
 
1500 code active 2005 Oct anonymous Unknown 2005 Oct   4 4 MIssing file listing permission causes DB opening/creation to fail edit
When using SQLite in PHP 5.0.5, trying to create or open a SQLite database in a directory to which the path does not have file listing (r) permissions all the way, the opening or creation fails.

Please see PHP bug report #34868:

<A HREF="http://bugs.php.net/bug.php?id=34868" TARGET="_blank">http://bugs.php.net/bug.php?id=34868

The PHP developers say that this is phenomenon is caused by the SQLite code, and suggested that I should forward this to you for possible investigation, as they merely bundle the lib with their PHP releases (and have some kind of minimal wrapper around it).

It is worth noting that this problem seem to appear in other PHP situations as well (then mostly connected to the usage of PHP's "Safe Mode" or "open_basedir" restrictions), but should appear with just about any application using getcwd() under IBM AIX.

The underlying reason is that getcwd() under IBM AIX fails if file listing (r) permissions are missing somewhere along the path. However, I am not sure if there are other, equal, means of determining the current working directory without using getcwd().

Best regards, Bjorn Wiberg

 
1493 code active 2005 Oct anonymous Parser 2005 Oct   3 3 lemon: pathsearch uses wrong directory separator under Win32 edit
The pathsearch function in lemon.c uses a semicolon (;) to separate the directories in the path. Under Win32 systems this should be a colon (:).
2005-Oct-18 09:37:10 by anonymous:
--- lemon.c.orig 2005-10-18 11:27:55.753467000 +0200 +++ lemon.c 2005-10-18 11:29:11.897825400 +0200 @@ -2791,13 +2791,16 @@ { char *pathlist; char *path,*cp; + char ds; char c; extern int access();

#ifdef __WIN32__ cp = strrchr(argv0,'\\'); + ds = ';'; #else cp = strrchr(argv0,'/'); + ds = ':'; #endif if( cp ){ c = *cp; @@ -2812,7 +2815,7 @@ path = (char *)malloc( strlen(pathlist)+strlen(name)+2 ); if( path!=0 ){ while( *pathlist ){ - cp = strchr(pathlist,':'); + cp = strchr(pathlist,ds); if( cp==0 ) cp = &pathlist[strlen(pathlist)]; c = *cp; *cp = 0;


2005-Oct-18 09:39:00 by anonymous:
More readable version of the patch:

  --- lemon.c.orig        2005-10-18 11:27:55.753467000 +0200
  +++ lemon.c     2005-10-18 11:29:11.897825400 +0200
  @@ -2791,13 +2791,16 @@
   {
     char *pathlist;
     char *path,*cp;
  +  char ds;
     char c;
     extern int access();

   #ifdef __WIN32__
     cp = strrchr(argv0,'\\');
  +  ds = ';';
   #else
     cp = strrchr(argv0,'/');
  +  ds = ':';
   #endif
     if( cp ){
       c = *cp;
  @@ -2812,7 +2815,7 @@
       path = (char *)malloc( strlen(pathlist)+strlen(name)+2 );
       if( path!=0 ){
         while( *pathlist ){
  -        cp = strchr(pathlist,':');
  +        cp = strchr(pathlist,ds);
           if( cp==0 ) cp = &pathlist[strlen(pathlist)];
           c = *cp;
           *cp = 0;


2005-Oct-19 14:05:27 by anonymous:
Cygwin and other Posix emulation layers on Windows require ':' for path separators, so you cannot blindly rely on __WIN32__ to make this determination.
 
1489 code active 2005 Oct anonymous   2005 Oct   3 2 Bad permissions on install-sh prevent 'make install' from completing edit
It's a trivial problem -

install-sh has incorrect permissions via CVS, resulting in 'make install' failing.

Error: make installtclsh ../sqlite/tclinstaller.tcl 3.2../sqlite/install-sh -c -d /usr/local/libmake: execvp: ../sqlite/install-sh: Permission deniedmake: *** [install] Error 127

Permissions: -rw-r--r-- 1 cat other 5598 Sep 28 2001 ../sqlite/install-sh

Fix: chmod 755 ../sqlite/install-sh

 
1488 code active 2005 Oct anonymous   2005 Oct   1 1 Collate Reverse does not exists? edit
when I execute below SQL
CREATE Unique INDEX index10 On Test2 (
F1 Collate BINARY ,
F2 Collate REVERSE DESC)

there is a error message:
no such collation sequence: REVERSE

but the latest document said that binary ,nocase , reverse is common collate function. what is wrong with my sql?

 
1487 code active 2005 Oct anonymous BTree 2005 Oct   1 3 Corrupt database causes indefinite loop in sqlite3_step() edit
I had a database become corrupt (no idea why, 57 other databases of similiar information are fine). When attempting to work with the database and execute a SELECT query the application froze in an endless loop inside sqlite3_step(). Upon further investigation (which is when I found the db was corrupt) it seems to be stuck inside the btree code (as reported by Sample). I tested the same query and alternates from sqlite3 CLI and got the same results. The exact query causes an infinite loop. Leaving off part of the WHERE statement (and making it broader) or removing one of the reporting columns simply causes a corruption error.

I have the original database as-is and the SQL query that can be run to cause the problem.

OS: Mac OS X 10.4.2

 
1485 code active 2005 Oct anonymous Unknown 2005 Oct jshen 3 1 cyrilic problem(suppose Unicode as a whole, for PPC) edit
I think there is a problem in the utf.c file.
2005-Oct-14 06:18:45 by anonymous:
Pocket PC support isn't provided in the default SQLite provider. The code necessary to support the Pocket PC is at http://sourceforge.net/projects/sqlite-wince and its there that a bug report should be filed.
 
1484 code active 2005 Oct anonymous Unknown 2005 Oct   4 4 Solaris8 awk problem edit
/usr/bin/awk in Solaris8 doesn't have sub() function.

To avoid this problem, use @AWK@ in Makefile and add AC_PROG_AWK in configure.ac.

 
1298 code active 2005 Jun anonymous Shell 2005 Oct drh 4 3 sqlite3.exe not recognizing newline as comment terminator edit
The sqlite3.exe program does not recognize comments that end in a newline if there is valid SQL before them on the same line. The statement:
"SELECT 1; -- this is a comment"
should be valid SQL, but sqlite3.exe still requires a semicolon after the comment.

Please look at the test below:

C:\Temp\SQLite>sqlite3

SQLite version 3.2.1

Enter ".help" for instructions

sqlite> select 1;

1

sqlite> select 1; -- test comment

   ...> ;

1

sqlite> select 1; -- test;

1

sqlite>

2005-Jun-22 18:20:37 by anonymous:
The string "SELECT 1; -- this is a comment" is not valid SQL. SQL does not use the semicolon character inside SQL statements except to seperate the constituent statements of a trigger, stored procedure, or an embedded program.

The semicolon is used by sqlite3.exe (and standard SQL) as a end of statement marker that triggers it to parse and execute the input up to that point. From the SQL 2003 standard:

  21 Direct invocation of SQL
  21.1 <direct SQL statement>
  Function
  Specify direct execution of SQL.
  Format
  <direct SQL statement> ::= <directly executable statement> <semicolon>

This SQL statement should be "SELECT 1 --this is a comment" followed by a semicolon to mark the end of the statement. Putting the semicolon in the middle terminates the first statement at that point, executes it, and then starts collecting input for a second statement (which in this case does not have a terminating semicolon).

Note that sqlite3 also accepts the word GO (used by SQL server) or the Oracle compatible character "/" as the end of statement marker, but only when they appear on a line of input by themselves (i.e. at the continuation prompt in the shell).

  sqlite> SELECT 1 --this is a comment
     ...> go
  1
  sqlite> SELECT 1 --this is a comment
     ...> /
  1
  sqlite>
 
1465 code active 2005 Oct anonymous CodeGen 2005 Oct   1 1 fdatasync not available and not yet fixed edit
fdatasync is still there ... i downloaded the current configure files which should check for it. do i have to use something else too?

./libtool --mode=link cc -g -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -DHAVE_READLINE=0 \ -o sqlite3 ./src/shell.c libsqlite3.la -lcurses cc -g -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -DHAVE_READLINE=0 -o .libs/sqlite3 ./src/shell.c ./.libs/libsqlite3.so -lcurses "./src/shell.c", line 355: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/shell.c", line 84 argument : pointer to const char "./src/shell.c", line 523: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/shell.c", line 84 argument : pointer to char "./src/shell.c", line 694: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./src/shell.c", line 583 argument : pointer to const unsigned char Undefined first referenced symbol in file fdatasync ./.libs/libsqlite3.so ld: fatal: Symbol referencing errors. No output written to .libs/sqlite3 make: *** [sqlite3] Error 1

2005-Oct-04 21:42:26 by drh:
Clear out your build directory (or start a new one) and rerun configure from scratch. Save the output of configure. Then rerun make. If you still have a problem, attach the output of configure to this ticket.
 
1312 code active 2005 Jun anonymous Shell 2005 Sep   1 1 CSV file import / export is all wrong! edit
  Four problems:
    Importing a proper CSV file (which delimits strings within
    double-quotes) is impossible. The '.import' command just
    treats the double-quotes as ordinary text characters. So
    (1) Error "expected 2 columns of data but found 3" can occur
        if one of the strings contains a comma
    (2) the delimiting double-quotes are NOT stripped off before
        inserting the data into the table as it should
    (3) it doesn't understand the standard convention that to
        represent a double-quote character within a double-quoted
        string you use TWO double-quote (eg. "3.5"" Floppy Drive")
    (4) outputting data in CSV mode also doesn't use this standard
        convention

  --------------------------------------------
  _Product.csv contains:

  "A001","McVities"
  "B001","Heinz"
  "C001","Callard,Bowser"

  sqlite> .mode csv
  sqlite> .import _Product.csv Product
  _Product.csv line 3: expected 2 columns of data but found 3
2005-Aug-12 23:13:54 by anonymous:
Commas are also not accounted for when using the sqlite3_mprintf() function(s). I'm guessing the %q flag should also escape these.
 
1351 code active 2005 Aug anonymous Shell 2005 Sep   1 1 Unable to parse UTF8 input edit
I'm in the process of writing a program which parses in UTF8 data, and then processes it and writes a UTF8 output into a text file. This textfile needs to be imported into SQLite.

However the commandline SQLite program doesnt support UTF8 input text files for its ".read" command. Considaring the database itself supports UTF8, would it be possible to allow UTF8 text file input.

I can't progress much further on my program if this can't be fixed.

2005-Aug-08 13:56:24 by drh:
Please attach an example UTF-8 script that ".read" is not reading correctly.


2005-Aug-08 17:58:44 by anonymous:
I can't seem to attach a text file, so instead i'll put it on my FTP, and it should be accessible from there. If you have trouble with that, i could email the text file. So if you have trouble, give me an email to send it to.

There will be a sample of a text file that won't ".read" available here: ftp://62.231.38.73/ in approximately 10 minutes.

Thanks for the fast reply. I'd be surprised if it was a problem with my text file generation, but stranger things have happened :p


2005-Aug-11 01:40:08 by drh:
Attach files using the [Attach] hyperlink at the top-right of this page.

Please do not send RAR files since that is an obscure archive format. If you want to use a compressed archive, make it either ZIP or GZIP.


2005-Aug-11 09:46:23 by anonymous:
I can only attach one because neither winzip or gzip are great at compressing text files. The files keep ending up over 100kb except for the artists.txt file. Thats the only one that went below 100kb.

I'm unwilling to try editing the file to remove lines of text from it because i want you to have the exact output that i'm getting from my program. Not the output that i'd get from notepad if i edited it. That will help identify whether it is a problem in my program, or a problem with SQLite.

Its always possible its a proglem with my source data, and its not actually proper UTF8, but i doubt that as SQLite doesn't seem to read the normal text correctly (such as the first line which is supposed to start a transaction, but SQLite instead ignores the line, and throws an error when it reachs the commit; at the end.

 
1397 code new 2005 Aug anonymous Shell 2005 Sep   1 1 .mode csv creates ASCII output instead of UTF-8 edit
compiled from source

.mode csv mixes up the charset IMHO

Example "f&#252;r" becomes "f\37777777703\37777777674r"

which makes the output file not usable

2005-Aug-31 13:54:57 by anonymous:
it's better but not UTF-8 utrac -p says ASCII

G&#252;ssing now is G\303\274ssing

hope it's ok to reopen the bug


2005-Sep-03 15:29:37 by anonymous:
.mode tab csv list all destroy the output now


2005-Sep-20 08:10:34 by anonymous:
same problem in 3.2.6


2005-Oct-06 20:14:37 by anonymous:
csv of today:

.mode cvs still does not work,

.mode tab works fine now

 
1461 code active 2005 Sep anonymous Unknown 2005 Sep drh 1 2 3.2.7 DLL can not deal File paths with international characters edit
My platform:winxpsp2 chinese version,my database file under a path with chinese charater,with the dll(3.2.1) sqliteexplore works fine,if I change the dll to 3.2.7,it show sqlite error 14:can't open the file,and then I change the path fully english,it can work fine again,so I think mybe it relate to Check-in:2656
2005-Sep-28 15:31:34 by anonymous:
and more,the source version has no such problem.


2005-Sep-28 16:09:04 by anonymous:
I notice in os_win.c, function "sqlite3OsFileExists" use GetFileAttributesA and GetFileAttributesW,but I tried GetFileAttributes works ok.
 
1458 code active 2005 Sep anonymous Shell 2005 Sep   2 2 Error at .importing in csv format (another) edit
Sqlite3 version 3.2.6 :

When importing data in csv format the programa adds commas when importing strings enclosed with commas in the source file.

In particular it shouldnt add commas when field data is already enclosed in comma, but it does. Curiously enough, it correctly imports numeric data.

Example: Take de demodatabase file, and take the table clients. If you try to add these records to the table with .import, it is impossible (the only workaround is deleting commas in the file and importing it in <list .mode>

504,"New Enterprise","Mr Smart","93-2275400"
505,"Another Enterprise","John Dongu","93-8765432"
506,"And here we are","Mr Strange","973-237131"

This file would be impossible to import correctly with .import If you set .mode list, it is imported incorrectly, since it keeps the commas around character fields in the table -which is what it should do anyway, since in this mode the program does not expect commas around field data. But when you set <.mode csv>, it imports them also incorrectly - it adds new commas around character data.

Souce data in csv format is important, -probably the most general data format available, and often a last resort format for difficult cases...

Thank in advance. I would like to help at fixing problems myself, but I do not understand a word of C.

Antoni Francino afrancino@mesvilaweb.com

2005-Sep-27 23:07:43 by anonymous:
You've got the names of your punctuation characters confused. What's happening is that the double quote marks around the text fields are gettting imported, whereas the usual understanding of "CSV" is that they should be stripped off.


2005-Sep-27 23:11:27 by anonymous:
On further inspection, this turns out to be the same problem as in ticket #1312.
 
1457 code active 2005 Sep anonymous Shell 2005 Sep   3 1 non-latin chars not recognized by CLI edit
Hello, If i am trying to execute an SQL statement via the CLI of a self-compiled (Win via MinGW) or the prebuilded exe all chars that are not iso are converted to something ugly.

For example, the German Umlaute or the &#232; are not entered correctly into a table name, field value and so on. If the same commands are executed from the sqlite>> promt everything works well.

As I need to compile my own sqlite.exe I need to be able to change that in code.

Thank you for this great Product and a solution to this problem.

btw: This is my first request here, so please be patient with me if I&#180;ve set the priority wrong... It&#180;s obviously highest priority to me ;)

2005-Sep-26 21:44:12 by anonymous:
&#232 should be the accented e in my post, sorry for that
 
1455 code active 2005 Sep anonymous Shell 2005 Sep   3 2 .import error: comma inside a string is read as field separator edit
In Sqlite version 3, when you need to import data into a table you use .import. (You cannot do it with COPY).

Well, if you need to import data in 'csv' format, and if there is a string in the input data that contains a <comma> inside itself, the reading is impossible since the comma is interpreted as a field separator. Example error message: "Error: There are 10 fields in file, and 8 fields were expected."

To me its pretty much a nuisance, since csv format is the most usual format for the data I use, and I've got to change the separating character, or else locate and eliminate those extra commas.

Hope this helps Thanks Antoni Francino afrancino@mesvilaweb.com

 
1451 code active 2005 Sep anonymous Shell 2005 Sep   4 3 .mode insert does not output BLOBs in an usable way edit
sqlite> CREATE TABLE a(b);
sqlite> INSERT INTO a VALUES (X'41424300500051');
sqlite> .dump
BEGIN TRANSACTION;
CREATE TABLE a(b);
INSERT INTO "a" VALUES(X'41424300500051');
COMMIT;
sqlite> .mode insert
sqlite> SELECT * FROM a;
INSERT INTO table VALUES('ABC');
It would be nice for ".mode insert" to print a command that would actually re-create the same data, the same as ".dump" (the obvious difference is that .dump can't filter data in any way, it just dumps it all) or, at least, it would be very nice if the already existing function that "prints binary data as X'-encoded-string" were reachable from SQL, so that one could use something like:
SELECT xencode(b) FROM a;

and obtain

X'41424300500051'
2005-Sep-25 17:03:40 by anonymous:
I am not the original ticket poster, but I noticed that this feature request is related to Monotone migrating away from Base64 encoding to using straight Sqlite blobs.


2005-Sep-26 01:49:33 by drh:
The built-in quote() function converts BLOBs into ascii BLOB literals. Will it not server for the requested xencode() function?

   SELECT quote(b) FROM a


2005-Sep-26 08:57:47 by anonymous:
Yes, I guess it can perfectly do. What about ".mode insert" output? Is it supposed to print raw data?
 
1447 code active 2005 Sep anonymous BTree 2005 Sep   1 1 Abnormal program termination in src/btree.c line 1339 edit
In some circumstances (after having used wxgrid ..) a call to sqlite gives a strange : Assertion Failed: pCur->idx>=0 && pCur->idx < pCur->pPage->nCell, file src/btree line 1339 abnormal program termination there seems to be non way of making a trace back ... any idea?

Thanx Doriaqn Tessore

2005-Sep-23 14:32:27 by drh:
Not much to go on. What version of SQLite is being used? ("SQLite 2" is kind of vague.)
 
1441 code active 2005 Sep anonymous VDBE 2005 Sep   4 4 sqlite3_clear_bindings routine missing edit
Implementation of sqlite3_clear_bindings routine is missing. I fix it this way, but the question is if that is correct... in vdbeapi.c :
/*
** The following routine unbind (set to NULL) binded parameters
*/
int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
  Vdbe *p = (Vdbe*)pStmt;
  int i;

  for(i = 1; i <= p->nVar; i++)
    vdbeUnbind(p, i);     

  return SQLITE_OK;
} 
2005-Sep-19 10:06:12 by anonymous:
The function is in experimental.c. check the source file.
 
1428 code active 2005 Sep anonymous TclLib 2005 Sep   3 3 tclinstaller.tcl script problems edit
The pkgIndex.tcl file generated by the tclinstaller.tcl script contains absolute pathnames to the TCL extension library. This causes problems if the extension subdirectory is moved. A more portable solution is shown below.

A second problem is that the shared library does not have executable permission. This is a problem on HPUX operating systems. Adding the 0755 permission mode to the open command solves the problem for HPPA and does not cause problems for the other platforms.

Here's a diff of the changes I made to address these two problems:

  cvs diff tclinstaller.tcl
  Index: tclinstaller.tcl
  ===================================================================
  RCS file: /sqlite/sqlite/tclinstaller.tcl,v
  retrieving revision 1.2
  diff -r1.2 tclinstaller.tcl
  17c17
  < puts $fd "package ifneeded sqlite3 $VERSION \[list load $LIB sqlite3\]"
  ---
  > puts $fd "package ifneeded sqlite3 $VERSION \[list load \[file join \$dir $LIBNAME\]\]"
  25c25,26
  < set out [open $LIB w]
  ---
  > #Some platforms such as the HP requre that libraries have the executable bit set
  > set out [open $LIB w 0755]
 
1415 code active 2005 Sep anonymous Unknown 2005 Sep drh 1 1 Querying for BLOB type fields edit
How do I query for BLOB type fields?

I tried

  1. field LIKE 'abc'
  2. field LIKE quote('abc') and
  3. field LIKE X'616263'

but nothing seems to return back the record that I am interested in.

2005-Sep-13 08:00:28 by anonymous:
Using version 3.2.5, you might use the quote function to convert a blob into a string which you can filter using the like operator: select * from test where quote(text) like '%6263%'; is working and usable but may not work as expected because like '%26%' would find the same and this was not expected, isn't it? select * from test where like(quote(text),'%6263%'); doesn't work and select * from test where like(quote(text),'%6263%','%'); doesn't work either


2005-Oct-04 05:44:08 by anonymous:
This should really be taken to the mailing list, preferably with descriptions of how other DBMSs handle LIKE as applied to BLOB columns.
 
1403 code active 2005 Sep anonymous Pager 2005 Sep   4 4 Newly initialized pages aren't completely cleared edit
Rational Purify reports many, many UMRs within SQLite, all originating from the following code path:

sqlite3OsWrite [os_win.c:296]
pager_write_pagelist [pager.c:2209]
sqlite3pager_get [pager.c:2445]
getPage [btree.c:1114]
allocatePage [btree.c:3153]

At a glance, it appears that the problem lies in sqlite3pager_get, which does appear to fully clear the newly allocated page.

A portion of the Purify-generated backtrace is attached.

2005-Sep-01 15:41:50 by drh:
SQLite does not clear "don't-care" sections of the page. Doing so would use CPU cycles unnecessarily and hence slow things down. That unused sections of a database page are never initialized is a feature of SQLite, not a bug.


2005-Sep-01 16:17:17 by anonymous:
Would it be possible to clear the entire page when NDEBUG is not defined? Admittedly, not clearing the page has no ill effects; it does clutter the output from Purify quite a bit though, which will inevitably lead to missing a real error amidst the noise.


2005-Sep-01 17:59:04 by anonymous:
Actually, it looks like I was off the mark as to what's causing this. It isn't writing a newly allocated page that's causing the warning, but reuse of an existing page (from pPager->pFirstSynced). So I'm not sure what needs to be cleared to avoid the warning; some range within the page's memory area, obviously, but it's not as simple as just memset'ing the entire memory area like it would be when the page is freshly allocated earlier in sqlite3pager_get.
 
1401 code active 2005 Aug anonymous Shell 2005 Aug   4 4 concatenating html in select list edit
    create table test( f1 text, f2 text );
insert into table values( 'hello', 'world' );
.mode html
select f1 || '<br>' || f2 from test;
<TR><TD>hello&lt;br>world</TD>
</TR>

    Of course, I would like to see
<TR><TD>hello<br>world</TD>
</TR>
 
1382 code active 2005 Aug anonymous   2005 Aug drh 1 1 Assert nErr==0 on corrupt db edit
I'm working on an embedded filesystem where files can be randomly altered. Sometimes my .db files get messed up. I've attached an example db.

I'd like to catch the asserts and return an error rather than crash.

$ sqlite corrupt-assert.db 'select count(*) from sensor'

sqlite: src/main.c:120: sqliteInitCallback: Assertion `nErr==0' failed.

Aborted

 
1365 code active 2005 Aug anonymous   2005 Aug   3 3 64 bit types not completely overridable edit
The current 64 bit types in sqlite3.h and sqliteInt.h do not allow the type to be overriden using a preprocessor definition, unlike all the other base types. The current 64 bit typedefs assume that a "long long" is 64 bits - this is not guaranteed (and on PS2 it is wrong, long long is 128 bits).

Here are some minor patches that should allow these types to be overriden, but keep the old behavior if they are not:

  ==== //sqlite-3.2.2/src/sqlite3.h#1 - sqlite-3.2.2\src\sqlite3.h ==== 81,83c81,83
  < #if defined(_MSC_VER) || defined(__BORLANDC__)
  <   typedef __int64 sqlite_int64;
  <   typedef unsigned __int64 sqlite_uint64;
  ---
  > #ifdef INT64_TYPE
  >   typedef INT64_TYPE sqlite_int64;
  >   typedef unsigned INT64_TYPE sqlite_uint64;
  85,86c85,93
  <   typedef long long int sqlite_int64;
  <   typedef unsigned long long int sqlite_uint64;
  ---
  > # if defined(_MSC_VER) || defined(__BORLANDC__)
  >     typedef __int64 sqlite_int64;
  >     typedef unsigned __int64 sqlite_uint64;
  > # else
  >     typedef long long int sqlite_int64;
  >     typedef unsigned long long int sqlite_uint64;
  > # endif
  > # define INT64_TYPE sqlite_int64
  > # define UINT64_TYPE sqlite_uint64

  ==== sqlite-3.2.2/src/sqliteInt.h#1 - sqlite-3.2.2\src\sqliteInt.h ==== 157,163d156
  < #ifndef UINT64_TYPE
  < # if defined(_MSC_VER) || defined(__BORLANDC__)
  < #   define UINT64_TYPE unsigned __int64
  < # else
  < #   define UINT64_TYPE unsigned long long int
  < # endif
  < #endif
  183c176
  < typedef UINT64_TYPE u64;           /* 8-byte unsigned integer */
  ---
  > typedef sqlite_uint64 u64;         /* 8-byte unsigned integer */
2005-Aug-27 16:45:09 by drh:
Can someone suggest a suitable #ifdef that will automatically identify a PS and do the right thing to provide a 64-bit integer type, similar to what is down for windows?
 
1342 code active 2005 Jul anonymous   2005 Jul   1 1 sqlite 3.2.2 will not load on Suse Linux 9.3 edit
when trying to load the sqlite 3.2.2 .so lib with tcl I get this problem:

  couldn't load file "/usr/lib/sqlite3/tclsqlite-3.2.2.so": /usr/lib/sqlite3/tclsqlite-3.2.2.so: undefined symbol: sqlite3_version

Sqlite 3.2.1 does not give an error, with the same script

 
1327 code active 2005 Jul ghaering VDBE 2005 Jul   2 3 UNION causes sqlite3_column_decltype to always return NULL edit
create table test(foo bar);

select foo from test union select foo from test;

Normally, sqlite3_column_decltype() will return 'bar', but with the UNION, it will always return NULL.

This is quite annoying for pysqlite users, because it renders the type detection useless for UNION queries (and EXCEPT and INTERSECT).

 
1325 code active 2005 Jul anonymous Unknown 2005 Jul   1 4 sqlite3_bind_value not implemented edit
function sqlite3_bind_value not implemented
 
1323 code active 2005 Jul anonymous   2005 Jul   1 1 misuse-4.4...gmake: *** [test] Segmentation Fault (core dumped) edit
misuse-4.4...gmake: *** [test] Segmentation Fault (core dumped)

on both solaris 8 and 9 build env

export CPPFLAGS="-I/tps/include"

export LDFLAGS="-L/tps/lib -R/tps/lib"

export PKG_CONFIG_PATH=/tps/lib/pkgconfig

CC=/tps/bin/gcc

CXX=/tps/bin/g++

LD_LIBRARY_PATH=/tps/lib:/tps/lib/sparcv9:/lib:/usr/lib:/usr/local/lib:\ /usr/ccs/lib:/usr/dt/lib:/usr/ucblib:/usr/openwin/lib

PATH=/tps/bin:/tps/java/bin:/dsw/source/bin:/dsw/depot-5.13/bin:\ /usr/ccs/bin:/usr/bin:/usr/openwin/bin:/bin:/usr/local/bin:/sbin:\ /usr/sbin:/usr/ucb:/etc:.:/sfoc/bin:/usr/dt/bin:\ /dsw/source/harvest/bin:/usr/afsws/bin:/dsw/pgp-2.6.2s/bin

export CC CXX LD_LIBRARY_PATH PATH

where /tps is my version of /usr/local where I put all the configuration controlled open source and licensed s/w for my network.

<pray@fir:/export/build/sqlite-3.2.2/bld> [525]$ ../configure --prefix=/dsw/sqlite-3.2.2 --with-tcl=/tps/lib

gmake

gmake test

then got error

gcc -v

Reading specs from

/dsw/gcc-3.4.0/lib/gcc/sparc-sun-solaris2.9/3.4.0/specs Configured with: ../configure --prefix=/dsw/gcc-3.4.0 --disable-nls --enable-languages=c,c++,f77,objc --disable-libgcj --srcdir=/export/build/gcc-3.4.0 --with-ld=/usr/ccs/bin/ld Thread model: posix gcc version 3.4.0

using ActiveTcl8.4.5.0

 
1308 code active 2005 Jun anonymous   2005 Jun   3 4 PRAGMA TABLE_INFO does not recognize attached database syntax. edit
PRAGMA TABLE_INFO does not recognize the dbName.tableName syntax to distinguish between identically named tables in attached databases.
2005-Jun-28 17:06:51 by anonymous:
The pragma command use a different syntax to select the attached database. The following should work:

  PRAGMA database_name.table_info(table_name)

This should be fixed in the documentation. The optional database name is shown for the version number pragmas, but not for the others on the page http://www.sqlite.org/pragma.html#schema

This seems to be a common and natural expectation since attached tables are referred to using the database_name.table_name syntax in queries. The documentation should be very clear that it is different for the pragma commands.


2005-Jun-28 19:51:03 by anonymous:
It should also be made clear whether a single pragma value applies to all attached databases, or if each attached database has its own value for the pragma.
 
1305 code active 2005 Jun anonymous TclLib 2005 Jun   1 1 Tcl installs pkgIndex with wrong path edit
Correct script below:

  # This script attempts to install SQLite3 so that it can be used
  # by TCL.  Invoke this script with single argument which is the
  # version number of SQLite.  Example:
  #
  #    tclsh tclinstaller.tcl 3.0
  #
  set VERSION [lindex $argv 0]
  set LIBFILE .libs/libtclsqlite3[info sharedlibextension]
  if { ![info exists env(DESTDIR)] } { set DESTDIR "" } else { set    DESTDIR $env(DESTDIR) }
  set LIBDIR [lindex $auto_path 0]
  set LIBNAME [file tail $LIBFILE]
  set LIB $LIBDIR/sqlite3/$LIBNAME

  file delete -force $DESTDIR$LIBDIR/sqlite3
  file mkdir $DESTDIR$LIBDIR/sqlite3
  set fd [open $DESTDIR$LIBDIR/sqlite3/pkgIndex.tcl w]
  puts $fd "package ifneeded sqlite3 $VERSION \[list load $LIB   sqlite3\]"
  close $fd

  # We cannot use [file copy] because that will just make a copy of
  # a symbolic link.  We have to open and copy the file for ourselves.
  #
  set in [open $LIBFILE]
  fconfigure $in -translation binary
  set out [open $DESTDIR$LIB w]
  fconfigure $out -translation binary
  puts -nonewline $out [read $in]
  close $in
  close $out
 
1286 code active 2005 Jun anonymous   2005 Jun   4 4 The downloadable DLL file does not work with Intel VTune edit
The DLL which can be downloaded in sqlitedll-3_2_2.zip does not work with the Intel VTune profiler version 7.2. I don't know the cause of the problem, but after recreating the DLL with Visual Studio 2003 from the source found in sqlite-source-3_2_2.zip, it works well.
 
1111 code active 2005 Feb anonymous Unknown 2005 Jun   3 1 no such column error with a subselect as a table edit
Execute the following script. In 3.0.8, you get the following results:

  line 0
  line 2

in 3.1.1 beta, you get the following error:

  SQL error: no such column: bb.a

SCRIPT:

  create table test1 (a int);
  insert into test1 values (0);
  insert into test1 select max(a)+1 from test1;
  insert into test1 select max(a)+1 from test1;

  create table test2 (a int, b text);
  insert into test2 select a,'line ' || a from test1;

  select test2.b from (select test1.a from test1 where a%2 = 0) as bb   join test2 on bb.a = test2.a;
2005-Feb-21 17:48:20 by anonymous:
Tested in 3.1.3, issue still exists


2005-Jun-12 22:09:08 by drh:
Workaround:

  select test2.b 
  from (select test1.a as a from test1 where a%2=0) as bb
       join test2 on bb.a=test2.a;
 
1278 code active 2005 Jun anonymous   2005 Jun   1 2 sqlite3_finalize doesn't clear previous error code or message edit
A call to sqlite3_finalize(), after an error during sqlite3_prepare() of another statement, returns the correct result SQLITE_OK, but does not reset the error code or error message returned by sqlite3_errcode() and sqlite3_errmsg(). The error reporting functions still return the error code and message associated with the error that occurred during the previous prepare.

The attached code demonstrates the problem. One statement is prepared successfully. Then an second statement is prepared. This one fails and returns an error result. The correct error code and message are retrieved using the error reporting API functions. Next, the first statement is finalized, which returns SQLITE_OK. Calling the sqlite_errcode() function at this point still returns the error code from the previous error.

I believe the error code and message should be cleared by the successful call to the sqlite3_finalize() API function.

 
1264 code active 2005 May anonymous Unknown 2005 May   3 3 access() undefined on MSVC edit
  shell.c(1705) : warning C4013: 'access' undefined; assuming extern returning int

Add this:

  #if defined(_WIN32) && defined(_MSC_VER)
  # include <io.h>
  #endif
 
1255 code active 2005 May anonymous   2005 May   4 3 Decrease number of warnings with Microsoft Visual C++ edit
Add this to sqliteInt.h to decrease the number of warnings produced by sqlite:

  #if defined(_MSC_VER)
  #pragma warning (disable: 4018) // signed/unsigned mismatch
  #pragma warning (disable: 4244) // conversion from 'unsigned __int64 ' to 'unsigned char ', possible loss of data
  #pragma warning (disable: 4761) // integral size mismatch in argument; conversion supplied
  #endif
2005-May-20 19:27:50 by drh:
Is there no command-line option on microsoft to disable these warnings?


2005-May-21 08:56:15 by anonymous:
It's possible to lower the warning level, from say 3 to 2 using the command line. But this is not as selective and will remove more warnings than those #pragmas.
 
1248 code active 2005 May anonymous Unknown 2005 May   3 1 sqlite3_get_table returns garbage for BLOB data edit
BLOB data returned by sqlite_get_table() is garbage when it contains data bytes holding '0' values.

Code: Windows, 3.2.1, VC 6.0

char data[128];

for(int i = 0;i<128;i++)

{ data[i] = i+1; }

sqlite3_exec(thedb,"CREATE TABLE test (b BLOB)",NULL,NULL,NULL);

result = sqlite3_prepare(thedb,"INSERT INTO test (b) VALUES (?)",-1,&cstate,NULL);

sqlite3_bind_blob(cstate,1,data,128,SQLITE_STATIC); // bind the data to the statement

result = sqlite3_step(cstate);

result = sqlite3_finalize(cstate);

sqlite3_get_table(thedb,"SELECT * FROM test",result,rows,columns,NULL);

this sqlite3_get_table() returns a properly layed out table. However, it looks like sqlite_get_table() is converting blob data to another type of data (string?) as it processes the command. The BLOB data it returns using this call is completely corrupted, due to processing '0' valued bytes as EOS characters. Instead it should be inferring BLOB data where appropriate, and returning a correct data block.

As a workaround I've been using the prepare/step functions instead. However, the sqlite3_get_table() is a neccessity for many users of this library, as it allows a simple and elegant SQL query mechanism, and should be fixed ASAP to support BLOB data properly.

2005-Sep-27 01:44:39 by anonymous:
sqlite3_get_table is considered legacy code, intended to make porting of sqlite2 applications (which never had to deal with BLOBs) easier. Its use in new applications is deprecated. If you need something like it that can handle BLOBs, you're best off writing a wrapper function for the prepare/step interface (you can use the sqlite3_get_table code as a template).
 
1241 code active 2005 May anonymous   2005 May   4 5 sqlite3_create_collation16 - should have 'const void* zName' arg edit
sqlite3_create_collation16 - should have 'const void* zName' arg NOT 'const char* zName' I believe that:

  int sqlite3_create_collation16(
    sqlite3*, 
    const char *zName, 
    int eTextRep, 
    void*,
    int(*xCompare)(void*,int,const void*,int,const void*)
  );

in sqlite3.h should be:

  int sqlite3_create_collation16(
    sqlite3*, 
    const void *zName,  /* <<== CHANGE HERE <<== */
    int eTextRep, 
    void*,
    int(*xCompare)(void*,int,const void*,int,const void*)
  );
 
1235 code active 2005 May anonymous Unknown 2005 May drh 4 3 inconsistent pragma handling edit
The pragma user_version and schema_version are handled inconsistently in this respect : the result set returned contains a single column that has no name. all other pragmas return named columns. since some high-level languages complain about db fields with no names (most wrappers will gag at this), I suggest that a simulated "column_name" is also generated here, as with all other pragmas.
 
1228 code active 2005 Apr anonymous Unknown 2005 Apr   4 3 problem with select+union on a view with aliased columns edit
    CREATE TABLE tbl1 (col1 VARCHAR PRIMARY KEY);
    INSERT INTO tbl1 VALUES ('1');
    INSERT INTO tbl1 VALUES ('2');
    CREATE VIEW view1 AS SELECT col1 AS col1a FROM tbl1;

This creates a view with one column (col1a). Normal SELECTs on this view return results as expected, but the following:

  SELECT col1a FROM view1 WHERE col1a = 1
  UNION
  SELECT col1a FROM view1 WHERE col1a = 2;

Produces:

  col1
  1
  2

When the column name should in fact be col1a (this is the behaviour in postgres). You can work around this by doing:

  SELECT col1a AS col1a FROM view1 WHERE col1a = 1
  UNION
  SELECT col1a AS col1a FROM view1 WHERE col1a = 2;

But that shouldn't be necessary. Thanks. --Sebastian Kun

 
1223 code active 2005 Apr anonymous   2005 Apr   3 4 .read FILENAME fails edit
on win xp with an uft-8 encoded file saved by notepad : "SQLerror:near "&#180;&#9559;&#9488;": syntax error"

sqlite-3_2_1 (precompiled binaries for windows).

2005-Apr-26 12:33:32 by drh:
Without some additional hints (such as the text of the file containing the syntax error) we cannot diagnose this problem.


2005-Apr-26 14:55:33 by anonymous:
to produce the problem : from win use notepad, enter any valid sql, save as with encoding utf8 (the file begin with the utf8 BOM &ef &bb &bf), from sqlit3 use the .read and you get it ...
 
1222 code active 2005 Apr anonymous Unknown 2005 Apr   2 4 spec file errors edit
the "spec.template" file as included with sqlite-3.2.1.tar.gz does not work. the following fixes need to be made:

(1) on the "%prep" line, change "-n %{name}" to "-n %{name}-%{version}" since that's the directory name that the source tarball expands into.

(2) the main package needs a dependency on "tcl" and a build dependency on "tcl-devel". this is done by adding "Requires: tcl" and "Buildrequires: tcl-devel" below the "BuildRoot" line.

(3) i suspect the devel package will also have a dependency on "tcl-devel"- as long as the user is required to have tcl in order to install sqlite from RPM files, does it make sense to have "sqlite-devel" without also having "tcl-devel" installed?

in addition, it looks like when "make tcl_install" runs as part of the rpmbuild process, it isn't picking up $DESTDIR from the environment and is therefore trying to create "/usr/share/tcl8.4/sqlite3" on the system instead of within the virtual root created by rpm. rpmbuild's "%make" script contains the following:

#!/bin/sh

  RPM_SOURCE_DIR="/home/jms1/rpm/SOURCES"
  RPM_BUILD_DIR="/home/jms1/rpm/BUILD"
  RPM_OPT_FLAGS="-O2 -g -march=i386 -mcpu=i686"
  RPM_ARCH="i386"
  RPM_OS="linux"
  export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
  RPM_DOC_DIR="/usr/share/doc"
  export RPM_DOC_DIR
  RPM_PACKAGE_NAME="sqlite"
  RPM_PACKAGE_VERSION="3.2.1"
  RPM_PACKAGE_RELEASE="1"
  export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
  RPM_BUILD_ROOT="/var/tmp/sqlite-3.2.1-root"
  export RPM_BUILD_ROOT
  
  set -x
  umask 022
  cd /home/jms1/rpm/BUILD
cd sqlite-3.2.1
install -d $RPM_BUILD_ROOT//usr
install -d $RPM_BUILD_ROOT//usr/bin
install -d $RPM_BUILD_ROOT//usr/include
install -d $RPM_BUILD_ROOT//usr/lib
make install prefix=$RPM_BUILD_ROOT//usr
   
    /usr/lib/rpm/brp-compress 
    /usr/lib/rpm/brp-strip 
    /usr/lib/rpm/brp-strip-static-archive 
    /usr/lib/rpm/brp-strip-comment-note 
and when it runs, it generates the following output:

Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.11845
+ umask 022
+ cd /home/jms1/rpm/BUILD
+ cd sqlite-3.2.1
+ install -d /var/tmp/sqlite-3.2.1-root//usr
+ install -d /var/tmp/sqlite-3.2.1-root//usr/bin
+ install -d /var/tmp/sqlite-3.2.1-root//usr/include
+ install -d /var/tmp/sqlite-3.2.1-root//usr/lib
+ make install prefix=/var/tmp/sqlite-3.2.1-root//usr
tclsh ./tclinstaller.tcl 3.2
can't create directory "/usr/share/tcl8.4/sqlite3": permission denied
    while executing
"file mkdir $LIBDIR/sqlite3"
    (file "./tclinstaller.tcl" line 15)
make: *** [tcl_install] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.11845 (%install)
looking at tclinstaller.tcl, it looks like it sets DESTDIR to an empty string if the variable doesn't already exist (i will admit i'm guessing here, i'm not an expert with tcl) which causes LIBDIR to point to "/usr/share/tcl8.4" (instead of "/var/tmp/sqlite-3.2.1-root/usr/share/tcl8.4", which is what one would expect.) the "rpmbuild" process, running as non-root, doesn't have permission to create this system directory, hence the error message.

i don't know enough about tcl to figure out how to make DESTDIR carry into the script correctly, or even how to debug it to make sure that's what's actually going on.

 
1214 code active 2005 Apr anonymous Unknown 2005 Apr   2 3 sqlite3_column_bytes returns 0 on p3 column with EXPLAINed selects edit
Both functions

  sqlite3_column_bytes()
  sqlite3_column_bytes16()

do not return the correct length for the p3 text column of EXPLAIN select queries. Both functions always return 0, even if the p3 column contains text.

The bug can be easily reproduced with the following query:

  EXPLAIN SELECT 'text';

The p3 column, row 2, contains the word 'text', but the functions return 0 regardles.

I have not seen this bug with non EXPLAIN queries, but it breaks code which relies on the fact that sqlite3_column_bytes always retun the correct length of the text and needs to preallocate memory accordingly.

 
1213 code active 2005 Apr anonymous Parser 2005 Apr   3 2 Problem with alias columns in subqueries edit
The following query create an SQL error while it seems to me to be SQL complient (in fact it works fine with a lot database servers): sqlite> select i from (select 0 as i union all select 1) as tmp; SQL error: no such column: i

I found a workaround writting the following SQL query (it works well if you explicits the implicit variable i) : select i from (select 0 as i union all select 1 as i) as tmp;

Thanks for your help Jerome

2005-Apr-17 11:03:52 by anonymous:
SQLite appears to take the column names from the last clause in a UNION (your originally query works if you reverse the order of the clauses).

IIRC, the standard says that the column names in a UNION of clauses with different column names is DBMS-dependent and while many DBMSs take them from the first clause, this is not something to count on.


2005-Apr-18 19:53:09 by anonymous:
You're perfectly right, but it seems to me that it should be better that sqlite do respect the "de facto" standard.
 
1205 code active 2005 Apr anonymous Unknown 2005 Apr   3 1 accent ecu etc. in connectionstring edit
Hi

Whenever I use a accent grave or accent ecu or whatever accented characters in the connectionstring sqlite turns this into weird characters (in the file name of the database. Since my database name is dependent on user input I can't eliminate this situation... bart@arlanet.com

2005-Apr-13 12:16:08 by drh:
What version of SQLite? What operating system?


2005-Apr-14 12:22:32 by anonymous:
Windows 2000 (dutch version) Sqlite version 3.

the word privé in the connectionstring becomes privé.db3 on the disk, which causes errors afterwards when opening the database


2005-Apr-14 12:23:06 by anonymous:
I see something goes wrong with the accents as well on the previous remark


2005-Apr-14 12:29:41 by anonymous:
It really sounds to me like you're taking an accented character encoded in ISO8859-1 or some similar single-byte encoding and feeding it to something that's expecting a UTF-8 encoded string. In UTF-8, any byte that has its high bit set must be part of a multi-byte sequence.


2005-Apr-14 14:00:56 by anonymous:
After converting my string to an UTF8 encoded string, it still does the same thing....


2005-Apr-14 14:06:41 by anonymous:
using sqlite.net
 
1030 code active 2004 Dec anonymous Shell 2005 Apr   2 3 impossible to import a file and do other things in the same invocation (strongly affects scripting) edit
The sqlite2 shell can be scripted in 2 ways:

        1.  sqlite mydb 'commands'
        2.  commands | sqlite mydb

The first form has a bug, which I have not submitted, and which also occurs in sqlite3:

        o dot commands are not fully intermixable with sql commands

It will also fail for long command lines.

To work around this, it is necessary to use the second form of scripting. However:

        o for entering data via COPY or .import, a separator is
          necessary to allow sql after the data
        o COPY has \. as a separator

Here is the sqlite3 bug:

        o .import has no separator that I know of

The only possible workaround seems to be to call the executable more than once. However:

        o this makes :memory: databases impossible

Therefore, I said this is major with a workaround. The workaround is to use temporary files instead of memory databases, and:

        o inconveniently kludge the sqlite2 behavior using multiple
          calls to the executable

However, files are far slower than memory, making the use of sqlite as an awk-like filter less attractive than it was with sqlite2.

Here are 2 solutions to fix the problem, both of which are desirable:

        o allow dot commands and sqlite commands to be intermixable on
          the command line such as with "sqlite :memory:
          '.show;.import ...;select ...;.import ...; select ...'" 
        o allow a separator for .import

Here are some related bugs, also not submitted:

        o .separator is overloaded to mean input and output
          separators, but for scripting it would be useful to have
          them separate
        o csv mode and tabs mode are lightly documented.  what are the
          exact syntaxes for them (line continuation, quoting, etc.),
          and what is the difference between tabs mode and .separator
          set to tab?
        o it might also be useful to have a .with command so that you
          can do .with .separator ","; .import ...; .endwith to
          effectively emulate (let ((...)) ...) in lisp.
          i.e. temporarily set a value to something without having to
          know what to set it back to when you are done.

Sqlite rocks.

Thanks.

 
1201 code active 2005 Apr anonymous CodeGen 2005 Apr danielk1977 1 1 erro defined type UINT8_TYPE edit
In file sqliteInt.h line 203 typedef UINT8_TYPE i8; /* 1-byte signed integer */

it should be INT8_TYPE.

 
1200 code active 2005 Apr anonymous   2005 Apr   2 3 new versions of SQLite return different (incorrect) results. edit
Newer versions of SQLite are returning different, and I believe incorrect, results compared to those returned by older versions.

Using version 3.0.8 the following query returns the correct results given the attached database.

  sqlite> select * from device_property_list where device_property_value = 0;
  1|Station|3|Initial Volume|0
  1|Station|1|Template|0
  2|Station|3|Initial Volume|0
  2|Station|1|Template|0
  3|Station|3|Initial Volume|0
  3|Station|1|Template|0

This same query does not return any results using versions 3.1.6 and 3.2. If the query is changed slightly, by quoting the zero in the where condition, then both of the newer versions return the same set of results as 3.0.8.

  sqlite> select * from device_property_list where device_property_value = '0';
  1|Station|3|Initial Volume|0
  1|Station|1|Template|0
  2|Station|3|Initial Volume|0
  2|Station|1|Template|0
  3|Station|3|Initial Volume|0
  3|Station|1|Template|0

The device_property_list is a view that hides a complex join of several tables, and a long case expression that select the value to return for device_property_value; the field that is being tested by the condition.

I have attached a sample database and the sql script used to create it for testing.

 
1191 code active 2005 Mar anonymous Unknown 2005 Mar   2 3 last_insert_id() Does Not Work after Insert on View edit
If I have a view with an INSERT trigger attached to it, and then use the view to insert a record, last_insert_rowid() does not return the ID inserted. For example, given this DDL:

  CREATE TABLE _simple (
    id INTEGER NOT NULL PRIMARY KEY,
    name TEXT
  );
  CREATE VIEW simple AS
    SELECT _simple.id AS id, _simple.name AS name
    FROM   _simple;

  CREATE TRIGGER insert_simple
  INSTEAD OF INSERT ON simple
  FOR EACH ROW BEGIN
    INSERT INTO _simple (name)
    VALUES (NEW.name);
  END;

This is what I get when I use the view to insert:

  sqlite> insert into simple (name) values ('foo');
  sqlite> select last_insert_rowid();
  last_insert_rowid()
  -------------------
  0                  

It does work if I insert directly into the table, of course:

  sqlite> insert into _simple (name) values ('foo');
  sqlite> select last_insert_rowid();
  last_insert_rowid()
  -------------------
  2
2005-Mar-31 06:04:59 by anonymous:

  VIEWs are read-only so you can not INSERT into them.
  See: http://www.sqlite.org/omitted.html

  Regards,
  Bartosz.


2005-Mar-31 18:12:10 by anonymous:
Bartosz,

Please note that triggers have been applied to the view, so you can actually insert into them. I do it all the time. For example, given my previous examples, this insert will work:

sqlite> insert into simple (id, ame) values (1, 'foo');

Pretty coole, eh? See:

  http://www.sqlite.org/lang_createtrigger.html

--Theory


2005-Mar-31 18:21:08 by drh:
The last_insert_rowid() routine does return the correct insert rowid while you are still within the trigger. Once you leave the trigger, last_insert_rowid() returns the rowid of the most recently inserted row outside of any trigger. This is by design. If last_insert_rowid() were to be responsive to inserts done by triggers, then any AFTER INSERT trigger that happened to update a logfile would overwrite the last_insert_rowid() from the actual INSERT.

One could argue, I suppose that last_insert_rowid() should work for inserts performed by an INSTEAD OF trigger but not by other kinds of triggers. I will ponder that notion and might implement it if I cannot think of any objections.


2005-Mar-31 18:25:14 by anonymous:
Allowing it to persist past the trigger in an INSTEAD OF trigger would certainly do what I need. I think that'd make a lot of sense.

All of this should probably be well-documented somewhere. I'd be happy to add a page to the wiki once you've decided how to proceed with this issue.

Thanks!

Theory


2005-Apr-27 02:21:21 by anonymous:
Have you had a chance to think more on this issue?

Thanks,

Theory


2005-Nov-08 03:06:51 by anonymous:
Just checking in on this issue again. Do you think that it's something that will be resolved, one way or the other, soon?

Thanks,

Theory


2005-Nov-08 17:44:14 by anonymous:
The instead of insert trigger can't, in general, update the last_insert_rowid value automatically and do it correctly, since a trigger may do multiple inserts into multiple tables. SQLite has no idea which rowid should be reported back outside the trigger. This is left to the user (i.e. the author of the trigger). You can get the last_insert_rowid after the appropriate insert in the trigger and then save that value into an auxillary table that is visible outside the trigger.

This is especially important when your view is created from entries in several joined tables. Your instead of insert trigger must do inserts into the individual tables, and may need to use the last_insert_rowid function to link the records in the tables together correctly. It then needs to return the "master" rowid for the table. SQL doesn't have any syntax to specify which value is returned as the rowid of the instead of trigger, so SQLite doesn't do anything automatically. You need to create a sperate last_rowid table, and inside the trigger you update the value of a row in that table (possibly the only row) with the value you want to return. Then the code that does the insert into the view needs to get the value of that row instead of calling last_insert_rowid.

This type of behavior is needed since there is no limit to the number of nested instead of triggers that could be executed by a single SQL statement (i.e. one instead of trigger could do an insert into another view... and so on).

The current behavior isn't quite as convenient in the simplest case, but it works correctly in the more complicated general case, where simply updating the last_insert_rowid value would be wrong.


2005-Nov-08 22:51:56 by anonymous:
I think that there's an argument to be made that last_insert_rowid() should return the last inserted row ID, even if a trigger inserted a bunch. It should simply return the last one entered.

However, I agree with your analysis. Could there perhaps be a set_insert_id() function, or some such, that the trigger could use to tell last_insert_row_id() what to return?

 
1177 code active 2005 Mar anonymous Shell 2005 Mar   1 4 (Win32) .import inserts extra carrier character in every row edit
Hi,

Please investigate the following .import problem. I assume no one would expect a \r character be appeneded at the end of the values of the last column.

Step 1: Type the below text in Notepad and save as test.txt:

    Row1	try1
    Row2	try2
    Row3	try3
    

Step 2: In sqlite3, type the following:

    CREATE TABLE test (col1 char(4), col2 char(4));
    .separator \t
    .import test.txt test
    .mode csv
    SELECT * FROM test;
    

The following results are observed:

    "Row1","try1\r"
    "Row2","try2\r"
    "Row3","try3"
    

I'm new to sqlite and I'm not sure whom shall I assign this ticket to. Please help me to re-assign to the right person if I've set it wrong.

Thanks.

Amanda

2005-Mar-24 02:53:08 by anonymous:
Seems this is also related to ticket #939 ... there it says it's been solved, but as far as I'm using 3.20, it seems that it's not been fixed completely.

Please note that Windows use BOTH \r and \n for every new line break.

 
1158 code active 2005 Mar anonymous VDBE 2005 Mar   1 1 core dump on solaris, edit
some sqlite functions core dumped on solaris. I tracked this back to a byte alignment problem in Vdbeint.h. I added the __attribute__ ((__aligned__(16))) to the zshort character string.

/*
** A single level of the stack or a single memory cell
** is an instance of the following structure.
*/
struct Mem {
  int i;              /* Integer value */
  int n;              /* Number of characters in string value, including '\0' */
  int flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
  double r;           /* Real value */
  char *z   ;         /* String value */
  char zShort[NBFS] __attribute__ ((__aligned__(16)));  /* Space for short strings */
};
typedef struct Mem Mem;
2005-Mar-09 22:06:47 by anonymous:
I think this is a duplicate of bug #700.... simply adding the attribute seems to reslove the bug... select the sum of an integer column, to reproduce....

sqlite> select sum(seqval) from tbl; Bus Error(coredump)

 
1149 code active 2005 Feb anonymous   2005 Feb   2 1 VACUUM, DUMP/RESTORE fail in certain cases edit
When a database has interacting views, such as the following:

CREATE VIEW test1 AS SELECT * FROM tableA;
CREATE VIEW test AS SELECT COUNT(*) FROM test1;
then a dump and restore fails, because the views will be created in the alphabetical order of the table names, rather than the order of their dependence. Thus, the create of table test will fail. Because the script otherwise runs to completion, the restore will usually be adequate except that the views are not recreated.

VACUUM appears to fail the same way, probably for the same reason. In this case, however, the VACUUM fails without clearly alerting the user.

I ran into this problem trying to VACUUM a large file, which produced the otherwise inexplicable error message about the syntax of a dependent view definition.

Users can workaround, once the problem is understood, either by renaming views so that their names have alphabetical sequence consistent with their dependency, or by dropping them prior to a vacuum or dump/restore and then recreating them later.

Of course, the view order can be repaired in the dump file, but this usually requires patience with a powerful text editor, and some capacity to understand the problem.

 
1142 code active 2005 Feb anonymous Parser 2005 Feb danielk1977 1 1 Column names edit
  create table a (id, x);
  create table b (id, y);
  insert into a values (1,1);
  insert into b values (1,2);
  select * from a inner join b;

column names returned: id,x,id,y How am I supposed to use such column names? Ouwey.

2005-Mar-15 07:28:43 by anonymous:
This bug breaks existing applications where 'SELECT rowid, * FROM table' was used to open any table and then precompiled statements were used to update the changed record by using 'UPDATE table SET <field1>=?, <field2>=? ... WHERE rowid=?'. We cannot update to sqlite v3.1.x because of this.


2005-Mar-15 08:36:31 by drh:
There are lots of people telling me the current behavior is wrong. But nobody has yet suggested what the correct behavior should be. Until I know what the correct behavior should be, there is little I can do to fix the problem.

Rather than just telling me the current behavior is wrong, please offer an explanation of what the correct behavior should be. What do Oracle and PostgreSQL do in the same situation?


2005-Mar-16 09:04:30 by anonymous:
Dr. Hipp, very sorry for the confusion I've caused! My comments were actually targeted at bug #1141! I've included the same remarks there.

As for this bug: I can only tell you how SQL Server reacts:

select * from a inner join b Line 1: Incorrect syntax near 'b'.

select * from a inner join b on a.id = b.id

id x id y

1 1 1 2

So SQL Server behaves like sqlite in returning column names, although it doesn't accept the syntax 'select * from a inner join b'

I guess this behavior is normal and it's the programmer's resposability to use aliases in sql statement. Just my personal oppinion, though.

 
1134 code active 2005 Feb anonymous   2005 Feb drh 3 3 select command with a view and a condition gets no result edit
In a view with more than one tables it is no longer possible to use that view within a select command; the columns of the view are not found.
 
1112 code active 2005 Feb anonymous   2005 Feb   3 4 make test failures (108 out of 19721) on AIX 5.2, Power5 CPU edit
Platform is an IBM p5-570 running AIX 5.2. sqlite built with

  CC=xlc ./configure --enable-shared=NO --disable-shared \
                     --enable-static=YES    \
                     --enable-tempstore     \
                     --enable-threads=POSIX \
                     --enable-tempdb-in-ram

and GNU make.

'make test' ends with '108 errors out of 19721 tests'. Here are the lines that did not end with Ok:

  attach2-4.12...
  Expected: [0 {}]
       Got: [1 {disk I/O error}]
  attach2-4.15...
  Expected: [1 2 1 2]
       Got: [1 2]
  attach2-5.2...
  Error: disk I/O error
  autovacuum-ioerr-5.56.3...
  Expected: [1]
       Got: [0]
  bigfile-1.2...
  Error: file is encrypted or is not a database
  bigfile-1.3...
  Error: file is encrypted or is not a database
  bigfile-1.4...
  Error: file is encrypted or is not a database
  bigfile-1.5...
  Error: file is encrypted or is not a database
  bigfile-1.6...
  Error: file is encrypted or is not a database
  bigfile-1.7...
  Error: file is encrypted or is not a database
  bigfile-1.8...
  Error: file is encrypted or is not a database
  bigfile-1.9...
  Error: file is encrypted or is not a database
  bigfile-1.10...
  Error: file is encrypted or is not a database
  bigfile-1.11...
  Error: file is encrypted or is not a database
  bigfile-1.12...
  Error: file is encrypted or is not a database
  bigfile-1.13...
  Error: file is encrypted or is not a database
  bigfile-1.14...
  Error: file is encrypted or is not a database
  bigfile-1.15...
  Error: file is encrypted or is not a database
  bigfile-1.16...
  Error: file is encrypted or is not a database
  ioerr-5.53.3...
  Expected: [1]
       Got: [0]
  misc4-5.2...
  Expected: [a 1 b 2 a:1 1 c 3]
       Got: []
  misc4.test did not close all files: 1
  notnull.test did not close all files: 1
  null.test did not close all files: 1
  pager.test did not close all files: 1
  pager2.test did not close all files: 1
  pager3.test did not close all files: 1
  pagesize.test did not close all files: 1
  pragma.test did not close all files: 1
  printf.test did not close all files: 1
  progress.test did not close all files: 1
  quote.test did not close all files: 1
  reindex.test did not close all files: 1
  rollback.test did not close all files: 1
  rowid.test did not close all files: 1
  safety.test did not close all files: 1
  schema.test did not close all files: 1
  select1.test did not close all files: 2
  time with cache: 895550 microseconds per iteration
  time without cache: 2262076 microseconds per iteration
  select2.test did not close all files: 2
  select3.test did not close all files: 2
  select4.test did not close all files: 2
  select5.test did not close all files: 2
  select6.test did not close all files: 2
  select7.test did not close all files: 2
  sort.test did not close all files: 2
  subquery.test did not close all files: 2
  subselect.test did not close all files: 2
  table-8.1...
  Expected: [desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all]
       Got: []
  table-8.1.1...
  Expected: [{CREATE TABLE t2(
    "desc" text,
    "asc" text,
    "key" int,
    "14_vac" boolean,
    fuzzy_dog_12 varchar(10),
    "begin" blob,
    "end" clob
  )}]
       Got: []
  table-8.3...
  Expected: [cnt 1 max(b+c) 5]
       Got: []
  table-8.3.1...
  Expected: [{CREATE TABLE "t4""abc"(cnt,"max(b+c)")}]
       Got: []
  table-8.4...
  Expected: [y'all 1]
       Got: []
  table-8.5...
  Error: no such table: t4"abc
  table-8.6...
  Error: no such table: t2
  table.test did not close all files: 3
  tableapi.test did not close all files: 3
  tclsqlite.test did not close all files: 3
  temptable.test did not close all files: 3
  thread1.test did not close all files: 3
  trace.test did not close all files: 3
  trans-6.1...
  Expected: [a 1 b 2 c 3]
       Got: []
  trans-6.3...
  Expected: [p 1 q 2 r 3]
       Got: []
  trans-6.4...
  Expected: [a 4 b 5 c 6]
       Got: []
  trans-6.5...
  Expected: [p 1 q 2 r 3]
       Got: []
  trans-6.6...
  Expected: [a 4 b 5 c 6]
       Got: []
  trans-6.7...
  Expected: [1 {no such table: t1}]
       Got: [1 {cannot commit - no transaction is active}]
  trans-6.10...
  Error: table t1 already exists
  trans-6.12...
  Expected: [p 1 q 2 r 3]
       Got: []
  trans-6.13...
  Expected: [a 4 b 5 c 6]
       Got: []
  trans-6.14...
  Expected: [p 1 q 2 r 3]
       Got: []
  trans-6.15...
  Expected: [a 4 b 5 c 6]
       Got: []
  trans-6.16...
  Expected: [1 {no such table: t1}]
       Got: [1 {cannot commit - no transaction is active}]
  trans-6.20...
  Error: table t1 already exists
  trans-6.21...
  Expected: [4 -5 -6 1 -2 -3]
       Got: []
  trans-6.22...
  Expected: [1 -2 -3 4 -5 -6]
       Got: []
  trans-6.23...
  Expected: [4 -5 -6 1 -2 -3]
       Got: []
  trans-6.24...
  Expected: [4 -5 -6 1 -2 -3]
       Got: []
  trans-6.25...
  Expected: [1 -2 -3 4 -5 -6]
       Got: []
  trans-6.26...
  Expected: [4 -5 -6 1 -2 -3]
       Got: []
  trans-6.27...
  Expected: [4 -5 -6 1 -2 -3]
       Got: []
  trans-6.28...
  Expected: [1 -2 -3 4 -5 -6]
       Got: []
  trans.test did not close all files: 4
  trigger-10.3...
  Error: disk I/O error
  trigger-10.7...
  Error: disk I/O error
  trigger-10.10...
  Error: disk I/O error
  trigger-10.11...
  Expected: [main 21 22 23 temp 24 25 26 aux 27 28 29]
       Got: [main 21 22 23]
  trigger1.test did not close all files: 4
  trigger2.test did not close all files: 4
  trigger3.test did not close all files: 4
  trigger4.test did not close all files: 4
  trigger5.test did not close all files: 4
  trigger6.test did not close all files: 4
  types.test did not close all files: 4
  types2.test did not close all files: 4
  unique.test did not close all files: 4
  update.test did not close all files: 4
  vacuum.test did not close all files: 4
  varint.test did not close all files: 4
  view-3.3...
  Expected: [xyz 2 pqr 7 c-b 1]
       Got: []
  view-3.4...
  Expected: [b 2 b 3 b 5 b 6]
       Got: []
  view-3.5...
  Expected: [y 2 y 3 y 5 y 6]
       Got: []
  view-8.1...
  Error: no such column: pqr
  view-8.2...
  Error: no such table: v6
  view-8.3...
  Error: no such table: main.v6
  view-8.6...
  Error: no such table: v6
  view-8.7...
  Error: no such table: v6
  view.test did not close all files: 5
  where.test did not close all files: 5
  108 errors out of 19721 tests

  Failures on these tests: attach2-4.12 attach2-4.15 attach2-5.2
  autovacuum-ioerr-5.56.3 bigfile-1.2 bigfile-1.3 bigfile-1.4 
  bigfile-1.5 bigfile-1.6 bigfile-1.7 bigfile-1.8 bigfile-1.9 
  bigfile-1.10 bigfile-1.11 bigfile-1.12 bigfile-1.13 bigfile-1.14 
  bigfile-1.15 bigfile-1.16 ioerr-5.53.3 misc4-5.2 misc4.test 
  notnull.test null.test pager.test pager2.test pager3.test 
  pagesize.test pragma.test printf.test progress.test quote.test 
  reindex.test rollback.test rowid.test safety.test schema.test 
  select1.test select2.test select3.test select4.test select5.test 
  select6.test select7.test sort.test subquery.test subselect.test 
  table-8.1 table-8.1.1 table-8.3 table-8.3.1 table-8.4 table-8.5 
  table-8.6 table.test tableapi.test tclsqlite.test temptable.test 
  thread1.test trace.test trans-6.1 trans-6.3 trans-6.4 trans-6.5 
  trans-6.6 trans-6.7 trans-6.10 trans-6.12 trans-6.13 trans-6.14 
  trans-6.15 trans-6.16 trans-6.20 trans-6.21 trans-6.22 trans-6.23 
  trans-6.24 trans-6.25 trans-6.26 trans-6.27 trans-6.28 trans.test 
  trigger-10.3 trigger-10.7 trigger-10.10 trigger-10.11 trigger1.test 
  trigger2.test trigger3.test trigger4.test trigger5.test 
  trigger6.test types.test types2.test unique.test update.test 
  vacuum.test varint.test view-3.3 view-3.4 view-3.5 view-8.1 view-8.2
  view-8.3 view-8.6 view-8.7 view.test where.test
 
1100 code active 2005 Feb anonymous   2005 Feb   3 3 make test segfaults at capi2-7.12 on amd64 system edit
System is Gentoo Linux 2004.1 on Opteron processor; gcc v3.3.3, creating 64 bit binaries.

Here is a traceback:

  capi2-7.11... Ok
  capi2-7.11a... Ok
  capi2-7.12...
  Program received signal SIGSEGV, Segmentation fault.
  0x0000002a95b25830 in strlen () from /lib/libc.so.6
  (gdb) where
  #0  0x0000002a95b25830 in strlen () from /lib/libc.so.6
  #1  0x000000000043991c in sqlite3VdbeList (p=0x5aab60) at  src/vdbeaux.c:528
  #2  0x0000000000438737 in sqlite3_step (pStmt=0x13000a6023d0064)
     at src/vdbeapi.c:207
  #3  0x0000000000416a80 in test_step (clientData=0x13000a6023d0064, 
    interp=0x55a450, objc=0, objv=0x4) at src/test1.c:2070
  #4  0x0000002a956978fe in TclEvalObjvInternal () from  /usr/lib/libtcl8.4.so
  #5  0x0000002a956ba181 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #6  0x0000002a956b9648 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #7  0x0000002a956e4f66 in TclObjInterpProc () from /usr/lib/libtcl8.4.so
  #8  0x0000002a956978fe in TclEvalObjvInternal () from /usr/lib/libtcl8.4.so
  #9  0x0000002a956982d8 in Tcl_EvalEx () from /usr/lib/libtcl8.4.so
  #10 0x0000002a95698097 in Tcl_EvalTokensStandard () from /usr/lib/libtcl8.4.so
  #11 0x0000002a95698273 in Tcl_EvalEx () from /usr/lib/libtcl8.4.so
  #12 0x0000002a95698767 in Tcl_EvalObjEx () from /usr/lib/libtcl8.4.so
  #13 0x0000002a956e4a93 in Tcl_UplevelObjCmd () from /usr/lib/libtcl8.4.so
  #14 0x0000002a956978fe in TclEvalObjvInternal () from /usr/lib/libtcl8.4.so
  #15 0x0000002a956ba181 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #16 0x0000002a956b9648 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #17 0x0000002a956e4f66 in TclObjInterpProc () from /usr/lib/libtcl8.4.so
  #18 0x0000002a956978fe in TclEvalObjvInternal () from /usr/lib/libtcl8.4.so
  #19 0x0000002a956982d8 in Tcl_EvalEx () from /usr/lib/libtcl8.4.so
  #20 0x0000002a95698767 in Tcl_EvalObjEx () from /usr/lib/libtcl8.4.so
  #21 0x0000002a956e4a93 in Tcl_UplevelObjCmd () from /usr/lib/libtcl8.4.so
  #22 0x0000002a956978fe in TclEvalObjvInternal () from /usr/lib/libtcl8.4.so
  #23 0x0000002a956ba181 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #24 0x0000002a956b9648 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #25 0x0000002a95698815 in Tcl_EvalObjEx () from /usr/lib/libtcl8.4.so
  #26 0x0000002a9569c486 in Tcl_CatchObjCmd () from /usr/lib/libtcl8.4.so
  #27 0x0000002a956978fe in TclEvalObjvInternal () from  /usr/lib/libtcl8.4.so
  #28 0x0000002a956ba181 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #29 0x0000002a956b9648 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #30 0x0000002a95698815 in Tcl_EvalObjEx () from /usr/lib/libtcl8.4.so
  #31 0x0000002a9569ef7e in Tcl_IfObjCmd () from /usr/lib/libtcl8.4.so
  #32 0x0000002a956978fe in TclEvalObjvInternal () from /usr/lib/libtcl8.4.so
  #33 0x0000002a956ba181 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #34 0x0000002a956b9648 in TclCompEvalObj () from /usr/lib/libtcl8.4.so
  #35 0x0000002a956e4f66 in TclObjInterpProc () from /usr/lib/libtcl8.4.so
  #36 0x0000002a956978fe in TclEvalObjvInternal () from /usr/lib/libtcl8.4.so
  #37 0x0000002a956982d8 in Tcl_EvalEx () from /usr/lib/libtcl8.4.so
  #38 0x0000002a956d1e41 in Tcl_FSEvalFile () from  /usr/lib/libtcl8.4.so
  #39 0x0000002a956d120e in Tcl_EvalFile () from /usr/lib/libtcl8.4.so
  #40 0x0000000000424641 in main (argc=2, argv=0x7fbffff138)
     at src/tclsqlite.c:1744
  (gdb)
2005-Feb-04 23:11:02 by anonymous:
Some more information from a gdb session (I added the printf at line 527 and recompiled; the line numbers below will be off by one from the stack trace above):

  (gdb) up
  #1  0x000000000043996d in sqlite3VdbeList (p=0x5aab60) at src/vdbeaux.c:529
  529         pMem->n = strlen(pMem->z);
  (gdb) list 525,535
  525
  526         pMem->flags = MEM_Static|MEM_Str|MEM_Term;
  527     printf("src/vdbeaux.c sqlite3VdbeList pOp->opcode= %d\n", pOp->opcode);
  528         pMem->z = sqlite3OpcodeNames[pOp->opcode];  /* Opcode */
  529         pMem->n = strlen(pMem->z);
  530         pMem->type = SQLITE_TEXT;
  531         pMem->enc = SQLITE_UTF8;
  532         pMem++;
  533
  534         pMem->flags = MEM_Int;
  535         pMem->i = pOp->p1;                          /* P1 */
  (gdb) p pOp->opcode
  $1 = 40 '('
  (gdb) p pMem->z
  $2 = 0x175002100200173 <Address 0x175002100200173 out of bounds>
 
1085 code active 2005 Jan anonymous   2005 Jan   2 3 pragma full_column_names and short_column_names still broken edit
the following statement :

  SELECT T1.*,D1.*
  FROM test T1,dt D1
  WHERE T1.id=D1.id

does not give "long" column names, even if full_column_names is ON.

But, the following does:

  SELECT T1.ID,D1.NAME
  FROM test T1,dt D1
  WHERE T1.id=D1.id

in other words, tablename prefix is applied only to explicit columns, not to "*" selected columns.

 
1078 code active 2005 Jan anonymous   2005 Jan   2 3 Lemon destructor bugs that don't affect sqlite edit
I found a few bugs Lemon's destructor handling code. I don't think that they affect sqlite, but the do affect other grammars.

- The code that collapses cases for default destructors erroneously assumes that all symbols have the same type.

- If a reduction rule doesn't have code, then the RHS symbols will not have their destructors called.

- The default destructor shouldn't be called on the auto-generated "error" symbol

- In the internal function "append_str", zero-length strings may be returned un-terminated.

I have some proposed fixes that I'll try to attach to this ticket.

2005-Jan-14 13:33:52 by drh:
Do you also have some test grammars? That would really be helpful.


2005-Jan-14 17:14:15 by anonymous:
Sure. Here is one grammar that will demonstrate the "Tokens leak when rule has no code" bug:

 
%token_type { char * }
%token_destructor 
{ 
    printf("Deleting token '%s' at %x\n", $$, (int)$$); 
    free($$); 
}
result ::= nt. 
nt ::= FOO BAR.
Running the following code against the grammar should theoretically show 2 allocations and two destructions. It won't though, unless you modify the rule for nt to have an empty body, like:
nt ::= FOO BAR. {}
char *mkStr(const char *s)
{
    printf("Allocating '%s' at 0x%x\n", s, (int)(s));
    return strdup(s);
}

int main(int argc, char **argv)
{
    void *parser = ParseAlloc(malloc);
    Parse(parser, FOO, mkStr("foo"));
    Parse(parser, BAR, mkStr("bar"));
    Parse(parser, 0, 0);
    ParseFree(parser, free);
    return 0;
}



2005-Jan-14 17:50:26 by anonymous:
Here is another test grammar. This one demonstrates (a) default destructors being called on the 'error' symbol, and (b) problems with default destructors being called on the wrong symbol type.

%token_type { char * }
%token_destructor { delete [] $$; }
%default_destructor { delete $$; }

%type result { int }
%destructor result { }
result ::= fooStruct barStruct. { }

%type fooStruct { Foo * }
fooStruct(lhs) ::= FOO(f). { lhs = new Foo(f); }

%type barStruct { Bar * }
barStruct(lhs) ::= BAR(b). { lhs = new Bar(b); }
Here is the code generated by lemon (with comments added & removed for clarity):

typedef union {
  ParseTOKENTYPE yy0;
  int yy4;
  Bar * yy5; 
  Foo * yy7; 
  int yy15;
} YYMINORTYPE;

static const char *const yyTokenName[] = { 
  "$",             "FOO",           "BAR",           "error",       
  "result",        "fooStruct",     "barStruct",   
};


static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
  switch( yymajor ){
    case 1:
    case 2:
{ delete [] (yypminor->yy0); }
      break;
    case 3: /* error */
    case 5: /* fooStruct of type "Foo *"  */ 
    case 6: /* barStruct of type "Bar *"  */ 
#line 3 "typeBug.y"
{ delete (yypminor->yy5); }  /* Yikes! yy5 is a "Bar *" */
#line 308 "typeBug.c"
      break;
    case 4:
#line 6 "typeBug.y"
{ }
#line 313 "typeBug.c"
      break;
    default:  break;   /* If no destructor action specified: do nothing */
  }
}
 
709 code active 2004 Apr anonymous Unknown 2005 Jan drh 1 1 Unable to unregister or replace functions edit
I believe this started with 2.8.13, as it did work previously. There appears to be a show-stopper with unregistering or replacing existing functions. Specifically, if one tries to replace (or remove by passing nulls) one of the built-in functions, for example "like" or "upper", the function does not get replaced, and is in fact still called and available. The odd thing is that if you try to replace one of the functions with an underscore, such as "change_count", it works fine! This is causing problems as we replace a lot of the existing functions, and allow users to add and replace their own functions, which are now failing.
2004-Apr-26 20:56:19 by anonymous:
Alright, turns out this is due to mismatch in argument count when unregistering functions. It would be useful if we could unregister all instances of a function name, irregardless of argument counts.


2004-Apr-26 23:11:43 by anonymous:
Turns out there really is a bug... the problem is in the sqliteFindFunction function's matching of inexact argument counts, when being called from sqliteExprCheck with >0 argument count. This is the scenario. I override the "upper" function with my own, but first removing the old "upper", specifying 1 argument and null for the function. I then register a new "upper" with -1 for the argument count, and a valid function.

When sqliteFindFunction attempts to locate the upper function, It locates the new function, but because it is registered with -1, it tries to find a better match. It then runs into the original one, and because it has a null function pointer, it fails. This causes sqliteExprCheck to try again with -1 as the count, and since that matches, it reports an error of wrong_num_args.

Unfortunately this means there is no way to override an existing method (it would be good if we could just delete them, rather than override them, although I still think this behaviour with -1 is wrong).


2004-Apr-26 23:29:23 by anonymous:
I've applied the following patch in the sqliteFindFunction function, that I believe addresses the problem:

/* Change this 
  if( p && !createFlag && p->xFunc==0 && p->xStep==0 ){
    return 0;
  }
*/
/* To this */
  if( p && !createFlag && p->xFunc==0 && p->xStep==0 ){
    return pMaybe;
By returning pMaybe we provide a function that will work, while returning 0 if no variable argument function was found.
 
1063 code active 2005 Jan anonymous   2005 Jan   1 3 Lemon bug: Strings in rule code should not be interpreted edit
There are two related bugs in the lemon parser related to processing code snippets defined in rule actions.

Here is a simple grammar that demonstrates the problem:

%include { extern int line_number; extern const char *file_name; }

result(r) ::= TOKEN(s). { printf("BAD: Got a token on line '%d'\n", line_number); printf("BAD: \tFile = '%s'\n", file_name); r = s; }

The first bug is that the "%d" in the first printf is interpreted by the append_str function, when it shouldn't be, producing code that looks like: printf("BAD: Got a token on line '0d'\n", line_number); I believe that the solution is to have append_str() NOT do %d substitution when it is copying the code.

The second bug is that the "s" in the "%s" format is being interpreted as a symbolic name, producing code that looks like: printf("BAD: \tFile = '%yymsp[0].minor.yy0'\n", file_name);

I believe that the solution is to have translate_code() ignore symbolic names inside of quoted strings.

 
969 code new 2004 Oct anonymous TclLib 2005 Jan   3 3 PRAGMA empty_result_callbacks not working in tclsqlite-3.0.8.so part 2 edit
Referencing ticket # 967, I stated that it was the tclsqlite code that was not functioning properly, not the ./sqlite3 executable.

Here is a script that you can use to reproduce the issue. As you can see the results are quite different.

#----------->
load ./lib/tclsqlite-3.0.8.so sqlite3
puts [info patchlevel]
sqlite3 db :memory:
db eval "create table t1(a,b);"
puts "before 3.0.8 select, no pragma"
db eval "select * from t1;" x {
        puts "x(*) = $x(*)"
}
db eval "PRAGMA empty_result_callbacks=1"
puts "before 3.0.8 select, yes pragma"
db eval "select * from t1;" x {
        puts "x(*) = $x(*)"
}
db close
load ./lib/tclsqlite-2.8.15.so Tclsqlite
sqlite db2 :memory:
db2 eval "create table t1(a,b);"
puts "before 2.8.15 select, no pragma"
db2 eval "select * from t1;" x {
        puts "x(*) = $x(*)"
}
db2 eval "PRAGMA empty_result_callbacks=1"
puts "before 2.8.15 select, yes pragma"
db2 eval "select * from t1;" x {
        puts "x(*) = $x(*)"
}
db2 close
puts "done"
# <-------------------

and the results:

$ tclsh test_sqlite.tcl
8.4.3
before 3.0.8 select, no pragma
before 3.0.8 select, yes pragma
before 2.8.15 select, no pragma
before 2.8.15 select, yes pragma
x(*) = a b
done
2006-May-16 18:29:44 by anonymous:
This is still a problem in the 3.3.5 version of the tclsqlite library. The tclsqlite.c code never calls the callback code on empty results when PRAGMA empty_result_callbacks=1 is set.
 
1058 code active 2005 Jan anonymous BTree 2005 Jan   3 3 btree.c pageSize -> usableSize edit
Check-in [2125] was a fix for Ticket #1010, but left out some of the fixes proposed in the ticket. I'm not sure whether this was an oversight or an intentional omission. I tried to re-open the ticket, but those edits didn't persist (I'm not sure why).

Here are the remaining instances of pageSize that I believe should be changed to usableSize in btree.c:

  --- sqlite/src/btree.c.ORIG	Wed Nov 24 18:54:30 2004
  +++ sqlite/src/btree.c	Wed Nov 24 20:29:21 2004
  @@ -220,13 +220,13 @@
   /* The following value is the maximum cell size assuming a maximum page
   ** size give above.
   */
  -#define MX_CELL_SIZE(pBt)  (pBt->pageSize-8)
  +#define MX_CELL_SIZE(pBt)  (pBt->usableSize-8)

   /* The maximum number of cells on a single page of the database.  This
   ** assumes a minimum cell size of 3 bytes.  Such small cells will be
   ** exceedingly rare, but they are possible.
   */
  -#define MX_CELL(pBt) ((pBt->pageSize-8)/3)
  +#define MX_CELL(pBt) ((pBt->usableSize-8)/3)

   /* Forward declarations */
   typedef struct MemPage MemPage;
  @@ -1745,7 +1745,7 @@
     Pgno finSize;   /* Pages in the database file after truncation */
     int rc;           /* Return code */
     u8 eType;
  -  int pgsz = pBt->pageSize;  /* Page size for this database */
  +  int pgsz = pBt->usableSize;/* Usable bytes on each page */
     Pgno iDbPage;              /* The database page to move */
     MemPage *pDbMemPage = 0;   /* "" */
     Pgno iPtrPage;             /* The page that contains a pointer to iDbPage */
 
1056 code active 2004 Dec anonymous Shell 2004 Dec   3 3 test pragma-9.4 fails during second pass in "make fulltest" edit
During a "make fulltest" run, the pragma tests appear to run twice. On the first run, pragma-9.4 runs properly. On the second run, it gives an error:

  pragma-9.4...
  Expected: []
       Got: [/Volumes/Local/Users/sqlite/test/bld]

(where the path listed is the build directory for this build of sqlite).

The pragma-9.4 test is a recent addition to sqlite.

This is currently the only failure I'm seeing in a "make fulltest" of the current cvs tree on Mac OS X when the build/test directory is on a hard drive.

  1 errors out of 68411 tests
  Failures on these tests: pragma-9.4
  make: *** [fulltest] Error 1
 
1053 code active 2004 Dec anonymous Pager 2004 Dec   3 3 SQLITE_IOERR and strange rollback when db is busy edit
Environment on which bug was found:
Windows XP, both SP1 and SP2, on different computers. The SQLite library was built using the precompiled source from the download page (as static library).

Description of bug scenario:

One process performs very long reads from a db (multiple joins, so the cartesian product is very large, and the reader needs a while to complete).

Another process performs a BEGIN TRANSACTION , then executes lots of INSERT INTO ... VALUES .
At some point, this process will end up in sqlite3pager_get, when it tries to read some page from the database file (the main file, not a temp file or a journal). It detects that the page is not in the page cache (it ends up in the 'else' branch of if( pPg==0 ) ). It runs down to the block of code covered by the following comment:

     /* Write the page to the database file if it is dirty.
     */

In this block, pager_write_pagelist( pPg ) returns with SQLITE_BUSY. As a consequence, the changes are rolled back and SQLITE_IOERR is returned.

And here seems to be the problem: First, the database file is locked, so I don't understand why the SQLITE_BUSY value isn't propagated back to the caller. If SQLITE_BUSY would be returned, then the application could restart the command. Seconds, sqlite3VdbeHalt decides to perform a sqlite3BtreeRollbackStmt, so only the last command should be rolled back. However, this is not what happens! In fact, all commands back to the beginning of the transaction are rolled back; the transaction, however is not closed. Doesn't this violate the default rollback behaviour (roll back last command, keep transaction open)? As a consequence, even if the application would get SQLITE_BUSY, it couldn't properly react on it.

There are other places in sqlite3pager_get where SQLITE_IOERR are returned; I've not checked whether these can also be triggered by the db being locked or if they indicate serious problem.

I will attach the code I used to reproduce and track down the problem, together with a Visual Studio 2003 project.

If you extract the archive, on toplevel you will find the following:

  • Reader: the directory containing the source for the reader
  • Writer: the directory contaiing the source for the writer
  • SQLite: A directory in which to place the precompiled source for windows users, which is used to build the library. If you want to use the provided project file with Visual Studio, just copy the source in there and everything will build with a single mouse click.
  • BugDemo.sln: The Visual Studio project file.
  • bugdemo.sql: The SQL statements used to create the test database.

How to reproduce:

  • Create a database using bugdemo.sql
  • Adapt reader.cpp and writer.cpp to include the sqlite3 headers, and set the define at the top of the files to the path of the test database.
  • Compile everything.
  • Start the reader.
  • Start the writer, and wait until it reports an error (for me, it takes < 30 seconds).

I tried to keep the source portable, so it shouldn't be too hard to make it compile on Unix.

 
1026 code active 2004 Dec anonymous Unknown 2004 Dec   3 3 sqlite automake sqlite3.pc file does not have version information edit
When the configure of sqlite has been done, the sqlite3.pc file does not have information in the Version: section. This means there's no way to check for versions in other autogen/configure files concerning the sqlite version in the system, style:

PKG_CHECK_MODULES(SQLITE, sqlite >= 3.0.3, AC_MSG_ERROR([$SQLITE_PKG_ERRORS]))

 
923 code active 2004 Sep anonymous   2004 Sep anonymous 3 2 Missing quotes in 2.8.15 .dump cause data loss when loading in sqlite3 edit
When converting a database by means of the command:

  sqlite old.db .dump | sqlite3 new.db

the content of char/varchar fields is dumped by sqlite without quotes (e.g. 00001) and then when reloaded by sqlite3 it looses the heading zeroes (i.e. becomes '1', which is a really different thing for an alphanumeric field).

This could be solved by a new release (sqlite 2.8.16 ?) which add quotes to alphanumeric fields (as sqlite3 does), or by a filter script that adds the quotes to the sqlite2 .dump output (I used a quick and dirty perl script to fix my dump...).

2005-Jul-11 20:08:11 by anonymous:
This does not appear to be solved in sqlite 2.8.16.
 
841 code active 2004 Aug anonymous Unknown 2004 Aug   3 2 inner group by query isn't honored by outer count(*) aggregate edit
  CREATE TEMP TABLE A(a int NOT NULL, b int NOT NULL, c int NOT NULL);
  INSERT INTO A VALUES (1, 1, 1);
  INSERT INTO A VALUES (1, 2, 1);
  INSERT INTO A VALUES (2, 1, 1);

  -- typical behaviour is for this to behave like the DISTINCT query below
  -- but instead it shows a=1 as having occured twice (but it was grouped in the inner query)
  SELECT a, count(*) FROM (
    SELECT a, c FROM A GROUP BY 1, 2) GROUP BY a;
  Result:
  2|1
  1|2

  -- shows a=1 as having occured once (correctly)
  SELECT a, count(*) FROM (
    SELECT DISTINCT a, c FROM A) GROUP BY a;
  Result:
  2|1
  1|1

  -- the top query performs better, which is why I am reporting this bug
2004-Aug-08 18:42:00 by drh:
SQLite ignores the ORDER BY clause if there are no aggregate functions.
 
832 code active 2004 Jul anonymous Unknown 2004 Jul anonymous 4 4 os_win.c :: sqlite3OsUnlock() method has an unused variable: rc edit
os_win.c :: sqlite3OsUnlock() method has an unused variable: rc
 
822 code active 2004 Jul anonymous Unknown 2004 Jul drh 1 4 port of sqlite to dos with djgpp + small general bugfixes edit
here is a diff to be applied on sqlite 2.8.14 to make it work with djgpp.

some of the fixes are needed for general purpose, such as relative path handling, and bypass of history and readline wherever not present.

anyway, i see no harm to apply this patch to mainstream sqlite. port for version 2.8.15 will come soon.

best regards,

alex <alexbodn@012.net.il>

 
798 code active 2004 Jul anonymous Unknown 2004 Jul   1 1 Unable to run tests on Tru64 bit Linux platform edit
I was able to compile SQLite 3.0.2 on a RedHat 64-bit Linux system; however, when running the tests I would get a segmentation fault when executing a blob test. I was wondering if anyone has attempted to build SQLite for a 64-bit architecture and run all tests successfully. If so I was hoping to get any configuration parameters needed.
 
783 code active 2004 Jun anonymous Unknown 2004 Jun   3 3 Build on MAC with -DSQLITE_DEBUG=1 compile error edit
MacOS 10.3.4 gcc 3.3

Compileing with -DSQLITE_DEBUG=1 gives following error

./libtool --mode=compile gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DSQLITE_DEBUG=1 -I. -I../sqlite/src -DTHREADSAFE=0 -c ../sqlite/src/os_unix.c gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DSQLITE_DEBUG=1 -I. -I../sqlite/src -DTHREADSAFE=0 -c ../sqlite/src/os_unix.c -fno-common -DPIC -o .libs/os_unix.o ../sqlite/src/os_unix.c: In function `sqlite3OsRead': ../sqlite/src/os_common.h:31: error: inconsistent operand constraints in an `asm' make: *** [os_unix.lo] Error 1

 
763 code active 2004 Jun anonymous Unknown 2004 Jun   5 4 tclsqlite.dll not showing the correct version edit
The TCL binding of SQLite indicates that the current binary version available for download is 2.0 (determined with the "package require sqlite" command). I suppose that's because tclsqlite.c has the following statement in it: tcl_PkgProvide(interp, "sqlite", "2.0");

Is it possible that the binary distribution of tclsqlite.dll is really version 2.8 and NOT 2.0? It could be that the reference to version # 2.0 in tclsqlite.c needs to be corrected to some other number!

 
754 code active 2004 Jun anonymous Shell 2004 Jun drh 2 3 problem opening a dbfile in the upper directory (../dbname) edit
there is a problem in the calculation of a full path name based on a relative path name in an uproot location (../).

i have fixed this during my porting to dos, and the relevant diff is at http://www.sqlite.org/cvstrac/tktview?tn=524.

best regards

alex

 
744 code active 2004 May anonymous BTree 2004 May anonymous 2 2 make test seg faults on x86_64 Linux edit
I'm running the 64 bit version of Gentoo Linux on an AMD Opteron system. Ordinarily I'd install software with "emerge <package>" but "emerge sqlite" only gives me version 2.8.11. I downloaded the 2.8.13 source and did the usual ./configure; make; make test. The configure and make steps went OK but make test fails half way through:

bind-1.99... Ok

btree-1.1... Ok

btree-1.1.1... Ok

btree-1.2... Ok

btree-1.3... Ok

btree-1.4... Ok

btree-1.4.1... Ok

btree-1.5... Ok

btree-1.6...make: *** [test] Segmentation fault

The code was built with GCC 3.3.3.

As sqlite is a known 'emerge' option for 64 bit Gentoo I'm guessing sqlite is known to work on 64 bit platforms?

I didn't mark this as a severe error because in theory I should be able to create a statically linked executable on a 32 bit linux system and run this on the Opteron box. Haven't been successful at that yet however.

2004-May-25 04:35:32 by anonymous:
It's pretty clear that sqlite has never been compiled on a 64-bit system, much less run. The test problems are fatal bugs caused by type conversions between 64-bit and 32-bit values, including truncating pointers and other sins. The fixes look quite involved.
 
735 code active 2004 May anonymous Shell 2004 May   4 3 .sqliterc not processed if running on a driver other than C: edit
In shell.c there is a snippet that reads:

if (!home_dir) { home_dir = getenv("HOMEPATH"); /* Windows? */ }

The HOMEPATH environment variable does not include the drive letter and needs to be concatenated with the HOMEDRIVE environment variable.

2004-May-12 14:43:40 by anonymous:
That should read "drive" in the title, not "driver"
 
656 code active 2004 Mar anonymous Unknown 2004 May   5 5 The 'sum' and 'avg' functions don't work on Solaris (UNIX) edit
I have a database that was created by a previous version of Sqlite. I tried to find the average age of the people in the database. "age" was declared as an integer in the create part. The odd thing is that both 'sum' ans 'age' seem to work fine under Windows but not under UNIX (I am using Solaris!). Also, when I used a very old version of Sqlite, the 'age' and 'sum' functions worked.

Bob

The sum() and avg() functions work correctly for the 194 and 111 cases (respectively) where they are used in the test suite. This trouble report is too vague to be useful. Without additional information, there is little that can be done to address the issue.

Information missing from the trouble report:

  • What is meant by "it doesn't work". Does it get the wrong answer? Is there an error message? Does the program crash?

  • What was the input data? Be specific. Provide the table schema. Vague references to "age" are not helpful. How many entries are in the table? How many of those entries are NULL?

  • What is the exact text of the query that failed?

  • What was the version number of SQLite that originally created the database? What version number of SQLite does sum() and avg() work for? Saying "an earlier version" is not helpful. There are 127 earlier versions.


2004-May-11 04:31:48 by anonymous:
I have the same problem. The version of SQLite is the latest 2.8.13, and we are running Solaris as well. The definition statement for the table is

CREATE TABLE alert_source ( src NOT NULL, dst NOT NULL, tcp NOT NULL, udp NOT NULL, icmp NOT NULL, first NOT NULL, last NOT NULL, );

The view made for it is

create view sum_view as select tcp+udp+icmp as cnt, * FROM alert_source;

This query core dumps:

select sum(cnt) from sum_view;

It isn't too complicated but it definitely dumps in as many permutations of a summarizing select statement as I can come up with....

 
721 code active 2004 May anonymous Shell 2004 May drh 3 2 empty .databases information edit
in file shell.c around line 570 the callback_data structure needs to be added:

  data.cnt = 0;

so the column widths are correctly used. or else, it will display empty lines.

this problem is visible after executing one sql command

 
700 code active 2004 Apr anonymous VDBE 2004 Apr   2 3 Solaris-sparc segfaults on sum() edit
On Solaris (sparc) trying to do a sum() (sometimes) SEGVs: this is because the result is placed in a chunk of memory which is allocated as a char * and therefore isn't aligned to 16-byte boundaries (which SPARC-Solaris seems to want).

One fix for this which seems to work for me is to change vdbeInt.h:118 to

  char zShort[NBFS]  __attribute__ ((__aligned__(16)));  /* Space for short strings */

and change sqlite_aggregate_context to assign p->pAgg to zShort rather than z (since z is malloc()ed you can't align it) - I don't know if this would cause problems elsewhere though.

2004-Apr-22 16:10:37 by dougcurrie:
malloc() should always return memory aligned for any purpose; I don't think this is the problem.

Looking at the function sqlite_aggregate_context though, I wonder:

  • where is p->z initialized?
  • where is p->pAgg sqliteFree()d?
  • what happens when sqlite_aggregate_context and sqlite_set_result_string share Mem.zShort?


2004-Apr-23 09:58:03 by anonymous:
> malloc() should always return memory aligned for any purpose; I don't think this is the problem.

I didn't make it clear: I'm getting a Bus Error, not just a normal SEGV.

There are several places mentioned on the web which suggests that solaris' malloc() aligns memory to 8-byte boundaries, while (on 64-bit, I assume) a double is 128 bits... however you're correct, the manpage does insist that all malloc()s are aligned to data large enough for any purpose. I suppose if s.z isn't even assigned at this point (but hasn't been cleared at initialisation) it might contain something completely non-aligned.

However I now can't reproduce the problem, although that's not to say that it means the thing isn't broken... I'll try and break it again and let you know.

As to your other point: the reason I posted was because of exactly this: I don't know the code well enough (I'd never heard of it until yesterday!) to be able to say whether .zShort could be used elsewhere at the same time as a sum() function.


2004-Apr-23 10:35:11 by anonymous:
Aha. A core file lying around may well help.


...
Program terminated with signal 10, Bus Error.

...
#0  0xff33d4a4 in sumStep (context=0x2a158, argc=203556, argv=0x3ac08)
    at src/func.c:421
421         p->sum += sqliteAtoF(argv[0], 0);
...
(gdb) list
416     static void sumStep(sqlite_func *context, int argc, const char **argv){
417       SumCtx *p;
418       if( argc<1 ) return;
419       p = sqlite_aggregate_context(context, sizeof(*p));
420       if( p && argv[0] ){
421         p->sum += sqliteAtoF(argv[0], 0);
422         p->cnt++;
423       }
424     }

....

(gdb) print &p.sum
$5 = (double *) 0x31b24
Now my basic maths (a hex 16-byte aligned number should end in 0, right?) says that somehow p.sum has become misaligned by 4 bytes.

sqlite_aggregate_sum simply assigns p->pAgg to p->s.z and returns p->pAgg, which means that p->s.z is misaligned also.

Further investigation makes more worrying reading:

(gdb) print *context
$18 = {pFunc = 0x75736572, s = {i = 0, n = 0, flags = 16, z = 0x0,
    r = 3.6586602629506839e-309,
    zShort = '\000' <repeats 11 times>, "\020\000\000\000\000\000\002¡\230", '\000' <repeats 11 times>}, pAgg = 0x10, isError = 0 '\000', isStep = 0 '\000',
  cnt = 172464}
Note that pAgg is 0x10 (!?) and s.z is 0. Something seriously unhappy going on there: I think it's likely there's some corruption going on due to some specific set of events which was being run.

I'll rerun the exact scenario and try again.


2004-May-03 02:27:25 by anonymous:
i have seen this exact same problem on sparc/solaris. my core looks exactly the same. it really does look like an alignment issue.


2004-Jul-12 13:09:26 by anonymous:
I had this exact problem on solaris 8 with gcc3.3.4 and well, every version of sqlite over 2.5.

Heres my solution, hopefully it will help someone with more time and IQ points to figure out the real problem

After forcing PTR_FMT to %x in test1.c (so i can run all the tests) I changed src/vbdeInt.h #define NBFS from 32 to 15 (one less than a long double on a sparc) thus forcing all long doubles to be malloced.

This allowed me to run all the tests (and my application) bus error free. 5 of the tests failed, which looks like a precision problem and seems harmless in my applications.

date-1.19... Expected: [2451545.00000116] Got: [2451545.00000] date-1.20... Expected: [2451545.00000012] Got: [2451545.00000] date-1.21... Expected: [2451545.00000001] Got: [2451545.00000]

expr-2.4... Expected: [0.525641025641026] Got: [0.52564102564] expr-2.5... Expected: [1.90243902439024] Got: [1.90243902439]


2004-Jul-17 12:26:31 by anonymous:
I found a better solution than my changing NBFS solution. from what little info i found, doubles in a structure are aligned to 8. so align zShort to 8 and it works with NBFS as 32. change PTR_FMT to %X instead of %x and it passes all the tests.
 
698 code active 2004 Apr anonymous Unknown 2004 Apr   1 3 .mode list - not going to next line edit
To create a comma delimited output file:
------------------------------------------------
C:\SQLite>sqlite locate.db
SQLite version 2.8.13
Enter ".help" for instructions
sqlite> .mode list
sqlite> .separator ", "
sqlite> .output data.cdf
sqlite> select * from parts;
sqlite> .quit

That should create a text file of something like this:
1st rec field 1, 1st rec field 2, 1st rec field 3, 1st rec field 4
2nd rec field 1, 2nd rec field 2, 2nd rec field 3, 2nd rec field 4
3rd rec field 1, 3rd rec field 2, 3rd rec field 3, 3rd rec field 4

but it does not provide a line break after each record, so the output looks like this:

1st rec field 1, 1st rec field 2, 1st rec field 3, 1st rec field 42nd rec field 1, 2nd rec field 2, 2nd rec field 3, 2nd rec field 43rd rec field 1, 3rd rec field 2, 3rd rec field 3, 3rd rec field 4

Each record is butted up against the previous record, without even a space. This is inconsitant with the instruction on how it is supposed to work, via this page:

http://www.sqlite.org/sqlite.html

Also, can you please refer me to somewhere that would explain how I can use SQLite with a batchfile, EG: using a batchfile to add a record, delete a record, query, Etc...

Thanks,

Tom

 
691 code active 2004 Apr anonymous Unknown 2004 Apr drh 1 1 OS X File Sharing edit
Hello Sir:

This ticket may be considered a duplicate of ticket #301. I am unable to access SQLite databases from HFS or SMB network shares when using Mac OS X (10.3.3) as a client.

The more technical aspects of the problem are explained well in ticket #301.

I am using SQLabs SQLite plugin for RealBasic 5.5, and would like to use SQLite exclusively as my DB.

I am concerned that the original ticket was submitted approximately one year ago. So I am submitting this to see if this issue is being addressed, and if there is a timetable set for its resolution.

Thank you,

Tony Dellos Milwaukee WI

 
685 code active 2004 Apr anonymous CodeGen 2004 Apr   1 3 SELECT from a VIEW with GROUP BY edit
When you SELECT from a VIEW (which is having a GROUP BY statement) and try to apply another GROUP BY statement you get:

  $ sqlite ../../db/main.db
  SQLite version 2.8.13
  Enter ".help" for instructions
  sqlite> .dump prod_elem_totals
  BEGIN TRANSACTION;
  CREATE VIEW prod_elem_totals AS
    SELECT
      pe.elem_id AS elem_id, p.prod_id AS prod_id, e.name AS name,
      p.name AS p_name, pe.count AS count,
      SUM(b.count) / pe.count AS p_max,
      SUM(b.count) AS total, SUM(b.price * b.count) / SUM(b.count) AS price,
      e.min AS min
    FROM
      products AS p, elements AS e, batches AS b, prod_elems AS pe
    WHERE
      p.prod_id = pe.prod_id AND
      pe.elem_id = b.elem_id AND
      pe.elem_id = e.elem_id
    GROUP BY
      p.prod_id,
      pe.elem_id
    ORDER BY
      e.name;
  COMMIT;
  sqlite> SELECT * FROM prod_elem_totals GROUP BY elem_id;
  sqlite: src/select.c:1775: flattenSubquery: Assertion `p->pGroupBy==0' failed.
  Aborted

It seams it doesn't matter which column I GROUP BY. I can prepare a full test case if needed.

Maybe somehow connected with #678.

After further investigation I found that when I add a aggregate function like "SUM (count * 10) AS min" it works...

 
684 code active 2004 Apr anonymous Unknown 2004 Apr   3 2 Incorrect function result type when using SQLITE_ARGS edit
I registered a function using the SQLITE_ARGS return type. I then execute the statement "select test('sample')". The type information returned from sqlite_step in the pazColName is incorrectly reported as "NUMERIC". If I use a "0", specifying the first column, instead of SQLITE_ARGS when registering the function, the return value is correctly set to "TEXT".
 
575 code active 2004 Jan anonymous VDBE 2004 Mar drh 3 3 pragma (default_)temp_store implementations seems incomplete edit
This problem is a conflict between documented behaviour and actual behaviour, and could fall in the 'Documentation' category as well.

There seems to be a problem with 'pragma default_temp_store'. In pragma.c code exists to handle it, and that code stores the provided value in Cookie 5 (as VDBE instruction argument; that is the sixth metadata integer, and would correspond to meta[6] in sqliteInitOne() in main.c).

However, the code loading a database (the aforementioned sqliteInitOne() in main.c) never looks at that value, and the setting is ignored. (Also, Vacuum doesn't seem to copy it.)

A related problem is that using the default_temp_store or temp_store pragma's doesn't work as advertised, at least not in the precompiled commandline tool sqlite.exe: you will always get the following error, even if you use the pragma at init time:

   SQL error: The temporary database already exists - its location cannot now be changed

Trying to set the flag (the value at offset 0x50 in a database file) to 2 (attempting to force an in-memory database for temp tables) with a hex editor has only partial success: the handcrafted value is reported by pragma default_temp_store; but typing .databases still shows a file name for the temporary data base, and using the filemon tool (a windows file activity monitor, downloadable from www.sysinternals.com) shows that the temp file is actually accessed when giving a 'create temp table' command (not surprising, if there is no code to actually ever initialize the db->temp_store from the Cookie).

If for some reason it is infeasible to circumvent the issue that the temp table will always be open before executing the pragma, I suggest changing the semantics of pragma default_temp_store to only change the default (as stored in the file), but not change the current value. This would allow executing pragma default_temp_store even while a temp table is open (though its effect will only be visible when the database is opened again).

Note that this issue has a few documentation issues:

  • lang.html suggests that pragma default_temp_store and pragma temp_store are currently working. At least in the commandline tool they aren't (I didn't make a dedicated test program to see if the problem already exists at the C-API level)
  • fileformat.html doesn't document the location where the temp_store flag is stored. In fact, I consider the fact that the fifth meta value (meta[5] a.k.a. Cookie 4) is seemingly not used anywhere slightly suspicious.
  • the number of metadata values is documented inconsistently in fileformat.html: in one place it mentions there are 6 values including the two leading values (which makes 4 metavalues), a bit later 9 metavalues are mentioned...
 
666 code active 2004 Mar anonymous Unknown 2004 Mar anonymous 5 4 Error message indicates wrong error edit
This is just a message problem. When creating objects if the object alread exists (be it table, view) you always get the table already exist error. Perhapes a change to object alread exists would be better
 
637 code active 2004 Mar anonymous Parser 2004 Mar   5 4 union uses non-standard column names edit
for other dbms, such as postgresql, mysql, etc, issuing a

  select x as name,
         y as value
    from first_table
  union
  select x,
         y
    from second_table

will produce a resultset with column names of 'name' and 'value' (the first resultset). in sqlite it will produce a resultset with column names of 'x' and 'y' (the last resultset). Code causing this appears to be in multiSelect function in src/select.c.

 
627 code active 2004 Feb anonymous   2004 Feb   3 3 sqliteRunVacuum returning wrong code? edit
The last 3 lines of sqliteRunVacuum, as of the version checked in on Feb 12 2004, are:

  if( rc==SQLITE_ABORT ) rc = SQLITE_ERROR;
  if( sVac.rc!=SQLITE_OK ) rc = sVac.rc;
  return sVac.rc;

It seems suspicious to set a local variable, rc, that one is never going to use again. I suspect that the last line should be

return rc;

2004-Feb-27 00:54:03 by anonymous:
The fix by check-in 1271 still doesn't look right to me. If one of the execsql calls returns SQLITE_CANTOPEN (which I have seen happen), then rc will be SQLITE_CANTOPEN and sVac.rc will be 0, and sqliteRunVacuum will return 0.
 
608 code active 2004 Feb anonymous   2004 Feb   3 3 Problem with "pragma show_datatypes = on" and busy timeout edit
When a busy timeout is set, pragma show_datatypes = on and SQLite sleeps some time on the lock, no datatypes are passed to the exec callback function.

The attachment is an archive with a Makefile, a shell script and a program that reproduce the error.

2004-Feb-12 21:05:28 by anonymous:
This problem breaks the auto-typing feature of PySQLite when a busy timeout is used.
 
369 code active 2003 Jun anonymous   2004 Jan   3 2 Testsuite fails on btree-1.1.1 (Mac OS X, SQLite 2.8.4) edit
On Mac OS X the testsuite fails:

  btree-1.1.1..../src/btree.c:2687: failed assertion `pPage->isInit'
  make: *** [test] Abort trap  

SQLite version: 2.8.4, OS Version: 10.2.6

Obtained same result. Mac OS X 10.2.6, Developer Tools Dec 2002, SQLite 2.8.5.
Shared libraries are busted on Macs. As far as I can tell, this appears to be Apple's fault. Until a workaround is devised, do not attempt to compile using shared libraries. Add the --disable-shared option to the configure script:

    ../sqlite/configure --disable-shared


On 2.8.5+, this shows up on 2689. Also, configure does not allow the use of --disable-shared (probably requries a fix in the configure scripts). On a G5 in 10.3.2, this error shows up as a Bus Error. Builds work fine otherwise. This issue may be related to the warnings received in src/test1.c thru src/test4.c and in src/tclsqlite.c regarding Tcl_SetVar, Tcl_GetInt, Tcl_GetBoolean, Tcl_GetIndexFromObj. All warnings are regarding promotion of arguments to pointers of invalid type. oso2k/Louis


2004-Feb-11 22:57:17 by anonymous:
I did some quick testing of 2.8.12 on the machines I have available to me. In general, there seems to be more warnings than I remember (I believe I was testing 2.8.9 from cvs before it went live).

  • G3 700MHz/640MB iBook 10.2.8
    Same results as we last spoke. Fails make test at:
    btree-1.1.1

  • Dual G4 800MHz/1.25GB 10.2.8
    Same results as we last spoke. Fails make test at:
    btree-1.1.1

  • G5 1.6GHz/1.25GB 10.3.2
    Something really weird happens here. There is no longer a bus error. Right after make test gets past bigfile-1.1, the machine seems to enter an infinite loop or something.
 
414 code active 2003 Jul anonymous VDBE 2003 Nov   3 4 sqlite_compile() and database schema changes edit
If you compile a query using sqlite_compile(), and then change the database schema using the same db handle, SQLite doesn't detect this. The following program demonstrates:

  void corrupt_query(char * filename)
  {
        sqlite *db;
        sqlite_vm *vm;
        int rc;

        db = sqlite_open(filename, 0, 0);
        assert(db);

        sqlite_exec(db, "DROP TABLE tbl;", 0, 0, 0);
        sqlite_exec(db, "CREATE TABLE tbl(a, b);", 0, 0, 0);
        sqlite_compile(db, "SELECT * FROM tbl;", 0, &vm, 0);
        sqlite_exec(db, "DROP TABLE tbl;", 0, 0, 0);

        /* This next line causes an assert() in the memory db or an SQLITE_CORRUPT
         * with the real db.  This is because the program stored in vm tries to
         * open a cursor to a table that no longer exists.
         */
        rc = sqlite_step(vm, 0, 0, 0);
        printf("sqlite_step returned %d, \"%s\"\n", rc, sqlite_error_string(rc));

        sqlite_close(db);
  }

  int main( int argc, char ** argv )
  {
        corrupt_query("cookie_test.db");
        corrupt_query(":memory:");
        return 0;
  }

It seems unlikely to happen in practice, but I imagine there is a series of operations you could perform using this loophole that would corrupt the database file.

äääüüüü""&5
 
395 code active 2003 Jul anonymous Unknown 2003 Jul   4 4 Error opening db on Mac OS X not reported correctly edit
When sqlite is passed a directory as the database to open on Mac OS X it doesn't report an immediate error, only when you run any command does it fail.

     e.g..
$ mkdir 1
$ sqlite 1
SQLite version 2.8.4
Enter ".help" for instructions
sqlite> .schema
Error: database is locked
sqlite> 

where on Linux it reports as I expect the code intends with: Unable to open database "contrib": disk I/O error

I've tracked it down as far as I can into sqlite_open at line 162 where it calls sqliteInit - sorry my C knowhow runs out at this point.

I'm more than happy to test any patches that you would like.

Also I have a feeling this is related to ticket #304 that you weren't able to reproduce - presumably its a Mac OS X only problem too.

Regards, PeterW.

I've done some more poking about with this and it looks like the problem boils down to the line "s = fcntl(id->fd, F_SETLK, &lock);" in sqliteOsReadLock in os.c.

On Mac OS X fcntl returns EISDIR when the file to lock is a directory rather than EINVAL so that the check a line or so down returns SQLITE_BUSY. On Linux this returns SQLITE_OK which causes the pager to try and find a page and causes an error when it tries to read from the directory which ends up failing with a disk I/O error.

If I change the check to be:

    rc = (errno==EINVAL || errno==EISDIR) ? SQLITE_NOLFS : SQLITE_BUSY;

then passing a directory name to open fails with the predictable error of no large file support which certainly doesn't seem like the right thing to do in this instance.

Does it make to have a check right at the beginning of sqlite_open to see if the file to open is a regular file and so stop this much earlier if something other than a regular file is passed in?

 
403 code active 2003 Jul anonymous   2003 Jul   4 4 Two small fixes in .spec file for RPMS edit
1. The sqlite.pc isn't packaged in the sqlite-devel package. Simply add in the package %files section: %{_libdir}/pkgconfig/*.pc

2. There is not %post and %postun: Need to run /sbin/ldconfig in both sections.

 
330 code active 2003 May anonymous VDBE 2003 May   3 4 Aggregator's error are ignored edit
Any error set by aggregator functions using sqlite_set_result_error() is ignored and returned as the aggregator's result.

In vdbe.c, the AggNext and AggReset operators implementation do not check the context's isError attribute after the xFinalize function is called. Errors reported by normal functions works fine.

Additional note on errors from aggregates: there is an requirement (and corresponding assert in the code) that sqlite_set_result_error will never be called from xStep callback. So it is required to wait for the first xFinalize call, this leads to allocation of extra memory to remember that an error is occured.

Can it be allowed to call this function from xStep callback ?

 
301 code active 2003 Apr anonymous Unknown 2003 Apr   2 3 Can't acquire lock for database on Mac OS X AppleShare volume edit
I'm using SQLite on Mac OS X 10.2.5. If I try to do a SELECT from a database that resides on an AppleShare volume (from my code or from sqlite), SQLite says that it's locked, even if no other process is using it. It appears that sqliteOsReadLock always returns SQLITE_BUSY for files on AppleShare volumes. I've temporarily solved the problem here by disabling SQLite's locking code and implementing higher-level protections in my application.

You may find this link helpful: http://developer.apple.com/technotes/tn/tn2037.html

2004-Mar-22 11:21:56 by anonymous:
under OSX fcntl returns ENOTSUP (45) = Operation Not Supported when trying to open a DB on AFP or SMB. Local HD is fine (HFS) as well as on USB devices HFS and UFS. Even with the recommendations from Apple's technote tn2037 the problem persists.
 
2864 doc active 2007 Dec anonymous   2007 Dec   5 3 ext/fts3/README.txt edit
File ext/fts3/README.txt reads: This folder contains source code to the second full-text search [...]

Shouldn't that be: This folder contains source code to the third full-text search [...]

2007-Dec-30 18:27:08 by anonymous:
Oh, after Googl'ing a little bit, I found that fts3 really is fts2-with-rowid-fixed.

If both fts2 and fts3 are considered to be the "second full-text search extension for SQLite", the README files could maybe explain the situation.

 
2856 doc active 2007 Dec anonymous   2007 Dec anonymous 4 3 SQLite Documentation - Tcl API - Link broken edit
On the page "The Tcl Interface to the SQLite library", the link "enable load extension" does not work.
 
2808 doc active 2007 Nov anonymous   2007 Nov   4 2 Documentation GIF images take up too much space edit
The GIF format used for the documentation images takes up too much space. I believe that this is in strict contrast to the "small" feature of SQLite.

Converting the GIFs to PNG images saves up to 181 KB (64%) of the documentation storage space:

  Documentation images as is (mostly GIF): 381 KB == 100%
  Documentation images as PNG:             292 KB ==  77%
  Documentation images as PNG 16 colors:   137 KB ==  36%

16 colors are more than plenty -- the diagrams show no visibility degradation. You might even cut it down to 8 colors to save even more ...

 
2729 doc active 2007 Oct anonymous   2007 Oct   1 1 Lemon: %fallback, %wildcard, and @X uncodumented edit
I noticed that the lemon documentation does not mention the %fallback and %wildcard directives. Both are in the code and are apparently doing useful work in SQLite's parse.y. Can other users benefit from them as well?

The symbol @X is also undocumented. From a source code comment I read that it "If the argument is of the form @X then substituted the token number of X, not the value of X". A short documentation example would help to understand where and how it can be useful to apply this syntax.

Are there other nice but undocumented Lemon goodies lacking documentation?

 
2629 doc active 2007 Sep anonymous   2007 Sep   4 4 typo in os_unix.c for nolock edit
Index: src/os_unix.c
===================================================================
RCS file: /sqlite/sqlite/src/os_unix.c,v
retrieving revision 1.165
diff -u -3 -p -r1.165 os_unix.c
--- src/os_unix.c       5 Sep 2007 13:56:32 -0000       1.165
+++ src/os_unix.c       6 Sep 2007 17:53:47 -0000
@@ -2126,7 +2126,7 @@ static const sqlite3_io_methods sqlite3D

 /*
 ** This vector defines all the methods that can operate on an sqlite3_file
-** for unix with dotlock style file locking.
+** for unix with nolock style file locking.
 */
 static const sqlite3_io_methods sqlite3NolockLockingUnixIoMethod = {
   1,                        /* iVersion */
 
2595 doc active 2007 Aug anonymous   2007 Aug   4 4 sqlite3_commit_hook doc typo edit
src/main.c:

  -** Register a function to be invoked when a transaction comments.
  +** Register a function to be invoked when a transaction commits.
 
2582 doc active 2007 Aug anonymous   2007 Aug anonymous 5 5 documenation clarification edit
docs for topic `Set A Busy Timeout` int sqlite3_busy_timeout(sqlite3*, int ms); http://sqlite.org/capi3ref.html#sqlite3_busy_timeout

the wording "The handler will sleep multiple times until at least "ms" milliseconds of sleeping have been done" implies it will wait the total amount regardless of the lock status, it should perhaps indicate in the same sentence that it will exit early if the lock becomes available.

 
2442 doc active 2007 Jun anonymous   2007 Jun   1 4 mailing list link doesn't always exist in website header edit
The header at the website doesn't always show the "mailing list" link. It is shown on http://www.sqlite.org/contrib but not on the front page. Other problems exist, like the header graphic at http://www.sqlite.org/contrib doesn't link to the top page.

It would be best to have the menu consistent over all pages that it exists on, and to have the graphic link back to the top page.

 
2427 doc active 2007 Jun anonymous   2007 Jun   4 3 HTML Tidy warnings on new capi3ref.html edit
HTML Tidy (http://tidy.sourceforge.net) produces a large number of warnings on the newly generated http://www.sqlite.org/capi3ref.html.

The warnings could cause problems with certain HTML browsers. It might be worth fixing the auto-generation script accordingly.

Here is the list:

  line 1 column 1 - Warning: missing <!DOCTYPE> declaration
  line 2 column 1 - Warning: inserting implicit <body>
  line 3 column 1 - Warning: discarding unexpected <body>
  line 336 column 1 - Warning: missing </a> before <h2>
  line 337 column 5 - Warning: inserting implicit <a>
  line 338 column 13 - Warning: inserting implicit <a>
  line 338 column 13 - Warning: missing </a> before <pre>
  line 352 column 1 - Warning: missing </a> before <h2>
  line 353 column 5 - Warning: inserting implicit <a>
  line 354 column 13 - Warning: inserting implicit <a>
  line 354 column 13 - Warning: missing </a> before <pre>
  line 368 column 1 - Warning: missing </a> before <h2>
  line 369 column 5 - Warning: inserting implicit <a>
  line 370 column 13 - Warning: inserting implicit <a>
  line 370 column 13 - Warning: missing </a> before <pre>
  line 380 column 1 - Warning: missing </a> before <h2>
  line 381 column 5 - Warning: inserting implicit <a>
  line 382 column 13 - Warning: inserting implicit <a>
  line 382 column 13 - Warning: missing </a> before <pre>
  line 398 column 6 - Warning: inserting implicit <p>
  line 402 column 1 - Warning: missing </a> before <h2>
  line 403 column 5 - Warning: inserting implicit <a>
  line 404 column 13 - Warning: inserting implicit <a>
  line 404 column 13 - Warning: missing </a> before <pre>
  line 415 column 1 - Warning: missing </a> before <h2>
  line 416 column 5 - Warning: inserting implicit <a>
  line 417 column 13 - Warning: inserting implicit <a>
  line 417 column 13 - Warning: missing </a> before <pre>
  line 434 column 1 - Warning: missing </a> before <h2>
  line 435 column 5 - Warning: inserting implicit <a>
  line 436 column 13 - Warning: inserting implicit <a>
  line 436 column 13 - Warning: missing </a> before <pre>
  line 454 column 1 - Warning: missing </a> before <h2>
  line 455 column 5 - Warning: inserting implicit <a>
  line 456 column 13 - Warning: inserting implicit <a>
  line 456 column 13 - Warning: missing </a> before <pre>
  line 473 column 1 - Warning: missing </a> before <h2>
  line 474 column 5 - Warning: inserting implicit <a>
  line 475 column 13 - Warning: inserting implicit <a>
  line 475 column 13 - Warning: missing </a> before <pre>
  line 485 column 1 - Warning: missing </a> before <h2>
  line 486 column 5 - Warning: inserting implicit <a>
  line 487 column 13 - Warning: inserting implicit <a>
  line 487 column 13 - Warning: missing </a> before <pre>
  line 504 column 1 - Warning: missing </a> before <h2>
  line 505 column 5 - Warning: inserting implicit <a>
  line 506 column 13 - Warning: inserting implicit <a>
  line 506 column 13 - Warning: missing </a> before <pre>
  line 515 column 1 - Warning: missing </a> before <h2>
  line 516 column 5 - Warning: inserting implicit <a>
  line 517 column 13 - Warning: inserting implicit <a>
  line 517 column 13 - Warning: missing </a> before <pre>
  line 525 column 1 - Warning: missing </a> before <h2>
  line 526 column 5 - Warning: inserting implicit <a>
  line 527 column 13 - Warning: inserting implicit <a>
  line 527 column 13 - Warning: missing </a> before <pre>
  line 544 column 7 - Warning: inserting implicit <p>
  line 554 column 1 - Warning: missing </a> before <h2>
  line 555 column 5 - Warning: inserting implicit <a>
  line 556 column 13 - Warning: inserting implicit <a>
  line 556 column 13 - Warning: missing </a> before <pre>
  line 569 column 1 - Warning: missing </a> before <h2>
  line 570 column 5 - Warning: inserting implicit <a>
  line 571 column 13 - Warning: inserting implicit <a>
  line 571 column 13 - Warning: missing </a> before <pre>
  line 589 column 1 - Warning: missing </a> before <h2>
  line 590 column 5 - Warning: inserting implicit <a>
  line 591 column 13 - Warning: inserting implicit <a>
  line 591 column 13 - Warning: missing </a> before <pre>
  line 648 column 1 - Warning: missing </a> before <h2>
  line 649 column 5 - Warning: inserting implicit <a>
  line 650 column 13 - Warning: inserting implicit <a>
  line 650 column 13 - Warning: missing </a> before <pre>
  line 666 column 1 - Warning: missing </a> before <h2>
  line 667 column 5 - Warning: inserting implicit <a>
  line 668 column 13 - Warning: inserting implicit <a>
  line 668 column 13 - Warning: missing </a> before <pre>
  line 694 column 1 - Warning: missing </a> before <h2>
  line 695 column 5 - Warning: inserting implicit <a>
  line 696 column 13 - Warning: inserting implicit <a>
  line 696 column 13 - Warning: missing </a> before <pre>
  line 707 column 1 - Warning: missing </a> before <h2>
  line 708 column 5 - Warning: inserting implicit <a>
  line 709 column 13 - Warning: inserting implicit <a>
  line 709 column 13 - Warning: missing </a> before <pre>
  line 722 column 1 - Warning: missing </a> before <h2>
  line 723 column 5 - Warning: inserting implicit <a>
  line 724 column 13 - Warning: inserting implicit <a>
  line 724 column 13 - Warning: missing </a> before <pre>
  line 735 column 1 - Warning: missing </a> before <h2>
  line 736 column 5 - Warning: inserting implicit <a>
  line 737 column 13 - Warning: inserting implicit <a>
  line 737 column 13 - Warning: missing </a> before <pre>
  line 749 column 1 - Warning: missing </a> before <h2>
  line 750 column 5 - Warning: inserting implicit <a>
  line 751 column 13 - Warning: inserting implicit <a>
  line 751 column 13 - Warning: missing </a> before <pre>
  line 764 column 1 - Warning: missing </a> before <h2>
  line 765 column 5 - Warning: inserting implicit <a>
  line 766 column 13 - Warning: inserting implicit <a>
  line 766 column 13 - Warning: missing </a> before <pre>
  line 796 column 1 - Warning: missing </a> before <h2>
  line 797 column 5 - Warning: inserting implicit <a>
  line 798 column 13 - Warning: inserting implicit <a>
  line 798 column 13 - Warning: missing </a> before <pre>
  line 837 column 1 - Warning: missing </a> before <h2>
  line 838 column 5 - Warning: inserting implicit <a>
  line 839 column 13 - Warning: inserting implicit <a>
  line 839 column 13 - Warning: missing </a> before <pre>
  line 855 column 1 - Warning: missing </a> before <h2>
  line 856 column 5 - Warning: inserting implicit <a>
  line 857 column 13 - Warning: inserting implicit <a>
  line 857 column 13 - Warning: missing </a> before <pre>
  line 876 column 1 - Warning: missing </a> before <h2>
  line 877 column 5 - Warning: inserting implicit <a>
  line 878 column 13 - Warning: inserting implicit <a>
  line 878 column 13 - Warning: missing </a> before <pre>
  line 889 column 1 - Warning: missing </a> before <h2>
  line 890 column 5 - Warning: inserting implicit <a>
  line 891 column 13 - Warning: inserting implicit <a>
  line 891 column 13 - Warning: missing </a> before <pre>
  line 907 column 1 - Warning: missing </a> before <h2>
  line 908 column 5 - Warning: inserting implicit <a>
  line 909 column 13 - Warning: inserting implicit <a>
  line 909 column 13 - Warning: missing </a> before <pre>
  line 928 column 1 - Warning: missing </a> before <h2>
  line 929 column 5 - Warning: inserting implicit <a>
  line 930 column 13 - Warning: inserting implicit <a>
  line 930 column 13 - Warning: missing </a> before <pre>
  line 948 column 1 - Warning: missing </a> before <h2>
  line 949 column 5 - Warning: inserting implicit <a>
  line 950 column 13 - Warning: inserting implicit <a>
  line 950 column 13 - Warning: missing </a> before <pre>
  line 976 column 1 - Warning: missing </a> before <h2>
  line 977 column 5 - Warning: inserting implicit <a>
  line 978 column 13 - Warning: inserting implicit <a>
  line 978 column 13 - Warning: missing </a> before <pre>
  line 989 column 1 - Warning: missing </a> before <h2>
  line 990 column 5 - Warning: inserting implicit <a>
  line 991 column 13 - Warning: inserting implicit <a>
  line 991 column 13 - Warning: missing </a> before <pre>
  line 1004 column 1 - Warning: missing </a> before <h2>
  line 1005 column 5 - Warning: inserting implicit <a>
  line 1006 column 13 - Warning: inserting implicit <a>
  line 1006 column 13 - Warning: missing </a> before <pre>
  line 1017 column 1 - Warning: missing </a> before <h2>
  line 1018 column 5 - Warning: inserting implicit <a>
  line 1019 column 13 - Warning: inserting implicit <a>
  line 1019 column 13 - Warning: missing </a> before <pre>
  line 1069 column 1 - Warning: missing </a> before <h2>
  line 1070 column 5 - Warning: inserting implicit <a>
  line 1071 column 13 - Warning: inserting implicit <a>
  line 1071 column 13 - Warning: missing </a> before <pre>
  line 1083 column 1 - Warning: missing </a> before <h2>
  line 1084 column 5 - Warning: inserting implicit <a>
  line 1085 column 13 - Warning: inserting implicit <a>
  line 1085 column 13 - Warning: missing </a> before <pre>
  line 1107 column 1 - Warning: missing </a> before <h2>
  line 1108 column 5 - Warning: inserting implicit <a>
  line 1109 column 13 - Warning: inserting implicit <a>
  line 1109 column 13 - Warning: missing </a> before <pre>
  line 1166 column 1 - Warning: missing </a> before <h2>
  line 1167 column 5 - Warning: inserting implicit <a>
  line 1168 column 13 - Warning: inserting implicit <a>
  line 1168 column 13 - Warning: missing </a> before <pre>
  line 1198 column 36 - Warning: discarding unexpected </p>
  line 1198 column 40 - Warning: using <br> in place of <p>
  line 1198 column 40 - Warning: replacing <p> by <br>
  line 1203 column 7 - Warning: inserting implicit <p>
  line 1215 column 7 - Warning: inserting implicit <p>
  line 1222 column 1 - Warning: missing </a> before <h2>
  line 1223 column 5 - Warning: inserting implicit <a>
  line 1224 column 13 - Warning: inserting implicit <a>
  line 1224 column 13 - Warning: missing </a> before <pre>
  line 1238 column 1 - Warning: missing </a> before <h2>
  line 1239 column 5 - Warning: inserting implicit <a>
  line 1240 column 13 - Warning: inserting implicit <a>
  line 1240 column 13 - Warning: missing </a> before <pre>
  line 1259 column 1 - Warning: missing </a> before <h2>
  line 1260 column 5 - Warning: inserting implicit <a>
  line 1261 column 13 - Warning: inserting implicit <a>
  line 1261 column 13 - Warning: missing </a> before <pre>
  line 1286 column 1 - Warning: missing </a> before <h2>
  line 1287 column 5 - Warning: inserting implicit <a>
  line 1288 column 13 - Warning: inserting implicit <a>
  line 1288 column 13 - Warning: missing </a> before <pre>
  line 1299 column 1 - Warning: missing </a> before <a>
  line 1300 column 1 - Warning: missing </a> before <a>
  line 1301 column 1 - Warning: missing </a> before <a>
  line 1302 column 1 - Warning: missing </a> before <a>
  line 1303 column 1 - Warning: missing </a> before <a>
  line 1304 column 1 - Warning: missing </a> before <a>
  line 1305 column 1 - Warning: missing </a> before <a>
  line 1306 column 1 - Warning: missing </a> before <a>
  line 1307 column 1 - Warning: missing </a> before <a>
  line 1308 column 1 - Warning: missing </a> before <a>
  line 1309 column 1 - Warning: missing </a> before <a>
  line 1310 column 1 - Warning: missing </a> before <a>
  line 1311 column 1 - Warning: missing </a> before <a>
  line 1312 column 1 - Warning: missing </a> before <a>
  line 1313 column 1 - Warning: missing </a> before <a>
  line 1314 column 1 - Warning: missing </a> before <a>
  line 1315 column 1 - Warning: missing </a> before <a>
  line 1316 column 1 - Warning: missing </a> before <a>
  line 1317 column 1 - Warning: missing </a> before <a>
  line 1318 column 1 - Warning: missing </a> before <a>
  line 1319 column 1 - Warning: missing </a> before <a>
  line 1320 column 1 - Warning: missing </a> before <a>
  line 1321 column 1 - Warning: missing </a> before <a>
  line 1322 column 1 - Warning: missing </a> before <a>
  line 1323 column 1 - Warning: missing </a> before <a>
  line 1324 column 1 - Warning: missing </a> before <a>
  line 1325 column 1 - Warning: missing </a> before <a>
  line 1326 column 1 - Warning: missing </a> before <a>
  line 1327 column 1 - Warning: missing </a> before <h2>
  line 1328 column 5 - Warning: inserting implicit <a>
  line 1329 column 13 - Warning: inserting implicit <a>
  line 1329 column 13 - Warning: missing </a> before <pre>
  line 1370 column 1 - Warning: missing </a> before <a>
  line 1371 column 1 - Warning: missing </a> before <a>
  line 1372 column 1 - Warning: missing </a> before <a>
  line 1373 column 1 - Warning: missing </a> before <a>
  line 1374 column 1 - Warning: missing </a> before <a>
  line 1375 column 1 - Warning: missing </a> before <a>
  line 1376 column 1 - Warning: missing </a> before <a>
  line 1377 column 1 - Warning: missing </a> before <a>
  line 1378 column 1 - Warning: missing </a> before <a>
  line 1379 column 1 - Warning: missing </a> before <a>
  line 1380 column 1 - Warning: missing </a> before <a>
  line 1381 column 1 - Warning: missing </a> before <a>
  line 1382 column 1 - Warning: missing </a> before <a>
  line 1383 column 1 - Warning: missing </a> before <a>
  line 1384 column 1 - Warning: missing </a> before <a>
  line 1385 column 1 - Warning: missing </a> before <a>
  line 1386 column 1 - Warning: missing </a> before <a>
  line 1387 column 1 - Warning: missing </a> before <a>
  line 1388 column 1 - Warning: missing </a> before <a>
  line 1389 column 1 - Warning: missing </a> before <a>
  line 1390 column 1 - Warning: missing </a> before <a>
  line 1391 column 1 - Warning: missing </a> before <a>
  line 1392 column 1 - Warning: missing </a> before <a>
  line 1393 column 1 - Warning: missing </a> before <a>
  line 1394 column 1 - Warning: missing </a> before <a>
  line 1395 column 1 - Warning: missing </a> before <a>
  line 1396 column 1 - Warning: missing </a> before <a>
  line 1397 column 1 - Warning: missing </a> before <a>
  line 1398 column 1 - Warning: missing </a> before <a>
  line 1399 column 1 - Warning: missing </a> before <a>
  line 1400 column 1 - Warning: missing </a> before <a>
  line 1401 column 1 - Warning: missing </a> before <h2>
  line 1402 column 5 - Warning: inserting implicit <a>
  line 1403 column 13 - Warning: inserting implicit <a>
  line 1403 column 13 - Warning: missing </a> before <pre>
  line 1455 column 1 - Warning: missing </a> before <a>
  line 1456 column 1 - Warning: missing </a> before <a>
  line 1457 column 1 - Warning: missing </a> before <a>
  line 1458 column 1 - Warning: missing </a> before <a>
  line 1459 column 1 - Warning: missing </a> before <a>
  line 1460 column 1 - Warning: missing </a> before <h2>
  line 1461 column 5 - Warning: inserting implicit <a>
  line 1462 column 13 - Warning: inserting implicit <a>
  line 1462 column 13 - Warning: missing </a> before <pre>
  line 1476 column 1 - Warning: missing </a> before <a>
  line 1477 column 1 - Warning: missing </a> before <a>
  line 1478 column 1 - Warning: missing </a> before <a>
  line 1479 column 1 - Warning: missing </a> before <h2>
  line 1480 column 5 - Warning: inserting implicit <a>
  line 1481 column 13 - Warning: inserting implicit <a>
  line 1481 column 13 - Warning: missing </a> before <pre>
  line 1501 column 6 - Warning: inserting implicit <p>
  line 1507 column 1 - Warning: missing </a> before <a>
  line 1508 column 1 - Warning: missing </a> before <h2>
  line 1509 column 5 - Warning: inserting implicit <a>
  line 1510 column 13 - Warning: inserting implicit <a>
  line 1510 column 13 - Warning: missing </a> before <pre>
  line 1523 column 1 - Warning: missing </a> before <a>
  line 1524 column 1 - Warning: missing </a> before <a>
  line 1525 column 1 - Warning: missing </a> before <a>
  line 1526 column 1 - Warning: missing </a> before <a>
  line 1527 column 1 - Warning: missing </a> before <a>
  line 1528 column 1 - Warning: missing </a> before <a>
  line 1529 column 1 - Warning: missing </a> before <a>
  line 1530 column 1 - Warning: missing </a> before <a>
  line 1531 column 1 - Warning: missing </a> before <a>
  line 1532 column 1 - Warning: missing </a> before <a>
  line 1533 column 1 - Warning: missing </a> before <h2>
  line 1534 column 5 - Warning: inserting implicit <a>
  line 1535 column 13 - Warning: inserting implicit <a>
  line 1535 column 13 - Warning: missing </a> before <pre>
  line 1569 column 1 - Warning: missing </a> before <a>
  line 1570 column 1 - Warning: missing </a> before <h2>
  line 1571 column 5 - Warning: inserting implicit <a>
  line 1572 column 13 - Warning: inserting implicit <a>
  line 1572 column 13 - Warning: missing </a> before <pre>
  line 1589 column 1 - Warning: missing </a> before <a>
  line 1590 column 1 - Warning: missing </a> before <h2>
  line 1591 column 5 - Warning: inserting implicit <a>
  line 1592 column 13 - Warning: inserting implicit <a>
  line 1592 column 13 - Warning: missing </a> before <pre>
  line 1615 column 1 - Warning: missing </a> before <a>
  line 1616 column 1 - Warning: missing </a> before <a>
  line 1617 column 1 - Warning: missing </a> before <a>
  line 1618 column 1 - Warning: missing </a> before <h2>
  line 1619 column 5 - Warning: inserting implicit <a>
  line 1620 column 13 - Warning: inserting implicit <a>
  line 1620 column 13 - Warning: missing </a> before <pre>
  line 1635 column 1 - Warning: missing </a> before <a>
  line 1636 column 1 - Warning: missing </a> before <a>
  line 1637 column 1 - Warning: missing </a> before <a>
  line 1638 column 1 - Warning: missing </a> before <a>
  line 1639 column 1 - Warning: missing </a> before <a>
  line 1640 column 1 - Warning: missing </a> before <a>
  line 1641 column 1 - Warning: missing </a> before <a>
  line 1642 column 1 - Warning: missing </a> before <a>
  line 1643 column 1 - Warning: missing </a> before <h2>
  line 1644 column 5 - Warning: inserting implicit <a>
  line 1645 column 13 - Warning: inserting implicit <a>
  line 1645 column 13 - Warning: missing </a> before <pre>
  line 1666 column 6 - Warning: inserting implicit <p>
  line 1711 column 1 - Warning: missing </a> before <a>
  line 1712 column 1 - Warning: missing </a> before <h2>
  line 1713 column 5 - Warning: inserting implicit <a>
  line 1714 column 13 - Warning: inserting implicit <a>
  line 1714 column 13 - Warning: missing </a> before <pre>
  line 1746 column 1 - Warning: missing </a> before <a>
  line 1747 column 1 - Warning: missing </a> before <a>
  line 1748 column 1 - Warning: missing </a> before <a>
  line 1749 column 1 - Warning: missing </a> before <a>
  line 1750 column 1 - Warning: missing </a> before <a>
  line 1751 column 1 - Warning: missing </a> before <a>
  line 1752 column 1 - Warning: missing </a> before <a>
  line 1753 column 1 - Warning: missing </a> before <a>
  line 1754 column 1 - Warning: missing </a> before <a>
  line 1755 column 1 - Warning: missing </a> before <h2>
  line 1756 column 5 - Warning: inserting implicit <a>
  line 1757 column 13 - Warning: inserting implicit <a>
  line 1757 column 13 - Warning: missing </a> before <pre>
  line 1805 column 49 - Warning: inserting implicit <p>
  line 1822 column 14 - Warning: inserting implicit <p>
  line 1833 column 41 - Warning: discarding unexpected </p>
  line 1833 column 45 - Warning: missing <li>
  line 1835 column 20 - Warning: discarding unexpected </p>
  line 1835 column 24 - Warning: missing <li>
  line 1838 column 6 - Warning: inserting implicit <p>
  line 1847 column 6 - Warning: inserting implicit <p>
  line 1855 column 1 - Warning: missing </a> before <a>
  line 1856 column 1 - Warning: missing </a> before <a>
  line 1857 column 1 - Warning: missing </a> before <a>
  line 1858 column 1 - Warning: missing </a> before <a>
  line 1859 column 1 - Warning: missing </a> before <a>
  line 1860 column 1 - Warning: missing </a> before <h2>
  line 1861 column 5 - Warning: inserting implicit <a>
  line 1862 column 13 - Warning: inserting implicit <a>
  line 1862 column 13 - Warning: missing </a> before <pre>
  line 1890 column 1 - Warning: missing </a> before <a>
  line 1891 column 1 - Warning: missing </a> before <h2>
  line 1892 column 5 - Warning: inserting implicit <a>
  line 1893 column 13 - Warning: inserting implicit <a>
  line 1893 column 13 - Warning: missing </a> before <pre>
  line 1916 column 1 - Warning: missing </a> before <a>
  line 1917 column 1 - Warning: missing </a> before <h2>
  line 1918 column 5 - Warning: inserting implicit <a>
  line 1919 column 13 - Warning: inserting implicit <a>
  line 1919 column 13 - Warning: missing </a> before <pre>
  line 1937 column 1 - Warning: missing </a> before <a>
  line 1938 column 1 - Warning: missing </a> before <h2>
  line 1939 column 5 - Warning: inserting implicit <a>
  line 1940 column 13 - Warning: inserting implicit <a>
  line 1940 column 13 - Warning: missing </a> before <pre>
  line 1958 column 1 - Warning: missing </a> before <a>
  line 1959 column 1 - Warning: missing </a> before <h2>
  line 1960 column 5 - Warning: inserting implicit <a>
  line 1961 column 13 - Warning: inserting implicit <a>
  line 1961 column 13 - Warning: missing </a> before <pre>
  line 1981 column 1 - Warning: missing </a> before <a>
  line 1982 column 1 - Warning: missing </a> before <a>
  line 1983 column 1 - Warning: missing </a> before <h2>
  line 1984 column 5 - Warning: inserting implicit <a>
  line 1985 column 13 - Warning: inserting implicit <a>
  line 1985 column 13 - Warning: missing </a> before <pre>
  line 2039 column 1 - Warning: missing </a> before <a>
  line 2040 column 1 - Warning: missing </a> before <h2>
  line 2041 column 5 - Warning: inserting implicit <a>
  line 2042 column 13 - Warning: inserting implicit <a>
  line 2042 column 13 - Warning: missing </a> before <pre>
  line 2108 column 1 - Warning: missing </a> before <a>
  line 2109 column 1 - Warning: missing </a> before <a>
  line 2110 column 1 - Warning: missing </a> before <h2>
  line 2111 column 5 - Warning: inserting implicit <a>
  line 2112 column 13 - Warning: inserting implicit <a>
  line 2112 column 13 - Warning: missing </a> before <pre>
  line 2139 column 1 - Warning: missing </a> before <a>
  line 2140 column 1 - Warning: missing </a> before <a>
  line 2141 column 1 - Warning: missing </a> before <h2>
  line 2142 column 5 - Warning: inserting implicit <a>
  line 2143 column 13 - Warning: inserting implicit <a>
  line 2143 column 13 - Warning: missing </a> before <pre>
  line 2157 column 1 - Warning: missing </a> before <a>
  line 2158 column 1 - Warning: missing </a> before <h2>
  line 2159 column 5 - Warning: inserting implicit <a>
  line 2160 column 13 - Warning: inserting implicit <a>
  line 2160 column 13 - Warning: missing </a> before <pre>
  line 2183 column 7 - Warning: inserting implicit <p>
  line 2183 column 39 - Warning: unescaped & or unknown entity "&azResult"
  line 2193 column 7 - Warning: inserting implicit <p>
  line 2204 column 1 - Warning: missing </a> before <a>
  line 2205 column 1 - Warning: missing </a> before <h2>
  line 2206 column 5 - Warning: inserting implicit <a>
  line 2207 column 13 - Warning: inserting implicit <a>
  line 2207 column 13 - Warning: missing </a> before <pre>
  line 2235 column 1 - Warning: missing </a> before <a>
  line 2236 column 1 - Warning: missing </a> before <h2>
  line 2237 column 5 - Warning: inserting implicit <a>
  line 2238 column 13 - Warning: inserting implicit <a>
  line 2238 column 13 - Warning: missing </a> before <pre>
  line 2257 column 1 - Warning: missing </a> before <a>
  line 2258 column 1 - Warning: missing </a> before <a>
  line 2259 column 1 - Warning: missing </a> before <h2>
  line 2260 column 5 - Warning: inserting implicit <a>
  line 2261 column 13 - Warning: inserting implicit <a>
  line 2261 column 13 - Warning: missing </a> before <pre>
  line 2298 column 20 - Warning: inserting implicit <p>
  line 2302 column 20 - Warning: inserting implicit <p>
  line 2305 column 20 - Warning: inserting implicit <p>
  line 2308 column 20 - Warning: inserting implicit <p>
  line 2317 column 20 - Warning: inserting implicit <p>
  line 2321 column 1 - Warning: missing </a> before <a>
  line 2322 column 1 - Warning: missing </a> before <h2>
  line 2323 column 5 - Warning: inserting implicit <a>
  line 2324 column 13 - Warning: inserting implicit <a>
  line 2324 column 13 - Warning: missing </a> before <pre>
  line 2352 column 1 - Warning: missing </a> before <a>
  line 2353 column 1 - Warning: missing </a> before <a>
  line 2354 column 1 - Warning: missing </a> before <a>
  line 2355 column 1 - Warning: missing </a> before <h2>
  line 2356 column 5 - Warning: inserting implicit <a>
  line 2357 column 13 - Warning: inserting implicit <a>
  line 2357 column 13 - Warning: missing </a> before <pre>
  line 2423 column 6 - Warning: discarding unexpected </p>
  line 2423 column 10 - Warning: missing <li>
  line 2435 column 1 - Warning: inserting implicit <p>
  line 2437 column 1 - Warning: missing </a> before <a>
  line 2438 column 1 - Warning: missing </a> before <h2>
  line 2439 column 5 - Warning: inserting implicit <a>
  line 2440 column 13 - Warning: inserting implicit <a>
  line 2440 column 13 - Warning: missing </a> before <pre>
  line 2457 column 1 - Warning: missing </a> before <a>
  line 2458 column 1 - Warning: missing </a> before <a>
  line 2459 column 1 - Warning: missing </a> before <a>
  line 2460 column 1 - Warning: missing </a> before <a>
  line 2461 column 1 - Warning: missing </a> before <a>
  line 2462 column 1 - Warning: missing </a> before <a>
  line 2463 column 1 - Warning: missing </a> before <a>
  line 2464 column 1 - Warning: missing </a> before <a>
  line 2465 column 1 - Warning: missing </a> before <a>
  line 2466 column 1 - Warning: missing </a> before <a>
  line 2467 column 1 - Warning: missing </a> before <a>
  line 2468 column 1 - Warning: missing </a> before <a>
  line 2469 column 1 - Warning: missing </a> before <a>
  line 2470 column 1 - Warning: missing </a> before <h2>
  line 2471 column 5 - Warning: inserting implicit <a>
  line 2472 column 13 - Warning: inserting implicit <a>
  line 2472 column 13 - Warning: missing </a> before <pre>
  line 2506 column 1 - Warning: missing </a> before <a>
  line 2507 column 1 - Warning: missing </a> before <a>
  line 2508 column 1 - Warning: missing </a> before <a>
  line 2509 column 1 - Warning: missing </a> before <a>
  line 2510 column 1 - Warning: missing </a> before <a>
  line 2511 column 1 - Warning: missing </a> before <a>
  line 2512 column 1 - Warning: missing </a> before <a>
  line 2513 column 1 - Warning: missing </a> before <a>
  line 2514 column 1 - Warning: missing </a> before <a>
  line 2515 column 1 - Warning: missing </a> before <a>
  line 2516 column 1 - Warning: missing </a> before <a>
  line 2517 column 1 - Warning: missing </a> before <h2>
  line 2518 column 5 - Warning: inserting implicit <a>
  line 2519 column 13 - Warning: inserting implicit <a>
  line 2519 column 13 - Warning: missing </a> before <pre>
  line 4 column 1 - Warning: <table> lacks "summary" attribute
  line 6 column 22 - Warning: <img> lacks "alt" attribute
  line 38 column 1 - Warning: <table> lacks "summary" attribute
  line 46 column 1 - Warning: <table> lacks "summary" attribute
  line 61 column 1 - Warning: <table> lacks "summary" attribute
  line 159 column 1 - Warning: <table> lacks "summary" attribute
  line 338 column 13 - Warning: <a> anchor "sqlite3" already defined
  line 354 column 13 - Warning: <a> anchor "sqlite3_blob" already defined
  line 370 column 13 - Warning: <a> anchor "sqlite3_context" already defined
  line 382 column 13 - Warning: <a> anchor "sqlite3_stmt" already defined
  line 404 column 13 - Warning: <a> anchor "sqlite3_value" already defined
  line 417 column 13 - Warning: <a> anchor "sqlite3_aggregate_context" already defined
  line 436 column 13 - Warning: <a> anchor "sqlite3_auto_extension" already defined
  line 456 column 13 - Warning: <a> anchor "sqlite3_bind_parameter_count" already defined
  line 475 column 13 - Warning: <a> anchor "sqlite3_bind_parameter_index" already defined
  line 487 column 13 - Warning: <a> anchor "sqlite3_bind_parameter_name" already defined
  line 506 column 13 - Warning: <a> anchor "sqlite3_blob_bytes" already defined
  line 517 column 13 - Warning: <a> anchor "sqlite3_blob_close" already defined
  line 527 column 13 - Warning: <a> anchor "sqlite3_blob_open" already defined
  line 556 column 13 - Warning: <a> anchor "sqlite3_blob_read" already defined
  line 571 column 13 - Warning: <a> anchor "sqlite3_blob_write" already defined
  line 591 column 13 - Warning: <a> anchor "sqlite3_busy_handler" already defined
  line 650 column 13 - Warning: <a> anchor "sqlite3_busy_timeout" already defined
  line 668 column 13 - Warning: <a> anchor "sqlite3_changes" already defined
  line 696 column 13 - Warning: <a> anchor "sqlite3_clear_bindings" already defined
  line 709 column 13 - Warning: <a> anchor "sqlite3_close" already defined
  line 724 column 13 - Warning: <a> anchor "sqlite3_column_count" already defined
  line 737 column 13 - Warning: <a> anchor "sqlite3_db_handle" already defined
  line 751 column 13 - Warning: <a> anchor "sqlite3_enable_load_extension" already defined
  line 766 column 13 - Warning: <a> anchor "sqlite3_enable_shared_cache" already defined
  line 798 column 13 - Warning: <a> anchor "sqlite3_exec" already defined
  line 839 column 13 - Warning: <a> anchor "sqlite3_extended_result_codes" already defined
  line 857 column 13 - Warning: <a> anchor "sqlite3_finalize" already defined
  line 878 column 13 - Warning: <a> anchor "sqlite3_get_autocommit" already defined
  line 891 column 13 - Warning: <a> anchor "sqlite3_interrupt" already defined
  line 909 column 13 - Warning: <a> anchor "sqlite3_last_insert_rowid" already defined
  line 930 column 13 - Warning: <a> anchor "sqlite3_load_extension" already defined
  line 950 column 13 - Warning: <a> anchor "sqlite3_progress_handler" already defined
  line 978 column 13 - Warning: <a> anchor "sqlite3_release_memory" already defined
  line 991 column 13 - Warning: <a> anchor "sqlite3_reset" already defined
  line 1006 column 13 - Warning: <a> anchor "sqlite3_reset_auto_extension" already defined
  line 1019 column 13 - Warning: <a> anchor "sqlite3_set_authorizer" already defined
  line 1071 column 13 - Warning: <a> anchor "sqlite3_sleep" already defined
  line 1085 column 13 - Warning: <a> anchor "sqlite3_soft_heap_limit" already defined
  line 1109 column 13 - Warning: <a> anchor "sqlite3_step" already defined
  line 1168 column 13 - Warning: <a> anchor "sqlite3_table_column_metadata" already defined
  line 1224 column 13 - Warning: <a> anchor "sqlite3_thread_cleanup" already defined
  line 1240 column 13 - Warning: <a> anchor "sqlite3_total_changes" already defined
  line 1261 column 13 - Warning: <a> anchor "sqlite3_update_hook" already defined
  line 1288 column 13 - Warning: <a> anchor "sqlite3_user_data" already defined
  line 1328 column 5 - Warning: <a> anchor "SQLITE_ABORT" already defined
  line 1329 column 13 - Warning: <a> anchor "SQLITE_ABORT" already defined
  line 1402 column 5 - Warning: <a> anchor "SQLITE_ALTER_TABLE" already defined
  line 1403 column 13 - Warning: <a> anchor "SQLITE_ALTER_TABLE" already defined
  line 1461 column 5 - Warning: <a> anchor "SQLITE_ANY" already defined
  line 1462 column 13 - Warning: <a> anchor "SQLITE_ANY" already defined
  line 1480 column 5 - Warning: <a> anchor "SQLITE_BLOB" already defined
  line 1481 column 13 - Warning: <a> anchor "SQLITE_BLOB" already defined
  line 1509 column 5 - Warning: <a> anchor "SQLITE_DENY" already defined
  line 1510 column 13 - Warning: <a> anchor "SQLITE_DENY" already defined
  line 1534 column 5 - Warning: <a> anchor "SQLITE_IOERR_BLOCKED" already defined
  line 1535 column 13 - Warning: <a> anchor "SQLITE_IOERR_BLOCKED" already defined
  line 1571 column 5 - Warning: <a> anchor "SQLITE_STATIC" already defined
  line 1572 column 13 - Warning: <a> anchor "SQLITE_STATIC" already defined
  line 1591 column 5 - Warning: <a> anchor "SQLITE_VERSION" already defined
  line 1592 column 13 - Warning: <a> anchor "SQLITE_VERSION" already defined
  line 1619 column 5 - Warning: <a> anchor "sqlite3_aggregate_count" already defined
  line 1620 column 13 - Warning: <a> anchor "sqlite3_aggregate_count" already defined
  line 1644 column 5 - Warning: <a> anchor "sqlite3_bind_blob" already defined
  line 1645 column 13 - Warning: <a> anchor "sqlite3_bind_blob" already defined
  line 1713 column 5 - Warning: <a> anchor "sqlite3_collation_needed" already defined
  line 1714 column 13 - Warning: <a> anchor "sqlite3_collation_needed" already defined
  line 1756 column 5 - Warning: <a> anchor "sqlite3_column_blob" already defined
  line 1757 column 13 - Warning: <a> anchor "sqlite3_column_blob" already defined
  line 1803 column 1 - Warning: <table> lacks "summary" attribute
  line 1861 column 5 - Warning: <a> anchor "sqlite3_column_database_name" already defined
  line 1862 column 13 - Warning: <a> anchor "sqlite3_column_database_name" already defined
  line 1892 column 5 - Warning: <a> anchor "sqlite3_column_decltype" already defined
  line 1893 column 13 - Warning: <a> anchor "sqlite3_column_decltype" already defined
  line 1918 column 5 - Warning: <a> anchor "sqlite3_column_name" already defined
  line 1919 column 13 - Warning: <a> anchor "sqlite3_column_name" already defined
  line 1939 column 5 - Warning: <a> anchor "sqlite3_commit_hook" already defined
  line 1940 column 13 - Warning: <a> anchor "sqlite3_commit_hook" already defined
  line 1960 column 5 - Warning: <a> anchor "sqlite3_complete" already defined
  line 1961 column 13 - Warning: <a> anchor "sqlite3_complete" already defined
  line 1984 column 5 - Warning: <a> anchor "sqlite3_create_collation" already defined
  line 1985 column 13 - Warning: <a> anchor "sqlite3_create_collation" already defined
  line 2041 column 5 - Warning: <a> anchor "sqlite3_create_function" already defined
  line 2042 column 13 - Warning: <a> anchor "sqlite3_create_function" already defined
  line 2111 column 5 - Warning: <a> anchor "sqlite3_errcode" already defined
  line 2112 column 13 - Warning: <a> anchor "sqlite3_errcode" already defined
  line 2142 column 5 - Warning: <a> anchor "sqlite3_free" already defined
  line 2143 column 13 - Warning: <a> anchor "sqlite3_free" already defined
  line 2159 column 5 - Warning: <a> anchor "sqlite3_free_table" already defined
  line 2160 column 13 - Warning: <a> anchor "sqlite3_free_table" already defined
  line 2206 column 5 - Warning: <a> anchor "sqlite3_get_auxdata" already defined
  line 2207 column 13 - Warning: <a> anchor "sqlite3_get_auxdata" already defined
  line 2237 column 5 - Warning: <a> anchor "sqlite3_libversion" already defined
  line 2238 column 13 - Warning: <a> anchor "sqlite3_libversion" already defined
  line 2260 column 5 - Warning: <a> anchor "sqlite3_mprintf" already defined
  line 2261 column 13 - Warning: <a> anchor "sqlite3_mprintf" already defined
  line 2323 column 5 - Warning: <a> anchor "sqlite3_open" already defined
  line 2324 column 13 - Warning: <a> anchor "sqlite3_open" already defined
  line 2356 column 5 - Warning: <a> anchor "sqlite3_prepare" already defined
  line 2357 column 13 - Warning: <a> anchor "sqlite3_prepare" already defined
  line 2439 column 5 - Warning: <a> anchor "sqlite3_profile" already defined
  line 2440 column 13 - Warning: <a> anchor "sqlite3_profile" already defined
  line 2471 column 5 - Warning: <a> anchor "sqlite3_result_blob" already defined
  line 2472 column 13 - Warning: <a> anchor "sqlite3_result_blob" already defined
  line 2518 column 5 - Warning: <a> anchor "sqlite3_value_blob" already defined
  line 2519 column 13 - Warning: <a> anchor "sqlite3_value_blob" already defined
  line 389 column 120 - Warning: trimming empty <p>
  line 398 column 6 - Warning: trimming empty <p>
  line 542 column 20 - Warning: trimming empty <p>
  line 544 column 7 - Warning: trimming empty <p>
  line 835 column 62 - Warning: trimming empty <p>
  line 1196 column 29 - Warning: trimming empty <p>
  line 1203 column 7 - Warning: trimming empty <p>
  line 1209 column 13 - Warning: trimming empty <p>
  line 1215 column 7 - Warning: trimming empty <p>
  line 1368 column 89 - Warning: trimming empty <p>
  line 1495 column 65 - Warning: trimming empty <p>
  line 1501 column 6 - Warning: trimming empty <p>
  line 1660 column 11 - Warning: trimming empty <p>
  line 1666 column 6 - Warning: trimming empty <p>
  line 1802 column 17 - Warning: trimming empty <p>
  line 1805 column 49 - Warning: trimming empty <p>
  line 1805 column 53 - Warning: trimming empty <p>
  line 1822 column 14 - Warning: trimming empty <p>
  line 1830 column 28 - Warning: trimming empty <p>
  line 1833 column 45 - Warning: trimming empty <p>
  line 1833 column 45 - Warning: trimming empty <li>
  line 1835 column 24 - Warning: trimming empty <p>
  line 1835 column 24 - Warning: trimming empty <li>
  line 1838 column 6 - Warning: trimming empty <p>
  line 1843 column 34 - Warning: trimming empty <p>
  line 1847 column 6 - Warning: trimming empty <p>
  line 2177 column 88 - Warning: trimming empty <p>
  line 2183 column 7 - Warning: trimming empty <p>
  line 2184 column 46 - Warning: trimming empty <p>
  line 2193 column 7 - Warning: trimming empty <p>
  line 2296 column 85 - Warning: trimming empty <p>
  line 2298 column 20 - Warning: trimming empty <p>
  line 2298 column 84 - Warning: trimming empty <p>
  line 2302 column 20 - Warning: trimming empty <p>
  line 2303 column 52 - Warning: trimming empty <p>
  line 2305 column 20 - Warning: trimming empty <p>
  line 2306 column 33 - Warning: trimming empty <p>
  line 2308 column 20 - Warning: trimming empty <p>
  line 2313 column 72 - Warning: trimming empty <p>
  line 2317 column 20 - Warning: trimming empty <p>
  line 2413 column 38 - Warning: trimming empty <p>
  line 2423 column 10 - Warning: trimming empty <p>
  line 2423 column 10 - Warning: trimming empty <li>
  line 2435 column 1 - Warning: trimming empty <p>
 
2381 doc active 2007 May anonymous   2007 May   3 3 'VACUUM' aborts an active transaction. edit
VACUUM aborts an active transaction. I'm not sure if this is the intended behavior. I didn't see any documentation to this effect.

  sqlite> .sc
  CREATE TABLE bar ( c1 integer primary key not null );

  sqlite> select max(oid) from bar;
  count(oid)
  ----------
  240

  sqlite> begin;
  sqlite> delete from bar;
  sqlite> select max(oid) from bar;
  mcount(oid)
  ----------
  0

  sqlite> vacuum;
  SQL error: cannot VACUUM from within a transaction

  sqlite> select max(oid) from bar;
  count(oid)
  ----------
  240
 
2342 doc active 2007 May anonymous   2007 May   1 1 Document that prepared incremental vacuum needs multiple sqlite3_step edit
Unlike other PRAGMA commands, an sqlite3_prepare()ed PRAGMA incremental_vacuum(x); requires x calls to sqlite3_step to vacuum all x pages, or until sqlite3_step no longer returns SQLITE_ROW.

Maybe it is worth explicitly pointing this out in the documentation in order to avoid confusion?

 
2326 doc active 2007 Apr anonymous   2007 Apr a.rottmann 5 2 miss one word 'list' edit
in documentation sqlite3: A command-line access program for SQLite

The sqlite3 program is able to show the results of a query in eight different formats: "csv", "column", "html", "insert", "line", "tabs", and "tcl".

missed one format: "list"

it should be: The sqlite3 program is able to show the results of a query in eight different formats: "csv", "column", "html", "insert", "line", "list", "tabs", and "tcl".

 
2247 doc active 2007 Feb anonymous   2007 Feb   3 3 documentation of DEFUALT cluase in CREATE TABLE should be fixed edit
The documentation for the CREATE TABLE statement at http://www.sqlite.org/lang_createtable.html shows the syntax of the DEFAULT clause as

  DEFAULT value

and the description says that value can be NULL, a string constant, a number, or one of three keyword values; CURRENT_DATE, CURRENT_TIME, or CURRENT_TIMESTAMP.

This is incorrect since the DEFAULT clause also allows value to be an expression in brackets. The syntax should be changed to something like

  DEFAULT default_value

  default_value := value | ( expression )

and the description should say that some expressions are allowed. In particular functions can be used as the expression. It should also be clarified when the DEFAULT clause functions are evaluated, at the time the create statement executes, or at the time a record is added to the table.

Note that not all expressions are allowed. In particular the ( select_statement ) form produces an error saying the default value is not constant, even though the apparently non-constant function random() is accepted.

    sqlite> create table t2(id, b default ((select avg(a) from t1)));
    SQL error: default value of column [b] is not constant
    sqlite> create table t2(id, b default (random()));
    sqlite>

Tests using a default function julianday('now') as a default show that the function is evaluated at the time the record is inserted. If that is the case, why can the select expression above not be evaluated each time a record is inserted to generate a default value?

 
2246 doc active 2007 Feb anonymous   2007 Feb   5 4 SQL docs for CREATE TABLE should include FOREIGN KEY syntax edit
The documentation on supported SQL for CREATE TABLE should include syntax for foreign keys since foreign keys are parsed. Of course it should say that the foreign keys are not enforced, but since they are parsed having the syntax in the documentation would be appropriate.

http://sqlite.org/lang_createtable.html

Thanks,

Sam

 
2188 doc active 2007 Jan anonymous   2007 Jan   5 4 Doc bug in src/vdbe.c, should s/P1/P2/ in NotFound edit
  # diff
--- src/vdbe.c  2007-01-10 01:01:14.000000000 +1100
+++ src/vdbe_new.c      2007-01-24 16:34:38.139376872 +1100
@@ -2923,7 +2923,7 @@
 **
 ** The top of the stack holds a blob constructed by MakeRecord.  P1 is
 ** an index.  If no entry exists in P1 that matches the blob then jump
-** to P1.  If an entry does existing, fall through.  The cursor is left
+** to P2.  If an entry does existing, fall through.  The cursor is left
 ** pointing to the entry that matches.  The blob is popped from the stack.
 **
 ** The difference between this operation and Distinct is that
 
2148 doc active 2007 Jan anonymous   2007 Jan   5 5 3.3.9 changes.html addition edit
  - Fixed the ".dump" command in the command-line shell to show triggers and views again.
  + Fixed the ".dump" command in the command-line shell to show indexes, triggers and views again.
 
2106 doc active 2006 Dec anonymous   2006 Dec   4 4 FtsOne wiki page neglects to mention Porter stemming edit
http://www.sqlite.org/cvstrac/wiki?p=FtsOne claims that "the module does not perform stemming of any sort" when, in fact, FTS1 (in the 3.3.8 tarball and onwards) appears to fully support Porter stemming, using the same "tokenizer porter" syntax as FTS2.
 
2099 doc active 2006 Dec anonymous   2006 Dec   3 3 virtual table xDestroy/xDisconnect and cleanups edit
It isn't clear what happens if xDisconnect or xDestroy return an error. From the code for sqlite3VtabCallDestroy pTab->pVtab is not set to zero. Does that mean that Destroy/Disconnect can be called again (the table has been dropped so I don't see how)? If not, then the memory is table is memory leaked.

In my Python wrapper I have to decide what to do when the Python code returns an error. Should I free the Python objects when returning the error code, or leave them allocated. If they are left allocated, then will they be leaked or will there be another opportunity to free them?

2006-Dec-24 11:16:56 by anonymous:
From the code, the return code from xDisconnect is completely ignored (vtab.c:62)

xDisconnect is also unconditionally called whereas xDestroy is optionally called (vtab.c:496). If anything I would expect xDisconnect to be optional and xDestroy to be mandatory.

I still can't answer the original question in this ticket. Currently xDisconnect ignores the return value and therefore results in unconditional disconnection. xDestroy is ultimately called in OP_VDestroy in the vdbe but I can't tell what happens if an error is returned.

 
2095 doc active 2006 Dec anonymous   2006 Dec   1 3 xFindFunction documentation incomplete edit
The documentation doesn't say when xFindFunction is called. It is obviously called the first time a function is needed, but is it called every time?

My underlying issue is that the ppArg return value is going to be dynamically allocated and I need to know when it can be freed (I have to free it since it will be a pointer to a reference counted object)

 
1934 doc active 2006 Aug anonymous   2006 Aug   5 5 Documentation about default file format edit
Default file format has changed from 3.3.7.

This is mentionned here :

http://www.sqlite.org/changes.html and http://www.sqlite.org/formatchng.html

but not here :

http://www.sqlite.org/pragma.html (PRAGMA legacy_file_format)

 
1898 doc active 2006 Jul anonymous   2006 Jul   5 4 sqlite3_progress_handler still marked experimental in documentation edit
According to DRH's posting on the sqlite-user mailing list, sqlite3_progress_handler is no longer experimental and the note in the documentation should be removed. Here's the ticket to track this issue...
 
1895 doc active 2006 Jul anonymous   2006 Jul anonymous 4 3 IS operator not documented edit
Hello,

I tried to work with varchar fields having NULL values. However, I was not able to find the right operator to catch such values, and none of the operators mentionend in datatype3.html seemed to help. Finally I tried "is null" (or IS NOT NULL) and well, that seems to do what I want. But there are questions:

  • is this an intended feature?

  • if yes, can I rely on having it in the future versions?

  • if this is not an intended feature, what is the right way to match NULL values?

  • if that's just a documentation problem, will the documentation be updated?
2006-Jul-19 19:02:17 by anonymous:
It's part of the SQL standard. "IS" isn't really an operator; it's an optional token that's part of the NULL and NOT NULL predicates.
 
1869 doc active 2006 Jun anonymous Unknown 2006 Jun anonymous 4 4 Website typo edit
http://www.sqlite.org/capi3ref.html#sqlite3_exec has this:

    "As an example, suppose the query result where this table:"

Instead of "where," "were" should have been used.

 
1860 doc active 2006 Jun anonymous Pager 2006 Jun danielk1977 1 1 Problem in using SQLite3 with trigger and multithreading edit
I am using SQLite3 database with triggers . This database is used by my processing engine which is having 10 threads accessing the same database. Trigger is used to updata and insert records in a table and that very table is also updated by threads.

Processing engine crashes whenever a trigger updates or inserts a record in the table.

 
1858 doc active 2006 Jun anonymous   2006 Jun   5 5 Typo: Pearl -> Perl edit
sqlite/www/index.tcl 1.139

  s/Pearl/Perl/g
 
1833 doc active 2006 Jun anonymous Unknown 2006 Jun drh 4 3 PRAGMA legacy_file_format not documented edit
[2922] introduces the legacy_file_format pragma, but it's not documented anywhere. At the very least, it should be mentioned in /sqlite/www/pragma.tcl, unless there's some better way to have a SQLite 3.3.5 (or so) generate databases usable by older versions of SQLite 3 (Debian stable, for example, ships with 3.2.1).
 
1811 doc active 2006 May anonymous   2006 May   5 3 how many open cursors are allowed for one application? edit
I would like to know, how many open cursors allowed at the same time.
 
1798 doc active 2006 May anonymous   2006 May   5 4 preprocessed is misspelled on download page edit
On the download page you'll find the text "proprocessed".
 
1789 doc active 2006 May anonymous Unknown 2006 May drh 4 4 sqlite3_result_error() not adequately documented edit
Documentation for sqlite3_result_error() and friends says "operation of these routines is very similar to the operation of sqlite3_bind_blob() and its cousins", but none of the bind routines are really that similar. So it's not obvious from existing documentation whether the int argument is a string length or, say, a SQLITE_ error code, or a static/transient flag. A glance at /sqlite/src/func.c suggests that it's a static/transient flag, but it's not entirely clear (and if it is, why isn't the signature similar to sqlite3_result_text()?)

sqlite3.h and capi3.html should probably have a little more discussion about returning error situations from user-defined functions.

c.

 
1732 doc active 2006 Mar anonymous   2006 Mar   5 5 Info on Home page edit
  According to "Check-in [3144] : Increase test coverage to above 98%. (By drh)"
  the info on home page should be changed from 95% to 98%
 
1731 doc active 2006 Mar anonymous   2006 Mar   5 5 Typo in select4.test edit
  # Make sure the names of columns are takenf rom the right-most subquery
    should be
  # Make sure the names of columns are taken from the right-most subquery
 
1656 doc active 2006 Feb anonymous Parser 2006 Mar   5 4 lemon versions and changelog edit
Lemon lacks whatsnew.txt files and versioning to be used in other products than SQLite. Seems like to be useful utility. It will be nice to see some performance tests/comparison with other parsers.
 
1701 doc active 2006 Mar anonymous   2006 Mar drh 3 1 3.3 build option not documented? edit
3.3 db can not be read in easlier 3.X versions. Ok, then it says there is a 'rare' compile option to force them to be. I can not use 3.3 yet from php and perl, so I have the rare condidtion that I prefer to have all my tools in sync more. I have searched the incompatibilies page, the ./configure -h, grepped the source and read the options page... so far none seem to have lead me to this magic compile option.

Maybe it should be documented someplace?

2006-Mar-03 15:49:35 by anonymous:
The compilation option you are looking for is SQLITE_DEFAULT_FILE_FORMAT. I found it by looking back through the time line before version 3.3.0.

You are correct it should be added to the options displayed on http://www.sqlite.org/compile.html which is reached from the Compilation Options link on the documentation page.

 
1647 doc active 2006 Jan anonymous Unknown 2006 Jan paul 3 1 i want to use this lib in my project edit
HI, I want to use this sqlite source in my project for quick firing of quaries. I want dataled doc of source or how to use these source in my project.

  Hoping for  quick reply,

Bye

thaks & Regards Sumant Kadam 9422615104

2006-Jan-30 20:43:26 by anonymous:
This is not a bug report. Please use the mailing list for this type of question.
 
1635 doc active 2006 Jan anonymous   2006 Jan   4 4 SQLite Ticket "Version" field edit
The "Version" field in the CVSTrac ticket is ambiguous (particularly for "fixed" bugs). Can it be renamed to "Version Bug Appears" or something to that effect? Also, it would be very useful to see the SQLite version in which the ticket is fixed in addition to the SQLite version which the bug first appears. Manually correlating the date of the fix with the SQLite version is awkward.
 
1565 doc active 2005 Dec anonymous   2005 Dec   4 4 wrong return-type specified for sqlite3_db_handle in c-api-reference edit
The c-api-documentation tells, that sqlite3_db_handle returns an int. This is not true. It returns the databasehandle as sqlite3*. The line in capi3ref:

  int sqlite3_db_handle(sqlite3_stmt*);

should be replaced by

  sqlite* sqlite3_db_handle(sqlite3_stmt*);
 
1555 doc active 2005 Dec anonymous BTree 2005 Dec appledev 2 4 sqlite+Crystal reports connection edit
I have problem of sqlite and crystal report connection
 
1503 doc active 2005 Oct anonymous   2005 Oct   5 4 typo in datatype3.html edit
http://www.sqlite.org/datatype3.html

SQLite treats the expression "a IN (x, y, z)" as equivalent to "a = z OR a = y OR a = z".

should be

... equivalent to "a = x OR ...

 
1483 doc active 2005 Oct anonymous Unknown 2005 Oct xdong 1 3 expression document:describe ERROR. edit
http://www.sqlite.org/lang_expr.html
about the "CASE" expression,"CASE [expr] ( WHEN expr THEN expr )+ [ELSE expr] END " does not work. May the right is "CASE [expr] WHEN condition THEN expr [ELSE expr] END " others:all the documents about SQLite are scattered, someone should organize them for the user.It is very useful,sometime is important than the software itself's development.

                          infree at Beijing
 
1454 doc active 2005 Sep anonymous   2005 Sep   4 4 Functions should all be documented in one place edit
Currently some, but not all, of SQLite's functions are documented in lang_expr.html. For example, the date/time functions are only documented in a wiki page that describes them as "experimental." It would be nice if they could be moved into the "official" documentation.
 
1431 doc active 2005 Sep anonymous   2005 Sep   1 1 Please can FAQ 7 reference http://www.sqlite.org/lockingv3.html edit
FAQ item 7 is unclear on when concurrent readers and writers may block. Please add a reference to http://www.sqlite.org/lockingv3.html which makes this clear.

Also please add to http://www.sqlite.org/lockingv3.html this sumamry by Christian Smith sent to the mailing list with message-id Pine.LNX.4.58.0509161006430.16877@localhost.localdomain>

In summary: SQLite uses multiple readers/single writer locking. A writer can operate concurrently with readers until it is ready to commit or spill data from it's cache. In this case, it waits for readers to finish, then gets an exclusive write lock and writes it's data. Thus, the following concurrency is available to SQLite:

  time ---->
Reader >-------------|
Reader     >-------------|
Reader       >----------|
Writer        >-------c***----|
Reader           >***********-------------|

  Key:
 - Executing query
 c Commit
 * Blocked by lock
 > Start of query
 | End of query

The last reader above is blocked from starting by the writer until the writer commits. If the writer commits before the last reader has finished, it is blocked.

 
1209 doc active 2005 Apr anonymous Unknown 2005 Apr anonymous 3 5 SQLite3_Free_Table returns not #SQLITE_OK if suceeds edit
Using the function SQLITE3_Get_Table I get back a pointer to memory where the data table is stored. After reading this table I try to free the memory under use of command SQLITE3_Free_Table (using Windows DLL V3.2.1). I expect that, if freeing succeds, the answer "#SQLITE_OK". But instead I get mostly #SQLITE_ERROR, but sometimes very big numbers. In fact I checked the memory usage of my program.

When I use SQLITE_Free_Table with a wrong pointer, the answer of DLL is #SQLITE_OK while the memory usage of my program increases. Whe I use the correct pointer the answer of SQLITE3_Free_Table us #SQLITE_ERROR, but the memory usage of my program remains the same as before the SQLITE3_Get_Table command.

For me it seems as if the answer for the "free" command is not correct.

 
1199 doc active 2005 Apr anonymous   2005 Apr   4 3 Update the README file edit
The README file gives the following instructions:

    tar xzf sqlite.tar.gz    ; 
    mkdir bld                ;
    cd bld                   ; 
    ../sqlite/configure      ;  <==
    make                     ; 
    make install             ; 

I guess the indicated line should be changed to "../configure ; " since there is no "../sqlite/" directory.

Kind regards.

2005-Apr-02 12:44:19 by drh:
The directory is named ../sqlite-VERSION/ where VERSION is the current version number.
 
1059 doc active 2005 Jan anonymous Unknown 2005 Jan   5 4 Full support for IEEE 754 floating points edit
Current situation:
IEEE standard 754 allows for the following special cases of double values:
    Zero. Denoted as an exponent field of zero and a fraction field of zero
    Denormalized. Denoted as an all 0 exponent field with a non zero fraction field
    Infinity. Denoted as an all 1 exponent field and an all zero fraction field(sign bit indicates +infinity or -infinity)
    NaN. Denoted with an all 1 exponent field and a non zero fraction field. The most significant bit fraction indicates type of NaN.

SQLite converts these values to 0.

Request option to store these special values.

Current workaround: If only one type of special value is to be used, replace it with NULL. If multiple types are used add a type column to each floating point column indicating what is stored in the linked floating point column.

2005-Jul-25 01:46:58 by anonymous:
Here is some partial support for Infinity and NaN given C99 support. Both quantities are input and output correctly, and arithmetic works. I haven't defined what happens when storing these quantities on non-REAL columns. I also haven't added tests; I'm allergic to tcl. (note: gcc needs -std=gnu9x or -std=c99 to fully support Inf and NaN.)

The float i/o needs some serious work; are there any non-licensing constraints on what someone can replace it with?

If the patch is mangled, mail me. Jason Riedy <jason@acm.org>

   Index: Makefile.linux-gcc
  ===================================================================
  RCS file: /sqlite/sqlite/Makefile.linux-gcc,v
  retrieving revision 1.3
  diff -u -3 -p -r1.3 Makefile.linux-gcc
  --- Makefile.linux-gcc	11 Mar 2005 18:06:41 -0000	1.3
  +++ Makefile.linux-gcc	25 Jul 2005 01:41:34 -0000
  @@ -41,6 +41,12 @@ THREADSAFE = -DTHREADSAFE=0
   #THREADLIB = -lpthread
   THREADLIB = 

  +#### If you have C99's INFINITY, NAN, and the testing macros, 
  +#    define appropriately.
  +#
  +FPVALUES = 
  +#FPVALUES = -DHAVE_INFINITY=1 -DHAVE_ISINF=1 -DHAVE_NAN=1 -DHAVE_ISNAN=1
  +
   #### Leave SQLITE_DEBUG undefined for maximum speed.  Use SQLITE_DEBUG=1
   #    to check for memory leaks.  Use SQLITE_DEBUG=2 to print a log of all
   #    malloc()s and free()s in order to track down memory leaks.
  Index: configure.ac
  ===================================================================
  RCS file: /sqlite/sqlite/configure.ac,v
  retrieving revision 1.17
  diff -u -3 -p -r1.17 configure.ac
  --- configure.ac	6 Jul 2005 13:51:27 -0000	1.17
  +++ configure.ac	25 Jul 2005 01:41:37 -0000
  @@ -608,6 +608,44 @@ AC_SUBST(TARGET_DEBUG)
   AC_CHECK_FUNC(usleep, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_USLEEP=1"])

   #########
  +# Check for C99 INFINITY macro and isinf test.
  +#   C99 defines isinf to be a macro, but it is a macro on some systems
  +#   and a function on others.
  +AC_MSG_CHECKING([for INFINITY])
  +AC_LINK_IFELSE(
  +[#include <math.h>
  +int main () { double x; x = INFINITY; return((int)x); }],
  +  [AC_MSG_RESULT([yes])
  +   TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_INFINITY=1"],
  +  [AC_MSG_RESULT([no])])
  +AC_MSG_CHECKING([for isinf])
  +AC_LINK_IFELSE(
  +[#include <math.h>
  +int main () { return (0 != isinf(0.0)); }],
  +  [AC_MSG_RESULT([yes])
  +   TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_ISINF=1"],
  +  [AC_MSG_RESULT([no])])
  +
  +#########
  +# Check for C99 NAN macro and isnan test.
  +#   C99 defines isnan to be a macro, but it is a macro on some systems
  +#   and a function on others.
  +AC_MSG_CHECKING([for NAN])
  +AC_LINK_IFELSE(
  +[#include <math.h>
  +int main () { double x; x = NAN; }],
  +  [AC_MSG_RESULT([yes])
  +   TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_NAN=1"],
  +  [AC_MSG_RESULT([no])])
  +AC_MSG_CHECKING([for isnan])
  +AC_LINK_IFELSE(
  +[#include <math.h>
  +int main () { return (0 != isnan(0.0)); }],
  +  [AC_MSG_RESULT([yes])
  +   TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_ISNAN=1"],
  +  [AC_MSG_RESULT([no])])
  +
  +#########
   # Generate the output files.
   #
   AC_OUTPUT([
  Index: src/printf.c
  ===================================================================
  RCS file: /sqlite/sqlite/src/printf.c,v
  retrieving revision 1.43
  diff -u -3 -p -r1.43 printf.c
  --- src/printf.c	5 Nov 2004 17:17:50 -0000	1.43
  +++ src/printf.c	25 Jul 2005 01:41:37 -0000
  @@ -51,6 +51,14 @@
   **
   */
   #include "sqliteInt.h"
  +#ifndef etNOFLOATINGPOINT
  +#include <float.h>
  +#include <math.h>
  +#endif
  +
  +static const char infinity_string[] = "Infinity";
  +static const char negative_infinity_string[] = "-Infinity";
  +static const char NaN_string[] = "NaN";

   /*
   ** Conversion types fall into various categories as defined by the
  @@ -413,6 +421,10 @@ static int vxprintf(
         case etGENERIC:
           realvalue = va_arg(ap,double);
   #ifndef etNOFLOATINGPOINT
  +	/* XXX: This needs some serious help.
  +	     Multiplying by 0.1 is not an exact operation, so rounding
  +	     may change.
  +	 */
           if( precision<0 ) precision = 6;         /* Set default precision */
           if( precision>etBUFSIZE-10 ) precision = etBUFSIZE-10;
           if( realvalue<0.0 ){
  @@ -435,14 +447,34 @@ static int vxprintf(
           if( infop->type==etFLOAT ) realvalue += rounder;
           /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
           exp = 0;
  +#if defined(HAVE_ISINF)
  +	if( isinf(realvalue) ){
  +	  if( '-' == prefix ){
  +	    bufpt = negative_infinity_string;
  +	    length = (sizeof(negative_infinity_string)/sizeof(char)) - 1;
  +	  }
  +	  else {
  +	    bufpt = infinity_string;
  +	    length = (sizeof(infinity_string)/sizeof(char)) - 1;
  +	  }
  +	  break;
  +	}
  +#endif
  +#if defined(HAVE_ISNAN)
  +	if( isnan(realvalue) ){
  +	  bufpt = NaN_string;
  +          length = (sizeof(NaN_string)/sizeof(char)) - 1;
  +	  break;
  +	}
  +#endif
           if( realvalue>0.0 ){
             while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; }
             while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }
             while( realvalue<1e-8 && exp>=-350 ){ realvalue *= 1e8; exp-=8; }
             while( realvalue<1.0 && exp>=-350 ){ realvalue *= 10.0; exp--; }
             if( exp>350 || exp<-350 ){
  -            bufpt = "NaN";
  -            length = 3;
  +            bufpt = NaN_string;
  +            length = (sizeof(NaN_string)/sizeof(char)) - 1;
               break;
             }
           }
  Index: src/util.c
  ===================================================================
  RCS file: /sqlite/sqlite/src/util.c,v
  retrieving revision 1.141
  diff -u -3 -p -r1.141 util.c
  --- src/util.c	20 Jul 2005 14:31:53 -0000	1.141
  +++ src/util.c	25 Jul 2005 01:41:37 -0000
  @@ -19,6 +19,8 @@
   #include "sqliteInt.h"
   #include <stdarg.h>
   #include <ctype.h>
  +#include <float.h>
  +#include <math.h>

   #if SQLITE_MEMDEBUG>2 && defined(__GLIBC__)
   #include <execinfo.h>
  @@ -541,6 +543,52 @@ int sqlite3IsNumber(const char *z, int *
     int incr = (enc==SQLITE_UTF8?1:2);
     if( enc==SQLITE_UTF16BE ) z++;
     if( *z=='-' || *z=='+' ) z += incr;
  +#if defined(HAVE_INFINITY)
  +  if( *z=='I' || *z=='i' ){
  +    /*
  +      May be Infinity.  The SQL standard says that 'Infinity' and
  +      '-Infinity' are the only spellings, but this code accepts
  +      '+Infinity'.
  +    */
  +    z += incr;
  +    if (*z=='N'||*z=='n') z += incr;
  +    else goto not_inf;
  +    if (*z=='F'||*z=='f') z += incr;
  +    else goto not_inf;
  +    if (*z=='I'||*z=='i') z += incr;
  +    else goto not_inf;
  +    if (*z=='N'||*z=='n') z += incr;
  +    else goto not_inf;
  +    if (*z=='I'||*z=='i') z += incr;
  +    else goto not_inf;
  +    if (*z=='T'||*z=='t') z += incr;
  +    else goto not_inf;
  +    if (*z=='Y'||*z=='y') z += incr;
  +    else goto not_inf;
  +    if (realnum) *realnum = 1;
  +    goto done;
  +  not_inf:
  +    return 0;
  +  }
  +#endif
  +#if defined(HAVE_NAN)
  +  if( *z=='N' || *z=='n' ){
  +    /*
  +      May be NaN.  The SQL standard says that 'NaN' is the only
  +      spelling.  IEEE-754 does not attribute meaning to the sign
  +      bit of NaN, so this code also allows '+NaN' and '-NaN'.
  +    */
  +    z += incr;
  +    if (*z=='A'||*z=='a') z += incr;
  +    else goto not_nan;
  +    if (*z=='N'||*z=='n') z += incr;
  +    else goto not_nan;
  +    if (realnum) *realnum = 1;
  +    goto done;
  +  not_nan:
  +    return 0;
  +  }
  +#endif
     if( !isdigit(*(u8*)z) ){
       return 0;
     }
  @@ -560,6 +608,7 @@ int sqlite3IsNumber(const char *z, int *
       while( isdigit(*(u8*)z) ){ z += incr; }
       if( realnum ) *realnum = 1;
     }
  +done:
     return *z==0;
   }

  @@ -585,6 +634,46 @@ int sqlite3AtoF(const char *z, double *p
     }else if( *z=='+' ){
       z++;
     }
  +#if defined(HAVE_INFINITY)
  +  if( *z=='I' || *z=='i' ){
  +    const char *saved_z = z;
  +    /* May be Infinity.  See sqlite3IsNumber for caveats. */
  +    z++;
  +    if (*z=='N'||*z=='n') z++;
  +    else goto not_inf;
  +    if (*z=='F'||*z=='f') z++;
  +    else goto not_inf;
  +    if (*z=='I'||*z=='i') z++;
  +    else goto not_inf;
  +    if (*z=='N'||*z=='n') z++;
  +    else goto not_inf;
  +    if (*z=='I'||*z=='i') z++;
  +    else goto not_inf;
  +    if (*z=='T'||*z=='t') z++;
  +    else goto not_inf;
  +    if (*z=='Y'||*z=='y') z++;
  +    else goto not_inf;
  +    v1 = INFINITY;
  +    goto done;
  +  not_inf:
  +    z = saved_z;
  +  }
  +#endif
  +#if defined(HAVE_NAN)
  +  if( *z=='N' || *z=='n' ){
  +    const char *saved_z = z;
  +    /* May be NaN.  See sqlite3IsNumber for caveats. */
  +    z++;
  +    if (*z=='A'||*z=='a') z++;
  +    else goto not_nan;
  +    if (*z=='N'||*z=='n') z++;
  +    else goto not_nan;
  +    v1 = NAN;
  +    goto done;
  +  not_nan:
  +    z = saved_z;
  +  }
  +#endif
     while( isdigit(*(u8*)z) ){
       v1 = v1*10.0 + (*z - '0');
       z++;
  @@ -624,6 +713,7 @@ int sqlite3AtoF(const char *z, double *p
         v1 *= scale;
       }
     }
  +done:
     *pResult = sign<0 ? -v1 : v1;
     return z - zBegin;
   }
 
1043 doc active 2004 Dec anonymous   2004 Dec   3 3 SQLITE3_ANY does not exist edit
The file "www/capi3.tcl" refers to SQLITE3_encodings, such as SQLITE3_UTF8. In the header file, these are prefixed with SQLITE_ and not SQLITE3_.
 
1029 doc active 2004 Dec anonymous Unknown 2004 Dec   4 5 SQLITE_ not SQLITE3_ constants in the C/C++ interface . html edit
in this file :

http://www.sqlite.org/capi3.html

there are constants :

#define SQLITE3_UTF8 1 #define SQLITE3_UTF16 2 #define SQLITE3_UTF16BE 3 #define SQLITE3_UTF16LE 4 #define SQLITE3_ANY 5

but in the code , they are SQLITE_* not SQLITE3_*

 
1020 doc active 2004 Nov anonymous   2004 Nov   5 4 in html (.tcl) <,> is not always &lt, &gt edit
I created a .chm and got some error messages for invalid htm content. Here's the list:

datatype3.tcl (342):

For binary comparison operators (, <, >, < and >=) if either operand is a

should be: (replace <>)

For binary comparison operators (, &lt;, &gt;, &lt; and &gt;=) if either operand is a

version3.tcl (199)

sorts (or uses a comparison operator like "<" or ">=") the sort order

should be:

sorts (or uses a comparison operator like "&lt;" or "&gt;=") the sort order

I put it temporarily online here: http://www.hbreitner.de/tmp/sqlite3.0.8chm.zip

Feel free to put it online!

Harald

 
1014 doc new 2004 Nov anonymous Parser 2004 Nov   5 5 Can't have column name "first" any more... edit
I have an application where the main table is like:

   create table people (
      id integer primary key,
      first varchar(20),
      last varchar(50),
   ...etc...

This has never caused problems. But I just updated after the 'cursor' stuff was added, and my existing db can get a 'bad schema' error.

After investigating, I found that sqlite was complaining about having a column 'first'. It doesn't mind 'last', which I find curious.

2004-Nov-24 22:48:14 by anonymous:
I might point out that the documenation does not indicate 'first' is a reserved word.


2004-Nov-24 23:57:11 by drh:
I'd like to point out that the "cursor stuff" has not been released yet. When you use unstable code out of CVS you have to be prepared to encounter problems.
 
960 doc active 2004 Oct anonymous   2004 Oct   3 2 Make archive unpack into directory sqlite-VERSION/ edit
Please make the sqlite to unpack to separate directory, so that upgrading won't overwrite previous sources.

  sqlite-3.0.7.tar.gz

Should unpack all files under:

  sqlite-3.0.7/

This is the de facto format for all internet projects,

 
853 doc active 2004 Aug anonymous Parser 2004 Aug   4 3 syntax of DEFAULT in a CREATE TABLE statement not as documented edit
The syntax (as found under the syntax link on the website) indicates that a column default in a create table statement is like a column constraint definition. However, explicitly naming the column default fails. Consider:

  CREATE TABLE FOO(
      BAR VARCHAR(50) CONSTRAINT DEF_1 DEFAULT '(default)'
  )

yields

  SQL error: near "DEFAULT": syntax error
 
852 doc active 2004 Aug anonymous   2004 Aug   5 4 Typos found in the Syntax documentation edit
Here are all of the typos I have found in the online documentation. I noticed them after opening the saved .html file in Microsoft Word.

  "percisely" should be "precisely"
  "a transaction will also ROLLBACK" should be "transactions will also ROLLBACK"
  "documention" should be "documentation"
  "multiline" should be "multi-line"
  "whitespace" should be "white-space" (3 instances)
  "baskslash" should be "backslash" (3 instances)
  "entires" should be "entries"
  "Everytime" should be "Every time" (3 instances)
  "datatype" should be "data type" (6 instances)
  "If a is specified" ??
  "specify both a and the TEMP" ??
  "The default is abort ABORT." should be "The default is ABORT."
  "The text of CREATE TEMPORARY TABLE statements are" should be "The text of CREATE TEMPORARY TABLE statements is"
  "one or more specified columns of a table are updated" should be "one or more specified columns of a table is updated"
  "(either ABORT, FAIL or ROLLBACK)" should be "(ABORT, FAIL or ROLLBACK)"
  "comparision" should be "comparison"
  "globbing" should maybe be "globing"
  "yeilds" should be "yields"
  "mminimum" should be "minimum"
  "negative the the first character" should be "negative the first character"
  "constraint violation continue" should be "constraint violation will continue"
  "statisfy" should be "satisfy"
  "eachother" should be "each other"
  "modelled" should be "modeled"
  "reimplimented" should be "re-implemented"
  "but can speed up inserts." should be "but can speed up insertions."
  "views, ...)" should be "views ...)"
  "identifer" should be "identifier"

I have a Word modified HTML document if it would help. Email me if you have any questions.
ps. SQLite is AWESOME!

 
851 doc active 2004 Aug anonymous Parser 2004 Aug   5 2 SQLite allows Zero length table column names edit
SQLite allows zero length identifiers, that is, a statement like:

  CREATE TABLE [] (
    "" not null 
  , name
  )

does in fact create a (nameless) table with two (2) columns, be it that the first one ("", or []) is nameless. Although everything is still consistent (SELECT [] FROM "", or SELECT "" from [] does project the nameless column) it can be quit confusing. Consider this:

  INSERT 
  INTO   ""(name) 
  VALUES ('value')

generates SQL error:

. may not be NULL

At least the syntax documentation should state that it is in fact allowed to use zero length identifiers.

2004-Aug-10 16:03:02 by anonymous:
C:\database>sqlite3.exe temp.db
SQLite version 3.0.4
Enter ".help" for instructions
sqlite> create table [] ( "" int,name);
sqlite> insert into [] values (1,'t');
sqlite> select * from [];
1|t
sqlite> .mode column
sqlite> .header on
sqlite> select * from [];
name
---------- ----------
1 t
sqlite>
sqlite> create table "" (i int);
SQL error: table "" already exists
sqlite>


2004-Aug-10 16:04:50 by anonymous:
we can say sqlite allows zero length table & column name.
 
816 doc active 2004 Jul anonymous Unknown 2004 Jul   1 4 sqlite3_changes - absent in sqlitedll-3_0_2.zip edit
trying to make COM-Wrapper for SQLite in VC++ 6.0. can't find such entry point in any 3.x precompiled win32 dll
 
752 doc active 2004 Jun anonymous   2004 Jun   4 4 FAQ-Entry: How to escape quotes edit
Ticket #497 (not able to escape quotes) should really be mentioned in the FAQ. I'm sure many users (including me...) try to escape quotes using a backslash (C-style, like MySQL accepts it).
 
732 doc active 2004 May anonymous   2004 May   5 5 Odd columns lead to odder selections edit
This is not (necessarily) a bug, just some documentation about escaping funny column names. The idea is that if you make a column name having a quote character of one type (single or double), to make the name most easily, you surround the proposed column name with the other types of quotes. So far, so good, and OK, I agree that you really have no business doing this in the first place.

However, to reference this column, you should be a little more careful. Normally this would mean specifying it exactly as you had in the CREATE TABLE statement. This does not work on the first column of the example below (sqlite just treats it as constant text). In fact, you should double quote the column name and then escape the inner part as necessary, where this escaping means to double up the internal quotes. Here's an example to illustrate. Notice that when outer single quotes are used, sqlite does not match up the columns.

sqlite> create table test5 ('One"Two' integer, "Two'One" integer);
sqlite> insert into test5 values (1,2);
sqlite> insert into test5 values (3,4);
sqlite> select "One""Two" from test5;
1
3
sqlite> select 'One"Two' from test5;
One"Two
One"Two
sqlite> select "Two'One" from test5;
2
4
sqlite> select 'Two''One' from test5;
Two'One
Two'One

Csaba Gabor

2004-May-21 22:10:06 by anonymous:
I'd just like to add that if you prefix columns by the table name, then things seem to work as expected. Thus,

select test5.'One"Two' from test5; yields the expected result of: 1 3

Csaba

 
689 doc active 2004 Apr anonymous   2004 Apr anonymous 4 4 Old Comment for sqlite_decode_binary in sources ? edit
Comments in sqlite.h.in & encode.c refer to a return of -1 for an invalid data-block. I believe -1 cannot be returned. Maybe missed during jump from 1.11 to 1.12 of encode.c

Works perfectly though :)

 
48 doc active 2002 May anonymous   2004 Mar drh 1 1 use sqlite from a tclsh.exe edit
Hi !

Maybe I am to stupid to understand, but I don't really figure out how to use sqlite from a tclsh.exe333333

package require sqlite

does not work. And I did not find any simple introductory sample code.

greetings tom

2004-Sep-17 03:48:33 by anonymous:
This might help Tom: http://www.sqlite.org/cvstrac/wiki?p=SqliteTclPackageWrapper
 
652 doc active 2004 Mar anonymous Unknown 2004 Mar anonymous 5 5 small addition needed in pragma table_info edit
Small addition to the sql page:

PRAGMA table_info(table-name);

For each column in the named table, invoke the callback function once with information about that column, including the column name, data type, whether or not the column can be NULL, and whether or not the column is part of the primary key.

Last part should be added.

Best regards, Albert Drent

 
622 doc active 2004 Feb anonymous   2004 Feb   1 3 Should mention PRAGMA table_info() in FAQ edit
This is just a simple documentation suggestion. In your FAQ (www.hwaci.com/sw/sqlite/faq.html) you mention how to get a list of tables/indices by querying the schema_master, however this begs the next natural question, how can I get a list column names for each table? It is very easy to overlook the small mention of the PRAGMA table_info() command on the SQL reference page which may lead some people to pursue more awkward techniques such as attempting to parse the CREATE TABLE statement they get back from the schema_master query. Mentioning this handy little pragma near the question regarding tables/indicies would be very useful.
 
613 doc active 2004 Feb anonymous   2004 Feb   3 4 Doc is wrong with some prototypes and const is missing for errmsg edit
The C language interface to the SQLite library is incorrect in some function-prototypes regardning constness. For example, it says " int sqlite_exec(
    sqlite *db,
    char *sql,
    int (*xCallback)(void*,int,char**,char**),
    void *pArg,
    char **errmsg
    );"

In this example, the parameter "char *sql" is "const char *sql" in my sqlite.h. In addition to this, the parameter char **errmsg should be const-ified in many functions (at the moment, they're still non-const). This is especially important to C++ developers.

 
508 doc active 2003 Nov anonymous   2003 Nov   4 4 Build instructions on home page needs link to page with platform help edit
I just ran across SQLite and wanted to try to build it for Mac OS X. It seemed to build but kept failing the "make test" step. I dug around your site, then started googling trying to find information on building SQLite for Mac OS X. After quite a bit of searching, I finally found a link to a wiki page for cvstrac that told me exactly what I needed to know.

It would be handy for other folks in the future if the following link was included in the "Building From Source" section on the main page.

http://www.sqlite.org/cvstrac/wiki?p=HowToCompile

 
501 doc active 2003 Nov anonymous Unknown 2003 Nov anonymous 4 4 missing sqlite_encode_binary edit
The FAQ discusses a pair of functions for binary<-->ASCII encoding in "encode.c". I grabbed the windows "pre-processed" c files and there is no such file. Nor do I see any mention of those functions (sqlite_encode_binary) in the C/C++ documentation on the website. Was this removed for some reason? Either the FAQ needs updating or the code/docs do.
 
500 doc active 2003 Nov anonymous Unknown 2003 Nov   4 4 Discrepancies in comments in encode.c edit
The explanation for how the encoder works in src/encode.c says that the offset is added on encoding and subtracted on decoding. However, in the actual source code the reverse is true (i.e., the offset is subtracted in sqlite_encode_binary() and added in sqlite_decode_binary()). Presumably the source is correct, so the comments should be corrected to reflect this.
 
446 doc active 2003 Sep anonymous   2003 Sep drh 3 3 sqlite_compile can return no virtual machine with code SQLITE_OK edit
Hello,

Hope you are fine today!

Here is what can be found in the documentation of the C/C++ interface:

"A pointer to the virtual machine is stored in a pointer which is passed in as the 4th parameter. Space to hold the virtual machine is dynamically allocated. To avoid a memory leak, the calling function must invoke sqlite_finalize on the virtual machine after it has finished with it. The 4th parameter may be set to NULL if an error is encountered during compilation."

Just pay attention to the last line:

"The 4th parameter may be set to NULL if an error is encountered during compilation."

If you try to compile an empty query i.e. "" or ";" then SQLITE_OK is returned BUT no virtual machine.

I don't consider this as a bug because nothing has to be done for those empty queries. I just think it should be documented.

Example of documentation:

"The 4th parameter may be set to NULL if an error is encountered during compilation. It can also be NULL without error when one try to compile an empty query."

Kind regards

Valere Monseur aka Dobedo

 
286 doc active 2003 Apr anonymous   2003 Apr   3 3 Tcl command documentation does not explain (minus) options. edit
The -options of the sqlite tcl command are not documented.

-version : returns versions of sqlite

-encoding : returns default encoding

-tcl-uses-utf : returns whether tcl can handle utf strings

 
278 doc active 2003 Apr anonymous Unknown 2003 Apr anonymous 3 3 Possible documentation bug in "expression" section. edit
The documentation for expressions shows this:

  expr ::=

  ...

  ( select-statement ) |

  CASE [expr] ( WHEN expr THEN expr )+ [ELSE expr] END

I think this ought to be:

  expr ::=

  ...

  ( select-statement ) |

  SELECT CASE [expr] ( WHEN expr THEN expr )+ [ELSE expr] END

The "SELECT CASE" form seems to be needed, at least in triggers (although, I don't recall if I tried simply "CASE ..." or not).

 
192 doc active 2002 Nov anonymous Unknown 2002 Nov anonymous 4 4 Finishing build on MacOS 10.x (and other *nix's, likely) edit
Platform: MacOS 10.x (10.2.2)

Problem: "Make" of SQLite source goes fine, but using the libsqlite.a archive in an application build fails (eg., demo in Blackhole Media's ObjC wrappers, or in building Neo [http://expert.cc.purdue.edu/~mthole/neo/index.html] from source).

Errmsg: "table of contents for archive: libsqlite.a is out of date; rerun ranlib(1) (can't load from it)".

Solution: Run "ranlib libsqlite.a" in terminal.

Explanation: (From the "ranlib" manual:) "Ranlib adds or updates the table of contents to each archive so it can be linked by the link editor, ld. The table of contents is an archive member at the beginning of the archive that indicates which symbols are defined in which library members.... Ranlib takes all correct forms of libraries (fat files containing archives, and simple archives) and updates the table of contents for all archives in the file."

 
2607 event active 2007 Aug anonymous   2007 Sep   2 1 Data loss, continuation to Re: [sqlite] how to flush database to disk? edit
See that mailing list.

The originator message :


I've just lost a couple of days' worth of data when my app crashed. (Well, the data wasn't a total loss thanks to backup plans, but the database itself essentially reverted to its state of 2 days ago.) This is despite my app doing a COMMIT after every modification of the DB.

It's acting as though all the changes were held in memory, or somehow journaled, and when the crash happened, the changes were all lost or rolled back. What I need is a way to force the database to save its data to disk while my app is running, so that in the event of a crash, I lose little or no data. How can I do this? I presume that closing the database would do the trick, but is there a less heavy-handed way?


The exact like that data loss occured at me too. Three times, non-repropucible regualrilly.

What common in these losses ?

{Editing+committing} in the main thread then {navigating, bof/eof checking, reading data} from within different threads then return to the main thread for {editing+committing}.

2007-Aug-31 19:38:26 by drh:
The COMMIT does not actually occur until you call sqlite3_reset() and/or sqlite3_finalize() on all your prepared statements. Any prepared statement that has not been reset or finalized is still running, is incomplete, and is thus still holding the transaction open. I'm guessing that you have an unreset and unfinialized statement in your application.

I wonder what would happen if we changed the definition of COMMIT so that it returned an error if there were active prepared statements. This is, technically, an incompatibility. But we are coming up on a release with several other minor incompatibilities, so now might be a good time to insert such a change.


2007-Aug-31 19:45:36 by drh:
I looked in the code, and it turns out we already do this. Perhaps the application is not checking the return code from the COMMIT to see that it is failing?


2007-Aug-31 20:40:47 by anonymous:
No error reports came from COMMIT. The data loss were noticed after UPDATE & COMMIT after massive reading of results of SQL addressing the same virtual (ATTACHed) tables, from within another thread.


2007-Aug-31 20:53:48 by anonymous:
Is it possible that a pending transaction survive app shutdown & then OS restart ? Is yes, then any DB error would cause rollback to the data on last BEGIN, isn't ?


2007-Aug-31 21:00:18 by anonymous:
But me committed each smallest change to dat,a then saw these refreshed data in the tables. And on the next day these data were present. Only reading (with full scrolling ) the affected virtual tables from within another thread then new editing then committing caused the loss.


2007-Sep-01 23:12:31 by anonymous:
You mention virtual tables. Their data is not maintained by the SQLite engine, but by your own module. If that doesn't implement ACID, you're out of luck.

By definition:
A virtual table is an interface to an external storage or computation engine that appears to be a table but does not actually store information in the database file.

references:
CreateVirtualTable
VirtualTables


2007-Sep-04 04:51:15 by anonymous:
Me was wrong. These were't true virtual tables. Me used a LEFT OUTER query to several tables residing in different ATTACHed databases.


2007-Sep-04 04:52:01 by anonymous:
were't => were not, above.
 
2006 event active 2006 Sep anonymous   2006 Sep   1 1 Strange data in a table. edit
When dumping a database file, this is what I found:

CREATE TABLE TopSites ( XID INTEGER REFERENCES X(ID), YID INTEGER REFERENCES Y(ID), URLID INTEGER REFERENCES TopSitesURLs(ID));

INSERT INTO "TopSites" VALUES(-761955577, 5, 1322);
INSERT INTO "TopSites" VALUES(-761955577, 5, 1120);
INSERT INTO "TopSites" VALUES(-761955577, 5, 1323);
INSERT INTO "TopSites" VALUES(-761955577, 5, 1324);
....................................................... INSERT INTO "TopSites" VALUES(-761955577, 5, 1323);
INSERT INTO "TopSites" VALUES(-761955577, 5, 1324);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.bnimanningham.com', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.wellnesscareoncollins.com.au/Chiropractic-Articles.html', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.healthyrisepharmacy.com', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.alextechmelb.com/testimonials.html', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.ecca.com.au/melbourne-contactus.html', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.naturopathicwellness.com.au/additionaltherapies.htm', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.rrr.org.au/sponsors.php', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.caavic.asn.au/html/s02_article/show_article.asp?id=507&topic_id=-1&category_id=-1', NULL); INSERT INTO "TopSites" VALUES(NULL, 'http://www.cosmeticchoice.com.au/healing_nutrition.php?PHPSESSID=&PHPSESSID=d85928253b38f1bf88200022e7a93218', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.coca.com.au/vic.htm', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.embracechiropractic.com.au', NULL);
INSERT INTO "TopSites" VALUES(NULL, 'http://www.cooperchiro.com', NULL);

The database was created on: os: Mac OS X 10.4.6 jre: 1.5.0_06-64 sqlite: 3.3.4

The code for inserting into the database is:

  public static String GetTopSitesInsert(int aX, int aY, int aURLID)
{
return "INSERT OR ROLLBACK INTO TopSites (XID, YID, URLID) VALUES
(" + aX + ", " + aY + ", " + aURLID + ");";
}

I think that the last lines are from another table, or from another insert, as the java int could have never been a value like: http://www.bnimanningham.com

When trying to delete some rows from this table, sqlite threw "malformed database" exception and the java virtual machine crashed.

2006-Sep-29 12:23:31 by anonymous:
This is duplicate of #2005


2006-Sep-29 14:03:50 by drh:
I'm thinking this and #2005 represent a bug in whatever Java bindings the reporter is using.
 
2005 event active 2006 Sep anonymous   2006 Sep   1 1 Multiple rows with the same primary key, and null values in "not null" edit
This is what I have found when dumping a database file:

CREATE TABLE TopSitesURLs ( ID INTEGER PRIMARY KEY, URLText TEXT NOT NULL );

INSERT INTO "TopSitesURLs" VALUES(1, 'http://www.backinline.com.au');
INSERT INTO "TopSitesURLs" VALUES(2, 'http://www.wellnesscareoncollins.com.au');
INSERT INTO "TopSitesURLs" VALUES(3, 'http://www.oakleighdental.com.au/chirodontics.php');
INSERT INTO "TopSitesURLs" VALUES(4, 'http://bacinactionchiropractic.com');
INSERT INTO "TopSitesURLs" VALUES(5, 'http://melbourne.zpages.com.au/chiropractors');
INSERT INTO "TopSitesURLs" VALUES(6, 'http://myname.chiropractic.com.au');
INSERT INTO "TopSitesURLs" VALUES(7, 'http://www.melbournechiropractor.com');
INSERT INTO "TopSitesURLs" VALUES(8, 'http://www.chiroweb.net/us/fl_melbourne.html');
INSERT INTO "TopSitesURLs" VALUES(9, 'http://www.chiropractor.net.au/aridiskin.htm');
INSERT INTO "TopSitesURLs" VALUES(10, 'http://www.melbournechiropractic.com.au');
INSERT INTO "TopSitesURLs" VALUES(11, 'http://www.melbournechiropractor.com/index.php?page=privacy.php&pageID=-1');
INSERT INTO "TopSitesURLs" VALUES(12, 'http://www.vitaminstoday.com.au/chiropractor/index.php?page=grid');
INSERT INTO "TopSitesURLs" VALUES(13, 'http://www.goodechiro.com/index.asp');
INSERT INTO "TopSitesURLs" VALUES(14, 'http://www.goodechiro.com/FirstVisit.asp');
INSERT INTO "TopSitesURLs" VALUES(15, 'http://www.usenature.com/chirodirectory.htm');
INSERT INTO "TopSitesURLs" VALUES(16, 'http://www.melbournemeditationcentre.com.au/courses/teacher.htm');
INSERT INTO "TopSitesURLs" VALUES(17, 'http://www.yogatree.com.au/Therapies.htm');
................................................................................... INSERT INTO "TopSitesURLs" VALUES(6259, 'http://www.yarravillehealth.com.au/osteopath-melbourne.html');
INSERT INTO "TopSitesURLs" VALUES(6260, 'http://www.worldveganday.org.au/forum/viewtopic.php?p=4543&sid=465ea5c2e7452f6fd23470488e277781');
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(14, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);
INSERT INTO "TopSitesURLs" VALUES(15, NULL);

The database was created on: os: Mac OS X 10.4.6 jre: 1.5.0_06-64 sqlite: 3.3.4

The primary key 15 is duplicated, and the "not null" field is null.

2006-Sep-29 12:03:17 by anonymous:
What tool (and parameters) did you use to dump the database?


2006-Sep-29 13:13:28 by drh:
When I run the SQL, I get lots of errors. And the resulting database does not contain any duplicate primary keys or NULLs in NOT NULL columns.

Can you attach the database that contains duplicate primary keys and NULLs in NOT NULL columns to this ticket so that I can see it?

jre==Java Runtime Engine? Are you using some kind of java binding to SQLite? If so, which one? Is SQLite in a separate DLL, or is your Java binding using a statically linked (and possibly modified and broken) version of SQLite?


2006-Oct-03 15:15:54 by anonymous:
I am using a java wrapper for sqlite:

http://www.ch-werner.de/javasqlite/overview-summary.html

I got the same problem again:

INSERT INTO "TopSitesURLs" VALUES(13023, 'http://costaricaretirementvacationproperties.com/index.php?op=show_listing&ShowOption=Condo Resales&option=cat'); INSERT INTO "TopSitesURLs" VALUES(13024, 'http://www.hot-tropics.com/costa-rica-links.html'); INSERT INTO "TopSitesURLs" VALUES(13025, 'http://southpacificrealestateservices.com/index.php?PHPSESSID=6b7a257fad5cbd886f09526a2cd59ed8'); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(9, NULL); INSERT INTO "TopSitesURLs" VALUES(13041, 'http://www.livingabroadincostarica.com'); INSERT INTO "TopSitesURLs" VALUES(13042, 'http://limitededitionsre.com/blog.html'); INSERT INTO "TopSitesURLs" VALUES(13043, 'http://www.officecenter.nosaranet.com/property.html');

You can see the index 13025, then up to 13041 you can see only 9.

How do I upload a database?


2006-Oct-03 15:17:33 by anonymous:
I have dumped the database with sqlite3.exe in command line: sqlite3.exe file.db .dump > file.sql


2006-Oct-03 17:44:00 by anonymous:

  How do I upload a database?

Use the Attach link near the top right. Note that attachment size is currently limited to 100KB.


2006-Oct-04 06:38:23 by anonymous:
An integrity check on this database looks like this:

C:\Documents and Settings\stefan matei\Desktop>sqlite3 project.db
SQLite version 3.3.4
Enter ".help" for instructions
sqlite> PRAGMA integrity_check;
*** in database main ***
On tree page 59 cell 10: 2nd reference to page 1077
On tree page 59 cell 10: Child page depth differs
On tree page 59 cell 11: Child page depth differs
On page 871 at right child: 2nd reference to page 1078
sqlite> .quit

When can this happen? Is there a fix for this (integrity fix or something)? I ask this because the database is perfectly readable. I assume that a tool can be done to check the tables and remove all the data that are not complying to the table definition.

 
1939 event active 2006 Aug anonymous Unknown 2006 Aug   2 1 SQLite hangs with WHERE condition in an SELECT with joined table edit
I have an database with 7 Tables. I wanted to make an SELECT in which i join the other Tables with an LEFT OUTER JOIN. That works but when i add an WHERE clause on an Joined Table my Application hangs. The sqlite3.exe hangs at the same query.

My Database: CREATE TABLE MMBundesland (ID INTEGER, Bezeichnung varchar(255), Kennung INTEGER); CREATE TABLE MMCoords (ID INTEGER, Laenge DOUBLE, Breite DOUBLE, System varchar(50)); CREATE TABLE MMKFZ (ID INTEGER, Bezeichnung varchar(255)); CREATE TABLE MMKategorie (ID INTEGER,Bezeichnung varchar(255)); CREATE TABLE MMKreis (ID INTEGER, Bezeichnung varchar(255), Kennung INTEGER); CREATE TABLE MMOrte (ID INTEGER, CoordID INTEGER, Name varchar(255), KategorieID INTEGER, KreisID INTEGER, BundeslandID INTEGER, KfzID INTEGER, DefPLZID INTEGER, Kennung INTEGER); CREATE TABLE MMPLZ (ID INTEGER, PLZ varchar(10), CoordID INTEGER, OrtID INTEGER);

The Query was:

SELECT o.ID, o.Name,p.PLZ as DefPLZ,k.Bezeichnung,b.Bezeichnung as Bundesland, p.ID AS PLZID FROM MMOrte o LEFT OUTER JOIN MMPLZ p ON o.DefPLZID = p.ID OR o.ID = p.OrtID LEFT OUTER JOIN MMKategorie k ON o.KategorieID = k.ID LEFT OUTER JOIN MMBundesland b ON o.BundeslandID = b.ID LEFT OUTER JOIN MMPLZ p2 ON o.ID = p2.OrtID WHERE (p.PLZ like '72141%') ORDER BY o.Name

Wenn I use: SELECT o.ID, o.Name,p.PLZ as DefPLZ,k.Bezeichnung,b.Bezeichnung as Bundesland, p.ID AS PLZID FROM MMPLZ p LEFT OUTER JOIN MMOrte o ON o.DefPLZID = p.ID OR o.ID = p.OrtID LEFT OUTER JOIN MMKategorie k ON o.KategorieID = k.ID LEFT OUTER JOIN MMBundesland b ON o.BundeslandID = b.ID LEFT OUTER JOIN MMPLZ p2 ON o.ID = p2.OrtID WHERE (p.PLZ like '72141%') ORDER BY o.Name

The Query Works.

It seems to work if i use in WHERE Clause one Column from the Table neer the FROM keyword.

The main Problem is that SQLite hangs... I will generate my Query so that it works...

2006-Aug-25 13:32:21 by anonymous:
"Hanging" is not very descriptive. Your query is working but now it either makes poor use of indexes or is doing full table scans, or possibly an unintended cross join.


2007-Jan-10 16:31:41 by anonymous:
I am seeing the same problem. It works on a limit of 1 and then fails on a limit of 2.


2007-Jan-10 16:49:09 by drh:
If you would like me to work on this, please send a reproducible test case.
 
1935 event active 2006 Aug anonymous Parser 2006 Aug   4 4 GROUP BY and ORDER BY constant expressions valid? edit
I'm not sure what other databases do in this situation, or whether a constant expression should be deemed a constant in ORDER BY and GROUP BY and result in an error.

  CREATE TABLE t1(a,b);
  INSERT INTO "t1" VALUES(1, 2);
  INSERT INTO "t1" VALUES(1, 3);
  INSERT INTO "t1" VALUES(2, 3);
  INSERT INTO "t1" VALUES(2, 4);
  INSERT INTO "t1" VALUES(2, 5);

  -- as expected
  select a, b from t1 group by 0;
  SQL error: GROUP BY column number 0 out of range - should be between 1 and 2

  -- ???

  select a, b from t1 group by 0/1;
  2|5

  select a, b from t1 group by 0.0;
  2|5

  select a, b from t1 order by 13/2;
  1|2
  1|3
  2|3
  2|4
  2|5

  select a, b from t1 group by 3/9 order by 1/9, 7.0, 0.4-3;
  2|5
2006-Aug-26 07:26:06 by anonymous:
The integer is the column number.
 
1871 event active 2006 Jun anonymous   2006 Jun   2 3 VACUUM should not change 3.x file format edit
VACUUM should not "upgrade" the file format as it violates the principle of least astonishment. VACUUM upgrading the file format prevents users working with older versions of SQLite 3.x from sharing a common database file with users of more recent versions of the library. At the very least, if a version of SQLite can not produce the same version of the database file after VACUUM, it should do nothing, or perhaps return a warning.
2006-Jun-27 13:25:30 by drh:
What if a user wants to upgrade the file format so that they can take advantage of descending indices, for example? How should they accomplish that? Should they be forced to dump and restore the database?


2006-Jun-27 14:10:16 by anonymous:
Manually dumping the old database and restoring it with a more recent version of SQLite is reasonable given the incompatible nature of the change.


2006-Jun-27 15:30:32 by anonymous:
I agree. Can't SQLite do the equivalent of pragma legacy_file_format=1 on the new database created by the VACUUM command if the current file is in the old format?

The dump and restore operation is usable for updating the file format, but does require two installed versions of SQLite, one old and one new. Couldn't you add a new command or pragma that would do the format upgrade. Perhaps an optional upgrade argument to the VACUUM command that defualts to off could be used. If it is off the format of the new database is unchanged, if it is on, the format is upgraded. The VACUUM command doesn't seem like the obvious place tto look for a format upgrade option though. A new UPGRADE command would be more obvious, even if it is actually implemented by the same routines that do the VACUUM. It may be better to use something a little lower profile than a new command, perhaps a "PRAGMA upgrade_file_format" would be better. It would also allow future extension to provide a format version number that the database is to be upgraded to (ie PRAGMA upgrade_file_format=4).


2006-Jun-27 17:55:23 by anonymous:
it's a simple issue. since SQLite know the file format of database that is opened, on VACUUM it should create a file with the same version (such like a internal _sqlite3_open_ex() call that receive the file format that should be created. since SQLite can read/write those formats, there's no reason for doing a 'file format' upgrade.
 
1547 event active 2005 Nov anonymous Unknown 2005 Dec   1 1 slow insert into indexed table and slow index create on huge table edit
i have CREATE TABLE test (f1 VARCHAR(40), f2 INTEGER, f3 DOUBLE) with CREATE INDEX test_idx ON test(f1).

i try to load 270M(270,000,000) records into this table within transaction.

PRAGMA page_size = 8192 PRAGMA cache_size = 40000 PRAGMA syncronouse = OFF

i use Dell server : 2 x Intel XEON 2.8 Ghz with Multi-threading. 4 GB memory 2 x 72Gb HD UltraScsi320

for now it's run 7.5 hours and loaded just 30M records

2005-Nov-30 19:03:42 by anonymous:
What does your INSERT statement look like? Also, its more efficient to create the index for the table AFTER the insert has completed.


2005-Nov-30 21:50:38 by anonymous:
My Insert statement: INSERT INTO test VALUES (?, ?, ?)

I already checked option to create index after insert. Insert took 55 min. Create index was stopped after 24 hours


2005-Nov-30 22:52:32 by anonymous:

  Do you make inserts inside transaction ? If not, begin
  transaction before all inserts, commit it and then create
  index


2005-Nov-30 22:57:07 by anonymous:
it's already done. single begin transaction before inserts, single commit after


2005-Dec-01 00:28:06 by anonymous:
250 mln inserts in 55 min (your last statement) is about 76000 inserts/sec. That's a bit slow (for SQLite). My trivial system P-IV 3 GHz HT, 1 GB RAM, 100 GB Maxtor ATA 100 does that with a rate no lower than 105000 inserts/sec (non-indexed db, about 300 mln records, same schema, prepared statements). Anyway, if you're not satisfied with performance, do that with MS SQL Server - you'll easily get 1000 inserts/sec or even lower with 100% CPU usage.


2005-Dec-01 00:36:37 by anonymous:
Let me guess: you are running Windows with Symantech Antivirus active and Indexing Service turned on, right?


2005-Dec-01 00:43:16 by drh:
When creating the index, entries have to be inserted at random places throughout the (roughly) 10GiB disk file. Since you probably do not have 10GiB or RAM for caching, you are constanting having to read and write disk pages. In other words, you are thrashing.

To make it go faster, you need to establish some kind of locality of reference so pages get reused more often. Reused pages are in cache and work much faster.

After you have the data loaded but unindexed, perhaps try something like this:

  ATTACH 'new.db' AS n;
  CREATE TABLE n.test(f1 text, f2 integer, f3 double);
  CREATE TEMP TABLE prefix(x text) AS
    SELECT DISTINCT substr(f1,1,3) FROM test ORDER BY 1;
  INSERT INTO n.test 
    SELECT f1, f2, f3
      FROM prefix, test
     WHERE x=substr(f1,1,3);
  CREATE INDEX n.test_idx ON test(f1);

Suppose there are N entries in the prefix table. The INSERT statement makes N passes over the original test table inserting all entries with that prefix into the new test table. In the end, the entries in the new test table are approximately sorted. So then when you go to create the index, you have more locality of reference and the index creation should go faster.

In theory at least. Your mileage may very. You might want to adjust the size of your prefix depending on what your data looks like and how it is distributed.


2005-Dec-01 07:16:27 by anonymous:
thank you for inputs. application runing on RHEL4 without antivirus, and any unused daemons. The data is already sorted. "low" performance at insert to unindexed table caused by data generation process. but i don't understand the performance of index creation. most of time one CPU at 100% usage 3 other CPUs at 98% waits.
 
1525 event active 2005 Nov anonymous Unknown 2005 Nov anonymous 1 2 error creating database edit
with the 3.2.7 sqlite.dll i could'nt create database when the directories is with '&#231;' character like 'c:\fran&#231;ois\' but with the 3.0.2 sqlite.dll it's work
2005-Nov-18 01:44:28 by anonymous:
I'm pretty sure sqlite3_open() is expecting any non-ASCII characters in the filename to be encoded as UTF-8 rather than ISO8859-1; i.e. a c-cedilla needs to be encoded as two bytes, not one.
 
1480 event active 2005 Oct anonymous Unknown 2005 Oct   1 3 Wrong SQL statement crashes PHP+Apache edit

Configuration:

  • Windows NT VMSRV01 5.2 build 3790
  • Apache/2.0.53 (Win32)
  • PHP 5.0.5 Windows binary
  • SQLite 2.8.14 (included with PHP 5.0.5)

Windows application event log error:

Faulting application Apache.exe, version 2.0.53.0, faulting module php5ts.dll, version 5.0.5.5, fault address 0x000cd0d5.

Description:

Firing a SQL statement like

SELECT A.f1, A.f2, B.f3, B.f4 FROM t1 AS INNER JOIN t2 ON A.f1 = B.f1 ORDER BY A.f1 ASC, B.f4 DESC;
where the alias for t1 is missing, crashes both PHP and Apache.

PHP code to reproduce the problem:

<?php
ob_end_flush();

$goodSql = '';

$goodSql .= 'SELECT';
$goodSql .= '	A.categoryCode,';
$goodSql .= '	A.categoryStatus,';
$goodSql .= '	A.categoryName,';
$goodSql .= '	A.categoryDescription,';
$goodSql .= '	B.documentCode,';
$goodSql .= '	B.documentStatus,';
$goodSql .= '	B.documentFile,';
$goodSql .= '	B.documentCRC32,';
$goodSql .= '	B.documentSize,';
$goodSql .= '	B.documentTitle,';
$goodSql .= '	B.documentComments,';
$goodSql .= '	B.documentMimeType,';
$goodSql .= '	B.documentAddedOn,';
$goodSql .= '	B.documentAddedBy';
$goodSql .= '	FROM categories AS A INNER JOIN documents AS B';
$goodSql .= '	ON A.categoryCode = B.categoryCode';
$goodSql .= '	WHERE A.categoryStatus = "active" AND B.documentStatus = "active"';
$goodSql .= '	ORDER BY A.categoryCode, B.documentAddedOn DESC;';

$wrongSql = '';

$wrongSql .= 'SELECT';
$wrongSql .= '	A.categoryCode,';
$wrongSql .= '	A.categoryStatus,';
$wrongSql .= '	A.categoryName,';
$wrongSql .= '	A.categoryDescription,';
$wrongSql .= '	B.documentCode,';
$wrongSql .= '	B.documentStatus,';
$wrongSql .= '	B.documentFile,';
$wrongSql .= '	B.documentCRC32,';
$wrongSql .= '	B.documentSize,';
$wrongSql .= '	B.documentTitle,';
$wrongSql .= '	B.documentComments,';
$wrongSql .= '	B.documentMimeType,';
$wrongSql .= '	B.documentAddedOn,';
$wrongSql .= '	B.documentAddedBy';
$wrongSql .= '	FROM categories AS INNER JOIN documents AS B';
$wrongSql .= '	ON A.categoryCode = B.categoryCode';
$wrongSql .= '	WHERE A.categoryStatus = "active" AND B.documentStatus = "active"';
$wrongSql .= '	ORDER BY A.categoryCode, B.documentAddedOn DESC;';

echo '<h2>Running good SQL</h2>';
flush();
test('./db/sagnedb.dat', $goodSql);
flush();

echo '<h2>Running wrong SQL in 20 seconds...</h2>';
flush();
for ($i = 20; $i > 0; $i--) {
  echo "<small>$i...</small>";
  echo str_repeat(' ', 4096);
  flush();
  sleep(1);
}
test('./db/sagnedb.dat', $wrongSql);
echo '<h1>It will never print this!!!!!!!!!!!!!!!!!!!!!<h2>';
flush();

function test($dbFilename, $sql) {
//  ini_set('sqlite.assoc_case', 2);
  if ($dbConn = sqlite_open($dbFilename, 0666, $dbError)) {
    $sql = sqlite_escape_string($sql);
    if ($queryResult = @sqlite_query($dbConn, $sql)) {
      $n = sqlite_num_fields($queryResult);
      echo 'cols: ' . $n . '<br />';
      echo 'rows: ' . sqlite_num_rows($queryResult) . '<br />';
      for ($i = 0; $i < $n; $i++) {
        echo 'field[' . $i . ']: ' . sqlite_field_name($queryResult, $i) . '<br />';
      }
      echo '<br />data:<pre>';
      $data = sqlite_fetch_all($queryResult, SQLITE_ASSOC);
      print_r($data);
      echo '</pre>';
    }
    sqlite_close($dbConn);
  }
}
?>

Sergio

2005-Oct-11 22:19:24 by anonymous:
I had no idea to whom I'd have assigned this.

Sorry about that.

Sergio


2005-Oct-12 02:58:37 by anonymous:
This is the wrong place to file this bug. Report this to the PHP folks; Unless you can reproduce the issue with sqlite alone.


2005-Oct-12 15:05:42 by anonymous:
The alias for t1 is not missing, it's "INNER". This is a perfectly well formed SQL statement. The problem is that SQLite is not reporting the erroneous use of the reserved word INNER as an identifier when it should.

It does not do this for all reserved words as shown below.

  sqlite> select * from t as join;
  SQL error: near "join": syntax error
  sqlite> select * from t as "join";
  sqlite> select * from t as inner;
  sqlite>

However, I suspect that the error reported for the first select is due to the right hand table being omitted in the join, not because it recognizes that the alias (what the standard calls a correlation name) is a reserved word. The second select does not produce an error when it should, because the alias is still a reserved word even though it is delimited by double quotes. The third select does not produce an error either.


2005-Oct-12 15:09:36 by anonymous:
Of course this lack of error reporting is not what is causing Apache and/or PHP to crash. The erroneous queries that are accepted by SQLite execute correctly.

  sqlite> select * from t as inner;
  1|2
  2|4
  sqlite> select * from t as "join";
  1|2
  2|4
 
1469 event active 2005 Oct anonymous Parser 2005 Oct   1 1 Having problems with subselects that work on mySQL edit
I'm converting from mySQL. However I've run across several sub-selects that work on mySQL but not SQLite. Apache gives me a error. If I can't get them fixed, I will be forced back to mySQL. Not sure what I'm doing wrong. Basically trying to find the last variety record against a Wine Process Order (wpo). Program is in PHP5 script as follows:
	$sql =  "
	SELECT *
	FROM 
	wpo W,
	wpo_dtl as D,
	wpo_varietal V,
	storage S,
	variety VM
	WHERE 	S.stop_trace <> 'Y' 	

	AND     D.storage_id = S.storage_id
	AND	D.from_to	= 'T'
	AND	D.wpo_num = W.wpo_num
	AND	D.leg_num = W.leg_num

	AND	V.storage_id	= S.storage_id
	AND	V.from_to	= 'T'
	AND	V.wpo_num	= D.wpo_num
	AND	V.leg_num	= D.leg_num

	AND	VM.variety_num	= V.variety_num
	AND	VM.color	= 'R'

	AND 	W.wpo_datetime = (SELECT MAX(W1.wpo_datetime) 
	FROM 	wpo as W1,wpo_varietal as V1
	WHERE 	V1.storage_id = S.storage_id
	AND 	V1.from_to = 'T'
	AND 	W1.wpo_num = V1.wpo_num
	AND 	W1.leg_num = V1.leg_num)
	ORDER BY S.storage_id";
	$query = sqlite_query($link_id, $sql);
	$result = sqlite_fetch_all($query, SQLITE_ASSOC);
	foreach ($result as $qd) 
		{
...............
------------------------------------------
2005-Oct-05 20:08:11 by anonymous:
You've said it "gives you an error" and "doesn't work" but you don't tell anybody what error message it gives you or how it fails. Nobody here can help you solve your problem unless you provide that information.
 
1426 event active 2005 Sep anonymous Unknown 2005 Sep drh 2 2 Problem with DETACH in 2.8.16 edit
sqlite1.txt:

  create table documents (a);
  create index i on documents(a);

sqlite2.txt:

  attach 'x1.dbx' as d1; 
  attach 'x2.dbx' as d2;
  detach d1;

Commands:

  sqlite x1.dbx<script1.txt
  sqlite x2.dbx<script1.txt
  sqlite  myfile<script2.txt

The "detach" command in the last script will crash (sqlite.exe and sqlite.dll under Windows).

2005-Sep-13 22:55:06 by anonymous:
FWIW, this is no longer a problem in 3.2.5.


2005-Sep-14 00:36:31 by drh:
This problem does not exist in recent versions of SQLite. The problem does not cause database corruption. And it does not seem to impact many users since SQLite 2.x has been stable for over 1.5 years and nobody has yet complained. For all of these reasons, I'm going to have to give this issue a low priority.


2006-Jul-12 10:38:04 by anonymous:
The exact problem is a crash when you detach a db which is not the last attached...

Sure it's doesn't corrupt db but it's really disturbing. The only current trick is to :

  • memorize coming attached db,
  • detach them in inverse mode,
  • detach the one you wanted
  • and reattach the memorized
 
1393 event active 2005 Aug anonymous Unknown 2005 Aug   4 3 failure in select2-2.0.3... test edit
The "select2-2.0.3" self-test of sqlite 3.2.5 self test returned a bogus result, quote (indented by 2 spaces each):

  select2-2.0.1... Ok
  time with cache: 4123975 microseconds per iteration
  select2-2.0.2... Ok
  time without cache: 3089313 microseconds per iteration
  select2-2.0.3...
  Expected: [1]
       Got: [0]
  select2-2.1... Ok
[...]
  1 errors out of 20174 tests
  Failures on these tests: select2-2.0.3

This was on SuSE Linux 9.3 (kernel 2.6.11.4-21.8-default, a SUSE modified kernel) on a ext3 file system with 850 MB free on a parallel ATA hard disk drive with UDMA (i. e. CRC checking).

The configure options were:

  ../configure -C CFLAGS="-O2 -march=i586 -mcpu=athlon-xp"

The compiler was:

  gcc (GCC) 3.3.5 20050117 (prerelease) (SUSE Linux)

I haven't yet had the time to re-run the test with a released GCC 3.3.X or 3.4.Y compiler, but can do so if that is desired. Please send directions how to run only this test or a smaller subset of the tests.

2005-Aug-29 02:08:53 by anonymous:
This doesn't look like a major failure. The test is timing related. Did you run "make test" on an otherwise idle machine, or did you have other cpu/disk intensive processes running?

For comparison (using kernel-2.4.31, glibc-2.3.5, and gcc-3.3.6):

  # cat /proc/cpuinfo
  processor       : 0
  vendor_id       : AuthenticAMD
  cpu family      : 6
  model           : 8
  model name      : AMD Athlon(tm) XP 2200+
  ...

  # ./testfixture test/select2.test
  select2-1.1... Ok
  select2-1.2... Ok
  select2-2.0.1... Ok
  time with cache: 447501 microseconds per iteration
  select2-2.0.2... Ok
  time without cache: 1255564 microseconds per iteration
  select2-2.0.3... Ok
  ...
  0 errors out of 21 tests
  Failures on these tests:


2005-Aug-29 23:21:08 by drh:
To run the "select2" set of tests, do this:

   ./testfixture ../sqlite/test/select2.test


2005-Aug-29 23:25:12 by drh:
I'm running SuSE 9.2 with an 3.0GHz P4. My test times are much faster:

  select2-2.0.1... Ok
  time with cache: 767370 microseconds per iteration
  select2-2.0.2... Ok
  time without cache: 1879281 microseconds per iteration

Since the test time should be dominated by disk I/O not CPU, I am not sure why this is. Are you running on a laptop?

 
1302 event active 2005 Jun anonymous Unknown 2005 Jun   1 4 malloc error after dumping table edit
I dumped a table then quit SQLite and received the following error while using the shell program.

sqlite> .output "/participants.csv" sqlite> .dump part_info sqlite> .quit sqlite3(1593,0xa000ef98) malloc: *** Deallocation of a pointer not malloced: 0x726f7365; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug Segmentation fault

 
1300 event active 2005 Jun anonymous Unknown 2005 Jun   2 2 Apache.exe has encountered a problem and needs to close. edit
I converted a MySql DB to SWLite. They are running on the same system and have identical data. Works on MySQL and not SQLite. SQLite gives Apache problem above. It's a very simple SQL that finds the last WPO (Wine Process Order) for each storage tank. Here is the SQL
SELECT s.storage_id, d.from_to, d.leg_num, d.wpo_num, w.wpo_datetime, s.descr FROM wpo_dtl AS d, wpo AS w, storage AS s WHERE d.wpo_num = w.wpo_num AND d.leg_num = w.leg_num AND s.storage_id = d.storage_id AND w.wpo_datetime = ( SELECT max(wa.wpo_datetime) FROM wpo as wa, wpo_dtl as da WHERE da.wpo_num = wa.wpo_num AND da.leg_num = wa.leg_num AND da.storage_id = s.storage_id)
WPO has; wpo_num int,leg_num int , wpo_datetime datetime ... WPO_DTL has; wpo_num int,leg_num int, storage_id char ... Storage has; storage_id char ...
Thank you for your time.. Have a great day. Dan
2005-Jun-23 19:31:49 by drh:
Please include the database schema so that we can have at least an outside chance of reproducing the problem.

Please also note that version 3.2.2 is current and version 2.8.16 is current in the legacy version 2 series. Your bug has likely already been fixed.

 
1295 event active 2005 Jun anonymous Unknown 2005 Jun   1 1 SQL query involving subqueries causes reproduceable segfault in 2.8.14 edit
The query is

			SELECT COUNT(g.gid) 
			FROM kestassd_games g 
			WHERE (
				(
					SELECT COUNT(m1.gid) 
					FROM kestassd_memberships m1 
					WHERE m1.gid=g.gid
				) 
				=
				(
					SELECT COUNT(m2.gid) 
					FROM kestassd_memberships m2 
					WHERE m2.gid=g.gid 
					AND m2.finalized=1
				)

				OR (".time()." > g.nextproc)

				)

				AND NOT (g.mode = 0)
When executed Apache 2 logs a segfault, and you disconnect with no error message. The error which Apache reports is "[Tue Jun 21 15:39:05 2005] [notice] child pid 1107 exit signal Segmentation fault (11)"

Here's a zip/tar.gz of the database file which causes the segfault to occur if you run the query, along with a PHP script which will connect and execute the query: http://www.kuliukas.com/segfault.zip or http://www.kuliukas.com/segfault.tar.gz

Thanks for the help, please e-mail me if you need more info.

2005-Jun-21 09:28:35 by drh:
I will look at this. But because there is no easily reproducible script and the bug is against an older version of SQLite (a version to which many bug fixes have already been published), this problem will be investigated at a lower priority. I've attached a copy of the segfault.tar.gz file so that if the files on the http://www.kuliukas.com/ website go away we will still have a copy available.


2005-Jun-21 14:27:27 by anonymous:
Bear in mind that this is the version used in PHP 5 currently, it's quite a commonly used version I imagine, but I see your point.
 
1128 event active 2005 Feb anonymous Shell 2005 Feb   2 3 sqlite3-3.1.2.bin segfaults edit
Linux 2.4.26 (Knoppix 3.4 on hard drive)

download: http://sqlite.org/sqlite3-3.1.2.bin.gz

attached: strace log

In the strace log I notice that the segfault happens just after /etc/nsswitch.conf has been read, if that's of any consequence.

 
919 event active 2004 Sep anonymous Unknown 2004 Sep   1 1 'make test' RESETS macOSX at ioerr 2.73.1 edit
make test.. as ioerr 2.73.1 prints, the whole system freezes and MacOSX tells me to restart
2004-Sep-30 06:37:01 by anonymous:
I run "make test" often on a PowerBook G4 running Mac OS X 10.3.5. I've never seen this behavior. It might be helpful for you to include more information about the circumstances of the crash. --SCG
 
727 event active 2004 May anonymous   2004 May   4 3 "wrong" affected row value returned by REPLACE edit
When updating an existing row using the REPLACE syntax sqlite returns 1. This makes it impossible to know of an existing row was affected by the REPLACE call (1: no existing call was affected; 2: an existing row was affected).

MySQL (which I assume was used as the example of the REPLACE syntax) returns a more hopeful 2 in this case. This may be due to their implementation which does an INSERT and a conditional DELETE if a contraint violation was detected due to the INSERT.

 
720 event active 2004 May anonymous   2004 May   1 1 Write problem on MS Windows 98 edit
I've installed Python 2.3 and PDO on my Win98 machine and use SQLite as my DB. When script is running data is writing into tables, but after it quit there is no data in tables. The same script I run on Linux and Win98, but on Win98 it does not "leave" data in tables. On Linux all is right. (sorry for my English :)
 
697 event active 2004 Apr anonymous Unknown 2004 May   3 4 Questionable locking edit
Situation: SELECT some data into a statement handle. Loop through that statement handle using fetchrow_hashref(). For each row, do something, and then UPDATE the database with the return code. My UPDATES were failing with little to no information coming back from the DBI layer. (Even w/ trace on.)

Solution: As it turns out, the DB was locked from the first SELECT, and the UPDATES couldn't be written. So, I used fetchall_hashref() instead. That way, I took all the info in, undefined the statement handle, and the UPDATES work fine.

This may be as-intended, I can understand the appeal of simple locking for the niche SQLite fills. But, 1) the FAQ item 7, sentence one leads me to believe that SELECTS don't lock, and 2) common sense tells me that SELECTS are read-only and shouldn't lock.

I also wrote this up at perlmonks.org as the problem was found. http://www.perlmonks.org/index.pl?node_id=345931

Thanks for SQLite -- it's one of my favorite open source packages. Do one thing and do it well. Thank you.

2004-May-03 19:26:07 by anonymous:
Well, it seems that SqlLite only allows for one query to be completely executed at a time. This includes SELECT.

To test this, create a database test as follows,

create table test_table(a); INSERT INTO test_table VALUES('test');

Then run the following program. Executing another query does not work, even using a seperate VM. Right now, SELECT blocks, which makes things more difficult... :( Even worse, the DELETE does not even return an error - just fails silently.

#include <sqlite.h>
#include <stdio.h>

int main()
{
        sqlite *d1, *d2;
        const char *tail1, *tail2;
        const char **col_data1, **col_names1;
        const char **col_data2, **col_names2;
        sqlite_vm *v1, *v2;
        int i, j;
        int pN;
        char del_msg[255];
        char *err;

        d1 = sqlite_open( "test", 0, &err );
        if( err != 0 ) printf( "Open error: %s\n", err );

        d2 = sqlite_open( "test", 0, &err );
        if( err != 0 ) printf( "Open error: %s\n", err );


        /* Select one row */
        printf( " allocated: %d %d\n", (int)d1, (int)d2 );
        i = sqlite_compile( d1, "select * from test_table", &tail1, &v1, &err );
        sqlite_step( v1, &pN, &col_data1, &col_names1 );

        if( err != 0 )  printf( "Select error: %s\n", err );
        printf( "nCols: %d\n", pN );

        sprintf( del_msg, "delete from test_table where a=\"%s\"", col_data1[0]);
        printf( "%s\n", del_msg );

/*     // UNCOMMENT FOR THIS TO WORK
*       
*       sqlite_finalize( v1, &err );
*       if( err != 0 )  printf( "Finalize error: %s\n", err );
*
*/
        /* Delete that row */
        j = sqlite_compile( d2, del_msg, &tail2, &v2, &err );
        if( err != 0 )  printf( "Delete error: %s\n", err );
        sqlite_step( v2, &pN, &col_data2, &col_names2 );

        sqlite_finalize( v2, &err );
        if( err != 0 )  printf( "Finalize error: %s\n", err );

        /* COMMENT FOR THIS TO WORK */
        sqlite_finalize( v1, &err );
        if( err != 0 )  printf( "Finalize error: %s\n", err );
        /****************************/

        sqlite_close( d1 );
        sqlite_close( d2 );

        return 0;
}
 
592 event active 2004 Feb anonymous Unknown 2004 Feb   1 1 VIEW produces strange result set edit
VIEW produces strange result set, which is different from the select-statment that created the VIEW does. I'll use a simple database to show the problem. My current Sqlite version is : 2.8.11 running on WinXP

definition: a simple database to manage purchase and sale of a book


  CREATE TABLE buy(book,num);
CREATE TABLE sell(book,num);
INSERT INTO buy values(1,10);
INSERT INTO sell values(1,5);
INSERT INTO sell values(1,5);

so now I have two tables like these:

  table buy: 
sqlite> select * from buy;
book        num
----------  ----------
1           10

  table sell:
sqlite> select * from sell;
book        num
----------  ----------
1           5
1           5

now create a view to see how many book 1 are sold:

    CREATE VIEW v_sell AS
	SELECT book,sum(num) AS num 
	FROM sell
	GROUP BY book;
view v_sell:
sqlite> select * from v_sell;
book        num
----------  ----------
1           10

then create a view to see how many book 1 are in stock:

    CREATE VIEW v_stock AS
	SELECT buy.book AS book,buy.num - v_sell.num AS stock
	FROM buy,v_sell 
	WHERE buy.book=v_sell.book;

but this produces a strange table:

   sqlite> select * from v_stock;
book        stock
----------  ----------
1           0
1           0

there should be only one row in VIEW v_stock, but it gives out two. when run the query SELECT buy.book AS book,buy.num - v_sell.num AS stock FROM buy,v_sell WHERE buy.book=v_sell.book; in CREATE VIEW v_stock alone, it works just fine, and produces table as this:

   sqlite>         SELECT buy.book AS book,buy.num - v_sell.num AS stock
   ...>         FROM buy,v_sell
   ...>         WHERE buy.book=v_sell.book;
book        stock
----------  ----------
1           0

I wonder why VIEW v_stock produces a table which is not exactly the same as the select-

statement created it does. Need some help ... :(

 
540 event active 2003 Dec drh   2003 Dec   1 5 Database corruption observed edit
The CVSTrac database for SQLite become corrupt sometime between 2003-12-23 and 2003-12-31. The corruption is visible using

   PRAGMA integrity_check;

Note that the EXT3 filesystem on which the database file resided was corrupted by a power outage during this same time interval. The EXT3 errors were (allegedly) fixed by fsck. The EXT3 errors may have been (or was likely) the origin of the database corruption.

The database errors were fixed using

   sqlite sqlite.db .dump | sqlite sqlite.db.new
   mv sqlite.db.new sqlite.db

The old corrupt database has been saved for analysis.

Unless additional corruption reports come in, we will assume this was an EXT3 problem, not an SQLite problem. But we want to have a record of the problem just in case...

 
180 event active 2002 Oct anonymous   2003 Dec anonymous 1 1 on WIN32 - multithreaded process causes crash on assert(mutext) edit
I'm testing how the sqlite is handling load with multiple threads and processes writing to the same table in the same db. the attached program instantiates 3 threads that are sequentially updating a table. each thread has its own db connection (sqlite * psqlite). I tried running 2 instances of this program simultaneously and the following happens:

many times i get "Disk I/O Error" - but then i close an re-open the db and it works (is that the way to handle this problem?) some times i get the error " Error db no such table: ac" (that's a strange one - i also re-open the db to recover) but after a while the program constantly crashes on the following line: line 889 in os.c ( assert( !inMutex );) I'm currently testing it under windows 2000 - but this program should also run on linux. i'm attaching the code and a database (AWDB) on which i tested it.

I'm also experiencing this in linux doing multithreaded load tests with 2 threads updateing and 3 threads selecting. Nevermind! This was due to THREADSAFE not being defined at build time. It might be nice to have this defined by default.
 
409 event active 2003 Jul anonymous Unknown 2003 Dec anonymous 3 1 sqlite_open will cause segfault when using Rational PurifyPlus/Linux edit
Note: I'm not certain if this is a sqlite or purifyplus problem

While trying to troubleshoot some minor memory leaks in my application, I noticed that when using PurifyPlus the appliation will segfault when calling sqlite_open. I encountered the same problem when profiling src/threadtest.c.

1 - thread 11 - (thread) Run @ Sat Jul 19 23:58:54 2003

SIG (Signal 11 Handled: Segmentation fault)

   It occurs near after:

     worker_bee [/scratch/hsiab_c/hsiabd/t/sql/sqlite/src/threadtest.c] line 207

     main [/scratch/hsiab_c/hsiabd/t/sql/sqlite/src/threadtest.c] line 265

Program exit code: 11

No Memory Leak detected

The same problem happens when testing with an incredibly simple program:

#include <stdio.h> #include <stdlib.h> #include <sqlite.h> #ifdef MTRACE #include <mcheck.h> #endif

int main() {

    sqlite *db;
    char *azErr;

    #ifdef MTRACE 
        mtrace();
    #endif

    db = sqlite_open("/tmp/testdb", 0, &azErr);

    if (db == 0) {
        printf("Couldn't open db file!\n");
        free(azErr);  
        exit(0);
    }

    sqlite_close(db);

}

Oddly enough, when I mtrace this program is complains with:

Memory not freed:


   Address     Size     Caller
0x08049bd0     0x40  at 0x4004a3ac

I'm not sure if this is even related. Any ideas?

This problem is occuring on Redhat 7.2 with sqlite 2.8.5 and purifyplus 2003.06.00.
 
307 event active 2003 May anonymous Shell 2003 Dec anonymous 1 1 fail to rpm install on redhat 9 edit
OS: Redhat 9.0 Kernel: 2.4.20-8 rpm: 4.2

package: sqlite-2.8.0-1.i386.rpm Error: headerRead failed: region trailer: BAD, tag 2053730304 type 956301312 offset -4128768 count 524287

 
207 event active 2002 Dec anonymous Shell 2003 Dec   2 1 After installation cannot create any databases edit
After installation of sqlite 2.7.4, use of the commandline to create a database always ends with a SQL error: database locked. The file of the database is created.
I've been experiencing the same issue with 2.8.0, compiled for the Cygwin environment in Windows 95. The issue is not present if I instead compile for the MinGW environment.

For my case, I've tracked it down to an issue with the behaviour of advisory locking in Cygwin (based on the fcntl POSIX function). I've patched my copy to work around the issue by clearing any existing locks on a file before attempting to acquire a new one, though I'm not too sure this is the best solution.

Russell Reed (rreed@cei.net)


Same for me with sqlite 2.8.6. Here's my environment:

$ dmesg |head

Linux version 2.2.25 (root@sbgpcs22) (gcc version 2.95.4 20011002 (Debian prerelease)) \#1 SMP Mon Mar 31 19:10:06 CEST 2003

BIOS-provided physical RAM map:

BIOS-e820: 0009f000 @ 00000000 (usable)

BIOS-e820: terface adding patch-sets, bug tracking, and Wiki to CVS. http://www.hwaci.com/sw/cvstrac/.

 
509 event active 2003 Nov anonymous   2003 Nov   5 3 SQLite on Pocket PC - question - how to do that step by step? edit
Hi! First of all I really appreciate work you guys did with SQLite. My question is; can anyone tell me how can I create the SQLite version working with Unicode (_UNICODE defined on Win32) on Pocket PC platform. The case is I am creating application for pocket PC to cooperate with PC computer, and while I create and access database on the PC, I cant open or even create new database on Pocket PC. I was succesfull in compiling SQLite as it is ported to CE but always I get the error that the database disk image is malformed, even if I am creating new database. Does any one was successful in creating and accessing database on Pocket PC and then in copying it to PC and accessing it on PC? I will not stick to Unicode since I am converting the wide char to char but this is not helping in avoiding the malformed error while creating or accessing database.

I would appreciate any help, I am quit new bee for database sources and SQLite looks for me quite complex to get into it.

Artur

2004-Aug-20 09:14:36 by anonymous:
I have the same problem. I create a little parser using scripts for traslating a MySQL database to SQLite database. I pass the db file with ActiveSync. I open the file correctly with a XML generator that I create with Visual Studio, but I'm trying to do the same project with eMbedded Visual C++ 4.0 and I have a lot of errors. Can anybody help me? Thanks a lot. aaronpl@ya.com


2005-May-11 14:30:47 by anonymous:
Am also trying to port sqlite3.2.1 to WinCE, and have many errors in eMbeddedVC++ Version 4 sp4, mainly
btree.c(549) : error C2059: syntax error : 'type'

Error in line assert( iCell<int(get2byte(&data[pPage->hdrOffset+3])) );


btree.c(601) : warning C4244: '+=' : conversion from '__int64 ' to 'unsigned int ', possible loss of data

Many errors of this form, this line nPayload += pInfo->nKey;


os_win.c(394) : error C2065: 'LOCKFILE_FAIL_IMMEDIATELY' : undeclared identifier

Error in line res = LockFileEx(id->h, LOCKFILE_FAIL_IMMEDIATELY, 0, SHARED_SIZE,0,&ovlp);


 
493 event active 2003 Nov anonymous Unknown 2003 Nov   3 3 Problem compiling sqlite edit
  # gmake
./libtool gcc -s -O3 -march=i686 -DOS_UNIX=1 -DOS_WIN=0 -DHAVE_USLEEP=1 -I. -I./src -DHAVE_READLINE=1 -I/usr/local/include/readline -o sqlite ./src/shell.c \
        libsqlite.la -lreadline  -rpath /usr/local/lib
gcc -s -O3 -march=i686 -DOS_UNIX=1 -DOS_WIN=0 -DHAVE_USLEEP=1 -I. -I./src -DHAVE_READLINE=1 -I/usr/local/include/readline -o .libs/sqlite ./src/shell.c  ./.libs/libsqlite.so -lreadline -Wl,--rpath -Wl,/usr/local/lib
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `tgetnum'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `tgoto'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `tgetflag'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `BC'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `tputs'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `PC'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `tgetent'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `UP'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libreadline.so: undefined reference to `tgetstr'
collect2: ld returned 1 exit status
gmake: *** [sqlite] Error 1
 
128 event active 2002 Jul anonymous Unknown 2003 Oct   4 4 Workaround for problem reported in ticket 127- edit
Replacing the misuse-5.3 test case with the following enables testfixture to continue running the quick test suite without bus error on Mac OS X 10.1.5/Tcl 8.4b4.

  do_test misuse-5.3 {
    db close
    catch { sqlite_exec_printf $::DB {SELECT * FROM t1} {} } result
    set result
  } {21 {library routine called out of sequence}}
This problem does not appear under Linux or Win2K. It may be an issue with OS X or with the new Tcl. See also tickets #126, #127, and #129.
 
463 event active 2003 Sep anonymous   2003 Sep   2 1 list index out of bounds(1) edit
I am using the sqlite.dll with "sqlitedbu.pas" package in Delphi 7. Database has only one table called "baza". 'create table baza(filename string, bin blob)'; There is no problem when i am inserting mime encoded files into table. problem is when i have more than 200 records. Delphi gives me explanation : "list index out of bounds(1)". Same query in sqlite console works with no problems. same problem happens if i index table or when i create unique fields. query I've used is: _select filename from baza where filename like "%" order by filename;_
*Delphi code:*
procedure TForm1.Edit1Change(Sender: TObject);
var t:string;
baza:TSQLiteDB;
i:integer;
begin
t:=edit1.Text;
ListBox1.Clear;
if (DataBaseName<>'') then begin
baza:=TSQLiteDB.Create(nil,DataBaseName);
baza.sql:='select filename from baza where filename like "'+t+'%" order by filename';
baza.ExecSQL;
baza.Open;
if baza.RecordCount>0 then begin
baza.First;
while not baza.EOF do begin
ListBox1.Items.Add(baza.Fields['filename']);
baza.Next;
end;
end;
baza.Close;
FreeAndNil(baza);FreeAndNil(i);
end;
end;
 
462 event active 2003 Sep anonymous   2003 Sep   2 1 list index out of bounds(1) edit
I am using the sqlite.dll with "sqlitedbu.pas" package in Delphi 7. Database has only one table called "baza". 'create table baza(filename string, bin blob)'; There is no problem when i am inserting mime encoded files into table. problem is when i have more than 200 records. Delphi gives me explanation : "list index out of bounds(1)". Same query in sqlite console works with no problems. same problem happens if i index table or when i create unique fields. please help me to resolve this.
 
362 event active 2003 Jun anonymous Shell 2003 Jun jadams 4 2 Problem with select count edit
select count() nonetable;

select count without FROM always return 1, not return error message :-)

 
335 event active 2003 Jun anonymous Unknown 2003 Jun drh 2 2 ChangeCount still failing edit
Ah, I've traced deeper in my code instead of concluding that the workaround I've implemented in version 2.8.0 is still needed. Perhaps the problem lies a bit deeper. Here's what's happening in the driver: - SQLite_Compile 'update Simpsons set Firstname = "Homer." where Lastname = "Simpson" and Firstname = "Homer" ' - SQLite_Step which returns ok - SQLiteChanges which returns 1 Now the weird thing kicks in (See also my ticket #261): - SQLite_Finalize fails with "call is out of sequence" If I perform the following ticket #335 is relevant - SQLite_Step until EOF - Don't call SQLite_Finalize (reource leaking?) Any next virtual machine will increment the SQLiteChanges with the previous SQLiteChanges, again and again. Perhaps #335 is non relevant if #261 is fixed with the procedure described above.
Below are snippets of log from my sqlite dbexpress driver. Every execute line is using a different virtual machine. The first time everything is ok, the second virtual machine however doesn't seem to have reset the changecount, because it returns two changes. This increments to three, four etc...
Execute: update Simpsons set Firstname = "Homer." where Lastname = "Simpson" and Firstname = "Homer"

Rows affected: 1

Execute: update Simpsons set Firstname = "Barney." where Lastname = "Gumbles" and Firstname = "Barney"

Rows affected: 2

etcetera

I am unable to reproduce this with SQLite. Can you provide a pure SQL script that generates this behavior? Are you certain the problem is in SQLite and not in the DBExpress driver?
 
271 event active 2003 Mar anonymous Unknown 2003 Mar drh 3 2 'make test' fails on MacOS X edit
As per a message from drh, adding -DSQLITE_TEST=1 to the make file may fix the problem. Unfortunately adding -DSQLITE_TEST=1 to the makefile broke the sqlite build (not test) with the linker errors below. Adding -DSQLITE_TEST=1 just for the 'make test' did not fix the problem with the tests.

---- from 'make test' with or without -DSQLITE_TEST=1
trans-9.1...
Error: no such function: randstr
trans-9.2.1-0...
Error: cannot start a transaction within a transaction
trans-9.2.2-0...
Error: cannot start a transaction within a transaction
trans-9.2.9-0...
Error: no such function: randstr
trans-9.3.1-0...
Error: cannot start a transaction within a transaction
trans-9.3.2-0...
Error: cannot start a transaction within a transaction
trans-9.3.9-0...
Error: no such function: randstr
trans-9.4.1-0...
Error: cannot start a transaction within a transaction
trans-9.4.2-0...
Error: cannot start a transaction within a transaction
trans-9.4.9-0...
Error: no such function: randstr
trans-9.5.1-0...
Error: cannot start a transaction within a transaction
*** Giving up...
11 errors out of 13684 tests
Failures on these tests: trans-9.1 trans-9.2.1-0 trans-9.2.2-0
trans-9.2.9-0 trans-9.3.1-0 trans-9.3.2-0 trans-9.3.9-0 trans-9.4.1-0
trans-9.4.2-0 trans-9.4.9-0 trans-9.5.1-0
make: *** [test] Error 1

---- from 'make':
ld: multiple definitions of symbol _btree_native_byte_order
auth.lo definition of _btree_native_byte_order in section (__DATA,__common)
btree.lo definition of _btree_native_byte_order in section (__DATA,__data)
build.lo definition of _btree_native_byte_order in section (__DATA,__common)
delete.lo definition of _btree_native_byte_order in section (__DATA,__common)
expr.lo definition of _btree_native_byte_order in section (__DATA,__common)
func.lo definition of _btree_native_byte_order in section (__DATA,__common)
hash.lo definition of _btree_native_byte_order in section (__DATA,__common)
insert.lo definition of _btree_native_byte_order in section (__DATA,__common)
main.lo definition of _btree_native_byte_order in section (__DATA,__common)
os.lo definition of _btree_native_byte_order in section (__DATA,__common)
pager.lo definition of _btree_native_byte_order in section (__DATA,__common)
ld: multiple definitions of symbol _journal_format
btree.lo definition of _journal_format in section (__DATA,__common)
pager.lo definition of _journal_format in section (__DATA,__data)
ld: multiple definitions of symbol _pager_refinfo_enable
btree.lo definition of _pager_refinfo_enable in section (__DATA,__common)
pager.lo definition of _pager_refinfo_enable in section (__DATA,__data)
parse.lo definition of _btree_native_byte_order in section (__DATA,__common)
printf.lo definition of _btree_native_byte_order in section (__DATA,__common)
random.lo definition of _btree_native_byte_order in section (__DATA,__common)
select.lo definition of _btree_native_byte_order in section (__DATA,__common)
table.lo definition of _btree_native_byte_order in section (__DATA,__common)
tokenize.lo definition of _btree_native_byte_order in section (__DATA,__common)
update.lo definition of _btree_native_byte_order in section (__DATA,__common)
util.lo definition of _btree_native_byte_order in section (__DATA,__common)
vdbe.lo definition of _btree_native_byte_order in section (__DATA,__common)
where.lo definition of _btree_native_byte_order in section (__DATA,__common)
trigger.lo definition of _btree_native_byte_order in section (__DATA,__common)
make: *** [libsqlite.la] Error 1
2004-Aug-14 00:40:23 by anonymous:
On Mac OSX 10.3.5 with sqlite 3.0.4, "make test" resulted in:
    0 errors out of 22420 tests

I suggest this bug be closed.


2004-Nov-09 20:48:41 by anonymous:
Server compiled fine here on Mac OS X 10.3.6, none of the tests fail.
 
255 event active 2003 Feb anonymous   2003 Feb   1 1 Database locked on HP64 (B11.11) edit
When using %sqlite foo on HP64 (HPUX B11.11, gcc 3.2) and trying to create Table

An error message said that the database is locked

 
254 event active 2003 Feb anonymous   2003 Feb   1 1 make test does not work on HP64 (B11.11) edit
make test does not work on HP64 (B11.11)
 
253 event active 2003 Feb anonymous   2003 Feb   1 1 make install does not work with install-sh script edit
On HP64bits,B11.11

After ./configure and make

% make install does not work because install-sh does not have execution rights

need to do a chmod +x

 
233 event active 2003 Jan anonymous Unknown 2003 Jan   1 4 test bigfile-1.1 dumps core on Tru64 platform edit
I'm trying to get cvstrac (which uses sqlite) up and running on a Tru64 machine (uname -a follows):

   OSF1 calypso.umc.com.ua V5.1 732 alpha

However, cvstrac coredumps constantly. In attempt to track the reason of bug I tried to run 'make test' for sqlite and got:

   bigfile-1.1...make: Segmentation fault (core dumped)

I tried to compile with either gcc-3.0.3 or supplied cc (dont know how to get version of cc, though) - it doesnt matter, coredump doesnt go.

If I try to run testfixture under gdb, SIGSEGV kills gdb as well, so I tried to use truss to get a backtrace and got:

   [lots of open("/var/tmp/sqlite_59JacTYbQOLAC2h")/write/close skipped - they all were succefull ]
   185527: fcntl(9, F_SETLK, 0x000000011FFF9000)           = 0
   185527: fstat(9, 0x000000011FFF8F70)                    = 0
   185527: fcntl(9, F_SETLK, 0x000000011FFF9090)           = 0
   185527: write(7, "\0\0\003\0\0\0\0\b\0 803".., 1028)    = 1028
   185527:     Incurred fault #32, FLTBOUNDS  %pc = 0x0000000120007130   addr = 0x000000011FFF6EA0
   185527:     Received signal #11, SIGSEGV [default]
   185527:       siginfo: SIGSEGV SEGV_MAPERR addr=0x000000001FFF7369
                                                Err#139 Error 139 occurred.
   185527:         *** process killed ***

Seems like "write out of page bounds to me". Where can I get a closer look at in attempt to resolve the problem?

 
230 event active 2003 Jan anonymous Shell 2003 Jan anonymous 4 5 Problems compiling on AIX 4.3.3 edit
Probably not really a bug, but a problem compiling on AIX 4.3.3 that I fixed and thought you might like to know about...

During make, I got the output below. The problem turned out to be the AIX nm command itself. I used nm from gnu's bintools and it made fine. Thought you might like to know.

FYI, the relevant output from make was:

/usr/bin/nm -B .libs/btree.o .libs/build.o .libs/delete.o .libs/expr.o (etc, etc) nm: .libs/main.o: 0654-206 Cannot process the symbol table.

...

gcc -g -O2 -DOS_UNIX=1 -DOS_WIN=0 -DHAVE_USLEEP=1 -I. -I../src -DHAVE_READLINE=0 -o .libs/sqlite (etc, etc) ld: 0711-317 ERROR: Undefined symbol: .sqlite_interrupt ld: 0711-317 ERROR: Undefined symbol: .sqlite_exec ld: 0711-317 ERROR: Undefined symbol: .sqlite_open_aux_file ld: 0711-317 ERROR: Undefined symbol: .sqlite_close ld: 0711-317 ERROR: Undefined symbol: .sqlite_busy_timeout ld: 0711-317 ERROR: Undefined symbol: .sqlite_complete ld: 0711-317 ERROR: Undefined symbol: .sqlite_error_string ld: 0711-317 ERROR: Undefined symbol: .sqlite_open ld: 0711-317 ERROR: Undefined symbol: sqlite_version ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. collect2: ld returned 8 exit status make: 1254-004 The error code from the last command is 1.

Stop.

 
204 event active 2002 Dec anonymous Unknown 2002 Dec anonymous 1 1 Select statement takes hours (or more!) edit
On Win32, I have a 500> MB db with 13 tables. The schema for each table is:

CREATE TABLE XX (Year integer,Month integer, ProvOD integer,PaisOD integer,Posicion char(10),IOD char(1), PesoI float,UnidadesI float,ValorEstI float, PesoE float,UnidadesE float,ValorEstE float); create index tmpidx on tmp (provod,paisod,posicion,iod);

One the the tables is called tmp and it has more than 2.000.000 records.

Issuing the statement: select 1994 AS Year,-1 AS Month,ProvOD,PaisOD,Posicion,IOD, SUM(PesoI) AS PesoI,SUM(UnidadesI) AS UnidadesI,SUM(ValorEstI) AS ValorEstI, SUM(PesoE) AS PesoE,SUM(UnidadesE) AS UnidadesE,SUM(ValorEstE) AS ValorEstE FROM tmp GROUP BY ProvOD,PaisOD,Posicion,IOD;

takes forever (at least several hours - Pentium III 800Mhz), the I stopped with ^C. Also it "eats" more than 200 Mb of RAM while executin (through the sqlite command line).

If I get ride of the "Position" field in the group by it takes 50 seconds.

Is it normal? Is there anyway to speed that up? Am I taking sqlite to its limits? Comments?

 
164 event active 2002 Oct anonymous CodeGen 2002 Oct anonymous 3 4 Compiler warnings with MS Visual C++ 6.0 edit
Hi,

when I incorporated the "sqlite_source.zip" source code into a Microsoft Visual C++6.0 sample application, I got 24 warnings, mostly due to some signed/unsigned mismatch. It looks as it still works fine (no difference as when I used the DLL), but you never know if this holds true alltimes. Not showing up warnings would improve convidence into the product.

Regards, Louis Schneider

Deleting intermediate files and output files for project 'GENERIC - Win32 Release'.

--------------------Configuration: GENERIC - Win32 Release--------------------

Compiling resources...

Compiling...

GENERIC.C

where.c

build.c

delete.c

expr.c

C:\samples\techart\tech\win32\generic3\expr.c(1461) : warning C4018: '!=' : signed/unsigned mismatch

func.c

hash.c

insert.c

main.c

opcodes.c

os.c

C:\samples\techart\tech\win32\generic3\os.c(495) : warning C4018: '==' : signed/unsigned mismatch

pager.c

C:\samples\techart\tech\win32\generic3\pager.c(346) : warning C4018: '>' : signed/unsigned mismatch

C:\samples\techart\tech\win32\generic3\pager.c(1008) : warning C4018: '>=' : signed/unsigned mismatch

parse.c

printf.c

random.c

select.c

C:\samples\techart\tech\win32\generic3\select.c(99) : warning C4018: '==' : signed/unsigned mismatch

shell.c

table.c

tokenize.c

trigger.c

Generating Code...

parse.c(6771) : warning C4761: integral size mismatch in argument; conversion supplied

parse.c(6782) : warning C4761: integral size mismatch in argument; conversion supplied

Compiling...

update.c

util.c

vdbe.c

C:\samples\techart\tech\win32\generic3\vdbe.c(2069) : warning C4244: 'initializing' : conversion from 'double ' to 'int ', possible loss of data

btree.c

C:\samples\techart\tech\win32\generic3\btree.c(2306) : warning C4018: '<' : signed/unsigned mismatch

Generating Code...

C:\samples\techart\tech\win32\generic3\btree.c(629) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(1762) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(1764) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(516) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(520) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(534) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(538) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(541) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(482) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(483) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(410) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(421) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(432) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(434) : warning C4761: integral size mismatch in argument; conversion supplied

C:\samples\techart\tech\win32\generic3\btree.c(1924) : warning C4761: integral size mismatch in argument; conversion supplied

Linking...

   Creating library GENERIC.lib and object GENERIC.exp

GENERIC.exe - 0 error(s), 24 warning(s)

 
129 event active 2002 Jul anonymous Unknown 2002 Jul   4 4 tcl-2.2 test fails edit
Mac OS X 10.1.5/Tcl8.4b4

When sqlite is compiled with UTF-8 encoding, -DSQLITE_TEST and no memory debugging activated, the tcl-2.2 test fails in the context of running the quick test suite.

  tcl-2.2...
  Error: can't read "result(*)": variable isn't array

When the tclsqlite.test suite is run individually, all tests pass. I worked around this by modifying the test case to unset the variable 'result' at the top of the test.

  do_test tcl-2.2 {
   catch { unset result }
   execsql "INSERT INTO t\u0123x VALUES(1,2.3)"
   db eval "SELECT * FROM t\u0123x" result break
   set result(*)
  } "a b\u1235"
This problem does not appear under Linux or Win2k. It may be an issue with OS X or with the new Tcl. See also tickets #126, #127, and #128.
 
126 event active 2002 Jul anonymous VDBE 2002 Jul   4 5 malloc-1.195 test aborts from assert in vdbe.c edit
Release 2.6.2 passes the quick.test suite with no errors. In further testing with the complete suite (all.test), the tests abort at malloc-1.195. The error message is given below.

malloc-1.194... Ok malloc-1.195..../src/vdbe.c:5127: failed assertion `p->tos<pc' Abort trap

I don't know how serious this is, given that the quick tests pass. I submit it just in case you're idly curious about this particular failing test.

My system is Mac OS X 10.1.5, 640 MB RAM. sqlite compiled against Tcl 8.4b4, with -DSQLITE_TEST and -DMEMORY_DEBUG.

Bill Garrison garrison@standardorbit.com

This problem does not appear on Linux or Win2K. This may be an issue with OS X or with the new Tcl library. See also tickets #127, #128, and #129.
 
43 event active 2002 May anonymous   2002 May drh 1 1 sqlite compile without readline on linux slackware 8.0 edit
./configure won't detect libreadline on Linux slackware 8.0 (tested on 3 computer)

Adding by hand

READLINE = -DHAVE_READLINE=1 -l/usr/include/redline

and

LIBREADLINE = -lreadline -lcurses

work well

best claude

I think this may be a Slackware bug to do with the way they compiled libreadline, I've had it occur with other packages too.

If you put:

export config_TARGET_READLINE_LIBS="-lreadline -lcurses"

in your .profile or similar, you workaround the problem for multiple packages.

 
2228 new active 2007 Feb anonymous   2008 Feb   3 4 horizontal partitioning edit
I would love to see a feature in the next version of sqlite that includes horizontal table partitioning. I see it currently in MySQL Version 5.1 beta. It would be awesome to see it in SQLite
2008-Feb-01 02:46:29 by anonymous:
Well it would be great for us - won't need to emulate it. Any thoughts about that?

That's not only about large data sets - you can also make it for some sort of horizontal ATTACH of small separate pieces.

 
2912 new active 2008 Jan anonymous   2008 Jan   5 4 merge join edit
Would it be possible to implement merge joins?
 
2506 new active 2007 Jul anonymous   2008 Jan   3 2 New API to retrieve ROWID from SQLite3_stmt structire edit
Is it too much trouble to allow an API to retrieve ROWID for non-aggeregate queries directly from SQLite3_stmt structire? It would be very useful to create updatable non aggregate query results for situations when actually internal PK (ROWID) is not gived explicitly in SQL statement nor actual table's PK (if any).
SELECT queries that join two or more tables together would be a problem also.


2007-Jul-16 16:51:18 by anonymous:
It's more of a multi-step process. First you have to enumerate the open cursors on the sqlite3_stmt object. Then you need to resolve the table each cursor goes to, and then fetch the rowid for each active cursor. Of course this may get confusing when you've joined a table onto itself.


2008-Jan-19 10:32:59 by anonymous:
This is far to old active ticket. Is it in consideration to be implemented in the near future?
 
2892 new active 2008 Jan anonymous   2008 Jan   5 5 There should be a way in the api to read more precise error message. edit
Currently all errors in sql queries issued via C,C++ api result in error code SQLITE_ERROR = 1 and message "SQL error or missing database".

That leaves user completely clueless what mistake in his sql he actually made.

Some evidence of confusion can be found here: http://bugs.php.net/bug.php?id=33117

2008-Jan-16 17:41:00 by drh:
SQLite gives detailed error information for SQL syntax or logic errors. (Try, for example, entering invalid SQL into the CLI.) I think perhaps that PHP is simply failing to to access those errors and is instead picking up some other error indication from someplace else.


2008-Jan-16 21:59:17 by anonymous:
Well I shall retest it, but I got the same error message upon a duplicate key in Delphi. Although I'm aware of an enhanced api to get the errormessage.


2008-Jan-17 00:05:58 by drh:
What error message do you get from the CLI?
 
2884 new active 2008 Jan anonymous   2008 Jan   4 4 Way to find out limits edit
The page http://www.sqlite.org/limits.html shows some limits that SQLite has. They are consts in the code, and defaults are listed, but there doesn't seem to be any way to find out what values a particular binary was built with.

For example, I've gotten SQLite as part of my OS or another program, and I don't know what value of SQLITE_MAX_COLUMN was used to compile this SQLite. I'm trying to track down a bug in my code, and if this value was too small, that would explain it. (In truth, it's probably not the cause, but I'd like to rule it out.)

I'd like a way to print the value of these limits at runtime. It doesn't have to have a stable API -- it would mostly be useful for debugging. If the command-line client had a command ".limits" that printed all of these values, that would be super.

 
489 new active 2003 Nov anonymous   2008 Jan   4 4 DLL exports suggestion edit
Just a suggestion:

I'm building SQLite using MS C++, and an easily maintained alternative to a .def file for the DLL exports is to incorporate the following into the sqlite.h header...


	#ifdef _MSC_VER
		#ifdef SQLITE_EXPORTS
			#define SQLITE_API __declspec(dllexport)
		#else
			#define SQLITE_API __declspec(dllimport)
		#endif
	#else
		#define SQLITE_API
	#endif

	// example function declaration
	SQLITE_API void sqlite_close(sqlite *);


SQLITE_EXPORTS is defined when building the library, but not when building client applications.

I don't know if other compilers have similar methods of defining library exports, but if so, this could possibly be extended to support them.

2008-Jan-11 01:58:27 by anonymous:
There is a good reason for adding this feature in some form other than merely avoiding the manual import library creation step.

When __declspec(dllimport) is used, it is a hint to MSVC++ to produce more efficient code. This allows the function in the DLL to be called in a single call. Otherwise there is an extra jmp (2 in Debug mode). So those that want maximum performance out of C and DLL combo should take note. I patched this into my copy of the source.

But the code given in the ticket assumes that the library is used as a DLL and not statically linked in which case dllimport shouldn't be used.

-- Bz


2008-Jan-11 13:28:27 by drh:
The prefix SQLITE_API appears in front of all interfaces in the amalgamation. So it seems like this problem could be solved by adding

    -DSQLITE_API=__declspec(dllexport)

to the compiler command line. No?


2008-Jan-12 07:16:44 by anonymous:
Yes -DSQLITE_API will do, and also it is necessary to define SQLITE_EXTERN because some data symbols:

sqlite3_version[]

sqlite3_temp_directory

sqlite3_io_trace

are forward declared with SQLITE_EXTERN but defined with SQLITE_API and these must match.

But like I mentioned, this is only half of the issue. The other half is the small performance boost from __declspec(dllimport). It would be nice to have SQLITE_API prefixes in sqlite3.h for users of the DLL. It's low priority, but I thought I would point this out.

Another thing to note is that using __declspec(dllexport) instead of DEF file along with the (non default) stdcall convention (callee cleans up the stack) will result in function names in DLL export table being mangled with numeric suffixes. If one links through the auto generated import lib file, this isn't an issue, but it affects looking up a function name with GetProcAddress(). So the DEF file (the original intent of the ticket before I hijacked it) has a benefit in this case. But to use the stdcall convention properly there would have to be yet another prefix for the benefit of clients using the default cdecl convention:

#define SQLITE_CALL

#define SQLITE_CALL __stdcall

SQLITE_API int SQLITE_CALL sqlite3_open( const char *filename, sqlite3 **ppDb );

The 2 prefixes is what MS does with their API functions. I assume there is some small performance boost from __stdcall.

-- Bz


2008-Jan-13 02:02:38 by sdwilsh:
See also Ticket #2448
 
2847 new active 2007 Dec anonymous   2008 Jan   5 4 Include major, minor, and patch version numbers in sqlite.h edit
Hi, I'm working on a project where sqlite is being compiled into a DLL. Currently, sqlite.h makes the version number available as both an x.y.z string and an integer value in the form of x*1000000 + y*1000 + z.

Unfortunately, neither of these options works particularly well when trying to create a resource file so that the DLL can display the proper version information within Windows. I've tried many different ways of disassembling the integer version number, but limitations in the resource compiler unfortunately prevent them from working.

As a result, I've been forced for the time being to define SQLITE_VERSION_MAJOR, SQLITE_VERSION_MINOR, and SQLITE_VERSION_PATCH with manually-given values of x, y, and z respectively in order to accomplish this task. It would be really nice if these could be generated automatically for sqlite.h when running configure in the same way that VERSION and VERSION_NUMBER are so that setting the values manually wouldn't be required for the future.

Would you be willing to do that? Thanks in advance.

2007-Dec-17 13:30:22 by anonymous:
You could invoke this awk script in your make file:
#
## extrvers.awk
## Extract verison parts from sqlite3.h
#
## Usage:
#  %GNU_AWK% -f extrvers.awk sqlite3.h >sqlite3.h.new
# 	rm / del sqlite3.h
# 	mv / ren sqlite3.h.new sqlite3.h
#
#
## Ignore any previous defines
/^#define SQLITE_VERSION_(MAJOR|MINOR|PATCH)/{
	next
}
## generate extra #define MAJOR/MINOR/PATH lines
/^#define[[:blank:]]+SQLITE_VERSION[[:blank:]]/{
	split(substr($3,2,length($3) - 2),tmp,".")
	print "#define SQLITE_VERSION_MAJOR " tmp[1]
	print "#define SQLITE_VERSION_MINOR " tmp[2]
	print "#define SQLITE_VERSION_PATCH " tmp[3]
}
## Repeat all other lines untouched
{
	print
}


2007-Dec-18 00:06:53 by anonymous:
Original poster here. Thanks for the useful script! I'm assuming you're granting a license for this (or a modified version of it) to be included in the source tree if the powers that be are willing to accept it? This would be for the Mozilla project.


2007-Dec-18 00:21:52 by drh:
First off, I didn't post the script. I don't know who "anonymous" is.

Secondly, if you are working for Mozilla, you will get much faster service if you identify yourself as such.


2007-Dec-18 00:39:38 by anonymous:
I just want to make sure I'm not running afoul of anybody by using their work without proper permission.

To whoever posted it, you can contact me at ryanvm [at] gmail [dot] com. Thanks again for help!


2007-Dec-26 19:06:27 by anonymous:
I'm the poster of the script. Of course I don't mind it being used. For the peace of mind of anyone using it: please prepend the code with:
# Copyright (C) 2007 by Kees Nuyt, Rotterdam, Netherlands
# The author of this code dedicates any and all copyright
# interest in this code to the public domain. I make this
# dedication for the benefit of the public at large and
# to the detriment of my heirs and successors. I intend
# this dedication to be an overt act of relinquishment in
# perpetuity of all present and future rights to this
# code under copyright law.
#

Cheers! "Kees Nuyt" <k [dot] nuyt [at] zonnet [dot] nl>


2007-Dec-27 02:32:44 by anonymous:
Declaring a copyright and putting it into the public domain is not compatible.


2008-Jan-11 04:55:22 by anonymous:
Original poster here: FYI, I ended up writing a Python script to parse sqlite3.h for what we needed. The Mozilla bug for the work was

You can see the final script here: http://mxr.mozilla.org/mozilla/source/db/sqlite3/src/sqlite-version.py

At this point, you can close the bug if you want. I'll leave that up to you to decide.

 
2853 new active 2007 Dec anonymous   2008 Jan   2 3 optimizer fails to use an index on MAX subquery edit
i have these 2 identical queries with an index on (place_id,visit_date), the second query is about 2x fast the the first, while i'd expect that the MAX is faster than a limited order by clause... It's like the index is mis-used with MAX

  SELECT h.id, h.url, h.title, h.rev_host, h.visit_count,
  (SELECT MAX(visit_date) FROM moz_historyvisits WHERE place_id = h.id
  AND visit_type NOT IN(0,4)),
  f.url, null, null
  FROM moz_places h
  LEFT OUTER JOIN moz_favicons f ON h.favicon_id = f.id
  WHERE h.id IN
  (SELECT DISTINCT p.id
          FROM moz_places p
          JOIN moz_historyvisits ON place_id = p.id
          WHERE hidden <> 1 AND visit_type NOT IN (0,4)
          ORDER BY visit_date DESC
          LIMIT 10)
  ORDER BY 6 DESC;

  SELECT h.id, h.url, h.title, h.rev_host, h.visit_count,
  (SELECT visit_date FROM moz_historyvisits WHERE place_id = h.id
   AND visit_type NOT IN(0,4) ORDER BY visit_date DESC LIMIT 1),
  f.url, null, null
  FROM moz_places h
  LEFT OUTER JOIN moz_favicons f ON h.favicon_id = f.id
  WHERE h.id IN
  (SELECT DISTINCT p.id
          FROM moz_places p
          JOIN moz_historyvisits ON place_id = p.id
          WHERE hidden <> 1 AND visit_type NOT IN (0,4)
          ORDER BY visit_date DESC
          LIMIT 10)
  ORDER BY 6 DESC;
2007-Dec-20 04:13:44 by anonymous:
Can you supply the schema of these tables and all related indexes?


2007-Dec-20 10:55:29 by danielk1977:
Correct. SQLite does not use the index to optimize the max() in the first query. But it does use it to optimize ORDER BY in the second.


2007-Dec-21 00:54:10 by anonymous:
the schema is that of mozilla firefox 3 places.sqlite, with an added index on moz_historyvisits(place_id,visit_date), this is extracted from a i bug i was working on. Do you need that i append the full schema here?

Will this be fixed to use the index with max or is that the expected behaviour?


2007-Dec-21 15:59:58 by drh:
We will be enhancing the min()/max() optimization to be able to cover the case you describe above. But this will take some time to get right. If you are in a hurry, it seems like modifying your SQL is the easiest way to go.

The current optimizer recognizes queries of the form:

    SELECT min(x) FROM table;
    SELECT max(x) FROM table;

And it causes special VDBE code to be generated for these cases. The presence of a WHERE clause defeats the current optimization. We need to modify the optimizer to recognize queries of the form:

    SELECT min(x) FROM table WHERE expr

And convert them into:

    SELECT x FROM table WHERE expr AND x NOT NULL
     ORDER BY x LIMIT 1

But we only want to do this optimization if the ORDER BY can be evaluated using an index. If we have to accumulate the entire result set, sort it, then take the largest entry, that is more work than just keeping track of the largest entry as we loop through the result set.

Notice the addition of the "x NOT NULL" term in the WHERE clause. This is critical to preserving correct semantics. The query optimizer currently does not know how to deal with a NOT NULL. It just evaluates all rows, tests them individually for NULL, and throws out those that match. This would work in most cases, but would slow down in a min() where there were many NULL entries. The current implemention of the min() optimization knows to skip over the NULL entries in a single operation. The WHERE generator part of the optimizer will need to be enhanced to recognize NOT NULL constraints and skip over them.

All of this is a substantial change. The min()/max() optimization function will be rewritten from scratch. Significant and non-trivial modifications will need to be made to the code that looks for indices and generates the WHERE clause constraints. There are many opportunities to make coding mistakes, so we will need to spend a lot of time in testing before we put these changes into production.

So, we will be working the problem. But do not expect an overnight fix.

I suppose that while we are redesigning the min/max optimizer, we might as well also fix it so that

   SELECT arbitrary_expr(max(x)) FROM table WHERE expr;

gets converted into

   SELECT arbitrary_expr(x) FROM table WHERE expr AND x NOT NULL
    ORDER BY x DESC LIMIT 1;


2007-Dec-31 06:41:03 by anonymous:
Regarding:

  SELECT min(x) from table WHERE expr

being converted to:

  SELECT x FROM table WHERE expr AND x NOT NULL ORDER BY x LIMIT 1

There's no need for the "x NOT NULL" condition considering NULL is returned by min() (or max for that matter) when no rows match.

  sqlite> .nullvalue <null>

  sqlite> select min(a) from (select 123 as a) where a=7;
  <null>

  sqlite> select min(a) from (select NULL as a) where a=7;
  <null>

Even with this in mind, you can see that the rewritten query still does not return the same result in this case:

  sqlite> select a from (select 123 as a) where a=7 order by 1 limit 1;
  -- no rows returned

Logic would have to be added to return a NULL row in the event the WHERE clause matches no rows.


2007-Dec-31 07:06:22 by anonymous:
Given:

  SELECT min(x) from table WHERE expr

If column x or the WHERE expr can make use of an index, then the min query should be converted to:

  SELECT x from (
    SELECT x FROM table WHERE expr
      ORDER BY x LIMIT 1
  ) UNION ALL SELECT NULL LIMIT 1

which ought to cover all the corner cases, even if the WHERE matches no rows.


2008-Jan-01 19:21:51 by anonymous:
This ticket is related to WHERE cost estimation in ticket #2857.

Given:

  create table stuff(a,b,c,d);
  insert into stuff values(1,2,3,4);
  create temp view v1 as select random()%100,
    random()%100, random()%1000, random()%10000
     from stuff x, stuff y;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  insert into stuff select * from v1;
  create index stuff_b on stuff(b);
  create index stuff_c on stuff(c);
  create index stuff_d on stuff(d);
  analyze;

In the following example the existing min() implementation which uses a full table scan:

  sqlite> explain query plan select min(c) from stuff where a=12345;
  0|0|TABLE stuff

  sqlite> select min(c) from stuff where a=12345;
  (null)
  CPU Time: user 1.388087 sys 0.216014

is faster than performing the select min->order by/limit transform which uses an index:

  sqlite> explain query plan select c from stuff where a=12345 order by 1 limit 1;
  0|0|TABLE stuff WITH INDEX stuff_c ORDER BY

  sqlite> explain query plan select c from (select c from stuff where a=12345 order by c limit 1) union all select null limit 1;
  0|0|TABLE stuff WITH INDEX stuff_c ORDER BY
  0|0|TABLE  AS sqlite_subquery_82F83F8_
  CPU Time: user 0.000000 sys 0.000000

  sqlite> select c from (select c from stuff where a=12345 order by c limit 1) union all select null limit 1;
  (null)
  CPU Time: user 15.880993 sys 15.400962

Note that a=12345 is always false in this data set.

Had a=23 been used instead, we can see that the transformed select would be much faster than the original min() select:

  sqlite> select min(c) from stuff where a=23;
  -999
  CPU Time: user 1.552097 sys 0.148009

  sqlite> select c from (select c from stuff where a=23 order by c limit 1) union all select null limit 1;
  -999
  CPU Time: user 0.004001 sys 0.000000

I don't think WHERE clause cost estimation can be done accurately without using a statistical method based on historical WHERE clause hit percentages.


2008-Jan-05 18:15:39 by anonymous:
I appreciate that you have more refinements pending, but this query in particular has regressed from sqlite 3.5.4 using the schema mentioned above:

  -- sqlite 3.5.4
  sqlite> select min(c) from stuff where a=12345;
  (null)
  CPU Time: user 1.532095 sys 0.132008

  -- as of Check-in [4687]
  sqlite> select min(c) from stuff where a=12345;
  (null)
  CPU Time: user 23.041440 sys 16.369023
 
2869 new active 2008 Jan anonymous   2008 Jan   5 5 add "sqlite3_open16_v2" to the C API edit
I'm using UTF-16, and if the database file does not exist, "sqlite3_open16" will create a new one, but i wish it fails in such conditions. I notice that there's a "sqlite3_open_v2", but it doesn't support UTF-16, although i can implement a "sqlite3_open16_v2" myself, I think it should exists in the offical releases.
 
1648 new active 2006 Jan anonymous Shell 2007 Dec   4 3 meaningful error message: constraint failed edit
  create table emp( id text unique, sex text check( sex in 'm' or sex in 'f' );
  insert into emp values( '1','x' );
  SQL error: constraint failed

This error message could be better. If there are several constraints, which constraint failed? So I named the constraint

  create table emp( id text unique, sex text constraint chk_sex check( sex in 'm' or sex in 'f' );
  insert into emp values( '1','x' );
  SQL error: constraint failed

Still no joy . . . It would be nice if the error message were more specific.

2006-Jan-30 16:22:58 by anonymous:
actually my testing was better than my typing, I used:

  check (sex = 'm' or sex = 'f' )


2007-Oct-25 09:47:14 by anonymous:
This is a really big deal for me and for many others I suspect. If this is not a priority, could you at least throw out some hints about implementing it? I browsed through the code but can't seem to find where this would even go.


2007-Oct-25 10:10:36 by anonymous:
Hm, ok, the check constraints are stored in the table structure as a single expression which is the AND of all of them. This alone suggests that the task at hand is not simple...


2007-Oct-25 10:17:36 by anonymous:
Perhaps a new Check type could be created which could basically be Expr plus an extra pointer, which could then be used to make a list of them, similar to how the triggers seem to be stored. I'll keep snooping around, but I thought I'd post what I've found thus far in case anyone else looks at this.


2007-Oct-25 19:40:37 by anonymous:
I have attached a patch that implements this. I've only tested it lightly by hand. (The test suite failed to run and gave me some strange linking errors)


2007-Dec-20 11:38:03 by anonymous:
Although this is tagged as shell, the error message comes from the sqlite core.

My single biggest problem besides the lack of detail (some of my tables have 5 constraints) is that it also prevents me from localizing the error messages. If I have the constraint name then at least I can look it up in a translation table and tell non-english speakers something meaningful.

 
916 new active 2004 Sep anonymous Unknown 2007 Dec   1 1 No delete notification for INSERT OR REPLACE edit
It would be nice if the "ON DELETE" trigger is called for the row substituted with a new one during REPLACE. Or, even better, one could add the OLD statement for the "ON INSERT" trigger and set it to point to the same row as NEW if a new row is inserted or to the deleting row if replace occurs. Thanks.
2007-Dec-17 21:36:40 by anonymous:
I have the same problem. My solution would be to stick with the documentation of the ON REPLACE algorithm: "When a UNIQUE constraint violation occurs, the pre-existing rows that are causing the constraint violation are removed prior to inserting or updating the current row". That is, to call ON DELETE trigger whenever rows are removed. Thank you, and keep going, you do wonderful job anyway.
 
2831 new active 2007 Dec anonymous   2007 Dec   3 4 alter view edit
View can't be used after ALTER RENAME TO:

SQLite version 3.5.3
Enter ".help" for istructions
sqlite> create table t(a);
sqlite> create view v1 as select * from t;
sqlite> alter table v1 rename to v2;
sqlite> select * from v2;
SQL error: no such table: v2
sqlite> select * from v1;
SQL error: no such table: v1
sqlite> .schema
CREATE TABLE t(a);
CREATE VIEW v1 as select * from t;
sqlite> select * from sqlite_master;
table|t|t|2|CREATE TABLE t(a)
view|v1|v1|0|CREATE VIEW v1 as select * from t
This is a feature request, not a bug.


2007-Dec-11 18:40:17 by anonymous:
Notice that alter table doesn't return an error. After the command neither v1 nor v2 can be used.


2007-Dec-13 08:18:16 by danielk1977:
[4623] improves the situation by returning an error when the user attempts to rename a view.

One reason this feature (renaming views) is not a high priority is because a view can be dropped and recreated with a different name efficiently. This was not the case with tables.

 
2821 new active 2007 Dec anonymous   2007 Dec   3 4 hashtable indicies edit
It would be nice to implement non btree indices. I.e. CREATE INDEX ON table(rowid) AS HASH. Using a hashtable's O(1) properties, you could use the index for very quick lookups when one result is expected. This does have the tradeoff that a hashtable index has no ordering properties (can not be used for sorts or non-equality searching). However, it would be a huge win when you have 250,000 rowids in memory, and you want to go fetch another column in the database for each one of those rowids (SELECT * FROM table WHERE rowid=?).
2007-Dec-03 21:58:01 by anonymous:
For 250,000 rows I doubt you would see that much of an improvement (try it.)

You'll almost certainly find log_n is going to be fairly fast (especially for large n.)

I personally would prefer some sort of 'virtual' index though, that could be a hash or actually from a user-supplied function so that I can index large blobs by some function (i.e. a hash).

And yes, this would be an incompatible file-format change and it's not clear how to update an index when the function isn't loaded (i.e. db reopened with that function.) Perhaps mark the index as 'stale' and ignore it until the function loads then you can do the updates.

Of course this starts to get quite complicated.


2007-Dec-03 22:12:17 by anonymous:
Everything in sqlite depends on btree indexes. You're talking a major rewrite if you support hash-based or other indexing.
 
2417 new active 2007 Jun anonymous   2007 Nov drh 3 3 Idea for read write concurrency. edit
This is not a problem, but rather an idea on how to resolve the reader/writer concurrency issues encountered in sqlite.

The idea is to allow a reader and writer to work concurrently not blocking each other. Dual writers would of course block.

When a write occurs: 1. block level changes are made to the database file. 2. Pre-image of that change is written to the journal.

Readers: 1. File I/O on the main file would occur normally. 2. If the block encountered is "new" ie one that was written out by the writer. Then get the original block from the Journal file.

In order to determine "NEW" a change number could be put on each block. When a READ (select) begins it would first determine the starting global change number. (maybe on the master block?)

      When a write occurs it would read the Master blocks change number. (increment this in memory) and use write new blocks with the new value.  At commit. The Master block would be updated and the txn journal marked for purge if there are pending reads.

-- Drawbacks: Reading becomes dependent upon the txn journal.

-- Implementation of BLOCK level versioning may ultimately be a simpler approach. Idea would be for a seperate file conaining versioned blocks. This file could be accessed instead of the txn journal.

2007-Nov-08 15:12:00 by anonymous:
DRH: Also unaddressed in the proposal is how to locate a particular page within the journal file without having to do (performance killing) sequential scan of the possible very large file.

Resolution of page access to avoid sequential scans of Txn Journal.

When a writer is making the modification to a page first it writes the original page to the journal. At this point the journal file offset location is known. Save this offset in the "NEW" page being written into the database file. This implements a backwards chaining of pages into the txn journal.

The reader upon reading the db file page would recognize (see above) that the page is dirty. Acquire the txn journal offset from the dirty page, Read the page from the journal until the starting page is found. This would eliminate any sequential scanning, but may require more than one read request.

 
2760 new active 2007 Nov anonymous   2007 Nov   5 4 request: sqlite3_unlink() to delete db files. edit
Hi!

Today i came across a use case where i would like client code to be able to delete an underlying sqlite3 db, but that code doesn't have immediate access to the file name of that db (without refactoring the db wrapper code).

An interesting feature addition would, IMO, be:

int sqlite3_unlink( sqlite3 * db, bool closeTheFile );

Unlinks the file associated with the given database. It does not alter the database in any way (thus is it a no-op on a :memory: database). The closeTheFile flag specifies whether the file handle associated with db should also be closed (and thus db must also be closed), or just unlinked (e.g., as temporary databases are unlinked right after creation but kept open).

After browsing through the VFS API a bit, i see that there is an xDelete function, but i'm not sure if its semantics require that the underlying file handle be closed. i don't see an extra xClose member of VFS, so i assume that xDelete also handles closing the file handle. If these were split into two features, sqlite3_unlink() could be implemented very easily.

:)

 
2756 new active 2007 Nov anonymous   2007 Nov   1 1 allow vacuum to change pragma setting instead of using existing ones edit
we've got databases created with page_size of 1k, and we'd like to change that setting to 4k. vacuum creates a temporary db, attach it to the current connection, creates the tables (based on what's in the old db), and then selects from the old db and inserts into the new one.

vacuum does exactly what we need (creating a new db from an old one), but it re-uses the existing pragmas for page size, auto vacuum and reserved page size.

from sqlite.c, see sqlite3RunVacuum()

  sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain),
     sqlite3BtreeGetReserve(pMain));

dr hipp points out that the the operands to vacuum are unused. from sqlite.c:

sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0);

one solution would be to allow the user to specify the page size, reserve page size, and autovacuum as optional params to vacuum.

he had an idea of using the signedness of the first operand to represent the autovacuum setting (since after a table is created, you can change the setting from auto to incremental, but you can't change it from none to auto (or none to incremental)

 
2716 new active 2007 Oct anonymous   2007 Oct   5 1 Create Clear Command edit
I want a command caled "clear" like in MySQL. This command should erase the screen and then put the sqlite pointer on top of the screen
2007-Oct-11 07:41:45 by anonymous:
How about a cookie instead?


2007-Oct-30 08:02:04 by anonymous:
Clearing the screen and moving the cursor are platform-dependent operations. On Unix they are not only platform-dependent, but also terminal-dependent. Thus such a feature does not really belong in the cross-platform and minimalistic sqlite3 shell (in my opinion).
 
2701 new active 2007 Oct anonymous   2007 Oct   5 5 Make INSERT-ing multiple rows MySQL-compatible edit
SQLite syntax allows to insert only one row with
    insert into test (a, b, c) values (1, 2, 3);

MySQL allows to insert multiple with

    insert into test (a, b, c) values (1, 2, 3), (4, 5, 6), (7, 8, 9) -- etc

But SQLite is also capable of inserting multiple by using INSERT...SELECT:

    insert into test (a, b, c) select 1, 2, 3 union select 4, 5, 6 -- etc

It would be nice to make INSERT statement syntactically compatible with MySQL, allowing to insert multiple rows with VALUES clause.

It can be implemented by simply translating multiple 'VALUES ()()()' to 'select union' - no serious change required at all.

2007-Oct-08 21:45:05 by anonymous:
You mean "UNION ALL", not "UNION".

UNION would remove duplicate rows, and create an ephemeral table that you don't want because it's less efficient.

Your idea is a good one and could be implemented largely in the parser. The number of VDBE opcodes would be quite large for such a statement. I wonder if that would present a problem.


2007-Oct-14 08:12:11 by anonymous:
Patch implementing multi-row INSERT statements against 3.5.1 source tree:

http://www.mail-archive.com/sqlite-users%40sqlite.org/msg28337.html

 
55 new active 2002 Jun anonymous   2007 Oct drh 5 3 instead of triggers for inserts (updates) on regular tablesxx edit
It would be very useful to be able to define a trigger that only executes the trigger code and will prevent the actual insert (or update) on regular tables (eg. specialised autoincrement fields). This could be done by allowing the same "instead of" syntax as used for views. Even better would be the possibility of return codes in a before trigger that can prevents the insert or raise an error. Ideally, this return code could be given conditionally (implementing foreign key and check like functionality).
test


2007-Oct-01 23:37:44 by anonymous:
create trigger syntax :

A special SQL function RAISE() may be used within a trigger-program, with the following syntax:

  raise-function ::= 	RAISE ( ABORT, error-message ) |

  RAISE ( FAIL, error-message ) |
  RAISE ( ROLLBACK, error-message ) |
  RAISE ( IGNORE )
 
2677 new active 2007 Sep anonymous   2007 Sep danielk1977 5 3 CREATE TRIGGER .. {databaseevent ON ... }+ for multiple events edit
I have to write triggers which react on either INSERT or UPDATE of a specific field in a table. In some SQL syntax descriptions I found a possibility to combine the trigger events for more than one condition but not in SQLite3. Isn't there a possibility to use one trigger definition for more than one event or didn't I find the trick? Do I have to copy the whole definition for each event; even if the body text is exactly the same?
Suggestion: On INSERT event use the OLD.fieldnames filled with NULL content to avoid problems with UPDATE event. - If not possible please explain why not for my better understanding. Thank you.
 
2651 new active 2007 Sep anonymous   2007 Sep   5 4 Add support for overriding home directory location edit
Currently, the history file's and the rc file's location is hard-wired to $HOME. It would be nice if this could be overridden. One way is to look for a SQLITE_HOME environment variable that points to the location to use. This can be achieved by a simple addition to find_home_dir() in src/shell.c.
 
2649 new active 2007 Sep anonymous   2007 Sep   4 4 Add an "--enable-extensions" (default=no) to the configure script edit
The attached patch adds "--enable-extensions" to the configure script, but is disabled by default (because of the security considerations of having it enabled).
 
2604 new active 2007 Aug anonymous   2007 Aug   4 4 CREATE VIRTUAL TABLE does not allow IF NOT EXISTS edit
CREATE VIRTUAL TABLE vt IF NOT EXISTS; would help with development since creating a virtual table that exists returns error 1 - as do several "Real" errors.
 
2568 new active 2007 Aug anonymous   2007 Aug   3 3 TEMP_STORE is ignored in some cases edit
It seems that sometimes TEMP_STORE is ignored. I've tried to force SQLite to always use memory by setting TEMP_STORE=3, but some etilqs_* temp files are still being created. The call stack that's causing these file to be created is:

  sqlite3PagerOpentemp(OsFile * *)
  sqlite3PagerStmtBegin(Pager *)
  sqlite3BtreeBeginStmt(Btree *)
  sqlite3VdbeExec(Vdbe *)
  sqlite3Step(Vdbe *)
  sqlite3_step(sqlite3_stmt *)

It looks like the temp files are being used to store information for undoing earlier parts of a transaction if a later part fails. I'm assuming the fact this part of the code ignores TEMP_STORE is an over site?

2007-Aug-13 15:03:19 by drh:
The TEMP_STORE compile-time option only changes the storage for temporary database files. The statement journal is not a databaes file and thus does not come under the control of TEMP_STORE. There is currently no mechanism to force the statement journal into memory instead of onto disk.

I will reclassify this ticket as a "feature request".


2007-Aug-22 10:42:50 by anonymous:
Okay, thank you.
 
2555 new active 2007 Aug anonymous   2007 Aug   1 1 FTS index without original text edit
Is it possible to build FTS index without storing original text? I want to use fts index without features of snippets etc. I just want to find ID of the record not the content of indexed phrase. I suppose that the table myname_content stores this content. I have tried to update all columns of myname_content and set its values to &#8220;xyz&#8221; (without one column in which I store ID of the record). After this operation FTS search works good, but unfortunately the table isn&#8217;t smaller (I cant&#8217;t use vacuum on FTS tables). Is there any other way to have pure text indexes without source level changes?
 
2488 new active 2007 Jul anonymous   2007 Jul   5 4 autosize on column output mode in sqlite3 program edit
It would be nice if sqlite3 program has a autosizecolumn mode for displaying queries, because it truncates values, and to calculate and use .width size for each column is tedious.
2007-Jul-07 11:42:03 by drh:
In order to do this, we would have to either run the query twice or load the entire result set into memory. Otherwise, there would be no way to determine the longest element of each column. Neither approach seems attractive for large and complex queries.


2007-Jul-28 07:05:56 by anonymous:
every query should internally detect the longest column sizes and a new command should enable the user to set these values for any repetition or similar queries. At the end the queries run twice or more but only the first trial would have cause irritations on output. And this solution should be easy enough to implement it.
Even the core of sqlite could calculate the maximum length of each column and a new API function could make this available. It would be really nice to get such an enhancement!


2007-Jul-28 18:37:36 by anonymous:
while you don't move to next row, sqlite doesn't know the contents, so it will be impossible to do, only if you cache the text entirely in memory, but this is ugly, imagine a 1GB recordset into RAM...


have you tried .mode tabs ? here, i have correct column width
 
2520 new active 2007 Jul anonymous   2007 Jul   4 1 User defined aggregate functions are not reentrant edit
When an aggregate function is defined using sqlite3_create_function, it is not possible to execute any sql statement inside the step part or the finalizer. This is due to the fact that aggregate functions are not reentrant.
2007-Jul-20 02:32:36 by anonymous:
related: Ticket #2242: sqlite3 authorizer is not reentrant
 
2484 new active 2007 Jul anonymous   2007 Jul   5 4 Support for RETURNING edit
I was recently trying to get HTSQL (http://htsql.org) to work with SQLite, especially since it'd be nice to work out-of-the-box with Python. One of the hiccups was the lack of a RETURNING clause, this is especially important once you have auto-incremented keys. For example..

  INSERT INTO TABLE some_table (a_column) values ('value')
    RETURNING (serial_column);

This acts like a SELECT following the INSERT returning the requested columns on the affected rows. It is quite helpful for cases like UPDATE or DELETE when more than one row is affected. While this feature isn't critical for SQLite, it reduces client-side code significantly. Thank you for your kind consideration.

 
2474 new active 2007 Jun anonymous   2007 Jun   5 4 Multiple-record comma-delineated INSERT command edit
I believe that both MySQL and DB2 support this feature. Instead of using separate commands for multiple INSERTS, you could use one command, and delineate the separate INSERT data with commas. Having support for this type of INSERT would make migrating MySQL or DB2 files to SQLite easier.

Regular INSERT method:

  INSERT INTO foo VALUES ('Title1',26,NULL);
  INSERT INTO foo VALUES ('Title2',24,NULL);
  INSERT INTO foo VALUES ('Title3',12,NULL);

Delineated INSERT method:

  INSERT INTO foo VALUES
  ('Title1',26,NULL),
  ('Title2',24,NULL),
  ('Title3',12,NULL);
2007-Jun-29 12:32:45 by anonymous:
From the parsing point of view this is a bit interesting. Imagine the multi-insert statement is 100,000 lines long. Do you parse the entire statement for correctness first and hold this entire parsed tree in memory? Or do you begin a transaction, and try to process each sub-insert row by row and rollback if there's any error? I'd think the latter would be better from both a time and memory point of view.

Actually, this multi-insert statement could be optimized to work around the sqlite slow bulk insert issue with multiple keys.

 
2456 new active 2007 Jun anonymous   2007 Jun   5 5 REQ: use index where applicable instead of full table scan edit
There are times when you need information from a table that's held entirely in an index. Would it not make sense to scan over the index in these cases as those are likely to be more densely packed and therefore faster and more cache friendly?

  sqlite> .sc
  CREATE TABLE t1 ( c1 integer, c2 text, c3 text );
  CREATE INDEX idx1 on t1(c1);

so here SELECT SUM(c1) from t1 could be satisfied by scanning over idx1, which might be a lot smaller & more dense than t1.

 
2448 new active 2007 Jun anonymous   2007 Jun   4 3 SQLITE needs to identify public exported symbols edit
A number of platforms allow source code tagging of functions which are meant to be public functions exported in a shared library (most notably windows and platforms that use GCC 4.0 and above).

This tagging is usually accomplished through some define placed in front of the function declaration and definition (SQLITE3_PUBLIC sqlite3_open() for example), and SQLITE3_PUBLIC is set to the proper declaration for the given platform. Example:

    windows it would be: __declspec(dllexport)
    GCC it would be: __attribute__ ((visibility("default")))

see http://gcc.gnu.org/wiki/Visibility for more information.

 
2443 new active 2007 Jun anonymous   2007 Jun   3 3 sqlite should return different exit codes for different errors edit
sqlite should return different exit codes for different errors reported. sqlite always returns exit code 0 or 1. It would be helpful to have different codes. I/O error, locked, interrupted, busy etc. should declare defined return codes. If sqlite is executed from a shell script it is difficult to handle plain text that could change or be reformatted in a later version.

Thanks.

2007-Jun-21 19:59:41 by anonymous:
Just run sqlite3 -batch -bail and grep for the error in the last line.
 
2438 new active 2007 Jun rse   2007 Jun   3 3 More easily allow the building of SQLite with FTS1 and FTS2 edit
I don't know what the intended way is to build SQLite with FTS1 and/or FTS2, but for the OpenPKG "sqlite" package I at least now use the following change -- as I was unable to find any other automated solution. I know that FTS1 and FTS2 are experimental extensions, but if it is too complicated for people to build SQLite with them, they certainly will never become non-experimental ;-) So I recommend to at least provide some build-time glue for them. In the OpenPKG "sqlite" package I now use the following patch which at least provides this glue (one still has to enable it, of course):

Index: Makefile.in
--- Makefile.in.orig    2007-06-14 22:54:38 +0200
+++ Makefile.in 2007-06-20 18:09:00 +0200
@@ -130,6 +130,18 @@
          vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbefifo.lo vdbemem.lo \
          where.lo utf.lo legacy.lo vtab.lo

+# FTS1 support
+ifdef FTS1
+TCC    += -DSQLITE_ENABLE_FTS1
+LIBOBJ += fts1.lo fts1_hash.lo fts1_porter.lo fts1_tokenizer1.lo
+endif
+
+# FTS2 support
+ifdef FTS2
+TCC    += -DSQLITE_ENABLE_FTS2
+LIBOBJ += fts2.lo fts2_hash.lo fts2_porter.lo fts2_tokenizer1.lo
+endif
+
 # All of the source code files.
 #
 SRC = \
@@ -498,6 +510,23 @@
        -o testfixture $(TESTSRC) $(TOP)/src/tclsqlite.c \
        libsqlite3.la $(LIBTCL)

+fts1.lo:   $(TOP)/ext/fts1/fts1.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts1/fts1.c
+fts1_hash.lo:  $(TOP)/ext/fts1/fts1_hash.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts1/fts1_hash.c
+fts1_porter.lo:    $(TOP)/ext/fts1/fts1_porter.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts1/fts1_porter.c
+fts1_tokenizer1.lo:    $(TOP)/ext/fts1/fts1_tokenizer1.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts1/fts1_tokenizer1.c
+
+fts2.lo:   $(TOP)/ext/fts2/fts2.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts2/fts2.c
+fts2_hash.lo:  $(TOP)/ext/fts2/fts2_hash.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts2/fts2_hash.c
+fts2_porter.lo:    $(TOP)/ext/fts2/fts2_porter.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts2/fts2_porter.c
+fts2_tokenizer1.lo:    $(TOP)/ext/fts2/fts2_tokenizer1.c $(HDR)
+   $(LTCOMPILE) -c $(TOP)/ext/fts2/fts2_tokenizer1.c

 fulltest:  testfixture$(TEXE) sqlite3$(TEXE)
    ./testfixture $(TOP)/test/all.test
 
2411 new active 2007 Jun anonymous   2007 Jun   5 3 fts2 RFE - Separate index and storage edit
It is my understanding of the current implementations of the fts modules that you save your text into the chosen table.column and in the background an index is generated for use by a special search operator. IMHO this puts two distinct concepts together, namely the storage of the text to be indexed, and its actual indexing for full-text-search.

What I am asking for here is the ability to create an fts-index without having the system store the text itself. I.e. putting the text into the table.column extends the index, but will not save the text.

This allows several things not possible with the current implementations:

  1. Storage of the text outside of the database (fts-index joined to path names).
  2. Compressed storage of text in the database (fts-index joined to separate blob table).

While I currently have no real idea yet about usecases for the first item I do see the following possible applications for the last item:

  1. SCM systems which wish to allow fts over all versions of a file, without giving up delta-compression between revisions.
  2. Help files which allow fts despite being space-efficient due to compressed storage of the help pages (zlib).

In both cases the current implementations of fts would force the applications to choose between either space efficiency, or searchability.

2007-Jun-13 07:23:58 by anonymous:
This mailing list thread lists additional usage scenarios and arguments in favor of separating FTS index from text storage. It also gives some DB size savings statistics:
 
1597 new active 2006 Jan anonymous Unknown 2007 May   1 3 wish: support DROP COLUMN edit
Please - add support for "drop column". For GIS user, as I, the Sqlite3 is a great, lighweight, powerfull tool for mananaging spatial data attributes. However, the lack of "drop column" seriously hampers it's usefullnes and still forces many GIS folks to use eg. Postgres, which is much more hard to handle than Sqlite - especially for newbies.

Plese note that Sqlite3 support was recently added to Grass (http://grass.itc.it), the most powerfull FOSS GIS. There were even discussions about making Sqlite3 a default database driver for Grass - easy to use, powerfull and fast. Please see: http://search.gmane.org/?query=sqlite+default&email=&group=gmane.comp.gis.grass.devel&sort=relevance&DEFAULTOP=and&%3E=Next&xP=sqlite.default.&xFILTERS=Gcomp.gis.grass.devel---A Extending the alter table commands, "drop column" most of all, could incline Grass devs to do so even more. There already were sevaral requests from Grass users regarding "drop column" in Grass sqlite driver:

http://article.gmane.org/gmane.comp.gis.grass.user/11141 http://thread.gmane.org/gmane.comp.gis.grass.devel/9454 http://grass.itc.it/pipermail/grass5/2006-January/020764.html

Any chances?

Maciek

2006-Jan-10 22:51:16 by drh:
http://www.sqlite.org/faq.html#q13


2006-Oct-24 21:37:43 by anonymous:
Hope to see this feature too...


2006-Oct-24 21:44:53 by anonymous:
I did this in a way that I create a parses that undestand the drop column and modify column sintax, but they create a temporary table, copy data between old and new, then create the new table and copy data back. not efficient, but works.


2007-May-20 08:26:54 by anonymous:
Please give consideration to drop column. One of SQLite's most potent features is the tiny footprint embedding. Requiring a temporary table to perform simple structure alterations effectively halves the maximum safe size of a table with regards to its primary storage context.

There's a reason it comes up as often as it does, despite the points in the FAQ. The temporary table hack is frequently a serious limiting factor. It seems likely that this wouldn't be a huge issue for the codebase, considering that other table structural alterations (add column, most notably) are apparently workable.

Please?


2007-May-20 12:56:56 by anonymous:
What would you like DROP COLUMN to do?

Copy the old table to a new table without the column in question, or just leave the old table in place without reclaiming space and simply ignore the old column?

What about constraints on that column? If they are violated should the DROP COLUMN be ignored?

 
1924 new active 2006 Aug anonymous Parser 2007 May   2 3 optimize queries on unions, constant folding edit
Please see the attached patch that optimizes SELECTs on a compound subquery, or VIEWs containing UNIONS.

  pragma temp_store=memory;
  CREATE TABLE n1(a integer primary key);
  INSERT INTO "n1" VALUES(1);
  INSERT INTO "n1" VALUES(2);
  INSERT INTO "n1" VALUES(3);
  INSERT INTO "n1" VALUES(4);
  INSERT INTO "n1" VALUES(5);
  INSERT INTO "n1" VALUES(6);
  INSERT INTO "n1" VALUES(7);
  INSERT INTO "n1" VALUES(8);
  INSERT INTO "n1" VALUES(9);
  INSERT INTO "n1" VALUES(10);
  CREATE VIEW vu as select v3.a a, v5.a-v2.a*v7.a b from n1 v1,n1 v2,n1 v3,n1 v4,n1 v5,n1 v6,n1
v7;
  CREATE VIEW v2 as select * from vu union all select 7, 8;

  select count(*), avg(b) from v2 where a<3;

The above query takes 58 seconds in sqlite 3.3.7, using 136M of temp_store. With the patch, it takes just 12 seconds and uses 26M of temp_store.

The patch also performs 32 bit integer constant folding:

  sqlite> explain select 1*2+3-4%5/2|128;
  0|Goto|0|4|
  1|Integer|131|0|
  2|Callback|1|0|
  3|Halt|0|0|
  4|Goto|0|1|
  5|Noop|0|0|
2006-Aug-17 13:03:31 by anonymous:
TK_REM (the '%' operator) is not handled correctly in the patch. It should follow the logic of TK_SLASH and check 'right' against zero.

  +        case TK_REM:    { v = left %  right; break; }

...

  +        case TK_SLASH:  {
  +          if (right) {
  +            v = left / right;
  +          } else {
  +            return;
  +          }
  +          break;
  +        }


2006-Aug-17 15:50:20 by anonymous:
These 2 cases can overflow a 32 bit value. The calculation should be done in 64 bit int math, and if the result can fit into 32-bits, then fold it, otherwise return (similar to TK_SLASH).

  +        case TK_PLUS:   { v = left +  right; break; }
  +        case TK_STAR:   { v = left *  right; break; }

Or just handle all cases in 64-bit math.


2006-Aug-18 10:11:53 by anonymous:
Wouldn't TK_MINUS also be able to overflow 32-bit, just in the opposite direction, so to speak ? Example: -2000000000 - 2000000000


2006-Aug-18 13:51:05 by anonymous:
should you make

+ i64 left; + i64 right; + i64 v;

instead of

+ int left; + int right; + int v;

to avoid int32 overflows.


2006-Aug-18 16:27:21 by anonymous:
The attachment sqlite337-union-and-constants-opt-v2.diff.txt addresses all reported issues and passes "make test" without any regressions.


2006-Aug-18 19:41:20 by anonymous:
You're not assuming that "right" could be a i64 value in this last patch...


2006-Aug-19 13:41:14 by anonymous:
right is a 32 bit value.

  /*
  ** If the expression p codes a constant integer that is small enough
  ** to fit in a 32-bit integer, return 1 and put the value of the integer
  ** in *pValue.  If the expression is not an integer or if it is too big
  ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.
  */
  int sqlite3ExprIsInteger(Expr *p, int *pValue){


2007-May-16 20:09:38 by anonymous:
Updated patch as of May 16, 2007 CVS:

http://marc.info/?l=sqlite-users&m=117934558505665&w=2

http://marc.info/?l=sqlite-users&m=117934558505665&q=p3


2007-May-19 15:47:51 by anonymous:
Some improvements, new comments and a new test case.

http://www.mail-archive.com/sqlite-users%40sqlite.org/msg24859.html

http://marc.info/?l=sqlite-users&m=117958960408282&q=p3

 
2207 new active 2007 Jan anonymous   2007 May   3 4 "CREATE TABLE foo AS SELECT * FROM bar" doesn't copy constraints edit
(cut & paste from an email I sent to the list, though afaict it never appeared)

When creating a table using AS SELECT ... I noticed it didn't copy the constraints:

    SQLite version 3.3.8
    Enter ".help" for instructions
    sqlite> .schema
    CREATE TABLE bar (
            t INTEGER NOT NULL PRIMARY KEY,
            d INTEGER NOT NULL
    );
    sqlite> CREATE TABLE foo AS SELECT * FROM bar;
    sqlite> .schema
    CREATE TABLE foo(timestamp INTEGER,download INTEGER);
    CREATE TABLE bar (
            t INTEGER NOT NULL PRIMARY KEY,
            d INTEGER NOT NULL
    );

Is this expected behavior?

I find myself in a sitation where ideally I would like this to create a table copying contraints (so I can do some processing in dynamically created temporary tables).

I had a quick look over the documentation and it doesn't mention this either way.

2007-Jan-30 18:52:49 by drh:
I have a lot of code that depends "CREATE TABLE ... AS SELECT" not copying the constraints. Changing this so that constraints are copied would break my code - which is something I am disinclined to do.


2007-Jan-30 19:06:34 by anonymous:
Can we perhaps just document this then as the intended behavior then then close this bug out please?


2007-Jan-30 21:57:10 by anonymous:
How about a new feature:

CREATE TABLE foo WITH CONSTRAINTS AS SELECT * FROM bar

 
2373 new active 2007 May anonymous   2007 May   4 4 "create table as explain <expr>" doesn't work edit
When using EXPLAIN to try to figure out why/when indices are being used on some tables and not all sometimes I get a lot of data returned.

It would be useful to be able to store this in a table so I can actually use SQL itself to examine the differences in the results I get.

 
2333 new active 2007 May anonymous   2007 May   5 4 support memory mapped files edit
Both Unix and Windows support memory mapped files, i.e. you can load file into memory and then operate on the memory while system reads and writes data from/to a file.

It would be useful if Sqlite could support this -- the user would load file to memory (map file) and then open a database with not a filename but handle to this memory-map.

Reason of this wish: I have read-only database which takes too much time for the first load. Any next load (not long from the first one) is quite fast. So I would like to map the entire database into memory and keep it resident (i.e. database would be in memory even my app quits). This way any load (except the first) would be fast. In other words it would be a permanent database (the whole database) cache.

2007-May-03 11:27:36 by drh:
The size of memory mapped files is limited by the address space of the underlying CPU. So on a 32-bit machine, databases larger than 4GiB are not accessible using memory mapped files.
 
2329 new active 2007 Apr anonymous   2007 Apr   5 4 add a feature to .dump : partial dumps edit
Hi,

I would like to request a feature related to the .dump command

introduction: ;-) I have a large database (few GB) and I only remove rows from it. since I forgot to use the pragma auto_vacuum, I am creating using .dump another database that has the triggers and pragmas I needed. okay. so, this is slow. probably mainly because of the millions of inserts it needs to perform.

the feature request: partial .dumps - that is, you specify how many rows or how many megabytes to dump. this should add a begin transaction and a commit at the end of each dumpfile, and enumerate them as well.

for example:

sqlite3 mylarge.db .partialdump --rows=40000 > dumpfile.sql<enter>

dumping.. please wait

    1. dumping first 40000 rows to file dumpfile.001.sql ....done
    2. dumping second 40000 rows to file dumpfile.002.sql ....done

etc..

hope this is obvious enough. if you need more info contact me. I know sqlite tries to be minimal and to the point, but this is a good feature and very handy. (dumping to text and then splitting can take too much space and then impractical) Thanks, Kobi

 
2327 new active 2007 Apr anonymous   2007 Apr anonymous 2 1 "DELETE" operation makes memory rise edit
First declare a standard SQL script: delete from TableName where ....; Then calling repeatedly the sqlite3_exec() to process this "DELETE" operation. Surprisely the memory was rising fast, and couldn't be freed even the program exitted.
 
2304 new active 2007 Apr anonymous   2007 Apr   1 1 resolve "databas is locked" problem under DEFERRED transaction edit
under DEFERRED transaction,

if there are multiple thread immediate execute writing operation after BEGIN statement,
sqlite will direct kick in "database is locked" exception,

but if you execute some reading operation before writing operation,
it works well,

could BEGIN statement acquire a shared lock and solve this problem?

{quote: relative mail archive http://www.mail-archive.com/sqlite-users@sqlite.org/msg21768.html }

 
2256 new active 2007 Feb anonymous   2007 Apr drh 5 1 Add POSITION() function (SQL-92 standard) edit
Hi!

Just voting for POSITION() function.

It's mighty useful when you need to modify a field in real time with SUBSTR() function (for instance, when 'start' parameter of SUBSTR() function needs to be variable according to POSITION() function).

Many thanks!

Regards.

2007-Mar-23 14:10:14 by anonymous:
Yes, this is a function which I often suffered from not being available.
 
2280 new active 2007 Mar anonymous   2007 Mar   4 3 Check constraint failure message should include field name edit
When an insert or update fails due to a check constraint the error message only says that the insert/update failed. It would be nice if the error message included the field name related to the failed check constraint.

Thanks,

Sam

2007-Mar-31 00:53:55 by drh:
Duplicate of ticket #2258
 
930 new active 2004 Sep anonymous Unknown 2007 Mar drh 2 2 djgpp port for sqlite3 edit
hello,

attached is a diff to sqlite 3.0.7 for dos, using free djgpp.

i did it in the spirit of the isolated platform files, and the generic changes (such as creation of os_dependent functions) have been implemented for all platforms available.

as required, the following copyright applies:

The author or authors of this code dedicate any and all copyright interest in this code to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights this code under copyright law.

thanks for sqlite,

and enjoy coding,

alex

p.s. i see that the diff i provided got mangled, and i'm changing it for the original one. since i'm unable to delete the wrong attachment, i would urge you to use the second one.

alex

 
2136 new active 2007 Jan anonymous   2007 Mar   1 3 sqlite locking does not handle afs; patch included edit
Please see

http://www.mail-archive.com/sqlite-users%40sqlite.org/msg20672.html

2007-Jan-02 03:37:59 by anonymous:
According to this checkin, that code has already been added to SQLite:

http://www.sqlite.org/cvstrac/chngview?cn=3459


2007-Jan-16 00:08:58 by anonymous:
Nope, that's something different.


2007-Mar-30 00:39:05 by anonymous:
You're right. I should have looked at the link more closely.
 
2231 new active 2007 Feb anonymous   2007 Mar   4 4 shell should ignore leading whitespace for meta commands edit
The current shell.c doesn't ignore whitespace before meta commands. This is annoying since it ignores whitespace for sql and other commands and thus prevents indenting from being used. If a script is sent to someone like...

sqlite3 data.db3
  .header on
  create table ...
  .q
They can't just cut and paste the script into sqlite3 because of the whitespace.

Patch is ...

--- ..\sqlite-source-3_3_13\shell.c	2007-02-13 08:08:34.000000000 -0300
+++ shell.c	2007-02-15 04:18:05.726995200 -0300
@@ -934,22 +934,35 @@
   }
   return val;
 }

 /*
+** Determine if an input line begins with "." ignoring whitespace.
+*/
+static int is_meta_command(const char *z){
+    while( isspace((unsigned char)*z) ){ z++; }
+    return *z == '.';
+}
+
+/*
 ** If an input line begins with "." then invoke this routine to
 ** process that line.
 **
 ** Return 1 on error, 2 to exit, and 0 otherwise.
 */
 static int do_meta_command(char *zLine, struct callback_data *p){
-  int i = 1;
+  int i = 0;
   int nArg = 0;
   int n, c;
   int rc = 0;
   char *azArg[50];

+  /* Skip the "." prefix.
+  */
+  while(zLine[i] != '.'){ i++; }
+  ++i;
+
   /* Parse the input line into tokens.
   */
   while( zLine[i] && nArg<ArraySize(azArg) ){
     while( isspace((unsigned char)zLine[i]) ){ i++; }
     if( zLine[i]==0 ) break;
@@ -1560,11 +1573,11 @@
       seenInterrupt = 0;
     }
     lineno++;
     if( p->echoOn ) printf("%s\n", zLine);
     if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue;
-    if( zLine && zLine[0]=='.' && nSql==0 ){
+    if( zLine && is_meta_command(zLine) && nSql==0 ){
       rc = do_meta_command(zLine, p);
       free(zLine);
       if( rc==2 ){
         break;
       }else if( rc ){
2007-Mar-01 21:53:33 by anonymous:
Any possibility of this going in? A simple change. Full patch. Brings meta command whitespace processing to the same functionality as SQL (i.e. ignore leading whitespace). Submitting patches to opensource projects is so frustrating when there is no feedback.
 
2233 new active 2007 Feb anonymous   2007 Mar   4 3 extend xBestIndex in vtables to carry the values for each contraint edit
It would be helpful if the xBestIndex method in virtual table carried the actual values for each constraint. This would allow clients of this call to more accurately set the estimatedCost of the query. The values are available in xFilter but the estimated cost has already been set and encoded by then.

Thanks...

At the time xBestIndex is called, the values are likely runtime variables or unbound host parameters and are thus unknown.
 
2258 new active 2007 Feb anonymous   2007 Mar   4 3 Include field name in check constraint failure message edit
When a check constraint on a column fails SQLite just responds with "constraint failed". It'd be nice if it included the column name for which constraint failed and possibly the value that failed to pass the constraint.

Thanks,

Sam

 
1778 new active 2006 Apr anonymous Parser 2007 Mar   1 3 stdev does not work, workaround not possible due to missing sqrt edit
It would be so great but it is too hard to use sqlite for any statistical purposes without having either an easy way of calculating standard deviation (stdev) nor any chance to create an ugly workaround because square root (sqrt) is also not working or missing. And even to square (sqr) values are resulting in long terms; but at least this is possible.
Is this because it is a lot of work to calculate the sum of values and sum of values squared at the same time during record traversal? Would this basic and standard function be not SQL conform?

Example:
select count(*), avg(Num), stdev(Num) from Population;

My workaround proposal is to use variance due to missing sqrt function:
select count(*), avg(Num) as mean,
(sum(Num*Num)/(count(*)-1)-sum(Num)*sum(Num)/count(*)/(count(*)-1)) as stdevsquared from Population;
Isn't this looking ugly and error prone? Can you imagine the performance if I have to calculate mean and stdev for 20 or more columns?
2006-Apr-20 14:27:31 by anonymous:
It's pretty simple to add your own custom functions to SQLite. Edit sqlite/src/func.c and take a search for sumStep and sumFinalize for an example.


2006-Apr-20 18:11:06 by anonymous:

  Index: src/func.c
  ===================================================================
  RCS file: /sqlite/sqlite/src/func.c,v
  retrieving revision 1.127
  diff -u -r1.127 func.c
  --- src/func.c        7 Apr 2006 13:26:43 -0000       1.127
  +++ src/func.c        20 Apr 2006 18:10:08 -0000
  @@ -20,7 +20,7 @@
   */
   #include "sqliteInt.h"
   #include <ctype.h>
  -/* #include <math.h> */
  +#include <math.h>
   #include <stdlib.h>
   #include <assert.h>
   #include "vdbeInt.h"
  @@ -114,6 +114,20 @@
   }

   /*
  +** Implementation of the sqrt() function
  +*/
  +static void sqrtFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  +  double rVal;
  +  assert( argc==1 );
  +  rVal = sqlite3_value_double(argv[0]);
  +  if( rVal<0.0 ) {
  +    sqlite3_result_error(context, "sqrt of negative", -1);
  +    return;
  +  }
  +  sqlite3_result_double(context, sqrt(rVal));
  +}
  +
  +/*
   ** Implementation of the abs() function
   */
   static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  @@ -995,6 +1009,7 @@
   #ifndef SQLITE_OMIT_UTF16
       { "substr",             3, 0, SQLITE_UTF16LE, 0, sqlite3utf16Substr },
   #endif
  +    { "sqrt",               1, 0, SQLITE_UTF8,    0, sqrtFunc   },
       { "abs",                1, 0, SQLITE_UTF8,    0, absFunc    },
       { "round",              1, 0, SQLITE_UTF8,    0, roundFunc  },
       { "round",              2, 0, SQLITE_UTF8,    0, roundFunc  },


2006-Jun-03 22:30:12 by anonymous:
VAR() and STDEV() aggregate functions that match Excel:

  sqlite> select var(a), stdev(a) from (select 1 a union select 9 a);
  32.0|5.65685424949238

  Index: src/func.c
  ===================================================================
  RCS file: /sqlite/sqlite/src/func.c,v
  retrieving revision 1.128
  diff -u -3 -p -r1.128 func.c
  --- src/func.c        11 May 2006 13:25:39 -0000      1.128
  +++ src/func.c        3 Jun 2006 22:25:46 -0000
  @@ -20,7 +20,7 @@
   */
   #include "sqliteInt.h"
   #include <ctype.h>
  -/* #include <math.h> */
  +#include <math.h>
   #include <stdlib.h>
   #include <assert.h>
   #include "vdbeInt.h"
  @@ -820,6 +820,42 @@ static void test_error(
   }
   #endif /* SQLITE_TEST */

  +typedef struct VarCtx VarCtx;
  +struct VarCtx {
  +  i64 n;
  +  double sumw;
  +  double m;
  +  double t;
  +};
  +static void varStep(sqlite3_context *context, int argc, sqlite3_value **argv){
  +  VarCtx *p;
  +  double xi, q, temp, r;
  +  assert( argc==1 );
  +  p = sqlite3_aggregate_context(context, sizeof(*p));
  +  xi = sqlite3_value_double(argv[0]);
  +  q = xi - p->m;
  +  temp = p->sumw + 1;
  +  r = q / temp;
  +  p->m += r;
  +  p->t += r * p->sumw * q;
  +  p->sumw = temp;
  +  ++p->n;
  +}
  +static void varFinalize(sqlite3_context *context){
  +  VarCtx *p = sqlite3_aggregate_context(context, 0);
  +  if( p && p->n>1 ){
  +    double s2 = p->t * p->n / ((p->n - 1) * p->sumw);
  +    sqlite3_result_double(context, s2);
  +  }
  +}
  +static void stdevFinalize(sqlite3_context *context){
  +  VarCtx *p = sqlite3_aggregate_context(context, 0);
  +  if( p && p->n>1 ){
  +    double s2 = p->t * p->n / ((p->n - 1) * p->sumw);
  +    sqlite3_result_double(context, sqrt(s2));
  +  }
  +}
  +
   /*
   ** An instance of the following structure holds the context of a
   ** sum() or avg() aggregate computation.
  @@ -1026,6 +1062,8 @@ void sqlite3RegisterBuiltinFunctions(sql
       { "max",    1, 2, 1, minmaxStep,   minMaxFinalize },
       { "sum",    1, 0, 0, sumStep,      sumFinalize    },
       { "total",  1, 0, 0, sumStep,      totalFinalize    },
  +    { "var",    1, 0, 0, varStep,      varFinalize    },
  +    { "stdev",  1, 0, 0, varStep,      stdevFinalize  },
       { "avg",    1, 0, 0, sumStep,      avgFinalize    },
       { "count",  0, 0, 0, countStep,    countFinalize  },
       { "count",  1, 0, 0, countStep,    countFinalize  },


2007-Mar-29 08:18:34 by anonymous:
Is it still valid with 3.3.13 that sqrt function is not available from within SQLite? or stdev? Or does there exist anywhere in the www an extension library already (for windows and linux) to enhance SQLite 3.3.13 for mathematical/statistical functions? Or is it the standard that everybody has to develop her/his own extensions for basic functionality? I do not know if this is a bug/lack of function or if it's my fault to find the right way of usage. Please help! From my point of view some few statistical functions would increase the usability and value of the SQLite database very much.
 
151 new active 2002 Sep anonymous   2007 Mar   5 5 Add 'configure' options for locating readline headers and library edit
Just a feature request on the build system. If 'configure' offered compile-time options for specifying the location for readline's includes and headers, that would make it easier to link in readline support on systems where readline isn't installed in /usr/local.

It is common to see '--with-readline-includes' and '--with-readline-libs' as config options in other software distributions that use readline.

2007-Mar-20 23:11:10 by anonymous:
In the meantime, if you want to link against a readline in an unusual location, configure (it will configure without readline), then edit the resultant Makefile:

# Compiler options needed for programs that use the readline() library.
#
READLINE_FLAGS = -DHAVE_READLINE=1 -I/home/mjs/local/include

# The library that programs using readline() must link against.
#
LIBREADLINE = -L/home/mjs/local-linux/lib -lreadline -lncurses
 
2266 new active 2007 Mar anonymous   2007 Mar anonymous 3 3 Add support for Row_Number() Over edit
Row_Number() Over is a windowing function included in the SQL:2003 standard. I need it to be able to rank order several groups by size, using a single query. I know SQLite does not support SQL:2003, but it would be nice to have at least this one function supported.
2007-Mar-10 10:06:33 by anonymous:
You can easily write your own UDF using SQLite API. Here's an example if you need it right now:

typedef unsigned long long int rowNumberContext;
// aggregate step callback
void rowNumberStep(sqlite3_context *context, int argc, sqlite3_value **argv) {
  // initialize or get aggregate function context
  rowNumberContext *agg_context = (rowNumberContext*)sqlite3_aggregate_context(context, sizeof(rowNumberContext));
  (*agg_context)++;
}

// aggregate final callback
void rowNumberFinal(sqlite3_context *context) {
  sqlite3_result_int64(context, *((rowNumberContext *)sqlite3_aggregate_context(context, sizeof(rowNumberContext))));
}

// then just create function:
sqlite3_create_function(db_handle, "row_number", 0, SQLITE_ANY, null, null, rowNumberStep, rowNumberFinal);

I hope I get it right. This piece of sample code has NOT been tested! Use it at your own risk.


The code above is a good implementation of count(*), but not row_number().

I think Row_Number() is one of the SQL2003 windowing functions. Implementing these would require modifications to the parser, compiler and vdbe layers of sqlite. Not possible using current APIs.

At the current time queries that use Row_Number() will have to be rewritten to use temp tables as intermediate steps.

 
2254 new active 2007 Feb anonymous   2007 Feb   5 4 ATTACH support IF NOT ATTACHED statement edit
It'd be nice if ATTACH supported an IF NOT ATTACHED option as in

ATTACH IF NOT ATTACHED 'C:\db\log.dat' AS Logs

so there'd be no harm in issuing an attach statement multiple times (and no need to query the database list to see if a database is already attached).

 
2238 new active 2007 Feb anonymous   2007 Feb   2 3 Streams as datbase edit
Would it be possible to allow the use of streams as a database source?
2007-Feb-18 03:56:46 by anonymous:
You'll have to be more precise in what you mean by that.

SQLite needs to be able to do random access to the database data (ie seek all over the place according to how it is laid out).

It also needs the ability to have a journal file alongside the database which is used when writing to do a rollback, or even for readers to know that a rollback needs to be done.

I am not aware of any 'streams' that meet those criteria.

 
2235 new active 2007 Feb anonymous   2007 Feb   4 3 Missing xml support in FTS2 for the snippet function edit
The snippet function may output invalid characters when used for an xml stream (like xhtml). Characters &, < and > need to be escaped (&amp, &lt; &gt;) in this context. The modification proposed is to add a boolean parameter to the snippet function to disable/enable the XML processing mode ; for example, given :

insert into poem (name, text) values ('test', 'Xml string with special < > & entities') ;

select snippet(poem, '<strong>', '</strong>', '...', 1) from poem where text match 'xml' ;

output should be:

<strong>Xml</strong> string with special &lt; &gt; &amp; entities

This modification does not affect the default behaviour of the snippet function. Patch included.

 
2224 new active 2007 Feb scouten   2007 Feb   4 4 Option to have one-bit "journal should exist" flag edit
Per discussion with DRH: Would it be possible to have a one-bit flag in the header page of the DB file that signals that there should be a journal file present. If you attempt to open a database with that flag set, but the journal file is not present, SQLite should fail to open the DB.
2007-Feb-09 13:47:44 by drh:
Here is the issue: An application that uses SQLite for persistence is receiving database corruption reports from the field. The developers believe that the corruption occurs after a power failure or other crash leaves a hot journal file and then the users manually deletes the hot journal thinking that it is some garbage file left over from the crash. If there is a "journal should exist" flag in the database file and no journal is seen, that would indicate that the journal has been deleted or renamed and that the database has been corrupted. If the application can detect this, it might be able to locate the deleted journal in the trashcan and recover from the user error.

Other ideas for addressing this problem:

  • Change the "-journal" extension on the journal files to something like "-do-not-delete".

  • Make the journal a hidden file. (The problem here is that if somebody goes to move the databaes file and the database has a hot journal, they would likely not know to move the journal too since it is not visible.)

  • Change permissions on the journal file so that it is read-only. This doesn't prevent the journal from being deleted by a determined user, but it might at least give them a clue that this is not a file to be deleted without at least due consideration.
 
2221 new active 2007 Feb anonymous   2007 Feb drh 3 4 Store blobs using inode-like lookup of pages rather than linked list edit
In a recent conversation, the matter of how BLOBs are stored came up. Currently, each page of BLOB data is in a linked list. By default each page is 1K so a very large BLOB may have many many pages.

The linked list becomes inefficient to find and update BLOBs.

DRH mentioned a thought to move to an inode style of page management for BLOBs. This would require updating the file format.

 
2220 new active 2007 Feb anonymous   2007 Feb drh 2 4 fsck for database files edit
The existing recovery strategies for dealing with a corrupted database are entirely manual and could be improved with a reasonable amount of effort. One possible way to mitigate the issue would be the creation of an fsck recovery mechanism. This would be an improved recovery from the current .dump support.
 
2204 new active 2007 Jan anonymous   2007 Feb   5 3 Stable, documented metadata interface edit
In response to #2203, I'd like to suggest that a documented, stable means be added to SQLite3 by which consumers of the API may reliably query column metadata for a table, including the names of the columns, whether they are nullable or not, their types, and what their default values are. Given that, currently, the only way to get this data is via the undocumented table_info pragma, clients who want this data are at your mercy every time that pragma changes.

Thanks!

2007-Jan-30 00:07:28 by anonymous:
How about implementing the sql-standard information_schema?

I see something similar at http://www.sqlite.org/cvstrac/wiki?p=InformationSchema

The PostgreSQL equivalent: http://www.postgresql.org/docs/current/static/information-schema.html


2007-Jan-31 19:14:48 by anonymous:
Pragma table_info is documented at http://www.sqlite.org/pragma.html#schema


2007-Jan-31 19:31:48 by anonymous:
PRAGMAs are deficient because they cannot be used within SELECT statements or as sub-selects. This severely limits their usefulness in an SQL-only context. You have to use SQLite's API to make use of them.


2007-Feb-03 15:10:36 by anonymous:
Note that I was told by Richard himself that the table_info pragma is not considered a documented interface, and as such is fair game for incompatible changes in point releases (as we saw in 3.3.8). What I'm asking for in this ticket is an interface that is officially sanctioned and documented, and which (barring the occassional bug) can be guaranteed to remain stable (between point releases at the very least).
 
1126 new active 2005 Feb anonymous Unknown 2007 Jan drh 2 3 sqlite 2.8.16 port to djgpp edit
here is a diff to be applied on sqlite 2.8.16 to make it work with djgpp. some of the fixes are needed for general purpose, such as relative path handling, and bypass of history and readline wherever not functional.

dear drh, please apply this patch to mainstream sqlite. waiver of copyright in the patch itself.

best regards,

alex <alexbodn@012.net.il>

2005-Feb-16 14:14:56 by drh:
I applied these patches. But then the regression tests fail under unix. The patches much have broken something. No time to fix it now....


2005-Feb-17 11:46:57 by anonymous:
thanks for your time. i will try to compile on linux and compare results.


2005-Oct-11 14:58:05 by anonymous:
i have to appologize for the long time it took me to get to it. i have found the flaw in the patch that made the fulltest fail on unix.

now, that tests pass, please incorporate the diff in mainstream.

i will fix the ports for sqlite3 too.


2007-Jan-31 01:33:52 by anonymous:
it seems someone has accidentally changed the diff i've provided for an invalid binary file.
 
2206 new active 2007 Jan anonymous   2007 Jan   5 4 Support for foreign key constraints in virtual tables edit
Please consider supporting parsing of foreign key constraints in the CREATE TABLE SQL text passed to sqlite3_declare_vtab().

Rationale: when a virtual table is used to implement something like a JOIN or VIEW on table(s) of the master SQLite database, PRAGMA foreign_key_list() on the virtual table(s) can provide information about key relationship between the virtual table(s) and the table(s) in the master SQLite database.

I've attached a patch which implements this feature, however I'm unsure about possible side effects.

 
2202 new active 2007 Jan anonymous   2007 Jan   5 4 function request: sqlite3_attach() edit
Hello! A request for a new function, if i may:

  int sqlite3_attach( sqlite3 * host, sqlite3 * parasite, char const * dbname );

In case it's not obvious, this would be functionally identical to calling:

  ATTACH parasite as dbname;

from the host database.

Alternately, but probably less useful:

  int sqlite3_attach( sqlite3 * host, char const * parasite, char const * dbname );

to directly attach databases. This second option isn't so useful because we already have this feature via the ATTACH SQL command.

 
2200 new active 2007 Jan anonymous   2007 Jan   5 4 threadsafe status not reported in .pc file edit
Some application based on sqlite (for exampe Tracker indexing and searching tool) could need the threadsafe.

Currently there in no way to know the status of threadsafe of installed sqlite.

It could be good add a "threadsafe" variable in sqlite3.pc like

    libdir=${exec_prefix}/lib
    includedir=${prefix}/include
    threadsafe=yes

that developers could query using:

   $ pkg-config --variable=threadsafe sqlite3
   yes
 
2198 new active 2007 Jan anonymous   2007 Jan   5 4 API: opening only existing databases edit
It would be useful to enhance the sqlite3_open function so it would take 3 parameters -- the third would control whether the database should exist for function success.

In other words (the 3rd argument):
create_or_access_existing -- works in both cases
do_not_create_new_db -- fails if there is no such database file

It is extremely useful if the user wants only read from the db. In current API she/he gets an delayed error while trying to read the table in database.

 
2185 new active 2007 Jan anonymous   2007 Jan   5 3 API access to opened database pathname - helpful for virtual tables edit
It would be helpful if there was an api to retrieve the pathname (or :memory:) to the opened database. I am implementing a virtual table and would like to open subsequent virtual table (flat files in the filesystem) in the same location that the DB was opened.
 
2181 new active 2007 Jan anonymous   2007 Jan   5 4 Generalize ON CONFLICT to failure trapping for all SQL statements edit
(This is a more general alternative to the feature request in #2180.)

It would be nice if clauses similar to ON CONFLICT were available for all supported statements, to specify error recovery behavior in all cases. For instance, one would like to be able to write things like

SELECT ... FROM foo ON ABSENT IGNORE;

with the effect that if there is no table 'foo', the SELECT simply returns zero rows. I am not sure what the complete set of conditions to recover from would be, but I think that ABSENT (table or column missing), EXISTS (something you're trying to create already exists), and NONEMPTY (to avoid deleting data unintentionally, per #2180) should cover most cases.

 
2180 new active 2007 Jan anonymous   2007 Jan   5 4 feature request: DROP TABLE IF [EXISTS AND] EMPTY edit
It would be useful to have a straightforward way to drop a table only if it contains no rows. Currently it is necessary to do this in application logic, by doing a dummy SELECT to find out if there's any data in the table (e.g. "SELECT 1 FROM table LIMIT 1" - this is the most efficient such query I can find). And of course one has to take care to handle errors in that SELECT (e.g. if the table doesn't exist).

I suggest DROP TABLE IF EMPTY, by analogy with the existing DROP TABLE IF EXISTS. Naturally, one would like to be able to combine the two, to drop an empty table but do nothing if the table exists or isn't empty.

2007-Jan-26 22:59:50 by anonymous:
To comment on that last statement:

"I suggest DROP TABLE IF EMPTY, by analogy with the existing DROP TABLE IF EXISTS. Naturally, one would like to be able to combine the two, to drop an empty table but do nothing if the table exists or isn't empty."

That sounds redundant: DROP TABLE IF EMPTY will not drop a table if it has any data, nor if the table does not exist. The question comes to mind, "when is there an error?" Is DROP TABLE IF EMPTY an error if the table is not empty? Or would we need DROP TABLE IF EXISTS AND IF EMPTY to ensure that we have clear success/failure paths in the case that we do DROP TABLE IF EMPTY for a table which we're not sure is there or not. If sounds like "IF EMPTY" should automatically imply "AND IF EXISTS", because a prerequisite of being empty is that the table has to exist.

IMO, a statement like DROP TABLE IF EMPTY is 100% sugar and should not produce any error code, similarly to DROP TABLE IF EXISTS (which does not produce an error if the table DOES exist, though we could rightfully argue that it should raise an error because its condition is not met).

----- sgb

 
2167 new active 2007 Jan anonymous   2007 Jan   1 3 add sqlite3_copy_bindings (parallel to sqlite3_transfer_bindings) edit
sqlite3_transfer_bindings( from, to ) does not leave the 'from' stmt in a usable mode. If I want to create a separate, independent copy of an sqlite3_stmt, I have to replicate the bindings.

I have created a modified version of sqlite3_transfer_bindings() which simply replaced sqlite3VdbeMemMove() with sqlite3VdbeMemCopy(), and named the function sqlite3_copy_bindings. I'm not an expert in Sqlite internals so I can't tell if there any issues with this.

 
1722 new active 2006 Mar anonymous Unknown 2007 Jan   4 2 agregate sum() of strings edit
i'd like to have something like sum() i agregate functions but to work with strings. I'd like to that that function would concate strings similar to summing in sum()e.g: SELECT sum(name || ',')FROM names GROUP BY ..... etc... :) I've heard that something like this is in postgresql?
 
931 new active 2004 Sep anonymous   2006 Dec   5 4 Makefile for mingw on Win32, makes DLL, EXE and docs edit
This is a more compact and easier to understand makefile which will work out-of-the box (well, almost) for people using mingw32 on Windows platforms.

MSYS is not needed, but it does require gawk, sed and grep (well, and GNU make too).

2005-Aug-27 01:07:30 by anonymous:
Has anybody compiled successfully sqlite3 3.2.x with mingw? how?


2005-Aug-27 02:13:20 by anonymous:
From version 2.8.14 to 3.2.4 I have no problems.


2005-Aug-27 12:24:58 by anonymous:
1. installed msys -c:\msys
2. installed mingw - c:\msys\mingw
3. installed msys toolkit and mingw make. see http://mingw.org/download.shtml
4. run msys.
5. go to sqlite directory.
6. ./configure
7. make

So easy so I can't tell more.


2005-Aug-27 13:14:58 by drh:
The precompiled windows binaries on the SQLite website have always been generated using mingw running as a cross-compiler on a linux host.


2005-Aug-27 15:14:09 by anonymous:
Ok, I got it working. There is just one discrepancy - I end up with the following:

291840 sqlite3.dll
1280564 sqlite3.exe

Whereas the downloadable "precompiled" binaries are just:

248320 sqlite3.dll
330203 sqlite3.exe

Is there anything else I need to do to get the exact same byte-size? (this is 3.2.4)


2005-Aug-27 15:18:55 by anonymous:
Is it possible that you're compiling with readline support (which isn't present in the distributed binary due to licensing issues)?


2005-Aug-27 15:27:43 by anonymous:
I do not know how to enable/disable readline support. I have not changed or added any switch to the above. Besides, I think the .dll does not use readline.


2005-Dec-27 10:55:55 by anonymous:
see also BuildOnWindowsWithoutTcl


2006-Dec-28 19:18:55 by anonymous:
Does this also generate a .a for use in applications? Still needing the .dll that is. I don't need sqlite.exe at all...


2006-Dec-28 19:51:44 by anonymous:
I assume you mean .a for MinGW or Cygwin. Using Cygwin or MinGW/MSYS just download and untar the sqlite3 source and issue these commands:

  cd sqlite
  ./configure
  make sqlite3.dll

The .a file will be located in sqlite/.libs/libsqlite3.a

 
2120 new active 2006 Dec anonymous   2006 Dec   5 4 Date Column support edit
1) date column declared as 'date' or 'datestr' or similar. 2) date real type is text, stored like 'yyyy-mm-dd'. 3) sqlite3_column_type() return SQLITE_DATE 4) min, max function return type SQLITE_DATE 5) (optional) new function: sqlite3_column_date() is same as sqlite3_column_text(); 6) modify return type of sqlite3_value_type() (add SQLITE_DATE) 7) (optional) new function sqlite3_value_date() same as sqlite3_value_text().
 
2105 new active 2006 Dec anonymous   2006 Dec   5 5 sqlite3_exec does not return modified rows edit
SQLite does not provide a way to determine wether a statement has succeeded unless it is a select statement. For instance using the following sample database

  create table urls (url text unique)
  insert into urls(url) values('http://www.sqlite.org')
  insert into urls(url) values('http://www.google.com')

The following statement will execute the callback from sqlite3_exec which can be used to count the rows (becuase its deemed a query)

  select * from urls

But the following statement will not execute the callback and so there is no way of knowing wether the statement was succesful or not.

  delete from urls where url='http://news.com'

In fact, it is indistinguisable from the following statement...

  delete from urls where url='http://www.google.com'

Even using prepared statements and the sqlite3_step function does not allow the user to determine the success of a statement or count affected rows. There needs to be some way to determine the number of affected rows as a result of a particular statement, not just queries. One solution would be for sqlite3_exec to call the callback once for each affected row, and that the fields and values parameters be left blank for non queries. Of course, a better solution may be to add a new API call which can be used when SQLITE_DONE is returned to check for affected rows. This would allow the API to actually signal success or failure, and more importantly provide a way of counting the affected rows from a particular statement. Most other database API's provide a way to do this.

After submitting this bug, i saw other bug reports that were similar with the suggestion that sqlite3_changes can be used to determine the number of affected rows. So i would like to change this bug report to simply be a documentation request. Please add a link to sqlite3_changes and a description in the documentation for sqlite3_exec so that it is easier to find.
2006-Dec-11 01:06:07 by anonymous:
There is still one case which i cannot resolve even using the sqlite3_changes api call. That is the following statement.

  select * from urls where url='';

Since this select statement returns no results, the callback is not called, and when i call the sqlite3_changes routine it simply supplies the previous change (since select is not considdered a change). So how then would i determine wether a statement returned no results without knowing in advance wether it was a select? I suggest sqlite3_changes be modified to return 0 when the statement was a select statement (since this also makes sense, there were no changes). This would allow the detection of select statements which return no results.


2006-Dec-11 01:23:07 by anonymous:
A workaround for this problem is to always manually reset the change count before calling sqlite3_exec

  db->nChange = 0;

Unfortunately this is not available to the user, since the sqlite3 structure is not defined in the header. Perhaps executing a statement which is known to always have 0 changes may achieve the same effect until this can be added/fixed.


2006-Dec-11 19:36:38 by anonymous:
You should look at the empty_result_callbacks pragma documentation at http://www.sqlite.org/pragma.html You can use set this to 1 to get a callback even when your query returns no results.

The other pragma you may be interested in is the count_changes pragma. It can cause insert, delete, and update statements to return a single row with the number of changes when using the sqlite3_exec API.

 
2087 new active 2006 Nov anonymous   2006 Nov   3 3 Ability to add a check constraint via the alter table command edit
This is an improvement request.

Add the possibility to add a check constraint to an existing table via the alter table statement.

Example :

  CREATE TABLE a(x INTEGER, y INTEGER);
  INSERT INTO a VALUES (1,2);
  ALTER TABLE a ADD CHECK (y>0);

Actual result :

  SQL error: near "CHECK": syntax error
 
1996 new active 2006 Sep anonymous Unknown 2006 Sep drh 2 3 Data type CHAR edit
An interface API for CHAR datatypes would really be helpful.

For example, often sql tables contain CHAR(1) datatypes or CHAR(10) types. There should be some mechanism for handling these types natively. ie: sqlite3_bind_char sqlite3_column_char sqlite3_result_char sqlite3_value_char

This will allow a more native implementation for CHAR datatypes, As it is, a single CHAR(1) must be first converted into a string (char[2]) and copied with a terminator. for CHAR types, not \000 termination is required. It is implied with the lenght.

Thanks...

 
1975 new active 2006 Sep anonymous   2006 Sep   5 4 Request for sqlite3_table_column_metadata16 edit
It would be nice to have a sqlite3_table_column_metadata16() function as an UTF-16 version of the existing sqlite3_table_column_metadata().
 
1959 new active 2006 Sep anonymous   2006 Sep   4 3 Unblockable TEMP TABLES edit
TEMP TABLES locks the complete database as long as a prepared stmt is running at the main database. Temp Tables are in separate files... so I hope it can be changed without big problems.

The new driver for OpenOffice.org needs temp tables that won't lock the complete database because of cached resultsets.

It only can be emulate it with "attach a database, copy data, detach". But the problem is that the API of OOo needs to change the cached resultset. It isn't possible to add this without temporary tables. So the driver could use sqlite3_update_hook() to know when he needs to reload the resultset.

Thanks

 
725 new active 2004 May anonymous   2006 Aug anonymous 5 5 Implement ATTACH LIB comand edit
It would be nice to mantain some functions in separate library, and be able to reuse in command line sqlite or in other projects. Syntax should be something like:

ATTACH LIB "some_lib_name"

some_lib_name should export function like

RegisterSQLiteFunctions

 
1942 new active 2006 Aug anonymous   2006 Aug   4 4 select without left join with the *= operator edit
  Enhancement request for support *=/=* operator in select queries.
  It's more easier to write SQL queries without left/right join by using *=/=* operator.

  Mentionned on Unsupported Wiki page :

http://www.sqlite.org/cvstrac/wiki?p=UnsupportedSql

    * 2006.03.06 : select without left join with the *= operator

      SELECT t1.code, t2.code
      FROM table1 t1, table2 t2
      WHERE t1.t2_ref_id *= t2.id

      This is Sybase ASE syntax. Use LEFT JOIN or RIGHT JOIN instead.
 
1928 new active 2006 Aug anonymous Parser 2006 Aug   2 2 NULL rowid in views and subqueries edit
$ cat rowid_on_views.sql

  create table abc(a,b,c);
  insert into abc values(4,5,6);
  insert into abc values(3,2,1);
  create view vv as select * from abc;
  select 'select rowid, * from abc;';
  select rowid, * from abc;
  select 'select rowid, * from (select * from abc);';
  select rowid, * from (select * from abc);
  select 'select rowid, * from vv;';
  select rowid, * from vv;

$ ./sqlite337 < rowid_on_views.sql

  select rowid, * from abc;
  1|4|5|6
  2|3|2|1
  select rowid, * from (select * from abc);
  |4|5|6
  |3|2|1
  select rowid, * from vv;
  |4|5|6
  |3|2|1
2006-Aug-21 09:09:15 by anonymous:
The point is simply that a view or subquery does not (meaning "cannot") have a rowid - just contemplate the case where your view takes the max(..) or count(..) of something.

You would get the behaviour that you seem to expect when you declare your original table as

    create table abc(rowid integer primary key, a,b,c);


2006-Aug-21 14:35:04 by anonymous:
Not sure what you're talking about. Your example does not work.

Many databases support the concept of "row id's" on views. It is a very useful construct.

  -- working Oracle example

  create table abc(a integer, b integer ,c integer);
  insert into abc values(4,5,6);
  insert into abc values(3,2,1);
  create view abc_vu as select * from abc;
  select rownum, a, b, c  from (select * from abc_vu);

  ROWNUM	A	B	C
  1	4	5	6
  2	3	2	1

  -- another Oracle example
  select rownum, v1.*, v2.*  from (select * from abc_vu) v1, (select * from abc_vu) v2;

  ROWNUM	A	B	C	A	B	C

  1	4	5	6	4	5	6
  2	3	2	1	4	5	6
  3	4	5	6	3	2	1
  4	3	2	1	3	2	1


2006-Aug-22 05:32:26 by anonymous:
Hm, rowid (original ticket) and rownum (3rd remark) are very different things. I've tested the following with Oracle:

   create table abc(a integer, b integer ,c integer);
   insert into abc values(4,5,6);
   insert into abc values(3,2,1);
   insert into abc values(4,5,10);
   create view abc_vu as select max(a) as amax,b,count(*) as cnt from abc group by b;

Now

  SQL> select rownum, amax,b,cnt from (select * from abc_vu);

      ROWNUM	 AMAX	       B	CNT
  ---------- ---------- ---------- ----------
  	 1	    3	       2	  1
  	 2	    4	       5	  2

whereas

   SQL> select rowid, amax,b,cnt from (select * from abc_vu);
   select rowid, amax,b,cnt from (select * from abc_vu)
                                             *
   ERROR at line 1:
   ORA-01446: cannot select ROWID from view with DISTINCT, GROUP BY, etc.


2006-Aug-22 05:36:03 by anonymous:
PS: selecting rowid from views without "group by" is supported by Oracle:

  SQL> create view abc_vu2 as select * from abc;

  View created.

  SQL>  select rowid,a,b,c from (select * from abc_vu2);

  ROWID			    A	       B	  C
  ------------------ ---------- ---------- ----------
  AAADmaAAFAAAFNzAAA	    4	       5	  6
  AAADmaAAFAAAFNzAAB	    3	       2	  1
  AAADmaAAFAAAFNzAAC	    4	       5	 10
 
1933 new active 2006 Aug anonymous   2006 Aug   5 4 Add different date's separators edit
A time string can be in any of the following formats:

   1. YYYY-MM-DD
   2. YYYY-MM-DD HH:MM
   3. YYYY-MM-DD HH:MM:SS
   4. YYYY-MM-DD HH:MM:SS.SSS
   5. YYYY-MM-DDTHH:MM
   6. YYYY-MM-DDTHH:MM:SS
   7. YYYY-MM-DDTHH:MM:SS.SSS
   8. HH:MM
   9. HH:MM:SS
  10. HH:MM:SS.SSS
  11. now
  12. DDDD.DDDD

Add possibility to have date's separators different of dash

Examples :

  YYYY.MM.DD HH:MM:SS
  YYYY/MM/DD HH:MM:SS
 
1907 new active 2006 Aug anonymous   2006 Aug   4 4 date and time types edit
I would like to have datetime types in sqlite (date, datetime, interval).

as far as I understood of sqlite, the declared type used in the create table statement is just a hint, and the data is stored with its own type description. this makes it impossible to store a date into any field, unless type checking, conversion and validation is performed by the client side.

implementing type checking and conversion on the client side would mean that the dynamic typing in sqlite goes lost for that applications.

2006-Aug-05 13:49:35 by anonymous:
Also, the way SQLite currently stores datetimes is not space efficient (stored as text) and there is no standard format between different SQLite applications. But I can't see a way to improve this situation without breaking backwards compatability.
 
1906 new active 2006 Aug anonymous Unknown 2006 Aug   1 2 date.c line 417 uses non-thread safe localtime() call edit
The date.c file uses a call to localtime() that is not threadsafe. Could it be replaced with localtime_r where supported.
2006-Aug-04 16:17:22 by anonymous:
Please apply this patch to make SQLite threadsafe:

  Index: configure.ac
  ===================================================================
  RCS file: /sqlite/sqlite/configure.ac,v
  retrieving revision 1.26
  diff -u -r1.26 configure.ac
  --- configure.ac      3 Jun 2006 18:02:18 -0000       1.26
  +++ configure.ac      4 Aug 2006 16:05:21 -0000
  @@ -669,6 +669,11 @@
   #
   AC_CHECK_FUNC(usleep, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_USLEEP=1"])

  +#########
  +# Figure out whether or not we have a "localtime_r()" function.
  +#
  +AC_CHECK_FUNC(localtime_r, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_LOCALTIME_R=1"])
  +
   #--------------------------------------------------------------------
   # Redefine fdatasync as fsync on systems that lack fdatasync
   #--------------------------------------------------------------------
  Index: src/date.c
  ===================================================================
  RCS file: /sqlite/sqlite/src/date.c,v
  retrieving revision 1.54
  diff -u -r1.54 date.c
  --- src/date.c        31 Jan 2006 20:49:13 -0000      1.54
  +++ src/date.c        4 Aug 2006 16:05:21 -0000
  @@ -393,7 +393,7 @@
   static double localtimeOffset(DateTime *p){
     DateTime x, y;
     time_t t;
  -  struct tm *pTm;
  +  struct tm tmLocaltime;
     x = *p;
     computeYMD_HMS(&x);
     if( x.Y<1971 || x.Y>=2038 ){
  @@ -411,15 +411,20 @@
     x.validJD = 0;
     computeJD(&x);
     t = (x.rJD-2440587.5)*86400.0 + 0.5;
  -  sqlite3OsEnterMutex();
  -  pTm = localtime(&t);
  -  y.Y = pTm->tm_year + 1900;
  -  y.M = pTm->tm_mon + 1;
  -  y.D = pTm->tm_mday;
  -  y.h = pTm->tm_hour;
  -  y.m = pTm->tm_min;
  -  y.s = pTm->tm_sec;
  -  sqlite3OsLeaveMutex();
  +//#define HAVE_LOCALTIME_R
  +#ifdef HAVE_LOCALTIME_R
  +  localtime_r(&t, &tmLocaltime);
  +#else
  +  /* sqlite3OsEnterMutex(); not needed due to HAVE_LOCALTIME_R */
  +  tmLocaltime = *localtime(&t);
  +  /* sqlite3OsLeaveMutex(); not needed due to HAVE_LOCALTIME_R */
  +#endif
  +  y.Y = tmLocaltime.tm_year + 1900;
  +  y.M = tmLocaltime.tm_mon + 1;
  +  y.D = tmLocaltime.tm_mday;
  +  y.h = tmLocaltime.tm_hour;
  +  y.m = tmLocaltime.tm_min;
  +  y.s = tmLocaltime.tm_sec;
     y.validYMD = 1;
     y.validHMS = 1;
     y.validJD = 0;


2006-Aug-04 17:48:38 by anonymous:
The same type of autoconfig and src/date.c code changes have to be done for the not-threadsafe gmtime() function. The current implementation (even with the mutex) is not threadsafe in all cases.
 
1905 new active 2006 Aug anonymous VDBE 2006 Aug   5 4 Get bound param as sqlite3_value? edit
It doesn't seem to be possible to get the values, that have been bound to a prepared statement, after binding them.

What's the use you ask?

In complex scenarios the code might do complex binds (binding a NULL or an int/text depending on application logic is a simple example). A wrapper around sqlite3_step can use the requested new function to iterate over all parameters and dump them to the debug log on errors.

Looking at the vdbe stuff, this seems to be a straight forward function, that will just return a pointer to vdbe->aVar[i-1] after range checking.

 
1902 new active 2006 Jul anonymous Parser 2006 Jul   5 3 allow alternate INSERT syntax using SET foo=bar edit
Please support the alternate INSERT statement syntax in your parser that several other database products (and possibly the SQL standard) supports where you can say things like:

  INSERT INTO foo SET bar='hello', baz='world';

The main part of the statement, which maps field names to values, then is a lot easier for users to work with, either manually or in SQL generators, and can be reused between INSERT and UPDATE statements.

This should be simple to add, and I strongly suggest having it in before the next release (eg, as part of 3.3.7).

Thank you. -- Darren Duncan

 
1896 new active 2006 Jul drh   2006 Jul   1 1 All extensions to be statically linked edit
The new LoadableExtensions mechanism is great for loading new extensions out of external files. But we also need the ability to statically link extensions with an application and load them into database connections as needed.

One possible solution would be a new API that takes a fake filename and a function pointer. Any attempt to call sqlite3_load_extension() on that fake filename by any SQLite connection invokes the function pointer rather than actually opening a shared library with that filename.

2006-Jul-26 11:30:28 by anonymous:
In order to statically link extensions to the application, they'll all need to have unique entry function names. Besides meaning that extensions couldn't be statically linked without possible modification (I somehow suspect "sqlite3_extension_init" will be a popular name), it ensures that the extensions are uniquely identified in the application function namespace.

So I think it should just be necessary to have a function to register these function names and pointers, and sqlite3_load_extension() with a NULL zFile and appropriate zProc would have no trouble finding them in the "registry".

A trivial modification to the SQL load_extension() function to take just the function name would be a bonus.

c.


2006-Jul-26 11:39:59 by anonymous:
Something else which would be handy for statically linking extensions... It might be useful for a developer to directly call the extension entry function instead of formally registering it (i.e. they only want the extension available to a specific DB handle), in which case there should be a way to provide the sqlite3_api_routines structure to the entry function. Just making sure it's mentioned and formally documented in sqlite.h should be sufficient.
 
1817 new active 2006 May anonymous   2006 Jun   1 2 Patch to enable SQLite again on OS/2 edit
As we urgently need OS/2 support to be able to build Mozilla applications (Firefox, SeaMonkey, Thunderbird) we have to activate it again in SQLite CVS.

Daniel Lee Kruse ported the two C files with some input from Andy Willis and me (Peter Weilbacher). I hope this is the right way to go about this.

The OS/2 changes from this and from follow-up ticket #1836 were checked in some time ago, so I am marking this fixed.
 
1874 new active 2006 Jun anonymous CodeGen 2006 Jun   2 3 IN is much slower than making separate queries edit
I have a 500,000-row table with the following schema:

	CREATE TABLE foo(bar INTEGER NOT NULL, baz INTEGER NOT NULL, biz INTEGER NULL, buzz INTEGER NULL);
	CREATE INDEX biz ON foo (bar, baz, biz);
	CREATE INDEX buzz ON foo (bar, baz, buzz);

I'm performing the query:

   SELECT * FROM foo WHERE bar IN (0,1) AND baz IN (0,1) AND (biz IN (0,1) OR buzz IN (0,1));

On both Apple's 3.1.3 and a stock 3.3.6 on Mac OS X 10.4.6 PowerPC, this query consistently takes 3 seconds to execute. However, if I unroll the query:

	SELECT * FROM foo WHERE bar=0 AND baz=0 AND biz=0;
	SELECT * FROM foo WHERE bar=0 AND baz=0 AND buzz=0;
	...and so on for the other values of bar and baz...

it takes 0.2 seconds.

I was able to reproduce this with the attached scripts by doing:

	./mkdb > mkdb.sql
	sqlite3 testdb < mkdb.sql
	time sqlite3 testdb < q1 > /dev/null
	time sqlite3 testdb < q2 > /dev/null

The database was recreated between the 3.1.3 and the 3.3.6 testing.

EXPLAIN on the IN query segfaults on both 3.1.3 and 3.3.6, otherwise I'd attach that output. I'll write up a separate bug for that :)

2006-Jun-27 20:52:35 by anonymous:
[3315] fixed the EXPLAIN crash, so I've attached EXPLAIN output for the IN query.


2006-Jun-27 22:01:31 by drh:
On SuSE Linux 10.0 running on a Dell Latitude D600 laptop and using the latest code from CVS, I'm getting times of 1.2s and 0.45s. If I create an additional index:

    CREATE INDEX i2 ON foo(bar,baz,biz,buzz);

then the time for the first query drops to 0.7s. Note, however, the q1 and q2 are very different queries. In particular q2 omits half the rows. The (rough) equivalent of q2 is this:

    SELECT * FROM foo
     WHERE bar IN (0,1)
         AND baz IN (0,1)
        AND (biz=0 or buzz=0);

If I modify q2 so that it includes the biz=1 and buzz=1 cases, its query time increases to 0.7s, the same as q1 with the added index.

Further note that q1 and q2 are still not exactly the same. Q2 includes multiple copies of rows where biz IN (0,1) AND buzz IN (0,1) where q1 only includes such lines once. There are only 120 such lines in the database, but it still a difference.

I will recast this ticket as a request for performance enhancements on queries using the IN operator on a fixed list of values.


2006-Jun-28 01:52:32 by drh:
Note to self: The expression +x IN (1,2,3,...) appears to be faster than +x=1 OR +x=2 OR ... when there are 6 or more terms. With 5 terms or fewer, a string of ORs is faster.
 
1864 new active 2006 Jun anonymous   2006 Jun drh 3 3 List availabe SQL functions edit
Once LoadableExtensions are implemented it would be really nice to be able to get list of all available SQL functions and number[s] of arguments.
Mostly I'm thinking about a scenario where you'd load someone else's library from SQLite shell. Hopefully those will become common once infrastructure is in place.

I guess SQLite already keeps track of all available functions internally?

2006-Jun-21 19:48:07 by drh:
Perhaps this could be done using a virtual table.


2006-Jun-21 20:15:27 by anonymous:
Yes, this seems to be a really nice fit for virtual tables.

I lurked through the sources briefly, and it seems like all required info is already there, in struct sqlite3. Right?

 
1837 new active 2006 Jun anonymous Pager 2006 Jun   4 4 Deadlock detection would be best reported using explicit error code. edit
As discussed in email (*), an explicit deadlock error code might be beneficial for an application to detect and recover from deadlock. Deadlock is different to SQLITE_BUSY, and should be notified as such (IMHO).

(*) http://www.mail-archive.com/sqlite-users%40sqlite.org/msg15979.html

2006-Jun-12 11:23:49 by drh:
Changing the integer return code would be not be a backwards compatible change, so that approach must be rejected. But we will consider some mechanism to make it easier for programmers to figure out that they are dealing with deadlock and not a temporary delay.


2006-Jun-12 15:43:59 by anonymous:
Is there a fatal return code? If so, perhaps it could be overloaded with an additional function to determine if this 'fatal' error is actually a deadlock. Deadlocks are a common return code from almost every database I've ever programmed for. I am not sure how you can work around it otherwise.
 
1814 new active 2006 May anonymous   2006 May   3 4 Autoconf support for MacOSX univeral binaries edit
SQLite is used widely on OS X. One problem for many OS X developers is preparing SQLite for universal binaries. I think there are a couple ways to solve this.

1. Add a new configure option --enable-macosx-universal to put the right compiler switches

2. Rework the configure makefiles so that you can override with the typical CFLAGS overrides as suggested by Apple in this article: http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html

I've attached a patch that will enable universal binaries if you chose the --enable-macosx-universal option, are on -*-darwin os, and have disabled shared libraries. This patch may not be exactly how you would want to integrate but it should serve as a good starting point.

I've tested in a PPC powermac, PPC powerbook, and Intel Mac mini.


--- sqlite-3.3.5/configure.ac 2006-04-03 13:16:01.000000000 -0700
+++ sqlite-3.3.x/configure.ac 2006-05-18 16:42:08.000000000 -0700
@@ -661,6 +661,32 @@

AC_CHECK_FUNC(fdatasync, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_FDATASYNC=1"])

+##########
+# Mac OS X Universal Binary support
+#
+AC_MSG_CHECKING([whether building for macosx])
+case "${build}" in
+ *-*-darwin* )
+ AC_ARG_ENABLE(macosx-universal,
+ AC_HELP_STRING([--enable-macosx-universal],[Enable macosx universal binaries]),,enable_macosxuniversal=no)
+ AC_MSG_CHECKING([whether building Universal Binaries])
+ if test "$enable_macosxuniversal" = "no"; then
+ AC_MSG_RESULT([no])
+ else
+ AC_MSG_CHECKING([if shared libraries are disabled])
+ if test "$enable_shared" = "no"; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+ AC_MSG_RESULT([yes (Universal Binaries enabled)])
+ else
+ AC_MSG_RESULT([no (Universal Binaries disabled)])
+ fi
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT([no])
+esac
+
+
#########
# Put out accumulated miscellaneous LIBRARIES
#

 
1812 new active 2006 May anonymous   2006 May   4 1 alter table add column default current_timestamp edit
I wish I can alter my schema and add column with non-constant default. How difficult is this compared with constant default?
 
1810 new active 2006 May anonymous   2006 May   3 3 localtime() not threadsafe on UNIX edit
The following SQLite code from src/date.c is only guaranteed to function correctly with multiple threads on UNIX if the SQLite library is the only caller of localtime(). If an application that uses the SQLite library's date functions happens to call localtime() either directly or indirectly via another third party library, then localtime() can return a pointer to inconsistant data. localtime_r() should be use instead.

  sqlite3OsEnterMutex();
  pTm = localtime(&t);
  y.Y = pTm->tm_year + 1900;
  y.M = pTm->tm_mon + 1;
  y.D = pTm->tm_mday;
  y.h = pTm->tm_hour;
  y.m = pTm->tm_min;
  y.s = pTm->tm_sec;
  sqlite3OsLeaveMutex();

Windows and some versions of UNIX may use thread-local storage to make localtime() threadsafe. This is not the case with Linux or any other OS that uses GNU libc:

  /* Convert `time_t' to `struct tm' in local time zone.
     Copyright (C) 1991,92,93,95,96,97,98,2002 Free Software Foundation, Inc.
     This file is part of the GNU C Library.

     The GNU C Library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
     License as published by the Free Software Foundation; either
     version 2.1 of the License, or (at your option) any later version.

     The GNU C Library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Lesser General Public License for more details.

     You should have received a copy of the GNU Lesser General Public
     License along with the GNU C Library; if not, write to the Free
     Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     02111-1307 USA.  */

  #include <time.h>

  /* The C Standard says that localtime and gmtime return the same pointer.  */
  struct tm _tmbuf;

  /* Return the `struct tm' representation of *T in local time,
     using *TP to store the result.  */
  struct tm *
  __localtime_r (t, tp)
       const time_t *t;
       struct tm *tp;
  {
    return __tz_convert (t, 1, tp);
  }
  weak_alias (__localtime_r, localtime_r)

  /* Return the `struct tm' representation of *T in local time.  */
  struct tm *
  localtime (t)
       const time_t *t;
  {
    return __tz_convert (t, 1, &_tmbuf);
  }
  libc_hidden_def (localtime)

As an added benefit, you get better thread concurrency by getting rid of the sqlite3OsEnterMutex/sqlite3OsLeaveMutex when you use localtime_r.

2006-May-15 12:53:42 by drh:
All of this is pointed out already in the documentation. I will therefore change this ticket from a bug to an enhancement request.

Note that we have considered the use of localtime_r() in the past and rejected it since it will lead to a significant complication of the build process.

 
1801 new active 2006 May anonymous Pager 2006 May owensmk 5 4 Include Support for User-defined Lock Synchronization edit
SQLite uses a busy-wait model for locking. For high concurrency applications this can be become inefficient. I have written a patch for pager.c which introduces two hooks - lock() and unlock() - whereby the application can participate in locking/sychronization of connections. This can in some cases increase overall concurrency by an order of magnitude. The callback implementation is very similar to the busy handler.

All of the synchronization is implemented by the application. SQLite simply calls the hooks at the appropriate times, if they are registered. A full description of the patch is available at http://www.gintana.com/sqlite/.

 
1788 new active 2006 Apr anonymous   2006 Apr   5 5 memory allocator able to return with several allocated bloks at once edit
dlmalloc from Doug Lea (http://g.oswego.edu/dl/html/malloc.html) is public domain memory allocator written in C, replacing the malloc/free family. It is very fast (my microbenchmark had shown amortized allocation or deallocation time around 100 CPU cycles (Athlone XP), while default RTLs for VC++ or Borland were around 500x (really) slower, all three allocators were MT safe). dlmalloc is also used in Linux, I think, as a default allocator in libc.

dlmalloc has one more feature - it is able to allocate several blocks at once. This should be faster than chanin of malloc()s, has better cache locality and possible causes less of fragmentation.

Perhaps SQLite may employ such feature in some CPU bound place.

2006-Apr-29 21:50:53 by anonymous:
Developers are free to link with whatever malloc lib they want. The coding of SQLite itself does not require a change if you happen to use Lea's malloc or Hoard or whatever.


2006-May-01 23:56:15 by anonymous:
That's not my point (I do use dlmalloc). The library may take advantage of ability to allocate several independent memory block during single call to the allocator, expecting it to be faster, having better cache locality and less fragmentation than sequence of calls. Hypothetical effect depend on how much and where SQLite is allocator-bound.
 
1785 new active 2006 Apr anonymous Shell 2006 Apr   4 3 rl_readline_name not set edit
Hi,

I have a conditionnal construct into my .inputrc: $if sqlite "S ": "select " "L ": "like " "II ": "insert into " "U ": "update " "V ": "view " "(V ": "values (( " "C ": "create " "DR ": "drop " "DI ": "distinct " "F ": "from " "W ": "where " $endif

http://tiswww.tis.case.edu/~chet/readline/readline.html#SEC11

but it doesn't work with sqlite because rl_readline_name is not set in the source. I don't know about readline so i can't submit a patch.

regards

 
1781 new active 2006 Apr anonymous   2006 Apr   3 5 Interleaved sqlite_step behaves inconsistently edit
I am not sure if 'interleaved' is the correct term to use, but I will explain what I am doing. I have listed this ticket type as "code defect", maybe "documentation" or "incident" would have been just as good.

The issue here is that the sqlite3_step may fail or succeed depending on an 'irrelevant' ORDER BY clause - atleast irrelevant to my results.

I have a loop that performs a query using sqlite3_step(q), inside the loop the data from the resuling row is used to update a table using sqlite3_step(u). I know that I do not have to do it this way, I could cache the query results in an array thus avoiding the interleaving, but I am not doing that here for the purpose of illustrating this issue.

If what I am doing is illegal, it should not return success by just adding an ORDER BY clause, I think it should fail and be documented as such. When it succeeds, the results are 100% perfect everytime, so I know SQLite can do this.

If what I am doing is legal, why does it fail without the ORDER BY clause.

Contrived code that would reproduce the issue:

	sqlite3* db;
	sqlite3_stmt* stmtquery;
	sqlite3_stmt* stmtupdate;
	const char queryok[]  = "SELECT c1, c2 FROM t1 WHERE c2='row' ORDER BY c1;"; // ** ORDER BY c1
	const char query[]  = "SELECT c1, c2 FROM t1 WHERE c2='row';";
	const char update[] = "UPDATE t1 SET c2='foo' WHERE c1=1;";

	int ret = sqlite3_open( ":memory:", &db );
	ret = sqlite3_exec( db, "create table t1 (c1, c2);", NULL, NULL, NULL );
	ret = sqlite3_exec( db, "insert into t1 (c2) values ('row');", NULL, NULL, NULL );
	ret = sqlite3_exec( db, "insert into t1 (c2) values ('row');", NULL, NULL, NULL );

	// success using queryok (ORDER BY)
	ret = sqlite3_prepare( db, queryok, -1, &stmtquery, NULL );	// SQLITE_OK
	ret = sqlite3_step( stmtquery );							// SQLITE_ROW
	ret = sqlite3_prepare( db, update, -1, &stmtupdate, NULL );	// SQLITE_OK
	ret = sqlite3_step( stmtupdate );							// SQLITE_DONE
	ret = sqlite3_finalize( stmtquery );						// SQLITE_OK
	ret = sqlite3_finalize( stmtupdate );						// SQLITE_OK

	// same code fails using query (no ORDER BY)
	ret = sqlite3_prepare( db, query, -1, &stmtquery, NULL );	// SQLITE_OK
	ret = sqlite3_step( stmtquery );							// SQLITE_ROW
	ret = sqlite3_prepare( db, update, -1, &stmtupdate, NULL );	// SQLITE_OK
	ret = sqlite3_step( stmtupdate );							// ** SQLITE_ERROR
	ret = sqlite3_finalize( stmtquery );						// SQLITE_OK
	ret = sqlite3_finalize( stmtupdate );						// ** SQLITE_LOCKED

	// is this the only supported way?
	ret = sqlite3_prepare( db, query, -1, &stmtquery, NULL );	// SQLITE_OK
	ret = sqlite3_step( stmtquery );							// SQLITE_ROW
	ret = sqlite3_finalize( stmtquery );						// SQLITE_OK
	ret = sqlite3_prepare( db, update, -1, &stmtupdate, NULL );	// SQLITE_OK
	ret = sqlite3_step( stmtupdate );							// SQLITE_DONE
	ret = sqlite3_finalize( stmtquery );						// SQLITE_OK

	ret = sqlite3_close( db );
2006-Apr-24 14:52:51 by anonymous:
While the order by clause may be superfluous to you, it isn't to sqlite. To implement order by, sqlite must have an index on the column used for ordering, in which case it can scan the table in the expected order, or it must scan the table entire table copying records to a temporary table which it then sorts into the required order. In the first case the table is still being read while it is being scanned, so it is open when the first result is retuned. In the second case, the table is read during the table scan, then closed. Only the temporary table is open for reading when the first result is returned.

A query without an order by clause always scans the table in the same manner as the first case. I.e. the table is open for reading when the first result is returned.

Sqlite does not allow a table to be updated while it is open for reading, hence you will get an error in the first case, or with a query that does not have an order by clause.

The fact that it works with the order by clause in your case is a side effect of the fact that sqlite had to create a temporary table to sort the results. The main table is closed, and it is returning results from the temporary table when you try to do the update. This would break if you were to add an index on the column that you are ordering by.

 
1772 new active 2006 Apr anonymous TclLib 2006 Apr   5 5 db eval {QUERY} { do something } ELSE { there was no match } edit
When you add a script to execute the eval function always returns empty string. so something like

if {[db eval {SELECT * FROM TABLE WHERE time >= $timestamp} { puts "Found: $value1 $value2 $value3" }] == ""} { puts "Nothing found" }

will not work. Thinking about that i came to the conclusion that changing the eval command to support something to execute when no match was found would be quiet handy:

db eval {SELECT * FROM TABLE WHERE time >= $timestamp} { puts "Found: $value1 $value2 $value3" } { puts "Nothing Found." }

 
1770 new active 2006 Apr anonymous   2006 Apr   5 4 Request for expanded DELETE USING keyword like PostgreSQL edit
It would be nice is SQLite supported the new USING clause or allowed other tables to be referenced in delete statements.

That way this would short test case would work:

  create table foo(value text);
  create table bar(value text);
  insert into foo values('red');
  insert into foo values('blue');
  insert into bar values('red');

  delete from foo using bar where foo.value = bar.value;

  select * from foo

Would only return 1 row containing "blue" as its value.

For more information see the USING clause notes at:

http://www.postgresql.org/docs/8.1/interactive/sql-delete.html

Thanks.

2006-Apr-12 17:40:48 by drh:
Do it this way:

   DELETE FROM foo WHERE rowid IN
      (SELECT foo.rowid FROM foo JOIN bar USING(value))


2006-Apr-12 17:50:08 by anonymous:
Thanks drh! You rock.
 
1769 new active 2006 Apr anonymous Unknown 2006 Apr drh 5 5 Is there any djgpp port for 3-3-5 edit
yeah, us got 3.0.7 port.

while 3.3.5 is far far away from that.

me have tried port meself, dispointed.

did any lord get spare?

using 2.8.16 port

 
1747 new active 2006 Apr anonymous Unknown 2006 Apr   4 4 Non descriptive error message edit
When operating on closed db handle, sqlite3_exec returns SQLITE_MISUSE, which IMO is quite fair name. But when using:

  if( rc!=SQLITE_OK ){
    fprintf(stderr, "SQL error: (%d) %s\n",rc,  zErrMsg);
    sqlite3_close(db);
    exit (1);
  }

Message printed is as follows:

  SQL error: (21) library routine called out of sequence

This is a bit misleadig when starting debuging SQLite application.

 
1720 new active 2006 Mar anonymous   2006 Mar   3 4 Actions made by a trigger are not triggered edit
Hellow,

  CREATE TRIGGER trg_del_event BEFORE DELETE ON event FOR EACH ROW
  BEGIN
        SELECT RAISE(ROLLBACK, 'Cannot delete : event is referenced in table active_stuff')
        WHERE (SELECT id FROM active_stuff WHERE event_id = OLD.id) IS NOT NULL;

        DELETE from event WHERE parent_event_id = OLD.id;
  END;

This trigger verify if the current event is referenced in active_stuff table and if not, delete the row and the childs of the event.

The problem is that the delete made by this trigger is not triggered itself : There's no verification on event's child and no global rollback.

I don't know exactly if it's a feature or an incident. If it's a feature, you can simply close this ticket. Thanks :)

2006-Mar-19 17:38:15 by anonymous:
I believe it was mentioned on the mailing list that SQLite triggers are not recursive. However, I don't see any mention of this in the documentation: http://www.sqlite.org/lang_createtrigger.html


2006-Mar-19 17:49:57 by anonymous:
Yes, it's right, I've just found this in ML :

  Re: [sqlite] Are DELETE TRIGGERS recursive or not?

  drh
  Tue, 25 Oct 2005 06:38:42 -0700

  Ralf Junker <[EMAIL PROTECTED]> wrote:
  > I wonder if a DELETE TRIGGER should trigger itself recursively

  Not at this time.  Though work is underway to change this.
  We need recusive delete triggers in order to implement
  cascadinig deletes for referential integrity.
  --
  D. Richard Hipp <[EMAIL PROTECTED]>

So it's not a bug :)

It's :

- a documentation problem (missing "triggers are currently no recursive")

- a feature request

:)


2006-Mar-19 19:42:58 by anonymous:
Finally I've found the limitation here : http://www.sqlite.org/omitted.html
 
1718 new active 2006 Mar anonymous   2006 Mar   1 1 allow *.sqlite as parameter to sqlite3_analyzer edit
it would be nice if it was possible to to: sqlite3_analyzer.exe *.sqlite

currently you cant and you have to do: sqlite3_analyzer.exe 1.sqlite sqlite3_analyzer.exe 2.sqlite etc..

 
1689 new active 2006 Feb anonymous   2006 Mar   2 4 triggers and temporary tables edit
CREATE TRIGGER trg_upd_dict AFTER UPDATE ON dict
BEGIN
UPDATE dict SET code = (SELECT code from tmp_connected_user) WHERE old.dict_id = dict_id ;
END ;
This trigger doesn't work if tmp_connected_user is a temporary table. The message is : SQL error: no such table: main.tmp_connected_user
The goal is to have persistant triggers who works with temporary tables.

Exemple of use :

- Workarround who replace the non existing connection by user / password. When we insert/update, the database doesn't know who insert/update. If we have a table user, we can on each table fill by trigger fields like last_user_id, last_modif_d. The trigger cannot know who make the connection but we stock the user_id when he connects to the db in a temporary table, the trigger will work.

- Security (no one can update / insert the database if a special temporary table is not created and filled).


2006-Mar-03 20:25:41 by drh:
You can create a TEMP trigger that will reference tables in the main database and/or attached databases. But SQLite currently does not allow triggers in the main or attached database to reference tables in other databases.

I will enter this as an enhancement request.


2006-Mar-06 16:17:11 by anonymous:
Workarround for this ticket : if we only need 1 result, we can use user defined function instead temporary table in the trigger. Tested with php : it works :)
 
1655 new active 2006 Feb anonymous VDBE 2006 Mar   4 4 Every function can have their private data like agreagates edit
Is it possible to modify the way functions are handled in sqlite ? My idea is to allow functions to have their own private data space to save data from row to row like the agregates have, with that we can have functions that remember last row values, create counters and totalizers that return their updated values for each row.

Ex:

select increment(1),* from my_table;
1|car|rose|3
2|sea|bike|7
3|flower|water|33
select sum_and_return_row_by_row(row_value_to_sum),* from my_table;
3|car|rose|3
10|sea|bike|7
43|flower|water|33

select current_row_value + last_row_value(current_row_value),* from my_table;
3|car|rose|3
10|sea|bike|7
40|flower|water|33
The structure for that is already there, in fact is the same used by agregates, I was scratching the code but I could not find easily where to introduce code to push the context and pop it for functions that aren't agregates, someone know how to do that ?
2006-Feb-04 20:45:32 by anonymous:
/*
** Implementation of the increment() function
*/

static void incrementFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  assert( argc==1 );
  switch( sqlite3_value_type(argv[0]) ){
    case SQLITE_INTEGER: {
      i64 iVal = sqlite3_value_int64(argv[0]);
      i64 *pi = (i64*)&context->s.zShort;
      *pi = *pi + iVal;
      sqlite3_result_int64(context, *pi);
      break;
    }
  }
}

I've tried that but context are not saved row to row, of course here I was using a hidden member (s.zShort) of the context structure that seems not to be used or damaged, ideally should have a function like

"void sqlite3_set_presistent_data(sqlite3_context *context, void value, int size_to_be_allocated)"

or something like it that will allocate memory and return the actual value stored before if any.

 
1693 new active 2006 Feb anonymous Parser 2006 Mar   4 4 Parser sensitive to position of word AUTOINCREMENT edit
Command:

create table unique_ids ( 'id' INTEGER AUTOINCREMENT PRIMARY KEY)

fails, while the

create table unique_ids ( 'id' INTEGER PRIMARY KEY AUTOINCREMENT)

suceeds. The only difference is position of the word AUTOINCREMENT. I originally expected the AUTOINCREMENT to be standalone feature, not tied with PRIMARY KEY. Perhaps the parser may be more forgiving here.

 
1704 new active 2006 Mar anonymous   2006 Mar   4 3 extern "C" block in sqliteInt.h edit
can we put

#ifdef __cplusplus extern "C" { #endif ... #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif

around the declarations in sqliteInt.h. It would help as we need to access SQLite internals from our C++ code.

 
1703 new active 2006 Mar anonymous Pager 2006 Mar   2 3 Second parameter to gettimeofday() in os_unix.c should be NULL edit
in os_unix.c, function sqlite3UnixCurrentTime(): the second argument to gettimeofday() should be NULL and the declaration of sTz should be removed. struct timezone seems to cause trouble on Linux systems.
 
1702 new active 2006 Mar anonymous   2006 Mar   5 4 feature request: API to write in-memory DB to file. edit
Hello!

A feature suggestion regarding in-mem databases:

It would be interesting to be able to save this to files as normal sqlite3 dbs. i'm assuming that this is internally a rather simple operation, but i didn't find a function for doing it.

Take care,

----- stephan

2006-Jun-28 05:04:05 by anonymous:
There have been already good solutions. Watch this wiki page.

http://www.sqlite.org/cvstrac/wiki?p=InMemoryDatabase

 
1683 new active 2006 Feb anonymous Unknown 2006 Feb anonymous 4 3 .mode html produces uppercase tags edit
Quote from one of sqlite docs: "The last output mode is "html". In this mode, sqlite writes the results of the query as an XHTML table. The beginning <TABLE> and the ending </TABLE> are not written, but all of the intervening <TR>s, <TH>s, and <TD>s are. The html output mode is envisioned as being useful for CGI."

I tried the ".mode html" and the result is just like the doc said. But there is one oddity. AFAIK, XHTML discourages using uppercase tags. Inspite of that, sqlite produces uppercase tags. Why??

Now, this is a suggestion from a newbie point of view just for the sake of sqlite's consistency: Use lowercase tags for ".mode hmtl" result.

I know browsers produce the same result for <TR>...</TR> as well as for <tr>...</tr>. We all know xhtml 1.0 is just a more strict version of html 4.0 and xhtml is based on xml whilst html 4.o is based on sgml. Not make much any difference to me and the browsers. But following the xhtml standard and rules -that sqlite WANTS- doesn't hurt right?

I hope you can consider more seriously this lite suggestion :)

Keep up the great work!

ps:sorry for my broken english

2006-Feb-21 14:24:54 by anonymous:
Capitals tags aren't xhtml.
Why not offering an export may be also import mode in true xml ? With xsd schema file creation as useful for direct import into spread sheet and other popular programs.
Keep on going with this beautiful program.
 
1679 new active 2006 Feb anonymous   2006 Feb   4 4 SQLite requires code modification to replace memory allocation funcs edit
sqliteOsMalloc is a C macro that points to a 'generic' malloc routine by default. The same for realloc and free. This forces a SQLite user to modify the code of each realease to support their own memory functions. Allow it means that the user can no longer use a system wide SQLite library and have to ship their own.

If those memory functions where function pointers then the calling program could set them without modifying the source code. These function pointers could be global variables or set by a sqlite_memory_funcs() API function.

 
1675 new active 2006 Feb anonymous   2006 Feb   5 4 sqlite3_db_dup() ? edit
I don't need this myself, as I don't write multithreaded code now, but it seems a useful addition for all those people doing mutlithreaded code:

Duplicate a db connection for use in another thread.

The new db connection should NOT be connected to any shared caches for the current thread, so that the new connection can be moved to any thread. The idea might be a server, which starts some worker thread and wants to give that new thread a connection to the db.

 
1663 new active 2006 Feb anonymous Unknown 2006 Feb   4 4 Suggestion: DATETYPE field type using David Tribble's work? edit
How about a new field (/data) type, DATETIME, using David Tribble's excellent proposal? See here:

http://david.tribble.com/text/c0xlongtime.html

2006-Feb-09 02:58:34 by drh:
What advantage does David Tribble's datetype design have over the existing date and time support in SQLite? Why should we change?
 
1653 new active 2006 Feb anonymous CodeGen 2006 Feb   4 5 SQLITE_OMIT_COST_REORDERING ? edit
Embedded SQLite installations could benefit from conditionally compiling out the logic of the cost-based reordering of tables (i.e., always assume cross join). It might save a few kilobytes of code when the join order is always known in advance.
 
867 new active 2004 Aug anonymous Parser 2006 Jan   3 2 update on multiple tables edit
I would like to have update working on multi tables; It is not written as possible thus it is a request for enhancement.

basic example: create table a ( id integer primary key, val integer ); create table b ( id integer primary key, val integer );

insert into a (val) values (314); insert into a (val) values (315);

insert into b (val) values (314); insert into b (val) values (314);

update a, b set b.val = a.val;

2006-Jan-24 19:01:31 by anonymous:
I would prefer another syntax - using a SELECT as the source for data to be updated.

  UPDATE <DESTINATION_TABLE> SET <DESTINATION_FIELD>=<SOURCE_FIELD>...
  WHERE <DESTINATION_OTHERFIELD> = <XPTOVALUE>...
  SELECT <SOURCE_FIELD>
  FROM <SOURCE_TABLE>
  WHERE <SOURCE_OTHERFIELD>=<DESTINATION_OTHERFIELD>...

This is the update syntax used in PostgreSQL and other databases.

I also believe this is easier to understand and easier to implement (since the select is just the source for data)


2006-Jan-24 19:21:15 by anonymous:
Already supported via correlated subquery:

  update b set val = (select a.val from a where a.id = b.id);

See: http://www.sqlite.org/lang_update.html

 
1626 new active 2006 Jan anonymous Unknown 2006 Jan   4 4 ALTER TABLE BUG/MISHEAVIOR edit
I have observed a "bug" in sqlite (3.2.8). when a table is created, and then renamed via the ALTER TABLE statement, the create statement gets adjusted (which is correct), but the new name appears in single quotes. according to sql syntax, table and field names are quoted by double quotes, so this creates subsequent problems for parsing tools and such.

to test:

  create table x(id)
  select * from sqlite_master (observe the create statememt)
  alter table x rename to x1
  select * from sqlite_master (observe the create statememt again, the name is now 'x1' in quotes)

IMHO, the name should not be quoted by default, but only if it contains spaces, special characters and such (in other words, follow the quoting rules for tables that sqlite already has)

2006-Jan-23 00:24:34 by drh:
The result that SQLite produces is technically correct, even if it fails to meet the aesthetic expectations of this tickets author. Changes SQLite as suggest will make the code base larger, which is something we are loath to do. So I am converting this to a low-priority feature request.


2006-Feb-07 07:36:19 by anonymous:
ok, lets not do "intelligent" quoting. what about the quote format ? should it not be DOUBLE quotes, instead of single ?
 
1588 new active 2006 Jan anonymous   2006 Jan   4 4 common subexpression elimination not performed in SELECT edit
SQLite could perform common subexpression elimination to significantly speed up certain SELECT statements.

Consider the following:

  CREATE TABLE t6(a);

  INSERT INTO "t6" VALUES(1);
  INSERT INTO "t6" VALUES(2);
  -- ...imagine 5000 more rows inserted...
  INSERT INTO "t6" VALUES(4999);
  INSERT INTO "t6" VALUES(5000);

  CREATE VIEW v6 as
   SELECT x.a as xa, y.a as yb, (123.45*x.a*y.a-x.a*x.a) AS expr
   FROM t6 x, t6 y;

With the following SELECT statement:

  explain select expr s1, (expr/789.3) s2 from v6 order by s1;

You can see that SQLite repeats the calculation of 'expr' three times below. If the common subexpression 'expr' was calculated just once per inner-loop iteration this query would be significantly faster.

  0|OpenVirtual|3|3|keyinfo(1,BINARY)
  1|Goto|0|58|
  2|Integer|0|0|
  3|OpenRead|1|2|
  4|SetNumColumns|1|1|
  5|Integer|0|0|
  6|OpenRead|2|2|
  7|SetNumColumns|2|1|
  8|Rewind|1|46|
  9|Rewind|2|45|

  -- first expr
  10|Real|0|0|123.45
  11|Column|1|0|
  12|Multiply|0|0|
  13|Column|2|0|
  14|Multiply|0|0|
  15|Column|1|0|
  16|Column|1|0|
  17|Multiply|0|0|
  18|Subtract|0|0|

  -- second expr
  19|Real|0|0|123.45
  20|Column|1|0|
  21|Multiply|0|0|
  22|Column|2|0|
  23|Multiply|0|0|
  24|Column|1|0|
  25|Column|1|0|
  26|Multiply|0|0|
  27|Subtract|0|0|

  28|Real|0|0|789.3
  29|Divide|0|0|
  30|MakeRecord|2|0|

  -- third expr
  31|Real|0|0|123.45
  32|Column|1|0|
  33|Multiply|0|0|
  34|Column|2|0|
  35|Multiply|0|0|
  36|Column|1|0|
  37|Column|1|0|
  38|Multiply|0|0|
  39|Subtract|0|0|

  40|Sequence|3|0|
  41|Pull|2|0|
  42|MakeRecord|3|0|
  43|IdxInsert|3|0|
  44|Next|2|10|
  45|Next|1|9|
  46|Close|1|0|
  47|Close|2|0|
  48|Sort|3|57|
  49|Column|3|2|
  50|Integer|2|0|
  51|Pull|1|0|
  52|Column|-1|0|
  53|Column|-2|1|
  54|Callback|2|0|
  55|Pop|2|0|
  56|Next|3|49|
  57|Halt|0|0|
  58|Transaction|0|0|
  59|VerifyCookie|0|2|
  60|Goto|0|2|
  61|Noop|0|0|

The common sub-expression elimination may have to take into account user-defined functions that do not return the same value when given the same inputs (such as random()). Some databases fold such values into a single expression, while others evaluate each such function in a seperate expression.

2006-Jan-08 18:55:03 by drh:
Common Subexpression Eliminationi (CSE) is a planned enhancement to occur after the VDBE is converted from a 3-operand stack machine to a 4-operand register machine. Perhaps this year sometime.


2006-Jan-08 19:56:47 by anonymous:
I think it would be desirable to have a seperate expression optimization pass before (and without knowledge of) the VDBE code generation phase to simplify and optimize the SQL abstract syntax tree. Such high level AST transformation appears to already happen in select.c in such routines as flattenSubquery(), but it would be great if all non-VDBE-specific expression tree manipulation code could be factored out into seperate .c files so that it would be completely independent of the code generation. This could allow you support a variety of backends.
 
974 new active 2004 Oct anonymous   2005 Dec   5 4 Version-Resource in pre-compiled windows dll edit
It would be nice if the precompiled windows-dll would include a version-resource so that an installer or any user (via file-properties) can determine the version of the sqlite3.dll
2004-Oct-26 17:27:51 by anonymous:
The attached 'sqlite.rc' works under mingw32. Add the following lines to your makefile to add the version:

   sqliterc.res: sqlite.rc
   	windres sqlite.rc sqliterc.res

   sqliterc.o: sqliterc.res
   	windres sqliterc.res sqliterc.o

   sqlite3.dll: sqliterc.o etc...
 
1566 new active 2005 Dec ghaering VDBE 2005 Dec   5 4 Implement sqlite3_clone() edit
It would be nice to have an API function

int sqlite3_clone(sqlite3_stmt *src, sqlite3_stmt **dest)

which efficiently creates a new clone of the src statement. This is useful when you need to run the same query with different parameters on the same database simultaneously, like when walking through a tree-like table:

create table node (
  id integer primary key not null,
  parent integer,
  data
);
All in all, this is not needed very often, but I reckon implementing the API function would be relatively trivial.
2005-Dec-19 16:04:54 by anonymous:
If you want to re-execute the same query with different parameters, you should just use sqlite3_reset() instead of sqlite3_finalize(). This will reset the query so that it is ready to be executed again. Then issue the sqlite3_bind_...() calls to bind new values to the parameters that you need to change.


2005-Dec-19 16:06:47 by anonymous:
Oops, sorry I missed the "simultaneously" in your post the first time I read it.
 
1558 new active 2005 Dec anonymous VDBE 2005 Dec   3 4 Request more debugging info when SQL statements in progress edit
I am sporadically receiving the error message "Can't commit transaction - SQL statements in progress." I believe my own code is at fault, not anything in SQLite, but I would appreciate help in diagnosing the problem in my code.

SQLite obviously knows that I've lost track of one or more prepared statements that haven't run to completion, it isn't telling me what statements those are. I'm wondering if there is any way of getting that information. Armed with that knowledge, I can probably fix my code fairly quickly.

Note: DRH did provide a workaround that involved recompiling with extra debugging information, which will probably help me in the short run. This feature request is aimed at making that debugging process easier for future developers. :-)

 
1552 new active 2005 Dec anonymous Unknown 2005 Dec   5 4 Adding .read FILE support to the C API edit
Hello!

i've attempted to implement an SQL function which behaves like the sqlite3 shell's .read FILE feature. The problem is that functions don't have a handle to their DB, and therefor cannot call an sqlite3_exec() to actually evaluate the read-in code. The ability to do this from client code would be "really cool." :)

On a related note: i'm using C++, and found that the following won't compile:

std::string fname( sqlite3_value_text( argv[i] ) );

because sqlite3_value_text() explicitely returns an unsigned pointer. The STL uses plain old (const char *), so the following workaround is needed:

std::string fname( static_cast<char const *>( sqlite3... ) );

 
1550 new active 2005 Dec anonymous Unknown 2005 Dec   3 3 Triggers across attached databases edit
Support for triggers across attached databases would be very nice.

Example: sqlite3 db1 > CREATE TABLE Test (pk integer primary key autoincrement, Data vachar(128)not null);

> ATTACH db2 AS history;

> CREATE TABLE history.TestHistory (ObjectTable_fk integer not null, Action integer not null, Timestamp smalldatetime not null);

> CREATE TRIGGER trTestHistoryUpdate UPDATE ON Test FOR EACH ROW BEGIN INSERT INTO TestHistory VALUES(OLD.pk, 0, CURRENT_TIMESTAMP); END;

<Insert some posts into Test...>

> Update Test SET Data='FooBar' WHERE pk=1; This results in the error: "SQL error: no such table: main.TestHistory"

Changing the trigger to INSERT INTO history.TestHistory VALUES(OLD.pk,0,CURRENT_TIMESTAMP); results in "SQL error: near ".": syntax error".

Attaching the databases in the reverse order and then create the trigger results in "SQL error: trigger trTestHistoryUpdate cannot reference objects in database db1";

 
1532 new active 2005 Nov anonymous TclLib 2005 Nov   4 4 Variables don't get replaced in ATTACH statements. edit
When using mydb eval {ATTACH $var as var} in tcl scripts, $var is not replaced by its corresponding value.

  proc updatedb { filename } {
     sqlite3 mem :memory:
     ...
     mem eval {ATTACH $filename as file}
     mem eval {REPLACE INTO file.table SELECT * FROM table}
     mem close
  }

Will result in the errormessage: "No such table file.table" (additionally a file called $filename will be created in the current dir). But if you quote the ATTACH statement and let TCL handle the replacement it will work just fine.

This behavior is exactly as defined in the documentation. Variable substitution is only allowed in places where it is valid to put an expression. There are important technical reasons for this restriction.

Works as designed.


On second thought, I suppose it would be possible to extend the parser so that it allowed a (string value) expression at the point in the ATTACH command where a filename is needed. I will change this into an enhancment request.
 
1528 new active 2005 Nov anonymous Unknown 2005 Nov   5 4 Add Build Date To Command Line Greeting edit
When SQLite v3.x is started on the command line, show the build date and time. For example:

  [rlc@bobcp4 bld]$ sqlite3
  SQLite version 3.2.7 built 11/18/2005 06:44
  Enter ".help" for instructions
  sqlite>
2005-Nov-24 17:17:16 by anonymous:
    The date format 11/18/2005 06:44 is USA centric, which, in my opinion, is not good for a globally used product.

    Please use the human readable notation according to ISO 8601 , that is ccyy-mm-dd, or the current locale.

See also: open_directory_project

 
1506 new active 2005 Nov anonymous Shell 2005 Nov   1 4 Add some flags to .import command edit
I think it would be very useful to be able to instruct .import to use either "INSERT INTO" or "INSERT OR REPLACE INTO" via some flag.
Something along the lines of:

  .import FILE TABLE REPLACE

One other extension of .import that I'd find useful is to be able to instruct .import not to error out when malformed line of input is found, but instead just print the error message as it does now and continue on with next line.
Why is this useful? Sometimes I need to import large files with several million lines into SQLite for some statistical analysis and some of those lines are malformed sometimes. As it is now, sqlite3.exe will error out at that line and then I have to fix or remove that line from input file and restart the import. If there are other malformed lines I need to restart import again. Needless to say this is very time consuming and losing a few lines out of few millions wouldn't change my results (statistics) a bit.

Perhaps both above mentioned flags could be combined into one with 4 possible values.

2005-Nov-02 14:43:52 by anonymous:
I've attached a patch that does what I proposed in this ticket. It uses MODE argument to set two proposed flags. Other flags can be added easily, but it's kind of cumbersome to document all posible values of MODE argument.
 
1491 new active 2005 Oct anonymous Shell 2005 Oct   4 4 syntax error with " .mode column: edit
when I key in ".mode column" without any space, the command is work well. If I key in "^.mode column" with a space(the ^ means a space) , it will show the following error message :
SQL error: near "syntax": syntax error
Would you like fix it on next version, please ?

Have a nice day!

John Wei

 
1476 new active 2005 Oct anonymous   2005 Oct   5 4 Patch for SQLite sequence manipulation functions edit
This patch (against SQLite 3.2.7) implements a pair of sequence manipulation functions (nextval, curval) that provide similar functionality to the sequences found in RDBMS systems like postgresql, oracle, DB2, etc. These functions allow applications to pre-fetch a unique integer identifier for later use, or to use incremental sequences on non-primary key columns. This functionality can also alleviate the need to use sqlite3_last_insert_rowid() while building complex relationships between rows across related tables during inserts and updates. These functions should also work well in cases where primary key uniqueness is desirable across multiple tables.

ZETETIC LLC developed this code for use in an internal project, but is willing to provide the source code and test scripts to the SQLite project (under SQLite's public domain license) if you would like to incorporate them into SQLite.

[ Usage ]

  • nextval - A call to this function returns the next value for a sequence
  • curval - a call to this function returns the current value of a sequence

The actual sequence functions can be called in one of one of four ways:

  1. nextval/curval('name')
  2. nextval/curval('name, 'db')
  3. nextval/curval('name', classic)
  4. nextval/curval('name, 'db', classic)

Where the parameters are defined as follows:

  • 'name' - is the name of the sequence to match against the first column of the sequence table

  • 'db' - is the name of the optional attached database to use

  • classic - is an integer flag specifying whether to operate in classic sequence mode.

By default these sequence calls use a new sequence table format, defined as sqlite3_sequence. This table defines additional columns (name, seq, incr, min, max, cycle) providing some advanced sequence functionality, including:

  1. variable increment - the sequence increment value is 1 by default, but can be any integer (positive or negative). This allows sequences to move up or down by any increment.
  2. enforced minimum constraint - the sequence table allows a definition of a minimum value. If min is not NULL and a call to nextval() would cause the sequence counter to drop below min, the call will result in an error. If min is NULL, no constraint is enforced.
  3. enforced maximum constraint - the sequence table allows allows a maximum value. If max is not NULL and a call to nextval() would cause the sequence counter to increase above max, the call will result in an error. If max is NULL, no constraint is enforced.
  4. cycling - if a call to nextval would cause a min/max constraint to be violated, the function will cause the sequence to "cycle" and begin again from the min or max value. For example, assume the current sequence number=9, max=10, min=-10, and the sequence increment=2. The next call to nextval would exceed the max constraint, after incrementing by 1, so the cycle would increment min with the difference of 1, resulting in a nextval of -10. If increment=3, nextval would equal -9 and so on.

The sqlite3_sequence table has the following definition. Your application may optionally create this table in preparation for the first call to nextval, but if the table does not exist while operating in advanced mode it will be created automatically:
CREATE TABLE {db}.sqlite3_sequence(name TEXT, seq INTEGER, incr INTEGER, min INTEGER, max INTEGER, cycle INTEGER);

If the 'classic' argument is provided and not equal to zero, then these functions will operate on the standard sqlite_sequence table. In classic mode the sequence will always increment by one, and constraints/cycling are not supported. The sqlite_sequence table will NOT be created when operating in classic mode. Thus, the sqlite_sequence table must have been created through the use of an AUTOINCREMENT field on an existing table or the function call will return with an error.

Note that these functions can be used with the following caveats:

  1. Despite the fact that you can simply call nextval() from a select statement "SELECT nextval('sequence_name');", it does modify the database. Therefore, if another process has the database in an active transaction or otherwise locked you cannot obtain new sequence numbers.
  2. You can't use the function as a default value when you create tables.

There are 2 ways to create sequences that these functions will operate on:

  1. Allow nextval() to create the sequence. The first time nextval is called for a sequence name a row will be created and initialized with default values.
  2. Via INSERT. If your sequence needs specific non-default configurations, you simply insert a row into the sqlite3_sequence or sqlite_sequence table before your first call to nextval. For example the following sql command would create a cycling sequence starting at zero, with increments of -1 a minimum value of -100 and a maximium value of 100:
    INSERT INTO sqlite3_sequence(name, seq, incr, min, max, cycle) VALUES ('sequence_1', 0, -1, -100, 100, 1);
    Either of the following statements will create a non-cycling sequence with an initial value of zero a positive increment of 1, with no min and max values:
    INSERT INTO sqlite3_sequence(name, seq, incr, min, max, cycle) VALUES ('sequence_2', 0, 1, NULL, NULL, NULL);
    INSERT INTO sqlite3_sequence(name, seq, incr) VALUES ('sequence_2', 0, 1);

It is possible to change the values of any column of sqlite3_sequence except 'name' to change the behavior, even after the first call to nextval. For example, this statement would update the previous sequence defintion to include a maximum value of 200:
UPDATE sqlite3_sequence SET max=200 WHERE name='sequence_2';

[ Implementation ]
This patch introduces three new files:

  • src/sequence.h - header file for sequence functions
  • src/sequence.c - implementation of sequence functions
  • test/sequence.test - 50+ step regression test for sequence functions

This patch also modifies the following files:

  • Makefile.in - adjusted to include the compilation of sequence.c
  • src/func.c - adjusted to include sequence.h and call sqlite3_create_function to load the functions at initialization time
  • src/test1.c - adjusted to setup sqlite_options for use in the ifcapable section of the regression test

In order for the nextval function to work properly, the update of the sequence and the read happen at the same time, while the database is in a locked state. The nextval function uses using the Vdbe API directly. The Vdbe script implements a certain amount of logic to support increments of arbitrary values, min/max constraint enforcement, and cycling. The Vdbe code is almost identical between the between advanced and classic sequence modes. This the basic logic that it uses:

  1. Create a new Vdbe for the database based on the context.
  2. Try to obtain an exclusive lock (OP_Transaction, P2=3).
  3. Open the sequence table for writes (OP_OpenWrite)
  4. Search the table and obtain the current value from the sequence table associate with that name. If one isn't found, start a new sequence off at 0.
  5. Calculate the new sequence the value, taking into account defined increment, min/max enforcement, and cycling logic
  6. Write the new value into the table
  7. Callback the new value

[ Possible Future Extensions ]

  • impliment pre-fetch / sequence caching at the database handle level. This would allow a call to nextval() fetch multiple unique identifiers and cache them to avoid the need to repeatedly lock the database.
  • Support for CREATE SEQUENCE statement, instead of requiring an insert to the sqlite3_sequence table or creation of an autoincrement field
  • Support for alternate sequence call support like "xx_seq.nextval" or "NEXT VALUE FOR xxx_seq". This would make it easier to deal with sequences on attached database (the current scheme is usable but not elegant), and would be more similar to semantics used by other RDBMSs.
  • any other recommended changes from the SQLite development team / users


Stephen J Lombardo ZETETIC LLC stephen dot lombardo at zetetic dot net
2005-Oct-11 15:06:01 by anonymous:
The C functions nextval() and curval() in sequence.c should be static, so as not to pollute the global name space with such generic names, in which case they should probably live within func.c.

Else, they should have sqlite3 prepended to put them in the sqlite3 namespace.


2005-Oct-12 01:50:09 by anonymous:
The new attached patch renames prepends the C functions with sqlite3_ (sqlite3_curval() and sqlite3_nextval()). I agree that it might be a better idea to define them as static functions in func.c if the functions are accepted into SQLite. For now, it's easier to leave them defined in separate files so they can be compiled into a program as user defined functions outside of SQLite.
Stephen
 
1475 new active 2005 Oct anonymous Parser 2005 Oct anonymous 5 5 sytax error near autoincrement edit
Consider following sql syntax.

create table t1 (id integer primary key autoincrement); // no error

create table t2 (id integer autoincrement primary key); // error

create table t3 (id integer autoincrement, primary key(id)); // error

2005-Oct-07 03:15:23 by anonymous:
Your last two examples don't follow the syntax shown in the documentation. AUTOINCREMENT is a modifier for a PRIMARY KEY constraint and can only come after one.
 
1468 new active 2005 Oct anonymous Parser 2005 Oct   5 5 Added Mysql function CONCAT edit
static void concatFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
	unsigned char *z;
	int i;
	int len = 0;
	for(i=0;i<argc;i++)
		len+= sqlite3_value_bytes(argv[i]);
	z = sqliteMalloc(len+1);
	if( z==0 ) return;
	for(i=0;i<argc;i++)
		strcat(z, sqlite3_value_text(argv[i]));
	sqlite3_result_text(context, z, len , SQLITE_TRANSIENT);
	sqliteFree(z);
}

{ "concat",            -1, 0, SQLITE_UTF8,    0, concatFunc },
2005-Oct-05 14:27:29 by drh:
Seems kind of pointless since SQLite already supports the SQL-standard || operator.


2005-Oct-09 13:24:49 by anonymous:
sorry :-)
 
1464 new active 2005 Oct anonymous   2005 Oct   4 3 Improving PRAGMA table_info() edit
I have a small feature request regarding PRAGMA table_info() to add a new column named "auto_inc" which contains 1 if the corresponding field has the AUTO INCREMENT in its definition and 0 otherwise.
2005-Oct-04 15:37:31 by anonymous:
Once suggestions for extending the PRAGMA table_info() are on the agenda, I would like to suggest that the COLLATION sequence used for an INDEX would be made available as well.
 
229 new active 2003 Jan anonymous Parser 2005 Sep   5 4 DECLARE ... CURSOR FOR ... would be really nice edit
Cursors can be a tremendous performance aid in GUI-driven applications with large data sets, and it's pretty hard to emulate them if your application is written with the concept in mind.

I would really be thrilled if cursors found their way into SQLite!

Thanks,

b.g.

OK, this is now Jan 2005 and "cursors" are not there yet. Any plans? what would be an easy work around.


2005-Sep-14 06:31:57 by anonymous:
Yes Cursor would be a added advantage so that we dont have to move to and for from application to sqlite for smiple calculation


2005-Sep-14 20:03:40 by anonymous:
SQLite3's cursors are called sqlite3_prepare(), sqlite3_step(), sqlite3_reset() and sqlite3_finalize()

Seriously, the purpose of a cursor is to leave the data on the database server and retrieve only the data and columns you need from a resultset managed by the server. SQLite is an embedded file-based database engine, not a database server -- therefore cursors make no sense.

Asking for cursors in sqlite is akin to asking the filesystem to give you a cursor on a textfile so you can only read one line at a time -- when the reality is, you just open the file and read the lines yourself. sqlite3_step() is your cursor, it is reading the row from the file, one row at a time.

 
1424 new active 2005 Sep anonymous Unknown 2005 Sep drh 5 3 Pivot table creation edit
The beautiful SQLite engine lacks of pivot table creation. How to create cross tables? I tried the cross join but without success.
Example: create table tab ( name, department, hours ); Populated with hours that many people spent in some departments
How to produce an answer table (with row and column totals), where the sum of hours (or another aggregate function) is shown in each cell of row=name and column=department. The SQL statement is expected to look similar like following
TRANSFORM sum(hours) as Duration
SELECT name FROM tab GROUP BY name
PIVOT department

In simple words the aggregation of two select statements on some common fields with the other fields in row respective column direction.
I would like to use aggregate functions sum, count, avg, stdev, min, max as already mentioned in ticket #1381. Introduction of sqrt and macros would be fine to create work arounds for stdev and others.
2005-Sep-14 03:02:24 by anonymous:
This is a feature request and should be brought up on the mailing list. If you haven't already done so, read Unsupported SQL where there have been a few requests for OLAP-oriented features.
 
1423 new active 2005 Sep anonymous   2005 Sep drh 3 4 Binding NULL does not work as expected edit
There's currently no way to compare to NULL with binding parameters. My suggestion is that you make "= ?" with the NULL bound parameter work like "IS NULL" and "<> ?" like "IS NOT NULL".

Currently, neither this nor the normal way to bind to "IS ?" works. "IS ?" returns a syntax error even.

Testcase follows.

#include <assert.h>
#include <stdio.h>

#include "sqlite3.h"

int main()
{
    sqlite3* db;
    sqlite3_stmt* st;
    const char* tail;
    int rc;

    sqlite3_open(":memory:", &db);

    /* create table */
    sqlite3_prepare(db, "create table test(foo)", 0, &st, &tail);
    rc = sqlite3_step(st);
    assert(rc == SQLITE_DONE);
    rc = sqlite3_finalize(st);
    assert(rc == SQLITE_OK);

    /* insert row */
    sqlite3_prepare(db, "insert into test(foo) values (null)", 0, &st, &tail);
    rc = sqlite3_step(st);
    assert(rc == SQLITE_DONE);
    rc = sqlite3_finalize(st);
    assert(rc == SQLITE_OK);
     
    /* query 1 */
    rc = sqlite3_prepare(db, "select count(*) from test where foo is ?", 0, &st, &tail);
    if (rc != SQLITE_OK) {
        printf("query 1: %s\n", sqlite3_errmsg(db));
    }

    /* query 2 */
    sqlite3_prepare(db, "select count(*) from test where foo = ?", 0, &st, &tail);
    sqlite3_bind_null(st, 0);
    rc = sqlite3_step(st);
    assert(rc == SQLITE_ROW);
    
    printf("number of rows: %i\n", sqlite3_column_int(st, 0));

    rc = sqlite3_finalize(st);
    assert(rc == SQLITE_OK);

    return 0;
}
2005-Sep-12 09:26:19 by ghaering:
forgot to log in ...


2005-Sep-12 09:38:22 by anonymous:
The index of the sqlite3_bind_* and sqlite3_column_* is starting from 1 not 0. see http://www.sqlite.org/capi3ref.html#sqlite3_bind_null


2005-Sep-12 09:49:26 by drh:
I think what Gerhard is proposing is to have a new operator which can be used to compare for NULL so that it works against bound parameters even if the parameter is bound to NULL. You cannot use == for his. x=='abc' and x==123 both work, but x==NULL always fails. So saying x==:param is dangerous because if :param is bound to NULL it does not do what you really want.

I have previously proposed extending the IS operator for this purpose. You can already say "x IS NULL". Why shouldn't you also be able to say "x IS 'abc'" and "x IS 123"? Then you could do things like "x IS :param" and it would work with bound parameters.

I proposed this on the mailing list once, if I recall, and it was resoundingly rejected. But maybe people just didn't understand the question or the problem it was trying to resolve.

 
1417 new active 2005 Sep anonymous   2005 Sep drh 3 3 Fix successive access to a DB handler (unix broken thread file lock) edit
This patch allows threads to access successively to a DB handle and remove the heavy restriction of the SQLITE_MISUSE. In case of simultaneous access, concurent threads get SQLITE_BUSY until the OsFile is unlocked.

patch against os_unix.c in version 3.2.5.

2005-Sep-09 20:26:58 by drh:
I do not believe this patch works. When a handle is moved between threads on a system where separate threads cannot override each others locks, then then lockInfo structure for that handle needs to be released and a new lockInfo structure suitable for the new thread needs to be allocated. There is a separate lockInfo structure for each thread/file combination so when moving a handle from one thread to another it is important to get a new lockInfo structure.


2005-Sep-10 01:26:19 by anonymous:
Why this lockInfo structure should need to be released for another thread?

This patch resets safely the thread(a)/file combination to a thread(b)/file combination until the next move. This allows successive access to a DB handle and manage properly concurrent access with SQLITE_BUSY.


2005-Sep-21 15:16:44 by drh:
Suppose this patch is run on a system where threads cannot override each others locks. (Ex: RedHat 9). Two handles are opened on separate threads. This gives them different lockKey values. After opening, the handles are passed to the same thread. The first handle does "BEGIN; UPDATE ....;" but does not yet commit. The second handle then does an UPDATE. The first handle does ROLLBACK. At that point the database has likely been corrupted.


2005-Sep-21 19:50:17 by anonymous:
I can not suppose this because it's "impossible". This patch is not active on a system where threads cannot override each others locks:

# define CHECK_THREADID(X) ( threadsOverrideEachOthersLocks>0 && check_threadid(X) )

Or if you suppose this is possible, this means that, on the current version of SQLite:

  • the testThreadLockingBehavior function is wrong
  • data corruption can happen on a system where threads can override each others locks

All this is nonsense.

 
1400 new active 2005 Aug anonymous   2005 Sep   5 5 Use of indexes in queries to VIEWS built from UNION SELECTS edit
Attach 2 DBs DB1 and DB2 that have each a table with same schema (say A). Create a view so that all data i seen as one piece, like: VIEW = SELECT * from DB1.A UNION SELECT * from DB2.A

Many views are created like this (for a few tables) and queries that do joins are run on the views. Those queries do NOT to use the underlying DB1.A and DB2.A indexes (i.e. they are too slow). Is this a bug? Is this by design? Am I confusing something? Will "UNION ALL" make a difference?

Sorry if this is explained in docs but i did a search before entering this and could not find something.

2005-Aug-31 13:09:30 by drh:
I have difficulty understanding this ticket, but I I think it is an enhancement request for better query optimization.

It is a question: does creating a view V made as above - by union-ing 2 tables that have same schema - still use indexes from constituent tables? E.g. with a quey like (select * where V.field = 'value'). It appears not to be the case.

 
1381 new active 2005 Aug anonymous Parser 2005 Aug   5 4 missing important builtin function stdev edit
I really miss function stdev for support of statistical usage of SQLite. Also missed sqr and sqrt for square and square root calculations. This would help me very much to simplify my applications if they could be integrated also into the command line tool. An avg without stdev is of no useful meaning.

Another wish is the support of date and time stamp calculations. Some few functions to convert literal expressions into float and backwards would be sufficient for me. No time zone consideration required.

2005-Aug-25 11:35:15 by anonymous:
Proposal for powerful enhancements:
Introduce alias scripting to combine built in functions to create new function names. Similar to C language macros. SQR and SQRT to become available as builtin functions.
Example for creation:
PRAGMA FUNCTION newfunctionname(<arg1>{,<argn>+})=<macro syntax with arguments>
Example for an application:
PRAGMA FUNCTION
stdev(xsum,xsumcubed,n)=sqrt((n*xsumcubed-sqr(xsum))/(n*(n-1)));
SELECT avg(t1.c1) as c1mean,
stdev(sum(t1.c1),sum(sqr(t1.c1)),count(t1.c1)) as c1sigma,
avg(t1.c2) as c2mean,
stdev(sum(t1.c2),sum(sqr(t1.c2)),count(t1.c2)) as c2sigma
from t1;
This would reduce typing and enables to simulate non built in functions which can be created on basis of built in functions. Should be well supported by expression optimization to gain most benefit.


2005-Aug-29 16:00:39 by anonymous:
I also lack of sqrt, sqr and stdev (beside some other basics like sin, cos, tan, atan2, deg, rad, ... ). I like the idea of macros, too, because they make simplifications in statements easy. While sqr could be written like MACRO sqr(x)= ((x)*(x)) it is very difficult to live without the sqrt. Even stdev could become a macro but without sqrt the live stays difficult. If macros become part of SQLite3 then there should also be a command PROBE to see the expanded statement as executed by the parser; similar to EXPLAIN command.

Priority to this ticket should be higher to become realized.

 
1332 new active 2005 Jul anonymous Unknown 2005 Jul   5 5 update 20x slower when using a temp table edit
I have two versions of the same algorithm. The first operates directly on the main db table. The second operates on a temp table containing only the working set. The problem is that the second version is about 20x slower, 1.5 sec versus 30 sec. If the EXISTS line in the second version is commented out the execution time drops to 9 sec. The test dataset has 12000 rows in group_article and the query deals with 6400 rows. The final version will be expected to work with >2 million rows.

Version 1:

   UPDATE group_article SET parent=null WHERE group_id=?;
   UPDATE group_article SET parent=
	( SELECT article.id FROM refs ,article 
		WHERE refs.article_id=group_article.article_id 
		AND reference=hash 
		AND EXISTS (SELECT id FROM group_article 
			WHERE group_id=?1 AND article_id=article.id) 
		ORDER BY refs.id DESC LIMIT 1 )
	WHERE group_id=?1

Version 2:

   CREATE TEMP TABLE thrd(aid UNIQUE, parent);
   INSERT INTO thrd(aid) 
     SELECT article_id FROM group_article WHERE group_id=?;
   UPDATE thrd SET parent=
	( SELECT article.id FROM refs ,article 
		WHERE refs.article_id=thrd.aid 
		AND reference=hash 
		AND EXISTS (SELECT aid FROM thrd WHERE aid=article.id) 
		ORDER BY refs.id DESC LIMIT 1 ); 
   UPDATE group_article SET parent=
	( SELECT parent FROM thrd WHERE aid=article_id ) 
	WHERE group_id=? ;

Here are partial table defs.

table group_article (id PRIMARY, group_id INT, article_id INT);
  UNIQUE index on (group_id, article_id);
table refs (id PRIMARY, article_id int, reference BLOB(15));
  index on (article_id)
table article (id PRIMARY, hash BLOB(15));
  UNIQUE index on (hash)

Almost forgot, I'm running this on windows xp, compiled with mingw gcc 3.4.4.

The appears to be an enhancment request - you are wanting better optimization in the SQLite. It seems to get the correct answer, you just want to get the answer faster. So I have changed this ticket to an enhancment request and set the priority very low.

If you want help optimizing your query, the proper place to ask is on the mailing list.


2005-Jul-24 03:50:31 by anonymous:
After taking a day away from the code I finnaly found the problem. Declaring a column as UNIQUE without giving it a type means that either the index is not created or it's not used. A full table scan was being used each time in the second version. Adding INT as the type on thrd.aid fixed the performance problem.

Assuming I didn't miss this in the docs, this is either a bug or a note is needed so others don't make the same mistake.

 
1319 new active 2005 Jul anonymous   2005 Jul   5 4 Extend sqlite3_expired to detect schema changes edit
Hi,

It would be nice to have sqlite3_expired() detect if the database schema has changed by, for example, vacuuming. This also requires the statement to be recompiled, and so IMHO it makes sense to have expired handle that.

Thanks.

 
1313 new active 2005 Jun anonymous   2005 Jun   4 4 Allow headers in imported text files edit
  Please enhance the '.import' command to add a switch which
  allows the user to specify whether or not the imported text
  file contains headers.
  If it does, they can be silently discarded.
  As it stands the header row will be imported as a normal data row.
2007-Jan-26 16:57:48 by anonymous:
This feature would be very nice, but it would also be great to be able to create a table using the header row as column names during .import.
 
241 new active 2003 Feb anonymous   2005 Jun anonymous 5 5 lack of alter table statement edit
Have you any plans for the alter table statement?
 
1294 new active 2005 Jun anonymous   2005 Jun   3 3 API to get ordinal table name edit
When a select statement returns a recordset, SQLite current implementation has an API to retrieve all column names. It is great to have an API to retrieve table names for each columns. This is especial usefull to deal with joins and dynamic queries and update the recordset on the fly. I believe MySQL has this feature. It would be great to port this feature over.
 
1262 new active 2005 May anonymous VDBE 2005 May   5 3 5-15% performance increase for slow joins edit
Attaching an optimization to sqlite3VdbeRecordCompare() that gives a speedup of 5-15% for certain SELECTs with join.

The optimization does comparisons directly on serialized data instead of deserializing and then comparing.

It also inlines sqlite3GetVarint32 partly. The way the __inline keyword is used needs to be made portable.

2005-May-22 12:52:08 by anonymous:
I don't have the neccessary infrastructure to run the unit tests, so it's likely that unit tests fail since I only have done limited testing of the code.

As long as it doesn't contain any fundamental logic flaws any bugs should be possible to fix.


2005-May-22 19:56:29 by anonymous:
Looks like negative doubles don't compare as easy as I thought. Please wait for a fix before comitting.


2005-May-22 21:25:49 by anonymous:
Attaching file that passes the unit tests.
 
1254 new active 2005 May anonymous Pager 2005 May   3 3 better pager_cksum edit
pager_cksum currently reads one byte every 200 bytes in a page and computes a checksum from this.

Suggest changing this to reading 32-bits every 200 bytes. This will run a the same speed, but the likelyhood of detecting errors is larger, since 400% more data is used in the checksumming.

 
1250 new active 2005 May anonymous Pager 2005 May   1 3 FlushFileBuffers makes Windows sqlite dead slow compared to Linux edit
On Windows, FlushFileBuffers is used to commit changes to the disk. This makes Windows sqlite very slow in comparison with sqlite on Linux, because fsync() doesn't flush the disk controller's cache like FlushFileBuffers does.

When opening the database file and journal file, there should be an option to use the FILE_FLAG_WRITE_THROUGH file flag. This will make sure that all writes go through the OS cache directly to the disk before the write function returns.

This will give a small slowdown for HUGE commits, but the speedup for small commits is substantial. FILE_FLAG_WRITE_THROUGH is 5-10x faster than FlushFileBuffers for all commits that don't write to a huge number of pages. For commits in the size range of 5-10 megabytes, FILE_FLAG_WRITE_THROUGH is around 2x slower.

2005-May-18 17:49:22 by anonymous:
Attaching sqlite.patch that adds a global variable that controls the write through status. This is not ideal, but it allows you to benchmark the differences easily.


2006-Jun-06 18:34:18 by anonymous:
FILE_FLAG_WRITE_THROUGH is the norm for Microsoft's SQL Server.

http://support.microsoft.com/default.aspx?scid=kb;en-us;234656

 
1249 new active 2005 May anonymous Unknown 2005 May   5 4 transaction edit
It would be handy to have a sqlite3_in_transaction function that would return whether or not a databases connection was in the middle of a transaction or not. I'm thinking this could be as simple as just returning the value of the autoCommit flag. I suppose it might be interesting to have it return the type of the transaction, but that would be strictly for extra credit.
2005-May-18 15:20:00 by anonymous:
Actually, what we probably really want is a call that tells us the value of the autoCommit flag.
 
1240 new active 2005 May anonymous Pager 2005 May drh 1 3 Need integration of Apple's file locking callbacks improvement edit
Now that OSX 10.4 has been released to the public; Apple has dedicated their changes to improve and support locking on the OSX platform (as well as others) to the public domain. These changes will also make it possible to use sqlite on prior versions of OSX. They externalize the necessary file locking into a callback system which greatly simplifies maintaining this area of persistent headaches.

Apple has also included support for F_FULLFSYNC as described here: http://lists.apple.com/archives/darwin-dev/2005/Feb/msg00072.html

Apple's changes are to a base distro of sqlite 3.1.3

The sources can be found at: http://www.opensource.apple.com/darwinsource/tarballs/other/SQLite-28.tar.gz

 
1227 new active 2005 Apr anonymous Shell 2005 Apr   5 2 Small patch for timing commands in shell.c edit
  Please find attached small patch for timing commands in shell.
  Patch explains usage of a new .timer command.
  Patch is tested with OpenWatcom 1.4 + Windows

  20a21
  > #include <time.h>
  80d80
  < 
  778a779
  >   ".timer start|show      Internal timer functions\n"
  1385a1387,1414
  >   }else
  > 
  >   /*
  >    Bartosz Polednia 27.04.2005 - free for SQLite community
  >   
  >    .timer start
  >      Starts internal clock counter and prints it in form :
  >         Start time:                 Sat Mar 21 15:58:27 2005
  > 
  >    .timer show
  >      Shows time elapsed in form :
  >         Exec  time:  nnnnnn.nnn s.  Sat Mar 21 15:58:27 2005
  >      where nnnnnn.nnn is time in sec. since last .timer start command.
  >      Timer is not stopped so user can issue next .timer show command.
  >      To start timer user has to exec .timer start command again.
  >   
  >   */
  >   if( c=='t' && strncmp(azArg[0], "timer", n)==0 && nArg>=2 ){
  >     static clock_t timerstart = 0;
  >     time_t  now = time( NULL );
  >     if( strcmp(azArg[1],"start")==0 ){
  >       timerstart = clock();
  >       printf("Start time: %13s %s", "", ctime( &now ) );
  >     }else if (strcmp(azArg[1],"show")==0 ){
  >       clock_t tmp = clock();
  >       printf("Exec  time: %10.3lf s. %s", (1.0*tmp - timerstart)/CLOCKS_PER_SEC, ctime( &now ) );
  >     }

  Regards,
  Bartosz
 
1221 new active 2005 Apr anonymous   2005 Apr   5 4 Implementation of PRAGMA trigger_info(table) edit
Although this is not a bug it would be nice to implement the feature, as it can help developers to get information about table triggers. Also the code to do this is quite simple. See below the part of the code that should be inserted in the PRAGMA section:

/// Editing pragma.c and insert this

  if( sqlite3StrICmp(zLeft, "trigger_info")==0 ){
    Table   *pTab = sqlite3FindTable(db, zRight, 0);
    Trigger *pTrg = pTab->pTrigger;
	sqlite3VdbeSetNumCols(v, 4);
	sqlite3VdbeSetColName(v, 0, "table", P3_STATIC);
	sqlite3VdbeSetColName(v, 1, "trigger", P3_STATIC);
	sqlite3VdbeSetColName(v, 2, "op", P3_STATIC);
	sqlite3VdbeSetColName(v, 3, "tr_tm", P3_STATIC);

	while(pTrg)
	{
	  sqlite3VdbeOp3  (v, OP_String, 0, 0, pTrg->table, 0);
	  sqlite3VdbeOp3  (v, OP_String, 0, 0, pTrg->name, 0);
	  sqlite3VdbeAddOp(v, OP_Integer, pTrg->op, 0);
	  sqlite3VdbeAddOp(v, OP_Integer, pTrg->tr_tm, 0);
	  sqlite3VdbeAddOp(v, OP_Callback, 4, 0);

		pTrg = pTrg->pNext;
	}
  }else

/// End of new Insertion

 
1220 new active 2005 Apr anonymous   2005 Apr   4 3 Selectable calling convention edit
It would be helpful to be able to specify the calling convention for the SQLite API functions when building the library. This is sometimes an issue when writing wrapper libraries, specifically for .NET, which assumes a stdcall calling convention when calling DLL's. The default cdecl calling convention of a C DLL such as SQLite causes a bit of unnecessary overhead for the .NET runtime.

This is accomplished with Visual C++ (and GCC is similar) by adding a modifier to a function declaration...

void __stdcall sqlite3_open ();

This can be implemented using a macro, so the library can be compiled with the desired calling convention...

void SQLITE_CALL sqlite3_open ();

In sqlite3.h, the default macro would be empty...

#ifndef SQLITE_CALL
#define SQLITE_CALL
#endif

 
1208 new active 2005 Apr anonymous Unknown 2005 Apr   4 4 no version info provided in precompiled sqlite3.dll edit
sometimes i get confused which version i'm using. it would be nice to have an easy way to view the sqlite version.
2005-Jul-14 12:43:28 by anonymous:
Yes, would be great if the version information could be put in the resources of the dll and not only be accessible through the exported function! Tools like the popular Installer "InnoSetup" could recognize the version of the sqlite3.dll then and check if a newer version is already installed...
 
1040 new active 2004 Dec anonymous Unknown 2005 Apr   4 4 pragma needed to enable flexibility of insert statements (esp. for awk-like filter use) edit
In order to work around http://www.sqlite.org/cvstrac/tktview?tn=1032,3 it is possible to create insert statements manually using sed.

However, those insert statements are not as flexible as they are documented to be. An error is generated if there are more data than columns. It is too slow to count the number of columns in each row to work around it.

This makes the use of sqlite as an awk-like filter impossible, since you can't just define columns f1 through f9 and insert rows that have fewer columns into it. Defaulting is not done.

This is inconsistent with the sqlite2 copy command, which is flexible.

I propose a pragma to allow more flexibility.

There is no fast workaround, but I am not assigning that severity, because in principle it is possible to much more slowly create a disk db and use .import for most purposes.

 
1204 new active 2005 Apr anonymous TclLib 2005 Apr drh 4 2 (visible) version provided by tclsqlite package edit
As a new version of sqlite is released it would be good to see the tclsqlite package version modified accordingly.

On the file tclsqlite.c, function Sqlite3_Init, it gives a fixed version to the function Tcl_PkgProvide "3.0". I believe this should be replaced with SQLITE_VERSION (macro defined in sqlite3.h).

Is there a reason this should not happen? Or was simply overlooked?

 
1190 new active 2005 Mar anonymous Unknown 2005 Mar drh 4 4 strftime() does not Support Years with 3 or 5 digits edit
It looks like strftime() doesn't support years before 1000 CE or after 9999 CE:

  sqlite> select strftime('%Y', '2004-01-01T02:34:56');
  strftime('%Y', '2004-01-01T02:34:56')
  -------------------------------------
  2004                                 
  sqlite> select strftime('%Y', '200-01-01T02:34:56');
  strftime('%Y', '200-01-01T02:34:56')
  ------------------------------------
  [null]                              
  sqlite> select strftime('%Y', '20000-01-01T02:34:56');
  strftime('%Y', '20000-01-01T02:34:56')
  --------------------------------------
  [null]                                

The same applies to years BCE:

  strftime('%Y', '-2000-01-01T02:34:56')
  --------------------------------------
  -2000                                 
  sqlite> select strftime('%Y', '-20000-01-01T02:34:56');
  strftime('%Y', '-20000-01-01T02:34:56')
  ---------------------------------------
  [null]                                 
  sqlite> select strftime('%Y', '-200-01-01T02:34:56');
  strftime('%Y', '-200-01-01T02:34:56')
  -------------------------------------
  [null]

One can get around the requirement for pre-1000 by using a preceding 0 (and the ISO-8601 spec may well require this; I'm not sure), but the lack of support for five or more digits in the year has no workaround.

So much for my science fiction database! ;-)

2005-Mar-30 23:45:53 by anonymous:
Ah, found this link, which says that years must be represented by at least four digits. So 0200 is correct and works, while 200 is not. Sorry 'bout that. Ignore that part of the report.

  http://www.absoluteastronomy.com/encyclopedia/I/IS/ISO_86012.htm

But it still would be nice to support more than four digits for the year, so that astronomy folks can use SQLite. :-)


2005-Mar-31 18:24:53 by drh:
I think this is an enhancement request, not a bug report.

I deliberately limited the span of years that SQLite would handle to be 1000 through 9999 as a means of detecting faulty input. I reasoned that astronomers and others who were doing date calculations outside of this range are likely using their on date/time library anyhow and so the limited range of dates that SQLite would handle was not seen as a serious handicap. Even if an astronomer wanted to use SQLite, the changes to the SQLite code base to enable a larger span of years are minor and could be done on a case by case basis.

I'm not sure this is something that needs to be in the standard release.


2005-Mar-31 18:32:36 by anonymous:
I certainly understand the desire to detect faulty input, but since dates are simply stored in TEXT columns in SQLite (I think that's right--please correct me if I'm wrong), there isn't actually any fault input detection going on until someon uses strftime() or another date/time function.

Furthermore, 10000-12-19 is not faulty input; it's perfectly valid. So is -10001-02-28 (for the archaeologists). It may be easy to patch SQLite to support such dates, but that's relatively out of the hands of mere mortals.

Now if there was a compile directive to enable such support, that might be a decent compromise. Then, you'd still have the validation support, but at the same time, those who need astronomical or archaeological dates could easily get them without having to learn any C or the SQLite source code.


2005-Mar-31 18:55:48 by drh:
I will consider the request to support 5- or 6-digit dates. But the date algorithms used in SQLite doe not work correctly for negative Julian days (that is, dates prior to -4713-11-24T12:00:00). In fact, the date algorithms always assume the Gregorian calendar, which wasn't invented until the 16th century, was not in wide use until the 18th century. So any really old dates are suspect.

Due to changing standards and politics, date/time computations can be amazingly complex, especially when you start to consider things like daylight savings time. It is not the mission of SQLite to provide a complete date/time management system. The date/time functions provided are intended to give a baseline of functionality that meets 90% of the need. Users who need more can add their own code using the sqlite3_create_function() API. The date/time functions are already one of the largest modules within SQLite and I am very hesitant to go make them even larger.


2005-Mar-31 19:08:30 by anonymous:
Understood, thanks for the consideration.
 
1189 new active 2005 Mar anonymous Parser 2005 Mar   1 1 Make where-clause item count limit dynamic edit
If you enter a query with more then 100 'where clause items' (pieces of a where clause joined by AND or OR) then you get an error saying you must limited yourself to 100 or less items. This is fine for 99.9% of the time, but I ran into a problem when trying to implement ad-hoc bitmap indexes -- in other words, hundreds of columns in a table and therefor hundreds of items in the where clause. I was able to work around this, at the sqlite level, by simply changing a constant in where.c from 101 to 1001 (437 was what was needed for this specific application).

The requested I'd like to see filled is that this be more-or-less a dynamic value. Perhaps it reads from some environment variable to determine this, and defaults to 100(+1). This would likely result in a bit of code rewrite as to how where.c works, but I don't think it would be a terribly huge amount.

 
1186 new active 2005 Mar anonymous Shell 2005 Mar   4 4 Pragma page_size doesn't set the pagesize immediately edit
Sqlite3 doesn't change the page_size of a DB until you run a ddl command. Allthough this behavior doesn't really qualify as a bug, it is an annoyance to us.

Thanks for your great work

K.- M. Hansche

 
1176 new active 2005 Mar anonymous Unknown 2005 Mar   4 3 Blocking Writes edit
I would be nice if there was an option where a write query would block when the database was locked by another process/thread. I would prefer this over returning SQLITE_BUSY and looping...Is this planned at some point?
 
1162 new active 2005 Mar anonymous   2005 Mar drh 1 2 Column names in sqlite views differ from oracle/informix column names edit
I tried to use views with sqlite 3.1.5 with short_column_names (as default within 3.x). Below is the script of my try.

As with CheckIns 2230 - 2232 (Tickets #269, etc.) I thought I can access view elements without defining an alias. That does work if I create the view like this:

  create view yy2 as select y1.*, y2.* from y1, y2 where y1.a=y2.c;

But does not work, if I create it this way.

   create view yy as select y1.a, y1.b, y2.c, y2.d from y1, y2 where y1.a=y2.c;

It would be a hard job to change all my view definitions (which where fine for informix and oracle) to fit sqlite.

Reply from Dr Richard Hipp: If you will write a ticket that describes the column names assigned to views by Informix, Oracle, and PostgreSQL, I'll change SQLite to generate exactly the same column names.

Below i posted the behaviour of informix 9.3 and oracle. I currently have no postgreSQl available.

C:\devel\js\head\dst>sqlite3 ..\..\sqlite\problem.db
SQLite version 3.1.5
Enter ".help" for instructions
sqlite> create table y1(a,b);
sqlite> create table y2(c,d);
sqlite> create view yy as select y1.a, y1.b, y2.c, y2.d from y1, y2 where y1.a=y2.c;
sqlite> insert into y1 values (1,2);
sqlite> insert into y2 values (1,3);
sqlite> .headers on
sqlite> select * from yy;
y1.a|y1.b|y2.c|y2.d
1|2|1|3
sqlite> select * from yy where a=1;
SQL error: no such column: a
sqlite> select * from yy where y1.a=1;
SQL error: no such column: y1.a
sqlite> pragma short_column_names;
short_column_names
1
sqlite> pragma full_column_names;
full_column_names
0
sqlite> create view yy2 as select y1.*, y2.* from y1, y2 where y1.a=y2.c;
sqlite> select a,b,c,d from yy2;
a|b|c|d
1|2|1|3
sqlite> select * from yy2;
a|b|c|d
1|2|1|3

------------- INFORMIX -----------

CREATE TABLE y1 (a CHAR(20), b CHAR(20));
Table created
CREATE TABLE y2 (c CHAR(20), d CHAR(20));
Table created
INSERT INTO y1 VALUES ('1','2');
1 row(s) inserted
INSERT INTO y2 VALUES ('1','3');
1 row(s) inserted
CREATE VIEW yy AS SELECT y1.a, y1.b, y2.c, y2.d FROM y1, y2 WHERE y1.a=y2.c;
View created
select * from yy;
a 1
b 2
c 1
d 3
1 row(s) retrieved.

----------- Oracle ---------
CREATE TABLE y1 (a VARCHAR2(20), b VARCHAR2(20));
Table created.
CREATE TABLE y2 (c VARCHAR2(20), d VARCHAR2(20));
Table created.
INSERT INTO y1 VALUES ('1','2');
1 row created.
INSERT INTO y2 VALUES ('1','3');
1 row created.
CREATE VIEW yy AS SELECT y1.a, y1.b, y2.c, y2.d FROM y1, y2 WHERE y1.a=y2.c;
View created.
DESC yy;
 Name                                      Null?    Type
  A                                                  VARCHAR2(20)
  B                                                  VARCHAR2(20)
  C                                                  VARCHAR2(20)
  D                                                  VARCHAR2(20)

SELECT * FROM yy;
A                    B                    C                    D
1                    2                    1                    3
 
1031 new active 2004 Dec anonymous   2005 Jan   3 4 sqlite command line does not allow intermixing of dot commands and sql edit
Dot commands are not fully intermixable with sql commands in sqlite3.

Please see bug 1030.

 
1061 new active 2005 Jan anonymous Shell 2005 Jan   4 4 shell.c .import from stdin edit
e.g.: in = ( 0 == strcmp( "-", zFile ) ) ? stdin : fopen(zFile, "rb");
 
1011 new active 2004 Nov anonymous   2004 Nov   5 4 No .lib file for in windows precompiled binaries edit
It would be nice if there was .lib file available in precompiled binaries, so one could compile interface modules (like python sqlite) without building the full source.
2004-Nov-21 23:53:45 by anonymous:
Does the information under "MSVC and SQLite DLL" in http://www.sqlite.org/cvstrac/wiki?p=HowToCompile help you?


2004-Nov-23 05:21:41 by anonymous:
There should be sqlite3.h with dll for C-compiler.
 
965 new active 2004 Oct anonymous VDBE 2004 Oct   3 3 Busy Handler not invoked for SELECT et.al. in SQLite <= 2.8.15 edit
There exist very rare cases when sqlite_exec() can return SQLITE_BUSY but the user-provided busy handler although set with sqlite_busy_handler() was never invoked. Please consider the following patch against vdbe.c. It primarily affects SELECT statements. For PRAGMA similar code snippets might be necessary for the VDBE opcodes ReadCookie/SetCookie.

  --- sqlite.orig/src/vdbe.c      Mon Jul 19 21:30:50 2004
  +++ sqlite/src/vdbe.c   Tue Oct 19 14:45:11 2004
  @@ -2325,8 +2325,11 @@
   */
   case OP_VerifyCookie: {
     int aMeta[SQLITE_N_BTREE_META];
  +  int busy = 1;
     assert( pOp->p1>=0 && pOp->p1<db->nDb );
  -  rc = sqliteBtreeGetMeta(db->aDb[pOp->p1].pBt, aMeta);
  +  while( (rc = sqliteBtreeGetMeta(db->aDb[pOp->p1].pBt,aMeta))==SQLITE_BUSY
  +     && db->xBusyCallback
  +     && db->xBusyCallback(db->pBusyArg, "", busy++)!=0 ){}
     if( rc==SQLITE_OK && aMeta[1]!=pOp->p2 ){
       sqliteSetString(&p->zErrMsg, "database schema has changed", (char*)0);
       rc = SQLITE_SCHEMA;
 
944 new active 2004 Oct anonymous Shell 2004 Oct   4 3 Command to abort current expression. edit
It would be convenient if, at the sqlite prompt, it was possible to abort the current expression by entering e.g. a singel dot on a new line. I.e.:

sqlite> SELECT * FROM
   ...> .
sqlite>
 
883 new active 2004 Sep anonymous Shell 2004 Sep   1 4 Choose appropriate column widths for column output edit
Currently, when you use a select statement and have .mode set to column, it truncates the data based on the values in .width. It can be a problem to set .width properly because sometimes you are only selecting some columns and sometimes all of them. This means you really have to set .width before each select statement. Even when you do, sometimes the width is too wide and space is wasted unless you know in advance the width of the widest value being printed.

What I would like is another mode or some option to have SQLite figure out the optimal width of the columns. It would simply set the width of each column to the width of the widest value in the column. MySQL does this.

2004-Sep-02 15:18:20 by drh:
There are two ways of doing this:

  1. Run the query twice. Record the maximum column witdh on the first run then display the results on the second run.

  2. Store the entire result set in memory. Compute the maximum column widths prior to displaying anything.

Either approach requires a significant increase in resources to do the query.


2005-Jan-21 20:56:53 by anonymous:
How about instead of, or in addition to this feature, a mode where each column has a default width which corresponds to the data type? E.g. if the type is CHAR(50) the column would be 50 wide. That would be faster and would be good enough for my purposes.


2005-Apr-09 19:41:59 by anonymous:
I don't need this feature after all, since I wrote a filtering program to convert the tab-separated data from sqlite to produce the column-separated data I wanted. In case someone wants to use the code to implement this feature in sqlite, or in case someone wanting this functionality wants to use it directly, you can download the code for free from: http://personal.nbnet.nb.ca/aerichar/tab2col/
 
845 new active 2004 Aug anonymous   2004 Aug   5 4 Support shared-memory databases edit
It would be nice to have shared memory databases. In-memory databases with :memory are supported, but they can't be shared among multiple processes.
 
843 new active 2004 Aug anonymous Unknown 2004 Aug   3 3 Introducing I64 printf size prefix edit
sqlite3_mprintf supports the ll size prefix, so int64 can be formatted using the %llu format specifier.

VC++ printf routines doesn't support the ll size prefix but use the I64 prefix, so a int64 must be formatted as %I64d or %I64u

I think that sqlite3_mprintf should support both size prefixes, so a developer could use the same prefix independently to the function he will use (sqlite3_mprintf, printf, Format, etc....)

 
824 new active 2004 Jul anonymous Unknown 2004 Jul   5 4 StrSum - new build-in aggreate function suggestion edit
StrSum(string aggregatingFiels, string separator ) - aggregate function. create table x (y); insert into x(y) values ('one'); insert into x(y) values ('two'); insert into x(y) values ('three'); insert into x(y) values ('four'); insert into x(y) values ('five');

select StrSum(y, ' / ') from x == 'one / two / three / four / five'

I have coded this function myself into my wrapper but I think this function will be usefull for all users :)

 
823 new active 2004 Jul anonymous Unknown 2004 Jul   5 4 absent VERSIONINFO into any Win32 DLL edit
Hi! There are sqlite_version API entry BUT I need VERSIONINFO resource into WIN32 DLL to create CAB-file witch will replace older shared sqliteX.dll with new versions automaticaly
2004-Jul-26 12:49:33 by drh:
I have no idea what a VERSIONINFO resource is.


2004-Jul-26 15:19:14 by dougcurrie:
VERSIONINFO is built with the resource compiler (mingw handles this).

Here's how VIM added it: http://www.math.technion.ac.il/pub/vim/patches/6.1.374

Here some MS docn: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tools/tools/versioninfo_resource.asp

Maybe someday I'll have time for adding this, but not now. -- e

 
239 new active 2003 Feb anonymous Unknown 2004 Jul   4 2 ANSI/Unicode(Wide) version file-handling functions for Win32 edit
As I reported in the ML, since SQLite os.c file-operation functions accept only const char *zFilename, when you build a project with SQLite source code under _UNICODE defined on Win32, their internal expectation of ANSI version function fails. For example,

int sqliteOsDelete(const char *zFilename){
#if OS_UNIX
unlink(zFilename);
#endif
#if OS_WIN
DeleteFile(zFilename);
#endif
#if OS_MAC
unlink(zFilename);
#endif
return SQLITE_OK;
}

DeleteFile in this function is replaced with DeleteFileW, the unicode version of DeleteFile, which takes Unicode string(wide characters) as an argument.
To compile SQLite in Unicode application, you must change those functions to its ANSI version. For DeleteFile, it's DeleteFileA. The functions that should be presented in os.c as their explicit ANSI version are:

DeleteFile -> DeleteFileA
GetFileAttributes -> GetFileAttributesA
CreateFile -> CreateFileA
GetFullPathName -> GetFullPathNameA
GetTempPath -> GetTempPathA

Namely, all file-handling Win32 APIs that take a path name as its argument, not a handle.

The 'vanilla' versions of functions like GetFile() aren't functions, but symbols defined in "winbase.h". For example, GetFile() expands to:

#ifdef UNICODE
#define DeleteFile DeleteFileW
#else
#define DeleteFile DeleteFileA
#endif // !UNICODE

So when someone compiles SQLite under Windows, they need to #define _UNICODE (or not), as desired. Unless I completely misunderstand this, there is no reason to change the SQLite code, and doing so would make it less flexible.

Additionally, The unicode versions of the functions will handle ASCII strings, which are legal UTF8 strings. So the only real consideration left is the 'offical' SQLite Windows DLL. Because older systems (95, 98) lack built-in support for the Unicode versions of most functions, the DLL should probably be built without the Unicode versions.

We might want to force the definition of UNICODE when SQLITE_UTF8 is defined, so that the DLL can be queried to see what kind of strings it expects, but then, someone (me) may reasonably want to compile the app to use unicode strings for file handling, but iso8859 strings for data. So at most I would suggest a #pragma message when the two symbols disagree. This is compiler dependent, but one for MSVC, Borland, and gcc would probably catch most current users.

Jim Lyon


(by reporter)

In C++ context compiler issues error because const char* of os.c functions doesn't match DeleteFileW signature under _UNICODE defined and this is not convenient in simply adding SQLite source files in UNICODE-defined host app project.

Anyway, if os.c Windows-version functions take LPCTSTR zFilename that is translated into const char* in ANSI(MBCS) and const wchar* in _UNICODE in compile-time, you don't have to use explicit ANSI version API. If explicit use of ANSI version API makes SQLite "less flexible", I'd like to propose changing const char* zFilename to LPCTSTR in os.c.

Another way is, add to SQLite its own ANSI/Unicode(UCS-2) version APIs as Windows does, in Windows SQLite build. For example "open" is translated in sqlite.h to openA/openW which exists in dll. Fortunately SQLite has os.c as abstraction filter for its body, several changes in os.c will be sufficient.


(by reporter)

It's fixed in between 3.0.0 and 3.0.2 by adding 'A' suffix to those file-handling APIs. Can someone verify and close this ticket?


2004-Jul-22 23:19:23 by anonymous:
SQLite 2.8.15 os.c is not fixed as of now. I think there's no reason not to apply the same replacement that favors ASCII APIs.
 
797 new active 2004 Jul anonymous Parser 2004 Jul   4 3 require basic named subquery / WITH sql support edit
This ticket, derived from a recent discussion list posting, is a request for simple named subquery / WITH sql support. The level of support that I'm looking for should only require and update to the "Parser" subsystem, or possibly "CodeGen" too.

The fundamental implementation of how SQLite handles subqueries is not changed at all. You still execute the subqueries exactly once, prior to the main queries, as you do now.

The subset would be compliant with the SQL-1999 standard. As an additional reference, you can see SQL-2003 Foundation, 7.13 "<query expression>" (p351).

What I want is to be able to make a query like this:

	WITH
		first_subq AS (
			SELECT id FROM foo WHERE name LIKE '%zoo%'
		),
		second_subq AS (
			SELECT a, b, COUNT(c) AS d FROM bar GROUP BY a, b
		)
	SELECT *
	FROM second_subq AS s INNER JOIN baz AS z ON z.a = s.a AND z.b = s.b
	WHERE (z.opt1 IN first_subq OR z.opt2 IN first_subq) AND s.d >= z.boo
	ORDER BY s.d DESC

One of the main advantages I cite is that SQL code is a lot cleaner and easier to understand. You can do within complex selects the same thing you can do in complex routines, which is akin to breaking out blocks into named subroutines.

This advantage is particularly seen where the same subquery would be getting invoked multiple times within the main query (see example). It now does not have to be declared multiple times, leading to shorter and easier to parse SQL, and the code runs faster, because the subquery only has to be run once. As such, developers can also reduce some use of explicit temporary tables.

This ticket is not requesting support for passing arguments to the named subqueries, as SQL-1999 allows, nor having support for recursive named subqueries (those that invoke themselves). Those would be nice some day, but would require more substantial changes to SQLite, such as invoking subqueries during the main query, and multiple times, rather than in advance. So I am not requesting those today. (Note that, should you ever decide to support recursive subqueries later, it should be done the SQL-1999 way, and not Oracle 8's way of start-with connect-by.)

In summary, I propose that in the long run, named subqueries should be a lot more useful than inlined subqueries, both for programmer efficiency, and because SQLite itself has less work to do when parsing or optimizing sql queries; the programmer can tell you ways to optimize by reducing redundancy.

Thank you. -- Darren Duncan

P.S. On the list, Dennis Cote also showed a desire for the same features, saying:

I also believe support for named subqueries would be a valuable addition to SQLite.

I have previously advocated for this feature on the list as well, though I called it a WITH clause rather than a named subquery. It seems to me to be a fairly simple extension to SQLite that would allow the user to manually perform common sub-expression elimination optimizations. These optimizations are done automatically by other, not so lite, database engines. I also think they make the resulting SQL select statements easier to read.

 
755 new active 2004 Jun anonymous TclLib 2004 Jun drh 5 2 Adding aggregate function to the tcl binding edit
The diff against tclsqlite.c to solve the problem can be also submitted by email
 
748 new active 2004 May anonymous   2004 May   3 3 option to allow ignoring trailing whitespace in selects edit
According to the SQL-92, when comparing strings using the = operator, the strings are supposed to be padded out with spaces to the same length. For example, a char(5) column contains 'abc ' (two spaces at the end) and you perform

  select * from table1 where field1 = 'abc'

This should match that 'abc ' row. This is because both terms would have been padded with spaces to be matching lengths before comparison.

SQLite should at least have the option to turn on SQL-92 compliant padding.

 
742 new active 2004 May anonymous VDBE 2004 May anonymous 5 5 database is locked edit
when I tried to access your site, sometimes I could see the message like "the database is locked", and could not access. I think it's because of the so called "SQLITE_BUSY". if SQLITE_BUSY happens, can't we just access the website? if so, it would be nice to have an waiting time option, that is if SQLITE_BUSY happens the vdbe waits a little time and tries again till the appointed times even after if it is impossible, then show "database is locked". How about it?
2004-May-19 10:03:54 by drh:
The SQLite website is database driven. Not every page requires database access, but many do. If an SQLITE_BUSY occurs, the request is automatically retried multiple times. But if SQLITE_BUSY keeps occurring, the request will eventually timeout.

www.sqlite.org runs on User-Mode Linux (UML) partition at http://www.linode.org/. It is a Linode-64 (at the moment) meaning that there are 31 other linux instances running on the same CPU. Sometimes one or more of the other 32 linux instances get really busy and clog up the shared disk I/O channel, resulting in long delays for disk access. When this happens and there are multiple people trying to access the data at the same time, timeouts can occur.

 
741 new active 2004 May anonymous CodeGen 2004 May anonymous 5 5 command tool does not support history edit
if command tool support history, it would be great. windows supports its own history but on linux system command tool doesn't support history.
2004-May-23 18:07:31 by anonymous:
The sqlite command on linux and cygwin have history (internal to sqlite at least).

This capability comes from readline if it is installed on your systems. For some more details including libedit and OSX support see ReadLine

 
738 new active 2004 May anonymous   2004 May danielk1977 4 1 Sort order array in memory edit
Order is a problem when I have in memory a result of a long query, because I must order the array of the result.

For example in Ado I can use recordset.order . Is it possible with sqlite?

WHere is the problem?

I must do a query very time long ; if I want to sort the array that give me sqlite, I must remake the query. IT is very bad :).

This because I use in virtual listview the array.

char** paszResults for example

Very thanks

 
739 new active 2004 May anonymous Unknown 2004 May danielk1977 3 1 Suggestion speed query edit
Suggestion

If possible cache the result of query similar or identical.

For example I have a table of 100000 record.

I do a query with where clausal, this takes 2 seconds.

Ok, next time I remake the same query, I spend self time. Is advantageous?

No, my idea is to cache results until there are not changes or update.

The cache has to be done with caution, invisible for user and without compromise the performance.

For example of query result of 100 rows, I must wait another time the time needed to obtain the result. It is not fine!

Piero Romani

 
737 new active 2004 May anonymous Shell 2004 May anonymous 3 3 xml export edit
Export a sql statement to an oracle-style export xml.

  <ROWSET>
   <ROW>
     <cost>30.0</cost>
     <quant>30</quant>
   </ROW>
   ...
  </ROWSET>

This can be done in shell.c following the xthml-table model except without the field escapes (in case we are putting xml in a column).Sqlite will not be able to say what xml a column should have without some kind of schema integration, which seems too complex.

 
736 new active 2004 May anonymous   2004 May   4 4 Would like to be able to list the LAST 10 lines of a query edit
This falls outside the scope of pretty much everything, but still...
I'd like to be able to get the last 10 lines of a query. You may argue (as the mySQL people did about 2 years back) that I can just reverse the ORDER BY direction, but it wasn't a good argument then either, because I may not be setting a specific order (I call this the natural database order).

SELECT * FROM myTable LIMIT -10

makes good sense, especially as it is usually the last n items that a person tends to be most interested in. Since, as far as I know, negative limits are an undefined area, why not stake your claim to SQL fame and introduce something that will be wildly popular?

Specifically:
LIMIT -n should return the last n rows of a query.
LIMIT k, -n should return the n rows just before the kth row
LIMIT -k, n should return the n rows starting k rows before the end
LIMIT -k, -n should return the kth row from the end till n rows before the end.

There is good precedent for this in PHP and javascript string handling, and PHP array handling (see especially http://php.net/array_slice)

Anyway, thanks for listening,
Csaba Gabor

2004-May-13 16:53:56 by drh:
"Natural" database order in SQLite is equivalent to "ORDER BY rowid". So you you can say:

    SELECT whatever FROM whatever ORDER BY rowid DESC LIMIT 10;

And it will do what you want. And it is very fast at this.


2004-May-14 02:10:20 by anonymous:
Cool, that is great, thanks very much.

If I understand this correctly, whenever a new insert is made (regardless of whether the location used is that of a deleted row), there is an internal rowid that always gets incremented (and would overwrite any existing rowid if a deleted row was being reused). This is, therefore, essentially an inherent PRIMARY KEY with the restriction that it can't be changed. But it could be used to access and update any existing row. Very handy, thanks.

I have a related question/comment. There is a function last_insert_rowid(), but in the case of ignore (or abort) this value does not change (and why should it, after all?). But I may be interested in finding the location that the conflict occurred at. (For example, in my current application, I am entering edges in a graph. That is, I first enter the two vertices that define an edge by doing an INSERT. If the vertices already exist, however, it would be improper to do a REPLACE because previous vertex references would become invalid. No, I should really get the location of the existing vertes causing the conflict). Of course, I could manually wade through all the indeces checking to see if/where there is a conflict, but this could seriously increase my access time (we're talking thousands to millions of points) but is there not a shorthand way to find out last_attemptedInsert_row()? - well, you get the idea.

Finally, since this is too tiny to make a separate thread, the last "not" of the first paragraph of text for the insert command (http://sqlite.org/lang.html#insert) should be "no". Also, I would remark that last sentence of the second paragraph for ATTACH DATABASE (http://sqlite.org/lang.html#attach) running into the third paragraph is confusing to me because the first clause of the third paragraph is repeating part of what that previous sentence was saying. Why not remove the entire first clause in the third paragraph and merge the remaining paragraph with the second one.

Csaba Gabor

 
726 new active 2004 May anonymous Parser 2004 May anonymous 5 5 As to single quote edit
Hello

when we insert single quote(') into the query, currently it should be added a more single quote. I think it is not good for most of program espcially in database system uses backslash(\) not single quote.

To be appliable to other program, would you change this?

2004-May-07 15:31:06 by anonymous:
if you don't have any plan, I think putting an escaping option will be great. thanks.
 
724 new active 2004 May anonymous   2004 May   4 5 VACUUM resets settings for the current session edit
All settings tuned in current session are reverted to default values after VACUUM command execution.

Example:

  sqlite> PRAGMA synchronous;
  1
  sqlite> PRAGMA synchronous=off;
  sqlite> PRAGMA synchronous;
  0
  sqlite> VACUUM;
  sqlite> PRAGMA synchronous;
  1

I am convinced that this behavior is defined by VACUUM command implementation which reopens the database in the end. However, I think that this is an implementation detail and should not affect the session state.

 
723 new active 2004 May anonymous Unknown 2004 May   5 4 BatchScript: Example windows batch script for creating databases. edit
echo CREATE TABLE employee (id, name); | sqlite db

echo INSERT INTO employee VALUES (1, 'Adam'); | sqlite db

echo INSERT INTO employee VALUES (2, 'Eve'); | sqlite db

 
718 new active 2004 May anonymous   2004 May anonymous 2 2 Case insensitive index ? edit
It does not seem to be possible to create case-insensitive indices. Using UPPER() or LIKE is not as efficient and it usually requires to tweak applications in an ugly way to support case-insensitive searches.

Maybe the new file format will support this ?

If difficult to make it a feature, is it possible to compile sqlite to be case-insensitive for indicies (even for ones built previously); i.e. provide a #ifdef SQLITE_CASE_INSENSITIVE_INDICES

 
717 new active 2004 May anonymous Unknown 2004 May drh 2 2 minor fixes and port to dos edit
attached is a diff for sqlite 2.8.13 that allows work in dos gnu environment (32 bit djgpp), even without support of long file names.

it also contains minor adjacent bugfixes, in the file names handling area, and for the case of missing libreadline.

please take a look, and do apply to the main source tree. i do not ask for anything, even not for personal credits. it is a very small contribution, to make your wonderful work even more popular.

best regards,

alex

2004-Jul-09 02:22:15 by anonymous:
after feedback, mainly from hans-juergen taenzer, i have reviewed the port to dos and made better relative path support, applying to unix also.

for any questions or remarks, please feel free to contact me,

alex,

alexbodn@012.net.il.

 
714 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 3 Change sqlite_decode_binary to return buffer size edit
It would be nice to be able to have sqlite_decode_binary return the required buffer size, like the encode routine does. The reason is that in managed systems (we're using this in .NET) it avoids a needless allocation and then a copy. For example, without it, we need to allocate a buffer as big as the incoming one, decode, allocate one of the proper size, then copy the bytes. Otherwise, the array we return is incorrectly sized. I've made the following change...

    // TODO: Mark this up... was... out[i++] = c + e;
    if (out) out[i++] = c + e; else i++;

By checking the out argument, we still get the increment count, but we don't write anywhere.

 
712 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 3 Allow temporary databases to be created in specified folder edit
Right now temporary databases are created in a default folder, for example the Temp folder under Windows. It should be possible to customize this location by passing the "context" of the current database to the temporary OS.C function. If that function received the current database, it could parse the folder and optionally create the temporary file in the same location.
 
711 new active 2004 Apr anonymous   2004 Apr drh 3 3 Provide a callback function to verify values before insert or update edit
Such a function would be called during an insert or update with the column name, column type, and the value. The function could set an error and error message to deny the action. This would allow develops to create virtual datatypes with very little effort. For example, if a column was defined as type "Fruit", a function could check if the value was "Apple" and allow it, or "Cat" and deny it.
2004-Apr-28 23:00:07 by anonymous:
use triggers
 
710 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 4 Provide the ability to pass a user-data value during sqlite_compile edit
It would be very useful to be able to pass a user-data value during the sqlite_compile command, that could then be retrieved in a user function. This would allow context-sensitive responses by the functions, by allowing them to know what "command" is executing them. I can provide further details if required.
 
707 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 3 how to use internal functions? edit
to name a few:

  1. "SELECT @@CHECK_INTEGRITY", it will return the integrity of the database.

  2. "SELECT @@DATABASE_VERSION", it will return the version of the database.

  3. "SELECT @@ENGINE_VERSION", it will return the current version of the sqlite engine

  4. "SELECT @@ENGINE_ENCODING", it will return the encoding of the sqlite engine.

etc.

 
699 new active 2004 Apr anonymous   2004 Apr   5 4 Data types and implicit conversions edit
I am a long-time (since 1986 ...) Oracle user and I tend to use Oracle, definitely more than MySQL, as my reference.

I currently have a project of writing a SQL*Plus-like interface to SQLite, rather than the sqlite program, with the idea of providing people with something which can be used for educational purposes on hardware much less impressive than what the latest Oracle versions require.

Part of the project includes adding most of the (numerous) Oracle functions. I see dates as a major annoyance. I think that SQLite should be able to return DATE as a basic type besides TEXT and NUMERIC. I understand (even if I don't fully agree with) the type-less philosophy, but my belief is that, even if ordering doesn't belong to relational theory proper, a difference should be made where the expected ordering is different.

If DATE is recognized as a basic type, it should also allow some type-checking in functions, more importantly some integrity checking (preventing from entering 06/31/2004 for instance), as well as implicit conversions. Oracle uses a default DD-MON-YY date format (which can be redefined), any string conforming to the default format which is inserted into a DATE column becomes a date without any fuss. Of course, an explicit conversion can be obtained through TO_DATE().

Currently, having a consistent usage of dates in SQLite relies on the user's own discipline - good enough in a carefully written program, but not for an interactive interface.

2004-Apr-21 15:08:39 by anonymous:
You can let DBMS check the dates. But a good Front-End should check the date before trying a wrong 'insert' or 'update'.
 
169 new active 2002 Oct anonymous Unknown 2004 Apr anonymous 5 5 CE version edit
I've successfully ported sqlite to windows CE 3.0 using eVC3.5maybe it was already done ?) I have only modified os.c to take into account the unicode interface. I attach my modified file. Best regards Noel Frankinet
Can you attach the full modified source code for me ? (.zip) My personal e-mail is hensel@al.furb.br

Thanks ... Andri

 
673 new active 2004 Mar anonymous Shell 2004 Apr   4 3 Format .dump nicer (patch) edit
(I've already tried to mail this.So it goes here again.)I wanted the .dump and .schema commands to have niceroutput (better to read).So I wrote a small and simple formatter for sql.Note, that it is really simple, but should grok mostthings.Hope you like it.
 
682 new active 2004 Apr anonymous   2004 Apr   5 1 sqlite_aggregate_context() valid in xFunc callback routine edit
One of BIG limitations of SQL i suffer is that no information about previous row(s) is available in current row.

Supose a table


oChar | oNum
   a   |   3
   j   |   2
   w   |   4

i would like to get


oChar | oNum | SQLConcat(oChar) | SQLContSum(oNum)
   a   |   3   |         a         |         3
   j   |   2   |         aj        |         5
   w   |   4   |        ajw        |         9

If in xFunc routine sqlite_aggregate_context() were valid, then functions like SQLConcat and SQLContSum will be possible, and multi-instace-able.

BTW i see no advantage in using pUserData instead of any other global data, since it will be the same data for all instances of the function. Am i wrong?

Thank you for SQLite! Best regards. Marcelo

 
662 new active 2004 Mar anonymous   2004 Mar drh 5 5 Stored Procedures? edit
I know that sqlite demands not to support Stored Procedures, but why? it is quite good.
2005-Aug-30 20:23:58 by anonymous:
Stored procedures are becoming a standard practice with database development. Not supporting them in any form makes SQLite obsolete.


2005-Aug-30 20:43:25 by anonymous:
This is really something that deserves to be discussed on the mailing list.
 
660 new active 2004 Mar anonymous   2004 Mar   5 5 compression/encoding feature? edit
Would sqlite support built-in compression/encoding feature like http://www.sqliteplus.com/ does? and I think that the compression feature should use zlib which has source code.
2004-Mar-15 13:01:18 by anonymous:
I check http://www.sqliteplus.com/ and fount that they have these features:

1.Stored Procedures 2.Encryption 3.Compression 4.Binary encoding for BLOB data

will sqlite add these built-in features?

 
651 new active 2004 Mar anonymous   2004 Mar   5 4 Update optimisation edit
Possible optimisation on updates

I have a big table in my DB. One column is a number which, in my case, can be either 0 or 1

The statement

update info set new=0 where type='book'

always takes about 60 seconds to run (even though 'type' is indexed)

If I change the statement to

update info set new=0 where type='book' and new=1

it's usually almost instantaneous.

It looks as if SQLite is rewriting the row even though no actual data is being changed, so maybe the update code could be optimised to only rewrite the row if necessary.

 
645 new active 2004 Mar anonymous   2004 Mar   5 5 OpenWatcom makefile edit
  I have prepared initial version of makefile for OpenWatcom
  compiler. I use OpenWatcom 1.3 compiled from sources synced
  yesterday with OpenWatcom Perforce (CVS) server.
  SQLite.exe gets compiled and linked directly from
  sources in SQLite /src directory.
  To get compilation done you need two external tools:
   egrep - it could be find in source tree for OpenWatcom
   any wersion of awk.exe - I've used
       'gwk311b GNU Awk 3.1.1 for DJGPP v2'
   vi.exe editor in sed/ex/ed - like mode - vi is included
       in OpenWatcom package as standard editor.

  Please create directory /watcom under SQLite dir - on the same
  level as /src. Copy makefile to it and do wmake.

  To get lemon.c compiled with no errors I've had to change it.
  Please find attached diff file. Changes are cosmetic ones so it
  shouldn't broke anything:

  15,21d14
  < extern void qsort();
  < extern double strtod();
  < extern long strtol();
  < extern void free();
  < extern int access();
  < extern int atoi();
  < 
  43d35
  < void Action_add();
  377c369
  <   ap = (struct action *)msort(ap,&ap->next,actioncmp);
  ---
  >   ap = (struct action *)msort((char *)ap,(char **)&ap->next,actioncmp);
  814c806
  <     Action_add(&stp->ap,SHIFT,sp,newstp);
  ---
  >     Action_add(&stp->ap,SHIFT,sp,(char *)newstp);
  915c907
  <             Action_add(&stp->ap,REDUCE,lemp->symbols[j],cfp->rp);
  ---
  >             Action_add(&stp->ap,REDUCE,lemp->symbols[j],(char *)cfp->rp);
  1191c1183
  <   current = (struct config *)msort(current,&(current->next),Configcmp);
  ---
  >   current = (struct config *)msort((char *)current,(char **)&(current->next),Configcmp);
  1198c1190
  <   basis = (struct config *)msort(current,&(current->bp),Configcmp);
  ---
  >   basis = (struct config *)msort((char *)current,(char **)&(current->bp),Configcmp);
  1449a1442
  >   return (lem.errorcnt + lem.nconflict);

  Makefile is not the best one but it works. Futer version will be better.

  Bartosz Polednia
2004-Mar-04 09:32:30 by anonymous:

  I forgot to append makefile:

  #
  # OpenWatcom makefile for SQLite
  #
  # Bartosz Polednia
  #     bartosz@chill.com.pl
  #
  # 04.03.2004 - 0.01
  #

  # set database version
  SQLITEVERSION = 2.8.12

  # sqlite directory
  TOP = d:\!progs\sqlite

  #compiler settings
  CC = wcc386
  CCL = wcl386
  C_FLAGS = -wx -I$(TOP)\;.\
  CCL_FLAGS = $(C_FLAGS)
  EXE_OUTPUT = -fe

  # Should the database engine assume text is coded as UTF-8 or iso8859?
  #
  # ENCODING  = UTF8
  # ENCODING  = ISO8859
  ENCODING = ISO8859

  # Flags controlling use of the in memory btree implementation
  #
  # SQLITE_OMIT_INMEMORYDB is defined in order to omit the in-memory
  # red/black tree driver in the file btree_rb.c
  #
  # TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
  # default to file, 2 to default to memory, and 3 to force temporary
  # tables to always be in memory.
  #
  INMEMORYDB = 1
  INCOREFLAGS = -DTEMP_STORE=@TEMP_STORE@

  !ifeq $(INMEMORYDB) 0
  INCOREFLAGS += -DSQLITE_OMIT_INMEMORYDB=1
  !endif

  # You should not have to change anything below this line
  ###############################################################################

  all:	sqlite.h sqlite.lib sqlite.exe

  # Object files for the SQLite library.
  #
  LIBOBJ = attach.obj auth.obj btree.obj build.obj copy.obj date.obj &
  			delete.obj expr.obj func.obj hash.obj insert.obj &
  			main.obj opcodes.obj os.obj pager.obj parse.obj pragma.obj &
  			printf.obj random.obj select.obj table.obj tokenize.obj &
  			update.obj util.obj vacuum.obj vdbe.obj vdbeaux.obj &
  			where.obj trigger.obj btree_rb.obj

  # Only build the in-core DB if it is required.
  !ifeq $(INMEMORYDB) 1
  LIBOBJ += btree_rb.obj
  !endif

  # Header files used by all library source files.
  #
  HDR = sqlite.h $(TOP)\src\btree.h config.h $(TOP)\src\hash.h opcodes.h &
  		$(TOP)\src\os.h $(TOP)\src\sqliteInt.h $(TOP)\src\vdbe.h parse.h

  # Header files used by the VDBE submodule
  #
  VDBEHDR = $(HDR)$(TOP)\src\vdbeInt.h

  # This is the default Makefile target.  The objects listed here
  # are what get build when you type just "make" with no arguments.
  #
  sqlite.lib:	sqlite.h config.h parse.h opcodes.h lemon.exe $(LIBOBJ) 
  	for %i in ($(LIBOBJ)) do wlib sqlite.lib -+%i > nul

  sqlite.exe:	$(TOP)\src\shell.c sqlite.lib
  	$(CCL) $(CCL_FLAGS) $(TOP)\src\shell.c sqlite.lib  $(EXE_OUTPUT)=sqlite.exe 

  # Rules to build the LEMON compiler generator
  #
  lemon.exe:	lemon.c $(TOP)\tool\lempar.c
  	$(CCL) $(CCL_FLAGS) $(EXE_OUTPUT)=lemon.exe lemon.c
  	copy $(TOP)\tool\lempar.c .

  main.obj:	$(TOP)\src\main.c $(HDR)
  	$(CC) $(TOP)\src\main.c $(C_FLAGS)
  #	$(CC) $(TOP)\src\$[&.c $(C_FLAGS)
  #	${INCOREFLAGS}
  #	$(LTCOMPILE) -c ${INCOREFLAGS} $(TOP)\src\main.c

  opcodes.obj:	opcodes.c
  	$(CC) $[@ $(C_FLAGS)

  opcodes.c:	$(TOP)\src\vdbe.c
  	%create temp.vi
  	%write  temp.vi set magic
  	%append temp.vi set magicstring = ()
  	%append temp.vi atomic
  	%append temp.vi %s/^.*OP_/  "/
  	%append temp.vi %s/:.*$$/", /
  	%append temp.vi x
  	%create opcodes.c
  	%write  opcodes.c /* Automatically generated file.  Do not edit */
  	%write  opcodes.c char *sqliteOpcodeNames[] = { "???", 
  	egrep "^case OP_" $(TOP)\src\vdbe.c > opcodes.tmp
  	vi -s temp.vi opcodes.tmp
  	rm temp.vi
        copy opcodes.c+opcodes.tmp opcodes.c
  	echo }; >> opcodes.c 
  	rm opcodes.tmp

  opcodes.h:	$(TOP)\src\vdbe.h $(TOP)\src\vdbe.c
  	%create temp.vi
  	%write  temp.vi set magic
  	%append temp.vi set magicstring = ()
  	%append temp.vi atomic
  	%append temp.vi %s/://
  	%append temp.vi x
  	%create opcodes.h
  	%write  opcodes.h /* Automatically generated file.  Do not edit */
  	egrep "^case OP_" $(TOP)\src\vdbe.c > opcodes.tmp
  	vi -s temp.vi opcodes.tmp
  	rm temp.vi
        awk '{printf "$#define %-30s %3d\n", $$2, ++cnt}' opcodes.tmp > temp.awk
        type temp.awk >> opcodes.h
  	rm opcodes.tmp
  	rm temp.awk

  parse.obj:	parse.c $(HDR)
  	$(CC) $[@ $(C_FLAGS) -I$(TOP)\src\	

  parse.h:	parse.c
  	@echo parse.h

  parse.c:	$(TOP)\src\parse.y lemon.exe
  	copy $(TOP)\src\parse.y .
  	.\lemon .\parse.y
  	rm parse.y
  	rm lempar.c

  # The config.h file will contain a single #define that tells us how
  # many bytes are in a pointer.  This only works if a pointer is the
  # same size on the host as it is on the target.  If you are cross-compiling
  # to a target with a different pointer size, you'll need to manually
  # configure the config.h file.
  #
  config.h:	
  	%write  temp.c $#include <stdio.h>
  	%append temp.c int main(){
  	%append temp.c printf("$#define SQLITE_PTR_SZ %d\n",sizeof(char*));
  	%append temp.c return (0);}
  	$(CCL) $(C_FLAGS) $(EXE_OUTPUT)=temp.exe temp.c
  	.\temp.exe >config.h
  	rm -f temp.c temp.exe temp.obj

  sqlite.h:	$(TOP)\src\sqlite.h.in 
      copy $(TOP)\src\sqlite.h.in sqlite.h
  	%create temp.vi
  	%write  temp.vi set magic
  	%append temp.vi set magicstring = ()
  	%append temp.vi atomic
  	%append temp.vi %s/--VERS--/$(SQLITEVERSION)/
  	%append temp.vi %s/--ENCODING--/$(ENCODING)/
  	%append temp.vi x
  	vi -s temp.vi sqlite.h
  	rm temp.vi

  .c:     $(TOP)\src\
  #

  .c.obj:
  	$(CC) $(TOP)\src\$[&.c $(C_FLAGS)

Bartosz

 
638 new active 2004 Mar anonymous   2004 Mar   5 5 Lemon.c could not be compiled - source dated 27.02.2004 edit
I try to prepare makefile for OpenWatcom 1.3 and compile SQLite using standard source tree but compilation of lemon ends as in the attachment.

Bartosz Polednia

2004-Mar-01 07:57:58 by anonymous:
Open Watcom Make Version 1.3beta1 Limited Availability Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved. Source code is available under the Sybase Open Watcom Public License.

See http://www.openwatcom.org/ for details.

	wcl386 -wx -zm -fe=lemon.exe d:\!progs\sqlite\tool\lemon.c
Open Watcom C/C++32 Compile and Link Utility Version 1.3beta1 LA
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
       wcc386 d:\!progs\sqlite\tool\lemon.c  -wx -zm
Open Watcom C32 Optimizing Compiler Version 1.3beta1 LA
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
d:\!progs\sqlite\tool\lemon.c(814): Error! E1071: Type of parameter 4 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(814): Note! N2003: source conversion type is 'struct state *'
d:\!progs\sqlite\tool\lemon.c(814): Note! N2004: target conversion type is 'char *'
d:\!progs\sqlite\tool\lemon.c(915): Error! E1071: Type of parameter 4 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(915): Note! N2003: source conversion type is 'struct rule *'
d:\!progs\sqlite\tool\lemon.c(915): Note! N2004: target conversion type is 'char *'
d:\!progs\sqlite\tool\lemon.c(1450): Warning! W107: Missing return value for function 'main'
d:\!progs\sqlite\tool\lemon.c(377): Error! E1071: Type of parameter 1 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(377): Note! N2003: source conversion type is 'struct action *'
d:\!progs\sqlite\tool\lemon.c(377): Note! N2004: target conversion type is 'char *'
d:\!progs\sqlite\tool\lemon.c(377): Note! N2002: 'msort' defined in: d:\!progs\sqlite\tool\lemon.c(1547)
d:\!progs\sqlite\tool\lemon.c(377): Error! E1071: Type of parameter 2 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(377): Note! N2003: source conversion type is 'struct action **'
d:\!progs\sqlite\tool\lemon.c(377): Note! N2004: target conversion type is 'char **'
d:\!progs\sqlite\tool\lemon.c(1191): Error! E1071: Type of parameter 1 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(1191): Note! N2003: source conversion type is 'struct config *'
d:\!progs\sqlite\tool\lemon.c(1191): Note! N2004: target conversion type is 'char *'
d:\!progs\sqlite\tool\lemon.c(1191): Note! N2002: 'msort' defined in: d:\!progs\sqlite\tool\lemon.c(1547)
d:\!progs\sqlite\tool\lemon.c(1191): Error! E1071: Type of parameter 2 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(1191): Note! N2003: source conversion type is 'struct config **'
d:\!progs\sqlite\tool\lemon.c(1191): Note! N2004: target conversion type is 'char **'
d:\!progs\sqlite\tool\lemon.c(1198): Error! E1071: Type of parameter 1 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(1198): Note! N2003: source conversion type is 'struct config *'
d:\!progs\sqlite\tool\lemon.c(1198): Note! N2004: target conversion type is 'char *'
d:\!progs\sqlite\tool\lemon.c(1198): Note! N2002: 'msort' defined in: d:\!progs\sqlite\tool\lemon.c(1547)
d:\!progs\sqlite\tool\lemon.c(1198): Error! E1071: Type of parameter 2 does not agree with previous definition
d:\!progs\sqlite\tool\lemon.c(1198): Note! N2003: source conversion type is 'struct config **'
d:\!progs\sqlite\tool\lemon.c(1198): Note! N2004: target conversion type is 'char **'
d:\!progs\sqlite\tool\lemon.c: 4388 lines, included 1949, 1 warnings, 8 errors
Error: Compiler returned a bad status compiling 'd:\!progs\sqlite\tool\lemon.c'


2004-Mar-01 11:20:38 by anonymous:

  The code is K&R style with mismatched prototypes eg.:
  ......
  extern void qsort();
  extern double strtod();
  extern long strtol();
  extern void free();
  extern int access();
  extern int atoi();
  ........
  void Action_add();
  .....
  void Action_add(app,type,sp,arg)
    struct action **app;
    enum e_action type;
    struct symbol *sp;
    char *arg;
  {

Bartosz


2004-Mar-01 13:15:19 by drh:
Lemon was written before ANSI C compilers were widely available. It uses char* where void* would be more appropriate, because void* was not available on common compilers when lemon was written.

Probably there is an option to Watcom to get it to accept char* in place of void*. I am disinclined to rewrite lemon to accomodate a compiler which I do not use.

 
611 new active 2004 Feb anonymous VDBE 2004 Feb   1 3 Remove giant SWITCH statement in VM for better portability edit
This is not really a bug but a major drawback to the platform portability of SQLite. Specifically, this relates to the ease of support for segmented architectures such as Palm OS. The problem is that the enormous SWITCH statement in the sqliteVdbeExec() function contains more than 64K of code. In a 64K segmented architecture this exceeds the code segment limit and the ONLY workaround is to break up the code into subfunctions. This is not an easy task.

At present our "workaround" involves creating a "context" data structure that holds necessary state for execution (essentially the locals of sqliteVdbeExec()) then running an elaborate AWK script that parses each CASE in the switch statement and generates a separate function for the CASE that receives the execution context structure (functions are indexed by opcode for speed). This, followed by some hand tuning is our process of porting whenever we need to pick up a new release of SQLite. Over time this has proven to be the easiest way to integrate new releases, however, it is far from optimial and because of the non-automated steps involved, bug prone.

After making this change the SQLite engine runs fine on the Palm OS segmented architecture and suffers no visible performance drawbacks. If a similar approach were to be integrated directly into the SQLite codebase it would GREATLY improve the portability of the engine.

2004-Feb-16 23:05:07 by drh:
I experimented with using separate functions for each opcode and found the results to be about 20% slower than using a switch on GCC for i386. So changing the code to use functions only is clearly not an option for most users.

Modifying the code so that it could be compiled either way would complicate the code and it would eliminate the opportunity to use persistent local variables. If absolutely necessary, this could be tolerated. But is it really necessary?

The sqliteVdbeExec() function is only about 21K in size when compiled using GCC for i386 - less than a third of the maximum size allowed by PalmOS. Why is it so much bigger on Palm? Wouldn't a better approch to this problem be to fix the compiler on the Palm so that it generated binaries of a more modest size? Surely the Palm does not require more than three times the code space as an i386.

Is there a GCC implementation available that targets palm? Have you tried compiling using it?


2004-Mar-24 11:22:01 by anonymous:
>Why is it so much bigger on Palm?

The reason is not the compiler, but processor architecture. Palm's processor is a RISC (reduced instruction set computer) processor (in opposite to x86 CICS (complex instruction set compute)). That means that in general RISC code is much bigger, because action performed by one CISC instruction, takes several RISC instructions to do the same.


2006-Jun-06 18:38:46 by anonymous:
Perhaps the "workaround" could be implemented as a Palm-specific build script, augmented by some source-level "hints" (ala lint comments) to automate the tasks currently hand-tuned.
 
590 new active 2004 Jan anonymous Parser 2004 Jan   5 4 Treat ` like spaces outside of quoted strings. edit
Mysql allows the usage of ` for quoting field names in queries. SQLite interrupts with "unrecognized token". To improve compatibility with mysql ` should either be handled correctly or simply ignored.

For ignoring ` the following code can be used:

	case ' ': case '\t': case '\n': case '\f': case '\r': case '`': {
      for(i=1; isspace(z[i]) || z[i] == '`'; i++){}

starting at line 224 in tokenize.c

I know that this is a dirty enhancement but the structure of tokenize.c is rather unknown to me...

 
588 new active 2004 Jan anonymous   2004 Jan   5 4 Please provide support for NULLS LAST in ORDER BY clauses. edit
Would be nice to be able to specify NULLS LAST in ORDER BY clauses to force nulls to end of sort order. (Oracle provides this feature)
 
93 new active 2002 Jul anonymous   2004 Jan   3 3 Can't open database when TEMP environment variable is not defined well edit
This happened on WIN32 but is relevant to unix too. When the TEMP variable is not configured well the GetTempPath returns it without any checking that the directory exists. The error the database returns is something like "can't find table sqlite_temp_master" while the real error is that the temporary file couldn't be created.

For security reason, the best practice is to give the application to set the temp directory. Then as the application writter I know where all the relevant sqlite files will be created and have full control of it. I will be happy to do the fix (If you find it suitable). Thanks in advanced Avner

This happens always when using sqlite from a NT / Win2000 / XP service since they don't resolve the default TEMP directory var.
 
572 new active 2004 Jan anonymous Unknown 2004 Jan drh 3 3 sqlite 2.8.11 port to djgpp edit
hello friends

here is a patch to be applied to sqlite 2.8.11 to work with djgpp in a short file names environment.

it's a very small piece of code patches, but i will explicitly stick to the sqlite copyright policy:

The author or authors of this code dedicate any and all copyright interest in this code to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights this code under copyright law.

please apply this patch to the mainstream sources, for the benefit of all dos djgpp users.

best regards,

alex

 
566 new active 2004 Jan anonymous Unknown 2004 Jan   4 4 [PATCH] Port of sqlite and lemon to an EBCDIC mainframe edit
I have ported sqlite (and lemon - to bootstrap sqlite) to a mainframe which features a POSIX subsystem, but in which all files are stored in EBCDIC, not in ASCII. Very few places in sqlite have codeset dependencies, so the resulting patch is rather small.

I have not tested tcl (lacking a tcl-ebcdic port). I tested with a 3MB database of german bank codes and compared against a FreeBSD ASCII version.

The diffs for lemon are ~280 lines.

    Martin Kraemer
The Attachment contains the complete patch to make 2.8.9...2.8.11 compile & run on our EBCDIC platform.
 
563 new active 2004 Jan anonymous Parser 2004 Jan   4 3 Support for autoincrement type "SERIAL" (from PostgreSQL) edit
I am porting my application from PostgreSQL to SQLite but I want to keep it backwards compatible. With PostgreSQL autoincrement fields are created with type SERIAL. For example:

    CREATE TABLE t1( a SERIAL PRIMARY KEY, b INTEGER);

And statements like:

    INSERT INTO t1 VALUES(default,123);

are used to create rows with automatically increased ids.

 
550 new active 2004 Jan anonymous Unknown 2004 Jan anonymous 1 1 change of MASTER_NAME and TEMP_MASTER_NAME definition error edit
sqlite_master and sqlite_temp_master table name are directly use in main.c, shell.c and vacuum.c so when i try to change MASTER_NAME and TEMP_MASTER_NAME definition in the sqliteInt.h file it returns some errors.

so i replace sqlite_master and sqlite_master_table by "MASTER_NAME" and "TEMP_MASTER_NAME" to solve my problem in

main.c

  • at line 195 in static char master_schema[] (in sqliteInitOne)
  • at line 203 in static char temp_master_schema[] (in sqliteInitOne)
  • at lines 228,230 in static char init_script[] (in sqliteInitOne)
  • at lines 232,234,237 in static char older_init_script[] (in sqliteInitOne)
  • at line 344 in sqliteInitOne
  • at line 492 in sqlite_open

vacuum.c

  • at line 293 in int sqliteRunVacuum
  • at line 296 in int sqliteRunVacuum

shell.c

  • at line 584 in static int do_meta_command
  • at line 293 in static int do_meta_command
  • at lines 793,795,831,832,872,875,882,885 in static int do_meta_command
 
544 new active 2004 Jan anonymous   2004 Jan   5 4 Feature Request: Indicate UNIQUE columns in table_info. edit
I goofed with ticket #543. I meant that I thought it would be neat if we had a new column in table_info indicating which columns were UNIQUE. Sorry about that.
 
539 new active 2003 Dec anonymous VDBE 2003 Dec   5 4 Addition of engine 'Suspension' interface edit
For my use of SQLite I require that the engine be suspended temporarily such that other tasks can be performed. At present SQLite has the ability to be interrupted - stopping the current VM in its tracks and aborting whatever it was doing. This isn't what I required - I just need it to stop doing what it was doing and return to me.

As the system is implemented as a Virtual Machine and is already capable of being suspended by in order to return its results, the suspension of the engine is relatively simple.

The implementation I have used will return the code 'SQLITE_SUSPEND' from an sqlite_step() call if the operation has been suspended. The function sqlite_suspend(sqlite_vm *) is provided to set a flag which will cause the suspend to take effect.

The intended use is within an environment where a co-operative environment where SQLite can run for a period before and interrupt triggers the sqlite_suspend() function. Thus the caller can know that the operation is progressing but no results have been returned before the timeout.

I can create diffs, or supply other information about the information if necessary. Sadly I've only tried this with the sqlite_step() interface, because that's all I've needed it with. My examination of the code implies that it is safe to perform this suspension in this manner, and it has worked very well within my application.

I don't know if it would be of use to others, but I can at least offer it back to anyone who might find a use for it.

 
538 new active 2003 Dec anonymous   2003 Dec   4 3 Different warnings in windows edit
If you want the file, please contact me & I'm happy to send it through

[c:\]diff -up "C:\C++ Programs\DELISprint\SQLite" "sqlite_source_windows" > "new SQLite.txt"

------------------------------------------------diff code

diff -up C:\C++ Programs\DELISprint\SQLite/btree.c sqlite_source_windows/btree.c
--- C:\C++ Programs\DELISprint\SQLite/btree.c	Tue Dec 30 22:58:12 2003
+++ sqlite_source_windows/btree.c	Wed Dec 17 19:37:30 2003
@@ -65,7 +65,7 @@ static BtCursorOps sqliteBtreeCursorOps;
 ** X is an unsigned integer.  SWAB16 byte swaps a 16-bit integer.
 ** SWAB32 byteswaps a 32-bit integer.
 */
-#define SWAB16(B,X)   ((B)->needSwab? swab16((u16)(X)) : (u16)(X))
+#define SWAB16(B,X)   ((B)->needSwab? swab16((u16)X) : ((u16)X))
 #define SWAB32(B,X)   ((B)->needSwab? swab32(X) : (X))
 #define SWAB_ADD(B,X,A) \
    if((B)->needSwab){ X=swab32(swab32(X)+A); }else{ X += (A); }
@@ -538,7 +538,7 @@ static void freeSpace(Btree *pBt, MemPag
       if( idx + iSize + size == SWAB16(pBt, pFBlk->iNext) ){
         pNext = (FreeBlk*)&pPage->u.aDisk[idx + iSize + size];
         if( pBt->needSwab ){
-          pFBlk->iSize = swab16((u16)(swab16(pNext->iSize)+iSize+size));
+          pFBlk->iSize = swab16((u16)swab16(pNext->iSize)+iSize+size);
         }else{
           pFBlk->iSize += pNext->iSize;
         }
diff -up C:\C++ Programs\DELISprint\SQLite/date.c sqlite_source_windows/date.c
--- C:\C++ Programs\DELISprint\SQLite/date.c	Tue Dec 30 22:53:08 2003
+++ sqlite_source_windows/date.c	Wed Dec 17 19:37:30 2003
@@ -230,8 +230,8 @@ static void computeJD(DateTime *p){
   }
   A = Y/100;
   B = 2 - A + (A/4);
-  X1 = (int)(365.25*(Y+4716));
-  X2 = (int)(30.6001*(M+1));
+  X1 = 365.25*(Y+4716);
+  X2 = 30.6001*(M+1);
   p->rJD = X1 + X2 + D + B - 1524.5;
   p->validJD = 1;
   p->validYMD = 0;
@@ -335,14 +335,14 @@ static int parseDateOrTime(const char *z
 static void computeYMD(DateTime *p){
   int Z, A, B, C, D, E, X1;
   if( p->validYMD ) return;
-  Z = (int)(p->rJD + 0.5);
-  A = (int)((Z - 1867216.25)/36524.25);
+  Z = p->rJD + 0.5;
+  A = (Z - 1867216.25)/36524.25;
   A = Z + 1 + A - (A/4);
   B = A + 1524;
-  C = (int)((B - 122.1)/365.25);
-  D = (int)(365.25*C);
-  E = (int)((B-D)/30.6001);
-  X1 = (int)(30.6001*E);
+  C = (B - 122.1)/365.25;
+  D = 365.25*C;
+  E = (B-D)/30.6001;
+  X1 = 30.6001*E;
   p->D = B - D - X1;
   p->M = E<14 ? E-1 : E-13;
   p->Y = p->M>2 ? C - 4716 : C - 4715;
@@ -355,10 +355,10 @@ static void computeYMD(DateTime *p){
 static void computeHMS(DateTime *p){
   int Z, s;
   if( p->validHMS ) return;
-  Z = (int)(p->rJD + 0.5);
-  s = (int)((p->rJD + 0.5 - Z)*86400000.0 + 0.5);
+  Z = p->rJD + 0.5;
+  s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5;
   p->s = 0.001*s;
-  s = (int)(p->s);
+  s = p->s;
   p->s -= s;
   p->h = s/3600;
   s -= p->h*3600;
@@ -422,14 +422,14 @@ static int parseModifier(const char *zMo
       ** to "start of day".
       */
       if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0
-                 && (n=(int)(r))==r && n>=0 && r<7 ){
+                 && (n=r)==r && n>=0 && r<7 ){
         int Z;
         computeYMD(p);
         p->validHMS = 0;
         p->validTZ = 0;
         p->validJD = 0;
         computeJD(p);
-        Z = (int)(p->rJD + 1.5);
+        Z = p->rJD + 1.5;
         Z %= 7;
         if( Z>n ) Z -= 7;
         p->rJD += n - Z;
@@ -503,19 +503,19 @@ static int parseModifier(const char *zMo
       }else if( n==5 && strcmp(z,"month")==0 ){
         int x, y;
         computeYMD(p);
-        p->M += (int)(r);
+        p->M += r;
         x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
         p->Y += x;
         p->M -= x*12;
         p->validJD = 0;
         computeJD(p);
-        y = (int)(r);
+        y = r;
         if( y!=r ){
           p->rJD += (r - y)*30.0;
         }
       }else if( n==4 && strcmp(z,"year")==0 ){
         computeYMD(p);
-        p->Y += (int)(r);
+        p->Y += r;
         p->validJD = 0;
         computeJD(p);
       }else{
@@ -691,8 +691,8 @@ static void strftimeFunc(sqlite_func *co
       switch( zFmt[i] ){
         case 'd':  sprintf(&z[j],"%02d",x.D); j+=2; break;
         case 'f': {
-          int s = (int)(x.s);
-          int ms = (int)((x.s - s)*1000.0);
+          int s = x.s;
+          int ms = (x.s - s)*1000.0;
           sprintf(&z[j],"%02d.%03d",s,ms);
           j += strlen(&z[j]);
           break;
@@ -706,7 +706,7 @@ static void strftimeFunc(sqlite_func *co
           y.M = 1;
           y.D = 1;
           computeJD(&y);
-          n = (int)(x.rJD - y.rJD + 1);
+          n = x.rJD - y.rJD + 1;
           if( zFmt[i]=='W' ){
             sprintf(&z[j],"%02d",(n+6)/7);
             j += 2;
diff -up C:\C++ Programs\DELISprint\SQLite/os.c sqlite_source_windows/os.c
--- C:\C++ Programs\DELISprint\SQLite/os.c	Tue Dec 30 22:42:48 2003
+++ sqlite_source_windows/os.c	Wed Dec 17 19:37:30 2003
@@ -258,7 +258,7 @@ int sqliteOsDelete(const char *zFilename
   unlink(zFilename);
 #endif
 #if OS_WIN
-  DeleteFileA(zFilename);
+  DeleteFile(zFilename);
 #endif
 #if OS_MAC
   unlink(zFilename);
@@ -274,7 +274,7 @@ int sqliteOsFileExists(const char *zFile
   return access(zFilename, 0)==0;
 #endif
 #if OS_WIN
-  return GetFileAttributesA(zFilename) != 0xffffffff;
+  return GetFileAttributes(zFilename) != 0xffffffff;
 #endif
 #if OS_MAC
   return access(zFilename, 0)==0;
@@ -350,7 +350,7 @@ int sqliteOsOpenReadWrite(
   return SQLITE_OK;
 #endif
 #if OS_WIN
-  HANDLE h = CreateFileA(zFilename,
+  HANDLE h = CreateFile(zFilename,
      GENERIC_READ | GENERIC_WRITE,
      FILE_SHARE_READ | FILE_SHARE_WRITE,
      NULL,
@@ -359,7 +359,7 @@ int sqliteOsOpenReadWrite(
      NULL
   );
   if( h==INVALID_HANDLE_VALUE ){
-    h = CreateFileA(zFilename,
+    h = CreateFile(zFilename,
        GENERIC_READ,
        FILE_SHARE_READ,
        NULL,
@@ -482,7 +482,7 @@ int sqliteOsOpenExclusive(const char *zF
   }else{
     fileflags = FILE_FLAG_RANDOM_ACCESS;
   }
-  h = CreateFileA(zFilename,
+  h = CreateFile(zFilename,
      GENERIC_READ | GENERIC_WRITE,
      0,
      NULL,
@@ -556,7 +556,7 @@ int sqliteOsOpenReadOnly(const char *zFi
   return SQLITE_OK;
 #endif
 #if OS_WIN
-  HANDLE h = CreateFileA(zFilename,
+  HANDLE h = CreateFile(zFilename,
      GENERIC_READ,
      0,
      NULL,
@@ -679,7 +679,7 @@ int sqliteOsTempFileName(char *zBuf){
     "0123456789";
   int i, j;
   char zTempPath[SQLITE_TEMPNAME_SIZE];
-  GetTempPathA(SQLITE_TEMPNAME_SIZE-30, zTempPath);
+  GetTempPath(SQLITE_TEMPNAME_SIZE-30, zTempPath);
   for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
   zTempPath[i] = 0;
   for(;;){
@@ -899,8 +899,8 @@ int sqliteOsSeek(OsFile *id, off_t offse
 #endif
 #if OS_WIN
   {
-    LONG upperBits = (LONG) (offset>>32);
-    LONG lowerBits = (LONG) (offset & 0xffffffff);
+    LONG upperBits = offset>>32;
+    LONG lowerBits = offset & 0xffffffff;
     DWORD rc;
     rc = SetFilePointer(id->h, lowerBits, &upperBits, FILE_BEGIN);
     /* TRACE3("SEEK rc=0x%x upper=0x%x\n", rc, upperBits); */
@@ -991,8 +991,8 @@ int sqliteOsTruncate(OsFile *id, off_t n
 #endif
 #if OS_WIN
   {
-    LONG upperBits = (LONG) (nByte>>32);
-    SetFilePointer(id->h, (LONG) (nByte), &upperBits, FILE_BEGIN);
+    LONG upperBits = nByte>>32;
+    SetFilePointer(id->h, nByte, &upperBits, FILE_BEGIN);
     SetEndOfFile(id->h);
   }
   return SQLITE_OK;
@@ -1576,10 +1576,10 @@ char *sqliteOsFullPathname(const char *z
   char *zNotUsed;
   char *zFull;
   int nByte;
-  nByte = GetFullPathNameA(zRelative, 0, 0, &zNotUsed) + 1;
+  nByte = GetFullPathName(zRelative, 0, 0, &zNotUsed) + 1;
   zFull = sqliteMalloc( nByte );
   if( zFull==0 ) return 0;
-  GetFullPathNameA(zRelative, nByte, zFull, &zNotUsed);
+  GetFullPathName(zRelative, nByte, zFull, &zNotUsed);
   return zFull;
 #endif
 #if OS_MAC
diff -up C:\C++ Programs\DELISprint\SQLite/pager.c sqlite_source_windows/pager.c
--- C:\C++ Programs\DELISprint\SQLite/pager.c	Tue Dec 30 22:45:48 2003
+++ sqlite_source_windows/pager.c	Wed Dec 17 19:37:30 2003
@@ -599,17 +599,17 @@ static int pager_playback(Pager *pPager,
     rc = read32bits(format, &pPager->jfd, &pPager->cksumInit);
     if( rc ) goto end_playback;
     if( nRec==0xffffffff || useJournalSize ){
-      nRec = (int) ((szJ - JOURNAL_HDR_SZ(3))/JOURNAL_PG_SZ(3));
+      nRec = (szJ - JOURNAL_HDR_SZ(3))/JOURNAL_PG_SZ(3);
     }
   }else{
-    nRec = (int) ((szJ - JOURNAL_HDR_SZ(2))/JOURNAL_PG_SZ(2));
+    nRec = (szJ - JOURNAL_HDR_SZ(2))/JOURNAL_PG_SZ(2);
     assert( nRec*JOURNAL_PG_SZ(2)+JOURNAL_HDR_SZ(2)==szJ );
   }
   rc = read32bits(format, &pPager->jfd, &mxPg);
   if( rc!=SQLITE_OK ){
     goto end_playback;
   }
-  assert( pPager->origDbSize==0 || pPager->origDbSize==(int)(mxPg) );
+  assert( pPager->origDbSize==0 || pPager->origDbSize==mxPg );
   rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)mxPg);
   if( rc!=SQLITE_OK ){
     goto end_playback;
@@ -717,7 +717,7 @@ static int pager_ckpt_playback(Pager *pP
   if( rc!=SQLITE_OK ){
     goto end_ckpt_playback;
   }
-  nRec = (int)((szJ - pPager->ckptJSize)/JOURNAL_PG_SZ(journal_format));
+  nRec = (szJ - pPager->ckptJSize)/JOURNAL_PG_SZ(journal_format);
   for(i=nRec-1; i>=0; i--){
     rc = pager_playback_one_page(pPager, &pPager->jfd, journal_format);
     if( rc!=SQLITE_OK ){
@@ -925,9 +925,9 @@ int sqlitepager_pagecount(Pager *pPager)
   }
   n /= SQLITE_PAGE_SIZE;
   if( pPager->state!=SQLITE_UNLOCK ){
-    pPager->dbSize = (int)(n);
+    pPager->dbSize = n;
   }
-  return (int)(n);
+  return n;
 }
 
 /*
diff -up C:\C++ Programs\DELISprint\SQLite/parse.c sqlite_source_windows/parse.c
--- C:\C++ Programs\DELISprint\SQLite/parse.c	Tue Dec 30 23:00:24 2003
+++ sqlite_source_windows/parse.c	Wed Dec 17 19:37:30 2003
@@ -3982,7 +3982,7 @@ void sqliteParser(
              yyTracePrompt,yyTokenName[yymajor]);
         }
 #endif
-        yy_destructor((YYCODETYPE)(yymajor),&yyminorunion);
+        yy_destructor(yymajor,&yyminorunion);
         yymajor = YYNOCODE;
       }else{
          while(
@@ -3993,7 +3993,7 @@ void sqliteParser(
           yy_pop_parser_stack(yypParser);
         }
         if( yypParser->yyidx < 0 || yymajor==0 ){
-          yy_destructor((YYCODETYPE)(yymajor),&yyminorunion);
+          yy_destructor(yymajor,&yyminorunion);
           yy_parse_failed(yypParser);
           yymajor = YYNOCODE;
         }else if( yypParser->yytop->major!=YYERRORSYMBOL ){
diff -up C:\C++ Programs\DELISprint\SQLite/select.c sqlite_source_windows/select.c
--- C:\C++ Programs\DELISprint\SQLite/select.c	Tue Dec 30 22:46:48 2003
+++ sqlite_source_windows/select.c	Wed Dec 17 19:37:30 2003
@@ -98,7 +98,7 @@ int sqliteJoinType(Parse *pParse, Token 
   for(i=0; i<3 && apAll[i]; i++){
     p = apAll[i];
     for(j=0; j<sizeof(keywords)/sizeof(keywords[0]); j++){
-      if( (int)(p->n)==keywords[j].nChar 
+      if( p->n==keywords[j].nChar 
           && sqliteStrNICmp(p->z, keywords[j].zKeyword, p->n)==0 ){
         jointype |= keywords[j].code;
         break;
diff -up C:\C++ Programs\DELISprint\SQLite/vdbe.c sqlite_source_windows/vdbe.c
--- C:\C++ Programs\DELISprint\SQLite/vdbe.c	Tue Dec 30 22:53:08 2003
+++ sqlite_source_windows/vdbe.c	Wed Dec 17 19:37:30 2003
@@ -1292,7 +1292,7 @@ case OP_MustBeInt: {
   if( aStack[tos].flags & STK_Int ){
     /* Do nothing */
   }else if( aStack[tos].flags & STK_Real ){
-    int i = (int)(aStack[tos].r);
+    int i = aStack[tos].r;
     double r = (double)i;
     if( r!=aStack[tos].r ){
       goto mismatch;
@@ -1307,7 +1307,7 @@ case OP_MustBeInt: {
       }
       Realify(p, tos);
       assert( (aStack[tos].flags & STK_Real)!=0 );
-      v = (int)(aStack[tos].r);
+      v = aStack[tos].r;
       r = (double)v;
       if( r!=aStack[tos].r ){
         goto mismatch;

------------------------------------------------diff code

 
477 new active 2003 Oct anonymous   2003 Dec anonymous 4 4 Are there any plans to enchance SQLite to support Unicode edit
Hi,

Are there any plans to enchance SQLite to support UNICODE. Did anyone try and had any problems.

I would like to use SQLite in my embedded device. I might have to modify SQLite to support UNICODE. If anyone has any points please let me know.

Thanks,

Use UTF8 encoding, which doesn't require 0 values, and is especially efficient for encoding ASCII text.


But sqlite_exec takes a char* for SQL statement. Do I need to change this peace of code or is anything simple that can be done so that I can pass unicode information


UTF8 encoding looks like a normal ASCIIZ string; the NUL byte is not valid UTF8 encoding, and therefore any UTF8 string can be given to SQLite, which only cares that the data be an ASCIIZ string.


Will SELCT lower(text), upper(text) works ? I suppouse NO... Support of unicode in some form is needed. There is no hack way to do this my client side.
 
404 new active 2003 Jul anonymous   2003 Dec   3 3 new C API: sqlite_get_table_with_types with type information edit
Patches for a new C API function: sqlite_get_table_with_types, which is like sqlite_get_table but also adds type information in the return data which apepars right after the column names.

Implementation (patch is against 2.8.3) is almost zero overhead and only needs an extra few lines:

	--- table.c.old	Sun Jul 13 11:59:18 2003
	+++ table.c	Sun Jul 13 14:54:13 2003
	@@ -33,6 +33,7 @@
	   int nColumn;
	   int nData;
	   int rc;
	+  int headHasType;
	 } TabResult;

	 /*
	@@ -50,7 +51,7 @@
	   ** we need to remember from this invocation of the callback.
	   */
	   if( p->nRow==0 && argv!=0 ){
	-    need = nCol*2;
	+    need = nCol * (p->headHasType ? 3 : 2);
	   }else{
		 need = nCol;
	   }
	@@ -69,8 +70,9 @@
	   ** the names of all columns.
	   */
	   if( p->nRow==0 ){
	+    int cols_top = (p->headHasType ? nCol * 2 : nCol);
		 p->nColumn = nCol;
	-    for(i=0; i<nCol; i++){
	+    for(i=0; i<cols_top; i++){
		   if( colv[i]==0 ){
			 z = 0;
		   }else{
	@@ -121,13 +123,14 @@
	 ** Instead, the entire table should be passed to sqlite_free_table() when
	 ** the calling procedure is finished using it.
	 */
	-int sqlite_get_table(
	+static int sqlite_get_table_common(
	   sqlite *db,                 /* The database on which the SQL executes */
	   const char *zSql,           /* The SQL to be executed */
	   char ***pazResult,          /* Write the result table here */
	   int *pnRow,                 /* Write the number of rows in the result here */
	   int *pnColumn,              /* Write the number of columns of result here */
	-  char **pzErrMsg             /* Write error messages here */
	+  char **pzErrMsg,            /* Write error messages here */
	+  int headerHasTypes          /* set to 1 to return types after col names; else set to 0 */
	 ){
	   int rc;
	   TabResult res;
	@@ -141,6 +144,7 @@
	   res.nColumn = 0;
	   res.nData = 1;
	   res.nAlloc = 20;
	+  res.headHasType = headerHasTypes;
	   res.rc = SQLITE_OK;
	   res.azResult = malloc( sizeof(char*)*res.nAlloc );
	   if( res.azResult==0 ){
	@@ -199,4 +203,26 @@
		 for(i=1; i<n; i++){ if( azResult[i] ) free(azResult[i]); }
		 free(azResult);
	   }
	+}
	+
	+int sqlite_get_table(
	+  sqlite *db,                 /* The database on which the SQL executes */
	+  const char *zSql,           /* The SQL to be executed */
	+  char ***pazResult,          /* Write the result table here */
	+  int *pnRow,                 /* Write the number of rows in the result here */
	+  int *pnColumn,              /* Write the number of columns of result here */
	+  char **pzErrMsg             /* Write error messages here */
	+){
	+  return sqlite_get_table_common(db, zSql, pazResult, pnRow, pnColumn, pzErrMsg, 0);
	+}
	+
	+int sqlite_get_table_with_types(
	+  sqlite *db,                 /* The database on which the SQL executes */
	+  const char *zSql,           /* The SQL to be executed */
	+  char ***pazResult,          /* Write the result table here */
	+  int *pnRow,                 /* Write the number of rows in the result here */
	+  int *pnColumn,              /* Write the number of columns of result here */
	+  char **pzErrMsg             /* Write error messages here */
	+){
	+  return sqlite_get_table_common(db, zSql, pazResult, pnRow, pnColumn, pzErrMsg, 1);
	 }

	--- sqlite.h.old	Thu Jun 05 02:14:02 2003
	+++ sqlite.h	Sun Jul 13 12:28:30 2003
	@@ -314,6 +314,18 @@
	 );

	 /*
	+** Same as above but also returns column types after column names and before data
	+ */
	+int sqlite_get_table_with_types(
	+  sqlite*,               /* An open database */
	+  const char *sql,       /* SQL to be executed */
	+  char ***resultp,       /* Result written to a char *[]  that this points to */
	+  int *nrow,             /* Number of result rows written here */
	+  int *ncolumn,          /* Number of result columns written here */
	+  char **errmsg          /* Error msg written here */
	+);
	+
	+/*
	 ** Call this routine to free the memory that sqlite_get_table() allocated.
	 */
	 void sqlite_free_table(char **result);
 
524 new active 2003 Dec anonymous Unknown 2003 Dec   2 1 port of sqlite to dos with short file names edit
i'm just appending a patch i made to work with sqlite on dos with djgpp. see the wiki for backgrounds.

i hereby dedicate any and all copyright interest in this code to the public domain. i make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. i intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights this code under copyright law.

 
525 new active 2003 Dec anonymous   2003 Dec   4 4 DB testing edit
Hello,

I have a user wich finds it annoying that non-sqlite db files can be opened (or seems to be). Would be nice to have an option like create always and open existing etc.. similar to createfile() api

Thanks, Edwin Knoppert

 
517 new active 2003 Dec anonymous Parser 2003 Dec drh 1 1 \' sequence unrecognized token error enhancement request edit
per an email exchange with Richard on 12/6/03, am requesting an enhancement to handle a situation where a sequence of \' in a SQL INSERT INTO data stream causes an unrecognized token error. This occurs when attempting to reload data that has been dumped with the phpMyAdmin application. There are a number of allowed escape sequences in MySQL namely: \0 => NUL (ASCII 0) \' \" \b \n \r \t \\ \z
 
510 new active 2003 Nov anonymous Unknown 2003 Nov   5 2 trigger: addition of create ability edit
this code COULD be implemented outside the .sql script, but if this were possible it would cut that code by about 70-80%! not to mention makes it 10x easier to handle the db.

this is only a chunk:

/* create group info table on addtion to master group list /*
create trigger group_make_new after insert on group_list
begin
/* make table of users for group /*
create table group_[new.groupID] (
userID unique,
userlevel
);
/* insert owner as a member /*
insert into group_[new.groupID] values (new.owner,3);
end;
note: you'll have to fix the comments cause of this posting format....

 
498 new active 2003 Nov anonymous Unknown 2003 Nov   4 4 Suggestion: Allow named parameters. edit
The ability to add parameters using "?" is great. However, it would be even better if you could add a meaningful names to the parameters. This would be just for human purposes, as the parser could just ignore the names.

For example:

"insert into mytable values (?, ?, ?)"

could be written like

"insert into mytable values (?Day, ?Month, ?Year)"

Named parameters could also be used to allow a parameter to appear multiple times in a single query, and yet only require a single call to sqlite_bind to set its value. For example

  SELECT quantity FROM Inventory WHERE :price < 10 OR :price > 100;

would only require a single call to sqlite_bind to set the value of the :price parameter. This feature becomes more valuable with complex queries where multiple sub-selects may require the same parameter.

Implementing this feature outside SQLite would require parsing the SQL statments to locate the named parameters, substituting the positional parameters, then using the existing API to set the value of the positional parameters. This seems wasteful since SQLite will have to parse the same SQL statement again to extract the positional parameters.

The colon, ":", is used by SQL:1999 as the standard prefix to denote parameter names, and should probably be adopted by SQLite as well if named parameters are implemented.

 
259 new active 2003 Mar anonymous CodeGen 2003 Nov   1 2 ORDER BY queries including an integer primary key don't use index edit
G'day,

I have a table and index with the following specification: CREATE TABLE Disturbance (Entry INTEGER PRIMARY KEY,Input,Value,Time,HmiQuality,Quality); CREATE INDEX DisturbanceIndex ON Disturbance ( Input, Time, Entry );

When I do a query where the order by includes Input and Time, but not Entry no sorting is required as sqlite uses the index. When I include Entry at the end of the order by the index is not used for sorting.

I've traced this to the findSortingIndex() function in where.c. The first two order-by entries pass the appropriate tests in the part of the function beginning at pMatch = 0. The third colum fails the test.

On the line if( pOrderBy->a[i+j].pExpr->iColumn!=pIdx->aiColumn[i+nEqCol] ) break; the break is triggered because pOrderBy->a[i+j].pExpr->iColumn = -1, but pIdx->aiColumn[i+nEqCol] = 0.

It looks to me like it's the order by version that's wrong, but I didn't want to delve any deeper than this, because there's probably a reason why the value is -1, and not 0 :) I'll leave it for more experienced hands to look at from this point onwards. Any work-around suggestions would also be appreciated as this is software that will be going to a customer in a week :)

Benjamin.

Yes, the query optimizer, and especially the code that tries to avoid sorting by using an index, needs some work. That has been on the to-do list for some time.

Here is a temporary work-around: In the schema you define above, "ORDER BY Input, Time, Entry" and "ORDER BY Input, Time" will always generate the same order. So you should use the second ORDER BY form. Or, consider making Entry an "INT PRIMARY KEY" instead of "INTEGER PRIMARY KEY" to avoid invoking the primary key magic of SQLite.

BTW, a value of -1 for a column number means that the column is the key of the record.

 
268 new active 2003 Mar anonymous Parser 2003 Nov   1 3 columns of subselects containing joins are not recognized edit
The following is a transcript of a minimal sqlite session exhibiting the problem:

  SQLite version 2.8.0
  Enter ".help" for instructions
  sqlite> create table A(x);
  sqlite> create table B(y);
  sqlite> select * from (select * from A,B) where x = 0;
  SQL error: no such column: x

The problem does not appear to be with the statement select * from (select * from A,B) itself, because that produces the correct results, but with the parser being unable to resolve the column name. Using an alias does not help:

  sqlite> select * from (select * from A,B) as t1 where t1.x = 0;
  SQL error: no such column: t1.x

Obviously the simpler select * from A,B where x = 0 would work, but that's not a workaround in this case - I ran into this because I'm working with a relational algebra to SQL translator, that doesn't know how to simplify the expressions to more idiomatic SQL.

 
209 new active 2002 Dec anonymous BTree 2003 Nov   1 1 update libtool edit
The version of libtool shipped with sqlite is very out of date (well over a year old). It does not properly detect the ability to build shared libraries on darwin, for example, which is bad. You need to update to the latest version of gnu libtool.
 
338 new active 2003 Jun anonymous Unknown 2003 Nov   5 1 lowerFunc and upperFunc Fail on foreign characters edit
This seems to work better

  static void upperFunc(sqlite_func *context, int argc, const char  **argv){
    char *z;
    int i;
    if( argc<1 || argv[0]==0 ) return;
    z = sqlite_set_result_string(context, argv[0], -1);
    if( z==0 ) return;
    for(i=0; z[i]; i++){
      if ( ( z[i] >= 'a' && z[i] <= 'z' ) ||  
           ( z[i] >= '&#65533;' && z[i] <= '&#65533;' ) ||
           ( z[i] >= '&#65533;' && z[i] <= '&#65533;' ) )    
        z[i] = toupper(z[i]);
    }
  }
  static void lowerFunc(sqlite_func *context, int argc, const char   **argv){
    char *z;
    int i;
    if( argc<1 || argv[0]==0 ) return;
    z = sqlite_set_result_string(context, argv[0], -1);
    if( z==0 ) return;
    for(i=0; z[i]; i++){
      if ( ( z[i] >= 'A' && z[i] <= 'Z' ) ||  
           ( z[i] >= '&#65533;' && z[i] <= '&#65533;' ) ||
           ( z[i] >= '&#65533;' && z[i] <= '&#65533;' ) )
          z[i] = tolower(z[i]);
    }
  }
 
235 new active 2003 Jan anonymous Unknown 2003 Nov chw 5 1 Local language do not support! edit
We are from Russia! We need support for local language! I think, this make faster, if you add the WinAPI functions for compare ansi string, or other way.
To fix this you can add one small function to the sqlite sources. Note, I don't know about possible damages.


--- sqlite/src/util.c.locale Sat Aug 31 20:14:35 2002 +++ sqlite/src/util.c Fri Sep 27 14:06:56 2002 @@ -415,6 +415,23 @@ };

/* +** Compile with SQLITE_ISO8859=1 and call this function on startup. +** +** Usage: +** +** setlocale(LC_CTYPE, ""); +** sqliteSetUpperToLower(); +** +*/ +void sqliteSetUpperToLower(){ + /*extern int tolower (int c);*/ + int i; + for (i = 0; i <= 255; i++) { + UpperToLower[i] = (unsigned char)tolower(i); + } +} + +/* ** This function computes a hash on the name of a keyword. ** Case is not significant. */


 
478 new active 2003 Oct anonymous Parser 2003 Nov drh 1 3 select into is lacking edit
hi,

thanks for sqlite. i accidentally tryed a "select into" statement and found it is not parsed by sqlite.

best regards,

alex

 
472 new active 2003 Oct anonymous VDBE 2003 Nov   5 5 [Patch] Using localtime instead UTC time to 'now' edit
  --- os.c.orig   Mon Oct  6 09:23:03 2003
  +++ os.c        Mon Oct  6 09:29:16 2003
@@ -1605,20 +1605,35 @@
 */
 int sqliteOsCurrentTime(double *prNow){
 #if OS_UNIX
-  time_t t;
+  time_t t, lot;
+  struct tm ltm;
+  int ltmsec;
   time(&t);
-  *prNow = t/86400.0 + 2440587.5;
+  /*
+   * to use localtime, I used localtime - gmtime.
+   * localtime_r, gmtime_r are thread safe.
+   * by iosephATuriDATsarangDATnet
+   */
+  localtime_r(&t,&ltm);
+  lot = mktime(&ltm);
+  gmtime_r(&t, &ltm);
+  ltmsec = lot - mktime(&ltm);
+  *prNow = (t + ltmsec)/86400.0 + 2440587.5;
   return 0;
 #endif
 #if OS_WIN
-  FILETIME ft;
+  FILETIME ft,ft2;
   /* FILETIME structure is a 64-bit value representing the number of
      100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
   */
   double now;
   GetSystemTimeAsFileTime( &ft );
-  now = ((double)ft.dwHighDateTime) * 4294967296.0;
-  *prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5;
+  /* to use localtime, I used this API.
+   * by iosephATuriDATsarangDATnet
+   */
+  FileTimeToLocalFileTime(&ft, &ft2);
+  now = ((double)ft2.dwHighDateTime) * 4294967296.0;
+  *prNow = (now + ft2.dwLowDateTime)/864000000000.0 + 2305813.5;
 #endif
   return 0;

-- EOF --


This patch is local patch. I patched both OS_UNIX and OS_WIN to be thread safe.
 
491 new active 2003 Nov anonymous   2003 Nov   4 4 Want to use SET col = 'val' with INSERT statement edit
It would be nice if the an additional INSERT syntax is supported because: 1) This makes migrating from MySQL to SQLite easier. 2) The body of UPDATE and INSERT statements are the same using this syntax which makes developing faster and easier.

The exact syntax: INSERT [INTO] tbl_name SET col_name=(expression | DEFAULT), ... (From: http://www.mysql.com/doc/en/INSERT.html)

2004-Mar-14 22:29:54 by anonymous:
I'd like to second this item. From my readings, this is a documented feature of SQL92, and from my own use of SQL in programming languages, it's far easier to use the SET syntax over the VALUES syntax for manipulation queries.


2004-May-10 10:20:25 by anonymous:
My vote on this one too! When this is implemented, we can finally switch with our entire product range to sqlite :).
 
490 new active 2003 Nov anonymous VDBE 2003 Nov xdong 4 3 a few api improvements for recordset operations edit
hi friends,

i'm working on a visual user interface for sqlite under dos. sqlite works great and i will post a patch for short file name support. there are a few api enhancements needed for automatic synchronization of data in a recordset with the database.

1. please add a new format in printf (like %k) to convert a string to a valid sql identifier. (like rename field "from" to "[from]").

2. additional information on a selection result will be great also: add the source table name for each column, and the rowid of each field coming from a table. a timestamp for each such field will also be of great importance, though i understand it is not present in the current code. this information will be repeated of course when there are several fields of the same table, and other way to have this information will be welcome too (such like querying the vdbe for each column of interest, every row).

3. please provide a structured way to query the fields information for a table, index, view or view order part.

4. the database dump facility should be provided as an atomic routine in the utils library.

best regards,

alex

 
486 new active 2003 Oct anonymous VDBE 2003 Oct   5 4 index on expressions (general solution to case-insensitive problem) edit
Hi.

Just wanted to throw a suggestion for this very useful database: It would be very useful to be able to have indexes that use expressions rather than column names (and have the query optimizer be able to use them when it sees those expressions) Oracle has this capability and it's surprisingly general-purpose and useful for a variety of problems, so I'd like to ask that this be considered for a sqlite wish-list (not that I want to try to make sqlite into oracle or use 'oracle has this' as a justification for any feature:-).

For example, a frequent request or requirement is to search fields case-insensitively. However, most such requirements also require that the field be displayed in the original case.

    CREATE INDEX
      upper_ix
    ON
      employees (UPPER(last_name)); 

makes for an easy solution (though one might want a FOLD() function to correctly deal with internationalization, but that's another subject)

Thanks. Mark.

 
485 new active 2003 Oct anonymous BTree 2003 Oct   5 4 Comparing strings: user defined callback, strcoll? edit
I think it would be useful to specify the "C" locale character set (like strcoll), at database level, so strings are compared based on that locale. Or at least some callback routine so one could perform those string comparisons.
 
479 new active 2003 Oct anonymous Parser 2003 Oct drh 4 3 Sequences edit
Adding sequences to sqlite would be very useful... allowing to do several things that are not possible today. But I'm not sure if default column values must be implemented to take full use of sequences.
2004-Mar-03 13:14:00 by anonymous:
Any plans to add sequences?
 
243 new active 2003 Feb anonymous Unknown 2003 Oct anonymous 3 4 Performance problem with MSVC precompiled DLL edit
After a while the time for queries increase from e.g. 0.46 sec to 1.5 sec or even over 2 sec. The interesting thing is, that time for sqlite_free_table also increase. I recompiled the library with Borland C++ Builder 5 with the effect, that it runs 2 times faster (about 0.25 s for the same query) and produces constant times for queries. Another advantage of this library is : no need for msvcrt.dll. The only dependences are : kernel32.dll and user32.dll

For details mail me at : sascha_7777@onlinehome.de and i will send you this version of library.

My guess that this is entirely the fault of particularly poor malloc() that comes by default on Windows. Borland C++ Builder 5 is probably tossing in its own (better) malloc() implementation.

--- Pablo 10/16/2003

I have confirmed this as well with 2.8.6. I was seeing the behavior reported here and after rebuilding the DLL with BCB 5.5 (which is free now) the memory usage is down and the query times are constant.

With the downloaded DLL, I would see the following results (times in seconds):

took 0.0400 for 1 rows and 2 columns took 0.0700 for 681 rows and 17 columns took 0.0000 for 8 rows and 2 columns

took 0.6010 for 1 rows and 2 columns took 0.0700 for 681 rows and 17 columns took 0.0000 for 8 rows and 2 columns

took 0.5210 for 1 rows and 2 columns took 0.0800 for 681 rows and 17 columns took 0.0000 for 8 rows and 2 columns

It simply runs the same 3 select statements 3 times. The first time, it is fast because (presumably) the heap is clean.

After rebuilding the DLL with BCB 5.5, the results are as follows:

took 0.0100 for 1 rows and 2 columns took 0.0300 for 681 rows and 17 columns took 0.0100 for 8 rows and 2 columns

took 0.0100 for 1 rows and 2 columns took 0.0300 for 681 rows and 17 columns took 0.0000 for 8 rows and 2 columns

took 0.0100 for 1 rows and 2 columns took 0.0300 for 681 rows and 17 columns took 0.0000 for 8 rows and 2 columns

 
465 new active 2003 Sep anonymous   2003 Sep   4 3 data types should be implemented as formated strings edit
a real improvement of sqlite would be operating on numeric and date, time fields in a sortable string format, for example:

* date as YYYYDDMM, * time as HHMMSSmmm, * integer as hexadecimal string without "0x", * float as WWWWWWWWDDDDDDDDDDDDDEEEEEEE (wholes, decimals, exponent)

this way, there would be no need for the special integer keys and indexes, and code will be more feature oriented and less feature evading.

hexadecimal values will compress decimals and improve sortability. all numbers should be 0-padded, prefixed by their sign, with null strings for null values.

the developing effort required would be to: * make a library of basic mathematical functions for string values. * parse numeric, date, and time literals in queries without quotation marks. * match the right function for the specified type. * it would be very nice to support all the types of c variables.

 
457 new active 2003 Sep anonymous   2003 Sep   1 1 Ported to NetWare edit
I've ported SQLite to work on NetWare 5.1 and 6.x. The database file location must be an NSS volume.
 
454 new active 2003 Sep anonymous   2003 Sep   4 4 schema column types with parenthesis to automatically invoke functions edit
having a table such as:

CREATE TABLE foo (amount NUMERIC(10,2));

and having a function (NUMERIC) that accepts three parameters, it would be nice if:

INSERT INTO TABLE foo (10.50);

would call: NUMERIC(10.50,10,2);

and use its result as the insert.

Since this could break compatability, I recommend the use of a PRAGMA that would enable this mode.

I am aware that TRIGGERS make it possible to do this, however this would require application-level setup that is too specific for some of the applications I work with; A pragma is not an unrealistic setup for my application, but setting up special INSERT/UPDATE triggers is.

As a temporary workaround, my application downloads the sqlite_master table, parses out the columns, and creates the triggers accordingly. This code is somewhat complex, and thus represents an annoyance.

 
450 new active 2003 Sep anonymous Shell 2003 Sep   5 4 Make HTML Output XHTML compliant edit
According to the website documentation, sqlite already does this but the latest version I downloaded doesn't. XHTML states that tags should all be lowercase (<td> as opposed to <TD>). Instead of fixing the website, it would be easier to patch sqlite.

There follows a patch to do this and also a patch to change the documentation on the site as it says XHTML compliance but lists non XHTML compliant tags.

D'oh - just saw Attach link.

Sorry


2005-Sep-08 01:02:45 by anonymous:
Still an issue in v3.2.5
 
448 new active 2003 Sep anonymous   2003 Sep drh 3 3 a general bug-fix and dos support without lfn edit
there are 2 issues in the included diff:

1. fixed support for djgpp without long file names. djgpp gives brute force to dos in terms of 32bit and 4gb memory, but it still remains a mainly one process at a time os, where programs are being enhanced mainly through libraries. that's why sqlite makes such a big difference to dos users, allowing them to directly use databases.

2. a minor bug in the code if readline isn't on:

#if !HAVE_READLINE
# define macro1(arg)
# define macro2(arg)
#endif

if (a)
macro1(1)
if (b)
macro2(2)
if (c)
return;

will be preprocessed to contain:

if (a)
if (b)
if (c)
return;

which is equivalent to:

if (a && b && c)
return;

as i understand, you meant to write:

if (a)
/*do nothing*/
if (b)
/*do nothing*/
if (c)
return;

thus, i've changed the code to:

#if !HAVE_READLINE
# define macro1(arg) {}
# define macro2(arg) {}
#endif

feel free to correct me if i'm wrong.

best regards and thank you for sqlite,

alex

please also rename the only non short file names : sqliteInt.h, tclsqlite.c to some 8.3 compliant names.

thanks,

alex

 
442 new active 2003 Sep anonymous   2003 Sep   5 2 [PATCH] sqlite: allow configure --enable-threadsafe edit
attached is a patch against cvs head for incorporating the thread-safety aspect to the sqlite lib.

  http://cygwin.dev.wapme.net/sqlite/

Please try and comment. This is intended to be included to cvs head.

 
428 new active 2003 Aug anonymous TclLib 2003 Aug drh 5 5 missing prepare/fetch functions to be compatible with other DBs edit
To have a compatible behaviour to other database engines when fetching single rows from a database table, it would be nice to be able to have a single fetch function instead of the standard "db eval ..." ability using a callback code. I've found three functions in the file test1.c which comes with the source files and implemented them into the TCL interface (file tclsqlite.c proc DbObjCmd).

oops deleted attach. please post it again.

 
425 new active 2003 Aug anonymous VDBE 2003 Aug   5 3 Datetime enhancements: fractional seconds, addmonth edit
This code adds support for fractional seconds in the datetime functions. From 0 to 6 digits are supported on creation of timestamp or time strings; up to 12 digits are read from them.

  YYYY-MM-DD HH:MM:SS.SSSSSSS
  HH:MM:SS.SSSSSSS

The functions TIMESTAMP TIME and SECOND have been modified to accept an optional second argument to specify the number of fractional digits to be produced in the string result. The JD is rounded for the specified precision.

A new function ADDMONTHS is also included. It takes a datetime and an integer, and increments the datetime by the number of months specified. The number can be negative, and can be greater than 12. To add years, do ADDMONTHS(<jd>,<years>*12).

e

 
424 new active 2003 Aug anonymous Shell 2003 Aug   4 3 Provide access to internal function _all_whitespace() edit
Can the function _all_whitespace() in shell.c be made available as part of the SQLite API, perhaps with the more appropriate name sqlite_empty(). This function could then be used along with sqlite_complete() when splitting files contain SQL scripts into individual statements that can be executed by SQLite.

The problem occurs because sqlite_complete() returns true for an empty statment, but some applications (Borlands dbExpress for example) don't consider an empty statment to be valid SQL and throw an exception when they are executed. So the user must ensure that the statement accepted by sqlite_compltet() is not empty using the sqlite_empty() function before trying to execute it.

The name _all_whitespace() is not really appropriate since it also accepts comments which are not "whitespace" characters.

I am currently using a modified version of shell.c to build a custom DLL, but changing the SQLite source would be a lot cleaner.

 
420 new active 2003 Jul anonymous VDBE 2003 Jul   3 3 Not abort transaction when callback is cancelled edit
When a callback is cancelled (non-zero return value) in a transaction, the changes are undone, but the transaction is not rolled back.

This presents a problem as my sqlite wrapper sometimes legitimately cancels a callback in the middle of a transaction and wants to commit the changes made before/after the callback cancel.

The way I understand it, a callback is only invoked when a query is being executed (data retrieval) which doesn't impact a transaction anyway. If I am wrong in this assumption, then perhaps this will require more changes to accomplish.

[This code works on my box with the limited number of tests I have accomplished. I'm not a linux developer and I don't have tcl on my system so I can't run the full test suite. If someone could do that with these proposed changes I would be very appreciative]

My proposed changes are (quite simple):
1) create a new PRAGMA: PRAGMA callback_cancel_no_abort with a default of FALSE (to keep the current behaviour as default)
2) if a callback is ABORTed and this pragma is true, then don't return SQLITE_ERROR from sqlite_vbde_exec, but rather SQLITE_DONE

The code changes for these proposed changes are (to the official 2.8.5 release):

In sqliteInt.h: INSERT this line at line 351: #define SQLITE_CallBackNoAbort 0x00000400 /* Don't abort on callback cancel */

In pragma.c: INSERT this code at line 336:
if( sqliteStrICmp(zLeft, "callback_cancel_no_abort")==0 ){

    if( getBoolean(zRight) ){
      db->flags |= SQLITE_CallBackNoAbort;
    }else{
      db->flags &= ~SQLITE_CallBackNoAbort;
    }
    }else

In vbde.c: CHANGE line 5751: from
if( rc ){

TO

if( rc && ( !(db->flags & SQLITE_CallBackNoAbort) || rc != SQLITE_ABORT) ){

I don't believe these changes will conflict with existing callback abort responses, however I am not completely familiar with all parts of sqlite, therefore I would like to hear the thoughts of DRH and the sqlite community.

 
413 new active 2003 Jul anonymous   2003 Jul   5 1 SQL_CALC_FOUND_ROWS & FOUND_ROWS() not supported edit
for speedup & code compatibility with mysql
 
412 new active 2003 Jul anonymous Unknown 2003 Jul drh 1 1 sign function: quick hack for func.c (hope this helps) edit
        Here's a quick hack to create the sign  function in  /src/func.c

        /*
        ** Implementation of the sign() function
        */
        static void signFunc(sqlite_func *context, int argc, const char **argv){
          double r;
          char zBuf[3];
          assert( argc==1 );
          r = atof( argv[0] );
          if ( r < 0 )
            { zBuf[0]='-';
              zBuf[1]='1';
              zBuf[2]='\0';
              sqlite_set_result_string(context, zBuf, -1);
              return;
            }
          if ( r == 0 )
            { zBuf[0]='0';
              zBuf[1]='\0';
              sqlite_set_result_string(context, zBuf, -1);
              return;
            }
          if ( r > 0 )
            { zBuf[0]='1';
              zBuf[1]='\0';
              sqlite_set_result_string(context, zBuf, -1);
              return;
            }

        }

        Also note the following change in sqliteRegister where sign is added.

        ** This function registered all of the above C functions as SQL
        ** functions.  This should be the only routine in this file with
        ** external linkage.
        */
        void sqliteRegisterBuiltinFunctions(sqlite *db){
          static struct {
             char *zName;
             int nArg;
             int dataType;
             void (*xFunc)(sqlite_func*,int,const char**);
          } aFuncs[] = {
            { "min",       -1, SQLITE_ARGS,    minFunc    },
            { "min",        0, 0,              0          },
            { "max",       -1, SQLITE_ARGS,    maxFunc    },
            { "max",        0, 0,              0          },
            { "length",     1, SQLITE_NUMERIC, lengthFunc },
            { "substr",     3, SQLITE_TEXT,    substrFunc },
            { "abs",        1, SQLITE_NUMERIC, absFunc    },
            { "sign",       1, SQLITE_NUMERIC, signFunc    },
        ....

        The above is a quick hack; but, it allows the 
        users of sqlite to create pivot table as follows:

        CREATE TABLE exams (
          pkey int(11) ,
          name varchar(15),
          exam int,
          score int,
          PRIMARY KEY  (pkey)

        );

        insert into exams (name,exam,score) values ('Bob',1,75);
        insert into exams (name,exam,score) values ('Bob',2,77);
        insert into exams (name,exam,score) values ('Bob',3,78);
        insert into exams (name,exam,score) values ('Bob',4,80);

        insert into exams (name,exam,score) values ('Sue',1,90);
        insert into exams (name,exam,score) values ('Sue',2,97);
        insert into exams (name,exam,score) values ('Sue',3,98);
        insert into exams (name,exam,score) values ('Sue',4,99);

        sqlite> select name,
        sum(score*(1-abs(sign(exam-1)))) as exam1,
        sum(score*(1-abs(sign(exam-2)))) as exam2,
        sum(score*(1-abs(sign(exam-3)))) as exam3,
        sum(score*(1-abs(sign(exam-4)))) as exam4
        from exams group by name;

        Sue|90|97|98|99
        Bob|75|77|78|80

        ref http://sqlchar.sourceforge.net/index.php

        Hope this helps,

        Mike Chirico
        http://vc2000-08.med.upenn.edu/chirico/
 
407 new active 2003 Jul anonymous   2003 Jul   4 4 sqlite_compile etc. and pragma empty_result_callbacks. edit
Maybe if EMPTY_RESULT_CALLBACKS is set and you use sqlite_compile, sqlite_step etc. with a SELECT query that returns no rows the first invocation of sqlite_step() should return SQLITE_ROW with just columns data.
 
184 new active 2002 Oct mike   2003 Jul drh 5 3 auto update mechanism for CVS edit
is it possible to set up CVS in such a way that we are notified of activities on tickets, and check-ins?
 
386 new active 2003 Jul anonymous   2003 Jul   5 1 compile on WinCE ? edit
hi,

since wince is supported by pythonCE and pysqlite is a wrapper it might be usefull to compile SQLITE on WinCE ( I use winCE 2.1 on ARM (iPAQ) ).

.klemens

 
381 new active 2003 Jul anonymous   2003 Jul   1 3 Support for DJGPP and DOS edit
I would like to use SQLite in a pure DOS (MS-DOS, DR-DOS, FreeDOS) environment. Thankfully DJGPP provides many of the Unix APIs and tools. But the file name limit has been a prolem. DOS filenames must be 8.3, that is 8 characters plus a 3 character extension. I found 3 places where this is violated.

1) A file named "sqlite.h.in" is included with the source distribution. This unzips to "sqlite.h" since there may be only 1 extension. Since "sqlite.h" is supposed to be generated from the ".in", this causes problems. If I rename the file to "sqlite.hin" and modify the makefile main.mk, all works fine.

2) The temporary files created violate 8.3. The default pattern is "sqlite_XXXXXXXXXXXXXXXX". I modified the pattern to be "sqXXXXXX" so it is 8 characters long. Another possible (better?) solution would be to use mkstemp(), or even tmpnam().

3) The journal files created violate 8.3 The default is to append "-journal" to the end of the database or temp file name. For database file names like "mydb.sld", this results in "mydb.sld-journal". Since the extension may only be 3 characters, it ends up writing to "mydb.sld". This is really bad since now the journal and DB are the same file. Instead of "-journal", I used ".jnl". This works if the database filename does not already have an extension. A better fix would be to change the extension, if there is one.

2005-Feb-09 03:32:44 by anonymous:
Use ROM-DOS 7.1(from datalight)
 
366 new active 2003 Jun anonymous Unknown 2003 Jun drh 4 3 Functions sqlite_(en/de)code_binary() not in sqlite.h edit
The handy utility functions sqlite_encode_binary() and sqlite_decode_binary() from encode.c don't have any declarations in sqlite.h
 
363 new active 2003 Jun anonymous VDBE 2003 Jun jadams 5 5 sqlite support domain as user defined type edit
sqlite support domain as user defined type
 
356 new active 2003 Jun anonymous VDBE 2003 Jun   5 2 Returns real error codes edit
Hello,

I use succesfully sqlite with the php extension and some C application. While writes drivers for different backends I use, it is a real pain to know what really happen on error.

The output message is well down and usefull for a human ;). Once you switch to manager error programmatically, it's quit impossible to know exactly the error code. As you change it to a string output, 'SQL error' or others "useless" message.

Is there a chance to get an additionnal argument for the error code? I mean if you can populate the error code?

hth

pierre

The problem is that the returned by reference error message is very descriptive but that the error codes are too coarsely grained to be useful for programmatic decision making.

Eg: "select * from foo"

when the table foo does not exist provides a nice textual description of the error, but the error code is a generic code that does not distinguish between a missing database, missing table, syntax error etc.


2004-May-19 13:44:28 by anonymous:
Yup this issue is very severe if you want to do any sort of error handling in your code. Actually a work around is parsing the error messages returned from the initial API call that failed and mapping them to your own error code table. Very klunky and bound to break often too.
 
331 new active 2003 May anonymous Unknown 2003 Jun mike 5 5 Went to compile Win32 project and found a missing header reference edit
I created a project in VS.NET 2003, specifically a Windows Dll project. I included all of the *.c files from your windows source distribution. The build went ok with a bunch of warnings until I go to the tcl.h file inclusion. The build barfed.
The header "tcl.h" is only required when building the tcl-enabled version of SQLite used for testing. To compile a normal (non-testing) version, omit the file "tclsqlite.c". If you are building using the tarball, omit the files "md5.c", "test1.c", "test2.c", "test3.c" as well.

This is covered in the wiki pages HowToCompile, HowToCompileWithVsNet.

The tcl version can be built under Windows if the tcl development tools are installed.

Perhaps this should be converted to a "request for enhancement" for a MSVC project file or at least a readme.txt file to be placed in the Windows download.

 
326 new active 2003 May anonymous   2003 May   4 4 Request for additional callback for various functions edit
There are several functions of sqlite which take callbacks as a parameter. Two of them are sqlite_create_function and sqlite_create_aggregate.

I'm interfacing the sqlite with the ocaml language and it is required to do some work when the function is about to be "unregisttered", i.e. free some memory, tell the garbage collector to feel free with destroying some data and not to look for something anymore, etc.

It is relatively easy to track this with auth/trace callbacks and busy handler, but for functions and aggregates I have to keep track of all registered functions ang aggregates, so the information is stored twice in a very similar structures - once inside the sqlite, once in my code.

It would be easier if sqlite_create_function sqlite_create_aggregate will take one "cleanup" function as a parameter which (if not null) will be called at the time when registered function/aggregate is about to be replaced or disabled, or when sqlite structure is destroyed.

This can be extended further with registering optional cleanup functions for auth/busy/trace callbacks (with calling them all when closing the database, when disabling, and when replacing), but there are workarounds for it; the real pain is only with functions and aggregates.

Mikhail

 
321 new active 2003 May anonymous   2003 May   4 3 Make SQLITE_ISO8859 and SQLITE_UTF8 overridable by compiler define edit
For those of us who use the preprocessed sqlite_source.zip: it would be nice if we could override the character encoding with a compiler #define. That way I wouldn't have to manually edit sqlite.h.

You could put an #ifndef in sqlite.h:

  #ifndef SQLITE_UTF8
  # define SQLITE_ISO8859 1
  #endif

The other #defines I use (THREADSAFE, TEMP_FILE_PREFIX) etc. are overridable. Only the encoding is not.

 
279 new active 2003 Apr anonymous   2003 May   3 3 WinCE port of CVS version as of 02 Apr 2003 edit
I've re-ported http://cvs.hwaci.com:2080/sqlite/tktview?tn=169 sqlite to Windows CE. Currently only supports MIPS CPU's and x86 but ading a CPU is a 2 liner. Code and diffs attached.

The new files (contain _wince in the filename) in my build system are in a sub dir called WinCE_src and are in the include path before the sqlite src dir. The assert_wince.h is actually called assert.h. Same for config.h.

The diffs look bigger than they really are as I've re-indented the original Windows code to match the new #IFDEF's. I've include os.h, os.c and tokenize.c for clarity.

If you just want the src to build with evc, here is a complete zip ball http://www.geocities.com/clach04/src/sqlite/wince_sqlite_CVS_2003_04_02_src.zip

Chris

It should be considered that Windows CE doesn't support the FILE_FLAG_DELETE_ON_CLOSE option. This may cause a lot of problems with SQLite temporary files.
 
294 new active 2003 Apr anonymous Shell 2003 Apr a.rottmann 1 4 Diff for OpenBSD edit
In order to build on OpenBSD, the following diff must be applied, as per Wild Karl-Heinz <kh.wild@wicom.li>. This is on an OpenBSD 3.2 -current build.

diff Makefile.in Makefile.in~
52c52
< LIBREADLINE = @TARGET_READLINE_LIBS@ -lcurses
---
> LIBREADLINE = @TARGET_READLINE_LIBS@

Once that change is made to the Makefile.in, sqlite compiles and runs without problem. Otherwise, sqlite dies on '/usr/libexec/ld.so: Undefined symbol "_tgetent" called from sqlite:/usr/lib/libreadline.so.1.0 at 0x40083940'.

2004-Mar-09 12:48:12 by a.rottmann:
See #303; the build system should have an overhaul.
 
273 new active 2003 Mar drh CodeGen 2003 Mar drh 1 1 Make NULL_ALWAYS_DISTINCT a pragma rather than a compile-time option edit
NULL_ALWAYS_DISTINCT is a #define currently set to 0. If set to 1, then SQLite will treat NULLs a distinct in SELECT DISTINCT statements and in UNION operators. This is what the SQL standard calls for. But no database (other than Ocelot) works this way, so SQLite leaves NULL_ALWAYS_DISTINCT set to 0 to enhance compatibility. See http://www.sqlite.org/nulls.html for additional information.

This compile-time options should become a run-time option. It should still be off by default, but a pragma should be available to turn it on for those who want it.

 
263 new active 2003 Mar anonymous CodeGen 2003 Mar   1 4 sqlite locking strategy can lead to deadlock edit
G'day,

I'm currently on a customer site, and as one does when a big upgrade is coming up the next day I was thinking about problems I've encountered over the last few weeks. I realise now that a problem I'd considered not very imporant really should be reported to you:

The locking strategy of sqlite when doing operations that modify the database is to set a read lock while data is being analysed, then upgrade that read lock to a write lock when it comes time to modify the data. This strategy can cause deadlock on a UNIX-based system if two processes are executing sql code to modify data simultaneously. The following interleaving results in deadlock:

  Process 1: Lock file for read (ok)
  Process 2: Lock file for read (ok)
  Process 1: Upgrade lock to write lock (go into wait state for process 2 to release read lock)
  Process 2: Upgrade lock to write lock (deadlock waiting for process 1 to release read lock: fail)

I have a slightly modified version of sqlite that uses blocking locks instead of your usual non-blocking lock with delay backoff strategy. I have seen this bug in operation in my build, and although I think it is more likely to occur in my version it is still possible in the vanilla sqlite version.

Since most sql statements that can modify data probably do eventually end up modifying data, my suggested fix to the locking strategy is to decide based on the kind of overall statement whether to set a read lock or a write lock. In that scenario there is no interleaving which can cause a problem because every time a lock is obtained the relevant sqlite process is guaranteed to complete it's operation and then release the lock before trying to obtain another lock (unless the user application is trying to do something tricky, say run sqlite statements from two sqlite instances at the same time and in the same thread).

For the BEGIN TRANSACTION command's lock I would also recommend a write lock be obtained, since most use of this statement would involve non-const operations during the transaction (otherwise the transaction would have no value!).

Benjamin.

The scenario described above is not a problem for the standard SQLite build since locks are non-blocking there. But I will consider how locking might be changed to better accomodate blocking locks. This is not a high priority, however. And since the problem described above does not occur for the standard SQLite build with non-blocking locks, I'm changing this ticket to an enhancement request.

Further remarks by bug reporter:

The locking strategy can have implications for the non-blocking sqlite version as well. Consider the following interleaving:

  Process 1: Obtain read lock (ok)
  Process 2: Obtain read lock (ok)
  Process 1: Upgrade read lock to write lock (failed, read lock is active)

This means that even though Process 1 obtained a lock before process 2 the operation fails. If a write lock had been obtained instead of a read lock then it would have been Process 2 that had it's operation fail. This would unfairly balance the contention between a reader and a writer process in favour of the reader in very tightly contentious environments.

On the other hand, the non-blocking mechanism is not one that deals with high contention between readers and writers very well anyway ;) That's why I ended up making the locks blocking in the first place for my version.

Benjamin.

 
252 new active 2003 Feb anonymous   2003 Feb   4 1 Add optional regex matching similar to what Postgres & Oracle have edit
It would be really nice if one could use the ~ operator for regular expression matches. Postgres does this very nicely.

This one feature is a limiting factor in moving more completely to sqlite over ascii flatfiles. Using perl to slice thru stuff with regex is the only thing I miss. If I had regex matching I would be in heaven.

If you are looking for a regular expression engine, I might recommend http://www.pcre.org/

2004-May-03 15:33:30 by anonymous:
I second this request. I am in charge of the Gentoo Linux Tools project, and we are developing various searching tools which we wish to have a proper database backend for.

Currently, we're looking at using SQLite for this, but any speed and size advantage SQLite has over flat files for our purposes is easily removed by its inability to do regex SELECTs.

I have seen that Brad Campbell has written a patch for this, but it does not appear to have shown up by SQLite release 2.8.11, nor can I find any mention of it in the change log for the past 130 days.

 
236 new active 2003 Jan anonymous   2003 Feb   3 3 Add RENAME TABLE - will be easier to work around missing ALTER TABLE edit
Currently the recommended method to ALTER TABLE is:

  1. Create a temporary table.
  2. Copy all data from original table to temporary table.
  3. Drop the original table.
  4. Create a new table.
  5. Copy all data from the temporary table to the new table.

This means that most of the data is copied twice - with a big database this may take quite some time.

I suggest adding a RENAME TABLE command, which will cut 50% of the overhead (copy the data only once instead of twice):

  1. Rename the original table to a temporary name.
  2. Create a new table.
  3. Copy data from the temporary/original table to the new table.
  4. Drop the temporary/original table.

A further enhancement would be to make the RENAME TABLE an internal command (not exposed to the SQL interface), and use it internally in order to implement an ALTER TABLE feature.

This may not be the most efficient ALTER TABLE out there, but at least will make SQLite much more compatible with standard SQL commands. It will certainly make life easier during development, when tables need to be altered all the time.

This suggestion isn't as easy to implement as it sounds. Because VIEWs, TRIGGERs, FOREIGN KEYs,... can reference a table by name, renaming a table means modifying their schemas to do the renaming, and handling all kinds of cases.

One trick might be to have the parser modify the SQL used to create all SQLite TABLES, VIEWS,... by inserting special C-style comments into the SQL following every table name, which would allow you to find and replace them. For example:

  CREATE TABLE t1 (...);

becomes

  CREATE TABLE t1 /*SQLITE-TABLE-NAME:t1*/ (...);

Another way would be to create the temp table with a new name, and then have a SWAP TABLE pragma which ends up swapping the pointers to the tables. Afterwards you have to re-check constraints on both tables. Then you can drop the old table.

Jim Lyon

---

I agree that just renaming a table can have adverse side-effects as you describe. However, I suggest RENAME TABLE only as an intermediate solution for the missing ALTER TABLE.

If used only in the way I suggest, then RENAME TABLE will not have any side effects, as it will just be part of a procedure that results in no change to the original table name:

  1. Rename original table to temp name.
  2. Create new table with ORIGINAL name.
  3. Move data from previous to new table.
  4. Drop previous table.

As you can see in step 2, the "new" table retains the original name, so any references from other tables should be retained. I think that the SWAP TABLE you suggest is very similar.

Of course, references to specific fields may be affected (if the new table structure drops some fields), but this is anyway the case with ALTER TABLE.

Eyal Zvi.

 
244 new active 2003 Feb anonymous Unknown 2003 Feb drh 5 4 Combining CREATE TABLE with its populating from some flat file edit
Michael Ovcharenko wrote:
    Hi, Richard,

    SQLite is a brilliant tool which can be used for numerous purposes. It, however, can be especially useful when it comes to producing some information on the base of the data derived from multiple heterogeneous data sources to suck them up onto the SQLite tables, use these for some sophisticated analysis, produce the necessary information, and then drop the unnecessary tables. The whole process can be reproduced at any time, e.g., by running a single script with SQLite. And SQLite is very good and fast here with its ".COPY table-name FROM file-name ..." command. Still, the table should have been created before this operation.

    Don't you think it could be useful for SQLite to combine both (create table and populate it with the data) in one command (which can be considered as an extension of ".COPY..." command - it does not comply with SQL92 anyway) provided that the first row of the source data file contains column names. It seems to be especially reasonable as SQLite is typeless and could potentially "suck up" a source file representing any number and types of columns. In many cases the source data can represent some spreadsheet exported, e.g., in CSV format, so these files usually contain column headers anyway. In an extreme case, table name and column names (when missing) could be generated in according to some convention.


RH: Good idea. I suggest syntax like this:

    CREATE TABLE <name> AS COPY FROM <file>.

Or perhaps just

    CREATE TABLE <name> FROM <file>.

Can you write this up as an enhancement ticket on CVSTrac so that I don't forget?

    http://cvs.hwaci.com:2080/sqlite/tktnew

MO: Another opportunity is to extend .COPY command so that it will be able to implicitly create table in case it does not exist yet. Its parameters may establish certain pattern on default names for its columns if (in an extreme case) the first line of the source file does not contain any column names, e.g. something like DEFAULT COLNAME AS 'EMP_COL' (plus its sequential number like EMP_COL1, EMP_COL2, etc.). When created implicitly, the name of the table can be defaulted from "table-name" clause of .COPY command.

I think, it could be useful to consider employing ON CONFLICT clause for this case (can it be extednded with something like CREATE TABLE?).

Best regards,

Michael Ovcharenko.

 
68 new active 2002 Jun anonymous   2003 Jan   5 5 PRAGMA table_info(table-name) for queries edit
It would be nice to have a possibility to get columns information, something like from PRAGMA table_info(table-name), also for queries. Maybe It could be a one function which enables to get both information and data.
Selecting something from a view which is created with the statement "create view MyView as (select * from MyTable where ...)" is returning invalid datatypes instead of the MyTable datatypes.
 
219 new active 2003 Jan anonymous   2003 Jan   5 5 MySQL style enums edit
I would be really cool if SQLite supported enum like MySQL does:

http://www.mysql.com/doc/en/ENUM.html

 
216 new active 2003 Jan anonymous   2003 Jan   1 1 Add "DISTINCT ON()" clause to specify the fields to apply the unicity edit
Like postgresql is a good enhancement to the distinct clause allow to specify wich fields to use when decide that a row match the distinct clause.
Looking in a way to achieve the above functionality I've discovered that sqlite permit us to have columns in a "select" with "group by" that aren't present in the "group by" clause or in an agregate function.

With that functionality ("Bug" a nice one) we can get the same result of "DISTINCT ON()".

create table test(pk integer, name text);

insert into test(1,'carl');

insert into test(2,'pal');

insert into test(3,'carl');

select distinct on(name) name, pk from test; -- impossible in most databases

-- return the same result as

select name, pk from test group by name; -- as well impossible in all databases I know except SQLITE

Please leave the "group by" functionality ("bug") there allways.


2004-Mar-10 01:45:44 by anonymous:
That's a good workaround, except it's seemingly impossible to apply ordering first. E.g. I want to select the latest submission for each document in a table like the following:

  create table submissions (
    s_id integer primary key,
    doc_id integer references documents,
    entry_time datetime);

I do this in postgresql:

  select distinct on (doc_id) s_id from submissions order by doc_id,  entry_time desc;

By doing so, I get the s_id for the latest submission of each document.

Using the group by workaround in sqlite will not apply the sort before choosing the row, so it does not choose latest submission, but rather some arbitrary one.


2006-Feb-11 13:45:11 by anonymous:
What is the current status? I have found http://article.gmane.org/gmane.comp.db.sqlite.general/703 and I would like to know if it is now a supported feature instead of a "consequence". I would also like to know if running

     SELECT a, min(b) FROM t1 GROUP BY a;
        1, 2
        2, 4

is the proper way to select all rows with distinct a's and the smallest b. Is this equivalent to saying:

     SELECT a as aa, b FROM t1 where b = (select min(b) from t1 where a = aa) GROUP BY a;

It gives the same result with 3.2.8 but the 'explain' output looks longer for the second version...

 
203 new active 2002 Dec anonymous Unknown 2002 Dec anonymous 2 1 Missing Win32 open flag if shared database edit
In Win32, network and/or shared files should be opened with the FILE_FLAG_WRITE_THROUGH flag in the os.c file.

There could be a flag when opening a database that informs the file is to be opened as shared or exclusive, and avoid locking if exclusive. I think this would improve speed considerably in "local" or exclusive databases.

 
186 new active 2002 Nov anonymous Shell 2002 Nov   5 4 ./configure --enable-threads-safe ? edit
It would be nice to have a ./configure --enable-threads-safe feature instead of using the template Makefile to compile libsqlite with this option turned on.
 
175 new active 2002 Oct anonymous Pager 2002 Oct   5 3 journal file should be kept open edit
In windows at least, the journal file used to manage transactions is being created and deleted for every transaction. this makes transactions slow in the following case: if a virus scanner is active, it will attempt to scan the file being created every time , and it will add 50-100 ms to each transaction. While starting an explicit transaction makes the problem smaller, in an environment where many atomic transactions with a single INSERT or UPDATE must be executed, this slows things down quite a lot. I understand that the peculiarity of the virus scanner actually creates the problem, but , is it a good design decision to keep creating and droping the file ? of course, there is the issue of multiple process accessing the same database, in which case multiple journals would exist, but this should/would be resolved by the locking mechanism anyway...
 
139 new active 2002 Aug anonymous Pager 2002 Aug   3 3 Named transactions are misleading as documented edit
As documented it appears as though you can assign meaningful names to transactions, but in practice the names are just a throwaway for SQL92 compatibility. Nested transactions could be implemented if names were used -- perhaps by using markers in the journal file. This method would work well and provide for unlimited nesting of transactions given that sqlite does not support concurrent transactions.

Example nested transaction:

  begin transaction t1;
  -- creates journal: mydb-journal
  ...
  inserts, updates, deletes, etc...
  ...
  begin transaction t1a;
  -- adds a marker (e.g. 'begin t1a') to the journal
     ...
     inserts, updates, deletes, etc...
     ...
  commit transaction t1a;
  -- adds a marker (e.g. 'commit t1a') to the journal

  ...
  begin transaction t1b;
  -- adds a marker (e.g. 'begin t1b') to the journal
     ...
     ...  
     begin transaction t1b1;
     -- adds a marker (e.g. 'begin t1b1') to the journal
        ...
     commit transaction t1b1;
     ...
  rollback transaction t1b;
  -- rolls back the database to journal marker 'begin t1b' 

  rollback transaction t1;
  -- rolls back to the beginning of the journal, undoing
  -- the commit performed in transaction t1a.
 
82 new active 2002 Jun anonymous   2002 Jun   1 4 Add IsCacheable, IsNullable to sqlite_create_function edit
I did a first release of Ruby-SQLite interface and I've noticed that for some external functions it's not necessary to call then for each row wich will do a big difference in performance, probably adding another field to the sqlite_create_function let's call it "hints" that can tell SQLite that a function returns a constant value for the same entry or null if any of it's parameters are null, this is used in postgresql plpgsql.

Let's say that the new prototype of sqlite_create_function could be:

int sqlite_create_function( sqlite *db, const char *zName, int nArg, void (*xFunc)(sqlite_func*,int,const char**), void *pUserData, int hints );

The hints field can be a bit field that can hold new future hints like this.

#define IS_CACHEABLE (1)

#define IS_NULLABLE (1 << 2)

#define IS_ANOTHER_HINT (1 << 3)

int hints = IS_CACHEABLE | IS_NULLABLE;

 
2351 secure active 2007 May anonymous   2007 May   2 2 UTF-16 convertor accepts malformed UTF-8 sequence edit
UTF encoding convertor accepts some invalid sequences of UTF-8.

  $ ./sqlite3 -version
  3.3.17
  $ cat test.sql
  select hex(a), hex(b), a == b from (select '<CE><B1>' a, '<D0><31>' b);
  pragma encoding = 'UTF-16';
  select hex(a), hex(b), a == b from (select '<CE><B1>' a, '<D0><31>' b);
  $ ./sqlite3 < test.sql
  CEB1|D031|0
  CEB1|CEB1|1

It's necessary to validate subsequent bytes.

 
2860 todo active 2007 Dec anonymous   2007 Dec   3 1 Database file fragmentation edit
Adding data in database file increases file fragmentation. for example my file which size is 1G, consists of 20000 pieces. (NTFS)

This happens because truncation of '-journal' file. I see some ways to reduce fragmentaion: 1. Increase database file size by greater pieces (not by PAGESIZE). 2. SQLite can save '-journal' file in another folder(logical disc). 3. Preallocation of database file(must increase INSERT speed).

 
2841 todo active 2007 Dec anonymous   2007 Dec   1 1 The sqlite mailing list has become overrun by trolls edit
The sqlite mailing list is very useful. The S/N is at times a little high but nonetheless quite manageable.

Recently (see the DeviceSQL thread) it got really bad. Would moderation be unacceptable during these periods of time where people feel the need to protect their ego's?

The sqlite mailing list is primarily about sqlite (well, and lemon), not a marketing vector for other products? Surely they have their own lists and resources for that?

 
2476 todo active 2007 Jun anonymous   2007 Jun   4 3 SQLite3 ignores ORDER BY clause when performing SELECT ... GROUP BY edit
I found that sqlite3 ignores the ORDER BY clause when performing SELECT ... GROUP BY ... ORDER BY ...

Table schema:

  CREATE TABLE events (
    id integer not null primary key,
    title integer
  );

Data:

id title
1 hello
2 hello

Query: SELECT title, id FROM events GROUP BY title ORDER BY id ASC;

Result:

title id
hello 2

Expected result:

title id
hello 1

Note: I don't think this should even work in the first place, because id is not a grouped column, but MySQL and SQLite doesn't seem to have a problem with it. Oracle complains.

2007-Jun-29 07:46:00 by danielk1977:
In SQL, the sorting specified by the ORDER BY clause is performed (logically) after the grouping specified by the GROUP BY clause. In this case a single row - the ORDER BY clause is redundant.

So the problem is that SQLite and MySQL are implementing the non-standard SQL extension of allowing an expression that is neither an aggregate or a part of the GROUP BY clause in the result-set of the SELECT in a different way.

 
2274 todo active 2007 Mar anonymous   2007 Mar drh 5 3 Sqlite segfaults consistently in FTS2 edit
Sqlite segfaults consistently in FTS2

sqlite> delete from mail where subject_='backup failed'; bt

  Program received signal EXC_BAD_ACCESS, Could not access memory.
  Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
  0x00025726 in deleteTerms (v=0x404e20, pTerms=0xbfffe95c,   iRowid=10503) at ./ext/fts2/fts2.c:1418
1418      return string_dup_n(s, strlen(s));
  (gdb) bt
  #0  0x00025726 in deleteTerms (v=0x404e20, pTerms=0xbfffe95c, iRowid=10503) at ./ext/fts2/fts2.c:1418
  #1  0x00028c49 in fulltextUpdate (pVtab=0x404e20, nArg=1, ppArg=0x180e440, pRowid=0xbfffebf8) at ./ext/fts2/fts2.c:3678
  #2  0x000541df in sqlite3VdbeExec (p=0x180de00) at ./src/vdbe.c:4877
  #3  0x00012b46 in sqlite3_step (pStmt=0x180de00) at ./src/vdbeapi.c:236
#4  0x0001c392 in sqlite3_exec (db=0x400180, zSql=0x404850 "delete from mail where subject_='backup failed';", xCallback=0x3902 <callback>, pArg=0xbfffee94, pzErrMsg=0xbfffeddc) at ./src/legacy.c:78
#5  0x00006c86 in process_input (p=0xbfffee94, in=0x0) at ./src/shell.c:1649
#6  0x0000746f in main (argc=2, argv=0xbffff81c) at ./src/shell.c:1979
(gdb)
 
2187 todo active 2007 Jan anonymous   2007 Jan   3 4 RAISE in trigger not being caught by CONFLICT clause in calling SQL edit
When an exception is raised within a trigger, the on conflict clause on the calling SQL statement is not being invoked.

Note: The CASE statement in example is to demonstrate the error, a CHECK Constraint would have been more appropriate if this were a real world senario.

Sample SQL Below:


CREATE TABLE abc (a);

CREATE TRIGGER abc_insert BEFORE INSERT ON abc BEGIN
SELECT CASE WHEN (new.a > 2) THEN
RAISE(ABORT, 'error here')
END;
END;

BEGIN;
INSERT INTO abc VALUES (1);

-- This should raise error but not rollback
INSERT INTO abc VALUES (4);

-- This should raise error and rollback
INSERT OR ROLLBACK INTO abc VALUES (4);

-- Check to see if ROLLBACK performed (which it hasn't)
SELECT * FROM abc;

 
1636 todo active 2006 Jan anonymous Shell 2006 Jan drh 4 3 stdev does not work edit
When trying to calculate standard deviation I get the following error message: SQL error: no such function: stdev How does SQLite support statistical function stdev? What is the correct name of the function? The same with sqr and sqrt. What are the names for square and square-root? Is there any other way to use SQLite for statistical calculations?
 
1203 todo active 2005 Apr anonymous   2005 Apr   4 5 Web site problem, download links edit
it seems that your download links are broken. the starting http:// is missing at the begin of a href-anchors..
 
1184 todo active 2005 Mar danielk1977 CodeGen 2005 Mar   4 3 UTF-8 and UTF-16 substr() functions are subtly different edit
If you pass 0 as the second argument of substr() it is interpreted differently by the two different substr() functions. The documentation doesn't say what the correct result should be.

  SQLite version 3.2.0
  Enter ".help" for instructions
  sqlite> select substr('ABCDE', 0, 2);
  AB
  sqlite> pragma encoding = "utf-16";
  sqlite> select substr('ABCDE', 0, 2);

  sqlite>
 
971 todo active 2004 Oct anonymous Unknown 2004 Oct peter 2 1 how to recompile sqlite with THREADSAFE preprocessor macro set to 1? edit
I have just installed sqlite-2.8.15 on my linux machine. After that I've tried to run the sqlite.php file which returns the fatal error as like below:

Call to undefined function: sqlite_open() in /home/maintain/public_html/tmp/sqlite.php on line 2

As per the instruction given in the forum, I have learn that I have to recompile the sqlite with THREADSAFE preprocessor macro set to 1, but I really don't know how to do this. Kindly help me on this issue.

Thanks and Regards, Rajesh Kannan M

 
833 todo active 2004 Jul anonymous Unknown 2004 Jul   1 3 port of sqlite 2.8.15 to djgpp edit
here is a diff to be applied on sqlite 2.8.15 to make it work with djgpp.

some of the fixes are needed for general purpose, such as relative path handling, and bypass of history and readline wherever not present.

anyway, i see no harm to apply this patch to mainstream sqlite.

best regards,

alex <alexbodn@012.net.il>

 
762 todo active 2004 Jun anonymous Unknown 2004 Jun anonymous 4 3 Windows pre-compiled binaries are 2.8.13, not 2.8.14 edit
Windows pre-compiled binaries are 2.8.13, not 2.8.14
 
644 todo active 2004 Mar anonymous Unknown 2004 Mar   1 3 How do you fix "SQL error: database disk image is malformed" edit
I have a program, that I exit using ^C. When that happens and I attempt to access the table that it was writing to, I sometimes get the following error. How do you fix "SQL error: database disk image is malformed"

Isn't the database supposed to be able to rollback partial writes?

 
621 todo active 2004 Feb anonymous Unknown 2004 Feb anonymous 3 3 Assorted errors running test's on MAC OSX edit
Mac OSX 10.3.2, gcc 3.3
sqlite 2.8.12 built from tarball

Running tests gave following errors

date-8.1...
Expected: [{2003-10-26 12:34:00}]
Got: [{2004-02-22 21:46:56}]
date-8.2...
Expected: [{2003-10-27 12:34:00}]
Got: [{2004-02-23 21:46:56}]
date-8.3...
Expected: [{2003-10-28 12:34:00}]
Got: [{2004-02-24 21:46:56}]
date-8.4...
Expected: [{2003-10-22 12:34:00}]
Got: [{2004-02-25 21:46:56}]
date-8.5...
Expected: [{2003-10-01 00:00:00}]
Got: [{2004-02-01 00:00:00}]
date-8.6...
Expected: [{2003-01-01 00:00:00}]
Got: [{2004-01-01 00:00:00}]
date-8.7...
Expected: [{2003-10-22 00:00:00}]
Got: [{2004-02-20 00:00:00}]
date-8.8...
Expected: [{2003-10-23 12:34:00}]
Got: [{2004-02-21 21:46:56}]
date-8.9...
Expected: [{2003-10-23 12:34:00}]
Got: [{2004-02-21 21:46:56}]
date-8.10...
Expected: [{2003-10-23 18:34:00}]
Got: [{2004-02-22 03:46:56}]
date-8.11...
Expected: [{2003-10-21 12:34:00}]
Got: [{2004-02-19 21:46:56}]
*** Giving up...
11 errors out of 103 tests
Failures on these tests: date-8.1 date-8.2 date-8.3 date-8.4 date-8.5 date-8.6 date-8.7 date-8.8 date-8.9 date-8.10 date-8.11
format3-5.1...
Expected: [3 121 3]
Got: [3 121 0]
format3-5.2...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.3...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.4...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.5...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.6...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.7...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.8...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.9...
Expected: [3 144 3]
Got: [3 144 0]
format3-5.10...
Expected: [3 121 3]
Got: [3 121 0]
format3-5.11...
Expected: [3 100 3]
Got: [3 100 0]
*** Giving up...
11 errors out of 48 tests
Failures on these tests: format3-5.1 format3-5.2 format3-5.3 format3-5.4 format3-5.5 format3-5.6 format3-5.7 format3-5.8 format3-5.9 format3-5.10 format3-5.11
index-11.1...
Expected: [0.10 3]
Got: [0.10 0]
index-11.2... Ok
1 errors out of 84 tests
Failures on these tests: index-11.1
intpkey-3.2... Ok
intpkey-3.3...
Expected: [5 hello world 2]
Got: [5 hello world 0]
intpkey-3.4...
Expected: [5 hello world 3]
Got: [5 hello world 0]
intpkey-3.5... Ok
intpkey-3.6...
Expected: [5 hello world 3]
Got: [5 hello world 0]
intpkey-3.7...
Expected: [5 hello world 11 hello world 5]
Got: [5 hello world 11 hello world 0]
intpkey-3.8...
Expected: [11 hello world 5]
Got: [11 hello world 0]
intpkey-3.9...
Expected: [11 hello world 1]
Got: [11 hello world 0]
intpkey-4.1... Ok
intpkey-4.7...
Expected: [11 hello world 1]
Got: [11 hello world 0]
intpkey-4.8...
Expected: [11 hello world 1]
Got: [11 hello world 0]
intpkey-4.9...
Expected: [11 hello world 1]
Got: [11 hello world 0]
intpkey-4.10...
Expected: [-4 y z 1]
Got: [-4 y z 0]
intpkey-4.11...
Expected: [-4 y z 1]
Got: [-4 y z 0]
*** Giving up...
11 errors out of 54 tests
Failures on these tests: intpkey-3.3 intpkey-3.4 intpkey-3.6 intpkey-3.7 intpkey-3.8 intpkey-3.9 intpkey-4.7 intpkey-4.8 intpkey-4.9 intpkey-4.10 intpkey-4.11
ioerr-1.1.3... Ok
ioerr-2.1.1...
Error: no such function: randstr
ioerr-2.1.2... Ok
testfixture: can't read "cksum": no such variable
while executing
"do_test ioerr-2.$n.3 {
set r [catch {db eval {
VACUUM;
}} msg]
# puts "error_pending=$::sqlite_io_error_pending"
# if {$r} {puts..."
("for" body line 32)
invoked from within
"for {set n 1} {$go} {incr n} {
do_test ioerr-2.$n.1 {
set ::sqlite_io_error_pending 0
db close
catch {file delete -force test.db}
ca..."
(file "../sqlite/test/ioerr.test" line 73)
memdb-1.1...
Error: no such function: randstr
memdb-1.2.1-0...
Error: cannot start a transaction within a transaction
memdb-1.2.2-0...
Error: cannot start a transaction within a transaction
memdb-1.2.9-0...
Error: no such function: randstr
memdb-1.3.1-0...
Error: cannot start a transaction within a transaction
memdb-1.3.2-0...
Error: cannot start a transaction within a transaction
memdb-1.3.9-0...
Error: no such function: randstr
memdb-1.4.1-0...
Error: cannot start a transaction within a transaction
memdb-1.4.2-0...
Error: cannot start a transaction within a transaction
memdb-1.4.9-0...
Error: no such function: randstr
memdb-1.5.1-0...
Error: cannot start a transaction within a transaction
*** Giving up...
11 errors out of 11 tests
Failures on these tests: memdb-1.1 memdb-1.2.1-0 memdb-1.2.2-0 memdb-1.2.9-0 memdb-1.3.1-0 memdb-1.3.2-0 memdb-1.3.9-0 memdb-1.4.1-0 memdb-1.4.2-0 memdb-1.4.9-0 memdb-1.5.1-0
minmax-1.1... Ok
minmax-1.2...
Expected: [19]
Got: [0]
minmax-1.3... Ok
minmax-1.4...
Expected: [19]
Got: [0]
minmax-1.5... Ok
minmax-1.6...
Expected: [1]
Got: [0]
minmax-1.7... Ok
minmax-1.8...
Expected: [1]
Got: [0]
minmax-1.9... Ok
minmax-1.10...
Expected: [19]
Got: [0]
minmax-2.0... Ok
5 errors out of 38 tests
Failures on these tests: minmax-1.2 minmax-1.4 minmax-1.6 minmax-1.8 minmax-1.10
rowid-4.5...
Expected: [4 3]
Got: [4 0]
rowid-4.5.1...
Expected: [3 3]
Got: [3 0]
rowid-4.6... Ok
rowid-11.4... Ok
2 errors out of 123 tests
Failures on these tests: rowid-4.5 rowid-4.5.1
select2-3.2d...
Expected: [3]
Got: [0]
select2-3.2e...
Expected: [3]
Got: [0]
select2-3.3...
Expected: [29999]
Got: [0]
select2-4.1... Ok
3 errors out of 19 tests
Failures on these tests: select2-3.2d select2-3.2e select2-3.3
trans-8.3... Ok
trans-9.1...
Error: no such function: randstr
trans-9.2.1-0...
Error: cannot start a transaction within a transaction
trans-9.2.2-0...
Error: cannot start a transaction within a transaction
trans-9.2.9-0...
Error: no such function: randstr
trans-9.3.1-0...
Error: cannot start a transaction within a transaction
trans-9.3.2-0...
Error: cannot start a transaction within a transaction
trans-9.3.9-0...
Error: no such function: randstr
trans-9.4.1-0...
Error: cannot start a transaction within a transaction
trans-9.4.2-0...
Error: cannot start a transaction within a transaction
trans-9.4.9-0...
Error: no such function: randstr
trans-9.5.1-0...
Error: cannot start a transaction within a transaction
*** Giving up...
11 errors out of 130 tests
Failures on these tests: trans-9.1 trans-9.2.1-0 trans-9.2.2-0 trans-9.2.9-0 trans-9.3.1-0 trans-9.3.2-0 trans-9.3.9-0 trans-9.4.1-0 trans-9.4.2-0 trans-9.4.9-0 trans-9.5.1-0
vacuum-1.1...
Error: no such function: randstr
testfixture: can't read "cksum": no such variable
while executing
"do_test vacuum-1.2 {
execsql {
VACUUM;
}
cksum
} $cksum"
(file "../sqlite/test/vacuum.test" line 53)
where-1.0... Ok
where-1.1...
Expected: [3 121 3]
Got: [3 121 0]
where-1.2...
Expected: [3 144 3]
Got: [3 144 0]
where-1.3...
Expected: [3 144 3]
Got: [3 144 0]
where-1.4...
Expected: [3 144 3]
Got: [3 144 0]
where-1.5...
Expected: [3 144 3]
Got: [3 144 0]
where-1.6...
Expected: [3 144 3]
Got: [3 144 0]
where-1.7...
Expected: [3 144 3]
Got: [3 144 0]
where-1.8...
Expected: [3 144 3]
Got: [3 144 0]
where-1.9...
Expected: [3 144 3]
Got: [3 144 0]
where-1.10...
Expected: [3 121 3]
Got: [3 121 0]
where-1.11...
Expected: [3 100 3]
Got: [3 100 0]
*** Giving up...
11 errors out of 12 tests
Failures on these tests: where-1.1 where-1.2 where-1.3 where-1.4 where-1.5 where-1.6 where-1.7 where-1.8 where-1.9 where-1.10 where-1.11

2004-Feb-20 22:48:00 by anonymous:
I looked up a previous bug I reported, and following the recommended solution , reran configure with --disable-shared.

running 'make test' showed only one error remained

format 3-11.3 expected [1] got [0]

 
591 todo active 2004 Feb anonymous Unknown 2004 Feb anonymous 5 4 "PRAGMA table_info" doesn't show you which column is unique edit
"PRAGMA table_info" doesn't show you which column is unique. If we want to know if any column is unique, we have to use this query : select **** from sqlite_master.
 
411 todo active 2003 Jul anonymous   2003 Jul drh 1 1 support for sign function in select edit
     Adding the sign function to the select statement would 
     greatly enhance sqlite. Specifically, it would allow 
     the use of characteristic functions, which I believe 
     falls under the SQL92 standard. These characteristic 
     functions are very handy for creating pivot tables.

     Consider the following example which works in MySQL:

     CREATE TABLE exams (
       pkey int(11) ,
       name varchar(15),
       exam int,
       score int,
       PRIMARY KEY  (pkey)

     );

     insert into exams (name,exam,score) values ('Bob',1,75);
     insert into exams (name,exam,score) values ('Bob',2,77);
     insert into exams (name,exam,score) values ('Bob',3,78);
     insert into exams (name,exam,score) values ('Bob',4,80);

     insert into exams (name,exam,score) values ('Sue',1,90);
     insert into exams (name,exam,score) values ('Sue',2,97);
     insert into exams (name,exam,score) values ('Sue',3,98);
     insert into exams (name,exam,score) values ('Sue',4,99);

     select * from exams;
     +------+------+------+-------+
     | pkey | name | exam | score |
     +------+------+------+-------+
     |    1 | Bob  |    1 |    75 |
     |    2 | Bob  |    2 |    77 |
     |    3 | Bob  |    3 |    78 |
     |    4 | Bob  |    4 |    80 |
     |    5 | Sue  |    1 |    90 |
     |    6 | Sue  |    2 |    97 |
     |    7 | Sue  |    3 |    98 |
     |    8 | Sue  |    4 |    99 |
     +------+------+------+-------+
     8 rows in set (0.00 sec)

     select name,
     sum(score*(1-abs(sign(exam-1)))) as exam1,
     sum(score*(1-abs(sign(exam-2)))) as exam2,
     sum(score*(1-abs(sign(exam-3)))) as exam3,
     sum(score*(1-abs(sign(exam-4)))) as exam4
     from exams group by name;

     +------+-------+-------+-------+-------+
     | name | exam1 | exam2 | exam3 | exam4 |
     +------+-------+-------+-------+-------+
     | Bob  |    75 |    77 |    78 |    80 |
     | Sue  |    90 |    97 |    98 |    99 |
     +------+-------+-------+-------+-------+
     2 rows in set (0.00 sec)

     Note the last select statements pivots the select entries.

     More examples can be found at http://sqlchar.sourceforge.net/index.php

     It would be wonderful to have this feature available in sqlite.

     Regards,

     Mike
     Mike Chirico (mchirico@med.upenn.edu)
 
96 todo active 2002 Jul drh   2002 Jul drh 1 1 Handle problems resulting from fork() edit
Update the documentation to explicitly state that SQLite database connections should not be carried across a fork() under Unix. Try to detect when this rule is broken and return SQLITE_MISUSE.
The code is in place. We need to test it and add caveats to the documentation telling the user not to keep SQLite connections open across a fork().


2006-Nov-03 23:44:46 by anonymous:
Using pthread_atfork(3C) sqlite3 could re-open open files on fork(2).
 
98 todo active 2002 Jul drh   2002 Jul drh 1 1 Document and test TEMPORARY views edit
Add documentation and tests for TEMPORARY views.
 
2336 warn active 2007 May anonymous   2008 Jan   4 4 Compiler warnings on strcpy(), sprintf(), et al. edit
OpenBSD's gcc compiler reports link warnings concerning potential insecure use of certain functions that have a history of abuse, such as strcpy, strcat, sprintf. It would be nice if SQLite could use the more secure version when possible.

/home/achowe/Projects/org/sqlite/lib/libsqlite3.a(util.o)(.text+0x184): In function `sqlite3StrDup': : warning: strcpy() is almost always misused, please use strlcpy() /home/achowe/Projects/org/sqlite/lib/libsqlite3.a(os_unix.o)(.text+0x822): In function `sqlite3UnixTempFileName': : warning: sprintf() is often misused, please use snprintf()

There was no misuse of these functions. But we'll get rid of them to avoid the library dependency.

For those that think that the use of strcpy() is a security problem: if you will check the diffs for this check-in you will see that by avoiding the use of strcpy() we have made the code more obtuse and more likely to contain a security bug, not the other way around. But at least now the compiler will not give warnings about strcpy()...


2007-May-04 15:43:08 by anonymous:
Some are still left in fts1.c and fts2.c.


2008-Jan-07 10:54:43 by anonymous:
SQLite 3.5.4 now generates new warnings on OpenBSD concerning unsafe functions.

gcc -g -O2 -o lemon ./tool/lemon.c /tmp//cco18706.o(.text+0x14df): In function `ErrorMsg': tool/lemon.c:1327: warning: vsprintf() is often misused, please use vsnprintf() /tmp//cco18706.o(.text+0x1655): In function `handle_D_option': tool/lemon.c:1378: warning: strcpy() is almost always misused, please use strlcpy() /tmp//cco18706.o(.text+0x14a2): In function `ErrorMsg': tool/lemon.c:1319: warning: sprintf() is often misused, please use snprintf() /tmp//cco18706.o(.text+0x3918): In function `file_makename': tool/lemon.c:2678: warning: strcat() is almost always misused, please use strlcat()

 
2776 warn active 2007 Nov anonymous   2007 Nov   5 1 mailing list edit
sqlite-users-digest doesn't work. It remembers registered addresses but doesn't send any emails.
 
2749 warn active 2007 Oct anonymous   2007 Oct   3 4 SQLITE_OMIT_FLOATING_POINT, int constants too large edit
Hiya!

i'm working from the 3.5.1 (CVS version) of the amalgamation. The code was pulled from CVS sometime around Oct 27th 2007.

Platform: Kubuntu Linux 7.04, i386-32, gcc 4.1.2.

The compiler output says it all:

  gcc -c -DSQLITE_OMIT_FLOATING_POINT sqlite3.c
  sqlite3.c: In function 'bestVirtualIndex':
  sqlite3.c:65531: warning: integer constant is too large for 'long' type
  sqlite3.c: In function 'bestIndex':
  sqlite3.c:65600: warning: integer constant is too large for 'long' type
  sqlite3.c: In function 'sqlite3WhereBegin':
  sqlite3.c:66223: warning: integer constant is too large for 'long' type
  sqlite3.c:66248: warning: integer constant is too large for 'long' type
  sqlite3.c:66254: warning: integer constant is too large for 'long' type

These warnings would seem to indicate potentially serious problems, though i admittedly have not investigated whether overflows are really fatal in the affected contexts.

 
2748 warn active 2007 Oct anonymous   2007 Oct   4 4 amalgamation: SQLITE_OMIT_ALTERTABLE warnings edit
Hiya!

i'm working from the 3.5.1 (CVS version) of the amalgamation. The code was pulled from CVS sometime around Oct 27th 2007.

The compiler output says it all:

  gcc -c -DSQLITE_OMIT_ALTERTABLE sqlite3.c
  sqlite3.c:6909: warning: 'sqlite3AlterRenameTable' used but never defined
  sqlite3.c:6916: warning: 'sqlite3AlterFinishAddColumn' used but never defined
  sqlite3.c:6917: warning: 'sqlite3AlterBeginAddColumn' used but never defined

The relevant code is:

  sed -ne '6909p;6916p;6917p' sqlite3.c
  SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
  SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
  SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);

Platform: Kubuntu Linux 7.04, i386, gcc 4.1.2.

 
2473 warn active 2007 Jun anonymous   2007 Jun anonymous 3 2 sqlite memory org. on linux edit
i use sqlite on linux (2.4.35) and on FreePascal... i write an simple example code on linux_&_sqlite_&_freepascal. when working my example code on tty1, i run ps command on tty2; multiple process id showing about my example program... my example code is very simple... before v3.3.13 : no problem; but v3.3.17 and later is wrong... (excuse my poor english)
2007-Jun-28 13:10:10 by anonymous:
There is no bug mentioned in this ticket.


2007-Jun-28 14:09:36 by drh:
I think I see a hint of a bug report in the description where it says "before v3.3.13: no problem; but v3.3.17 and later is wrong". But that is not anything near enough information to isolate and fix the problem.

halukduman09: Please find a friend or coworker who speaks good English and ask that person to translate for you. We can only help you if we can understand what you are saying. Thanks.

 
2401 warn active 2007 Jun anonymous   2007 Jun   1 1 I can't send anything to the contrib page edit
I am trying to send a .zip file that is almost 3 meg in size to the contrib page.

I have a login and password.

When I try to upload the file I get a server error.

Is my file too large?

Thanks

Tony Scarpelli Computer Systems Specialist Maine Medical Center Portland Maine 207-662-4987

 
2283 warn active 2007 Apr anonymous   2007 Apr   1 1 Compile warning by VCToolkit2003 edit
sqlite3.c D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5494) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5495) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5600) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5601) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5604) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5605) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5606) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5607) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5622) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5623) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5625) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5668) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5674) : warning C4244: '=' : conversion from 'double' to 'time_t', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5785) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5791) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5883) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5889) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(5895) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(6104) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(9622) : warning C4244: '=' : conversion from 'u64' to 'unsigned char', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(9625) : warning C4244: '=' : conversion from 'u64' to 'unsigned char', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(9632) : warning C4244: '=' : conversion from 'u64' to 'u8', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(16030) : warning C4244: 'initializing' : conversion from 'i64' to 'LONG', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(16031) : warning C4244: 'initializing' : conversion from 'i64' to 'LONG', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(16071) : warning C4244: 'initializing' : conversion from 'i64' to 'LONG', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(16075) : warning C4244: 'function' : conversion from 'i64' to 'LONG', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(17312) : warning C4018: '<' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(17903) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(17908) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18120) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18128) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18146) : warning C4018: '<' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18264) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18280) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18668) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18674) : warning C4244: 'return' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(18771) : warning C4018: '<=' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(19202) : warning C4018: '<=' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(20253) : warning C4018: '>' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(20470) : warning C4018: '<=' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(21671) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(21673) : warning C4244: 'function' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(23335) : warning C4018: '>' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(23335) : warning C4018: '<=' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(23977) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(23983) : warning C4018: '>' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24117) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24124) : warning C4018: '>' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24437) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24437) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24439) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24441) : warning C4244: 'function' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24442) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24442) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24815) : warning C4018: '>' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(24976) : warning C4018: '>' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(25046) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(25048) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(26605) : warning C4018: '>' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(27294) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(27821) : warning C4101: 'rc' : unreferenced local variable D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(28087) : warning C4244: '=' : conversion from 'double' to 'i64', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(28325) : warning C4244: '=' : conversion from 'const i64' to 'double', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(28330) : warning C4244: '=' : conversion from 'const i64' to 'double', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30422) : warning C4244: 'return' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30479) : warning C4244: '=' : conversion from 'u64' to 'unsigned char', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30644) : warning C4018: '>=' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30646) : warning C4018: '>=' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30671) : warning C4018: '<' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30673) : warning C4018: '<' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30717) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30756) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(30860) : warning C4244: 'return' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(31019) : warning C4244: '=' : conversion from 'double' to 'i64', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(31056) : warning C4244: '=' : conversion from 'double' to 'u64', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(33652) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(33718) : warning C4018: '>=' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(33736) : warning C4018: '<' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(33751) : warning C4018: '<' : signed/unsigned mismatch D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(34173) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(34177) : warning C4244: '=' : conversion from 'i64' to 'u8', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(34279) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(34297) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(35189) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(35869) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(35875) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(36389) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(36403) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(46396) : warning C4244: 'initializing' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(46397) : warning C4244: 'initializing' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(46398) : warning C4244: 'initializing' : conversion from 'i64' to 'int', possible loss of data D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(56943) : warning C4005: 'ARRAYSIZE' : macro redefinition D:\Ulti\SDK\Include\WinNT.h(950) : see previous definition of 'ARRAYSIZE' D:\Ulti\MyApps\USQLite3\SQLite\sqlite3.c(58192) : warning C4244: '=' : conversion from 'u16' to 'unsigned char', possible loss of data USQLite3: 2 file(s) built in (0:04.04), 2022 msecs / file, duration = 4586 msecs
 
2098 warn active 2006 Dec anonymous   2006 Dec   1 1 php sqlite problem after commit transaction edit
please see php bugs

http://bugs.php.net/bug.php?id=39735&thanks=2

the error: COMMIT TRANSACTION; begin transaction; PRAGMA default_synchronous=NORMAL; PRAGMA auto_vacuum=1; PRAGMA synchronous=NORMAL; PRAGMA default_temp_store=MEMORY; PRAGMA temp_store=MEMORY; PRAGMA case_sensitive_like=0; PRAGMA encoding=\"UTF-8\"; COMMIT TRANSACTION; <-- here php(sqlite) crash

error message: php: ./src/pager.c:1237: syncJournal: Assertion `pPg->needSync==0' failed. Aborted

php 5.1.6

2006-Dec-04 23:41:22 by drh:
The code in question has been essentially unchanged for three years. This is the first report of this bug. Meanwhile, most of the rest of the world has moved on to use SQLite version 3.x.

Your work-around is to issued the pragmas separately, not inside a transaction.

We will keep this bug on file and work on it as time permits. But because the problem appears to be in 3-year-old code, does not lead to data loss or database corruption, does not impact any paid support customers, and because nobody has ever run into it before, this bug will be fixed at a very low priority. Please do not expect it to be fixed anytime soon.

 
1820 warn active 2006 May anonymous TclLib 2006 Oct anonymous 5 1 make: *** [tclsqlite.lo] Error 1 edit
unding ReHatlinux9.0

$ make .............. .............. ./libtool --mode=compile gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I../sqlite-3.3.5/src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_CURSOR -c ../sqlite-3.3.5/src/tclsqlite.c gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I../sqlite-3.3.5/src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_CURSOR -c ../sqlite-3.3.5/src/tclsqlite.c -fPIC -DPIC -o .libs/tclsqlite.o ../sqlite-3.3.5/src/tclsqlite.c: In function `DbUpdateHandler': ../sqlite-3.3.5/src/tclsqlite.c:333: warning: passing arg 3 of `Tcl_ListObjAppendElement' makes pointer from integer without a cast ../sqlite-3.3.5/src/tclsqlite.c: In function `tclSqlFunc': ../sqlite-3.3.5/src/tclsqlite.c:419: warning: passing arg 1 of `Tcl_NewByteArrayObj' discards qualifiers from pointer target type ../sqlite-3.3.5/src/tclsqlite.c:427: warning: assignment makes pointer from integer without a cast ../sqlite-3.3.5/src/tclsqlite.c:485: `Tcl_WideInt' undeclared (first use in this function) ../sqlite-3.3.5/src/tclsqlite.c:485: (Each undeclared identifier is reported only once ../sqlite-3.3.5/src/tclsqlite.c:485: for each function it appears in.) ../sqlite-3.3.5/src/tclsqlite.c:485: parse error before "v" ../sqlite-3.3.5/src/tclsqlite.c:486: `v' undeclared (first use in this function) ../sqlite-3.3.5/src/tclsqlite.c: In function `DbObjCmd': ../sqlite-3.3.5/src/tclsqlite.c:685: warning: passing arg 3 of `Tcl_GetIndexFromObj' from incompatible pointer type ../sqlite-3.3.5/src/tclsqlite.c:1309: warning: passing arg 2 of `Tcl_GetVar2Ex' discards qualifiers from pointer target type ../sqlite-3.3.5/src/tclsqlite.c:1331: `Tcl_WideInt' undeclared (first use in this function) ../sqlite-3.3.5/src/tclsqlite.c:1331: parse error before "v" ../sqlite-3.3.5/src/tclsqlite.c:1332: `v' undeclared (first use in this function) ../sqlite-3.3.5/src/tclsqlite.c:1382: warning: passing arg 1 of `Tcl_NewByteArrayObj' discards qualifiers from pointer target type ../sqlite-3.3.5/src/tclsqlite.c:1390: warning: assignment makes pointer from integer without a cast ../sqlite-3.3.5/src/tclsqlite.c:1838: warning: passing arg 3 of `Tcl_GetIndexFromObj' from incompatible pointer type ../sqlite-3.3.5/src/tclsqlite.c: In function `DbMain': ../sqlite-3.3.5/src/tclsqlite.c:2024: warning: passing arg 2 of `Tcl_CreateObjCommand' discards qualifiers from pointer target type make: *** [tclsqlite.lo] Error 1

To solve this error, install ActiveTCL and then: ../sqlite-3.3.8/configure --with-tcl=/usr/local/ActiveTcl/lib make
 
2004 warn active 2006 Sep anonymous   2006 Sep   1 4 vtab.c:142: warning: pointer targets in initialization differ in signe edit
const unsigned char *z = pParse->sArg.z;

fix this warning but then this warning appears:

vtab.c:145: warning: pointer targets in passing argument 1 of 'sqlite3StrNDup' differ in signedness

which can be fixed with:

addModuleArgument(pParse->pNewTable, sqliteStrNDup((char *)z, n));

 
1786 warn active 2006 Apr anonymous   2006 Apr   4 4 Yet another list of compiler warnings. edit
I compiled sqlite 3.3.5 from sqlite-source-3_3_5.zip using msvc 2005. Similar warnings show up with both gcc4 on mac (and I assume other platforms) and using sun studio on both solaris and linux. On msvc I set to the higest warning level, then disabled the following warnings which are in my opinion not real issues (4311;4312;4100;4210;4127). Most of the warnings follow the general form of int to smaller size int truncation without explicit cast, float or double sized type to int without explicit cast, or comparison of a signed to unsigned type. The following is my build log showing the warnings:

------ Rebuild All started: Project: sqlite, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'sqlite', configuration 'Debug|Win32'
Compiling...
alter.c
analyze.c
attach.c
c:\src\sqlite-source-3_3_5\attach.c(314) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
auth.c
btree.c
c:\src\sqlite-source-3_3_5\btree.c(449) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(450) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(453) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(454) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(455) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(456) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(538) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(540) : warning C4244: 'function' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(831) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(898) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(955) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(961) : warning C4244: '=' : conversion from 'u32' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(967) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(986) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(988) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(990) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1174) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(1226) : warning C4244: '-=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1239) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1303) : warning C4244: '+=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1316) : warning C4244: '-=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1342) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1343) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1344) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1349) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1350) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1353) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1354) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1356) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1405) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1407) : warning C4244: '=' : conversion from 'u32' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1435) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1460) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1465) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1467) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1468) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1661) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1663) : warning C4244: '=' : conversion from 'u32' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1692) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1865) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1867) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1949) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(1950) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(2056) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(2206) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(2267) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(2374) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(2397) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(2402) : warning C4018: '>' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(2402) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(2405) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(2418) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(2475) : warning C4389: '!=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(2814) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(2990) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(2996) : warning C4018: '>' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(3129) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3136) : warning C4018: '>' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(3184) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3448) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3448) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3450) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3452) : warning C4244: 'function' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3453) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3453) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(3817) : warning C4018: '>' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(3854) : warning C4389: '!=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(3859) : warning C4389: '!=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(3869) : warning C4389: '!=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(3970) : warning C4018: '>' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(4029) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(4038) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(4040) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data

c:\src\sqlite-source-3_3_5\btree.c(4117) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(4242) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(4259) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(4322) : warning C4244: '-=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(4331) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(4611) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(4695) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5070) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(5499) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(5591) : warning C4018: '>' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(5725) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(5768) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(5774) : warning C4389: '!=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\btree.c(5895) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5896) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5897) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5898) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5899) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5905) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5924) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5941) : warning C4244: '=' : conversion from 'u32' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5948) : warning C4244: '=' : conversion from 'u32' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5958) : warning C4244: '=' : conversion from 'u32' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(5962) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(6281) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\btree.c(6444) : warning C4389: '!=' : signed/unsigned mismatch

c:\src\sqlite-source-3_3_5\btree.c(6448) : warning C4389: '==' : signed/unsigned mismatch
build.c
c:\src\sqlite-source-3_3_5\build.c(35) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(183) : warning C4244: 'function' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(262) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(320) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(347) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(363) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(522) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(552) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(556) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(620) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(622) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\build.c(955) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1127) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1128) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1216) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1302) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1319) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1324) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1330) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1481) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1531) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1538) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1555) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(1624) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2036) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2073) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2081) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2082) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2083) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2109) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2342) : warning C4267: '=' : conversion from 'size_t' to 'unsigned int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2345) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2354) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2361) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2382) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2383) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2429) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2490) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\build.c(2873) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
callback.c
c:\src\sqlite-source-3_3_5\callback.c(28) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\callback.c(59) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\callback.c(160) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\callback.c(301) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
complete.c
date.c
c:\src\sqlite-source-3_3_5\date.c(204) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(233) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(234) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(339) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(340) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(343) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(344) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(345) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(346) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(360) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(361) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(363) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(407) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(413) : warning C4244: '=' : conversion from 'double' to 'time_t', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(459) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(508) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(514) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(590) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(606) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(612) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(618) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(812) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(813) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(815) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(827) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(839) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(844) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(848) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\date.c(849) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
delete.c
c:\src\sqlite-source-3_3_5\delete.c(71) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\delete.c(165) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
expr.c
c:\src\sqlite-source-3_3_5\expr.c(201) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\expr.c(346) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\expr.c(1158) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\expr.c(1160) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
func.c
c:\src\sqlite-source-3_3_5\func.c(221) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(234) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(866) : warning C4244: 'initializing' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(867) : warning C4244: 'initializing' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(868) : warning C4244: 'initializing' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(869) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(1052) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(1074) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(1096) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\func.c(1098) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
hash.c
c:\src\sqlite-source-3_3_5\hash.c(35) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\hash.c(39) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\hash.c(105) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
insert.c
c:\src\sqlite-source-3_3_5\insert.c(993) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\insert.c(996) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
legacy.c
main.c
c:\src\sqlite-source-3_3_5\main.c(413) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\main.c(446) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\main.c(458) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\main.c(773) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\main.c(783) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\main.c(787) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\main.c(1102) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
opcodes.c
os.c
os_unix.c
os_win.c
c:\src\sqlite-source-3_3_5\os_win.c(781) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(785) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(873) : warning C4244: 'initializing' : conversion from 'i64' to 'LONG', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(874) : warning C4244: 'initializing' : conversion from 'i64' to 'LONG', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(880) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(915) : warning C4244: 'initializing' : conversion from 'i64' to 'LONG', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(919) : warning C4244: 'function' : conversion from 'i64' to 'LONG', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(959) : warning C4244: '=' : conversion from 'int' to 'short', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(1135) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\os_win.c(1199) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
Generating Code...
c:\src\sqlite-source-3_3_5\os_win.c(856) : warning C4701: potentially uninitialized local variable 'wrote' used
c:\src\sqlite-source-3_3_5\btree.c(5424) : warning C4701: potentially uninitialized local variable 'pNext' used
c:\src\sqlite-source-3_3_5\btree.c(5424) : warning C4701: potentially uninitialized local variable 'szNext' used
Compiling...
pager.c
c:\src\sqlite-source-3_3_5\pager.c(424) : warning C4244: '=' : conversion from 'u32' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(425) : warning C4244: '=' : conversion from 'u32' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(426) : warning C4244: '=' : conversion from 'u32' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(427) : warning C4244: '=' : conversion from 'u32' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(469) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(554) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(750) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(972) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(1075) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1080) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1289) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1297) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(1307) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(1423) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1440) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1498) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1499) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1500) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1617) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1647) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1648) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1662) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1663) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1664) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1666) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1799) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1805) : warning C4244: 'return' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(1890) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(1927) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(2268) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(2520) : warning C4389: '==' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(2637) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pager.c(3009) : warning C4389: '!=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(3628) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\pager.c(3629) : warning C4389: '!=' : signed/unsigned mismatch
parse.c
parse.c(1309) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
parse.y(154) : warning C4244: '=' : conversion from '__w64 unsigned int' to 'unsigned int', possible loss of data
parse.y(229) : warning C4244: '=' : conversion from '__w64 int' to 'unsigned int', possible loss of data
parse.y(233) : warning C4244: '=' : conversion from '__w64 int' to 'unsigned int', possible loss of data
parse.y(379) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
parse.y(451) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
parse.y(532) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
parse.y(536) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
parse.y(871) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
parse.y(880) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
parse.y(919) : warning C4244: '=' : conversion from '__w64 unsigned int' to 'unsigned int', possible loss of data
parse.c(3271) : warning C4244: 'function' : conversion from 'int' to 'unsigned char', possible loss of data
parse.c(3282) : warning C4244: 'function' : conversion from 'int' to 'unsigned char', possible loss of data
pragma.c
c:\src\sqlite-source-3_3_5\pragma.c(49) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\pragma.c(118) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\pragma.c(443) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
prepare.c
c:\src\sqlite-source-3_3_5\prepare.c(274) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\prepare.c(577) : warning C4244: 'function' : conversion from '__w64 int' to 'int', possible loss of data
printf.c
c:\src\sqlite-source-3_3_5\printf.c(413) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(426) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(493) : warning C4244: '=' : conversion from 'int' to 'etByte', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(503) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(517) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(540) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(543) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(544) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(551) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(579) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(581) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(596) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(620) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(621) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(644) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\printf.c(647) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
random.c
c:\src\sqlite-source-3_3_5\random.c(68) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\random.c(83) : warning C4244: '+=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\random.c(86) : warning C4244: '+=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\random.c(97) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
select.c
c:\src\sqlite-source-3_3_5\select.c(69) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\select.c(183) : warning C4267: '=' : conversion from 'size_t' to 'unsigned int', possible loss of data
c:\src\sqlite-source-3_3_5\select.c(557) : warning C4244: 'initializing' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\select.c(976) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\select.c(1004) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\select.c(1744) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\select.c(2231) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
shell.c
c:\src\sqlite-source-3_3_5\shell.c(387) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(407) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(409) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(586) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(587) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(738) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(838) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(880) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(941) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(961) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1005) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1035) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1042) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1056) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1148) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1236) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1353) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1472) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1477) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\shell.c(1698) : warning C4013: 'access' undefined; assuming extern returning int
table.c
tokenize.c
trigger.c
c:\src\sqlite-source-3_3_5\trigger.c(113) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\trigger.c(172) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\trigger.c(260) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\trigger.c(265) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\trigger.c(454) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\trigger.c(476) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\trigger.c(540) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\trigger.c(631) : warning C4267: '=' : conversion from 'size_t' to 'unsigned int', possible loss of data
update.c
c:\src\sqlite-source-3_3_5\update.c(155) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
utf.c
c:\src\sqlite-source-3_3_5\utf.c(326) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(326) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(326) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(326) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(326) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(326) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(333) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(333) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(333) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(333) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(333) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(333) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(336) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(344) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(350) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(353) : warning C4244: '=' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(501) : warning C4244: 'return' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\utf.c(549) : warning C4244: 'function' : conversion from '__w64 int' to 'int', possible loss of data
util.c
c:\src\sqlite-source-3_3_5\util.c(724) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(756) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(870) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(1040) : warning C4244: '=' : conversion from 'long double' to 'double', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(1041) : warning C4244: 'return' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(1226) : warning C4244: '=' : conversion from 'u64' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(1229) : warning C4244: '=' : conversion from 'u64' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(1236) : warning C4244: '=' : conversion from 'u64' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(1355) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\util.c(1360) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
vacuum.c
c:\src\sqlite-source-3_3_5\vacuum.c(131) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
vdbe.c
c:\src\sqlite-source-3_3_5\vdbe.c(662) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(677) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(693) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(752) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(1601) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(1931) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(1957) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbe.c(1997) : warning C4018: '>=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbe.c(2004) : warning C4018: '>=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbe.c(2013) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbe.c(2028) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbe.c(2312) : warning C4244: 'initializing' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2313) : warning C4244: 'initializing' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2450) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2454) : warning C4244: '=' : conversion from 'i64' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2554) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2572) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2614) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2615) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2628) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2788) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(2805) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(3064) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(3445) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(3546) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(3595) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(3601) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(3641) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(3809) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(4118) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(4131) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbe.c(4514) : warning C4244: 'initializing' : conversion from 'int' to 'u8', possible loss of data
vdbeapi.c
c:\src\sqlite-source-3_3_5\vdbeapi.c(55) : warning C4244: 'return' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeapi.c(201) : warning C4244: '=' : conversion from 'double' to 'i64', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeapi.c(238) : warning C4244: '=' : conversion from 'double' to 'u64', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeapi.c(650) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
vdbeaux.c
c:\src\sqlite-source-3_3_5\vdbeaux.c(117) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(482) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(527) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(531) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(564) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbeaux.c(659) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(676) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(862) : warning C4244: 'function' : conversion from '__w64 int' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(1034) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(1526) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(1595) : warning C4244: 'return' : conversion from 'i64' to 'u32', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(1651) : warning C4244: '=' : conversion from 'u64' to 'unsigned char', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(1813) : warning C4018: '>=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbeaux.c(1815) : warning C4018: '>=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbeaux.c(1841) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbeaux.c(1843) : warning C4018: '<' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbeaux.c(1887) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbeaux.c(1926) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
vdbefifo.c
vdbemem.c
c:\src\sqlite-source-3_3_5\vdbemem.c(49) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\vdbemem.c(194) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbemem.c(319) : warning C4244: '=' : conversion from 'double' to 'i64', possible loss of data
c:\src\sqlite-source-3_3_5\vdbemem.c(491) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
c:\src\sqlite-source-3_3_5\vdbemem.c(557) : warning C4244: '=' : conversion from 'const i64' to 'double', possible loss of data
c:\src\sqlite-source-3_3_5\vdbemem.c(562) : warning C4244: '=' : conversion from 'const i64' to 'double', possible loss of data
c:\src\sqlite-source-3_3_5\vdbemem.c(740) : warning C4018: '<=' : signed/unsigned mismatch
c:\src\sqlite-source-3_3_5\vdbemem.c(859) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
Generating Code...
c:\src\sqlite-source-3_3_5\select.c(3290) : warning C4701: potentially uninitialized local variable 'pTabList' used
c:\src\sqlite-source-3_3_5\select.c(3290) : warning C4701: potentially uninitialized local variable 'pEList' used
c:\src\sqlite-source-3_3_5\select.c(764) : warning C4701: potentially uninitialized local variable 'pseudoTab' used
c:\src\sqlite-source-3_3_5\printf.c(372) : warning C4701: potentially uninitialized local variable 'xtype' used
c:\src\sqlite-source-3_3_5\pager.c(1635) : warning C4701: potentially uninitialized local variable 'nameLen' used
Compiling...
where.c
c:\src\sqlite-source-3_3_5\where.c(227) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(581) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(582) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(583) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(594) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(604) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(605) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(608) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(630) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(702) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(743) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(744) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(1798) : warning C4244: 'function' : conversion from 'int' to 'u16', possible loss of data
c:\src\sqlite-source-3_3_5\where.c(1836) : warning C4244: 'function' : conversion from 'int' to 'u16', possible loss of data
Generating Code...
Creating library...
Build log was saved at "file://c:\src\sqlite-source-3_3_5\Debug\BuildLog.htm"
sqlite - 0 error(s), 451 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

 
1741 warn active 2006 Mar anonymous VDBE 2006 Mar   5 4 unused variable with SQLITE_OMIT_UTF16 defined edit
vdbemem.c, function sqlite3VdbeChangeEncoding():

int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
int rc;
if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
return SQLITE_OK;
}
#ifdef SQLITE_OMIT_UTF16
return SQLITE_ERROR;
#else
...
If SQLITE_OMIT_UTF16 is defined then the "rc" variable is unused and compiler (Windows Intel 7.0) emits useless warning.
 
1638 warn active 2006 Jan anonymous   2006 Jan   3 2 rows place change and some row element missing edit
there is a problem with my table row order.I miss one roe header and the next one come to its place.also there is a problem like this in the columns too.it does not occur when the table is list or line.but when I turn it into column mode the problem happens.my table become puzzling
 
1627 warn active 2006 Jan anonymous   2006 Jan   4 4 warnings on BCB and how to resolve them + couple of minor fixes edit
I took 3.3.1 sources (the preprocessed version) and tried to compile them on Borland C++ Builder 6.4.

I wanted to keep all compiler warnings switched on.

I got some warnings from sqlite source. Some due to strlen() returning unsigned, some due signed/unsigned comparison, some because BCB requires

  if (a = b) ...
to be rewritten as
  if ((a = b) != 0) ...

to avoid warnings.

List of places generating warnings and ways to shut then up are bellow. Perhaps these fixes may be applied to the codebase since the warnings may happen with other C++ compilers as well.

I cannot promise the fixes will work with 64bit architectures but it seems likely.


Some macros, like MASTER_NAME, may cause collisions. Perhaps they all can be prefixed with SQLITE3 or so to avoid such accidents.


The trick to enable NDEBUG in sqliteInt.h:

#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) # define NDEBUG 1 #endif

has unfortunate property of changing NDEBUG settings in those parts of a project using sqlite and not in the others.

It is hard to detect reason for possible problems.

I suggest: 1) Put on top of each sqlite source file

#define THIS_IS_SQLITE_SOURCE

2) Change the trick to:

#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) && (defined THIS_IS_SQLITE_SOURCE) # define NDEBUG 1 #endif


Small wish for the documentation: could there be information how to switch off all sqlite memory management and checking and leave it all to host's malloc/realloc/free?

I have very optimized dmalloc allocator and want to be sure there are no other layers above this. My allocator also does boundary checking and error detection.


---- FIXES TO GET RID OF WARNINGS ON BCB ---
vdbmem.c, line 725:

assert( strlen(pMem->z)<=pMem->n );

==>>

assert( (int)strlen(pMem->z)<=pMem->n );


vdbeaux.c:

line 545:

if( strlen(zTemp)+strlen(zNum)+1<=nTemp ){

==>>

if( (int)strlen(zTemp)+(int)strlen(zNum)+1<=nTemp ){

line 1740:

if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;

==>>

if( (int)d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;

line 1742:

if( d2>=nKey2 && sqlite3VdbeSerialTypeLen(serial_type2)>0 ) break;

==>>

if( (int)d2>=nKey2 && sqlite3VdbeSerialTypeLen(serial_type2)>0 ) break;

line 1768:

}else if( d1<nKey1 ){

==>>

}else if( (int)d1<nKey1 ){

line 1770:

}else if( d2<nKey2 ){

==>>

}else if( (int)d2<nKey2 ){


btree.c:

line 878:

assert( iCell<get2byte(&data[pPage->hdrOffset+3]) );

==>>

assert( iCell<(int)get2byte(&data[pPage->hdrOffset+3]) );

line 932:

if( nPayload<=pPage->maxLocal ){

==>>

if( (int)nPayload<=pPage->maxLocal ){

line 1150:

assert( nCell==get2byte(&data[hdr+3]) );

==>>

assert( nCell==(int)get2byte(&data[hdr+3]) );

line 2351:

if( origSize>=PENDING_BYTE_PAGE(pBt) && finSize<=PENDING_BYTE_PAGE(pBt) ){

==>>

if( (int)origSize>=PENDING_BYTE_PAGE(pBt) && (int)finSize<=PENDING_BYTE_PAGE(pBt) ){

line 2367:

if( PTRMAP_ISPAGE(pgsz, iDbPage) || iDbPage==PENDING_BYTE_PAGE(pBt) ){

==>>

if( PTRMAP_ISPAGE(pgsz, iDbPage) || (int)iDbPage==PENDING_BYTE_PAGE(pBt) ){

line 2916:

if( offset+amt > nKey+pCur->info.nData ){

==>>

if( offset+amt > (int)(nKey+pCur->info.nData) ){

line 3056:

if( nLocal>nKey ){

==>>

if( nLocal>(int)nKey ){

line 3737:

if( *pPgno>sqlite3pager_pagecount(pBt->pPager) ){

==>

if( *pPgno>(Pgno)sqlite3pager_pagecount(pBt->pPager) ){

line 3774:

assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );

==>>

assert( *pPgno!=(Pgno)PENDING_BYTE_PAGE(pBt) );

line 3779:

assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );

==>>

assert( *pPgno!=(Pgno)PENDING_BYTE_PAGE(pBt) );

line 3789:

assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );

==>>

assert( *pPgno!=(Pgno)PENDING_BYTE_PAGE(pBt) );

line 3879:

if( ovflPgno>sqlite3pager_pagecount(pBt->pPager) ){

==>>

if( ovflPgno>(Pgno)sqlite3pager_pagecount(pBt->pPager) ){

line 3774:

assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );

==>>

assert( *pPgno!=(Pgno)PENDING_BYTE_PAGE(pBt) );

line 3938:

assert( info.nData==nData );

==>>

assert( (int)info.nData==nData );

line 4166:

assert( end <= get2byte(&data[hdr+5]) );

==>>

assert( end <= (int)get2byte(&data[hdr+5]) );

line 4972:

assert( pgnoChild<=sqlite3pager_pagecount(pPage->pBt->pPager) );

==>>

assert( pgnoChild<=(Pgno)sqlite3pager_pagecount(pPage->pBt->pPager) );

line 5399:

pgnoRoot==PENDING_BYTE_PAGE(pBt) ){

==>>

pgnoRoot==(Pgno)PENDING_BYTE_PAGE(pBt) ){

line 5491:

if( pgno>sqlite3pager_pagecount(pBt->pPager) ){

==>>

if( pgno>(Pgno)sqlite3pager_pagecount(pBt->pPager) ){

line 5616:

if( iTable==maxRootPgno ){

==>>

if( iTable==(int)maxRootPgno ){

line 5659:

if( maxRootPgno==PENDING_BYTE_PAGE(pBt) ){

==>>

if( maxRootPgno==(Pgno)PENDING_BYTE_PAGE(pBt) ){

line 5665:

assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );

==>>

assert( maxRootPgno!=(Pgno)PENDING_BYTE_PAGE(pBt) );

  if(
    (rc = restoreOrClearCursorPosition(pCur, 1)) ||
    (rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur)) ||
    (rc = sqlite3pager_write(pPage->aData))
  ){

==>>

  if(
    (rc = restoreOrClearCursorPosition(pCur, 1)) != 0 ||
    (rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur)) != 0||
    (rc = sqlite3pager_write(pPage->aData)) != 0
  ){

(to get rid "possibly incorrect assigment" warning)

line 3353:

     int dummy;
     pCell += getVarint32(pCell, &dummy);

==>>

     u32 dummy;
     pCell += getVarint32(pCell, &dummy);

line 3342:

i64 nCellKey;

==>>

u64 nCellKey;

because it causes warning in line 3353 in getVarint(pCell, &nCellKey);


build.c:

line 622:

if( (!OMIT_TEMPDB || i!=1 ) && n==strlen(pDb->zName) &&

==>>

if( (!OMIT_TEMPDB || i!=1 ) && n==(int)strlen(pDb->zName) &&

line 2367:

pIndex->aiRowEst = (int *)(&pIndex->aiColumn[nCol]);

==>>

pIndex->aiRowEst = (unsigned *)(&pIndex->aiColumn[nCol]);

(the type is defined as unsigned in sqliteInt.h)


vdbe.c:

line 1967:

assert( p2<nField );

==>>

assert( p2<(int)nField );

line 1967:

if( avail>=payloadSize ){

==>>

if( avail>=(int)payloadSize ){

line 2019:

if( !zRec && avail<offset ){

==>>

if( !zRec && avail<(int)offset ){

line 2034:

for(i=0; i<nField; i++){

==>>

for(i=0; i<(int)nField; i++){


select.c, line 113:

if( p->n==keywords[j].nChar

==>>

if( (int)(p->n)==keywords[j].nChar


expr.c, line 350:

&& pE->token.n==n

==>>

&& (int)(pE->token.n)==n


shell.c: functions isatty() and access() are in <io.h> on Borland.

I suggest to add:

#if (defined __BORLANDC__) # include <io.h> #endif

and at the same time to comment out shell.c, line 59:

#if !(defined __BORLANDC__) extern int isatty(); #endif

Prototype on BCB is

int isatty(int handle);


pager.c:

line 600:

for(i=0; i<len; i++){

==>>

for(i=0; i<(int)len; i++){

line 1016:

if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){

==>>

if( pgno==0 || pgno==(Pgno)PAGER_MJ_PGNO(pPager) ){

line 1341:

assert( pPager->origDbSize==0 || pPager->origDbSize==mxPg );

==>>

assert( pPager->origDbSize==0 || (Pgno)(pPager->origDbSize)==mxPg );

line 1354:

for(i=0; i<nRec; i++){

==>>

for(i=0; i<(int)nRec; i++){

line 1935:

if( pPg->pgno<=dbSize ){

==>>

if( pPg->pgno<=(Pgno)dbSize ){

line 2308:

if( pList->pgno<=pPager->dbSize ){

==>>

if( pList->pgno<=(Pgno)(pPager->dbSize) ){

line 2560:

if( pgno>PAGER_MAX_PGNO || pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){

==>>

if( pgno>PAGER_MAX_PGNO || pgno==0 || pgno==(Pgno)PAGER_MJ_PGNO(pPager) ){

line 3043:

assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );

==>>

assert( pPg->pgno!=(Pgno)PAGER_MJ_PGNO(pPager) );

line 3672:

for( i=nTrunc+1; i<=pPager->origDbSize; i++ ){

==>>

for( i=nTrunc+1; i<=(Pgno)(pPager->origDbSize); i++ ){

line 3673:

if( !(pPager->aInJournal[i/8] & (1<<(i&7))) && i!=iSkip ){

==>>

if( !(pPager->aInJournal[i/8] & (1<<(i&7))) && i!=(Pgno)iSkip ){


printf.c, line 409:

*(--bufpt) = cset[longvalue%base];

==>>

*(--bufpt) = cset[(unsigned)(longvalue%base)];

Here BCB complains on using 64 bit integer as array index with warning "suspcious pointer conversion".


Lot of code complains on memory debug functions not compiled in but used within asserts:

util.c:

line 1360:

  assert( sqlite3ThreadData()->mallocDisallowed>=0 );
  sqlite3ThreadData()->mallocDisallowed++;

==>>

#ifdef SQLITE_MEMDEBUG assert( sqlite3ThreadData()->mallocDisallowed>=0 ); sqlite3ThreadData()->mallocDisallowed++; #endif

line 1369:

  assert( sqlite3ThreadData()->mallocDisallowed>0 );
  sqlite3ThreadData()->mallocDisallowed--;

==>>

#ifdef SQLITE_MEMDEBUG assert( sqlite3ThreadData()->mallocDisallowed>0 ); sqlite3ThreadData()->mallocDisallowed--; #endif

line 556:

while( !(p = OSMALLOC(n)) && sqlite3_release_memory(n) );

==>>

while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) );

This is officially BCB recommended trick to shut up "possibly incorrect assignement" message. The docs says:

if (a = b) ... should be rewritten as if ((a = b) != 0) ...

line 586:

while( !(np = OSREALLOC(p, n)) && sqlite3_release_memory(n) );

==>>

while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) );

line 739:

if( db && (db->pErr || (db->pErr = sqlite3ValueNew()))!=0 ){

==>>

if( db && (db->pErr || ((db->pErr = sqlite3ValueNew())!=0))!=0 ){


There are several more warnings when BCB compiler claims a function has no prototype where it has.

It is knon Borland bug and the only way to fix it is to add

#ifdef __BORLANDC__ # pragma -warn ... #endif

...statements...

#ifdef __BORLANDC__ # pragma .warn ... #endif

inside sqlite code. I do not know whether you wish to pollute the code with such specific workarounds. If yes, I may provide more details.

EOF

 
1562 warn active 2005 Dec anonymous Unknown 2005 Dec   3 1 i64 not defined in 32bit compiler edit
Our 32-bit compiler doesn't recognize the i64 type. To force through compilation we've defined i64 as long. This seems to work but we have been experiencing failures in the VDBE module. We'd rather not revert to Sqlite2.

Any suggestions? (I'll be opening a seperate ticket regarding the VDBE failure)

2005-Dec-16 01:22:41 by drh:
Compile with -DSQLITE_32BIT_ROWID=1
 
1466 warn active 2005 Oct anonymous   2005 Oct   5 5 compile warnings edit
{{{ cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/os_unix.c -KPIC -DPIC -o .libs/os_unix.o "./src/main.c", line 644: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char "./src/alter.c", line 50: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char "./src/alter.c", line 61: warning: assignment type mismatch: pointer to const unsigned char "" pointer to const char "./src/alter.c", line 69: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1641 argument : pointer to const char "./src/alter.c", line 99: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char "./src/alter.c", line 111: warning: assignment type mismatch: pointer to const unsigned char "=" pointer to const char "./src/alter.c", line 119: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1641 argument : pointer to const char "./src/alter.c", line 445: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/func.c -KPIC -DPIC -o .libs/func.o "./src/pragma.c", line 47: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/stdlib_iso.h", line 94 argument : pointer to const unsigned char "./src/pragma.c", line 49: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/string_iso.h", line 70 argument : pointer to const unsigned char "./src/pragma.c", line 51: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1395 argument : pointer to const unsigned char "./src/pragma.c", line 169: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 61 argument : pointer to const char "./src/pragma.c", line 322: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 61 argument : pointer to char "./src/pragma.c", line 430: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 39 argument : pointer to char "./src/pragma.c", line 621: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 61 argument : pointer to char "./src/build.c", line 509: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/func.c -KPIC -DPIC -o .libs/func.o "./src/pragma.c", line 47: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/stdlib_iso.h", line 94 argument : pointer to const unsigned char "./src/pragma.c", line 49: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/string_iso.h", line 70 argument : pointer to const unsigned char "./src/pragma.c", line 51: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1395 argument : pointer to const unsigned char "./src/pragma.c", line 169: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 61 argument : pointer to const char "./src/pragma.c", line 322: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 61 argument : pointer to char "./src/pragma.c", line 430: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 39 argument : pointer to char "./src/pragma.c", line 621: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/pragma.c", line 61 argument : pointer to char "./src/build.c", line 509: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/hash.c -KPIC -DPIC -o .libs/hash.o "./src/date.c", line 642: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "./src/date.c", line 306 argument : pointer to const unsigned char "./src/date.c", line 645: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "./src/date.c", line 450 argument : pointer to const unsigned char "./src/date.c", line 758: warning: assignment type mismatch: pointer to const char "=" pointer to const unsigned char

./libtool --mode=compile cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -DTEMP_STORE=2 -c ./src/prepare.c "parse.y", line 241: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/stdlib_iso.h", line 94 argument : pointer to const unsigned char "parse.y", line 242: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/stdlib_iso.h", line 94 argument : pointer to const unsigned char "parse.y", line 275: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./src/sqliteInt.h", line 1456 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/date.c -o date.o >/dev/null 2>&1 "parse.y", line 885: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./src/sqliteInt.h", line 1620 argument : pointer to const unsigned char "parse.y", line 893: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./src/sqliteInt.h", line 1620 argument : pointer to const unsigned char "./src/btree.c", line 1537: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/pager.c", line 1012: warning: argument #3 is incompatible with prototype: prototype: pointer to const char : "./src/pager.c", line 960 argument : pointer to unsigned char "./src/build.c", line 1173: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1429 argument : pointer to unsigned char "./src/build.c", line 2160: warning: assignment type mismatch: pointer to const unsigned char "" pointer to char "./src/build.c", line 2161: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/string_iso.h", line 70 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/pragma.c -o pragma.o >/dev/null 2>&1 "./src/func.c", line 104: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char "./src/func.c", line 155: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char "./src/func.c", line 213: warning: argument #1 is incompatible with prototype: prototype: pointer to char : "/usr/include/iso/string_iso.h", line 66 argument : pointer to unsigned char "./src/func.c", line 213: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/string_iso.h", line 66 argument : pointer to const unsigned char "./src/func.c", line 217: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./sqlite3.h", line 1073 argument : pointer to unsigned char "./src/func.c", line 226: warning: argument #1 is incompatible with prototype: prototype: pointer to char : "/usr/include/iso/string_iso.h", line 66 argument : pointer to unsigned char "./src/func.c", line 226: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/string_iso.h", line 66 argument : pointer to const unsigned char "./src/func.c", line 230: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./sqlite3.h", line 1073 argument : pointer to unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/os_unix.c -o os_unix.o >/dev/null 2>&1 "./src/pager.c", line 1360: warning: statement not reached "./src/build.c", line 2913: warning: argument #3 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1619 argument : pointer to const unsigned char "./src/expr.c", line 238: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/stdlib_iso.h", line 94 argument : pointer to const unsigned char "./src/expr.c", line 330: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/stdlib_iso.h", line 94 argument : pointer to const unsigned char "./src/expr.c", line 418: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char "./src/expr.c", line 418: warning: assignment type mismatch: pointer to const unsigned char "" pointer to char "./src/expr.c", line 435: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char "./src/expr.c", line 435: warning: assignment type mismatch: pointer to const unsigned char "" pointer to char "./src/btree.c", line 5817: warning: statement not reached "./src/func.c", line 498: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1601 argument : pointer to const unsigned char "./src/func.c", line 595: warning: assignment type mismatch: pointer to const char "=" pointer to const unsigned char "./src/func.c", line 1103: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1539 argument : pointer to const unsigned char

./libtool --mode=compile cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/random.c "./src/expr.c", line 755: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1598 argument : pointer to const unsigned char "./src/expr.c", line 1154: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char "./src/expr.c", line 1401: warning: initialization type mismatch "./src/expr.c", line 1477: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./src/expr.c", line 1423 argument : pointer to const unsigned char "./src/expr.c", line 1485: warning: argument #5 is incompatible with prototype: prototype: pointer to const char : "src/vdbe.h", line 103 argument : pointer to const unsigned char "./src/expr.c", line 1498: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/delete.c -o delete.o >/dev/null 2>&1 argument #3 is incompatible with prototype: prototype: pointer to const char : "src/vdbe.h", line 108 argument : pointer to const unsigned char "./src/expr.c", line 1632: warning: assignment type mismatch: pointer to const char "=" pointer to const unsigned char "./src/expr.c", line 1766: warning: argument #5 is incompatible with prototype: prototype: pointer to const char : "src/vdbe.h", line 103 argument : pointer to const unsigned char "./src/expr.c", line 2059: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1395 argument : pointer to const unsigned char "./src/expr.c", line 2059: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1395 argument : pointer to const unsigned char "./src/expr.c", line 2191: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1539 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/vdbe.c -KPIC -DPIC -o .libs/vdbe.o "./src/select.c", line 112: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1395 argument : pointer to const unsigned char "./src/select.c", line 157: warning: assignment type mismatch: pointer to const unsigned char "" pointer to const char "./src/select.c", line 625: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/printf.c", line 628: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "unknown", line 0 argument : pointer to const unsigned char "./src/trigger.c", line 240: warning: argument #3 is incompatible with prototype: prototype: pointer to const char : "src/vdbe.h", line 108 argument : pointer to const unsigned char "./src/trigger.c", line 281: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char "./src/trigger.c", line 281: warning: assignment type mismatch: pointer to const unsigned char "" pointer to char "./src/trigger.c", line 623: warning: assignment type mismatch: pointer to const unsigned char "" pointer to char "./src/trigger.c", line 624: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/string_iso.h", line 70 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/random.c -o random.o >/dev/null 2>&1 "./src/select.c", line 869: warning: argument #3 is incompatible with prototype: prototype: pointer to const char : "src/vdbe.h", line 120 argument : pointer to const unsigned char "./src/select.c", line 882: warning: argument #3 is incompatible with prototype: prototype: pointer to const char : "src/vdbe.h", line 120 argument : pointer to const unsigned char "./src/tokenize.c", line 360: warning: assignment type mismatch: pointer to const unsigned char "=" pointer to const char "./src/select.c", line 2088: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char "./src/select.c", line 2187: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1395 argument : pointer to const unsigned char "./src/select.c", line 2189: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1395 argument : pointer to const unsigned char "./src/vacuum.c", line 61: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./src/vacuum.c", line 40 argument : pointer to const unsigned char "./src/vdbeaux.c", line 199: warning: integer overflow detected: op "<<" "./src/vdbeaux.c", line 199: warning: initializer does not fit or is out of range: -1155858600 "./src/vdbeaux.c", line 1735: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1605 argument : pointer to char "./src/vdbeaux.c", line 1736: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1605 argument : pointer to char "./src/vdbeaux.c", line 1738: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/vdbeaux.c", line 1540 argument : pointer to char "./src/vdbeaux.c", line 1774: warning: argument #2 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/vdbeaux.c", line 1704 argument : pointer to char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/tokenize.c -o tokenize.o >/dev/null 2>&1 "./src/vdbe.c", line 1873: warning: assignment type mismatch: pointer to char "" pointer to unsigned char "./src/vdbe.c", line 1940: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/vdbe.c", line 1940: warning: assignment type mismatch: pointer to char "" pointer to unsigned char "./src/vdbe.c", line 1945: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1605 argument : pointer to char "./src/vdbe.c", line 1972: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1605 argument : pointer to char "./src/vdbe.c", line 2026: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/vdbeInt.h", line 336 argument : pointer to char "./src/vdbe.c", line 2189: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/vdbe.c", line 2223: warning: assignment type mismatch: pointer to char "=" pointer to unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c opcodes.c -KPIC -DPIC -o .libs/opcodes.o "./src/vdbe.c", line 2920: warning: argument #2 is incompatible with prototype: prototype: pointer to const unsigned char : "src/vdbeInt.h", line 344 argument : pointer to char "./src/vdbe.c", line 2937: warning: argument #3 is incompatible with prototype: prototype: pointer to const unsigned char : "src/vdbeInt.h", line 340 argument : pointer to char "./src/vdbe.c", line 3710: warning: argument #3 is incompatible with prototype: prototype: pointer to const unsigned char : "src/vdbeInt.h", line 340 argument : pointer to char "./src/vdbe.c", line 3748: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1605 argument : pointer to const char "./src/vdbe.c", line 3750: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "src/sqliteInt.h", line 1605 argument : pointer to const char "./src/utf.c", line 275: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/utf.c", line 311: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/utf.c", line 363: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/utf.c", line 368: warning: assignment type mismatch: pointer to char "" pointer to unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/where.c -KPIC -DPIC -o .libs/where.o "./src/where.c", line 514: warning: assignment type mismatch: pointer to const char "" pointer to const unsigned char "./src/vdbemem.c", line 76: warning: assignment type mismatch: pointer to char "" pointer to unsigned char "./src/vdbemem.c", line 96: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/vdbemem.c", line 109: warning: assignment type mismatch: pointer to char "" pointer to unsigned char "./src/vdbemem.c", line 165: warning: assignment type mismatch: pointer to unsigned char "" pointer to char "./src/vdbemem.c", line 177: warning: argument #2 is incompatible with prototype: prototype: pointer to char : "./sqlite3.h", line 397 argument : pointer to unsigned char "./src/vdbemem.c", line 180: warning: argument #2 is incompatible with prototype: prototype: pointer to char : "./sqlite3.h", line 397 argument : pointer to unsigned char "./src/vdbemem.c", line 182: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "/usr/include/iso/string_iso.h", line 70 argument : pointer to unsigned char "./src/vdbemem.c", line 183: warning: assignment type mismatch: pointer to char "" pointer to unsigned char "./src/vdbemem.c", line 769: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char "./src/vdbemem.c", line 789: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "src/sqliteInt.h", line 1414 argument : pointer to const unsigned char

cc -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -DHAVE_READLINE=0 -o .libs/sqlite3 ./src/shell.c ./.libs/libsqlite3.so -lcurses -R/export/opt/svn/1.3.0/lib "./src/shell.c", line 355: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/shell.c", line 84 argument : pointer to const char "./src/shell.c", line 523: warning: argument #1 is incompatible with prototype: prototype: pointer to const unsigned char : "./src/shell.c", line 84 argument : pointer to char "./src/shell.c", line 694: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./src/shell.c", line 583 argument : pointer to const unsigned char

}}}

 
1379 warn active 2005 Aug anonymous Unknown 2005 Aug   1 1 cannot install . phpize failed edit
Trying to install via pear on RHAT Linux Ent V3

[root@host bin]# pear install sqlite

downloading SQLite-1.0.3.tgz ...

...done: 371,189 bytes

50 source files, building

running: phpize `phpize' failed

Tried some ln -s commands but no use. Trying to get Paypal SDK for PHP work, which requires pear mod Log, which inturn is looking for sqlite. I appreciate any help

2005-Aug-25 03:17:06 by anonymous:
This question should be addressed to PHP helpers not here. You should visit php.net.
 
1246 warn active 2005 May anonymous   2005 May   4 3 Many warnings from gcc4 edit
Compiling 3.2.0 on Fedora Core 4 Test 3 with gcc 4 gives MANY:

'pointer targets in assignment differ in signedness'

warnings

 
972 warn active 2004 Oct anonymous   2005 May   3 3 building SQLite on Irix edit
Hi,

Here are the warnings I got while building SQLite 3.0.8 on Irix 6.5 using SGI's MIPSpro 7.3.1.1m compiler. Most of the warnings are about signed/unsigned char issues (these warnings are common with commercial Unix compilers) and I'm not sure you're willing to fix them. Some other warnings should probably be fixed (unused variables, missing return values, and the like).

cc-1116 cc: WARNING File = ./tool/lemon.c, Line = 2352 Non-void function "preprocess_input" (declared at line 2308) should return a value.

  }
  ^

cc-1164 cc: WARNING File = ./src/attach.c, Line = 170 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( sqlite3StrNICmp(pDb->zName, pDbname->z, pDbname->n)==0 ) break;
                                      ^

cc-1515 cc: WARNING File = ./src/btree.c, Line = 1251 A value of type "char *" cannot be assigned to an entity of type "u8 *".

        pPage->aData = &((char*)pPage)[-pBt->pageSize];
                     ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 1901 The variable "pBt" is set but never used.

    Btree *pBt;
           ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2005 The variable "oldPgno" is set but never used.

    Pgno oldPgno;
         ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2936 The variable "idxDiv" is set but never used.

    int idxDiv[NB];              /* Indices of divider cells in pParent */
        ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 4186 The variable "cur" is set but never used.

    BtCursor cur;
             ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 4188 The variable "maxLocal" is set but never used.

    int maxLocal, usableSize;
        ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 461 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      zName = sqliteStrNDup(pName->z, pName->n);
                            ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 490 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

          0==sqlite3StrNICmp(pDb->zName, pName->z, pName->n) ){
                                         ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 580 The variable "pIdx" is set but never used.

    Index *pIdx;
           ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 780 The variable "pz" is set but never used.

    char *z, **pz;
               ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 1195 Argument of type "unsigned char *" is incompatible with parameter of type "const char *".

                    || sqlite3KeywordCode(zIdent, j)!=TK_ID;
                                          ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 1370 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeChangeP3(v, -1, pParse->sNameToken.z, n);
                                   ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 1904 The variable "pISameName" is set but never used.

        Index *pISameName;    /* Another index with the same name */
               ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 1905 The variable "pTSameName" is set but never used.

        Table *pTSameName;    /* A table with same name as the index */
               ^

cc-1515 cc: WARNING File = ./src/build.c, Line = 1948 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      nullId.z = pTab->aCol[pTab->nCol-1].zName;
               ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 1949 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      nullId.n = strlen(nullId.z);
                        ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 2109 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeChangeP3(v, -1, pName->z, n);
                                   ^

cc-1164 cc: WARNING File = ./src/date.c, Line = 648 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        parseDateOrTime(sqlite3_value_text(argv[0]), p) ) return 1;
                        ^

cc-1164 cc: WARNING File = ./src/date.c, Line = 651 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

          parseModifier(sqlite3_value_text(argv[i]), p) ) return 1;
                        ^

cc-1140 cc: WARNING File = ./src/date.c, Line = 764 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

    const char *zFmt = sqlite3_value_text(argv[0]);
                       ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 286 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      pExpr->iTable = i = atoi(&pToken->z[1]);
                               ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 359 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      pNew->token.z = sqliteStrDup(p->token.z);
                                   ^

cc-1515 cc: WARNING File = ./src/expr.c, Line = 359 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      pNew->token.z = sqliteStrDup(p->token.z);
                    ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 375 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      pTo->z = sqliteStrNDup(pFrom->z, pFrom->n);
                             ^

cc-1515 cc: WARNING File = ./src/expr.c, Line = 375 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      pTo->z = sqliteStrNDup(pFrom->z, pFrom->n);
             ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 573 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        if( sqlite3GetInt32(p->token.z, pValue) ){
                            ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 583 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        if( n==0 && sqlite3GetInt32(p->token.z, pValue) ){
                                    ^

cc-1515 cc: WARNING File = ./src/expr.c, Line = 1039 A value of type "const unsigned char *" cannot be assigned to an entity of type "const char *".

        *pzName = pExpr->token.z;
                ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1212 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        codeInteger(v, pExpr->token.z, pExpr->token.n);
                       ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1219 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeOp3(v, op, 0, 0, pExpr->token.z, pExpr->token.n);
                                    ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1225 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeOp3(v, op, 0, 0, pExpr->token.z+1, pExpr->token.n-1);
                                    ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1236 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

          sqlite3VdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n);
                                     ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1466 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

                          pExpr->token.z, pExpr->token.n);
                          ^

cc-1552 cc: WARNING File = ./src/expr.c, Line = 1491 The variable "v" is set but never used.

    Vdbe *v;
          ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1733 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( sqlite3StrNICmp(pA->token.z, pB->token.z, pB->token.n)!=0 ) return 0;
                          ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1733 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( sqlite3StrNICmp(pA->token.z, pB->token.z, pB->token.n)!=0 ) return 0;
                                       ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1805 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

               pExpr->token.z, pExpr->token.n,
               ^

cc-1140 cc: WARNING File = ./src/func.c, Line = 100 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

        const char *z = sqlite3_value_text(argv[0]);
                        ^

cc-1515 cc: WARNING File = ./src/func.c, Line = 151 A value of type "const unsigned char *" cannot be assigned to an entity of type "const char *".

    z = sqlite3_value_text(argv[0]);
      ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 209 Argument of type "unsigned char *" is incompatible with parameter of type "char *".

    strcpy(z, sqlite3_value_text(argv[0]));
           ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 209 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    strcpy(z, sqlite3_value_text(argv[0]));
              ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 213 Argument of type "unsigned char *" is incompatible with parameter of type "const char *".

    sqlite3_result_text(context, z, -1, SQLITE_TRANSIENT);
                                 ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 222 Argument of type "unsigned char *" is incompatible with parameter of type "char *".

    strcpy(z, sqlite3_value_text(argv[0]));
           ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 222 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    strcpy(z, sqlite3_value_text(argv[0]));
              ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 226 Argument of type "unsigned char *" is incompatible with parameter of type "const char *".

    sqlite3_result_text(context, z, -1, SQLITE_TRANSIENT);
                                 ^

cc-1140 cc: WARNING File = ./src/func.c, Line = 562 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

        const char *zArg = sqlite3_value_text(argv[0]);
                           ^

cc-1515 cc: WARNING File = ./src/main.c, Line = 876 A value of type "const unsigned char *" cannot be assigned to an entity of type "const char *".

    z = sqlite3_value_text(db->pErr);
      ^

cc-1552 cc: WARNING File = ./src/os_unix.c, Line = 1185 The variable "inMutex" is set but never used.

  static int inMutex = 0;
             ^

cc-1164 cc: WARNING File = ./src/pager.c, Line = 873 Argument of type "u8 *" is incompatible with parameter of type "const char *".

      if( pager_cksum(pPager, pgno, aData)!=cksum ){
                                    ^

cc-1164 cc: WARNING File = parse.y, Line = 193 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

  { yygotominor.yy284 = atoi(yymsp[0].minor.yy98.z); }
                             ^

cc-1164 cc: WARNING File = parse.y, Line = 194 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

  { yygotominor.yy284 = -atoi(yymsp[0].minor.yy98.z); }
                              ^

cc-1164 cc: WARNING File = parse.y, Line = 215 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

  {sqlite3AddCollateType(pParse, yymsp[0].minor.yy98.z, yymsp[0].minor.yy98.n);}
                                 ^

cc-1164 cc: WARNING File = parse.y, Line = 753 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( p ) p->pColl = sqlite3LocateCollSeq(pParse, yymsp[-1].minor.yy98.z, yymsp[-1].minor.yy98.n);
                                                      ^

cc-1164 cc: WARNING File = parse.y, Line = 761 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( p ) p->pColl = sqlite3LocateCollSeq(pParse, yymsp[-1].minor.yy98.z, yymsp[-1].minor.yy98.n);
                                                      ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 31 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

    if( sqlite3IsNumber(z, 0, SQLITE_UTF8) ){
                        ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 32 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

      return atoi(z);
                  ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 35 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

      if( sqlite3StrICmp(z,azTrue[i])==0 ) return 1;
                         ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 35 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

      if( sqlite3StrICmp(z,azTrue[i])==0 ) return 1;
                           ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 65 Argument of type "u8 *" is incompatible with parameter of type "const char *".

    if( sqlite3IsNumber(z, 0, SQLITE_UTF8) ){
                        ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 66 Argument of type "u8 *" is incompatible with parameter of type "const char *".

      return atoi(z);
                  ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 69 Argument of type "u8 *" is incompatible with parameter of type "const char *".

      if( sqlite3StrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val;
                         ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 69 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

      if( sqlite3StrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val;
                           ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 158 Argument of type "const char *" is incompatible with parameter of type "const u8 *".

        }else if( getBoolean(zRight) ){
                             ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 351 Argument of type "char *" is incompatible with parameter of type "u8 *".

          pDb->safety_level = getSafetyLevel(zRight)+1;
                                             ^

cc-1164 cc: WARNING File = ./src/printf.c, Line = 594 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

            (*func)(arg, pToken->z, pToken->n);
                         ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 105 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

            && sqlite3StrNICmp(p->z, keywords[j].zKeyword, p->n)==0 ){
                               ^

cc-1515 cc: WARNING File = ./src/select.c, Line = 150 A value of type "const char *" cannot be assigned to an entity of type "const unsigned char *".

    p->z = z;
         ^

cc-1515 cc: WARNING File = ./src/select.c, Line = 575 A value of type "char *" cannot be assigned to an entity of type "u8 *".

    pInfo->aSortOrder = (char*)&pInfo->aColl[nCol];
                      ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 761 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

          sqlite3VdbeSetColName(v, i, p->span.z, p->span.n);
                                      ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 774 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeSetColName(v, i, p->span.z, p->span.n);
                                    ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 1957 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        pList->a[i].zName = sqliteStrNDup(pExpr->span.z, pExpr->span.n);
                                          ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 2060 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    if( sqlite3StrNICmp(pExpr->token.z,"min",3)==0 ){
                        ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 2062 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    }else if( sqlite3StrNICmp(pExpr->token.z,"max",3)==0 ){
                              ^

cc-1515 cc: WARNING File = ./src/tokenize.c, Line = 427 A value of type "const char *" cannot be assigned to an entity of type "const unsigned char *".

      pParse->sLastToken.z = &zSql[i];
                           ^

cc-1164 cc: WARNING File = ./src/trigger.c, Line = 237 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      sqlite3VdbeChangeP3(v, addr+6, pAll->z, pAll->n);
                                     ^

cc-1164 cc: WARNING File = ./src/trigger.c, Line = 276 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      p->target.z = sqliteStrNDup(p->target.z, p->target.n);
                                  ^

cc-1515 cc: WARNING File = ./src/trigger.c, Line = 276 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      p->target.z = sqliteStrNDup(p->target.z, p->target.n);
                  ^

cc-1515 cc: WARNING File = ./src/trigger.c, Line = 627 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      sDb.z = pParse->db->aDb[iDb].zName;
            ^

cc-1164 cc: WARNING File = ./src/trigger.c, Line = 628 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      sDb.n = strlen(sDb.z);
                     ^

cc-1164 cc: WARNING File = ./src/vacuum.c, Line = 61 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      rc = execSql(db, sqlite3_column_text(pStmt, 0));
                       ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1176 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3SetString(&p->zErrMsg, sqlite3_value_text(pTos), (char*)0);
                                      ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 1737 A value of type "u8 *" cannot be assigned to an entity of type "char *".

        zRec = pC->aRow;
             ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 1802 A value of type "char *" cannot be assigned to an entity of type "u8 *".

          zRec = pC->aRow = zData;
                          ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 1802 A value of type "u8 *" cannot be assigned to an entity of type "char *".

          zRec = pC->aRow = zData;
               ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1807 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

      idx = sqlite3GetVarint32(zData, &szHdr);
                               ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1833 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

        idx += sqlite3GetVarint32(&zData[idx], &aType[i]);
                                  ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1873 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3VdbeSerialGet(zData, aType[p2], pTos);
                         ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 2018 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

      zNewRecord = zTemp;
                 ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 2060 A value of type "unsigned char *" cannot be assigned to an entity of type "char *".

      pTos->z = zNewRecord;
              ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 2715 Argument of type "char *" is incompatible with parameter of type "const u8 *".

      szRowid = sqlite3VdbeIdxRowidLen(nKey, zKey);
                                             ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 2732 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

      rc = sqlite3VdbeIdxKeyCompare(pCx, len, zKey, &res); 
                                              ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3383 Argument of type "const char *" is incompatible with parameter of type "const u8 *".

        len = nKey - sqlite3VdbeIdxRowidLen(nKey, zKey);
                                                  ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3389 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

          if( sqlite3VdbeIdxKeyCompare(pC, len, zKey, &c)==SQLITE_OK && c==0 ){
                                                ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3539 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

      rc = sqlite3VdbeIdxKeyCompare(pC, pTos->n, pTos->z, &res);
                                                 ^

cc-1552 cc: WARNING File = ./src/vdbe.c, Line = 3525 The variable "pCrsr" is set but never used.

    BtCursor *pCrsr;
              ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3577 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

    k = sqlite3GetVarint32(z, &serial_type);
                           ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3579 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

      k += sqlite3GetVarint32(&z[k], &serial_type);
                              ^

cc-1119 cc: WARNING File = ./src/vdbeapi.c, Line = 47 The "return" expression type differs from the function return type.

    return (const char *)sqlite3ValueText(pVal, SQLITE_UTF8);
           ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1746 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3GetVarint32(m.z, &szHdr);
                       ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1747 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3GetVarint32(&m.z[szHdr-1], &typeRowid);
                       ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1749 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3VdbeSerialGet(&m.z[m.n-lenRowid], typeRowid, &v);
                         ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1785 Argument of type "char *" is incompatible with parameter of type "const u8 *".

    lenRowid = sqlite3VdbeIdxRowidLen(m.n, m.z);
                                           ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 65 A value of type "u8 *" cannot be assigned to an entity of type "char *".

    pMem->z = z;
            ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 85 A value of type "char *" cannot be assigned to an entity of type "u8 *".

      z = pMem->zShort;
        ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 98 A value of type "u8 *" cannot be assigned to an entity of type "char *".

    pMem->z = z;
            ^

cc-1140 cc: WARNING File = ./src/vdbemem.c, Line = 154 A value of type "char *" cannot be used to initialize an entity of type "u8 *".

    u8 *z = pMem->zShort;
            ^

cc-1164 cc: WARNING File = ./src/vdbemem.c, Line = 166 Argument of type "u8 *" is incompatible with parameter of type "char *".

      sqlite3_snprintf(NBFS, z, "%.15g", pMem->r);
                             ^

cc-1164 cc: WARNING File = ./src/vdbemem.c, Line = 169 Argument of type "u8 *" is incompatible with parameter of type "char *".

      sqlite3_snprintf(NBFS, z, "%lld", pMem->i);
                             ^

cc-1164 cc: WARNING File = ./src/vdbemem.c, Line = 171 Argument of type "u8 *" is incompatible with parameter of type "const char *".

    pMem->n = strlen(z);
                     ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 172 A value of type "u8 *" cannot be assigned to an entity of type "char *".

    pMem->z = z;
            ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 274 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

      zIn = pMem->z;
          ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 310 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

    zIn = pMem->z;
        ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 362 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

      zOut = pMem->zShort;
           ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 367 A value of type "unsigned char *" cannot be assigned to an entity of type "char *".

    pMem->z = zOut;
            ^

cc-1164 cc: WARNING File = ./src/shell.c, Line = 353 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

    }else if( isNumber(z, 0) ){
                       ^

cc-1164 cc: WARNING File = ./src/shell.c, Line = 519 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

          }else if( isNumber(azArg[i], 0) ){
                             ^

cc-1164 cc: WARNING File = ./src/shell.c, Line = 682 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        zSelect = appendText(zSelect, sqlite3_column_text(pTableInfo, 1), '"');
                                      ^

ld32: WARNING 84 : /usr/lib32/libcurses.so is not used for resolving any symbol. creating sqlite3

2005-Jan-24 23:04:23 by anonymous:
Hi,

Here are the warnings I got while building SQLite 3.1.0 alpha on Irix 6.5 using SGI's MIPSpro 7.3.1.1m compiler.

cc-1116 cc: WARNING File = ./tool/lemon.c, Line = 2352 Non-void function "preprocess_input" (declared at line 2308) should return a value.

  }
  ^

cc-1164 cc: WARNING File = ./src/attach.c, Line = 170 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( sqlite3StrNICmp(pDb->zName, pDbname->z, pDbname->n)==0 ) break;
                                      ^

cc-1515 cc: WARNING File = ./src/btree.c, Line = 1494 A value of type "char *" cannot be assigned to an entity of type "u8 *".

        pPage->aData = &((char*)pPage)[-pBt->psAligned];
                     ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2444 The variable "pBt" is set but never used.

    Btree *pBt;
           ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2548 The variable "oldPgno" is set but never used.

    Pgno oldPgno;
         ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 3757 The variable "idxDiv" is set but never used.

    int idxDiv[NB];              /* Indices of divider cells in pParent */
        ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 5384 The variable "cur" is set but never used.

    BtCursor cur;
             ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 5386 The variable "maxLocal" is set but never used.

    int maxLocal, usableSize;
        ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 128 The variable "rc" is set but never used.

    int rc;
        ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 499 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      zName = sqliteStrNDup(pName->z, pName->n);
                            ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 626 The variable "pIdx" is set but never used.

    Index *pIdx;
           ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 849 The variable "pz" is set but never used.

    char *z, **pz;
               ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 1281 Argument of type "unsigned char *" is incompatible with parameter of type "const char *".

                    || sqlite3KeywordCode(zIdent, j)!=TK_ID;
                                          ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 2191 The variable "pISameName" is set but never used.

        Index *pISameName;    /* Another index with the same name */
               ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 2192 The variable "pTSameName" is set but never used.

        Table *pTSameName;    /* A table with same name as the index */
               ^

cc-1515 cc: WARNING File = ./src/build.c, Line = 2235 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      nullId.z = pTab->aCol[pTab->nCol-1].zName;
               ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 2236 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      nullId.n = strlen(nullId.z);
                        ^

cc-1164 cc: WARNING File = ./src/build.c, Line = 2923 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      pColl = sqlite3FindCollSeq(db, db->enc, pName1->z, pName1->n, 0);
                                              ^

cc-1164 cc: WARNING File = ./src/date.c, Line = 646 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        parseDateOrTime(sqlite3_value_text(argv[0]), p) ) return 1;
                        ^

cc-1164 cc: WARNING File = ./src/date.c, Line = 649 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

          parseModifier(sqlite3_value_text(argv[i]), p) ) return 1;
                        ^

cc-1140 cc: WARNING File = ./src/date.c, Line = 762 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

    const char *zFmt = sqlite3_value_text(argv[0]);
                       ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 226 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    depth = atoi(&pToken->z[1]);
                 ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 322 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      pExpr->iTable = i = atoi(&pToken->z[1]);
                               ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 395 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      pNew->token.z = sqliteStrNDup(p->token.z, p->token.n);
                                    ^

cc-1515 cc: WARNING File = ./src/expr.c, Line = 395 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      pNew->token.z = sqliteStrNDup(p->token.z, p->token.n);
                    ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 411 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      pTo->z = sqliteStrNDup(pFrom->z, pFrom->n);
                             ^

cc-1515 cc: WARNING File = ./src/expr.c, Line = 411 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      pTo->z = sqliteStrNDup(pFrom->z, pFrom->n);
             ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 663 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        if( sqlite3GetInt32(p->token.z, pValue) ){
                            ^

cc-1515 cc: WARNING File = ./src/expr.c, Line = 946 A value of type "const unsigned char *" cannot be assigned to an entity of type "const char *".

        *pzName = pExpr->token.z;
                ^

cc-1174 cc: WARNING File = ./src/expr.c, Line = 993 The variable "i" was declared but never referenced.

    int i;
        ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1402 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        codeInteger(v, pExpr->token.z, pExpr->token.n);
                       ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1409 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeOp3(v, op, 0, 0, pExpr->token.z, pExpr->token.n);
                                    ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1416 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeOp3(v, op, 0, 0, pExpr->token.z+1, pExpr->token.n-1);
                                    ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1428 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

          sqlite3VdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n);
                                     ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1673 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

                          pExpr->token.z, pExpr->token.n);
                          ^

cc-1552 cc: WARNING File = ./src/expr.c, Line = 1726 The variable "v" is set but never used.

    Vdbe *v;
          ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1968 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( sqlite3StrNICmp(pA->token.z, pB->token.z, pB->token.n)!=0 ) return 0;
                          ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 1968 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( sqlite3StrNICmp(pA->token.z, pB->token.z, pB->token.n)!=0 ) return 0;
                                       ^

cc-1164 cc: WARNING File = ./src/expr.c, Line = 2037 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

               pExpr->token.z, pExpr->token.n,
               ^

cc-1140 cc: WARNING File = ./src/func.c, Line = 100 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

        const char *z = sqlite3_value_text(argv[0]);
                        ^

cc-1515 cc: WARNING File = ./src/func.c, Line = 151 A value of type "const unsigned char *" cannot be assigned to an entity of type "const char *".

    z = sqlite3_value_text(argv[0]);
      ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 209 Argument of type "unsigned char *" is incompatible with parameter of type "char *".

    strcpy(z, sqlite3_value_text(argv[0]));
           ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 209 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    strcpy(z, sqlite3_value_text(argv[0]));
              ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 213 Argument of type "unsigned char *" is incompatible with parameter of type "const char *".

    sqlite3_result_text(context, z, -1, SQLITE_TRANSIENT);
                                 ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 222 Argument of type "unsigned char *" is incompatible with parameter of type "char *".

    strcpy(z, sqlite3_value_text(argv[0]));
           ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 222 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    strcpy(z, sqlite3_value_text(argv[0]));
              ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 226 Argument of type "unsigned char *" is incompatible with parameter of type "const char *".

    sqlite3_result_text(context, z, -1, SQLITE_TRANSIENT);
                                 ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 479 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( sqlite3utf8CharLen(zEsc, -1)!=1 ){
                             ^

cc-1140 cc: WARNING File = ./src/func.c, Line = 560 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

    char const *zCsr = zSql;
                       ^

cc-1515 cc: WARNING File = ./src/func.c, Line = 571 A value of type "const char *" cannot be assigned to an entity of type "const unsigned char *".

        tname.z = zCsr;
                ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 579 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

          len = sqlite3GetToken(zCsr, &token);
                                ^

cc-1140 cc: WARNING File = ./src/func.c, Line = 611 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

    char const *zCsr = zSql;
                       ^

cc-1515 cc: WARNING File = ./src/func.c, Line = 623 A value of type "const char *" cannot be assigned to an entity of type "const unsigned char *".

        tname.z = zCsr;
                ^

cc-1164 cc: WARNING File = ./src/func.c, Line = 631 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

          len = sqlite3GetToken(zCsr, &token);
                                ^

cc-1140 cc: WARNING File = ./src/func.c, Line = 713 A value of type "const unsigned char *" cannot be used to initialize an entity of type "const char *".

        const char *zArg = sqlite3_value_text(argv[0]);
                           ^

cc-1515 cc: WARNING File = ./src/main.c, Line = 888 A value of type "const unsigned char *" cannot be assigned to an entity of type "const char *".

    z = sqlite3_value_text(db->pErr);
      ^

cc-1552 cc: WARNING File = ./src/os_unix.c, Line = 1217 The variable "inMutex" is set but never used.

  static int inMutex = 0;
             ^

cc-1164 cc: WARNING File = ./src/pager.c, Line = 922 Argument of type "u8 *" is incompatible with parameter of type "const char *".

      if( pager_cksum(pPager, pgno, aData)!=cksum ){
                                    ^

cc-1164 cc: WARNING File = parse.y, Line = 201 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

  { yygotominor.yy60 = atoi(yymsp[0].minor.yy406.z); }
                            ^

cc-1164 cc: WARNING File = parse.y, Line = 202 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

  { yygotominor.yy60 = -atoi(yymsp[0].minor.yy406.z); }
                             ^

cc-1164 cc: WARNING File = parse.y, Line = 230 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

  {sqlite3AddCollateType(pParse, yymsp[0].minor.yy406.z, yymsp[0].minor.yy406.n);}
                                 ^

cc-1164 cc: WARNING File = parse.y, Line = 804 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( p ) p->pColl = sqlite3LocateCollSeq(pParse, yymsp[-1].minor.yy406.z, yymsp[-1].minor.yy406.n);
                                                      ^

cc-1164 cc: WARNING File = parse.y, Line = 812 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      if( p ) p->pColl = sqlite3LocateCollSeq(pParse, yymsp[-1].minor.yy406.z, yymsp[-1].minor.yy406.n);
                                                      ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 47 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

      return atoi(z);
                  ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 49 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

    n = strlen(z);
               ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 51 Argument of type "const u8 *" is incompatible with parameter of type "const char *".

      if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){
                                                              ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 163 Argument of type "const char *" is incompatible with parameter of type "const u8 *".

        }else if( getBoolean(zRight) ){
                             ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 309 Argument of type "char *" is incompatible with parameter of type "const u8 *".

        sqlite3BtreeSetAutoVacuum(pBt, getBoolean(zRight));
                                                  ^

cc-1164 cc: WARNING File = ./src/pragma.c, Line = 417 Argument of type "char *" is incompatible with parameter of type "const u8 *".

          pDb->safety_level = getSafetyLevel(zRight)+1;
                                             ^

cc-1164 cc: WARNING File = ./src/printf.c, Line = 600 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

            (*func)(arg, pToken->z, pToken->n);
                         ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 105 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

            && sqlite3StrNICmp(p->z, keywords[j].zKeyword, p->n)==0 ){
                               ^

cc-1515 cc: WARNING File = ./src/select.c, Line = 150 A value of type "const char *" cannot be assigned to an entity of type "const unsigned char *".

    p->z = z;
         ^

cc-1515 cc: WARNING File = ./src/select.c, Line = 591 A value of type "char *" cannot be assigned to an entity of type "u8 *".

    pInfo->aSortOrder = (char*)&pInfo->aColl[nCol];
                      ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 789 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

          sqlite3VdbeSetColName(v, i, p->span.z, p->span.n);
                                      ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 802 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3VdbeSetColName(v, i, p->span.z, p->span.n);
                                    ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 2037 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        pList->a[i].zName = sqliteStrNDup(pExpr->span.z, pExpr->span.n);
                                          ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 2140 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    if( sqlite3StrNICmp(pExpr->token.z,"min",3)==0 ){
                        ^

cc-1164 cc: WARNING File = ./src/select.c, Line = 2142 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

    }else if( sqlite3StrNICmp(pExpr->token.z,"max",3)==0 ){
                              ^

cc-1515 cc: WARNING File = ./src/tokenize.c, Line = 356 A value of type "const char *" cannot be assigned to an entity of type "const unsigned char *".

      pParse->sLastToken.z = &zSql[i];
                           ^

cc-1164 cc: WARNING File = ./src/trigger.c, Line = 236 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      sqlite3VdbeChangeP3(v, addr+6, pAll->z, pAll->n);
                                     ^

cc-1164 cc: WARNING File = ./src/trigger.c, Line = 275 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      p->target.z = sqliteStrNDup(p->target.z, p->target.n);
                                  ^

cc-1515 cc: WARNING File = ./src/trigger.c, Line = 275 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      p->target.z = sqliteStrNDup(p->target.z, p->target.n);
                  ^

cc-1515 cc: WARNING File = ./src/trigger.c, Line = 612 A value of type "char *" cannot be assigned to an entity of type "const unsigned char *".

      sDb.z = pParse->db->aDb[iDb].zName;
            ^

cc-1164 cc: WARNING File = ./src/trigger.c, Line = 613 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      sDb.n = strlen(sDb.z);
                     ^

cc-1164 cc: WARNING File = ./src/vacuum.c, Line = 61 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

      rc = execSql(db, sqlite3_column_text(pStmt, 0));
                       ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1193 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        sqlite3SetString(&p->zErrMsg, sqlite3_value_text(pTos), (char*)0);
                                      ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 1748 A value of type "u8 *" cannot be assigned to an entity of type "char *".

        zRec = pC->aRow;
             ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 1815 A value of type "char *" cannot be assigned to an entity of type "u8 *".

          zRec = pC->aRow = zData;
                          ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 1815 A value of type "u8 *" cannot be assigned to an entity of type "char *".

          zRec = pC->aRow = zData;
               ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1820 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

      idx = sqlite3GetVarint32(zData, &szHdr);
                               ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1846 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

        idx += sqlite3GetVarint32(&zData[idx], &aType[i]);
                                  ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 1885 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3VdbeSerialGet(zData, aType[p2], pTos);
                         ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 2030 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

      zNewRecord = zTemp;
                 ^

cc-1515 cc: WARNING File = ./src/vdbe.c, Line = 2064 A value of type "unsigned char *" cannot be assigned to an entity of type "char *".

      pTos->z = zNewRecord;
              ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 2728 Argument of type "char *" is incompatible with parameter of type "const u8 *".

      szRowid = sqlite3VdbeIdxRowidLen(nKey, zKey);
                                             ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 2745 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

      rc = sqlite3VdbeIdxKeyCompare(pCx, len, zKey, &res); 
                                              ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3439 Argument of type "const char *" is incompatible with parameter of type "const u8 *".

        len = nKey - sqlite3VdbeIdxRowidLen(nKey, zKey);
                                                  ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3445 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

          if( sqlite3VdbeIdxKeyCompare(pC, len, zKey, &c)==SQLITE_OK && c==0 ){
                                                ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3595 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

      rc = sqlite3VdbeIdxKeyCompare(pC, pTos->n, pTos->z, &res);
                                                 ^

cc-1552 cc: WARNING File = ./src/vdbe.c, Line = 3581 The variable "pCrsr" is set but never used.

    BtCursor *pCrsr;
              ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3633 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

    k = sqlite3GetVarint32(z, &serial_type);
                           ^

cc-1164 cc: WARNING File = ./src/vdbe.c, Line = 3635 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

      k += sqlite3GetVarint32(&z[k], &serial_type);
                              ^

cc-1119 cc: WARNING File = ./src/vdbeapi.c, Line = 47 The "return" expression type differs from the function return type.

    return (const char *)sqlite3ValueText(pVal, SQLITE_UTF8);
           ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1747 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3GetVarint32(m.z, &szHdr);
                       ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1748 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3GetVarint32(&m.z[szHdr-1], &typeRowid);
                       ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1750 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

    sqlite3VdbeSerialGet(&m.z[m.n-lenRowid], typeRowid, &v);
                         ^

cc-1164 cc: WARNING File = ./src/vdbeaux.c, Line = 1786 Argument of type "char *" is incompatible with parameter of type "const u8 *".

    lenRowid = sqlite3VdbeIdxRowidLen(m.n, m.z);
                                           ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 76 A value of type "u8 *" cannot be assigned to an entity of type "char *".

    pMem->z = z;
            ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 96 A value of type "char *" cannot be assigned to an entity of type "u8 *".

      z = pMem->zShort;
        ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 109 A value of type "u8 *" cannot be assigned to an entity of type "char *".

    pMem->z = z;
            ^

cc-1140 cc: WARNING File = ./src/vdbemem.c, Line = 165 A value of type "char *" cannot be used to initialize an entity of type "u8 *".

    u8 *z = pMem->zShort;
            ^

cc-1164 cc: WARNING File = ./src/vdbemem.c, Line = 177 Argument of type "u8 *" is incompatible with parameter of type "char *".

      sqlite3_snprintf(NBFS, z, "%.15g", pMem->r);
                             ^

cc-1164 cc: WARNING File = ./src/vdbemem.c, Line = 180 Argument of type "u8 *" is incompatible with parameter of type "char *".

      sqlite3_snprintf(NBFS, z, "%lld", pMem->i);
                             ^

cc-1164 cc: WARNING File = ./src/vdbemem.c, Line = 182 Argument of type "u8 *" is incompatible with parameter of type "const char *".

    pMem->n = strlen(z);
                     ^

cc-1515 cc: WARNING File = ./src/vdbemem.c, Line = 183 A value of type "u8 *" cannot be assigned to an entity of type "char *".

    pMem->z = z;
            ^

cc-1552 cc: WARNING File = ./src/where.c, Line = 883 The variable "pTab" is set but never used.

      Table *pTab;             /* Left-most table in the FROM clause */
             ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 275 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

      zIn = pMem->z;
          ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 311 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

    zIn = pMem->z;
        ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 363 A value of type "char *" cannot be assigned to an entity of type "unsigned char *".

      zOut = pMem->zShort;
           ^

cc-1515 cc: WARNING File = ./src/utf.c, Line = 368 A value of type "unsigned char *" cannot be assigned to an entity of type "char *".

    pMem->z = zOut;
            ^

cc-1164 cc: WARNING File = ./src/shell.c, Line = 353 Argument of type "const char *" is incompatible with parameter of type "const unsigned char *".

    }else if( isNumber(z, 0) ){
                       ^

cc-1164 cc: WARNING File = ./src/shell.c, Line = 519 Argument of type "char *" is incompatible with parameter of type "const unsigned char *".

          }else if( isNumber(azArg[i], 0) ){
                             ^

cc-1164 cc: WARNING File = ./src/shell.c, Line = 682 Argument of type "const unsigned char *" is incompatible with parameter of type "const char *".

        zSelect = appendText(zSelect, sqlite3_column_text(pTableInfo, 1), '"');
                                      ^


2005-Feb-13 13:59:50 by anonymous:
Hi,

Here are the warnings I got while building SQLite 3.1.1 beta on Irix 6.5 using SGI's MIPSpro 7.3.1.1m compiler.

I've removed all the signed/unsigned issues, since I suspect you're not interested...

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2444 The variable "pBt" is set but never used.

    Btree *pBt;
           ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2548 The variable "oldPgno" is set but never used.

    Pgno oldPgno;
         ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 3757 The variable "idxDiv" is set but never used.

    int idxDiv[NB];              /* Indices of divider cells in pParent */
        ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 5384 The variable "cur" is set but never used.

    BtCursor cur;
             ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 5386 The variable "maxLocal" is set but never used.

    int maxLocal, usableSize;
        ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 131 The variable "rc" is set but never used.

    int rc;
        ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 629 The variable "pIdx" is set but never used.

    Index *pIdx;
           ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 2238 The variable "pISameName" is set but never used.

        Index *pISameName;    /* Another index with the same name */
               ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 2239 The variable "pTSameName" is set but never used.

        Table *pTSameName;    /* A table with same name as the index */
               ^

cc-1552 cc: WARNING File = ./src/expr.c, Line = 996 The variable "pSrcList" is set but never used.

    SrcList *pSrcList;
             ^

cc-1552 cc: WARNING File = ./src/expr.c, Line = 1696 The variable "v" is set but never used.

    Vdbe *v;
          ^

cc-1552 cc: WARNING File = ./src/os_unix.c, Line = 1217 The variable "inMutex" is set but never used.

  static int inMutex = 0;
             ^

cc-1552 cc: WARNING File = ./src/vdbe.c, Line = 3586 The variable "pCrsr" is set but never used.

    BtCursor *pCrsr;
              ^

cc-1552 cc: WARNING File = ./src/where.c, Line = 899 The variable "pTab" is set but never used.

      Table *pTab;             /* Left-most table in the FROM clause */
             ^


2005-Feb-20 16:37:31 by anonymous:
Hi,

Here are the warnings I got while building SQLite 3.1.3 on Irix 6.5 using SGI's MIPSpro 7.3.1.1m compiler.

Once again I've removed all the signed/unsigned issues, since I suspect you're not interested in them.

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2425 The variable "pBt" is set but never used.

    Btree *pBt;
           ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 2529 The variable "oldPgno" is set but never used.

    Pgno oldPgno;
         ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 3741 The variable "idxDiv" is set but never used.

    int idxDiv[NB];              /* Indices of divider cells in pParent */
        ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 5372 The variable "cur" is set but never used.

    BtCursor cur;
             ^

cc-1552 cc: WARNING File = ./src/btree.c, Line = 5374 The variable "maxLocal" is set but never used.

    int maxLocal, usableSize;
        ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 133 The variable "rc" is set but never used.

    int rc;
        ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 631 The variable "pIdx" is set but never used.

    Index *pIdx;
           ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 2244 The variable "pISameName" is set but never used.

        Index *pISameName;    /* Another index with the same name */
               ^

cc-1552 cc: WARNING File = ./src/build.c, Line = 2245 The variable "pTSameName" is set but never used.

        Table *pTSameName;    /* A table with same name as the index */
               ^

cc-1552 cc: WARNING File = ./src/expr.c, Line = 1021 The variable "pSrcList" is set but never used.

    SrcList *pSrcList;
             ^

cc-1552 cc: WARNING File = ./src/expr.c, Line = 1721 The variable "v" is set but never used.

    Vdbe *v;
          ^

cc-1552 cc: WARNING File = ./src/where.c, Line = 899 The variable "pTab" is set but never used.

      Table *pTab;             /* Left-most table in the FROM clause */
             ^
 
955 warn active 2004 Oct anonymous Unknown 2004 Oct   1 1 When installing SQLite it says that a file is missing. edit
I downloaded sqlite-2.8.15-1.i386.rpm. I tried to install it but is says that libreadline.so.4 is missing or something. When i go to KFind it says it is in /lib/ , i go there and i find it. I really need SQLite to play a game from freashmeat.net.

PLEASE HELP ME !!!

 
947 warn active 2004 Oct anonymous Unknown 2004 Oct   3 3 Cygwin: integer constant is too large for "long" type edit
During porting to Cygwin, following is displayed

... gcc -DOS_WIN=1 -DHAVE_USLEEP=1 -I. -I/cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src -DNDEBUG -c /cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src/util.c -DPIC -o .libs/util.o /cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src/util.c: In function `sqlite3PutVarint': /cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src/util.c:861: warning: integer constant is too large for "long" type

2004-Oct-06 22:18:17 by anonymous:
[Forgot to paste this too] gcc -DOS_WIN=1 -DHAVE_USLEEP=1 -I. -I/cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src -DNDEBUG -c /cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src/vdbe.c -DPIC -o .libs/vdbe.o
/cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src/vdbe.c: In function `sqlite3VdbeExec':
/cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src/vdbe.c:2890: warning: integer constant is too large for "long" type
/cygdrive/e/home/jaalto/tmp/tmp/tmp/sqlite-3.0.7/src/vdbe.c:2897: warning: integer constant is too large for "long" type


2004-Oct-07 03:54:36 by dougcurrie:
This is a duplicate of ticket #828

Are there any issues with using the LL suffix on these constants?

 
828 warn active 2004 Jul anonymous Unknown 2004 Jul   3 3 integer constants to long edit
when compiling sqlite3 on windows using msys/mingw I get the following warnings:

src/util.c: In function `sqlite3PutVarint':
src/util.c:1022: warning: integer constant is too large for "long" type
src/vdbe.c: In function `sqlite3VdbeExec':
src/vdbe.c:2917: warning: integer constant is too large for "long" type
src/vdbe.c:2924: warning: integer constant is too large for "long" type
src/vdbeaux.c: In function `sqlite3VdbeSerialType':
src/vdbeaux.c:1440: warning: integer constant is too large for "long" type
src/vdbeaux.c:1440: warning: integer constant is too large for "long" type

2004-Aug-30 16:06:52 by anonymous:
I had the same problem in Solaris.


2004-Dec-09 09:31:46 by anonymous:
I have the same problem compiling Sqlite 3.0.8 on Mac OS X 10.3.6.

I got rid of the warnings by added the LL suffix to the offending constants.

Since the line numbers producing the warnings have changed over time, below is a list that includes the statements, which might help the Sqlite developer looking for them in the current code:

  vdbeaux.c:1496: integer constant is too large for "long" type
  vdbeaux.c:1496: integer constant is too large for "long" type

      if( i>=-140737488355328L && i<=140737488355328L ) return 5;

  vdbe.c:2867: integer constant is too large for "long" type

     if( v==0x7fffffffffffffff ){

  vdbe.c:2874: integer constant is too large for "long" type

      if( v==0x7fffffffffffffff ){

  util.c:799: integer constant is too large for "long" type

  	if( v & 0xff00000000000000 ){
 
802 warn active 2004 Jul anonymous   2004 Jul anonymous 1 1 Unable to compile the sqlite edit
- compilation of many modules produces warnings, warnings, warnings, warnings ...................... warnings. - Borland 5.02 is not able to compile some modules at all (compiler internal error).
 
780 warn active 2004 Jun anonymous Unknown 2004 Jun   3 2 Builkd gice src code errors on MacOS edit
Building/testing MacOSX 10.3.4 gcc 3.3

Building sqlite & test gave error "constant too long for long" util.c line 1180 vdbe.c lines 2979 and 2986 vdbeaux.c line 1482 (twice)

running full test gave following errors

printf-1.11.1... Expected: [Three integers: -2 fffffffffffffffe 1777777777777777777776] Got: [Three integers: -1 fffffffffffffffe 1777777777777777777776] printf-1.11.2... Expected: [Three integers: ( -2) (fffffffffffffffe) (1777777777777777777776)] Got: [Three integers: ( -1) (fffffffffffffffe) (1777777777777777777776)] printf-1.11.3... Expected: [Three integers: (-2 ) (fffffffffffffffe) (1777777777777777777776)] Got: [Three integers: (-1 ) (fffffffffffffffe) (1777777777777777777776)] printf-1.11.4... Expected: [Three integers: ( -2) (fffffffffffffffe) (1777777777777777777776)] Got: [Three integers: ( -1) (fffffffffffffffe) (1777777777777777777776)] printf-1.11.5... Expected: [Three integers: (-00002) (fffffffffffffffe) (1777777777777777777776)] Got: [Three integers: (-00001) (fffffffffffffffe) (1777777777777777777776)] printf-1.11.6... Expected: [Three integers: ( -2) (fffffffffffffffe) (1777777777777777777776)] Got: [Three integers: ( -1) (fffffffffffffffe) (1777777777777777777776)] printf-1.12.1... Expected: [Three integers: -5 fffffffffffffffb 1777777777777777777773] Got: [Three integers: -1 fffffffffffffffb 1777777777777777777773] printf-1.12.2... Expected: [Three integers: ( -5) (fffffffffffffffb) (1777777777777777777773)] Got: [Three integers: ( -1) (fffffffffffffffb) (1777777777777777777773)] printf-1.12.3... Expected: [Three integers: (-5 ) (fffffffffffffffb) (1777777777777777777773)] Got: [Three integers: (-1 ) (fffffffffffffffb) (1777777777777777777773)] printf-1.12.4... Expected: [Three integers: ( -5) (fffffffffffffffb) (1777777777777777777773)] Got: [Three integers: ( -1) (fffffffffffffffb) (1777777777777777777773)] printf-1.12.5... Expected: [Three integers: (-00005) (fffffffffffffffb) (1777777777777777777773)] Got: [Three integers: (-00001) (fffffffffffffffb) (1777777777777777777773)] printf-1.12.6... Expected: [Three integers: ( -5) (fffffffffffffffb) (1777777777777777777773)] Got: [Three integers: ( -1) (fffffffffffffffb) (1777777777777777777773)] printf-1.13.1... Expected: [Three integers: -10 fffffffffffffff6 1777777777777777777766] Got: [Three integers: -1 fffffffffffffff6 1777777777777777777766] printf-1.13.2... Expected: [Three integers: ( -10) (fffffffffffffff6) (1777777777777777777766)] Got: [Three integers: ( -1) (fffffffffffffff6) (1777777777777777777766)] printf-1.13.3... Expected: [Three integers: (-10 ) (fffffffffffffff6) (1777777777777777777766)] Got: [Three integers: (-1 ) (fffffffffffffff6) (1777777777777777777766)] printf-1.13.4... Expected: [Three integers: ( -10) (fffffffffffffff6) (1777777777777777777766)] Got: [Three integers: ( -1) (fffffffffffffff6) (1777777777777777777766)] printf-1.13.5... Expected: [Three integers: (-00010) (fffffffffffffff6) (1777777777777777777766)] Got: [Three integers: (-00001) (fffffffffffffff6) (1777777777777777777766)] printf-1.13.6... Expected: [Three integers: ( -10) (fffffffffffffff6) (1777777777777777777766)] Got: [Three integers: ( -1) (fffffffffffffff6) (1777777777777777777766)] printf-1.14.1... Expected: [Three integers: -99 ffffffffffffff9d 1777777777777777777635] Got: [Three integers: -1 ffffffffffffff9d 1777777777777777777635] printf-1.14.2... Expected: [Three integers: ( -99) (ffffffffffffff9d) (1777777777777777777635)] Got: [Three integers: ( -1) (ffffffffffffff9d) (1777777777777777777635)] printf-1.14.3... Expected: [Three integers: (-99 ) (ffffffffffffff9d) (1777777777777777777635)] Got: [Three integers: (-1 ) (ffffffffffffff9d) (1777777777777777777635)] printf-1.14.4... Expected: [Three integers: ( -99) (ffffffffffffff9d) (1777777777777777777635)] Got: [Three integers: ( -1) (ffffffffffffff9d) (1777777777777777777635)] printf-1.14.5... Expected: [Three integers: (-00099) (ffffffffffffff9d) (1777777777777777777635)] Got: [Three integers: (-00001) (ffffffffffffff9d) (1777777777777777777635)] printf-1.14.6... Expected: [Three integers: ( -99) (ffffffffffffff9d) (1777777777777777777635)] Got: [Three integers: ( -1) (ffffffffffffff9d) (1777777777777777777635)] printf-1.15.1... Expected: [Three integers: -100 ffffffffffffff9c 1777777777777777777634] Got: [Three integers: -1 ffffffffffffff9c 1777777777777777777634] printf-1.15.2... Expected: [Three integers: ( -100) (ffffffffffffff9c) (1777777777777777777634)] Got: [Three integers: ( -1) (ffffffffffffff9c) (1777777777777777777634)] printf-1.15.3... Expected: [Three integers: (-100 ) (ffffffffffffff9c) (1777777777777777777634)] Got: [Three integers: (-1 ) (ffffffffffffff9c) (1777777777777777777634)] printf-1.15.4... Expected: [Three integers: ( -100) (ffffffffffffff9c) (1777777777777777777634)] Got: [Three integers: ( -1) (ffffffffffffff9c) (1777777777777777777634)] printf-1.15.5... Expected: [Three integers: (-00100) (ffffffffffffff9c) (1777777777777777777634)] Got: [Three integers: (-00001) (ffffffffffffff9c) (1777777777777777777634)] printf-1.15.6... Expected: [Three integers: ( -100) (ffffffffffffff9c) (1777777777777777777634)] Got: [Three integers: ( -1) (ffffffffffffff9c) (1777777777777777777634)] printf-1.16.1... Expected: [Three integers: -9999999 ffffffffff676981 1777777777777731664601] Got: [Three integers: -1 ffffffffff676981 1777777777777731664601] printf-1.16.2... Expected: [Three integers: (-9999999) (ffffffffff676981) (1777777777777731664601)] Got: [Three integers: ( -1) (ffffffffff676981) (1777777777777731664601)] printf-1.16.3... Expected: [Three integers: (-9999999) (ffffffffff676981) (1777777777777731664601)] Got: [Three integers: (-1 ) (ffffffffff676981) (1777777777777731664601)] printf-1.16.4... Expected: [Three integers: (-9999999) (ffffffffff676981) (1777777777777731664601)] Got: [Three integers: ( -1) (ffffffffff676981) (1777777777777731664601)] printf-1.16.5... Expected: [Three integers: (-9999999) (ffffffffff676981) (1777777777777731664601)] Got: [Three integers: (-00001) (ffffffffff676981) (1777777777777731664601)] printf-1.16.6... Expected: [Three integers: (-9999999) (ffffffffff676981) (1777777777777731664601)] Got: [Three integers: ( -1) (ffffffffff676981) (1777777777777731664601)] misuse-1.1... Error: invalid command name "sqlite_exec_printf" misuse-1.2... Error: invalid command name "sqlite_exec_printf" misuse-1.3... Error: invalid command name "sqlite_create_function" misuse-1.4... Error: invalid command name "sqlite_exec_printf" misuse-1.5... Error: invalid command name "sqlite_exec_printf" misuse-1.6... Ok misuse-2.1... Ok misuse-2.2... Error: invalid command name "sqlite_exec_printf" misuse-2.3... Expected: [1 {library routine called out of sequence}] Got: [1 {invalid command name "sqlite_create_function"}] misuse-2.4... Error: invalid command name "sqlite_exec_printf" misuse-2.5... Expected: [1 {library routine called out of sequence}] Got: [0 {1 2}] misuse-3.1... Ok misuse-3.2... Error: invalid command name "sqlite_exec_printf" misuse-3.3... Expected: [1 {library routine called out of sequence}] Got: [1 {invalid command name "sqlite_create_aggregate"}] misuse-3.4... Error: invalid command name "sqlite_exec_printf" misuse-3.5... Expected: [1 {library routine called out of sequence}] Got: [0 {1 2}] misuse-4.1... Ok misuse-4.2... Error: invalid command name "sqlite_exec_printf" misuse-4.3... Expected: [1 {library routine called out of sequence}] Got: [1 {invalid command name "sqlite_close"}] misuse-4.4... Error: invalid command name "sqlite_exec_printf" misuse-4.5... Expected: [1 {library routine called out of sequence}] Got: [0 {1 2}] misuse-5.1... Ok misuse-5.2... Error: invalid command name "sqlite_exec_printf" misuse-5.3... Error: invalid command name "sqlite_exec_printf" Skipping malloc tests: not compiled with -DMEMORY_DEBUG... 59 errors out of 22454 tests Failures on these tests: crash-1.2 crash-1.4 crash-1.5 printf-1.11.1 printf-1.11.2 printf-1.11.3 printf-1.11.4 printf-1.11.5 printf-1.11.6 printf-1.12.1 printf-1.12.2 printf-1.12.3 printf-1.12.4 printf-1.12.5 printf-1.12.6 printf-1.13.1 printf-1.13.2 printf-1.13.3 printf-1.13.4 printf-1.13.5 printf-1.13.6 printf-1.14.1 printf-1.14.2 printf-1.14.3 printf-1.14.4 printf-1.14.5 printf-1.14.6 printf-1.15.1 printf-1.15.2 printf-1.15.3 printf-1.15.4 printf-1.15.5 printf-1.15.6 printf-1.16.1 printf-1.16.2 printf-1.16.3 printf-1.16.4 printf-1.16.5 printf-1.16.6 printf-5.2 misuse-1.1 misuse-1.2 misuse-1.3 misuse-1.4 misuse-1.5 misuse-2.2 misuse-2.3 misuse-2.4 misuse-2.5 misuse-3.2 misuse-3.3 misuse-3.4 misuse-3.5 misuse-4.2 misuse-4.3 misuse-4.4 misuse-4.5 misuse-5.2 misuse-5.3 make: *** [fulltest] Error 1 [

 
746 warn active 2004 May anonymous CodeGen 2004 May anonymous 5 5 How can I make sqlite support serial term? edit
How can I make sqlite support "serial" term?

I just put some code into build.c and this is the cord that I changed.

void sqlite3AddPrimaryKey(Parse *pParse, IdList *pList, int onError){
...
if( zType && ( sqlite3StrICmp(zType, "INTEGER")==0 ||
sqlite3StrICmp(zType, "SERIAL")==0 )
){
...


void sqlite3AddColumnType(Parse *pParse, Token *pFirst, Token *pLast){
Table *p;
int iCol, i, j;
int n;
char *z, **pz, *t=0;
Column *pCol;
if( (p = pParse->pNewTable)==0 ) return;
iCol = p->nCol-1;
if( iCol<0 ) return;
pCol = &p->aCol[iCol];
pz = &pCol->zType;
n = pLast->n + Addr(pLast->z) - Addr(pFirst->z);
sqliteSetNString(pz, pFirst->z, n, 0);
z = *pz;
if( z==0 ) return;
for(i=j=0; z[i]; i++){
int c = z[i];
if( isspace(c) ) continue;
z[j++] = c;
}
z[j] = 0;
if( pParse->db->file_format>=4 ){
pCol->sortOrder = sqliteCollateType(z, n);
}else{
pCol->sortOrder = SQLITE_SO_NUM;
}
t = p->aCol[iCol].zType;
if( t && sqliteStrICmp(t, "SERIAL")==0 ){
if( p->iPKey == -1 ) p->iPKey = i;
else {
/* it has already "INTEGER PRIMARY KEY" or "SERIAL" */
sqliteErrorMsg(pParse,
"table \"%s\" has more than one serial type column", p->zName);
}
}
}
the result is "<column-name> serial primary key" is OK, but "<column-name> serial" has a bug. the program exits abnormally.

I just want to change it for my own. anybody give me some advice. thanks.

2004-May-24 12:30:21 by anonymous:
1.Add following code to the end of sqliteAddColumnType function in build.c

if( z && sqliteStrICmp(z, "SERIAL")==0 ){
if( p->iPKey == -1 ) p->iPKey = iCol;
else {
/* it has already "INTEGER PRIMARY KEY" or "SERIAL" */
sqliteErrorMsg(pParse,
"table \"%s\" has more than one serial type column", p->zName);
}
}

2. Change some code of sqliteAddPrimaryKey function so that it looks like this

if( pParse->db->file_format>=1 &&
zType && ( sqliteStrICmp(zType, "INTEGER")==0 ||
sqliteStrICmp(zType, "SERIAL")==0 )
){


2004-May-24 13:16:08 by anonymous:
Ups... the second code above has a bug.
correct one is this:

if( pParse->db->file_format>=1 &&
zType && ( sqliteStrICmp(zType, "INTEGER")==0 ||
sqliteStrICmp(zType, "SERIAL")==0 )
){
/* If there is already a serial */
if( pTab->iPKey>=0 && sqliteStrICmp(zType, "INTEGER")==0 ){
sqliteErrorMsg(pParse,
"table \"%s\" has more than one serial column type", pTab->zName);
goto primary_key_exit;
}


the result :

C:\test>sqlite.exe test.db
SQLite version 2.8.13
Enter ".help" for instructions
sqlite> create table t1 (id integer primary key, t text, i int);
sqlite> insert into t1 values (null, 'a', 1);
sqlite> insert into t1 values (null, 'b', 2);
sqlite> select * from t1;
1|a|1
2|b|2
sqlite> create table t2 (id serial primary key, t text, i int);
sqlite> insert into t2 values (null, 'a', 1);
sqlite> insert into t2 values (null, 'b', 2);
sqlite> select * from t2;
1|a|1
2|b|2
sqlite> create table t3 (id serial, t text, i int);
sqlite> insert into t3 values (null, 'a', 1);
sqlite> insert into t3 values (null, 'b', 2);
sqlite> select * from t3;
1|a|1
2|b|2
sqlite> create table t4 (id serial, t text primary key, i int);
sqlite> insert into t4 values (null, 'a', 1);
sqlite> insert into t4 values (null, 'b', 2);
sqlite> insert into t4 values (null, 'b', 2);
SQL error: column t is not unique
sqlite> select * from t4;
1|a|1
2|b|2
sqlite> create table t5 (id serial, t text, i integer primary key);
SQL error: table "t5" has more than one serial column type
sqlite> create table t5 (id serial, t text, i serial primary key);
SQL error: table "t5" has more than one serial type column
sqlite> create table t5 (id serial, t text, i serial);
SQL error: table "t5" has more than one serial type column
sqlite> create table t5 (id integer primary key, t text, i serial);
SQL error: table "t5" has more than one serial type column
sqlite>
 
647 warn active 2004 Mar anonymous Shell 2004 Mar   5 4 Shell.c compilation warnings edit
  Compilation of shell.c with OpenWatcom 1.3 reports

  d:\!progs\sqlite\src\shell.c(156): Warning! W111: Meaningless use of an expression
  d:\!progs\sqlite\src\shell.c(1337): Warning! W111: Meaningless use of an expression
  d:\!progs\sqlite\src\shell.c(272): Warning! W202: Symbol 'interrupt_handler' has been defined, but not referenced

  Bartosz Polednia
 
646 warn active 2004 Mar anonymous Pager 2004 Mar   5 4 Pager.c compilation warnings edit
  Compilation of pager.c with OpenWatcom 1.3 reports

  d:\!progs\sqlite\src\pager.c(360): Warning! W201: Unreachable code
  d:\!progs\sqlite\src\pager.c(1674): Warning! W201: Unreachable code

  Bartosz Polednia
 
560 warn active 2004 Jan anonymous   2004 Jan   4 4 Warnings on commpiling using Visual C++ 6.0 edit
Hello,

I tried to create static library using Visual C++ to make SQLite internal library of my project. When I compile SQLite, I receive 44 warnings:

Compiling...
attach.c
auth.c
btree.c
btree_rb.c
C:\Work\projects\SQLite_lib\src\btree.c(1920) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(1922) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(537) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(541) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(559) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(503) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(504) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(440) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\btree.c(451) : warning C4761: integral size mismatch in argument; conversion supplied
build.c
copy.c
date.c
C:\Work\projects\SQLite_lib\src\date.c(234) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(235) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(339) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(340) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(343) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(344) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(345) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(346) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(359) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(360) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(362) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(390) : warning C4244: 'initializing' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(396) : warning C4244: '=' : conversion from 'double ' to 'long ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(503) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(510) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(584) : warning C4244: '+=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(590) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(596) : warning C4244: '+=' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(772) : warning C4244: 'initializing' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(773) : warning C4244: 'initializing' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\date.c(787) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
delete.c
expr.c
func.c
hash.c
insert.c
main.c
opcodes.c
os.c
C:\Work\projects\SQLite_lib\src\os.c(925) : warning C4244: 'initializing' : conversion from '__int64 ' to 'long ', possible loss of data
C:\Work\projects\SQLite_lib\src\os.c(926) : warning C4244: 'initializing' : conversion from '__int64 ' to 'long ', possible loss of data
C:\Work\projects\SQLite_lib\src\os.c(1017) : warning C4244: 'initializing' : conversion from '__int64 ' to 'long ', possible loss of data
C:\Work\projects\SQLite_lib\src\os.c(1018) : warning C4244: 'function' : conversion from '__int64 ' to 'long ', possible loss of data
pager.c
C:\Work\projects\SQLite_lib\src\os.c(1018) : warning C4761: integral size mismatch in argument; conversion supplied
C:\Work\projects\SQLite_lib\src\pager.c(602) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\pager.c(605) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\pager.c(720) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\pager.c(928) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\pager.c(930) : warning C4244: 'return' : conversion from '__int64 ' to 'int ', possible loss of data
parse.c
pragma.c
parse.c(3985) : warning C4761: integral size mismatch in argument; conversion supplied
parse.c(3996) : warning C4761: integral size mismatch in argument; conversion supplied
printf.c
random.c
select.c
C:\Work\projects\SQLite_lib\src\select.c(102) : warning C4018: '==' : signed/unsigned mismatch
shell.c
table.c
tclsqlite.c
tokenize.c
trigger.c
update.c
util.c
vacuum.c
vdbe.c
C:\Work\projects\SQLite_lib\src\vdbe.c(1295) : warning C4244: 'initializing' : conversion from 'double ' to 'int ', possible loss of data
C:\Work\projects\SQLite_lib\src\vdbe.c(1310) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
vdbeaux.c
where.c
Creating library...
2004-Jul-22 06:42:15 by anonymous:
Anything happening here ? I actually try to convince my boss to evaluate SQLite for our project but as long as there are so many warnings I have no chance. I think it's quite crucial to get a clean compile, especially those "possible loss of data" warnings are quite horrible for a database ;-)
 
503 warn active 2003 Nov anonymous Unknown 2003 Dec anonymous 5 2 Include sqlite source in Visual C++ 6.0 SP5 edit
when I try to use sqlite source in my VC6 project,there a lot of errors with compile,then I change the precompiled header setting to NONE,now no errors,but there so many warning about type,I suggest forced convertion type should be used then it will look more official,and there a "( )" should be inside the MACRO defination for SWAB16(?).
 
391 warn active 2003 Jul anonymous   2003 Dec   4 3 signed/unsiged compiler warnings from Borland C++6 edit
When I compile the 2.8.4 source code (as of 2003-07-14) with Borland's C++ Builder 6 compiler I get warnings about signed-unsigned comparisons and suspicious pointer conversions (int * vs unsigned *) in two files.

  pager.c produces the following messages:
  [C++ Warning] pager.c(598): W8075 Suspicious pointer conversion
  [C++ Warning] pager.c(613): W8012 Comparing signed and unsigned values

  select.c produces the following message:
  [C++ Warning] select.c(99): W8012 Comparing signed and unsigned values

These warnings can be eliminated by the small changes detailed in the attached diff files.

 
348 warn active 2003 Jun anonymous Unknown 2003 Dec drh 4 3 SQLite and GCC using enhanced warning levels edit
SQLite doesn't compile cleanly if you enable the following GCC compiler warnings:

  -Wcast-qual
  -Wmissing-declarations
  -Wnested-externs
  -Wuninitialized
  -Wwrite-strings

Most of these can be fixed by changing "char *" to "char const *" in a few judicious places.