bgcolor # Type Status Created By Subsys Changed Assigned Svr Pri Title _Description _Remarks #c8c8c8 27 code closed 2002 Apr anonymous 2002 Apr drh 2 2 incorrect result when doing select using quotes in where the following sql does not return a result (where it should): create table test ( "id" varchar(5), "value" varchar(10) ); insert into "test" values ('test','test it'); select * from "test" where "id" = 'test'; The following query does work, so it is probably an error in the parser select * from "test" where id = 'test'; SQLite is correct. The expression "id" is a string and it is not equal to the string 'test'. If you want the value of the id column, either omit the double-quotes, or put the name of the table in front separated by a dot. select * from test where id='test'; select * from test where 'test'.'id' = 'test'; #c8c8c8 25 code closed 2002 Apr anonymous 2002 Apr drh 1 1 continu ticket 23, I Direct Access Sqlite.dll I'm Sorry, My Desciption not a good detail. I'm China User, Use Chinese Char and Direct Access Your's Sqlite.dll, the Error As Ticket23, So you can copy follow sql Statement to test: 1, create table test (Óû§Ãû,ÃÜÂë); 2, insert into test values ('Óû§Ãû','ÃÜÂë'); 2, select rowid, Óû§Ãû, ÃÜÂë from test; 3, sqlite_exec(Handle, Sql, Callback, ErrMsg); 4, Data of Result is Correct, but FieldName not Same as Above. I think, because you OS not Surpport Chinese, so you can compare fieldname's Byte, you can find the problem. else I Ask How to Change to Utf-8 charset. I am unable to reproduce this problem. I have tried the sequence of commands above, using versions of SQLite compiled for both ISO8859 and UTF-8 and they all work perfectly. #c8c8c8 24 code closed 2002 Apr anonymous 2002 Apr drh 4 3 Make "update ... where ..." fail if where clause is false. It would be of great help to software using SQLite if update´s fails if a given where clause is false. If you need to know if the WHERE clause was false for all rows of an UPDATE, you can use the sqlite_changes() API to see how many rows were changed. #c8c8c8 20 code closed 2002 Apr anonymous 2002 Apr drh 1 1 Order By clause not sorting correctly for string columns I have a string column called seqID with the following values (0.3, 0.1.1, 0.1) I perform "select seqID from table order by seqID" using sqlite command-line tool and receive the recods in the following order (0.1, 0.3, 0.1.1) This is contrary to every other SQL implementation I could try (including SQL Server). Should be (0.1, 0.1.1, 0.3) My app depends on having the right sequence and is broken. Works as designed. The 0.1 and 0.3 are interpreted as numbers. These sort in numerical order and come before all strings. 0.1.1 is not a well-formed number so it is interpreted as a string and sorts after all numbers. You can work around this problem by forcing the comparision to always be between strings. Do this by prepending a single non-numeric character to the column to be sorted. For example: SELECT * FROM table ORDER BY 'x' || key; The 'x'|| prepends a single 'x' character to the sort key and thus forces all keys to be compared as strings. #c8c8c8 18 event closed 2002 Apr anonymous 2002 Apr drh 1 1 The sqlite server does not run under windows xp The sqlite server does not run under windows xp, it does not start. There must be some misunderstanding. SQLite is not a server. One does not "start" SQLite. #c8c8c8 14 new closed 2002 Apr anonymous 2002 Apr drh 5 4 decouple the BTREE implementaion from sqlite decouple the BTREE implementaion from sqlite. So one can use Berkley DB, NDB or any other DB for data storage. MySQL did it in their implementation and it would make room for multi platform databases. This is already the case. The BTREE module has a well defined interface to the rest of the system. It should be a (relatively) simple matter to construct a wrapper around BDB, or any other B-Tree implementation, that will seamlessly replace the existing BTREE module. #c8c8c8 145 code closed 2002 Aug anonymous Unknown 2002 Aug 1 1 Tests failing I just compiled sqlite-2.7.0 on a Linux-2.4.19 ix86 box. The _make test_ is failing as follows: 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 6749 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 If you need more information, just email me... This was a problem in the Makefile, not in the code. It's fixed now. ---- Works for me: 0 errors out of 7193 tests #c8c8c8 144 new closed 2002 Aug anonymous Unknown 2002 Aug 4 3 Read/Write Locks under Windows NT/2000/XP (simul. access) SQLite doesn't allow multiple Threads/Processes simul. access to a SQLite database (if a transaction begins, the database is completely WRITE-Locked) under Windows. A patch is availabe (http://groups.yahoo.com/group/sqlite/message/1577) that allows r/w locks at least under Windows NT/2000/XP. Of course, I can send you the patch again via E-Mail. Reader/writer locks for windows have already been implemented (see check-in [714]). When a transaction begins, the entire database is write-locked. Always. This is not a windows thing. The rule for SQLite is that there can be multiple readers or a single writer. It used to be that under windows there could only be a single reader. That restriction was lifted by check-in [714] - now windows may have multiple readers. But it has always been the case for all OSs that SQLite would only allow a single process to write to the database at one time. #c8c8c8 143 code closed 2002 Aug anonymous Unknown 2002 Aug anonymous 1 3 order by and null columns The results of order by are inconsistent for the secondary sort key if the primary sort key is null. Example sql code is below which illustrates the problem. The first select returns c b a while the second returns a b c create table a (x, y); insert into a values (null, 'a'); insert into a values (null, 'b'); insert into a values (null, 'c'); select * from a order by x, y; select * from a order by y; This appears to be a duplicate of ticket #142 which was fixed by check-in [730]. #cfe8bd 142 code fixed 2002 Aug anonymous 2002 Aug 1 1 Incorrect Order By when column is null create table a( a id ); INSERT INTO a VALUES(3); INSERT INTO a VALUES(1); INSERT INTO a VALUES(2); select * from a order by null , a; returns 2,1,3, and it must return 1,2,3 A better example: create table a ( a int , b varchar(10) ); INSERT INTO a VALUES(2,'ab'); INSERT INTO a VALUES(1,NULL); INSERT INTO a VALUES(3,NULL); INSERT INTO a VALUES(0,'cd'); INSERT INTO a VALUES(5,NULL); INSERT INTO a VALUES(4,NULL); select * from a order by b , a; #c8c8c8 141 code closed 2002 Aug anonymous Unknown 2002 Aug 1 3 Using the incorrect format inhibits record update If, inside a c code, you use something like: "UPDATE TABLE PIPPO SET PLUTO=%d" but PLUTO is defined float and you pass a float to the sqlite_exec_printf() that does the update, then the record is NOT updated and no error is reported. If you pass a float to a %d format string, you are going to have problems. I'm not sure there is anything SQLite can do about it. #cfe8bd 140 todo fixed 2002 Aug drh CodeGen 2002 Aug drh 4 4 Enhance INSERT ... SELECT to omit the intermediate temporary table Consider the following statement. INSERT INTO table SELECT ... As currently implemented, statements of this form first execute the SELECT and store the results in a temporary table. Then the temporary table is scanned and the results are written into the destination table. The operation would go about twice as fast if the results of the SELECT were written into the destination table directly, bypassing the intermediate temporary table. Suggested implementation strategy: 1: Implement OP_Gosub and OP_Return operators in the VDBE. (These are needed for other things anyhow.) 2: Add a new destination type to the sqliteSelect() routine, *SRT_Subroutine*, that invokes a subroutine to process each row of the result set. 3: Modify the sqliteInsert() procedure to code a subroutine to do the insert and then call sqliteSelect() to code the select using the new SRT_Subroutine target. Skipping the intermediate table causes problems for statements like this: INSERT INTO t1 SELECT * FROM t1; So we need to either drop this idea or fall back to the old intermediate scheme when there is self-reference. There might also be problems when there are insert triggers that mess with some of the tables in the SELECT clause. #f2dcdc 139 new active 2002 Aug anonymous Pager 2002 Aug 3 3 Named transactions are misleading as documented 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. #cfe8bd 138 code fixed 2002 Aug jadams 2002 Aug 4 4 Makefile doesn't use exec_prefix, has some install problems 1: autoconf provides an '--exec_prefix' option, which lets you set a directory, (by default the same as '--prefix') in which to install architecture-specific executables and libraries. The Makefile.in shipped with sqlite doesn't use this, and just uses --prefix. 1: the 'sqlite' target does not include a -rpath directive, which makes installing the shlibs in a non-standard location tricky. 1: the install target gets _very_ confused if the target directories do not exist. I've added INSTALL -d directives to fix that. unidiff: (had some extra stuff in there) --- Makefile.in.dist Wed May 15 04:07:05 2002 +++ Makefile.in Tue Aug 20 23:47:11 2002 @@ -31,6 +31,7 @@ # Some standard variables and programs # prefix = @prefix@ +exec_prefix = @exec_prefix@ INSTALL = @INSTALL@ LIBTOOL = ./libtool @@ -121,15 +122,15 @@ | awk '{print $$5,$$6}' >last_change libsqlite.la: $(LIBOBJ) - $(LIBTOOL) $(TCC) -o libsqlite.la $(LIBOBJ) -rpath $(prefix)/lib + $(LIBTOOL) $(TCC) -o libsqlite.la $(LIBOBJ) -rpath $(exec_prefix)/lib libtclsqlite.la: tclsqlite.lo libsqlite.la $(LIBTOOL) $(TCC) -o libtclsqlite.la tclsqlite.lo \ - libsqlite.la $(LIBTCL) -rpath $(prefix)/lib + libsqlite.la $(LIBTCL) -rpath $(exec_prefix)/lib sqlite: $(TOP)/src/shell.c libsqlite.la sqlite.h $(LIBTOOL) $(TCC) $(READLINE_FLAGS) -o sqlite $(TOP)/src/shell.c \ - libsqlite.la $(LIBREADLINE) + libsqlite.la $(LIBREADLINE) -rpath $(exec_prefix)/lib # Rules to build the LEMON compiler generator # @@ -309,8 +310,11 @@ mv $(DOC) doc install: sqlite libsqlite.la sqlite.h - $(LIBTOOL) $(INSTALL) libsqlite.la $(prefix)/lib - $(LIBTOOL) $(INSTALL) sqlite $(prefix)/bin + $(INSTALL) -d $(exec_prefix)/lib + $(LIBTOOL) $(INSTALL) libsqlite.la $(exec_prefix)/lib + $(INSTALL) -d $(exec_prefix)/bin + $(LIBTOOL) $(INSTALL) sqlite $(exec_prefix)/bin + $(INSTALL) -d $(prefix)/include $(INSTALL) -m 0644 sqlite.h $(prefix)/include clean: #cfe8bd 137 code fixed 2002 Aug anonymous Shell 2002 Aug 4 3 shell's find_home_dir() is ineffecient in src/shell.c: 981 static char *find_home_dir(void){ 982 char *home_dir = NULL; 983 984 #if !defined(_WIN32) && !defined(WIN32) 985 struct passwd *pwent; 986 uid_t uid = getuid(); 987 while( (pwent=getpwent()) != NULL) { 988 if(pwent->pw_uid == uid) { 989 home_dir = pwent->pw_dir; 990 break; 991 } 992 } 993 #endif If you've got a NIS server with a large passwd map, this takes a long time to complete. The getpwuid(3) function does a lookup instead of a line-by-line search. diff -u src/shell.c.dist src/shell.c --- src/shell.c.dist Thu Jul 25 13:30:01 2002 +++ src/shell.c Tue Aug 20 18:17:53 2002 @@ -984,11 +984,8 @@ #if !defined(_WIN32) && !defined(WIN32) struct passwd *pwent; uid_t uid = getuid(); - while( (pwent=getpwent()) != NULL) { - if(pwent->pw_uid == uid) { - home_dir = pwent->pw_dir; - break; - } + if( (pwent=getpwuid(uid)) != NULL) { + home_dir = pwent->pw_dir; } #endif When I try this patch on my RedHat7.2 box, the getpwuid() function spins. It never returns - just uses 100% of the CPU. (I didn't let it run for more than 15 seconds. Maybe it would have finished if I had been more patient...) Does anybody have any suggestions on how to fix this? ----- Silly me. I has a "while" around getpwuid() instead of an "if". The problem is fixed now. #cfe8bd 136 code fixed 2002 Aug drh CodeGen 2002 Aug drh 1 1 Segfault on VIEW of a subquery The following SQL causes a segfault: CREATE TABLE t1(a); CREATE VIEW v1 AS SELECT max(cnt) FROM (SELECT a, count(*) FROM t1 GROUP BY a); SELECT * FROM v1; #cfe8bd 135 new fixed 2002 Aug anonymous 2002 Aug 5 4 Code optimizations (to reduce compilation warnings under BC5 Windows) btree.c (variable totalSize unused): 2003 MemPage *pOldCurPage; /* The cursor originally points to this page */ 2004 - int totalSize; /* Total bytes for all cells */ 2005 int subtotal; /* Subtotal of bytes in cells on one page */ 2228 */ 2229 - totalSize = 0; 2230 - for(i=0; inSrc && inSrc && i<32; i++){ 412 int j; printf.c (variable zMem unused): 208 enum et_type xtype; /* Conversion paradigm */ 209 - char *zMem; /* String to be freed */ 210 char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ 552 case etSTRING: 553 - zMem = bufpt = va_arg(ap,char*); 553 + bufpt = va_arg(ap,char*); 554 if( bufpt==0 ) bufpt = "(null)"; #cfe8bd 134 code fixed 2002 Aug anonymous Parser 2002 Aug anonymous 2 4 syntax error in lemon.c on IBM AIX systems (both gcc and xlc) On IBM systems, the include file defines FALSE and TRUE as 0 and 1. This generates a syntax error on line 120 of lemon.c: typedef enum {FALSE=0, TRUE} Boolean; because this line is mapped into typedef enum {0=0, 1} Boolean; which is not legal C. Possible work-arounds: *: explicitly define your own FALSE and TRUE as 0 and 1 then replace "FALSE=0" with just "FALSE" *: change FALSE to False and TRUE to True #cfe8bd 133 code fixed 2002 Aug anonymous Unknown 2002 Aug 5 5 sqlite.exe crashes If I manipulate a database from TCL using tclsqlite.dll and then try to use sqlite.exe on the database, I receive the following error: SQLITE.exe has generated errors and will be closed by Windows. The database is very small (27KB) and I would be glad to send it to you if you will supply an email address. This has happend twice, the first time I just ignored it and started over. I can also be reached at 919.997.7878 - Ron. This is from an older version of SQLite. The problem was fixed by check-in [682]. #cfe8bd 132 new fixed 2002 Aug anonymous Unknown 2002 Aug 3 3 Temp file path In os.c: int sqliteOsTempFileName(char *zBuf){ #if OS_UNIX static const char *azDirs[] = { ".", "/tmp", "/var/tmp", "/usr/tmp", }; ... The choice of the current directory "." as the first candidate where to put the temp file is IMO very bad. In an embedded system like ours this results in a premature compact flash consumption. And, you know, embedded systems are the preferred targets of sqlite. It would be far better preferible to put "." as the last resort, preferring the other three, which can be statically linked or mounted on a ram disk (as we do). Or, even better, specify it as a compile options. Anyway, you are doing a wonderful job! #cfe8bd 131 code fixed 2002 Aug drh 2002 Aug drh 1 1 ORDER BY ignored when used with GROUP BY on an indexed column Consider the following code: CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(3,4); INSERT INTO t1 VALUES(1,2); INSERT INTO t1 SELECT a+4,b+4 FROM t1; INSERT INTO t1 SELECT a,b+8 FROM t1; SELECT a, min(b) FROM t1 GROUP BY a ORDER BY a; CREATE INDEX i1 ON t1(a); SELECT a, min(b) FROM t1 GROUP BY a ORDER BY a; The first SELECT occurs before the index is created and it sorts the result correctly. But in the second SELECT, the output appears in a random order. The ORDER BY clause has no effect. This appears to only happen when a GROUP BY clause is used and the ORDER BY clause refers to an indexed column. #cfe8bd 130 code fixed 2002 Aug anonymous 2002 Aug 3 3 No transactions across Linux threads seems restrictive. I see that you have added an explanation that starting a transaction in one thread and terminating it in another thread are not permitted under LinuxThreads. If I understand your reason for instituting this restriction, it is to prevent someone from starting a transaction in one processes forking, then completing it in another process. If this is the case, then it is a pity that you put this restriction into your threaded implementation under Linux where it apparently works fine. Did you implement this restriction to prevent someone from possibly doing something stupid? Hmmm -- I'm sure that if we think about it, you can find out if you are really running as a thread or not, but it doesn't seem to me to be that important. As far as I can tell LinuxThreads are perfectly compliant with Posix Threads. I see nothing in the standard that refers to a process id (other than that you should be able to create at least 64 threads from a single process, which, of course, you can do). pthreads do not contain the concept of a process id as far as I know. If you really want to have this restriction, fine, but if it does no harm on Linux machines, then please provide us with a configuration parameter for disabling it. If you have some real reason why it won't work on Linux, then of course, you can trash this request. PS: Is there any way to get your response by email? #c8c8c8 113 doc closed 2002 Jul anonymous 2002 Aug 5 5 Incorrect description of SQLite The page http://www.hwaci.com/sw/index.html contains incorrect description of the product: SQLite is a C library that functions as an SQL frontend to a GDBM database. #cfe8bd 208 code fixed 2002 Dec anonymous BTree 2002 Dec 2 2 pager.c uninitlized local variable LINE 832: static int syncAllPages(Pager *pPager){ PgHdr *pPg; /* AOS Correction to add 0 initializer */ Pgno lastPgno = 0; int rc = SQLITE_OK; LINE 854: if( lastPgno==0 || pPg->pgno!=lastPgno+1 ){ used before being initialized. This bug was introduced by check-in [795]. It could (in theory) lead to database corruption, though that is unlikely. #c8c8c8 205 code closed 2002 Dec anonymous VDBE 2002 Dec 4 4 select order by on a column with null values causes uninitialized-read On Windows, compiled with Visual Studio C++ 7.0, sending SQLite the following statements: create table x (y text, z text); insert into x (y) values ('1'); insert into x (y) values ('2'); select * from x order by z desc; causes an uninitialized read of memory in the file: ** $Id: util.c,v 1.50 2002/08/26 19:55:08 drh Exp $ at the end of the function: int sqliteSortCompare(const char *a, const char *b) within the line: if (dir=='-' || dir=='D') res = -res; because 'dir' is never initialized when the function is passed two empty (empty, not null) strings to compare. I just changed it to: if (res && (dir=='-' || dir=='D')) res = -res; as res is initialized, but I didn't look very hard to see if something 'more bad' was happening (eg, was this function not supposed to receive empty strings...). Thank you for the great lightweight SQL database. Have you ever run it through a memory profiler? I tried it on Windows with BoundsChecker and BC complained a few times about memory being lost -- not sure if it was a spurious report by BC or not though. This has already been fixed. See check-in [757] on 2002-Sep-29. Compiling SQLite with the -DMEMORY_DEBUG=1 flag enables a built-in memory profiler. The test suite does this and finds no memory leaks. There are also provisions in the test code for simulating out-of-memory conditions (when malloc() returns NULL). The test suite shows that SQLite responds sensibly to such occurrances. #f2dcdc 204 event active 2002 Dec anonymous Unknown 2002 Dec anonymous 1 1 Select statement takes hours (or more!) 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? #f2dcdc 203 new active 2002 Dec anonymous Unknown 2002 Dec anonymous 2 1 Missing Win32 open flag if shared database 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. #cfe8bd 202 code fixed 2002 Dec anonymous 2002 Dec 1 1 make test core-dumps on solaris I untarred sqlite, created a sqlite-build folder, went in there, ../sqlite/configure, then make. make test proceeded through to the misuse tests without incident, but then: misuse-5.3... Ok{linebreak} make: *** [test] Segmentation Fault (core dumped){linebreak} This is on Solaris 2.7 (ultrasparc, 32-bit OS), with TCL 8.3 installed. Compiler is GCC 3.1. I applied the patch from check-in [799] onto 2.7.3 (well, got the patch from cvs in case of HTML formatting problems) and rebuilt from scratch. The full test suite runs without error now. The test suite also runs without error in the CVS HEAD as of Dec 17, noon. It's worth noting that I upgraded to TCL 8.4.1 while trying to isolate the bug. So, the above successful tests were run with libtcl8.4. However, misuse.test runs to completion on 8.3 as well. #cfe8bd 200 code fixed 2002 Dec anonymous Pager 2002 Dec 3 3 full pathname of database not recorded, so errors when chdir used When a db is opened with sqlite_open(), only the filename argument is saved, not the full pathname or current directory. If the program subsequently changes the current directory, and the argument to sqlite_open() was not a full pathname, then the journal file will be created in an arbitrary place. This leads to many potential errors, including no possibility of recovery, or runtime errors. An example Windows tcl session demonstrating one problem is below. Here the e: drive is initially empty, and then a CD-ROM is inserted. By changing to this drive as the current directory, sqlite is unable to create the journal file despite the fact that the db is on a writable drive. 14 % sqlite db test.db 0x009D7FB8 () 15 % cd a: couldn't change working directory to "a:": file busy () 16 % cd e: couldn't change working directory to "e:": file busy () 17 % cd e: () 18 % db eval {CREATE TABLE t1(a int, b text)} unable to open database file () 19 % cd c: () 20 % db eval {CREATE TABLE t1(a int, b text)} SQL logic error or missing database () 21 % db close () 22 % sqlite db test.db 0x009D7FB8 () 23 % db eval {CREATE TABLE t1(a int, b text)} () 24 % cd e: () 25 % db eval {CREATE TABLE t2(a int, b text)} unable to open database file () 26 % cd c: () 27 % db eval {select * from t1} () 28 % db eval {CREATE TABLE t2(a int, b text)} SQL logic error or missing database () 29 % db eval {select * from t1} () 30 % db eval {select * from t2} no such table: t2 () 31 % #cfe8bd 197 code fixed 2002 Dec anonymous Unknown 2002 Dec 1 1 Missing .yacc & .lex file... I encountered annyoing disability with sqlite (no 'LIKE') and i wanted to add it, but as sources are generated, changing them is really painfull... would you be so nice and add yaccs input files to the distribution. Anyway usefull program... Thank you, Rok Erjavec, Slovenia 1: SQLite supports LIKE. Also NOT LIKE, GLOB, and NOT GLOB. 2: The lexical analyzer is hand-coded. The source file is tokenize.c 3: The parser is generated using {link: http://www.hwaci.com/sw/lemon Lemon}, not Yacc. The grammer is defined by the parse.y source file. The source code and documentation for Lemon are also include in the distribution. #cfe8bd 193 code fixed 2002 Nov anonymous Unknown 2002 Dec 3 3 Incorrect creation of a VIEW when using SELECT ... LIMIT First of all, I really like your efforts. SQLite is a great product and I'm very happy to be able to use it. The bug occured when I executed the following SQL query: CREATE VIEW top3 AS SELECT DISTINCT COUNT(*) FROM restaurants GROUP BY plaats ORDER BY COUNT(*) DESC LIMIT 3 Where the table 'restaurants' is defined as follows: CREATE TABLE restaurants (plaats, naam, adres, postcode, toelichting, telefoonnummer) Executing the following query on the 'top3' view... SELECT * FROM top3 ...gives the following resultset: 2 1 3 While executing... SELECT DISTINCT COUNT(*) FROM restaurants GROUP BY plaats ORDER BY COUNT(*) DESC LIMIT 3 ...gives this resultset: 15 13 7 In other words: when creating a view based on SELECT ... ORDER BY query, the ordering gets lost, which (when using a LIMIT) results in a wrong VIEW. It is interesting to know that this only happens when creating a view. When creating a similar table, using this query... CREATE TABLE top3 AS SELECT DISTINCT COUNT(*) FROM restaurants GROUP BY plaats ORDER BY COUNT(*) DESC LIMIT 3 ...the ordering is taken into account. If you need any more information (I will try to include the database, which actually contains the addresses of McDonald's restaurants in the Netherlands), please let me know. Regards, Michiel de Wit #cfe8bd 187 code fixed 2002 Nov anonymous Parser 2002 Dec 2 2 Having count(*) issue /* FAILING QUERY */ SELECT PARTOFFT FROM ROLE GROUP BY PARTOFFT HAVING COUNT(*)=2; /* ACCEPTED QUERY */ SELECT PARTOFFT, COUNT(*) FROM ROLE GROUP BY PARTOFFT HAVING COUNT(*)=2; /* USELESS IN SUBQUERIES LIKE */ SELECT PARTOFFT, ROLE FROM ROLES WHERE PARTOFFT IN ( SELECT PARTOFFT FROM ROLE GROUP BY PARTOFFT HAVING COUNT(*)=2); #c8c8c8 167 new closed 2002 Oct anonymous Shell 2002 Dec 5 4 Difficult to quickly quit sqlite It would be nice if ctrl-C worked to quit from sqlite. It doesn't work on Debian GNU/Linux. Ctrl-D works. Ctrl-D does not print a newline, so the shell prompt appears after the sqlite prompt (doesn't look "clean"). Though I appreciate the tip :) #cfe8bd 155 code fixed 2002 Sep anonymous Unknown 2002 Dec 2 2 sqliteSortCompare var dir uninitialized The variable dir is not initialized. There is a code path in this function that results in the use of this uninitialized variable. This results in a runtime exception under Visual Studio .NET. For the record, this is not a bug in SQLite but rather a bug in .NET. Nevertheless, I have added code to work around the problem. ---- (2002-Dec-21) I stand corrected. This was actually an SQLite bug. See ticket #205. #f2dcdc 129 event active 2002 Jul anonymous Unknown 2002 Jul 4 4 tcl-2.2 test fails 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. #f2dcdc 126 event active 2002 Jul anonymous VDBE 2002 Jul 4 5 malloc-1.195 test aborts from assert in vdbe.c 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 select * from course; id|category|shortname|longname|grp|units 1|CHEM|001A|GENERAL CHEMISTRY|A|5 2|CHEM|001A|GENERAL CHEMISTRY|B|5 sqlite> insert into course values (NULL, "category", "test", "test2", "A", 6); sqlite> select * from course; id|category|shortname|longname|grp|units 1|CHEM|001A|GENERAL CHEMISTRY|A|5 2|CHEM|001A|GENERAL CHEMISTRY|B|5 3|category|test|test2|A|6 sqlite> select id from course where category="category"; id 1 2 3 The last SQL statement should - in theory - return one record... This is running on windows and I have duplicated it on linux... Double-quoted strings are interpreted as column names if possible. So your WHERE clause is the same as category=category which is always true. Use a single-quoted string to mean a string literal. Like this ... WHERE category='category' #c8c8c8 123 new closed 2002 Jul anonymous 2002 Jul 3 3 Would like Query type info If I understand ticket #68 correctly, I would like to second it. That is, it would be VERY useful to be able to get the type info for a query that has been submitted (perhaps the same kind of info you return for table_info). This would permit proper formating of numbers (with commas, ...) etc. MySQL supplys a programming API that returns this info in a nice format. Duplicate of ticket #68 #c8c8c8 122 new closed 2002 Jul anonymous 2002 Jul 3 3 BLOB support needs only an escape_string() function. It would be nice to be able to handle binary data in SQLite. Ticket 67 proposes a solution, but none of that is necessary. You just need an escape_string() function (this is MySQL's name) that takes arbritary data input, a length of the data, and outputs a string that can be feed to SQLite. It seems to me that you need only add a zero value to your current escape codes to make it work. I.e. if you define that a zero is '0 where 0 is a binary zero, then you have everything you need. Function already exists: sqlite_encode_binary() #c8c8c8 121 code closed 2002 Jul anonymous 2002 Jul 1 1 Bug LEFT JOIN - GROUP BY Create a database as follows: BEGIN TRANSACTION; create table a(id); INSERT INTO a VALUES(1); INSERT INTO a VALUES(2); INSERT INTO a VALUES(3); create table b(id); INSERT INTO b VALUES(2); INSERT INTO b VALUES(3); INSERT INTO b VALUES(3); INSERT INTO b VALUES(4); INSERT INTO b VALUES(5); INSERT INTO b VALUES(5); INSERT INTO b VALUES(5); INSERT INTO b VALUES(5); INSERT INTO b VALUES(5); INSERT INTO b VALUES(6); INSERT INTO b VALUES(7); create index ax on a(id); create index bx on b(id); COMMIT; And for the following query: select A.id from a LEFT JOIN b on a.id = b.id where A.ID = 3 group by a.id; I get 2 rows. I found (in a big database) a case like select ... , count(x.id) from .... left join X on .... group by ... the count is very big, but it must be 0 SQLite ignores the GROUP BY clause if there are no aggregate functions in the result set. This is by design. #c8c8c8 120 code closed 2002 Jul anonymous 2002 Jul 1 1 Strange comparison logic I know that strings that are numbers are treated differently. But: select 'a' < 'b'; returns 1, witch is OK select 'a' < '1'; returns 0, witch is OK select ' ' < '1'; returns 0, witch is BAD select '1' < '2'; returns 1 witch is OK select '12' < '2'; returns 0 witch is OK if you consider numbers, BAD, if you consider strings select '2x' < '4x'; returns 1 which is OK but: select '2x' < '4'; returns 0 which is BAD. Why if one of the operands is a number, than it is done a number comparison? I think that the correct way is to do a number comparison if BOTH operands are numbers. The comparison rules are as follows: *: If it looks like a number, treat it as a number. *: Anything that is not a number and is not NULL is a string. *: NULL comes before everything. *: Strings come after numbers and are ordered according to memcmp(). *: Numbers come before strings and after NULL and are ordered by value. The comparisons in the description are consistent with these rules. Nothing needs to be changed. #c8c8c8 118 code closed 2002 Jul anonymous 2002 Jul 1 1 Under WinNT4.04 Call Opendatabase or Else Function Generate Error Os is Win Nt4.04. 1. When Call Sqlite_Open Function Display Error Msg "No Such Table: Sqlite_Temp_Master". 2. When Call Sqlite_Exec Function Ok, But Call Sqlite_Get_Table Function Generate Fatal Error: 'ntdll.dll entry error' Unable to reproduce either problem. The test suite for SQLite calls both of these functions many times without error. I've just rerun the test suite under WinNT4 service pack 4, and everything works fine. #c8c8c8 117 code closed 2002 Jul anonymous 2002 Jul 1 1 run err with Hint Call msvcrt.dll. under win98 use sqlite.dll display err, as Call msvcrt.dll Error Duplicate of #116. #c8c8c8 116 code closed 2002 Jul anonymous 2002 Jul 1 1 run err with Hint Call msvcrt.dll. under win98 use sqlite.dll display err, as Call msvcrt.dll Error Description is undecypherable. #c8c8c8 109 new closed 2002 Jul anonymous 2002 Jul 5 4 Can the build process include a way to make a static library? I am building an ocaml interface to sqlite (and it works GREAT!). I would like to have a static libsqlite.a built for me. I have worked around the problem now by adding : libsqlite.a: $(LIBOBJ) $(LIBTOOL) $(TCC) -o libsqlite.a -static $(LIBOBJ) libtclsqlite.a: tclsqlite.lo libsqlite.la $(LIBTOOL) $(TCC) -o libtclsqlite.a tclsqlite.lo \ libsqlite.la $(LIBTCL) -static to Makefile.in... I also changed all: to include these two targets. BTW, I have had a great time and success using sqlite... Thank you for working so diligently on this!!! bob Switched to using Makefile.template... That seems to be the standard way of doing things. It worked just fine. Thanx #c8c8c8 106 code closed 2002 Jul anonymous 2002 Jul 1 1 Bad handling of nulls x = null returns null. Equality/inequality must return a boolean value: 0 or 1 For example: select 1 when null returns 1 and it must not return anything select 1 when null = 1 returns 1 and it must not return anything The current behavior of SQLite is correct select 1 when null; This is a syntax error. It does not return 1. select 1 where null; This returns 1 because it ignores the WHERE clause. A WHERE clause is only processed if you have a table to read. select 1 from t1 where null; This returns nothing, as it should. #c8c8c8 103 code closed 2002 Jul anonymous 2002 Jul 2 1 Memory Leak in the Server In a client/server environment using rudp as a protocol (Reliable UDP), a memory leak occured in the server side when inserting in the database. The language used is tcl. The originator of this ticket is unable to supply a script to reproduce this bug. We'll have to assume the problem is not in SQLite. #c8c8c8 101 new closed 2002 Jul anonymous 2002 Jul 3 3 builtin functions do not work properly with LIMIT clause The limit clause seem to be ignored when used with built in functions. For example taking the average of a column with the LIMIT clause result in the entire column being averaged instead of just the limited results. Works as designed. The current behavior is the same as with PostgreSQL. It is different from MySQL, but MySQL is not noted for its standards compliance so it is probably better to emulate PostgreSQL rather than MySQL when the two disagree. Furthermore, the MySQL behavior can be simulated using a subquery such as the following: (Later:) The real problem here is described in ticket #102. SELECT avg(x) FROM (SELECT x FROM tbl LIMIT 5); #f2dcdc 98 todo active 2002 Jul drh 2002 Jul drh 1 1 Document and test TEMPORARY views Add documentation and tests for TEMPORARY views. #f2dcdc 96 todo active 2002 Jul drh 2002 Jul drh 1 1 Handle problems resulting from fork() 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:_ {linebreak} Using pthread_atfork(3C) sqlite3 could re-open open files on fork(2). #e8e8bd 13 new review 2002 Apr anonymous 2002 Jul 3 4 DSO DLL , solaris and FREEBSD I would like to add DSO, SOLARIS, and FREEBSD support I am working on FREEBSD and SOLARIS and would like to make sure it compiles and runs on these platforms I managed to get it up and running but it is missing an easy port: 1) in DSO and DLL you must export the sqliteFree() function so it wont interfere with the caller's memory management 2) Add the capability to build as an .so or DLL using a configuration script, also generating the proper import lib. I am doing this now manually between versions, and it is a pain, since I have 4 versions, 1 for each platform (linux, freebsd, win32 and solaris) 3) add a custom CC compiler to the script (in freebsd we use a different one). #e8e8bd 12 new review 2002 Apr anonymous 2002 Jul 2 4 adding win32 multi process support using a Mutex it is possible to create a muti-process global mutex using a named CreateMutex API call. I am implementing it in my code so if you want an example, I send you it. #cacae5 86 new defer 2002 Jun anonymous 2002 Jun 5 2 Add SAFEARRAY support for WIN32 clients of SQLite.DLL. I have developed a new function called 'sqlite_get_table_com' The source for this is located here http://www.ag-software.com/sqlite/sqlite_com.c and http://www.ag-software.com/sqlite/sqlite_com.h This function should only be for win32 compiles. The problem is that the .NET framwork and VB6 do not support char arrays. The .NET framework does to a certain point but you need to know the bounds of the array before you can access the array. So to get arround this problem, I have developed a function that calls sqlite_get_table to get the information out of sqlite and then converts this information into a 2 dim SAFEARRAY of objects. Including this function in sqlite would mean that the .NET framework would be able to use SQLite natively. Using this function I have almost completed a fully functional .NET data provider. Using this data provider .NET programmers can bind SQLite databases to any and all controls in the .NET framework , just as if they were using MS SQL Server. This would open SQLite up to many many more people. Am am unable to get mingw to compile this code. #f2dcdc 82 new active 2002 Jun anonymous 2002 Jun 1 4 Add IsCacheable, IsNullable to sqlite_create_function 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; #cacae5 81 code defer 2002 Jun 2002 Jun 4 3 Single process on NFS Howdy, In the FAQ you mention: "The locking mechanism used to control simultaneous access might not work correctly if the database file is kept on an NFS filesystem. You should avoid putting SQLite database files on NFS if multiple processes might try to access the file at the same time." So I understand the NFS limitations. Unfortunately, even with a single process on NFS I cannot seem to create a database file. Using the sqlite command line tool, if I try to add a table I receive: "SQL error: database is locked". I'm running Mandrake Linux 8.1 with kernel 2.4.8-34. I don't actually plan to *run* against NFS as such, but my development space is NFS mounted and it's causing a little grief. Thought I'd report it just in case it is actually a bug. Thanks, Matt Sheats sheats@los-alamos.net This is a bug, but the bug is in NFS, not in SQLite. There are no plans to work around the NFS bug at this time. #c8c8c8 69 new closed 2002 Jun anonymous 2002 Jun 5 4 Sequences (some sort of auto-incremental fields...) A better way to have an unique value other than rowid would be having GENERATORS or SEQUENCES or something like that. As we have triggers, it would be easy to get the next sequence value inside the trigger and update the field. There's a workaround to accomplish (almost) the same result on the current version. It would be 1) create a new table, to record the sequences; 2) increment the sequence before the INSERT; 3) use an INSERT+SELECT statement do insert the row create table a(name text, id int); create table b(another_name text, another_id int); -- create and initiate the sequences table create table sequences(a_id int, b_id int); insert into sequences values(0,0); -- before any insert, increment the proper sequence update sequences set a_id=a_id+1; -- use a compound INSERT to get the value from the sequence insert into a(name,id) select "Mary Anne", a_id from sequences; -- a second insert requires a new update of the sequence update sequences set a_id=a_id+1; -- use a compound INSERT to get the value from the sequence insert into a(name,id) select "Joe Doe", a_id from sequences; It makes you work a little more, and also there's no garrantee that no other user updated the sequence value just before you insert the new row, thus both might get the same sequence value. So, it would be very nice to have some mechanism to generate and manage the sequences built in the triggers mechanism. What you think? See http://www.hwaci.com/sw/sqlite/faq.html#q1 #c8c8c8 61 new closed 2002 Jun anonymous 2002 Jun 1 1 Enhancement Request: Capability to Specify Table Join Type It doesn't appear possible to specify the table join type as part of a SQL operation. In particular, LEFT OUTER JOIN's are extremely common in most business applications that use a relational database. If implementing this feature, it would be preferable if done via ANSI JOIN syntax, rather than the old-school +/- on each side of the WHERE clause column joins. See ticket #58 #c8c8c8 60 new closed 2002 Jun anonymous 2002 Jun 3 4 UPDATE Statement with FROM Clause FAILS The SQL syntax: UPDATE Table1 SET Column = Value FROM Table1, Table2 WHERE Table1.Column1 = Table2.Column AND (condition) fails due to the FROM clause. This is not valid SQL syntax according to the SQL92 spec. You can do the same thing in SQLite as follows: UPDATE Table1 SET Column = Value WHERE rowid IN (SELECT Table1.rowid FROM Table1, Table2 WHERE Table1.Column1 = Table2.Column AND (condition)); See also ticket #63. #c8c8c8 58 new closed 2002 Jun anonymous 2002 Jun 4 4 Table JOIN Syntax Not Recognized JOIN syntax such as: SELECT Table1.Column, Table2.Column FROM Table1 INNER JOIN Table2 ON Table1.Column = Table2.Column AND (condition) WHERE (condition) is not recognized and produces are parsing error. Already implemented. See check-in [587]. #c8c8c8 57 code closed 2002 Jun anonymous 2002 Jun 4 4 UPDATE Command Fails When Table Name is Part of SET Statement For the SQL statement: UPDATE Table SET Table.Column = Value WHERE (condition) fails unless the table name is ommited in SET operator. The SQL statement must be written such as: UPDATE Table SET Column = Value WHERE (condition) This is not valid SQL syntax according to the SQL92 spec. #cacae5 56 event defer 2002 Jun anonymous 2002 Jun 1 1 'Permission Denied' while trying to use SQLITE in a Familiar iPAQ I am new on Linux and I desperately need a SQL engine to work with some databases on my iPAQ. So, I installed SQLITE and it always goes wrong when I try to use it. I type: #sqlite or #sqlite test and... Permission Denied Maybe it is something about permissions under Linux. But the only user my iPAQ has is root, I installed it under root and always try to use it as root. Please help me! Thanks a lot, Joao #c8c8c8 51 doc closed 2002 May danielk1977 CodeGen 2002 May danielk1977 5 3 Triggers problem with INTEGER PRIMARY KEY When a trigger program *updates* the INTEGER PRIMARY KEY field of a row which is to be subsequently deleted or updated by the statement causing the trigger to fire, the code assumes that the row has been *deleted* by the trigger program and so doesn't execute the update or delete for that row. Example follows: CREATE TABLE aa(a INTEGER PRIMARY KEY, b); INSERT INTO aa VALUES(1, 2); CREATE TRIGGER at BEFORE DELETE ON aa BEGIN UPDATE aa SET a = a + 1; END; DELETE FROM aa; SELECT * FROM aa; This will just be documented as a problem for now, not fixed. This is given a low priority as it should be easy for users to avoid configuring triggers that modify INTEGER PRIMARY KEY values. #f2dcdc 43 event active 2002 May anonymous 2002 May drh 1 1 sqlite compile without readline on linux slackware 8.0 ./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. #cacae5 38 code defer 2002 May danielk1977 CodeGen 2002 May 3 5 Count-changes broken for: DELETE FROM (no WHERE clause) When executing: DELETE FROM ; The "count-changes" functionality doesn't work. A workaround is to use: DELETE FROM WHERE 1; This situation, and the reason for it, is already described in the documentaion of the sqlite_change() API function. #c8c8c8 36 code closed 2002 May anonymous 2002 May 4 3 drop table doesn't clean up database If I drop a table , the table will be removed from schema, but the records remain in the database. VACUUM doesn't help. The effect: The size of database is the same as before. The pages of data that used to hold the deleted data have been added to a list of free pages and will be reused the next time there is an INSERT or CREATE TABLE. SQLite does not leak disk space. This can be verified using the integrity_check pragma. If you need to minimize the size of an SQLite database, do this: sqlite old.db .dump | sqlite new.db mv new.db old.db #c8c8c8 21 code closed 2002 Apr anonymous Shell 2002 May 1 1 2.4.8 SQLITE.EXE: out of memory! (Windows98) Installed 2.4.8 pre-compiled downloads (sqlite.zip, sqlitedll.zip). At command prompt (Windows98) ran the sqlite command. Got error message: SQLITE.EXE: out of memory! Same files for 2.4.7 worked fine. I am attempting to recompile the sqlite_source.zip sources using MingW verions 1.0.6. Unable to reproduce. But I think the problem was that the sqlite.exe was unable to find the users home directory. This is now fixed. We can reopen the bug if original problem turns out to be something different. #c8c8c8 19 new closed 2002 Apr danielk1977 BTree 2002 May 3 4 synchronous pragma does not effect TEMP tables The default_synchronous or synchronous pragmas don't seem to effect the behaviour of tables created in the temporary database file (ie. with CREATE TEMP TABLE ...). Note that I'm only basing this on empirical testing. Would it be safe to always open the temporary data file as if default_synchronous was set to OFF, regardless of pragma settings? Yes, it is safe to treat TEMP tables as synchronous=OFF. And there was an attempt in the code already to do just that. But I missed a couple of cases. It should be working now. #c8c8c8 16 code closed 2002 Apr anonymous CodeGen 2002 May 2 2 sqlite cores I have a TABLE created with. create table sequence (id INTEGER, v); If I give sqlite this (bad) SQL statement it generates a core file. echo "INSERT INTO sequence (v) VALUES (p());" | sqlite dpc.db sqlite: ./src/expr.c:843: sqliteExprCode: Assertion `pDef!=0' failed. Aborted (core dumped) Yes its bad SQL but IMHO it should come back with a "syntax error". #c8c8c8 15 code closed 2002 Apr anonymous CodeGen 2002 May 5 4 getting the number of affected lines is harder than necessary while wrapping sqlite into a plugin for the qt framework (www.troll.no), I found that there is no simple way to get the number of modified rows after a call to get_table(), but the framework requires it. The currently available solution, using the pragma, doesn t quite work when using get_table() because no callback is called, and get_table() does make many other aspects of the project easier. So, it is currently a choice between making my code more complex using exec() or not report the affected rows accurately. Proposed solution: implement a funtion int sqlite_affected(sqlite *) that returns the number of rows affected by the last call to exec() Add a new API function: int sqlite_changes(sqlite*); This function returns the number of rows that were changed by the most recent call to sqlite_exec() or sqlite_get_table(). #c8c8c8 11 code closed 2002 Apr drh CodeGen 2002 May 1 1 Wrong number of inserts reported after an IGNORE When the COUNT_CHANGES pragma is one and one does an INSERT OR IGNORE, the rows that are ignored get counted. #c8c8c8 10 code closed 2002 Apr drh VDBE 2002 May 1 1 Stack grows without bound on UPDATE OR IGNORE Everytime the IGNORE action is taken on an UPDATE OR IGNORE statement, the depth of the VDBE stack grows by one. #c8c8c8 8 code closed 2002 Apr danielk1977 CodeGen 2002 May 2 1 More problems with where.c There's still a small problem in where.c. Some parts of the code assume that only binary operators may be part of WHERE clauses, and thus expressions may be evaluated outside of table-scan loops that they depend on. Examples: CREATE TABLE aa(a); CREATE TABLE bb(b); SELECT * from aa, bb WHERE b; SELECT * from aa, bb WHERE max(a, b); SELECT * from aa, bb WHERE CASE WHEN a = b THEN 1 END; #c8c8c8 7 code closed 2002 Apr danielk1977 VDBE 2002 May 5 2 VDBE trace prints out garbage for P3 of Function opcodes When the vdbe_trace pragma is active, and the VDBE executes a Function opcode, garbage is printed out for P3. eg: 5 Function 0 0 `@ The EXPLAIN command deals with this nicely. #c8c8c8 6 code closed 2002 Apr danielk1977 CodeGen 2002 May 1 1 Query optimizer does not consider function arguments The query optimizer in "where.c" is slightly broken. The code that determines the list of tables which an expression (Expr) depends on only considers the pLeft and pRight expressions, where it should consider pLeft, pRight and pList. It occurs all throughout the file. For example, exprTableUsage() should add the following: if (p->pList) for (int ii = 0; ii < p->pList->nExpr; ii++) mask |= exprTableUsage(base, p->pList->a[ii].pExpr); To produce an illustration of the problem: CREATE TABLE aa (a); CREATE TABLE bb (b); EXPLAIN SELECT * FROM aa, bb WHERE max(a, b); 0 ColumnCount 2 0 1 ColumnName 0 0 aa.a 2 ColumnName 1 0 bb.b 3 Open 0 3 aa 4 Ver #c8c8c8 5 code closed 2002 Mar anonymous 2002 May 3 4 Bug submitter ignores severity/priority Ticket 3 was submitted with a severity of 2 and a priority of 3, neither of which seemed to stick. Please investigate. (Note, this ticket was submitted with a severity of 3 and a priority of 4, for reference.) This is (or was) a bug in CVSTrac, not SQLite. The problem has already been fixed. Thanks for noticing it, though. #c8c8c8 4 new closed 2002 Mar persicom Shell 2002 May 2 3 Change prompt of 'sqlite' query tool. I'm using SQLite as the storage for configuration data. I would like to have the facility to change the prompts 'sqlite> ' and ' ...> ' to something that more accurately reflects the system it's part of. You could do this as part of the "config" process like you handle UTF-8 or ISO-8859. Fixed in shell.c 1.53 by persicom #c8c8c8 3 code closed 2002 Mar anonymous Parser 2002 May 1 1 Rejects "view" as column name Neither CREATE TABLE nor SELECT parse "view" as a column name properly; it is rejected as a syntax error before processing. Test SQL: "SELECT col1,view,col3 FROM dummytable" errmsg contains 'near "view": syntax error' and returns 1. #c8c8c8 2 new closed 2002 Mar drh CodeGen 2002 May 2 3 Add support for TABLE.* in a query SQLite supports "SELECT * FROM TABLE" but it does not support "SELECT TABLE.* FROM TABLE". The latter needs to be added. #cfe8bd 195 code fixed 2002 Nov anonymous 2002 Nov 2 4 Borland Compiler error for long long definition in os.h This problem is in os.h version 1.17 The borland compiler needs to use the first definition of a 64 bit integer so if you change the following code: # ifdef _MSC_VER typedef __int64 off_t; # else typedef long long off_t; # endif to this: #if defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 off_t; # else typedef long long off_t; # endif It fixes the problem. #f2dcdc 192 doc active 2002 Nov anonymous Unknown 2002 Nov anonymous 4 4 Finishing build on MacOS 10.x (and other *nix's, likely) 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." #cfe8bd 190 code fixed 2002 Nov anonymous 2002 Nov 1 3 the btree code crashes on LP64 systems The uptr type is defined as an int, which breaks on systems where this is less than a pointer (specifically I get a core dump on alpha). I know this type can be redefined, but it's usually unnecessary to use an integer type at all. As far as I can tell this type is only used in the btree code and when hashing on pointers. In the first case a char* would do just fine, and should work on most systems (but probably not vector crays, but neither should the current code). For the hash code there is no help, but then it doesn't really use the casted value. #cfe8bd 189 code fixed 2002 Nov anonymous 2002 Nov 4 4 sqlite html output format produces extra $ sqlite -html foo 'select * from test;' some data The last should not be there. #c8c8c8 188 todo closed 2002 Nov drh 2002 Nov 1 1 Serialize disk I/O Modify the pager so that when it flushes its buffers to the disk it attempts to do so in sequential order. When two or more adjacent pages are written, write them with a single write() call instead of two writes() with an intervening lseek(). Check to see if this improves performance. you are probably not going to get much improvement. I think what you are trying to do is called "elevator seeks" which is handled by the OS anyway. ---- You're right. I didn't get any noticable improvement. #f2dcdc 186 new active 2002 Nov anonymous Shell 2002 Nov 5 4 ./configure --enable-threads-safe ? 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. #c8c8c8 183 code closed 2002 Oct anonymous 2002 Nov drh 1 1 Bug regarding grouping, left joining, aggregate functions There is a bug regarding grouping, left joining, aggregate functions. I sent a mail containing a database dump to drh@hwaci.com. Bug does not reproduce in version 2.7.3 #cfe8bd 185 code fixed 2002 Oct anonymous Unknown 2002 Oct 1 1 Crash when running specific SQL As per https://sourceforge.net/tracker/?func=detail&atid=402788&aid=630828&group_id=31577 my user has sent me the related database as a ZIP file. I can forward that to you, just tell me how. I don't get the same error on 2.7.1 on Linux. ----- The following script demonstrates the problem: create table t1(a,b); insert into t1 values(1,2); select * from t1 where a in (); select * from t1 where a in (1,2) and b in (); Segfaults occur if the "IN" operator is used with empty sets. #c8c8c8 182 event closed 2002 Oct anonymous Unknown 2002 Oct 1 1 Win32 DBI Interface crashes Perl.exe When I try to use the Perl DBI-Interface to SQlite (DBI:SQLite) Perl.exe is crashing. IF I use sqlite.dll from sqlite.org, a Perl error (boot___SQlite ..not found) is coming up. Does anybody ever used this Module? This appears to be a bug report against the SQLite DBI interface. But that interface is a separate project that is not directly affiliated with this site. So I'm closing this bug. #c8c8c8 181 code closed 2002 Oct anonymous Unknown 2002 Oct anonymous 5 5 MAX Function on NULL Values MAX produces undefined output, if column has NULL values: sqlite> SELECT partno,MAX(price),MIN(price),AVG(price) FROM quotations GROUP BY partno; quotations MAX(price) MIN(price) AVG(price) ---------- ---------- ---------- ---------- ..... P207 pÄ♦ NULL 1735 This was fixed 5 months ago in version 2.5.0. #cfe8bd 179 code fixed 2002 Oct drh 2002 Oct anonymous 1 1 Column names and string constants in parentheses cause errors. Given a type like this: CREATE TABLE t(x); The following statements fail: SELECT * FROM t WHERE (x)==('hi'); If the parentheses are removed, it works. #cfe8bd 178 code fixed 2002 Oct anonymous Unknown 2002 Oct 2 3 Undefinied pointer with sqlite_get_table (empty result set) if i run the following program, the pointer 'result[0]' is not defined. But it will be freed in sqlite_free_table(). The problem is, that sqlite_get_table() set nData=1, but there are no datas. I am not able to reproduce this problem. The code in the attachment runs fine on my machine (RedHat 8.0) and it never tries to free unallocated memory. result[0] is undefined, but that is because there are no rows and no columns in the result set. But sqlite_free_table() never tries to free result[0], so that is not a problem, as far as I can tell. #cfe8bd 176 code fixed 2002 Oct mike 2002 Oct drh 1 3 locking mechanism fails under Windows There is a subtle defect in the locking mechanism used for Windows. The os.c code for windows uses LockFile() for locking, and an area of MX_LOCK_BYTES(10240) from the beginning of the file, essentially using the file itself for implementing multi-read-exclusive-write semaphores. this is a standard technique, but in all Microsoft operating systems (including DOS, and all versions of Windows), there is a caveat: When a lock is obtained in an area of a file, it exludes everybody else from reading that area. "everybody else" includes any other threads of the process that created the lock (!) Which means that, if the "real" data portion of the file is being used in this way (as semaphores), it may conflict with a legitimate attempt to read the data. This actually happened quite often in a stress test with multiple threads that I wrote. The result is that the engine gives an I/O error. This is a design bug, not a code bug. possible work-arounds are : 1. use a separate file for the locks, not the data file. 2. NEVER use the semaphore area for actual data (ie create a reserved area of MX_LOCK_BYTES in the beginning of the file). not a very good idea, but easy to implement, and would work. 3. Use the lock-beyond-eof technique. In Windows and DOS, the LockFile function will work for offsets than are beyond the physical end-of-file. this is documented. it potentially has the same problem , of course. if you lock beyond EOF, and the file has to extend , and it covers the locked area, then the *write* will fail (as opposed to the *read* failing with the current design). One way to solve this is to lock as far as possible from the eof. My technique involves locking at the 4GB limit (0xFFFFFFFF), minus the size of the semaphore area. This will of course limit the maximum size of the database, by this amount. in fact, in Windows NT/2000/XP, the Lockfile functions take 64-bit arguments, so, you could use the terrabyte area for this lock, and nobody is going to reach that limit, anyway. so, my suggested fix is, in pseudo-code : a. add some code to detect that you are in Win9x or NT/2000/xp b. if in 9X, bias all your lock calls by 0xFFFFFFFFF-MX_LOCK_BYTES c. if in winnt, bias by 0xFFFF FFFFF FFFFF FFFF - MX_LOCK_BYTES I have already tried (c), and it does solve the problem. PS. on the same subject: byte (0) (biased or not) of the file is used as a "sync" mutex, to ensure that no two processes are modifying the lock area at the same time. with the current design, if a conflict occurs in this lock, the locking mechanism aborts with SQLITE_BUSY. My suggestion is to make this is blocking call, and loop until a lock can be obtained. since this is a temporary lock that will always be released immediately, and since this would be the first action of the locking code, the possibility of a deadlock does not exist. this will improve the retry behavior of the engine (or the user code in case the user is handling the retries), since the sync lock by itself will not return with SQLITE_BUSY errors. SQLITE_BUSY itself should IMHO only have the semantics of "database is locked for updating", and it should not reflect the internal locking and sync mechanism, as it does now.. finally, last hint: make MX_LOCK_BYTES such that biasing is easy (65536 is a better choice, since the arithmetic is "lighter", just drop the least significant word) The recommended solution (3) also solved my lock problems on Win32, but I wasn't using threads at all. I had two separate processes, one inserting, and the other selecting. I would consistently see io errors from the writing process. I have no idea how the solution of locking a range beyond the file's size fixes this, but it seems to. All I did was change all the high-offset arguments (argument 3) to *LockFile* and *UnlockFile* from 0 to 1 -- I am running on Win2k so going beyond 2**32 is OK. Perhaps something in the insert code was trying to read the database in an area locked by the select before grabbing the write lock? -- e #f2dcdc 175 new active 2002 Oct anonymous Pager 2002 Oct 5 3 journal file should be kept open 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... #cfe8bd 174 code fixed 2002 Oct anonymous Unknown 2002 Oct drh 1 3 inconsistent data types According to the doc, a table created as CREATE TABLE XXX(a,b,c) (no data types) should create columns of NUMERIC type. when using the PRAGMA SHOW_DATATYPES, the columns are reported as NUMERIC (which is ok). however, the PRAGMA table_info shows them as TEXT, which is inconsistent with the documentation. #cfe8bd 173 todo fixed 2002 Oct anonymous 2002 Oct drh 4 3 publish.sh does not build dll correctly The publish.sh script does not contain an export definition for sqlite_function_type, which results in the function not being exported from the DLL. #bde5d6 172 code tested 2002 Oct anonymous 2002 Oct drh 3 3 incompatibility with Borland compiler in select.c, lines 735,1294 and 1347, the prototype declarations for forward routines include the keyword "static", which is neither required, nor accepted by the Borland compiler. Fix: remove the "static" keyword. even better, move the prototype declarations near the top of the file (cant help it, I am pascal-oriented :) #cfe8bd 171 code fixed 2002 Oct anonymous 2002 Oct drh 1 3 incompatibility with Borland run-time library The borland run-time *malloc* behaves differently than the Ms equivalent, and presumably than the Linux equivalent. When 0 is passed as an argument, the Borland malloc returns a nil pointer, but the Ms version returns a valid, 0-length pointer. The code in util.c contains two version of sqliteMalloc. the one used with MEMORY_DEBUG correctly works around this issue by testing for 0 and returning nil. however, the non-debug version lacks this test. It seems that some defect in the logic in some other place *will* attempt to Malloc 0 bytes (which IMHO it should not), and, as a result, the malloc (and all subsequent mallocs) fail. solution: modify Sqlitemalloc thus: void *sqliteMalloc(int n){ void *p; if( n==0 ) return 0; <-- add this line p = malloc(n); if( p==0 ){ sqlite_malloc_failed++; return 0; } memset(p, 0, n); return p; } #c8c8c8 170 code closed 2002 Oct anonymous TclLib 2002 Oct anonymous 2 2 Insert / select text with cp1250 characters I have problem saving data in proper encoding using tclsql package. From the sqlite commad line inserts work perfectly, but if I try to insert the same in TCL script the row is inserted, unfortunately, some characters with diacritics are replaced by question marks '?'. Text is in Central European(Windows-1250). The same problem is also with UTF-8 encoding. This happens on MS Windows platform. I want to withdraw this ticket. The real problem is with inserting/selecting binary data (without nuls). Wojtek #cfe8bd 166 code fixed 2002 Oct anonymous Unknown 2002 Oct 1 1 Left outer join doesn't seem to be working The left outer join appears to be giving identical results as an inner join. I'm not getting all rows from the left table. I'm not positive that this is inherent to 2.7.2, as I've found the bug by using the shell program on a database created by zeecookbook. Zeecookbook wasn't giving me the correct values, so I downloaded the shell program for windows and ran queries of my own to see where the problem was. Example: recipe_ingredient table that has a unit_id column, unit table with an id column that is used in the recipe_ingredient table unit_id column If I have 5 rows in recipe_ingredient, and 2 of the rows have either a null value and/or a value that is not in the unit table, they don't appear in the results of a recipe_ingredient left outer join unit on unit_id = unit.id I just tried the same query in mysql to verify my results, using the exact same tables and data and the results are correct in mysql, but not in sqlite. Here is a dump of the two tables I'm joining, as well as a sql statement to show how to reproduce: CREATE TABLE recipe_ingredient (id INTEGER PRIMARY KEY, recipe_id, position, quantity, unit_id, ingredient_id, is_group); INSERT INTO recipe_ingredient VALUES(1,1,1,2,1,1,0); INSERT INTO recipe_ingredient VALUES(2,1,2,1,2,2,1); INSERT INTO recipe_ingredient VALUES(3,1,5,6,3,3,0); INSERT INTO recipe_ingredient VALUES(4,1,3,'6-7',-1,4,0); INSERT INTO recipe_ingredient VALUES(5,1,4,'6-7',-1,4,0); INSERT INTO recipe_ingredient VALUES(6,1,6,'6-7',3,4,0); CREATE TABLE unit (id INTEGER PRIMARY KEY, name); INSERT INTO unit VALUES(1,'Pkg'); INSERT INTO unit VALUES(2,'cup'); INSERT INTO unit VALUES(3,'Pcs'); SELECT recipe_ingredient.id, recipe_ingredient.position, unit.name FROM recipe_ingredient LEFT JOIN unit ON recipe_ingredient.unit_id = unit.id; The output of this query is: 1|1|Pkg 2|2|cup 3|5|Pcs || and should have been: 1|1|Pkg 2|2|cup 3|5|Pcs 4|3| 5|4| 6|6| Hope this helps ---- _2005-Nov-20 06:29:07 by anonymous:_ {linebreak} I just tried the example today in sqlite3 3.1.3 and got the wrong result: 1|1|Pkg{linebreak} 2|2|cup{linebreak} 3|5|Pcs{linebreak} 4|3|{linebreak} 5|4|{linebreak} 6|6|Pcs That Pcs should not be there in the last line: very scary! ---- _2005-Nov-20 06:30:23 by anonymous:_ {linebreak} No, I take it back: doing it by hand the Pcs looks correct. Why is the original wrong? #c8c8c8 165 code closed 2002 Oct anonymous VDBE 2002 Oct anonymous 1 1 can create and change tickets, without logged in I can also edit open tickets without logged in. The top line shows 'Not logged in' I use IE 5.0 on NT with SP6 This is a feature, not a bug. #f2dcdc 164 event active 2002 Oct anonymous CodeGen 2002 Oct anonymous 3 4 Compiler warnings with MS Visual C++ 6.0 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) #cfe8bd 163 code fixed 2002 Oct anonymous Unknown 2002 Oct 2 2 Buggy initialization of random generator on win32 The function sqliteOsRandomSeed will always set the same random seed due to a wrong usage of the GetSystemTime API function on win32. It will copy the first 4 bytes of the SYSTEMTIME structure as the random seed, but they represent the year which is the same for quite a long time. I would suggest to use a simple time(NULL) call instead (that works on Win32 and unix): #include ... int sqliteOsRandomSeed(char *zBuf){ int seed; static int once = 1; #ifdef SQLITE_TEST /* When testing, always use the same random number sequence. ** This makes the tests repeatable. */ seed = 1; #else seed = time(NULL); #endif if( once ){ srand(seed); once = 0; } return SQLITE_OK; } The call to srand() was not being used for anything and has been removed. The real work of sqliteOsRandomSeed() is to come up with a 256-byte seed for the RC4 pseudorandom number generator coded in random.c. The entire SYSTEMTIME structure is being used for this, not just the first four bytes. #c8c8c8 162 code closed 2002 Oct anonymous Unknown 2002 Oct anonymous 3 2 mismatch in response column and Group by column is ignored In the select statement if response column name is not there in the group by clause sqlite is not giving error. It prints some values for that response column. Ex:tbl1 has 2 columns (f1, f2) sqlite>select * from tbl1; f1 ------ f2 2 ------ 2 3 ------ 2 1 ------ 5 1 ------ 2 1 ------ 2 2 ------ 3 sqlite>select f2, sum(f2) from tbl1 group by f1; f2 ------ sum(f2) 5 ------ 9 2 ------ 2 2 ------ 5 In the above case f2 is not in the group by clause. Still it is printing some value of f2. In Oracle same query gives following error: SQL>select f2, sum(f2) from tbl1 group by f1 * ERROR at line 1: ORA-00979: not a GROUP BY expression SQLite does not require the columns used in the GROUP BY clause to be elements in the result set. This is a feature, not a bug. #c8c8c8 158 code closed 2002 Oct anonymous Unknown 2002 Oct 3 2 Union doesn't check for data types I have two tables.First table has both the columns of type int and the second table has both the columns of type varchar.When I do a union on these two tables,I get no error message. This is a feature, not a bug. See http://www.sqlite.org/datatypes.html #c8c8c8 157 code closed 2002 Oct anonymous Unknown 2002 Oct anonymous 3 2 Doesn't check for data types I have created a table with two columns of type int.I get no error message,when I insert values of type string into this table. This is a feature, not a bug. see http://www.sqlite.org/datatypes.html #c8c8c8 156 code closed 2002 Oct anonymous Unknown 2002 Oct 1 1 Cannot log in to CVSTraq because no "create account page" The one-line summary says it all. I cannot log in, and apparently, other users cannot, either, as there only seem to be "anonymous" reports. The CVSTrac bug tracking system is an independent project. This bug already exists on that project. See http://www.cvstrac.org/tktview?tn=18. #cfe8bd 152 code fixed 2002 Sep anonymous Unknown 2002 Sep 1 1 "make test" has errors I got the following errors from "make test": temptable-6.3... Expected: [1 {attempt to write a readonly database}] Got: [0 {}] temptable-6.4... Expected: [0 {}] Got: [1 {table t9 already exists}] temptable-6.6... Expected: [1 {attempt to write a readonly database}] Got: [0 {xyzzy hello}] temptable-6.7... Expected: [0 {xyzzy 1 2}] Got: [0 {xyzzy 1 2 hello 1 2}] temptable-6.8... Expected: [1 {no such table: t9}] Got: [0 {xyzzy 1 2 hello 1 2}] version-2.1... Expected: [1 {unable to upgrade database to the version 2.6 format: attempt to write a readonly database}] Got: [0 0x8083200] 6 errors out of 7193 tests Failures on these tests: temptable-6.3 temptable-6.4 temptable-6.6 temptable-6.7 temptable-6.8 version-2.1 *: compiler: gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98) *: libc RPM: glibc-2.2.4-19.3 *: sqlite: sqlite-2.7.1 This happens when you try to run the tests as root. The test script is attempting to create a read-only database by setting the file permissions to 444. But that doesn't work for the superuser who can write a file regardless of the file permissions. Run the tests as a normal user and they will work. The tests were modified in check-in [740] to issue an appropriate error message if you try to run them as root. #cfe8bd 150 doc fixed 2002 Sep anonymous Unknown 2002 Sep anonymous 2 2 Missing documentation files Some of the doc files are missing. I know for sure that the quickstart.html is one. The file quickstart.html is generated by a TCL script named quickstart.tcl. quickstart.tcl is located in the source tarball (sqlite-2.7.1.tar.gz) and in the CVS repository. The derived quickstart.html file is available on the website. #c8c8c8 149 new closed 2002 Sep anonymous Unknown 2002 Sep 5 4 SELECT UNIQUE It would be nice if Sqlite understood a SELECT UNIQUE construct, so that one could do a "SELECT UNIQUE x FROM table". Currently I'm using "SELECT x FROM table UNION SELECT x FROM table" to get a list of unique x's, and I know of no better way of accomplishing this. Thanks! The correct syntax is SELECT DISTINCT. #c8c8c8 148 code closed 2002 Sep anonymous Unknown 2002 Sep anonymous 3 3 sqlHashFind() segfaults in a created function In main: Hash *re_cache; re_cache = sqliteMalloc(sizeof(Hash *)); sqliteHashInit(re_cache, SQLITE_HASH_BINARY, 0); sqlite_create_function(db, "matches", 2, matchFunc, re_cache); sqlite_function_type (db, "matches", SQLITE_NUMERIC); In matchFunc: static void matchFunc(sqlite_func *context, int argc, const char **argv) { Hash *re_cache; pcre *re; /* ... */ re_cache = (Hash *)sqlite_user_data(context); re = (pcre *)sqliteHashFind(re_cache, argv[0], 1 + strlen(argv[0])); /* ... */ } Induce a segmentation fault: zsh% make && ./sqlite TMP SQLite version 2.6.3 Enter ".help" for instructions sqlite> select matches('\d', '4445'); zsh: segmentation fault (core dumped) ./sqlite TMP Get dump: zsh% gdb ./.libs/lt-sqlite lt-sqlite.core Core was generated by `lt-sqlite'. Program terminated with signal 11, Segmentation fault. (gdb) bt 0 findElementGivenHash (pH=0x805d140, pKey=0x806a210, nKey=3, h=5144) at ./src/hash.c:213 1 0x2807f155 in sqliteHashFind (pH=0x805d140, pKey=0x806a210, nKey=3) at ./src/hash.c:270 2 0x280809ba in matchFunc (context=0xbfbfe6dc, argc=2, argv=0x805e280) at ./src/local_func.c:53 3 0x280919cf in sqliteVdbeExec (p=0x805c600, xCallback=0x8049254 , pArg=0xbfbfea3c, pzErrMsg=0xbfbfe960, pBusyArg=0x0, xBusy=0) at ./src/vdbe.c:1884 4 0x280764fc in sqliteExec (pParse=0xbfbfe94c) at ./src/build.c:73 5 0x28084fc5 in yy_reduce (yypParser=0x806b800, yyruleno=3) at parse.y:67 6 0x280865c3 in sqliteParser (yyp=0x806b800, yymajor=103, yyminor={ z = 0x80652dc ";", n = 1}, pParse=0xbfbfe94c) at parse.c:6633 7 0x2808cae6 in sqliteRunParser (pParse=0xbfbfe94c, zSql=0x80652c0 "select matches('\\d', '4445');", pzErrMsg=0xbfbfe9f8) at ./src/tokenize.c:456 8 0x28081971 in sqlite_exec (db=0x805c000, zSql=0x80652c0 "select matches('\\d', '4445');", xCallback=0x8049254 , pArg=0xbfbfea3c, pzErrMsg=0xbfbfe9f8) at ./src/main.c:626 9 0x804ad5b in process_input (p=0xbfbfea3c, in=0x0) at ./src/shell.c:953 10 0x804b499 in main (argc=2, argv=0xbfbff390) at ./src/shell.c:1185 11 0x8048de9 in _start () (gdb) print pH->ht $1 = (struct _ht *) 0x6374616d (gdb) print pH->ht[0] Cannot access memory at address 0x6374616d. Not very familiar with C programming ... help. Should be: re_cache = sqliteMalloc(sizeof(Hash)); ^^^^----- No "*". #cfe8bd 147 code fixed 2002 Sep anonymous 2002 Sep 1 1 "INSERT into xxx SELECT yyy ORDER BY zzz LIMIT 1" ignores the limit The following SQL code returns 3 rows of data where it should only return 1 row: create table t1(a,b,c); create table t2(x,y,z); insert into t1 values(1,2,3); insert into t1 values(2,3,4); insert into t1 values(3,4,5); insert into t2 select * from t1 order by b desc limit 1; select * from t2; #cfe8bd 146 code fixed 2002 Sep drh Pager 2002 Sep drh 1 1 Disk I/O error encountered on very large transactions In a very large transaction where: *: New records are inserted *: Those records are deleted creating free blocks at the end of the file. *: Lots of update occur to so that the free blocks at the end of the file are removed from the cache *: Additional inserts are attempted which attempt to use the free blocks at the end of the file Then the os.c layer will try to read a block that was never written. The read will be short (zero bytes) which will cause an SQLITE_IOERR. #c8c8c8 124 code closed 2002 Jul anonymous Unknown 2002 Sep anonymous 2 1 Segfault on a join using an INTEGER PRIMARY KEY. The following SQL causes a segfault: CREATE TABLE t5(a INTEGER PRIMARY KEY); CREATE TABLE t6(a INTEGER); INSERT INTO t6 VALUES(NULL); INSERT INTO t6 VALUES(NULL); INSERT INTO t6 SELECT * FROM t6; INSERT INTO t6 SELECT * FROM t6; INSERT INTO t6 SELECT * FROM t6; INSERT INTO t6 SELECT * FROM t6; INSERT INTO t6 SELECT * FROM t6; INSERT INTO t6 SELECT * FROM t6; SELECT * FROM t6 NATURAL JOIN t5; #c8c8c8 114 code closed 2002 Jul anonymous Unknown 2002 Sep 2 3 Concurrency problem in sqlite_open when automatic upgrading A code path exists which produces the error message unable to upgrade database to the version 2.6 format: table sqlite_master already exists during sqlite_open() when the database is currently locked by another process/thread but is already in proper 2.6 format. As far as I understand the sqlite_open() code there might be an error in handling the situation when sqliteInit() returns SQLITE_BUSY and later the sqlite.format field is checked for the version of the database file in order to perform an upgrade of the database format. #c8c8c8 112 code closed 2002 Jul anonymous 2002 Sep 4 4 Segmentation fault in 2.5.5 when opening a 2.6.1 database If you open a 2.6.1 database with version 2.5.5 (admittedly not a very smart thing to do), you get a segmentation fault. I do not consider this serious, but thought you might want to know since might be able to avoid a future problem in examining this. This problem was fixed in check-in [688], which occurred after version 2.5.5, unfortunately. #c8c8c8 111 doc closed 2002 Jul anonymous 2002 Sep 1 3 2.6.1 does not permit SELECT within TRANSACTION whereas 2.5.5 did In order to improve performance during a large number of INSERTs, I enclose them 10,000 at a time within a BEGIN. At the same time, I issue relatively small number of SELECT commands. In version 2.5.5 this all worked fine. In version 2.6.1, I get the following error: rufus-dir: Job kernsave.2002-07-24.08:07:54 Error: sql_get.c:476 query SELECT PoolId, Name, NumVols, MaxVols, UseOnce, UseCatalog, AcceptAnyVolume, AutoPrune, Recycle, VolRetention, PoolType, LabelFormat FROM Pool WHERE Pool.PoolId=1 failed: library routine called out of sequence This error does not occur if I do not start the TRANSACTION I'm not sure if this is a bug or a "feature", but it effectively eliminates the possibility of using a TRANSACTION for a large number of INSERTs (50,000-100,000). You must be running Linux and doing the SELECTs from a different thread that the INSERTs, huh? There is a test added to 2.6.1 that rejects attempts to access the database from a different process than the one that started the transaction. This test was added to prevent people from starting a transaction, doing a "fork()" then trying to commit the transaction in the child. But under Linux, depending on how you implement your threads, sometimes each thread has a different processID and so the test fires in that case too. _From_author_of_bug:_Kern_Sibbald_ I am doing the INSERTs and the SELECTs in a different thread from the one that started the TRANSACTION, but both the INSERTs and the SELECTs are done in the same thread. Under Linux (at least mine), all threads have a different process id -- always. I guarantee that only one thread at a time calls SQLite, and they all use exactly the same open packet. Is there any way I can turn this new behavior off? _Answer:_ No. You will need to start the transaction in the same thread that does the INSERTs and SELECTs. Well, maybe. If you make a bootleg change so that the sqliteOsProcessId() function always returns a constant, you will effectively disable the check. But I'm not sure doing so is a good idea. You really should do the entire transaction from a single thread. The resolution of this ticket is to update the documentation to explain that LinuxThreads (because they do not follow the Posix standard) do not allow transactions to be started in one thread and completed in another. #c8c8c8 110 new closed 2002 Jul anonymous Unknown 2002 Sep anonymous 5 4 Refuse multiple begin transaction or commit Sqlite allows multiple begin transaction or commit commands, or commits without a transaction open, to be issued without reporting an error. I think that if an error would be reported it would be useful, especially during application development where multiple commands may be issued by mistake. #c8c8c8 108 code closed 2002 Jul anonymous 2002 Sep 1 1 Sqlite's Windows Dll Version Still Is 2.56 Please Update Download Page's Windows Dll Files #c8c8c8 107 code closed 2002 Jul anonymous 2002 Sep 1 1 Incorrect query results The following script generates an output of 1 instead of 0: create table t( a int ); create index idx on t(a); insert into t values (''); select count(*) from t where a = 123; The problem appears to be a design flaw in the structure of SQLite indices that goes all the way back to version 2.1.0. An incompatible database format change will (probably) be required to fix the problem. Work on this change is underway now. The problem is expressed when an empty string is used in data that is indexed. Since this problem has not be noticed before, I suppose not many people use empty strings in indexed columns... #c8c8c8 105 code closed 2002 Jul anonymous CodeGen 2002 Sep 2 1 Assertion fails on UPDATE of indexed table with subquery in WHERE The following script results in an assertion failure: create table t1(a,b); insert into t1 values(1,2); create index i1 on t1(a); create index i2 on t1(b); update t1 set b=b+1 where a in (select a from t1); Assertion failed: pParse->nTab==base+i+1, file update.c, line 273 #c8c8c8 104 code closed 2002 Jul anonymous 2002 Sep 1 2 error in trigger on view after closing and reopening database An insert trigger on a view works ok before and returns an error after closing and reopening the database. The following code demonstrates the problem rm -f /tmp/test.sqlite sqlite /tmp/test.sqlite create table test1(id integer primary key,a); create table test2(id integer,b); create view test as select test1.id as id,a as a,b as b from test1 join test2 on test2.id = test1.id; create trigger I_test instead of insert on test begin insert into test1 (id,a) values (NEW.id,NEW.a); insert into test2 (id,b) values (NEW.id,NEW.b); end; insert into test (id,a,b) values(1,'t1','t2'); select * from test; .q sqlite /tmp/test.sqlite insert into test (id,a,b) values(2,'t2-1','t2-2'); returns the error: "SQL error: table test has no column named id" This problem isn't about triggers, it's about views implemented by SELECT statements that use the new join syntax. Here is some more empirical data: 370 ~/cvs/bld$ ./sqlite db SQLite version 2.5.6 Enter ".help" for instructions sqlite> create table test1(id integer primary key, a); sqlite> create table test2(id integer, b); sqlite> create view test_old_syntax as select test1.id, a, b from test1, test2 where test1.id = test2.id; sqlite> create view test_new_syntax as select test1.id, a, b from test1 join test2 on test2.id = test1.id; sqlite> select * from test_old_syntax; sqlite> select * from test_new_syntax; sqlite> .quit 371 ~/cvs/bld$ ./sqlite db SQLite version 2.5.6 Enter ".help" for instructions sqlite> select * from test_old_syntax; sqlite> select * from test_new_syntax; SQL error: no such column: test_.ew sqlite> I did this with the released 2.5.6 version. ------------------------------- The bug concerning old and new syntax you are testing for is already fixed in newer versions: #100. The problem in this ticket is about the insert trigger that returns an error. This problem remains even when using the old syntax. Your code does a select and not an insert after reopening, so the bug is not triggered. I have noticed now that when doing a select on the view after reopening and before doing an insert, the insert works. Without the select after reopening, the insert fails! #c8c8c8 102 code closed 2002 Jul drh 2002 Sep 1 1 ORDER BY ignored in subquery A subquery in the FROM clause of a SELECT ignores its ORDER BY clause. This can lead to incorrect answers, such as in the following: SELECT avg(x) FROM (SELECT x FROM tbl1 ORDER BY x DESC LIMIT 2); #c8c8c8 100 code closed 2002 Jul anonymous 2002 Sep 1 2 view not properly restored after closing and reopening database The view in the code works before closing the database, and gives an error after closing and reopening. (code not included for an error in an insert trigger on the view, as this is probably related) The following code demonstrates the error: sqlite /tmp/test.sqlite create table test1(id integer primary key,a); create table test2(id integer,b); create view test as select test1.id as id,a as a,b as b from test1 join test2 on test2.id = test1.id; select * from test; This works (returns nothing), after closing: sqlite /tmp/test.sqlite select * from test; results in "SQL error: no such column: t" The problem is in the use of the USING clause in the join. A similar problem will occur if ON is used to specify the columns to be joined. #c8c8c8 99 todo closed 2002 Jul drh 2002 Sep 1 1 Document and export the sqlite_mprintf() API. Add documentation on the sqlite_mprintf() API. Make sure this routine is exported in windows DLLs. #c8c8c8 95 code closed 2002 Jul drh CodeGen 2002 Sep 1 1 DROP INDEX on an automatically created internal index is allowed Create a new table with a UNIQUE column or a PRIMARY KEY. This will automatically create an index to handle the uniqueness constraint. Then drop that automatically created index. Leave the shell and bring it back up again, then try to insert a value into the new table. An error results. CREATE TABLE ex1(a unique, b primary key); DROP INDEX '(ex1 autoindex 1)'; -- stop and restart the sqlite shell program INSERT INTO ex1 VALUES(1,2); #c8c8c8 94 code closed 2002 Jul drh Pager 2002 Sep 1 1 ROLLBACK fails to restore all pages When a page is added to a freelist then removed from the freelist and reused during the same transaction, it does not get journaled. This leads to database corruption during a rollback. More rollback problems found and fixed by checking [663] #c8c8c8 92 code closed 2002 Jul anonymous 2002 Sep 2 2 max() looks boggus in a view in a view 'select max(x) + max(y) from t' acts as 'select max(x) + max(x) from t'. As a clue 'max(x) - max(y)' returns 0 and 'max(x) + max(x)' returns '2*max(x)'. Note: I use 2.4 or 2.5.4 on NT CREATE table dummy(foo,bar); insert into dummy values(10,20); insert into dummy values(5,25); select * from dummy; 10|20 5|25 select max(foo) - max(bar) from dummy; -15 CREATE view v as select * from dummy where ( foo == 10 or foo == 5 ); select * from v; 10|20 5|25 select max(foo) - max(bar) from v; 0 select max(foo) + max(bar) from v; 20 #c8c8c8 91 todo closed 2002 Jul anonymous 2002 Sep 4 3 A command-line program for windows There is no compiled 'sqlite' command line program for windows. #c8c8c8 90 code closed 2002 Jul anonymous 2002 Sep 1 1 table aliases in select commands stopped working Hello, I have been useing 2.4.12 and the table aliases used to work just fine (eg. select t1.col1, t2.col2 from table1 t1, table2 t2 where ...). When I have switched to 2.5.3 the old selects using the above syntax stopped working (the error is "Syntax error near "t1" if there is a single table or "Syntax error near ," if there are more tables in the FROM clause). Switching to the old version makes them work again but there is the possibility of data corruption error which makes me a little bit scared. The code example goes below: select kd.id_kat,kd.id_dok,dok.nazev from KAT_DOK kd, DOKUMENT dok where kd.id_dok=dok.id_dok order by kd.id_kat,dok.nazev Without table aliases, the self-joins are not possible and it is also major pain to code the joined selects (and it also breaks almost all the SQL code in my existing apps). Thank you for your marvellous software, I hope your day goes well. Feel free to contact me. Roman #c8c8c8 89 new closed 2002 Jun chw Parser 2002 Sep 1 4 table aliases broken Table aliases seem to be broken in SQLite 2.5.0 and above: $ sqlite test sqlite> create table test(field integer); sqlite> insert into test values(1); sqlite> select field from test; 1 sqlite> select t0.field from test t0; SQL error: near ";": syntax error SQLite requires the "AS" keyword in between the table name and its alias. select t0.field from test as t0; ^^ Making this keyword optional will require adding at least 7 new keywords to the language, as well as a host of other parser complications. #c8c8c8 88 doc closed 2002 Jun anonymous 2002 Sep 4 4 Typo on web page On the page http://www.hwaci.com/sw/sqlite/sqlite.html (emphasis mine): The sqlite program is able to show the results of a query in FIVE different formats: "line", "column", "list", "html", and "insert". You can use the ".mode" dot command to switch between these THREE output formats. #c8c8c8 84 code closed 2002 Jun drh 2002 Sep 1 1 Complex left outer joins might give the wrong answer If the number of WHERE, ON, and USING clause terms in a left-outer join exceeds 32, then the join might not be computed correctly. It use to be that the result was incorrect if there were both WHERE clause terms and USING terms, but that problem was fixed in check-in [639]. But [639] only works if the total number of terms is 32 or less. The fix needs to be extended to work with any number of terms. #c8c8c8 83 todo closed 2002 Jun drh 2002 Sep drh 1 1 Add test cases New test cases are needed in the test scripts. Especially needed are cases to test for the bugs fixed by check-ins [643] and [639]. #c8c8c8 80 code closed 2002 Jun anonymous 2002 Sep 2 2 Heap corruption on select with ORDER BY, LIMIT, and OFFSET Attempt the following script in the shell from an empty database. It is a bunch of identical inserts into a new table followed by a select statment that has WHERE i=0 ORDER BY j LIMIT 5 OFFSET 275 clauses. CREATE TABLE test (i, j, k); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); INSERT INTO test (i,j,k) VALUES (0,'hbhj bhjb dshjfvb hjvsdhjfb jhsbdfhvseyjbgy beryugb yudb gyubsdhjkjkvsdfsdkbfbhjkvsdbjkvsdbfhjkvbsdhjkfb hjksdfkb fsdbhjkhjksdfbvhjk sdbhjk bfsdjkhvb hjksdfb sdhjbvhj sdfbvhjsdfbhjkbjk bsdhjkfbv hjksdfbhjkvbdhjkfsb h','bhchjsbchjb hjadbjk bhj asdbchj basdhjkc asdjb cdbhj basdhjcaskk asdbchj bsdchj basdhjcsj adcbhjkasdbchjkbasdhjkcb asdhjkcbjhasdbchjksadvjkhbcjhkbfcacyuabvweurcbvasdhjkgbvhjkgasdcjkasdbvchjkabvchjkbvasdhjkcvbasdhcjkg vasdbchjvashjkdbvcjkhasbchjkbashjkcasdhj'); SELECT * FROM test WHERE i=0 ORDER BY j LIMIT 5 OFFSET 275; #c8c8c8 79 code closed 2002 Jun drh 2002 Sep 1 1 Tables are not being dropped correctly under certain circumstances. The following script fails: BEGIN; CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); CREATE INDEX i1 ON t1(b,c); INSERT INTO t1 VALUES(0,1,2); END; BEGIN; DROP INDEX i1; DROP TABLE t1; CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); INSERT INTO t1 VALUES(0,1,2); END; #c8c8c8 78 code closed 2002 Jun drh CodeGen 2002 Sep 1 1 Assertion failure when closing database in the middle of a transaction The following script causes an assertion failure: create table t1(x,y); begin; drop table t1; .exit #c8c8c8 77 code closed 2002 Jun anonymous 2002 Sep 2 2 more than one LIMIT on nested select shows 0 rows First at all: you have done a great job with SQLite. Now the bitter part, suppose a statement like: select whatever_you_want from table1, ( select whatever_again from table2 where some_logic_condition LIMIT 5 ) as virtualTable LIMIT 10; The result shows 0 records Removing any of the "LIMIT" keyword the result is not empty. I didn't find anywhere in the documentation that LIMIT is not supported in nested selects. Alexandru Faliboga, alexandru.faliboga@deuromedia.ro #c8c8c8 76 code closed 2002 Jun anonymous 2002 Sep 1 3 sqlite corruption possibly relating to drop of index G'day, I was hoping to ask describe this problem on the yahoo groups before issuing a formal bug report, but yahoo doesn't seem to want me to join the group using netscape (or perhaps it's just broken right now). I have a reproducable problem I noticed with sqlite version 2.4.12 both on my linux machine (installed via the debian package) and on my solaris 2.5.1 machine which I've built by hand. I've had a bit of a look around the code but it hasn't been immediately obvious where this kind of problem comes from. Here is the code to reproduce the problem on both of my machines: BEGIN TRANSACTION; DROP INDEX Trend; DROP TABLE Disturbance; CREATE TABLE Disturbance (Entry INTEGER PRIMARY KEY,Identity INTEGER,Sample DOUBLE,Good BOOLEAN,Time DOUBLE); CREATE INDEX Trend ON Disturbance (Identity, Time); INSERT INTO Disturbance VALUES(0,3271,5,1,1023781501.678765); END TRANSACTION; To see the corruption run twice: > rm fred* > sqlite fred < crash DROP INDEX Trend; SQL error: no such index: Trend DROP TABLE Disturbance; SQL error: no such table: Disturbance > sqlite fred < crash INSERT INTO Disturbance VALUES(0,3271,5,1,1023781501.678765); SQL error: database disk image is malformed I noticed this problem when running peformance tests of sqlite gainst other free databases for a commercial product I'm working on. Although I haven't seen anything like this in the prototypical applications I've written the fact that it has shown up leads me to want it resolved before I feel completely safe with sqlite :) The problem appears goes away if I take away the begin/end transaction pair, or if I take out the drop/create index pair. Benjamin. P.S. The public domain status of this product is an idea I like very much: Congratulations. It's good to see products of such high calibre being made so readily available no matter what the user situation. sqlite is also by -far- the fastest database system I've tested for my very simple purposes. Even though it's based on a file locking system it still outperforms everything else I've tried when it comes to a large number of insertions with some simultaneous queries. This bug has been around since version 2.0.0. #c8c8c8 75 code closed 2002 Jun drh CodeGen 2002 Sep 1 1 Auto-increment not working on an INSERT from a SELECT If you try to insert a NULL into an INTEGER PRIMARY KEY column using a VALUES clause in an INSERT statement, the primary key is filled with the next available integer. Ex: INSERT INTO x(pk,y) VALUES(NULL, 5); But if you do a similar insert were the source of data is a SELECT instead of a VALUES clause, the primary key is not automatically generated: INSERT INTO x(pk,y) SELECT NULL, a FROM z; #c8c8c8 73 code closed 2002 Jun drh CodeGen 2002 Sep drh 1 1 ORDER BY clause is ignored on subqueries The ORDER BY clause of a SELECT is ignored if the output of the SELECT is sent to a table as in a subquery. Usually this does not matter, but it makes a difference if there is also a LIMIT clause. #c8c8c8 72 code closed 2002 Jun anonymous 2002 Sep 1 1 malloc test in testbed fails Win32 build of 2.4.12 This is a bit of curly problem in that there are actually a number of issues being compounded into one, so please bear with me. I have been using sqlite 2.4.1 for some time now without any hitch. I noticed that 2.4.12 and had some nice features, so I decided to have deeper look into it. Using the 2.4.12 source release of sqlite, I ran the configure script from my build directory, and then compiled it successfully on cygwin, using gcc 2.95.3-5 and make 3.79.1 (successful only if you ignore the linker warnings about undefined symbols not allowed in shared libraries). I then ran the TCL test via 'make test' - no problems (testfixture was compiled with tcltk 20001125-1). I decided to run the fulltest, so I modified the Makefile to include the -DNDEBUG=1 and -DMEMORY_DEBUG=1 preprocessor directives and ran 'make fulltest'. The test scripts happily did their job, until malloc-1.77 (found in test/malloc.test) which failed with a 'database is locked' message. Upon further investigation, I found that the call to the Win32 function LockFile() was failing which causes the above message being returned when the SQL statement is evaluated. It is also very curious, seeing as there is only one instance of testfixture running, in which case LockFile() shouldn't fail as the lock is owned by the testfixture process instance. I investigated further to discover that there is a flaw in the testbed itself - any errors that occur while deleting files are silently discarded. This is issue 1. This means that the database is locked some point earlier in the testing and it is only by chance that the 'database is locked' message is obtained. By modifying the testbed scripts (test/*.test) to assert that the file does not exist whenever a file deletion occurs, I ascertained that the offending read lock first began at malloc-1.63 and was not released during the failure of the sqlite_open() call. Upon closer analysis it appears that during the call of sqlite_open() the Btree is opened successfully via a call to sqliteBtreeOpen(), which opens the database file for read and write. Then sqliteInit() is called, which fails because of an "out of memory" error. As there was a sqlite malloc failure, sqlite_close() is called to cleanup. Because sqlite.magic has a value of SQLITE_MAGIC_BUSY, the sqlite safety checks fail and sqliteBtreeClose() is never called and hence the sqlite db structure is never freed. This is issue 2. In fact, if sqliteInit() should fail for any reason, the same locking problem will eventually exhibit. This is issue 3. Seeing as I'm still getting a feel for the workings of sqlite and its clearly a state analysis issue, I felt it best that I leave the solution to the experts. The patch corrects issue 3. To ensure that something this complex is caught, perhaps the *.test files should be updated to so that any file deletion that does not succeed should report and stop further testing? #c8c8c8 71 code closed 2002 Jun anonymous 2002 Sep drh 2 4 "COPY table FROM file" expects lines to end with LF. The sqlite SQL statement "COPY table FROM file" reads delimited fields from each line in a file and writes a corresponding record containing those read fields into the table. The mechanism that reads a line from the file assumes that the end of the record in the file is delimited by a LF character. This mechanism relies upon repeatedly calling fgets() to obtain from the open file a line that ends with a LF character. Unfortunately, fgets() uses a platform-specific EOL marker. If sqlite is compiled for Cygwin or Linux the EOL marker that fgets() uses is LF. If sqlite is compiled for Win32 (using the Win32 source and Visual C++) the EOL marker that fgets() uses is CRLF. If sqlite was compiled for a Mac environment the EOL marker that fgets() would use would be CR. This means that if the fgets() EOL marker is not the LF character that sqlite uses, the "COPY table FROM file" operation will not be as expected. There are three solutions: 1) Force fopen() to open the file for reading using text mode in the OP_FileOpen section of code in the src/vdbe.c file. ie: From this p->pFile = fopen(pOp->p3, "r"); To this p->pFile = fopen(pOp->p3, "rt"); This will cause fgets() to translate the various forms of EOL markers read from the file to a LF character, at the cost of not being able to copy in binary data. 2) Replace the fgets() call with a less platform specific mechanism so that a consistent EOL marker be used across platforms, suitable for copying in binary data. 3) Provide in the SQL statement a mechanism to specify what sqlite should use as the end of record delimiter when reading from the file. Steps to reproduce (Cygwin example): Using gcc 2.95.3-5, make 3.79.1, and tcltk 20001125-1, issue from the build directory a 'make fulltest'. The build directory must reside within a mount point that has been mounted in binmode. The test "copy-3.2" should fail, because this Cygwin release of Tcl implements EOL marker as CRLF and fgets() uses LF as the EOL marker. If the build directory resides on a mount point that has been mounted in textmode, the tests in test/copy.test will succeed. #c8c8c8 70 doc closed 2002 Jun anonymous 2002 Sep 5 5 Error in online documentation for DROP VIEW The online documentation at "http://www.hwaci.com/sw/sqlite/lang.html" for DROP VIEW has a cut-and-paste error. The DROP VIEW statement consists of the keywords "DROP TABLE" followed by the name of the view. This should be "DROP VIEW". #c8c8c8 66 code closed 2002 Jun anonymous 2002 Sep drh 1 2 LIMIT clause ignored in subselects This should work: gerhard@lilith:~$ sqlite /tmp/db SQLite version 2.4.7 Enter ".help" for instructions sqlite> create table test(id); sqlite> insert into test(id) values (1); sqlite> insert into test(id) values (2); sqlite> insert into test(id) values (3); sqlite> select id from test; 1 2 3 sqlite> select id from test limit 2; 1 2 sqlite> delete from test where id in (select id from test limit 2); sqlite> select id from test; [nada] I just verified that the problem still exists in 2.4.12. As you can see, there is some bug in SQLite so that this statement deletes all rows instead of only these with id=1 or id=2 :-( Yeah. The LIMIT and ORDER BY clauses are both ignored on a subselect. For an ORDER BY this is ok, but as you point out, LIMIT should not be ignored. I'll have to make some changes. #c8c8c8 65 code closed 2002 Jun anonymous 2002 Sep 2 2 Error in .dump'ed INSERT statements For columns containing a long string which appear to be an integer number but are not representable in 32 bit (eg 004001001000) the .dump command of the sqlite shell does not output a proper INSERT statement which quotes these strings. This results in a dump file which can't be reloaded into an sqlite database. Test case: CREATE TABLE station ( name char(15) UNIQUE NOT NULL, place char(15) UNIQUE NOT NULL ); INSERT INTO station VALUES('S01',001001001000); INSERT INTO station VALUES('S02',002001001000); INSERT INTO station VALUES('S03',003001001000); INSERT INTO station VALUES('S04',004001001000); #c8c8c8 64 code closed 2002 Jun danielk1977 Shell 2002 Sep 5 5 TEMP tables in a read-only db using the shell tool When you try and create an (ordinary, not TEMP) table in a read-only database using the shell tool no error is returned. This looks like a bug in the shell, not the library, as testcase temptable-6.3 demonstrates that the library returns an error. The cut-and-paste from a terminal below shows the behaviour. 1979 ~/cvs2/bld$ ./sqlite a SQLite version 2.4.12 Enter ".help" for instructions sqlite> create table tbl(a); sqlite> select * from tbl; SQL error: no such table: tbl sqlite> .exit 1980 ~/cvs2/bld$ ./testfixture % sqlite db a 134636032 % db eval {CREATE TABLE tbl(a)} Error: attempt to write a readonly database % #c8c8c8 63 new closed 2002 Jun drh CodeGen 2002 Sep 3 3 Add optimizations for "WHERE rowid IN (SELECT...)" Add optimizations to the where.c module that will efficiently handle a WHERE clause that consists of a single IN operator. For example: UPDATE t1 SET c1=NULL WHERE rowid IN (SELECT t1.rowid FROM t1 NATURAL JOIN t2 WHERE t2.c2>10) #c8c8c8 62 code closed 2002 Jun danielk1977 VDBE 2002 Sep 3 4 TEMP tables with a read-only database When using a read-only database, you can't create TEMP tables. It would be useful to be able to do so. #c8c8c8 59 doc closed 2002 Jun anonymous 2002 Sep 3 4 Undocumented Concatenation Operator The concatenation operator || appears to be missing from the documentation on expressions in: http://hwaci.com/sw/sqlite/lang.html #c8c8c8 54 todo closed 2002 Jun anonymous 2002 Sep 2 2 win32 binaries are missing symbols In the win32 binaries, the DLL and DEF file are missing symbols, in particular the sqlite_set_result_* functions and the sqlite_user_data, sqlite_create_aggregate sqlite_create_function Maybe others, too. I finally managed to build my own Windows binaries with MSYS + mingw32, so this isn't very pressing. But it also means that the win32 binaries are useless, if you need the above symbols, which I do. #c8c8c8 53 new closed 2002 May anonymous 2002 Sep 5 4 Single checkpoint file enhancement I have made some changes on pager.c that allows the use of a single temporary checkpoint file instead of a checkpoint file for each checkpoint. The checkpoint file is created when the pager is opened and closed when the pager is closed (and so automatically deleted by the OS). On checkpoint commit or rollback the file is just truncated. This leads to a performance increase of about 3/4 % on Win32 (tested under Win98), especially on big transactions. It also works for Linux but I haven't tested performances on it, so the code is enabled by a define (SQLITE_FAST_CKPT) on top of pager.c. For sure this change put less load on the operating system so I expect some performance increase also under Unix. I implemented this differently that shown in the patch. The checkpoint journal file is closed when the transaction ends because I do not want to leave open file descriptors hanging around unnecessarily. The checkpoint journal is truncated when it is committed (or rolled back) rather than when the next checkpoint starts. The checkpoint journal is not initially opened until the start of the first checkpoint. #c8c8c8 52 new closed 2002 May anonymous 2002 Sep 5 4 Backslash check on temporary file names under Win32 This is just a paranoid check, but it is always a good check to do under Win32. Furthermore there was a unneeded '/' appended to the temp path. It worked, but I don't know how. Tested patch for os.c follows. --- os.c.orig Wed Mar 20 01:00:30 2002 +++ os.c Wed May 29 13:04:01 2002 @@ -432,11 +432,14 @@ "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; - int i, j; + int i, j, tl; char zTempPath[SQLITE_TEMPNAME_SIZE]; - GetTempPath(SQLITE_TEMPNAME_SIZE-30, zTempPath); + tl = GetTempPath(SQLITE_TEMPNAME_SIZE-30, zTempPath); for(;;){ - sprintf(zBuf, "%s/sqlite_", zTempPath); + if (zTempPath[tl - 1] == '\\') + sprintf(zBuf, "%ssqlite_", zTempPath); + else + sprintf(zBuf, "%s\\sqlite_", zTempPath); j = strlen(zBuf); for(i=0; i<15; i++){ int n = sqliteRandomByte() % sizeof(zChars); #c8c8c8 50 code closed 2002 May drh 2002 Sep 3 2 Memory leak in triggers on TEMP tables When a trigger is attached to a TEMP table and the TEMP table is automatically delete when the DB connection closes, the memory used to hold the trigger is not cleaned up. #c8c8c8 49 code closed 2002 May drh CodeGen 2002 Sep 2 1 DELETE Trigger causes extra rows to be deleted When the body of a DELETE trigger deletes rows that were later to be deleted by the original statement, then the original statement deletes rows that follow the ones it was originally to delete. For example, in the following program, the table t1 should be left with two rows: {2,'b'} and {4,'d'}. But as currently implemented, the {4,'d'} row is deleted incorrectly. create table t1(a,b); insert into t1 values(1,'a'); insert into t1 values(2,'b'); insert into t1 values(3,'c'); insert into t1 values(4,'d'); create trigger r1 after delete on t1 for each row begin delete from t1 WHERE a=old.a+2; end; delete from t1 where a in (1,3); select * from t1; A similar problem occurs on an UPDATE trigger when subsequent rows in the change set are deleted. Both problems are now fixed. #c8c8c8 47 code closed 2002 May anonymous 2002 Sep 5 4 Compiler Warning using MingW/gcc C:\sqlite\build>gcc -c -O2 ..\src\hash.c -I. ..\src\hash.c: In function `sqliteHashInsert': ..\src\hash.c:323: warning: assignment discards qualifiers from pointer target type C:\sqlite\build>gcc -v Reading specs from C:/MSYS/1.0/MINGW/BIN/../lib/gcc-lib/mingw32/2.95.3-6/specs gcc version 2.95.3-6 (mingw special) #c8c8c8 46 code closed 2002 May drh CodeGen 2002 Sep 3 2 CREATE TABLE accepts duplicate column names The SQL statement shown below is accepted and the new table is created. This is wrong. An error should be issued because two or more columns share the same name. CREATE TABLE bug1(a,a,a); #c8c8c8 45 code closed 2002 May anonymous 2002 Sep 4 4 Unique constraint problem on updating PRIMARY KEY column When you update a table with an INTEGER PRIMARY KEY column, the uniqueness constraint fails if you are updating that column to its *same* value [that is, not actually changing THAT column at all in the update]. #c8c8c8 44 code closed 2002 May anonymous 2002 Sep 3 3 UNIQUE constraint (incorrectly) applies to NULL My understanding of SQL9X is that NULL values are not considered equal for the purpose of a UNIQUE constraint.SQLITE on the other hand appears to consider NULL a value to be constrained like any other non-null value. My work-around for now is to remove UNIQUE from the column(s) concerned and enforce the contraint in my application. I would prefer however that the database enforce the constraint itself to eliminate the possibility of non-null duplicates occuring. SQLite treats NULL as just another value. This behavior is at odds with every SQL standard out there, but it is not likely to change any time soon. #c8c8c8 42 doc closed 2002 May drh 2002 Sep 1 1 Add comments to Trigger structures in sqliteInt.h The structures associated with trigger need to be carefully commented. #c8c8c8 41 code closed 2002 May drh 2002 Sep 1 2 sqlite_complete() failure In the "sqlite" shell program, enter the following SQL: create table misc(name,value); create table backend(a,b,c); create trigger t1 on backend begin update misc set value=value+1 where name='chngcnt'; The shell should issue a continuation prompt waiting on the completion of the CREATE TRIGGER statement. But instead, it gets confused, thinks the semicolon at the end of the UPDATE is the end of the CREATE TRIGGER, tries to execute the incomplete SQL statement, and reports a syntax error. #c8c8c8 40 code closed 2002 May drh 2002 Sep 3 3 Compiler warnings on RedHat 7.2 There are compiler warnings on RedHat 7.2 that need to be fixed. #c8c8c8 39 todo closed 2002 May drh 2002 Sep 5 1 Reformat the TRIGGER code for consistent style. The newly inserted TRIGGER code does not conform stylistically to the rest of the code. It needs to be brought into compliance. Among the areas where there is stylistic deviation: (1) Spacing on "if" statements and on pointer declarations, (2) Variable naming conventions, (3) Indentation of procedure definitions, (4) The body of "if" and "while" statements are not always enclosed in {...}. Also add detailed comments to the beginning of every new function. #c8c8c8 35 code closed 2002 May drh CodeGen 2002 Sep 1 1 An ORDER BY clause on a subquery causes a segfault Placing an ORDER BY clause on a subquery can result in a segfault. For example: create table t1(a,b); insert into t1 values(1,2); select a from (select a,b from t1 union select b,a from t1 order order by b, a); Fix this by simply ignoring the ORDER BY clause on a subquery. #c8c8c8 34 code closed 2002 May drh CodeGen 2002 Sep 1 1 Segfault when a VIEW contains an ORDER BY clause When the definition of a VIEW contains an ORDER BY clause, attempting to access the view can cause a segfault. For example, the following code fails: create table t1 as select 1 as 'a', 2 as 'b'; create view v1 as select b, a from t1 union select a, b from t1 order by a, b; .header on select a from v1; This problem is fixed by getting views to ignore their ORDER BY clause. This is a reasonable constraint, I think, because a view is suppose to simulate a table and tables are unordered. My question is: should putting an ORDER BY on a view definition raise an error, or should it just be silently ignored. SQL Server raises an error. MySQL does not support views. I don't know what Oracle, Informix, or PostgreSQL do. #c8c8c8 33 code closed 2002 May drh CodeGen 2002 Sep 1 1 Segfault when a VIEW contains a compound SELECT with an ORDER BY The following command sequence causes a segfault: create table t1 as select 1 as 'a', 2 as 'b'; create view v1 as select a from t1 union select b from t1 order by b; .header on select * from v1; #c8c8c8 32 code closed 2002 May drh 2002 Sep 1 1 Columns in views are not always named correctly. Create a veiw like this: CREATE VIEW v1 AS SELECT f AS 'g' FROM t1; When we do a "SELECT * FROM v1" we would expect the name of the column to be 'g'. But instead it comes out as 'f'. #c8c8c8 31 code closed 2002 Apr danielk1977 CodeGen 2002 Sep 4 4 SELECT without FROM Trivial issues with SELECT statements that don't have FROM clauses: "SELECT * FROM (SELECT 1);" does a segfault. "SELECT 1 WHERE 0;" returns a single row. This is not really incorrect, just wierd. #c8c8c8 28 code closed 2002 Apr anonymous 2002 Sep drh 3 1 sqlite_changes not exported in sqlite.def in SQLite_source.zip "sqlite_changes" is not listen in the .def file for the Windows DLL. And thus the function is not linkable through the DLL import library. #c8c8c8 26 doc closed 2002 Apr anonymous 2002 Sep drh 5 4 Proc-1 Not Refresh Newer SQLITE_MASTER Info After Proc-2 CreateTable For Example: Two Processes, First Open A Database File, then 2nd Open the Same Database File, Create Table Named 'demo', 1st Execute 'select * from demo', Error Show 'no such table: demo' This behavior is intentional. Documentation saying as much has been added to the FAQ. #c8c8c8 22 code closed 2002 Apr anonymous 2002 Sep drh 2 1 compound selects as expressions (All on Windows2K) Given the two tables: CREATE TABLE pictures (id INTEGER PRIMARY KEY,filename varchar(255),import_date date,fileDateTime date,fileSize long); CREATE TABLE pictures_categories (picture integer, category integer); Having some records in pictures and some in pictures_categories I now want a select on pictures of the pictures NOT having an entry in the pictures_categories table I try: select * from pictures where id in (select id from pictures except select picture as id from pictures_categories); The result is as expected when done from the commandline interface, but if I do a ".header on" or use SQLite as a lib in my application I get a windows memory protection error. If I only select the .filename column the commandline writes "id" as the column header (depending on the "as" in the last select in the compound) this can be changed. It seems to me as if only the headers from the right most select is written. #c8c8c8 17 new closed 2002 Apr anonymous 2002 Sep drh 5 5 Enhancement of %q in sqlite...printf API The %q format specifier needs to be enclosed in single quotes and produces '(NULL)' for string arguments passed as NULL pointers. For some applications it would be nice to have an alternate form (let's call it %Q) with slightly different behaviour: - does implicit single quote enclosure - expands to NULL when associated argument is a NULL pointer - thus allows to safely enter NULL values in insert or update statements Examples: Old (%q): insert into foo values(1, '%q') with argument NULL expands to insert into foo values(1, '(NULL)') New (%Q): insert into foo values(1, %Q) with argument NULL expands to insert into foo values(1, NULL) with argument ba'r expands to insert into foo values(1, 'ba''r') #c8c8c8 9 new closed 2002 Apr anonymous BTree 2002 Sep 1 3 platform-independent db files Trying to create an application that will run in a heterogeneous envioronment of x86, sparc, mips, and alpha machines running a variety of operating systems. User's home directories and data files are shared across all platforms. I'd like to use SQLite in an application but I want users to be able to share a database file across all platforms. The "simple" fix is to change all database reads/writes to use Network Byte Order for the on-disk file format, and convert to local byte-order for in-memory use. This might be more of a problem due to the fact that SQLite is untyped. If you don't know that data is an integer vs. a string, you may not know the appropriate byte order. OTOH, if you store everything as strings, then you must have some way to convert the integer "10" to the two-byte string "10", and back, so the only byte-order issue would be data lengths. Unfortunately SQLite is useless to me without portable data files. Thanks, Changing the database file format to be byteorder independent is a reasonable request. However, it is also a major rewrite of the BTree layer. We'll put this off for the time being. ----- OK. It turned out to be easier than expected. ----- The first fix is incomplete. The journal file still is byte-order dependent. So if a big-endian machine tries to rollback a transaction started by a little-endian machine, it will fail. ----- Numbers are now written into the rollback journal as big-endian, regardless of the byte-order of the host machine. There is a new magic number at the beginning of journal files to identify them as such. Old journals can still be rolled back, but only by a process on the same byte-order machine as the journal was originally created on. #cfe8bd 302 code fixed 2003 Apr anonymous Shell 2003 Apr 3 3 .sqliterc can do memory fault If I put a ".timeout 100" into the ".sqliterc" configuration file sqlite exit for a memory fault. The problem is that the .sqliterc is processed before the database is opened so a ".timeout 100" command (but so other commands) use a NULL "db" pointer. Into "shell.c" the "do_meta_command" call the "sqlite_busy_timeout" funcion with a NULL db pointer. #f2dcdc 301 code active 2003 Apr anonymous Unknown 2003 Apr 2 3 Can't acquire lock for database on Mac OS X AppleShare volume 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:_ {linebreak} 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. #cfe8bd 298 code fixed 2003 Apr drh CodeGen 2003 Apr 1 1 SELECT sometimes ignores constant WHERE clause The following queries return 1 when they should return an empty set: SELECT 1 WHERE abs(random())<0; SELECT 1 WHERE NULL=5; This only happens when the FROM clause is omitted and the WHERE clause slips through the optimizer as a non-constant expression. #cfe8bd 297 code fixed 2003 Apr anonymous 2003 Apr 1 1 sqliteSortCompare crashes when sorting ints by more than one key in line 836 (at the end of sqliteSortCompare) a and b are set to the next element which is set wrong if the elements don't have the same size. example: a: +100\000A1\000\000 b: +100.0\000A4\000\000 after cmp: a: A1\000\000 b: 0\000A4\000\000 sqlite: ../sqlite/src/util.c:804: sqliteSortCompare: Assertion `a[0]==b[0]' failed. this can be fixed with the following patch in util.c: instead of : len = strlen(&a[1]) + 2; a += len; b += len; someone should write: a += strlen(&a[1]) + 2; b += strlen(&b[1]) + 2; thanks for all the stuff anyway, marcus. #cfe8bd 296 code fixed 2003 Apr anonymous VDBE 2003 Apr 1 4 crash sqlite or execute via libtclsqlite create table proba(num integer unique not null); select max(num) from proba; $ sqlite: ./src/dtree.c:1215: sqliteBtreeKey:Assertion `offset>=0' failed. #cfe8bd 295 code fixed 2003 Apr drh CodeGen 2003 Apr 1 1 ATTACH does not work on a database containing triggers The ATTACH command fails if the database begin attached contains triggers. #f2dcdc 294 new active 2003 Apr anonymous Shell 2003 Apr a.rottmann 1 4 Diff for OpenBSD In order to build on OpenBSD, the following diff must be applied, as per Wild Karl-Heinz . This is on an OpenBSD 3.2 -current build. diff Makefile.in Makefile.in~{linebreak} 52c52{linebreak} < LIBREADLINE = @TARGET_READLINE_LIBS@ -lcurses{linebreak} ---{linebreak} > LIBREADLINE = @TARGET_READLINE_LIBS@{linebreak} 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:_ {linebreak} See #303; the build system should have an overhaul. #cfe8bd 293 code fixed 2003 Apr anonymous 2003 Apr paul 1 2 configure-script broken by checkin #903 Hate to bother you again, but the changes to the configure script concerning the in-memory btrees broke it. Problem is you are using shell variables with the name enable_incore-db and enable_tempdb-in-ram which both are not legal shell variable identifiers. I think the '-' is not allowed. You should use '_' instead. #cfe8bd 291 code fixed 2003 Apr drh 2003 Apr drh 1 1 autoincrement does not work with triggers Consider the following SQL: CREATE TABLE t1(a INTEGER PRIMARY KEY); CREATE TABLE t2(b); CREATE TRIGGER r1 AFTER INSERT ON t1 FOR EACH ROW BEGIN INSERT INTO t2 VALUES(new.a); END; INSERT INTO t1 VALUES(NULL); The insert of a NULL into the INTEGER PRIMARY KEY column causes the NULL to be changed into the next available rowid for that table. But within the trigger, NEW.A does not take on the rowid value. It continues to be NULL. #cfe8bd 290 event fixed 2003 Apr drh VDBE 2003 Apr 1 1 interaction of last_insert_rowid() and AFTER triggers Consider the following SQL: CREATE TABLE t1(a integer primary key); CREATE TABLE t2(x); CREATE TRIGGER r1 AFTER INSERT on t1 FOR EACH ROW BEGIN INSERT INTO t2 VALUES(NEW.a+10); END; When a value is inserted into t1, it causes trigger r1 to fire and insert a related value into t2. The next call to sqlite_last_insert_rowid() will return the rowid for the insert into table t2, not the insert into table t1. Technically, this behavior is correct, because the last row inserted was into table t2. But the behavior was unexpected. The user was expecting the rowid of the row inserted into t1 because the t2 insert happens behind the scenes - out of view from the user. I'm not sure if this is a bug or not. #cfe8bd 289 code fixed 2003 Apr anonymous BTree 2003 Apr 1 1 File src/btree_rb.c is missing File src/btree_rb.c is missing from CVS! #cfe8bd 288 code fixed 2003 Apr anonymous 2003 Apr 1 1 sqlite don't compile on SuSE 8.2 (gcc 3.3) Hello, sqlite 2.8.0 don't compile on SuSE 8.2 (gcc 3.3). The following error is shown on the console: gcc -g -O2 -o lemon ../sqlite/tool/lemon.c In file included from ../sqlite/tool/lemon.c:10: /usr/lib/gcc-lib/i486-suse-linux/3.3/include/varargs.h:4:2: #error "GCC no longer implements ." /usr/lib/gcc-lib/i486-suse-linux/3.3/include/varargs.h:5:2: #error "Revise your code to use ." ../sqlite/tool/lemon.c:1106: error: parse error before "va_dcl" ../sqlite/tool/lemon.c:1107: error: syntax error before '{' token ../sqlite/tool/lemon.c:1116: error: parse error before "ap" ../sqlite/tool/lemon.c:1116: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1119: warning: parameter names (without types) in function declaration ../sqlite/tool/lemon.c:1119: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1120: error: parse error before "char" ../sqlite/tool/lemon.c:1121: error: parse error before "int" ../sqlite/tool/lemon.c:1122: error: conflicting types for `format' ../sqlite/tool/lemon.c:1110: error: previous declaration of `format' ../sqlite/tool/lemon.c:1122: error: parse error before "char" ../sqlite/tool/lemon.c:1129: error: initializer element is not constant ../sqlite/tool/lemon.c:1129: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1130: error: initializer element is not constant ../sqlite/tool/lemon.c:1130: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1133: warning: parameter names (without types) in function declaration ../sqlite/tool/lemon.c:1133: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1134: warning: parameter names (without types) in function declaration ../sqlite/tool/lemon.c:1134: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1135: error: initializer element is not constant ../sqlite/tool/lemon.c:1135: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1137: error: parse error before "while" ../sqlite/tool/lemon.c:1142: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1143: error: parse error before "while" ../sqlite/tool/lemon.c:1147: error: parse error before string constant ../sqlite/tool/lemon.c:1147: warning: conflicting types for built-in function `fprintf' ../sqlite/tool/lemon.c:1147: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1148: error: redefinition of `base' ../sqlite/tool/lemon.c:1142: error: `base' previously defined here ../sqlite/tool/lemon.c:1148: error: initializer element is not constant ../sqlite/tool/lemon.c:1148: warning: data definition has no type or storage class ../sqlite/tool/lemon.c:1149: error: parse error before '}' token make: *** [lemon] Fehler 1 see ticket #280 #f2dcdc 286 doc active 2003 Apr anonymous 2003 Apr 3 3 Tcl command documentation does not explain (minus) options. 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 #cfe8bd 284 code fixed 2003 Apr anonymous Unknown 2003 Apr 2 1 "make test" --> Segmentation Fault on Solaris Several test cases fail catastrophically: * auth-1.1.1 * capi2-1.1 I've tried several environments with similar results: Solaris 8 - Sun WorkShop C++ 5.0 + tcl8.4 - gcc 3.2.2 + tcl8.4 Solaris 9 - gcc 3.2.2 + tcl8.4 I've attached two stack dumps, both from the Sun WorkShop environment on Solaris 8. BTW, sqlite 2.7.6 builds and passes all tests in that same environment. The problem appears to be in the test code, not in SQLite itself. So you might still be able to use the library even though some of the tests fail. The problem seems to be in the getDbPointer() routine near the top of the test1.c source file. I suspect it has something to do with Sparcs using a 64-bit pointer. Either getDbPointer() is not decoding that pointer correctly, or the pointer is not being rendering into a string correctly by the printf() in sqlite_test_open() of the same file. I don't have access to a Sparc and cannot debug this. I'd appreciate it if the reporter would look into this using a debugger and suggest a patch to fix it. ---- In tclsqlite.c there is a fragment of code that formats native pointers to string values for Tcl. The code looks like this: sprintf(zBuf,"%p",p->db); if(strncmp(zBuf,"0x",2)){ sprintf(zBuf,"0x%p",p->db); } This has the effect of forcing a 0x prefix. However, in getDbPointer() in test1.c the sscanf() uses a bare "%p". Adding the leading 0x to the PTR_FMT in test1.c resolves the problem and gets us past auth-1.1.1 and capi2-1.1 ----- Note to self: The %p format appears to work differently on different systems. Consider doing a run-time test to discover the operation of %p when the test fixture is initialized and set up the format appropriately based on the results. #c8c8c8 283 code closed 2003 Apr anonymous Parser 2003 Apr 3 1 Defect in sqlite_exec_vprintf sqlite_exec_vprintf which I use in Delphi to process SQL statement with parameters causes sqlite.dll library (tested on 2.8.0) to crash when : 1. There is SQL statement with "like %" like: select * from simpsons where LastName like '%burn%' 2 and valist is nil (no parameters ) seems that library improperly recognize % sign. When using sqlite_exec_vprintf() use two % symbols to generate a single %. Like this: SELECT * FROM simpsons WHERE lastname like '%%burn%%' You only have to do this with sqlite_exec_vprintf() and the other "printf"-style routines - not sqlite_exec(). This is a feature of the printf-style interface, not a bug. #cfe8bd 281 code fixed 2003 Apr anonymous 2003 Apr 1 1 expression 0 = '' is true Expression 0 = '' is true: run script create table t1(i integer primary key); create table t2(i integer); insert into t1 values(0); insert into t2 values(0); select 1, i from t1 where i = ''; select 2, i from t2 where i = ''; select 3, i from t1 where 0 = ''; Output (sqlite 2.7.5): 1|0 2|0 3|0 Output (sqlite 2.8.0): 2|0 3|0 #cfe8bd 280 code fixed 2003 Apr anonymous 2003 Apr 2 2 Revise your code to use Starting with version 3.3, GCC no longer implements . Please revise your code to use . In file included from tool/lemon.c:10: /usr/lib/gcc-lib/i486-suse-linux/3.3/include/varargs.h:4:2: #error "GCC no longer implements ." /usr/lib/gcc-lib/i486-suse-linux/3.3/include/varargs.h:5:2: #error "Revise your code to use ." tool/lemon.c:1106: error: parse error before "va_dcl" tool/lemon.c:1107: error: syntax error before '{' token tool/lemon.c:1116: error: parse error before "ap" tool/lemon.c:1116: warning: data definition has no type or storage class tool/lemon.c:1119: warning: parameter names (without types) in function declaration tool/lemon.c:1119: warning: data definition has no type or storage class tool/lemon.c:1120: error: parse error before "char" tool/lemon.c:1121: error: parse error before "int" tool/lemon.c:1122: error: conflicting types for `format' tool/lemon.c:1110: error: previous declaration of `format' tool/lemon.c:1122: error: parse error before "char" tool/lemon.c:1129: error: initializer element is not constant tool/lemon.c:1129: warning: data definition has no type or storage class tool/lemon.c:1130: error: initializer element is not constant tool/lemon.c:1130: warning: data definition has no type or storage class tool/lemon.c:1133: warning: parameter names (without types) in function declaration tool/lemon.c:1133: warning: data definition has no type or storage class tool/lemon.c:1134: warning: parameter names (without types) in function declaration tool/lemon.c:1134: warning: data definition has no type or storage class tool/lemon.c:1135: error: initializer element is not constant tool/lemon.c:1135: warning: data definition has no type or storage class tool/lemon.c:1137: error: parse error before "while" tool/lemon.c:1142: warning: data definition has no type or storage class tool/lemon.c:1143: error: parse error before "while" tool/lemon.c:1147: error: parse error before string constant tool/lemon.c:1147: warning: conflicting types for built-in function `fprintf' tool/lemon.c:1147: warning: data definition has no type or storage class tool/lemon.c:1148: error: redefinition of `base' tool/lemon.c:1142: error: `base' previously defined here tool/lemon.c:1148: error: initializer element is not constant tool/lemon.c:1148: warning: data definition has no type or storage class tool/lemon.c:1149: error: parse error before '}' token gmake: *** [lemon] Fehler 1 Added simple patch that fixes compile on GCC 3.3. The patch is somewhat ugly because it mixes K&R-style C with ANSI C in one source file, but I see no other way to use . #f2dcdc 278 doc active 2003 Apr anonymous Unknown 2003 Apr anonymous 3 3 Possible documentation bug in "expression" section. 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). #cfe8bd 277 code fixed 2003 Apr anonymous Parser 2003 Apr 1 2 Multi-line comments cause syntax errors in ".read" files Commenting out multiple lines of code using "/\*...\*/" in files that are .read into sqlite.exe causes a syntax error to be thrown on the closing "\*/": SQL error: near "\*": syntax error The syntax error is thrown at the END of the following statement. I do not know if the error is thrown if there is nothing after the commented out block. The priority assigned is bacause this flaw makes it devilishly hard to debug code. NOTE: the backslashes before the astrisks are to prevent the bug tracker from eating them and trying to bold the text after/between two asterisks. If there is another way to get these characters verbatim, the "Formating Hints" don't show it. #cfe8bd 276 new fixed 2003 Apr anonymous Shell 2003 Apr 3 3 Proposal/Bug-Fix for TTY determination one line summary: Call to isatty() could be "cleaner", the current implemenation fails under Windows CE. This is an enhancement but also a bug fix in relation to Windows CE. I expect to be submitting my changes against sqlite "proper" for the Windows CE / Pocket PC platform soon. The only reason I'm raising this pedantic change is to get my PocketPC port working :-) diff winCE_sqlite_280_source/shell.c sqlite-2.8.0/sqlite/src/shell.c{linebreak} 1213c1213{linebreak} < if( isatty( fileno( stdout ) ) ){{linebreak} ---{linebreak} > if( isatty(0) ){{linebreak} Under PocketPC we don't have console's etc. so I'm relying opon PocketConsole (and portlib) http://www.symbolictools.de/public/pocketconsole/index.htm#download to get the (shell) terminal monitor working (they are not nessacary for the sqlite library). PocketConsole doesn't appear to use the standard integer values for stdout, etc. I'm not clear if ANSI enforce this standard or whether the constants 0,1, 2 are just a convention. Once I made the change above everything was hunky-dorey. I can't for-see any problems under Unix/Windows but I can't test/build sqlite[.exe] to confirm/prove this :-( Thanks, Chris #cfe8bd 275 code fixed 2003 Mar anonymous CodeGen 2003 Apr 3 5 "INSERT INTO x SELECT * FROM x" doesn't work when x is a TEMP table SQLite version 2.8.0 Enter ".help" for instructions sqlite> create temp table a(a); sqlite> insert into a values (1); sqlite> insert into a select * from a; SQL error: database table is locked On line 196 of insert.c, vdbe code already generated is searched for an OP_OpenTemp instruction. It should be OP_OpenAux. #c8c8c8 274 code closed 2003 Mar anonymous Unknown 2003 Apr 2 3 bug in sqlite_free_table Hello! I've discovered what I believe is bug in sqlite (I use version 2.8.0, for Linux, compiled from source). It looks like function sqlite_free_table is not working porperly. It doesn't nulify the pointer which I give to it; and if I call it twice with the same pointer it crash program with "Segmentation fault" message.... sqlite_free_table() works like the standard library function free(). It does not null its pointer (it can't because C uses call by value) and it fails if you call it twice with the same pointer. This is not a bug in SQLite - this is a bug in your program. #cfe8bd 270 code fixed 2003 Mar anonymous Unknown 2003 Apr 3 4 incorrect check for fcntl error code Reading through the Unix locking code, s (return code from fcntl) is being compared to EINVAL. s = fcntl(id->fd, F_SETLK, &lock); if( s!=0 ){ rc = (s==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY; This is incorrect; s will only ever be 0 or -1, and never be EINVAL (22 on most systems). I think the code means to say rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY; Duplication of ticket #240. #cfe8bd 266 new fixed 2003 Mar drh 2003 Apr 1 1 Make the VACUUM command work. The VACUUM command used to remove free space from the database file, back in version 1.0. Since version 2.0, VACUUM has been a no-op. The VACUUM command should be made functional again for version 2.0. #cfe8bd 240 code fixed 2003 Feb anonymous 2003 Apr 5 4 fcntl return code checked instead of errno When fcntl fails the return code is checked to determine whether to report SQLITE_BUSY or SQLITE_NOLFS. The return code should be used to determine whether the call succeeded or failed, but the specific error must be obtained from errno for this test to work: if( s!=0 ){ rc = (s==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY; should be changed to if( s!=0 ){ rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY; I only noticed this through code review as I investigated a deadlocking problem due to my own code, so I don't know of any specific problem outcome that could emerge from this problem. FYI only... Benjamin. See also ticket #270. #cfe8bd 234 code fixed 2003 Jan anonymous 2003 Apr 4 4 Impossibility to have Comments and DOT-Commands in an SQL-File This is a followup to Ticket #211, but I think, now I've found the real source of the problem. If a comment is immediately followed by a "DOT-Command" SQLite reports a syntax error : ----- Example : create table bar (foo integer);{linebreak} insert into bar values (42);{linebreak} -- This is a comment {linebreak} .echo off{linebreak} select max(foo) from bar;{linebreak} SQL error: near ".": syntax error #cfe8bd 194 new fixed 2002 Nov anonymous BTree 2003 Apr 5 3 Remove warnings in btree.c Please remove the annoying warnings in btree.c that appear when using the visual c++-compiler. You just have to change two lines in btree.c... Change line 64 to: #define SWAB16(B,X) ((B)->needSwab? swab16((u16)(X)) : ((u16)(X))) and line 520 to: pFBlk->iSize = swab16((u16)(swab16(pNext->iSize)+iSize+size)); (The casts to u16 are new.) The line numbers belong to the 2.7.3-release of sqlite - i am sure you will find these lines in your version... #cfe8bd 168 new fixed 2002 Oct anonymous Shell 2003 Apr 4 4 Startup file complicates dumping a database The example shown for dumping a database from the command line does not work if there is a startup file, since the first line of stdout contains the "Loading resources from ..." text. An option such as -dump that would supress this message would be useful. I had to write a shell script to rename the startup file before dumping. #cfe8bd 159 code fixed 2002 Oct anonymous Unknown 2003 Apr drh 2 2 Triggers don't work _at all_ in the presence autoincrement fields There's this mentioned caveat in the docs for triggers: Note that currently, triggers may behave oddly when created on tables with INTEGER PRIMARY KEY fields. If a BEFORE trigger program modifies the INTEGER PRIMARY KEY field of a row that will be subsequently updated by the statement that causes the trigger to fire, then the update may not occur. The workaround is to declare the table with a PRIMARY KEY column instead of an INTEGER PRIMARY KEY column. However, I'm having a different problem: create table work ( id integer primary key, foo varchar(20), last_change timestamp ); create trigger trig_work_insert after insert on work begin update work set last_change=timestamp() where id=new.id; end; insert into work (foo) values ('bar'); timestamp() is a custom Python function that I use from PySQLite. Now the strange thing is that the trigger is NOT called. It is called when I change the id column to "integer". That's a new kind of bug, right? #c8c8c8 85 todo closed 2002 Jun drh 2003 Apr 1 1 Document and test the sqlite_open_aux_file() API. The sqlite_open_aux_file() API needs to be documented and test cases for this API need to be added to the test suite. Overcome by events. The sqlite_open_aux_file() API has been removed. Equivalent functionality is now available using the ATTACH command. #c8c8c8 437 code closed 2003 Aug anonymous Unknown 2003 Aug 3 3 Wrong order for results of SELECT I have the following SQL Statement: CREATE TABLE uobject ( name varchar(255) default NULL, serial int(11) NOT NULL default '0', multis int(11) NOT NULL default '-1', pos_x smallint(6) NOT NULL default '0', pos_y smallint(6) NOT NULL default '0', pos_z smallint(6) NOT NULL default '0', pos_map tinyint(4) NOT NULL default '0', direction char(1) NOT NULL default '0', events varchar(255) default NULL, bindmenu varchar(255) default NULL, havetags tinyint(1) NOT NULL default '0', PRIMARY KEY (serial) ); I am querying this table and another one using this statement: SELECT uobject.name,uobject.serial,uobject.direction, uobject.multis,uobject.pos_x,uobject.pos_y, uobject.pos_z,uobject.pos_map,uobject.events, uobject.bindmenu,uobject.havetags FROM uobject,uobjectmap; And i am not using the column information returned by sqlite but assumed that actually the field order would matter but actually sqlite returned the fields in the order used when creating the table... I'm not sure what this bug report is saying. The columns in the result set of an SQLite query are determined by the SELECT statement, not by the original table definition. This is per SQL specs. I have verified this behavior. Unable to reproduce any problems. #c8c8c8 436 code closed 2003 Aug drh BTree 2003 Aug drh 1 1 In-memory database backend segfaults on recursive access The following code (using the TCL bindings) causes a segfault: sqlite db :memory: db eval { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); } db eval {SELECT rowid, x FROM t1} {} { db eval "DELETE FROM t1 WHERE rowid=$rowid" } The segfault only occurs using the in-memory backend. The file-based backend returns an error "database is locked" which is the correct behavior. #cfe8bd 435 code fixed 2003 Aug anonymous Unknown 2003 Aug 3 3 backslash in Makefile hides clean target at the end of the install target in the Makefile, there is an extra backslash, which continues the line, so that the clean target is not recognized. I am using HPUX 10.20 (yeah, I know its old) #cfe8bd 434 code fixed 2003 Aug anonymous 2003 Aug 3 3 vacuum-3.1 test fails on Win2k needs db2 close When running 'make test' on Win2k with mingw/msys the test vacuum-3.1 fails with an error "cannot delete file, permission denied." This seems to be because the file is still open. I added a line to vacuum-3.1 db2 close It seems to fix the problem, and 'make test' reports 0 errors. do_test vacuum-3.1 { db close db2 close file delete test.db sqlite db test.db execsql { PRAGMA empty_result_callbacks=on; VACUUM; } } {} #cfe8bd 432 code fixed 2003 Aug drh 2003 Aug 3 3 Returns "Disk I/O Error" when the filename is an empty string The shell command sqlite '' Gives an error as follows: Unable to open database "": disk I/O error The error of using an empty string as the database name should be caught sooner and a better error message should be returned. #c8c8c8 431 new closed 2003 Aug anonymous Shell 2003 Aug 5 4 possibility to use sql scripts in a file on the command line It would be nice if one could create a db from a script only with the commandline. syntax more or less like this: sqlite newdb.db .read scripts.sql (analog to: sqlite newdb.db .dump > backup.sqlbak) regards, Yves Glodt You can do this now, simply redirect the input to sqlite. For example; sqlite newdb.db error.log ---- The anonymous remarks above are correct. Another way to do it is like this: sqlite newdb.db '.read scripts.sql' ---- ok, thank you. this works in bash: sqlite newdb.db '.read scripts.sql' and this in cmd.exe: sqlite test.db error.log thank you! #cfe8bd 430 code fixed 2003 Aug drh 2003 Aug 1 1 Dropping a trigger with the same name as a table corrupts the database The following sequence of commands results in a corrupt database: create table t1(x unique); create trigger t1 before delete on t1 begin select raise(abort,'cannot delete'); end; drop table t1; Dropping a trigger that has the same name as a table also removes the table entry from the SQLITE_MASTER table. But it does not actually drop the table. The table just becomes inaccessible. After the above commands, nn assertion failure occurs if the next command is executed: pragma integrity_check; #cfe8bd 429 code fixed 2003 Aug anonymous 2003 Aug 1 2 os.h cygwin compilation patch Hi, I needed the attached patch on cygwin perl 5.8.0/cygwin-multi-64int to compile SQLite correctly. This holds true for perl DBD-SQLite-0.25, DBD-SQLite-0.26 and the current sqlite cvs version. gcc -c -I/usr/lib/perl5/site_perl/5.8.0/cygwin-multi-64int/auto/DBI -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -DUSEIMPORTLIB -O6 -DNDEBUG=1 -DSQLITE_PTR_SZ=4 -DVERSION=\"0.25\" -DXS_VERSION=\"0.25\" "-I/usr/lib/perl5/5.8.0/cygwin-multi-64int/CORE" os.c In file included from /usr/include/sys/types.h:363, from /usr/include/stdio.h:46, from vdbe.h:22, from sqliteInt.h:19, from os.c:18: /usr/include/cygwin/types.h:39: conflicting types for `off_t' os.h:123: previous declaration of `off_t' os.c:813: conflicting types for `sqliteOsSeek' os.h:159: previous declaration of `sqliteOsSeek' os.c: In function `sqliteOsSeek': os.c:821: warning: right shift count >= width of type os.c: At top level: os.c:892: conflicting types for `sqliteOsTruncate' os.h:161: previous declaration of `sqliteOsTruncate' os.c: In function `sqliteOsTruncate': os.c:899: warning: right shift count >= width of type os.c: At top level: os.c:921: conflicting types for `sqliteOsFileSize' os.h:162: previous declaration of `sqliteOsFileSize' os.c: In function `sqliteOsFileSize': os.c:935: warning: left shift count >= width of type make: *** [os.o] Error 1 /usr/include/cygwin/types.h: #ifndef __off_t_defined #define __off_t_defined typedef long __off32_t; typedef long long __off64_t; #ifdef __CYGWIN_USE_BIG_TYPES__ typedef __off64_t off_t; #else typedef __off32_t off_t; #endif #endif /*__off_t_defined*/ sqlite patch (apply with patch -p1 < ...) --- DBD-SQLite-0.25/os.h.orig 2003-02-17 08:40:52.000000000 +0100 +++ DBD-SQLite-0.25/os.h 2003-07-25 14:40:09.000000000 +0200 @@ -109,6 +109,9 @@ #endif #if OS_WIN +# ifdef __CYGWIN__ +# define __CYGWIN_USE_BIG_TYPES__ +# endif #include #include typedef struct OsFile OsFile; @@ -119,8 +122,10 @@ # if defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 off_t; # else +# ifndef _CYGWIN_TYPES_H typedef long long off_t; # endif +# endif # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) # define SQLITE_MIN_SLEEP_MS 1 #endif #f2dcdc 428 new active 2003 Aug anonymous TclLib 2003 Aug drh 5 5 missing prepare/fetch functions to be compatible with other DBs 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. #cfe8bd 427 code fixed 2003 Aug anonymous Unknown 2003 Aug 2 2 access violation on vacuum with pragma empty_result_callbacks Hello, How are you today? The subject of my mail is...a bug report with correction (to be validate by you of course). In summary, access violation occurs when vacuum command is run and pragma empty_result_callbacks is on. The problem is easily reproducable (just enter the pragma command and then vacuum and it crashes) and comes from the fact that the callback is always called once due to the pragma. When the callback is called, the third argument (argv) is null (as defined in the documentation). Oups! we found the problem => callback functions used in the vacuum code don't take this possibility into account. Here is the code (where I've already corrected the problems, just see the comments) sqliteVacuum ... rc = sqlite_exec(db, "SELECT type, name, sql FROM sqlite_master " "WHERE sql NOT NULL", vacuumCallback1, &sVac, &zErrMsg); => if there is no database created then vacuumCallback1 will be called with argv = 0 static int vacuumCallback1(void *pArg, int argc, char **argv, char **NotUsed) { vacuumStruct *p = (vacuumStruct*)pArg; /* int rc = 0; use #define instead */ int rc = SQLITE_OK; assert( argc==3 ); /* true */ /* assert( argv[0]!=0 ); not true if empty_result_callbacks is ON * * assert( argv[1]!=0 ); not true if empty_result_callbacks is ON * * assert( argv[2]!=0 ); not true if empty_result_callbacks is ON */ if (argv == 0) /* take into account empty_result_callbacks */ return rc; rc = execsql(p->pParse, p->dbNew, argv[2]); if( rc==SQLITE_OK && strcmp(argv[0],"table")==0 ){ char *zErrMsg = 0; p->s1.nUsed = 0; appendText(&p->s1, "SELECT * FROM ", -1); appendQuoted(&p->s1, argv[1]); p->zTable = argv[1]; rc = sqlite_exec(p->dbOld, p->s1.z, vacuumCallback2, p, &zErrMsg); if( rc && p->pParse->zErrMsg==0 ){ sqliteErrorMsg(p->pParse, "%s", zErrMsg); } } return rc; } => if there is at least one database created but with no row then vacuumCallback2 is called...with argv = 0 static int vacuumCallback2(void *pArg, int argc, char **argv, char **NotUsed) { vacuumStruct *p = (vacuumStruct*)pArg; /* int rc = 0; use #define instead */ int rc = SQLITE_OK; const char *zSep = "("; int i; if (argv == 0) /* take into account empty_result_callbacks */ return rc; => and finally, when the temporary database is initialised, it receives also argv = 0 static int sqliteInitCallback(void *pInit, int argc, char **argv, char **azColName) { InitData *pData = (InitData*)pInit; Parse sParse; int nErr = 0; if (argv == 0) /* take into account empty_result_callbacks */ return nErr; assert( argc==5 ); ... I've not tried to enter the vacuumCallback3 but I think it's the same problem. So, may I ask you to have a look to the solution to implement. I've done some changes in the code but I'm not sure if it's really correct. Moreover, the other simpler solution would be to force the pragma empty_result_callback to OFF at start of sqliteVacuum and reset it to the previous value at the end of the function. Enjoy :) Dobedo Waremme/Belgium Apparently, I've discovered another access violation when exiting the application. I've not yet pointed out the faulty instruction. Come to you soon. #f2dcdc 425 new active 2003 Aug anonymous VDBE 2003 Aug 5 3 Datetime enhancements: fractional seconds, addmonth 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(,*12). e #f2dcdc 424 new active 2003 Aug anonymous Shell 2003 Aug 4 3 Provide access to internal function _all_whitespace() 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. #cfe8bd 421 code fixed 2003 Aug anonymous 2003 Aug 3 3 bug on sqliteRealloc_ The variable p can be used before being initialized (but only on memory corruption). The code to change is at line 163, file 'util.c': 150 void *sqliteRealloc_(void *oldP, int n, char *zFile, int line){ 151 int *oldPi, *pi, i, k, oldN, oldK; 152 void *p; 153 if( oldP==0 ){ 154 return sqliteMalloc_(n,1,zFile,line); 155 } 156 if( n==0 ){ 157 sqliteFree_(oldP,zFile,line); 158 return 0; 159 } 160 oldPi = oldP; 161 oldPi -= N_GUARD+1; 162 if( oldPi[0]!=0xdead1122 ){ 163*** fprintf(stderr,"Low-end memory corruption in realloc at 0x%x\n", (int)p); *** 164 return 0; 165 } Probably a copy/paste error made on CheckIn 1067. #cfe8bd 419 new fixed 2003 Jul anonymous 2003 Aug 4 3 Return index name with 'uniqueness constraint failed' error message I am proposing the following (simple) code changes to display the unique index name as part of the uniqueness constraint failed error message. My proposal consists of the following code changes to insert.c:{linebreak} Replace Line 820 and 821 (currently): sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);{linebreak} sqliteVdbeChangeP3(v, -1, "uniqueness constraint failed", P3_STATIC);{linebreak} be replaced with: char *zMsg = 0;{linebreak} sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);{linebreak} sqliteSetString(&zMsg, pIdx->zName, " uniqueness constraint failed", 0);{linebreak} sqliteVdbeChangeP3(v, -1, zMsg, P3_DYNAMIC); #c8c8c8 417 code closed 2003 Jul anonymous Unknown 2003 Aug 4 4 Resultset differs between ..LIMIT 20 OFFSET 100 and ..LIMIT 20, 100 I tried some simple queries with the commandline interface (RPM version 2.8.5). When using the LIMIT clause I realized different resultsets. As I understood the documentation using ...LIMIT 20 OFFSET 100 should return exactly the same resultset as using ...LIMIT 20, 100 "LIMIT 20 OFFSET 100" is the same as "LIMIT 100,20". See ticket #245. #c8c8c8 376 code closed 2003 Jul anonymous BTree 2003 Aug 2 3 btree-1.1.1...../src/btree.c:2687: failed assertion `pPage->isInit' Failed test: "make test" btree-1.1.1...../src/btree.c:2687: failed assertion `pPage->isInit' Also experienced bigfile-1.1... Ok **** Unable to create a file larger than 4096 MB. ***** bigrow-1.0... Ok Don't know is the a bug or not. Running on OS X 10.2.6 (Darwin). During normal operations things seem to be OK so I don't know how worried I should be with this failed test. I would be happy to run the tests in gdb if that would help. Just tell me how to start up the tests from w/in gdb. Thanks, Jason This is a duplicate of ticket #369. See that ticket for the resolution. #cfe8bd 373 code fixed 2003 Jul anonymous 2003 Aug 1 2 2.8.4 Cygwin compile failure Under W2k / Cygwin latest (www.cygwin.com) with gcc 3.2; 2.8.4 fails to compile. Error log says: gcc -DOS_UNIX=0 -DOS_WIN=1 -DHAVE_USLEEP=1 -I. -I/usr/src/build/sqlite/sqlite-2.8.4/src -c -DTEMP_STORE=1 /usr/src/build/sqlite/sqlite-2.8.4/src/main.c -DDLL_EXPORT -DPIC -o .libs/main.lo In file included from /usr/src/build/sqlite/sqlite-2.8.4/src/main.c:20: /usr/src/build/sqlite/sqlite-2.8.4/src/os.h:91:1: warning: "OS_WIN" redefined /usr/src/build/sqlite/sqlite-2.8.4/src/main.c:1:1: warning: this is the location of the previous definition In file included from /usr/src/build/sqlite/sqlite-2.8.4/src/main.c:20: /usr/src/build/sqlite/sqlite-2.8.4/src/os.h:156: parse error before "OsFile" /u Full log is in attachment jari.aalto@poboxes.com Looks like configure is fooled. In the makefile try: TCC = gcc -g -O2 -DOS_UNIX=1 -DOS_WIN=0 -DHAVE_USLEEP=1 -I. -I${TOP}/src Becuase windows cannot lock on files in os.c add: #define fcntl(A,B,C) 0 You will still get three errors in 'make test' bigfile-1.2... Error: database disk image is malformed copy-6.1... Expected: [11 22 33 22 33 44 33 44 55 44 55 66 55 66 77 66 77 88] Got: [11 22 33 22 33 44] expr-6.75... Ok skipping tests of GLOB operator: unknown encoding "iso8859-1" 3 errors out of 25586 tests Failures on these tests: attach-5.1 bigfile-1.2 copy-6.1 but it runs. Just be aware there are no file locks, ie single user. #cfe8bd 357 code fixed 2003 Jun anonymous Pager 2003 Aug drh 4 3 Compilation errors and warnings when compiled on Open VMS Problems in insert.c and func.c. One warning is an undefined variable which may be meant to do something important. #cfe8bd 349 code fixed 2003 Jun anonymous 2003 Aug 3 2 Cygwin build errors The build on cygwin fails. 1) The auto generated Makefile defines OS_UNIX=0, so the #ifndef on line 65 of os.h fails and the #else part on line 95 is the one processed. Fix: Delete OS_UNIX=0 from the compiler options. 2) The cygwin system types already define off_t, but if __CYGWIN_USE_BIG_TYPES__ is not defined, off_t is a 32 bits offset. Fix: Define __CYGWIN_USE_BIG_TYPES__ on the compiler options. I don't know nothing of autoconf so I don't know how to fix this (but I belive it should be a quick fix). #cfe8bd 327 code fixed 2003 May anonymous 2003 Aug 1 1 Cygwin 1.3.22 compile failure Latest CVS (co 2003-05-29) SQLite build fails under current Cygwin 1.3.22/Windows 2000, sp3. Details of the build are in the attachments #cfe8bd 322 code fixed 2003 May anonymous 2003 Aug 3 3 Configure problem with ming32 on win32 (XP) and all sqlite version When you launch configure script , setting for OS are OS_WIN=0 and OS_UNIX=1. This is wrong and compilation abort on os.c. In configure i just modify before TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=$OS_UNIX -DOS_WIN=$OS_WIN" case test in order to test os_type with ming32 (like for cygwin ). Moreover , as OS_* is defined , error appear in os.h because OS_WIN and OS_UNIX are already defined. #cfe8bd 316 code fixed 2003 May anonymous Unknown 2003 Aug 2 3 Cygwin with gcc V2.95.3 compilation -- os.h Cygwin using gcc V2.95.3 won't compile because the off_t and OS_xxx definitions are wrong. My patch to os.h below addresses this by including /usr/include/cygwin/types.h under Cygwin, using Cygwin's off_t, and by not redefining OS_WIN and OS_MAC if they are already defined during the build. These changes allow SQLite V2.8.0 to compile, along with compiling the embedded version of SQLite V2.8.0 included in the Perl DBI driver DBD::SQLite. == Mark Leighton Fisher (mark-fisher@mindspring.com) == PATCH: *** os.h.orig Mon Feb 17 03:40:51 2003 --- os.h Fri May 16 07:26:12 2003 *************** *** 18,23 **** --- 18,32 ---- #define _SQLITE_OS_H_ /* + ** Handle Cygwin specially for off_t. + */ + #ifdef __CYGWIN__ + #ifndef _CYGWIN_TYPES_H + #include "/usr/include/cygwin/types.h" + #endif + #endif + + /* ** These #defines should enable >2GB file support on Posix if the ** underlying operating system supports it. If the OS lacks ** large file support, or if the OS is windows, these should be no-ops. *************** *** 82,90 **** --- 91,104 ---- # define OS_UNIX 0 # endif #else + #ifndef OS_MAC # define OS_MAC 0 + #endif + #ifndef OS_WIN # define OS_WIN 0 #endif + #endif + /* ** A handle for an open file is stored in an OsFile object. *************** *** 119,126 **** --- 133,144 ---- # if defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 off_t; # else + # if defined(__CYGWIN__) + /* use from types.h */ + # else typedef long long off_t; # endif + # endif # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) # define SQLITE_MIN_SLEEP_MS 1 #endif #cfe8bd 213 new fixed 2003 Jan anonymous Unknown 2003 Aug 4 4 Cygwin port needs __CYGWIN_USE_BIG_TYPES__ defined When building on the cygwin platform, an incompatible typedef of 'off_t' is made in src/os.h at line 92 (the clash is with /usr/include/cygwin/types.h at line 27. The cygwin type is to '__off32_t' which is 'long'. The sqlite type is 'long long'. However, if __CYGWIN_USE_BIG_TYPES__ is defined upon processing of /usr/include/cygwin/types.h, the declarations match (both are 'long long'). A workaround is simply to add '#define __CYGWIN_USE_BIG_TYPES__' to either the makefile options or the top of sqliteInt.h. Thanks Sorry, this is incorrect. I reran the configure script and ran make on the resulting makefile under cygwin and the build ran completely perfectly. ---- I have not been able to successfully make sqlite under cygwin _: a. No success on the command line, even after adding __CYGWIN_USE_BIG_TYPES__ in the Makefile _: b. No success in the DBD::SQLite install using the CPAN shell. Same symptoms: _: In file included from main.c:20: os.h:122: conflicting types for `off_t' /usr/include/cygwin/types.h:39: previous declaration of `off_t' Environment is a fresh install of the latest cygwin: $ uname -a CYGWIN_NT-5.0 host040 1.3.22(0.78/3/2) 2003-03-18 09:20 i686 unknown unknown Cygwin --Derek Lane #c8c8c8 23 code closed 2002 Apr anonymous 2003 Aug drh 1 1 FieldName Returned Not Correct When Use Fast-East Chararctor Set When SqlText = 'Select RowId, SC;'C{, C\Bk From Test'; SQLite_GetTable; The Return FieldName not Equal Above FieldName in Select StateMent Unable to reproduce. UTF-8 field names are returned correctly in my tests. "SQLite_GetTable" is not an SQLite API function. Could it be that you are using a third-party wrapper library (for VB, Perl, or Python) that is causing the problem? #c8c8c8 543 new closed 2003 Dec anonymous 2003 Dec 5 4 Feature Request: Indicate NOT NULL columns in table_info. It would be neat if there were a new column added to table_info that indicated which columns of a table were NOT NULL. The fourth column of the results set from the table_info pragma is non-zero for NOT NULL columns. #cfe8bd 542 code fixed 2003 Dec anonymous Parser 2003 Dec 1 1 crash on date parsing while running the following sql statement: SELECT coalesce(date('2003-10-22','weekday 0'),'NULL'); I crashed with the following stack:
  parseModifier  isDate  dateFunc  sqliteVdbeExec  sqliteExec  yy_reduce  sqliteParser  sqliteRunParser  sqliteMain  sqlite_exec  
The reason is that the code is running on both strings for 29 characters while the parameter is much shorter.
  static int parseModifier(const char *zMod, DateTime *p){    int rc = 1;    int n;    double r;    char z[30];    for(n=0; n	
#cfe8bd	541	code	fixed	2003 Dec	anonymous		2003 Dec	drh	1	1	Compile error in os.c	Check-in [1149] introduce a compile error on unix and mac os, by running a statement before variable declaration (during normal build). The following patch corrects the problem:    
  --- os.orig     Wed Dec 31 16:38:24 2003  +++ os.c        Wed Dec 31 16:35:05 2003  @@ -39,6 +39,7 @@      #if OS_WIN   # include   +#include    #endif      #if OS_MAC  @@ -1441,6 +1442,8 @@   ** supply a sufficiently large buffer.   */   int sqliteOsRandomSeed(char *zBuf){  +  int pid;  +  memset(zBuf, 0, 256);     /* We have to initialize zBuf to prevent valgrind from reporting     ** errors.  The reports issued by valgrind are incorrect - we would     ** prefer that the randomness be increased by making use of the  @@ -1453,9 +1456,7 @@     ** that we always use the same random number sequence.* This makes the     ** tests repeatable.     */  -  memset(zBuf, 0, 256);   #if OS_UNIX && !defined(SQLITE_TEST)  -  int pid;     time((time_t*)zBuf);     pid = getpid();     memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid));  @@ -1464,7 +1465,6 @@     GetSystemTime((LPSYSTEMTIME)zBuf);   #endif   #if OS_MAC  -  int pid;     Microseconds((UnsignedWide*)zBuf);     pid = getpid();     memcpy(&zBuf[sizeof(UnsignedWide)], &pid, sizeof(pid));  
Related #535 #f2dcdc 540 event active 2003 Dec drh 2003 Dec 1 5 Database corruption observed 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... #f2dcdc 539 new active 2003 Dec anonymous VDBE 2003 Dec 5 4 Addition of engine 'Suspension' interface 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. #f2dcdc 538 new active 2003 Dec anonymous 2003 Dec 4 3 Different warnings in windows 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; jn)==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 #c8c8c8 537 code closed 2003 Dec anonymous VDBE 2003 Dec 1 2 Problems using sqlite_bind() with INSERT INTO ... SELECT statements Precompiled INSERT INTO ... SELECT statements which use sqlite_bind() to insert values seem to fail. Attached is a simple test program to demonstrate. I'm more than a little rusty with SQL, and new to sqlite, so it's entirely possible I'm doing this the wrong way. :)
  #include <assert.h>  #include <stddef.h>  #include <sqlite.h>    int main (void)  {    static const char * FILENAME = "/tmp/test.sqlite";    int tmp;    int sqlstate;    sqlite * db = NULL;    sqlite_vm * pVm = NULL;       /* create a new database */    unlink (FILENAME);    db = sqlite_open (FILENAME, 1, NULL);    sqlstate = sqlite_exec (db, "CREATE TABLE department ( name TEXT NOT NULL );", NULL, NULL, NULL);    assert (SQLITE_OK == sqlstate);    sqlstate = sqlite_exec (db, "CREATE TABLE professor ( name TEXT NOT NULL, department_id INTEGER NOT NULL );", NULL, NULL, NULL);    assert (SQLITE_OK == sqlstate);       /* add some departments */    sqlstate = sqlite_exec (db, "INSERT INTO department VALUES ('history');", NULL, NULL, NULL);    assert (SQLITE_OK == sqlstate);    sqlstate = sqlite_exec (db, "INSERT INTO department VALUES ('english');", NULL, NULL, NULL);    assert (SQLITE_OK == sqlstate);    assert (sqlite_last_insert_rowid(db) == 2); /* two rows added */    tmp = sqlite_last_insert_rowid (db);       /* precompile an insert statement */    sqlstate = sqlite_compile (db, "INSERT INTO professor SELECT '?', department.ROWID FROM department WHERE department.name='?'", NULL, &pVm, NULL);    assert (SQLITE_OK == sqlstate);       /* insert via the precompiled statement */    sqlite_bind (pVm, 1, "Bob Jones", -1, 0);    sqlite_bind (pVm, 2, "history", -1, 0);    sqlstate = sqlite_step (pVm, NULL, NULL, NULL);    assert (SQLITE_DONE == sqlstate);    assert (tmp != sqlite_last_insert_rowid (db)); /* this assert fails -- sqlite_step() didn't insert anything */       sqlite_finalize (pVm, NULL);    sqlite_close (db);    return 0;  }  
You are doing it wrong. '?' Is a string literal. A bindable parameter is a question mark that is not contained inside single quotes. Works as designed. no changes to code. #c8c8c8 536 code closed 2003 Dec anonymous Pager 2003 Dec 1 1 Syscall param write(buf) contains unaddressable byte(s) Wrong memory access. This is a general library problem. To reproduce: 1: Run valgrind like so: valgrind --num-callers=16 sqlite some.db 2: Run any database change SQL statement on the sqlite command line 3: For instance: create table X(Y varchar(20) primary key); or insert into X values('blabla'); or update(...) The stack trace generated by valgrind:
  ==10597== Syscall param write(buf) contains uninitialised or unaddressable byte(s)  ==10597==    at 0x420DAE54: __libc_write (in /lib/i686/libc-2.2.5.so)  ==10597==    by 0x804D48A: sqliteOsWrite (./src/os.c:866)  ==10597==    by 0x8065F48: pager_write_pagelist (./src/pager.c:1155)  ==10597==    by 0x8066FC0: sqlitepager_commit (./src/pager.c:1904)  ==10597==    by 0x8056D20: fileBtreeCommit (./src/btree.c:906)  ==10597==    by 0x8072ECC: sqliteVdbeExec (./src/vdbe.c:2269)  ==10597==    by 0x805B660: sqliteExec (./src/build.c:97)  ==10597==    by 0x80678A0: yy_reduce (in /home/hauk/bin/sqlite)  ==10597==    by 0x8069139: sqliteParser (parse.c:3946)  ==10597==    by 0x804F90E: sqliteRunParser (./src/tokenize.c:450)  ==10597==    by 0x804C8EA: sqliteMain (./src/main.c:631)  ==10597==    by 0x804CA35: sqlite_exec (./src/main.c:681)  ==10597==    by 0x804B1CF: process_input (./src/shell.c:1038)  ==10597==    by 0x804BA83: main (./src/shell.c:1329)  ==10597==  Address 0x41718319 is 861 bytes inside a block of size 1364 alloc'd  ==10597==    at 0x40027CA6: malloc (vg_replace_malloc.c:160)  ==10597==    by 0x804FCD1: sqliteMallocRaw (./src/util.c:268)  ==10597==    by 0x8066155: sqlitepager_get (./src/pager.c:1279)  ==10597==    by 0x805783D: moveToChild (./src/btree.c:1392)  ==10597==    by 0x8057B2A: moveToRightmost (./src/btree.c:1510)  ==10597==    by 0x8057C22: fileBtreeLast (./src/btree.c:1551)  ==10597==    by 0x8073E18: sqliteVdbeExec (./src/vdbe.c:2872)  ==10597==    by 0x805B660: sqliteExec (./src/build.c:97)  ==10597==    by 0x80678A0: yy_reduce (in /home/hauk/bin/sqlite)  ==10597==    by 0x8069139: sqliteParser (parse.c:3946)  ==10597==    by 0x804F90E: sqliteRunParser (./src/tokenize.c:450)  ==10597==    by 0x804C8EA: sqliteMain (./src/main.c:631)  ==10597==    by 0x804CA35: sqlite_exec (./src/main.c:681)  ==10597==    by 0x804B1CF: process_input (./src/shell.c:1038)  ==10597==    by 0x804BA83: main (./src/shell.c:1329)  
  > This is a bug in valgrind.  The section of the SQLite library  > identified works exactly as it should.  All parameters to the  > write() function are fully and correctly initialized.  
FYI: I Reported this back to the valgrind maintainers and got this reply: http://bugs.kde.org/show_bug.cgi?id=71523 #c8c8c8 535 code closed 2003 Dec anonymous Unknown 2003 Dec 1 1 Use of uninitialised value of size 4 The problem is reported by valgrind and may indicate a real problem. To reproduce the error, run the sqlite utility from valgrind like so: valgrind -v --leak-check=yes --leak-resolution=high --num-callers=16 \ --freelist-vol=10000000 sqlite some.db Then excute any SQL-statement at the sqlite command line, e.g.: begin transaction; The problem is in the library and is not particularly to sqlite. Here's a stack trace (there is also a memory leak but it's not important for this error report) Stack trace from the example run above:
  ==3746== Use of uninitialised value of size 4  ==3746==    at 0x804EE3D: randomByte (./src/random.c:70)  ==3746==    by 0x804EF02: sqliteRandomInteger (./src/random.c:107)  ==3746==    by 0x80668AD: pager_open_journal (./src/pager.c:1560)  ==3746==    by 0x80669C2: sqlitepager_begin (./src/pager.c:1620)  ==3746==    by 0x8056CC9: fileBtreeBeginTrans (./src/btree.c:885)  ==3746==    by 0x8072DB6: sqliteVdbeExec (./src/vdbe.c:2224)  ==3746==    by 0x805B660: sqliteExec (./src/build.c:97)  ==3746==    by 0x80678A0: yy_reduce (parse.y:77)  ==3746==    by 0x8069139: sqliteParser (parse.c:3946)  ==3746==    by 0x804F90E: sqliteRunParser (./src/tokenize.c:450)  ==3746==    by 0x804C8EA: sqliteMain (./src/main.c:631)  ==3746==    by 0x804CA35: sqlite_exec (./src/main.c:681)  ==3746==    by 0x804B1CF: process_input (./src/shell.c:1038)  ==3746==    by 0x804BA83: main (./src/shell.c:1329)  ==3746==    by 0x42017588: __libc_start_main (in /lib/i686/libc-2.2.5.so)  ==3746==    by 0x8049190: (within /home/hauk/bin/sqlite)    [Supressed similar error stack traces]  
  > The uninitialized variable warning must be a bug in valgrind.  If  > you look in the random.c source file on line 70, you will clearly  > see that prng.s[] is initialized in the previous loop and that the  > index to prng.s[] (the value prng.j) must be in the range 0..255 due  > to the "& 0xff" in the previous statement.  
Actually valgrind is correct. The problem lies in os.c:sqliteOsRandomSeed. The code looks like this:
  int sqliteOsRandomSeed(char *zBuf){  #ifdef SQLITE_TEST    /* When testing, always use the same random number sequence.    ** This makes the tests repeatable.    */    memset(zBuf, 0, 256);  #endif  #if OS_UNIX && !defined(SQLITE_TEST)    int pid;    time((time_t*)zBuf);    pid = getpid();    memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid));  #endif  ....  
Clearly, the zBuf is _only_ cleared when SQLITE_TEST is defined, which it is *not* during normal build (and the memset is misplaced). Changing the code to:
  --- random.c    Wed Dec 31 03:56:58 2003  +++ random.diff Wed Dec 31 03:57:15 2003  @@ -60,6 +60,7 @@       char k[256];       prng.j = 0;       prng.i = 0;  +    memset(k, 0, 256);       sqliteOsRandomSeed(k);       for(i=0; i<256; i++){         prng.s[i] = i;  
Makes the problem go away and the k buffer properly initialized. Ps. You might want to reconsider and look into the other bug I reported based on the valgrind error report on writing unaddressable bytes :-) ------ This *is* a bug in valgrind. It reported the problem on random.c line 70 when in fact it meant to say line 69. Yes, there are parts of the k[] array that are uninitialized. But think about what k[] is suppose to hold - *random* data. Any portion of k[] that is not set by sqliteRandomSeed() might as well be uninitialized since that will increase the randomness. Initializing k[] to 0 removes the valgrind warning, but reduces the randomness of k[]. #cfe8bd 533 code fixed 2003 Dec anonymous 2003 Dec 2 1 Crash when using datetime() with a NULL value. isDate in date.c appears to crash when passed a NULL value. The problem can best be seen by issuing the following SQL: select datetime(NULL); I think a simple check for argv being NULL in isDate should do the trick. #c8c8c8 532 code closed 2003 Dec anonymous Parser 2003 Dec 2 3 crashes on gigantic query I'm generating a gigantic query with a for loop. With a query string of length 4,878, which asks for 109 columns, it works OK; extending the query by about 30 chars to 110 col.s causes SQLite to segfault. My debugger says the error is somewhere in SqliteParserAlloc, but I can't get further than that. I've looked for limitations listed in the documentation and could find none. Code sample available on request. Submitter reports the problem was in the application code, not in SQLite. #c8c8c8 531 code closed 2003 Dec anonymous 2003 Dec 4 4 INT is not treated the same as INTEGER The INT and INTEGER keywords should be functionally equivalent, but they aren't specifically when creating an auto-incrementing primary key. Works as designed. #cfe8bd 530 code fixed 2003 Dec anonymous Pager 2003 Dec 2 2 sqlite returns SQLITE_BUSY forever (linux multithreaded) sqliteOsReadLock() and sqliteOsUnlock() in the OS_UNIX def leave open the potential that a different thread will make the fcntl() UNLOCK call from the the thread that made the fcntl() LOCK call. [thread1] ReadLock()s with pLock->cnt=0: fcntl(LOCK); cnt++ [thread2] ReadLock()s with pLock->cnt=1: cnt++ [thread1] UnLock()s with pLock->cnt=2: cnt-- [thread2] UnLock()s with pLock->cnt=1: fcntl(UNLOCK); cnt=0 in linux thread2 can't fcntl(UNLOCK) thread1's lock what ends up happening is: a read lock is leaked! and any attempt to get a write lock from then on returns SQLITE_BUSY ive been using my own fix since 2.8.4 that gets a rdlock for each call to ReadLock() and unlocks for each call to Unlock() to avoid this problem. (i dont have repro steps but each time i ran my high-load application the db would become unusable in a few minutes) If this is true, then Linux is does not conform to the POSIX spec. This would technically be a bug in Linux, then, not in SQLite. Given the widespread use of linux, I suppose I'll have to invent some kind of work-around. ---- Works now on linux. Question is, did this break it for other unix systems. ---- The locks should now work on both linux and POSIX systems. I say "should" because I don't have any way to test non-linux unix systems. #cfe8bd 529 code fixed 2003 Dec drh 2003 Dec 1 1 An aborted update can corrupt the database The following sequence of SQL statements applied against a new database will result in a database file that is corrupt. The corruption can be seen using the "PRAGMA integrity_check" command. CREATE TABLE t(a UNIQUE,b); INSERT INTO t VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_'); UPDATE t SET b=b||b; UPDATE t SET b=b||b; UPDATE t SET b=b||b; UPDATE t SET b=b||b; UPDATE t SET b=b||b; INSERT INTO t VALUES(2,'x'); UPDATE t SET b=substr(b,1,500); BEGIN; UPDATE t SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y'; CREATE TABLE t2(x,y); COMMIT; The first group of statements constructs a database with a single table holding two entries. One of the two entries uses a single overflow page. There is a single page on the freelist. The UPDATE statement within the transaction processes row 1 of the table first. The long "b" column of that row is truncated, which causes the overflow page used to hold data for the "b" column to be moved onto the freelist. When the UPDATE statement continues to the second row, a constraint failure occurs which causes the statement to abort. The abort restores the content of the first row and remove the overflow page used to store "b" from the freelist on disk. But the overflow page is not removed from the freelist in the in-memory cache image that SQLite maintains of parts of the disk file. This omission - the failure to keep the in-memory cache synchronized with the disk - is the origin of the error. At this point, the in-memory cache has become corrupt. No harm would come of this if the transaction ended immediately because that would flush the cache. But since the transaction continues and the corrupt cache continues to be used instead of the correct data on disk, permanent database corruption can result. Because it is using the corrupt in-memory cache image of the database freelist, the CREATE TABLE statement within the transaction reuses the the overflow page from table t to be the root page of table t2. The same page is now being used for two different things at the same time. When the transaction commits, this corruption is written to disk and becomes permanent. The problem was introduced on 2003-Jan-29 by check-in [855]. This occurred in between release 2.7.6 and 2.8.0 so only the 2.8.0 through 2.8.7 should be effected by this problem. #c8c8c8 528 code closed 2003 Dec anonymous Unknown 2003 Dec 4 2 compiled c code shows queries in executable if you run `strings` against your outputted c program or shared library you can see all the sql queries. this may be a security risk for some people. ex: bash # strings my_prog 1: This is a programming language (C/C++) issue, not an SQLite issue. 2: It is impossible to construct a program which an advisary can read which cannot also be reverse engineered by that advisary. No changes to code. #cfe8bd 526 code fixed 2003 Dec anonymous 2003 Dec 1 1 Primary key not unique (database corruption?) Having many problems that look like indexing issues. We are seeing a primary key that is losing uniqueness among other things. Here is the sqlite_master table: select * from sqlite_master; table|version|version|3|CREATE TABLE version (version INT) table|message_log_meta_data|message_log_meta_data|5|CREATE TABLE message_log_meta_data ( name VARCHAR(32) PRIMARY KEY, value VARCHAR(128) ) index|(message_log_meta_data autoindex 1)|message_log_meta_data|4| table|message_log|message_log|7|CREATE TABLE message_log ( id VARCHAR(32) PRIMARY KEY, client VARCHAR(16), start_time INT, end_time INT, latency INT, time VARCHAR(32), log_time VARCHAR(32), msg_file VARCHAR(64), to VARCHAR(128), from_email VARCHAR(64), subject VARCHAR(128), tag VARCHAR(32), quarantine VARCHAR(32), virus_block VARCHAR(32), spam_block VARCHAR(32), spam_score FLOAT, disconnect VARCHAR(16), message_delivered VARCHAR(16), error VARCHAR(128), connect VARCHAR(64), debug_id VARCHAR(32), pu_quarantine VARCHAR(32), whitelist VARCHAR(32) ) index|(message_log autoindex 1)|message_log|6| index|start_time|message_log|105666|CREATE INDEX start_time ON message_log (start_time) index|to|message_log|108337|CREATE INDEX to ON message_log (to) index|latency|message_log|112359|CREATE INDEX latency ON message_log (latency) table|recipients|recipients|114339|CREATE TABLE recipients ( to VARCHAR(128) PRIMARY KEY, last_message_time INT ) index|(recipients autoindex 1)|recipients|114336| index|recipients_to|recipients|116279|CREATE INDEX recipients_to ON recipients (to) index|last_message_time|recipients|117212|CREATE INDEX last_message_time ON recipients (last_message_time) Note that "id" is the primary key of the "message_log" table. However, look at the following log: # sqlite /tmp/message.lite SQLite version 2.8.6 Enter ".help" for instructions sqlite> vacuum; SQL error: column id is not unique >>>>> How is this possible?? column "id" is a primary key.. sqlite> SELECT id FROM message_log GROUP BY id HAVING COUNT(1) > 1; 1071129925-32560-6-0 1071130020-32662-6-0 1071130053-32710-1-0 1070988099-22639-3-0 sqlite> DELETE FROM message_log WHERE id IN (SELECT id FROM message_log GROUP BY id HAVING COUNT(1) > 1); sqlite> SELECT id FROM message_log GROUP BY id HAVING COUNT(1) > 1; 1070988099-22639-3-0 >>>>> We just deleted these!! sqlite> SELECT id FROM message_log WHERE id ='1071130173-440-2-0' ; 1071130177-466-0-0 >>>>> Huh? sqlite> DELETE FROM message_log WHERE id ='1071130173-440-2-0'; sqlite> SELECT id FROM message_log WHERE id ='1071130173-440-2-0' ; 1071130177-466-0-0 >>>>> Still there... sqlite> vacuum; sqlite> SELECT id FROM message_log WHERE id ='1071130173-440-2-0' ; 1071130173-440-2-0 >>>>> Fixed!?! Please download the test database from: http://205.158.110.60/sqlite Probably the same as ticket #529. #f2dcdc 525 new active 2003 Dec anonymous 2003 Dec 4 4 DB testing 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 #f2dcdc 524 new active 2003 Dec anonymous Unknown 2003 Dec 2 1 port of sqlite to dos with short file names 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. #c8c8c8 522 code closed 2003 Dec anonymous Unknown 2003 Dec 1 1 Error in comparision equal and less-equal To whom it may concern, there is a inconsistent tuple given terface adding patch-sets, bug tracking, and Wiki to CVS. http://www.hwaci.com/sw/cvstrac/. *: SQL Relay: A persistent database connection pooling, proxying and load balancing system with APIs for a wide range of programming languages. http://www.firstworks.com/ --> http://sqlrelay.sourceforge.net *: Zee Cookbook: A cookbook application for Sharp Zaurus PDA. hb interface adding patch-sets, bug tracking, and Wiki to CVS. http://www.hwaci.com/sw/cvstrac/. *: SQL Relay: A persistent database connection pooling, proxying and load balancing system with APIs for a wide range of programming languages. http://www.firstworks.com/ --> http://sqlrelay.sourceforge.net *: Zee Cookbook: A cookbook application for Sharp Zaurus PDA. h #cfe8bd 520 code fixed 2003 Dec anonymous Parser 2003 Dec drh 2 2 tokenize bug in simultaneous threaded sqlite_open (with patch) Bug with patch: To check if the keyword hash table is already initialized, sqliteKeywordCode method checks the len of the first element...{linebreak} If set, it thinks the hash is initialized... it's wrong.{linebreak} The method must test the last element to be sure another process is not still generating hash values. Here is a possible patch: ----------------------------------------------------------- -- CUT HERE -- --- tokenize.wrong.c 2003-09-27 15:39:39.000000000 +0200 +++ tokenize.c 2003-12-10 14:39:17.000000000 +0100 @@ -155,13 +155,12 @@ int sqliteKeywordCode(const char *z, int n){ int h; Keyword *p; + int aKeywordTableSz = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]); - if( aKeywordTable[0].len==0 ){ + if( aKeywordTable[ aKeywordTableSz ].len==0 ){ /* Initialize the keyword hash table */ sqliteOsEnterMutex(); if( aKeywordTable[0].len==0 ){ int i; - int n; - n = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]); - for(i=0; i NUL (ASCII 0) \' \" \b \n \r \t \\ \z #c8c8c8 516 code closed 2003 Dec anonymous Parser 2003 Dec 1 1 unrecognized token error when a string contains a \' escape sequence When .read[ing] a file with sqlite.exe on a Win2k Pro box that was produced with phpmyadmin containing a single quote escape (\') within a single-quoted string, an "unrecognized token" error occurs. It appears the case '\'': in tokenize.c is failing -- seems it should be double-quoted as case "\'": Backslash quoting is a C-language convention. It does not work in SQL. In SQL you double the quotes. Ex: 'That''s all folk!' ^^ No code changes. Works as designed. #cfe8bd 515 code fixed 2003 Dec anonymous Unknown 2003 Dec 4 3 VACUUM fails after dependent table DROP,CREATE sequence see this test script for example: CREATE TABLE Test (TestID int primary key); INSERT INTO Test VALUES (NULL); CREATE VIEW viewTest AS SELECT * FROM Test; BEGIN; CREATE TEMP TABLE tempTest (TestID int primary key, Test2 int NULL); INSERT INTO tempTest SELECT TestID, 1 FROM Test; DROP TABLE Test; CREATE TABLE Test(TestID int primary key, Test2 int NULL); INSERT INTO Test SELECT * FROM tempTest; COMMIT; VACUUM; -- this fails with message "SQL error or missing database. no such table: main.Test" #c8c8c8 513 code closed 2003 Dec anonymous 2003 Dec 2 3 C++-style comments prevent compilation I tried to install DBD::SQLite (perl module) on my AIX box. The install fails because the AIX compiler rejects dbdimp.c because it has // comments in it, which are not allowed in C code. cc -c -I/usr/local/perl-5.6.1/lib/site_perl/5.6.1/aix/auto/DBI -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=16384 -I/usr/local/include -q32 -D_LARGE_FILES -qlonglong -O6 -DNDEBUG=1 -DSQLITE_PTR_SZ=4 -DVERSION=\"0.28\" -DXS_VERSION=\"0.28\" -I/usr/local/perl-5.6.1/lib/5.6.1/aix/CORE dbdimp.c cc: 1501-216 command option 6 is not recognized - passed to ld "/usr/local/perl-5.6.1/lib/site_perl/5.6.1/aix/auto/DBI/dbipport.h", line 43.43: 1506-342 (W) "/*" detected in comment. "dbdimp.c", line 389.5: 1506-046 (S) Syntax error. "dbdimp.c", line 390.5: 1506-046 (S) Syntax error. make: 1254-004 The error code from the last command is 1. This appears to be a perl or DBD:SQLite error. The dbdimp.c file is not a part of the SQLite core. #c8c8c8 512 code closed 2003 Dec anonymous Parser 2003 Dec 2 2 order by clause is not ordering data properly in aggregate functions order by clause is not ordering data properly in aggregate functions There are dozens and dozens of tests in the regression test suite for SQLite that check that ORDER BY is working properly on queries that contain aggregates. All of those tests pass. Perhaps the person who submitted this ticket could provide a specific example of a case that he thinks is not being sorted correctly. Until then, there isn't much we can do to "fix" the problem. Works as designed. No changes to code. ---- _The original poster writes:_ After trying long and hard to come up with an example to pass on to you I've decided that it would be best to explain the problem in more detail instead. Here I go. I have an SQLite database that I frequently do insert replace on one particular table. I have also created a few aggregate functions that do specific math operations on values in that table. These math functions operated on ordered data (order by field clause). I noticed that my aggregate functions were not returning expected data so I decide to create an aggregate function that simply echoed the argv[0] value of the aggregate step function. To my surprise the value that is sometimes echoed did not match the order of the value that showed up when I did the same select without the aggregate function and the order by field clause. As I said I have verify the problem, the problem does not show up all the time and aggregate functions that do not care about the ordering of data (for example min, max, etc) do not exhibit the problem. ---- _drh replies:_ The ORDER BY applies to the output of the query, not the input. So (for example) if you say: SELECT count(*), type FROM table GROUP BY type ORDER BY 1; The aggregate function runs first to compute a new virtual table of two columns where the first column is a count and the second column is "type". Then the sort occurs on the new virtual table to order the output by count. If you want to order the input, you have to do that with a subquery: SELECT count(*), type FROM (SELECT type FROM table ORDER BY 1) GROUP BY 2; #f2dcdc 503 warn active 2003 Nov anonymous Unknown 2003 Dec anonymous 5 2 Include sqlite source in Visual C++ 6.0 SP5 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(?). #cfe8bd 482 code fixed 2003 Oct anonymous BTree 2003 Dec 1 1 SIGSEGV inside memRbtreeNext (gdb) bt #0 memRbtreeNext (pCur=0x835ed88, pRes=0x835c6a0) at src/btree_rb.c:1052 #1 0x41284d8e in sqliteVdbeExec (p=0x82f81d0) at src/vdbe.c:4414 #2 0x41257c3c in sqliteExec (pParse=0xbffff020) at src/build.c:95 #3 0x4126c66f in yy_reduce (yypParser=0x82f81d0, yyruleno=5) at parse.y:77 #4 0x4126c272 in sqliteParser (yyp=0x82b9e50, yymajor=107, yyminor= {z = 0x835c6a0 " ü1\belations.origin may not be NULL", dyn = 0, n = 546637480}, pParse=0x4e206562) at parse.c:7017 #5 0x412771e9 in sqliteRunParser (pParse=0xbffff020, zSql=0x8193fb4 "SELECT sid, weight FROM 'Recent' WHERE time < '1066861751';", pzErrMsg=0x81920ac) at src/tokenize.c:452 #6 0x4126746a in sqliteMain (db=0x81961f8, zSql=0x8193fb4 "SELECT sid, weight FROM 'Recent' WHERE time < '1066861751';", xCallback=0x4e206562, pArg=0x4e206562, pzTail=0x0, ppVm=0x0, pzErrMsg=0x81920ac) at src/main.c:630 #7 0x412665ed in sqlite_exec (db=0x4e206562, zSql=0x4e206562
, xCallback=0x4e206562, pArg=0x4e206562, pzErrMsg=0x4e206562) at src/main.c:680 #8 0x4118b143 in SqlDb::select_query(std::string const&, int (SqlDb::*)(int, char**)) ( this=0x81920a0, query=@0xbffff160, callback= {__pfn = 0x4118672e , __delta = 0}) at sqldb.cc:91 Not sure what is happening here. I am hoping that maybe you can give me some insight into what could be causing this. The only guess that I have is that it could be caused by the way I use callbacks. I do something like: "SELECT uid FROM WHERE ;" and then inside the callback, I do a "DELETE FROM WHERE uid = '';" In essence removing the element for which the callback is currently in progress (of course there's other processing happening as well... otherwise I could just do a delete in the first place). Is this not an acceptable practice? Output of 'backtrace full' is available upon request. #f2dcdc 477 new active 2003 Oct anonymous 2003 Dec anonymous 4 4 Are there any plans to enchance SQLite to support Unicode 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. #c8c8c8 464 code closed 2003 Sep anonymous 2003 Dec 2 2 VACUUM doesn't compile with sqlite_compile Hello, When trying to compile (with sqlite_compile) the following query "VACCUM;" the function returns SQLITE_ERROR. Running VACCUM with sqlite_exec is working fine. I was not able to find where the problem was exactly, but I can say that a lot of processing is done correctly. I would say that somewhere an error code is set erroneously but without being able to confirm it. Kind regards Valere Monseur aka dobedo. Fixed. #cfe8bd 452 code fixed 2003 Sep anonymous TclLib 2003 Dec 4 3 DbMain assumes sscanf likes 0x... syntax for pointers, breaking tests DbMain in src/tclsqlite.c ensures that its result always starts with 0x, which is a problem on some systems (such as Solaris) that treat everything from the x on as garbage and parse the pointer as NULL. As a result, certain tests (starting with capi2-1.1) end up segfaulting. I ended up simply #if-ing out the relevant three lines, but a better fix would be to adopt something like the logic in makePointerStr in src/test1.c; I'd even suggest giving libtclsqlite a public C interface containing at minimum a sane pointer->string converter (and its inverse?), since I see several more hardcoded occurrences of "0x", some of which are doubly nonportable by using "%x" as the format directive and assuming that casting from pointers to ints loses no information. #f2dcdc 445 build active 2003 Sep anonymous Unknown 2003 Dec anonymous 3 1 Compilation problem on MinGW 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 #cfe8bd 444 code fixed 2003 Sep anonymous Shell 2003 Dec 3 4 free (zErrMsg) in shell.c should be sqlite_freemem(zErrMsg) According to documentation on sqlite_exec: The calling function is responsible for freeing the memory that holds the error message. Use sqlite_freemem() for this. By the way, the reason free() does not work in Win32 if SqlLite is a DLL is: The DLL obtains new memory calling its own implementation of "malloc" returning that pointer. Thus, if the application which loaded the DLL calls free on that pointer, it is calling its own implementation of "free" in which, for sure, that pointer does not exist. Therefore => crash!! #c8c8c8 441 code closed 2003 Sep anonymous Parser 2003 Dec drh 1 1 Cannot find table under Managed C++ I am writing a .NET wrapper for Sqlite in Managed C++. I've divided the task in a couple of stages: _: A native C++ project that builds Sqlite into a library Sqlite.lib{linebreak} _: A native C++ project that wraps sqlite into a library SqliteNative.lib{linebreak} _: A native test application of the native C++ wrappers.{linebreak} _: A managed C++ project that wraps the native C++ wrappers for use in a C# application{linebreak} _: A C# application. All phase build correctly. However the native version works and the managed version fail to create the VM and reports that it cannot find the table in the test database. I'm not certain how the hash functions work but I think there may be some pointer assumptions going on as it is puzzling why the same code works on the native side but fails under Managed C++. Whoever contacts me (chriswa@comcast.net) I can send you zip files of the projects. Thanks my email address is chriswa@comcast.net ---- This is not a bug. It is a request for help in porting SQLite to a new compiler and execution environment. The appropriate forum is the SQLite users mailing list. #c8c8c8 440 code closed 2003 Sep anonymous 2003 Dec drh 3 3 dayofmonth("now") returns one more than actual day The 'dayofmonth()' function returns one more than the correct value, on both Linux and Win32 compiled with gcc. Today is the second of September, but: select dayofmonth('now'); returns '3'. (both machines I tried this on are set to the correct date) Note the time on the ticket. I suspect it was 2003-Sep-02 *local time* on the user's computer, but 2003-Sep-03 *GMT* e ---- That is what I think; shouldn't it return local time? ---- OBE: Time & date functions have been rewritten. #cfe8bd 433 new fixed 2003 Aug anonymous Unknown 2003 Dec dougcurrie 3 2 configure needs updating for mingw/msys configure produces a Makefile that is _almost_ usable by mingw/msys on Windows. There are just two problems. One is that it ignores the setting of EXEEXT and uses CYGWIN instead (which isn't set for msys). So this: if test "$CYGWIN" = "yes"; then BUILD_EXEEXT=.exe else BUILD_EXEEXT="" should say: if test "$CYGWIN" = "yes"; then BUILD_EXEEXT=.exe else BUILD_EXEEXT=$EXEEXT (I dunno why the present script uses CYGWIN for this at all since EXEEXT is there to use for this purpose; perhaps it's a legacy.) Second, the tcl library that ships with mingw/msys is called tcl84 so this: AC_SEARCH_LIBS(Tcl_Init, dnl tcl8.4 tcl8.3 tcl8.2 tcl8.1 tcl8.0 tcl80 tcl,,,$otherlibs) should say: AC_SEARCH_LIBS(Tcl_Init, dnl tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,$otherlibs) in configure.ac , or this: for ac_lib in tcl8.4 tcl8.3 tcl84 tcl83 tcl; do in configure. I guess the right thing to do is edit configure.ac and regenerate configure, but I do not run autoconf and friends, so I've just been editing configure directly. I found a couple of other problems with the Makefile produced by configure on mingw/msys. First, the shell is built without readline support since mingw has the readline libraries and headers under the /mingw directory which is not searched. This can be corrected by adding /mingw to the list of directories to search in configure.ac at line 497. Second, 'make clean' does not delete lemon.exe which cause future makes to fail since lempar.c is not copied. This is corrected by changing Makefile.in to use the BUILD_EXEEXT and TARGET_EXEEXT macros to generate the correct target filenames in the Makefile produced by configure. I have attached a set of diff files that can be used to patch the distributed configure.ac and Makefile.in file to correct these problems (as well as the problems noted in the original ticket).Since I don't have autoconf etc. installed, I have manually modified the configure file. I have also attached a diff file that can be used to patch the distributed configure file. The Makefile.in.diff patch also adds a couple of new targets to the Makefile; dll and implib. 'make dll' will produce a windows dll file, and 'make implib' will make a dll import library for the Borland C++ compiler and the Microsoft VC compiler. The later won't work if you don't have the Borland or Microsoft programs on your path, but the make will succeed since the errors are ignored. Making the windows dll requires a sqlite.def file. I have also attached a def file produced by copying the appropriate section from the distributed publish.sh script. I hope this helps someone else. #c8c8c8 426 code closed 2003 Aug anonymous VDBE 2003 Dec 2 3 TIME produces JDs off by 12 hours In both the CVS version, and in my enhancement #425, the TIME function is broken: sqlite> select time('12:34:56'); 00:34:56 My preferred solution is to use Truncated Julian Dates which use midnight as a time base. e The TJD code as implemented here fixes this problem. Three files added: - func.c.diff includes changes for #425 plus a TJD fix for this bug - funct.c.diff just the changes from #425 to TJD fix for this bug - tjdate.test a test file for datetime ---- OBE: Time and date functions have been rewritten. #c8c8c8 423 code closed 2003 Aug anonymous Unknown 2003 Dec 1 1 'data schema has been changed error' how will overcome this when adding new table in to the existing database it throwing 'data schema has been changed error' how wil l overcome this Answer: issue the request again. This is not a bug. It is documented behavior. #c8c8c8 422 code closed 2003 Aug anonymous Unknown 2003 Dec 4 1 Memory leak in src/build.c I use dmalloc memory debuger (dmalloc.com) to debug memory usage in my application, this application now use SQLite, but dmalloc now report an memory leak: some memory allocated at src/build.c line 1661 of SQLite is not fried at exit. SQLite allocates a little bit of memory once, in several places, and then reuses that same memory over and over. The memory is never freed. But this is not a leak. #c8c8c8 415 code closed 2003 Jul anonymous VDBE 2003 Dec 3 3 Stringify can loose digits in doubles The Stringify macro's hardStringify function uses printf to convert doubles to strings. The format argument used is "%.15g" but to retain full precision for IEEE doubles "%.17g" should be used. I verified this with printf("%.17g\n", 2.225073858507201e-308); printf("%.16g\n", 2.225073858507201e-308); printf("%.15g\n", 2.225073858507201e-308); printf("%.17g\n", 2.2250738585072014e-308); printf("%.16g\n", 2.2250738585072014e-308); printf("%.15g\n", 2.2250738585072014e-308); printf("%.17g\n", 2.2250738585072018e-308); printf("%.16g\n", 2.2250738585072018e-308); printf("%.15g\n", 2.2250738585072018e-308); printf("%.17g\n", 0x7FEFFFFFFFFFFFFFLL); printf("%.16g\n", 0x7FEFFFFFFFFFFFFFLL); printf("%.15g\n", 0x7FEFFFFFFFFFFFFFLL); printf("%.17g\n", 0x7FEFFFFFFFFFFFFELL); printf("%.16g\n", 0x7FEFFFFFFFFFFFFELL); printf("%.15g\n", 0x7FEFFFFFFFFFFFFELL); A related note: The reliance upon the standard C library for conversion between strings and doubles is certainly a reasonable and obvious decision. If the inconsistency between sqlite platforms ever becomes an issue, I recommend using David Gay's dtoa available from netlib which prints doubles in the fewest characters needed to read them back accurately with the supplied strtod. http://www.netlib.org/fp/dtoa.c e Formats %.17g and %.16g cause too much roundoff error. Values that should be 0.1 come out as 0.09999999999999998. I'm deliberately choosing to leave the conversion at %.15g. #f2dcdc 409 event active 2003 Jul anonymous Unknown 2003 Dec anonymous 3 1 sqlite_open will cause segfault when using Rational PurifyPlus/Linux 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 #include #include #ifdef MTRACE #include #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. #f2dcdc 404 new active 2003 Jul anonymous 2003 Dec 3 3 new C API: sqlite_get_table_with_types with type information 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 http://sqlrelay.sourceforge.net *: Zee Cookbook: A cookbook application for Sharp Zaurus PDA. hb interface adding patch-sets, bug tracking, and Wiki to CVS. http://www.hwaci.com/sw/cvstrac/. *: SQL Relay: A persistent database connection pooling, proxying and load balancing system with APIs for a wide range of programming languages. http://www.firstworks.com/ --> http://sqlrelay.sourceforge.net *: Zee Cookb iy #f2dcdc 180 event active 2002 Oct anonymous 2003 Dec anonymous 1 1 on WIN32 - multithreaded process causes crash on assert(mutext) 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. #c8c8c8 161 code closed 2002 Oct anonymous Unknown 2003 Dec 1 1 Left join with 3 tables bug ? On the sql statements bellow the first "left join" with 2 tables return one row but in the second with 3 tables no rows are returned but it's expected to return 1 as well. Just in case of it's possible allow parentesis to define the join order when more than 2 tables are used will be nice. drop table gl; CREATE TABLE gl ( id integer primary key, source text, description text, transdate date DEFAULT current_date, employee_id int ); drop table chart; CREATE TABLE chart ( id integer primary key, accno text NOT NULL, description text, charttype char(1) DEFAULT 'A', category char(1), link text, gifi_accno text ); drop table acc_trans; CREATE TABLE acc_trans ( trans_id int, chart_id int, amount float, transdate date DEFAULT current_date, source text, cleared bool DEFAULT 'f', fx_transaction bool DEFAULT 'f' ); insert into chart values(1,'0001','account 1','A','E','link','23'); insert into gl values(1, 's1', 'some description','01/01/2002',0); select gl.id, gl.source, gl.description, acc_trans.transdate from gl left join acc_trans on gl.id = acc_trans.trans_id; select gl.id, gl.source, gl.description, acc_trans.transdate, chart.accno from gl left join acc_trans on gl.id = acc_trans.trans_id left join chart on acc_trans.chart_id = chart.id; Sorry but what happens in the second select with 3 tables is that one record is returned with only blank or null field values. In the real database when records are added to de acc_trans table it works correctly. And comparing the result of a explain when it works and when not it's identical so is something in the execution phase. ---- Unable to reproduce. No changes to code. #f2dcdc 255 event active 2003 Feb anonymous 2003 Feb 1 1 Database locked on HP64 (B11.11) 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 #f2dcdc 254 event active 2003 Feb anonymous 2003 Feb 1 1 make test does not work on HP64 (B11.11) make test does not work on HP64 (B11.11) #f2dcdc 253 event active 2003 Feb anonymous 2003 Feb 1 1 make install does not work with install-sh script 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 #f2dcdc 252 new active 2003 Feb anonymous 2003 Feb 4 1 Add optional regex matching similar to what Postgres & Oracle have 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:_ {linebreak} 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. #cfe8bd 247 code fixed 2003 Feb anonymous VDBE 2003 Feb drh 1 1 OUTER JOIN problem When the right table in a LEFT OUTER JOIN has an INTEGER PRIMARY KEY, that key does not become NULL when no row in the right table matches the current left table row. Example: CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2); INSERT INTO t1 VALUES(3,NULL); INSERT INTO t1 VALUES(5,6); CREATE TABLE t2(x INTEGER PRIMARY KEY,y); INSERT INTO t2 VALUES(2,22); INSERT INTO t2 VALUES(6,66); SELECT t1.a, coalesce(t2.x,999) FROM t1 LEFT OUTER JOIN t2 ON (t1.b=t2.x); The output of the above is 1|2 3|2 5|6 When it should be 1|2 3|999 5|6 #cfe8bd 246 event fixed 2003 Feb anonymous Unknown 2003 Feb 2 3 View not the same as direct query Something is funny with the views ... I get different results if i use the View than If I use the query directly. CREATE TABLE Signal ( uSignalID INTEGER UNSIGNED PRIMARY KEY, strComment VARCHAR(128), ca4CurPinName CHAR(4), UNIQUE(strTag, strName), ); CREATE TABLE Pin ( ca4Name CHAR(4) NOT NULL, strComment VARCHAR(128), uSignalIDCache INTEGER UNSIGNED, PRIMARY KEY(ca4Name) ); DROP VIEW PinComment; CREATE VIEW PinComment AS SELECT (CASE Signal.uSignalID IS NULL WHEN 1 THEN Pin.strComment ELSE Signal.strComment END) AS strComment, Pin.ca4Name as ca4Name FROM Pin LEFT JOIN Signal ON (Signal.ca4CurPinName=Pin.ca4Name); SELECT (CASE Signal.uSignalID IS NULL WHEN 1 THEN Pin.strComment ELSE Signal.strComment END) AS strComment, Pin.ca4Name as ca4Name FROM Pin LEFT JOIN Signal ON (Signal.ca4CurPinName=Pin.ca4Name) WHERE ca4Name Like "pa3_"; pa30 pin|pa30 pa31 sig|pa31 sqlite> select * from PinComment where ca4Name Like "pa3_"; |pa30 pa31 sig|pa31 Unable to reproduce. The straight select and the view in the code below produce identical output. CREATE TABLE t1(a PRIMARY KEY,b,c); CREATE TABLE t2(x PRIMARY KEY,b); INSERT INTO t1 VALUES(2,'com1-1','pa31'); INSERT INTO t1 VALUES(3,'com1-2','pa32'); INSERT INTO t1 VALUES(4,'com1-2','pa99'); INSERT INTO t2 VALUES('pa30','com2-0'); INSERT INTO t2 VALUES('pa31','com2-1'); INSERT INTO t2 VALUES('pa99','com2-1'); SELECT 'A', CASE t1.a IS NULL WHEN 1 THEN t2.b ELSE t1.b END AS b, t2.x AS x FROM t2 LEFT JOIN t1 ON (t1.c=t2.x) WHERE x LIKE "pa3_"; CREATE VIEW v1 AS SELECT CASE t1.a IS NULL WHEN 1 THEN t2.b ELSE t1.b END AS b, t2.x AS x FROM t2 LEFT JOIN t1 ON (t1.c=t2.x); SELECT 'B', * FROM v1 WHERE x LIKE "pa3_"; #cfe8bd 245 code fixed 2003 Feb anonymous Parser 2003 Feb 3 3 LIMIT and OFFSET clause LIMIT and OFFSET clause have two syntax 1. LIMIT integer [OFFSET integer] 2. LIMIT [offset,] rows For example, select * from t1 limit 50,10; correct result: 50~59 SQLite result: 10~59 #f2dcdc 244 new active 2003 Feb anonymous Unknown 2003 Feb drh 5 4 Combining CREATE TABLE with its populating from some flat file 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 AS COPY FROM . Or perhaps just CREATE TABLE FROM . 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. #cfe8bd 238 code fixed 2003 Feb drh CodeGen 2003 Feb 1 1 Assertion failure after some incorrect SQL The following series of commands causes an assertion failure. CREATE TABLE t1 AS SELECT c2; DROP TABLE t1; The first command returns an error. (The FROM clause was omitted from the SELECT statement.) But somehow, SQLite thinks table T1 was created in spite of this error. So it allows the DROP TABLE statement to be executed which results in an error. The problem appears to have been introduced when support for CREATE TABLE ... AS SELECT was first added by check-in [377] on 2002-Feb-18 as part of SQLite 2.3.3. #f2dcdc 236 new active 2003 Jan anonymous 2003 Feb 3 3 Add RENAME TABLE - will be easier to work around missing ALTER TABLE 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. #cfe8bd 232 code fixed 2003 Jan anonymous Parser 2003 Feb 2 2 group by result is wrong Select x from T1 group by x The result shows x's for every row in the table T1. The result should be equal to "select distinct x from T1". (Question if it being resolved: will you treat all nulls as a single row?) To answer the question: I originally coded SQLite so that NULLs were distinct in a "SELECT DISTINCT" query. But then I noticed that every other database engine I could find (except Ocelot) treated NULLs as indistinct in that context. So I changed SQLite. There is a #define in the code someplace to change it back, if I recall. See http://www.sqlite.org/nulls.html. #cfe8bd 215 new fixed 2003 Jan anonymous 2003 Feb 4 2 sqlite authorizer callback New feature that adds an interface or hook for an application that wants to control if an access to a table/row should be granted or denied. This could be done be with following interface function as discussed on the mailing list: int sqlite_set_authorizer( sqlite*, int (*xAuth)(void*, int op, const char*, const char *), void* ); The xAuth() function is called during the code generation phase to check access permissions on each column accessed. The "op" argument is one of SQLITE_READ or SQLITE_WRITE. zTable is the name of the table and zColumn is the name of the column being accessed. The xAuth() function should return SQLITE_OK to permit access, SQLITE_DENY to deny access (causing sqlite_exec() to return SQLITE_DENY without executing any part of the request) or SQLITE_IGNORE to cause reads to yield NULL and writes to become no-ops. If the xAuth argument to sqlite_set_authorizer is NULL, then authorization is disabled. The actual implementation ended up being somewhat more complex than this. See the documentation for details. #cfe8bd 237 code fixed 2003 Jan anonymous Parser 2003 Jan 2 2 suspected problem in IN operator {image: http://home.earthlink.net/~dav4is/sqlite/sqlite02.jpg} IN (on the right) seems to require single-quotes, rejecting values bounded by double quotes. This will be a problem when I have to denote values that contain single-quotes, no? This fails similarly when tried via RexxSQL. -R. #f2dcdc 233 event active 2003 Jan anonymous Unknown 2003 Jan 1 4 test bigfile-1.1 dumps core on Tru64 platform 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? #cfe8bd 231 code fixed 2003 Jan anonymous 2003 Jan 2 3 sqlite deny acces with wrong return value sqlite_exec seems to return SQLITE_ERROR instead of SQLITE_AUTH if access is denied. - Symbol SQLITE_AUTH isn't used in the source at all! - Functions sqliteAuthCheck() and sqliteAuthRead() need to set the 'return' value pParse->rc = SQLITE_AUTH before incrementing the count nErr. - These 2 functions need to make sure they aren't called for a pParse instance that already has an error value set, so they should either check pParse->rc and assert() or return or both if already non-zero. - sqliteAuthBadReturnCode() needs to 'return' SQLITE_MISUSE in its pParse->rc member. - sqliteAuthCheck() needs to set rc = SQLITE_DENY _after_ the call to sqliteAuthBadReturnCode() so that the actual error code is passed to that function. #f2dcdc 230 event active 2003 Jan anonymous Shell 2003 Jan anonymous 4 5 Problems compiling on AIX 4.3.3 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. #c8c8c8 228 event closed 2003 Jan anonymous Unknown 2003 Jan drh 1 1 The size of database file is not decreased . After delete the records from the table,The size of the database file is not decreased. Correct. When information is deleted from the database, free disk space is added to a freelist within the database file and is reused again as new information is added. But the free disk space is not returned back to the operating system. SQLite database files can grow but not shrink. If you delete a lot of information from a database and want to shrink it, do so as follows: sqlite old.db .dump | sqlite new.db #cfe8bd 227 code fixed 2003 Jan anonymous Pager 2003 Jan 2 1 win32 db locked in win32 - boundschecker warns about: "API failure LockFile returned 0x00000000 LastError: The process cannot access the file because another process has locked a portion of the file." this happens in os.c line 1020 during sqlite_open. this happens mostly when i don't implement myself a mutex that would prevent 2 threads from accessing the db in the same time. in the image you'll notice that this happens event though id->locked = 0 {image: locked1.gif} a similar problem happens in os.c line 1115. in the attached example it happened in a simple update sql command ("update ac set Mode = 4 where AC_ID = 1"). see image: {image: locked2.gif} Unless I badly misunderstand what is being said above, the LockFile() API is doing exactly what it is suppose to do - it is failing if another process or thread already has the file locked. This is how SQLite detects that another process or thread already has the database locked. This is a feature, not a bug. #cfe8bd 226 code fixed 2003 Jan anonymous Unknown 2003 Jan 2 2 Glob doesn't work for upercase letters BEGIN TRANSACTION; create table test (id integer primary key, name varchar(10)); INSERT INTO test VALUES(1,'abcABC exapmle'); COMMIT; sqlite> select * from test where name glob "*C*"; sqlite> select * from test where name glob "*c*"; 1|abcABC exapmle sqlite> Looking at util.c, function sqliteGlobCompare. There are missing conversion UpperToLower in next piece of code: }else{ while( (c2 = *zString)!=0 ){ while( c2 != 0 && c2 != c ){ c2 = *++zString; } if( c2==0 ) return 0; if( sqliteGlobCompare(&zPattern[1],zString) ) return 1; sqliteNextChar(zString); } Possible fix: }else{ while( (c2=UpperToLower[*zString])!=0 ){ while( c2 != 0 && c2 != c ){ c2 = UpperToLower[*++zString]; } if( c2==0 ) return 0; if( sqliteGlobCompare(&zPattern[1],zString) ) return 1; sqliteNextChar(zString); } #cfe8bd 225 code fixed 2003 Jan anonymous Unknown 2003 Jan 3 4 reading uninitialized memory during sqlite_open, in random.c line 69. sqliteOsRandomSeed(k); initializes only about 12 bytes for k[256] but then the function tries to use all 256 bytes for creating the random number. Hopefully, the uninitialized memory will contain random information, since that will increase the randomness of the starting value for the random number generator. This is a feature, not a bug. #cfe8bd 224 code fixed 2003 Jan anonymous Pager 2003 Jan 3 3 read overflows memory in pager.c line 1058 - doing operation on memory that's out of bound. upon deletion of entries from table. (pPager->aInJournal[pgno/8] points to some random memory) see image: {image: sqlite-uninit2.gif} I modified the code to always check the memory allocation prior to line 1058 and then reran the entire test suite. No problems were ever detected. Until evidence to the contrary emerges, I'm going to assume this is another bug in the boundschecker program being used and not a problem with SQLite. #cfe8bd 223 code fixed 2003 Jan anonymous VDBE 2003 Jan 3 3 using uninitialized memory's value in vdbe.c line 5188 - unitialized memory's value is used. i don't know how bad this is. as you can see - nErr's value is usueless after such an operation. see image: {image: sqlite-uninit1.gif} The bug here was that the nErr variable is never used. It has now been removed. #cfe8bd 222 code fixed 2003 Jan anonymous VDBE 2003 Jan 3 3 cleanup tries to access memory out of array bounds upon db creation - in WIN32 - the cleanup tries to pop from the stack at location -1. see image for better explanation - as you can see the p->tos == -1 {image: sqlite-stack-error.gif} This is a bug in the boundschecker program used, not in SQLite. The -1 element of the array is never really accessed. We just compute its address (which is a perfectly legal thing to do.) But the address is never used because N is 0 and so the while loop never executes. Nevertheless, I have revised the code to be less confusing to bounds checker programs. #cfe8bd 221 doc fixed 2003 Jan anonymous 2003 Jan 2 4 pragma show_datatypes not documented N/A Duplicate of ticket #97. #cfe8bd 220 code fixed 2003 Jan anonymous 2003 Jan 4 3 AS clause disables retrieving data types pragma show_datatypes=ON select 4+5 returns 'NUMERIC' select 4+5 as a returns NULL same for 'TEXT'. So it seems show_datatypes doesn't work as soon as 'AS' is used. Same as ticket #153. #f2dcdc 219 new active 2003 Jan anonymous 2003 Jan 5 5 MySQL style enums I would be really cool if SQLite supported enum like MySQL does: {link: http://www.mysql.com/doc/en/ENUM.html} #cfe8bd 218 new fixed 2003 Jan anonymous 2003 Jan 2 2 MacOS port for submission to CVS I have modified os.h, os.c and shell.c to work under MacOS compiled with CodeWarrior (version 8). This applies to Classic and Carbon builds. For OS X (aka Darwin) use Apple's tools (gcc) and treat as Unix. I have done a basic set of tests to verify that everything works, and everything seems to work with no problems. I have verifed all 3 builds: Classic, Carbon and Darwin. I have also checked that the files produced on the Mac are fully recognised and read by the Linux version of sqlite. The modified files are attached. A couple of things I forgot to mention: 1:I have put in the the option to change the temporary file name prefix. This defaults to what was there previously. See my comments in the file. 2:On *sqliteOsFullPathname()*, Windows version, *GetFullPathName()* returns the number of bytes required _not including the null terminator_. It needs one more byte to be allocated, which I have put in. (_DRH adds: The return value of GetFullPathName() does include space for the null-terminator according to the documentation on microsoft's website. But allocating an extra byte won't hurt and it will probably protect against bugs in the microsoft documentation, so I left it in._) #e8e8bd 217 code review 2003 Jan anonymous Unknown 2003 Jan anonymous 4 4 opcodes.c missing from the makefile SRC macro 'opcodes.c' missing from the makefile SRC macro This affects 'make target_source' which you need to do if you want to build with a non-gcc complier e.g. MSVC Correction: The error is in Makefile.in line 162, and the equivalent line in main.mk is correct. (The configure system is currently unmaintained, according to the docs.) #f2dcdc 216 new active 2003 Jan anonymous 2003 Jan 1 1 Add "DISTINCT ON()" clause to specify the fields to apply the unicity 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:_ {linebreak} 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:_ {linebreak} 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... #c8c8c8 214 code closed 2003 Jan anonymous Unknown 2003 Jan 1 1 segmentation fault on ETRAX board - started in version 2.7.4 sqlite_exec constantly causes a segmentation fault on embedded ETRAX 100 (risc) board. the exact same code works fine with version 2.7.3 - but fails with 2.7.4. the OS is redhat linux - but the same code runs fine on the same linux running on a pc. i cannot debug it on the embedded device - so i can't give much more info. any idea? Could this be related to ticket #210? Is the ETRAX a big endian processor? ---- this was due to a bug in the AXIS-ETRAX board support package - fixed. #cfe8bd 212 code fixed 2003 Jan drh Pager 2003 Jan 2 1 Corrupt database results if the very first transaction rolls back. If you open a new database (initial file size of 0 bytes) and start a transaction, and make it a big transaction so that information is written to disk during the transaction, then if you rollback that transaction, the rollback fails and you are left with a corrupt database file. This only happens if you start with an initially empty database, so there is not any danger of losing real data. But it is annoying. #cfe8bd 211 new fixed 2002 Dec anonymous Unknown 2003 Jan 4 4 How to add comments to an SQL-File This is not a bug, but I was unable to find anything in the documentation ... How can I insert a comment in an SQL-File ? Something like -- This is a comment Currently sqlite reacts with : Incomplete SQL: -- This is a comment By the way, sqlite is great ... :-) Comments can be entered like this:{linebreak} -- a comment{linebreak} or this:{linebreak} /* C-like comment */ But you cannot enter a comment inside an expression:{linebreak} CREATE TABLE T1({linebreak} -- comment inside argument list{linebreak} datetime int);{linebreak} This is the only way in which I could get parsing a comment to fail. The page "SQL As Understood By SQLite"("lang.html") could use a short section on comments. Jim Lyon (jplyon ta attglobal tod net) ----- Comments inside a table declaration work. In the "sqlite" shell, if comments occurred at the end of a file (with no ";" following) then an error was reported. This is fixed by check-in [838]. #cfe8bd 210 code fixed 2002 Dec anonymous Unknown 2003 Jan drh 1 1 Segfault on OSX with Perl bindings Hi, I'm the author of the Perl bindings for SQLite (DBD::SQLite). Since updating to 2.7.4 I'm getting strange segfaults when doing a looping bunch of inserts (in the benchmark part of the test harness - tests 500 inserts). The relevant part of the test suite is this code: $dbh->do("CREATE TABLE bench (id INTEGER, name CHAR(40)," . " firstname CHAR(40), address CHAR(40)," . " zip CHAR(10), city CHAR(40), email CHAR(40))"); my(@vals) = (0 .. 499); my($num); TimeMe("Testing INSERT speed ...", "%d rows in %.1f cpu+sys seconds (%d per sec)", sub { ($num) = splice(@vals, int(rand(@vals)), 1); $dbh->do("INSERT INTO bench VALUES (?, 'Wiedmann', 'Jochen'," . " 'Am Eisteich 9', '72555', 'Metzingen'," . " 'joe\@ispsoft.de')", undef, $num); }, 500); I've been unable to trace what's causing the segfault, so I'm hoping you might be able to help me here. Here's a backtrace of when the segfault occurs: Program received signal EXC_BAD_ACCESS, Could not access memory. 0x002c4914 in cellSize (pBt=0x140430, pCell=0x0) at btree.c:395 395 int n = NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h); (gdb) bt #0 0x002c4914 in cellSize (pBt=0x140430, pCell=0x0) at btree.c:395 #1 0x002caf94 in balance (pBt=0x140430, pPage=0x1cc8f0, pCur=0x1c8340) at btree.c:2294 #2 0x002cc430 in sqliteBtreeInsert (pCur=0x1c8340, pKey=0xbfffe6e4, nKey=4, pData=0x1c8370, nData=72) at btree.c:2562 #3 0x00306510 in sqliteVdbeExec (p=0x1ca880, xCallback=0x2f5e74 , pArg=0xbfffec40, pzErrMsg=0xbfffeb84, pBusyArg=0x7530, xBusy=0x2e40e0 ) at vdbe.c:3745 #4 0x002ce638 in sqliteExec (pParse=0xbfffeb70) at build.c:73 #5 0x002ea570 in yy_reduce (yypParser=0x1ca1a0, yyruleno=3) at parse.y:67 #6 0x002ed0cc in sqliteParser (yyp=0x1ca1a0, yymajor=0, yyminor={z = 0x1c823d ")", dyn = 0, n = 1}, pParse=0xbfffeb70) at parse.c:6790 #7 0x002f77ac in sqliteRunParser (pParse=0xbfffeb70, zSql=0x1c81d0 "INSERT INTO bench VALUES ('70', 'Wiedmann', 'Jochen', 'Am Eisteich 9', '72555', 'Metzingen', 'joe@ispsoft.de')", pzErrMsg=0xbfffeccc) at tokenize.c:469 #8 0x002e3d44 in sqlite_exec (db=0x1b6350, zSql=0x1c81d0 "INSERT INTO bench VALUES ('70', 'Wiedmann', 'Jochen', 'Am Eisteich 9', '72555', 'Metzingen', 'joe@ispsoft.de')", xCallback=0x2f5e74 , pArg=0xbfffec40, pzErrMsg=0xbfffeccc) at main.c:633 #9 0x002f6314 in sqlite_get_table (db=0x1b6350, zSql=0x1c81d0 "INSERT INTO bench VALUES ('70', 'Wiedmann', 'Jochen', 'Am Eisteich 9', '72555', 'Metzingen', 'joe@ispsoft.de')", pazResult=0x1c5220, pnRow=0x1c5224, pnColumn=0x1c522c, pzErrMsg=0xbfffeccc) at table.c:150 #10 0x002d5e38 in sqlite_st_execute (sth=0x19d908, imp_sth=0x1c51b0) at dbdimp.c:302 #11 0x002c2914 in XS_DBD__SQLite__st_execute (cv=0x1b3be8) at SQLite.xsi:398 [snip] As you can see, pCell is NULL in the call to cellSize(). Email me if you want more backtrace details. The segfault doesn't occur on my Linux box. No idea why not - perhaps stricter type checking, perhaps different optimisations or something. It occurred to me it might be different optimisation flags too, but turning off all optimisations didn't get rid of the bug. OSX is big endian. Is your Linux box little endian? -- e Yes, it's intel. -- matt OK, found the bug. It was my stupid. The perl bindings forgot to copy over config.h, so a config.h from somewhere else in the path got picked up, and SQLITE_PTR_SZ wasn't defined, so things broke. Thanks to drh for adding the asserts though that pointed out where the problem was! Marking bug as fixed. -- matt. #cfe8bd 206 code fixed 2002 Dec anonymous Pager 2003 Jan 3 3 Local variable used before it is initialised As reported by Visual C++ M:\Projects\sqlite\OsxBuild\tsrc\pager.c(853) : warning C4700: local variable 'lastPgno' used without having been initialized -------------- MSVC is fussy and reports other things, which probably won't be a problem. It's probably worth checking and putting casts in if the functionality is deliberate: M:\Projects\sqlite\OsxBuild\tsrc\os.c(562) : warning C4244: 'initializing' : conversion from '__int64 ' to 'long ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\os.c(563) : warning C4244: 'initializing' : conversion from '__int64 ' to 'long ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\os.c(604) : warning C4244: 'initializing' : conversion from '__int64 ' to 'long ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\os.c(605) : warning C4244: 'function' : conversion from '__int64 ' to 'long ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\os.c(605) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\pager.c(394) : warning C4018: '>' : signed/unsigned mismatch M:\Projects\sqlite\OsxBuild\tsrc\pager.c(480) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\pager.c(538) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\pager.c(555) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\pager.c(724) : warning C4244: '=' : conversion from '__int64 ' to 'int ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\pager.c(726) : warning C4244: 'return' : conversion from '__int64 ' to 'int ', possible loss of data parse.c(6827) : warning C4761: integral size mismatch in argument; conversion supplied parse.c(6838) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\select.c(100) : warning C4018: '==' : signed/unsigned mismatch M:\Projects\sqlite\OsxBuild\tsrc\vdbe.c(2123) : warning C4244: 'initializing' : conversion from 'double ' to 'int ', possible loss of data M:\Projects\sqlite\OsxBuild\tsrc\btree.c(2385) : warning C4018: '<' : signed/unsigned mismatch M:\Projects\sqlite\OsxBuild\tsrc\btree.c(637) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(1841) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(1843) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(524) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(528) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(542) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(546) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(549) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(490) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(491) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(418) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(429) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(440) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(442) : warning C4761: integral size mismatch in argument; conversion supplied M:\Projects\sqlite\OsxBuild\tsrc\btree.c(2003) : warning C4761: integral size mismatch in argument; conversion supplied #cfe8bd 198 todo fixed 2002 Dec anonymous 2003 Jan 1 1 Descending sort order in indices Wouldn't it be an idea to (bitwise) invert an index' column data if the column is to be sorted in descending order? By this you will get the right effect with a minimum of effort. Check-in [795] enhances the query optimizer so that it will scan a table or index backwards if that will help implement an ORDER BY ... DESC clause. Is this what you are asking for? #cfe8bd 191 code fixed 2002 Nov anonymous Unknown 2003 Jan drh 1 1 Large file support does not work in Windows Any database that is larger than 4GB becomes non-operational, at least for the tables that are beyond the 32-bit limit. Hint: I artifically enlarged the database by increasing the file size manually, as suggested by drh. Warnings in #206 may point to the cause (unwitting truncation of 64-bit integers). #bde5d6 177 code tested 2002 Oct danielk1977 VDBE 2003 Jan 1 4 Memory handling problem for very large aggregate results There is a problem at the VDBE level with very large aggregate results. You can demonstrate it like this: CREATE TABLE a(a); INSERT INTO a VALUES('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'); SELECT substr( (select max(a) from a), 1, 10 ); This should return a garbage result. The problem seems to be in the implementation of the OP_AggGet instruction. (approx line 5012 of vdbe.c). I think we need to replace the following: aStack[tos].flags &= ~STK_Dyn; with if( aStack[tos].flags & STK_Dyn ){ aStack[tos].flags &= ~STK_Dyn; aStack[tos].flags |= STK_Static; } This *seems* to work. A fix has been checked in but I still need to add test cases to the test suite. #cfe8bd 153 code fixed 2002 Sep anonymous Parser 2003 Jan 1 1 PRAGMA SHOW_DATATYPES bug If the pragma SHOW_DATATYPES in ON and one uses a SELECT query with aliasing like "SELECT tablecol AS foo ..." the data type info is missing for the alias column. The not aliased columns show correct data type info. Same as ticket #220. #c8c8c8 127 event closed 2002 Jul anonymous Unknown 2003 Jan 4 5 testfixture crashes with bus error following misuse-5.3 test While investigating another test failure, I recompiled sqlite 2.6.2 with -DSQLITE_TEST and MEMORY_DEBUG undefined. With just SQLITE_TEST defined, the quick test suite crashes testfixture just following the misuse-5.3 test. misuse-5.3... Ok make: *** [test] Bus error The test appears to pass, then testfixture bus errors. From the stack trace, the crasher seems to appear during an attempt to manipulate a path in the file system. I'm using Tcl 8.4b4 on Mac OS X 10.1.5, and there may be bugs in it's implementation here. Command: testfixture PID: 28398 Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000008 Thread 0 Crashed: #0 0x70004460 in szone_malloc #1 0x700042c8 in malloc_zone_malloc #2 0x70004204 in malloc #3 0x7000afe4 in __opendir2 #4 0x70038ebc in getcwd_physical #5 0x7003f728 in realpath #6 0x0a071b38 in TclpObjNormalizePath #7 0x0a04a2ec in TclNormalizeToUniquePath #8 0x0a04a21c in FSNormalizeAbsolutePath #9 0x0a04b1c4 in Tcl_FSGetCwd #10 0x0a04d09c in Tcl_FSGetNormalizedPath #11 0x0a04d5b0 in Tcl_FSGetFileSystemForPath #12 0x0a04aac8 in Tcl_FSStat #13 0x0a04a744 in Tcl_FSEvalFile #14 0x0a01aed8 in Tcl_SourceObjCmd #15 0x0a00e508 in TclEvalObjvInternal #16 0x0a00edcc in Tcl_EvalEx #17 0x0a04a858 in Tcl_FSEvalFile #18 0x0a01aed8 in Tcl_SourceObjCmd #19 0x0a00e508 in TclEvalObjvInternal #20 0x0a031f14 in TclExecuteByteCode #21 0x0a03151c in TclCompEvalObj #22 0x0a00f1d0 in Tcl_EvalObjEx #23 0x0a0154a4 in Tcl_ForeachObjCmd #24 0x0a00e508 in TclEvalObjvInternal #25 0x0a00edcc in Tcl_EvalEx #26 0x0a04a858 in Tcl_FSEvalFile #27 0x0a049da0 in Tcl_EvalFile #28 0x000156d4 in main #29 0x00002054 in _start #30 0x00001e84 in start I'm submitting this FYI. Lots of folks have been using sqlite under Mac OS X with no apparent problems, so I'm not sure there's that much cause for concern. Methinks this is a TCL bug, not an SQLite bug. #cfe8bd 97 todo fixed 2002 Jul drh 2003 Jan 1 1 Document and test the SHOW_DATATYPES pragma Add documentation and tests for the SHOW_DATATYPES pragma. See also ticket #221. #f2dcdc 68 new active 2002 Jun anonymous 2003 Jan 5 5 PRAGMA table_info(table-name) for queries 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. #e8e8bd 67 new review 2002 Jun anonymous 2003 Jan 5 5 BLOB (Binary Large OBject) support What about to add support for BLOB (Binary Large OBject) into SQLite. I know that SQLite is typeless. I mean just add functions for storing and reading block(s) of variable length. Somethig like: sqlite_read_blob(sqlite*, int block_num, int *block_size, char *block_data) sqlite_write_blob(sqlite*, int block_num, int block_size, char *block_data) (if block_num is zero for write_blob new blob is created) and user than can store this block_num into regular table.... I'd suggest you just put your 'BLOBS' into files, then refer to the BLOBS using a filename fields. All you then need is a function in your app to create unique filenames. ---- The sqlite_encode_binary() and sqlite_decode_binary() routines can be used to encode and decode binary data into a form where it can be inserted into a column of an SQLite table. This technique is used, for example, to store binary attachments in CVSTrac. ---- But in the case of first solution, there is danger that user deletes some of these files and so break the consistency od database. In the case of second solution the size of blob is limited to max size of the row, which is only 1MB by default(or even less because of encoding). BTW Where are the functions sqlite_encode_binary() and sqlite_decode_binary()? #f2dcdc 420 new active 2003 Jul anonymous VDBE 2003 Jul 3 3 Not abort transaction when callback is cancelled 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):{linebreak} 1) create a new PRAGMA: PRAGMA callback_cancel_no_abort with a default of FALSE (to keep the current behaviour as default){linebreak} 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 */{linebreak} In pragma.c: INSERT this code at line 336:{linebreak} if( sqliteStrICmp(zLeft, "callback_cancel_no_abort")==0 ){{linebreak} _:if( getBoolean(zRight) ){{linebreak} _::db->flags |= SQLITE_CallBackNoAbort;{linebreak} _:}else{{linebreak} _::db->flags &= ~SQLITE_CallBackNoAbort;{linebreak} _:}{linebreak} }else{linebreak} In vbde.c: CHANGE line 5751: from{linebreak} if( rc ){ {linebreak}{linebreak} TO {linebreak}{linebreak} if( rc && ( !(db->flags & SQLITE_CallBackNoAbort) || rc != SQLITE_ABORT) ){{linebreak} 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. #cfe8bd 416 code fixed 2003 Jul anonymous 2003 Jul 1 1 An SQL DML which yields a segfault 1. Create the following objects: CREATE TABLE Oid(high INTEGER,lastLow INTEGER); INSERT INTO Oid values(0,0); CREATE TABLE Object(id INTEGER PRIMARY KEY,type INTEGER); CREATE TABLE Occurence(id INTEGER PRIMARY KEY, topic INTEGER, type INTEGER, ref INTEGER, value); CREATE TABLE Relation (id INTEGER, role INTEGER, member INTEGER); CREATE TABLE Scope(id INTEGER, topic INTEGER, member INTEGER); CREATE VIEW Instance AS SELECT r1.member AS instance, r2.member AS class FROM Relation r1, Relation r2 WHERE r1.role = 110 AND r2.role = 109 AND r1.id = r2.id ; CREATE VIEW Axis AS SELECT r1.member AS topic, r2.member AS axi FROM Relation r1, Relation r2, Instance i WHERE r1.role = 1 AND r2.role = 105 AND i.class = 103 AND r1.id = r2.id AND r1.id = i.instance ; 2. This query yields a segmentation fault: SELECT * from Axis; Here is a much simpler way to generate the problem: CREATE TABLE x(a,b); CREATE VIEW y AS SELECT x1.b AS p, x2.b AS q FROM x AS x1, x AS x2 WHERE x1.a=x2.a; CREATE VIEW z AS SELECT y1.p, y2.p FROM y AS y1, y AS y2 WHERE y1.q=y2.q; SELECT * from z; #f2dcdc 413 new active 2003 Jul anonymous 2003 Jul 5 1 SQL_CALC_FOUND_ROWS & FOUND_ROWS() not supported for speedup & code compatibility with mysql #f2dcdc 412 new active 2003 Jul anonymous Unknown 2003 Jul drh 1 1 sign function: quick hack for func.c (hope this helps) 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/ #f2dcdc 411 todo active 2003 Jul anonymous 2003 Jul drh 1 1 support for sign function in select 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) #cfe8bd 410 code fixed 2003 Jul anonymous Pager 2003 Jul 3 4 Creation and deltions of files should fsync() directory Hello, re my post and drh's response both on 25/07/03 entitled "Deletion and recreation of journal files - database corruption" fsync is performed on both the main file and journal file, but whenever a journal file is created or destroyed and whenever a main file is created the directory also needs to be synched to ensure data integrity. If the fsync is not done then, for example, a journal file required to recover a database could be lost when the machine recovers after a power failure. This would result in a corrupt database, and I belive this is the source of some database corruption I've seen on a Sun machine running Solaris 8 with SCSI disks and a journalling filesystem. I suspect the directory sync will have to be executed no more often than twice per commit, and by avoiding deletion of the journal (truncate instead) sqlite might further reduce the impact of syncing the directory as it would not have changed. According to the fsync man page on linux the access time and other stat metadata is saved along with the file on fsync. It's just the directory entry which places the file in a particular location that doesn't get written, and that's how the journal file can get lost. I don't know how this affects platforms that do not use fsync. I noticed this problem in a scenareo where I've got transactions each of one-second duration that (almost) immediately restart whenever they commit, so it may even be possible in my case the the filesystem recovery mechanism pulled in an old journal file long since deleted if it's commit period is much longer than a second. Benjamin. A call is now made to fsync() for the directory that contains the journal filename after the journal is created. gdb was used to confirm that the fsync() is being called and is returning successfully. #cfe8bd 408 code fixed 2003 Jul anonymous VDBE 2003 Jul 1 1 toInt() reports success on overflow, causes comparisons to fail The comparison operators, and maybe other things in the VDBE, use the static function toInt to convert stack entries to integers, and to determine if the entries are integers. toInt reports success for numbers that overflow an int, but would fit in a double. This causes queries to return incorrect results. For example: create table DMData (time); insert into DMData values (1058989418890); insert into DMData values (1); insert into DMData values (1050); SELECT * FROM DMData WHERE time > 0; 1 1050 SELECT * FROM DMData WHERE time < 0; 1058989418890 In addition to fixing (or instead of using) toInt, perhaps the implementations of the comparison operators should use a conversion to double similar to what is done in OP_Add. #f2dcdc 407 new active 2003 Jul anonymous 2003 Jul 4 4 sqlite_compile etc. and pragma empty_result_callbacks. 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. #cfe8bd 406 code fixed 2003 Jul anonymous 2003 Jul 1 1 BEGIN ON CONFLICT ROLLBACK The sequence below will raise an access violation (at least on windows). It was executed using the sqlite_get_table() interface. PRAGMA empty_result_callbacks = ON; BEGIN ON CONFLICT ROLLBACK; CREATE TABLE tabx ( a INTEGER PRIMARY KEY, b, c, d ); INSERT INTO tabx VALUES ( NULL, 2, 3, 4 ); INSERT INTO tabx VALUES ( NULL, 2, 3, 4 ); INSERT INTO tabx VALUES ( NULL, 2, 3, 4 ); SELECT * FROM tabx; -- Force rollback INSERT INTO tabx VALUES ( 1, 2, 3, 4 ) /* * ACCESS VIOLATION with any querie I tried */ SELECT * FROM sqlite_master; This program was linked with the sqlite.dll (v2.8.5) on the downloads page with the same results (access violation), but I think this will also happen with previous versions. The access violation is on file 'MAIN.C', line 61, function 'sqliteInitCallback' (see comment): ----------- 55: int sqliteInitCallback(void *pInit, int argc, char **argv, char **azColName){ 56: InitData *pData = (InitData*)pInit; 57: Parse sParse; 58: int nErr = 0; 59: 60: assert( argc==5 ); 61: if( argv[0]==0 ){ //**ACCESS VIOLATION****** argv is a NULL pointer 62: corruptSchema(pData); 63: return 1; 64: } ------------ I didn't emphasize that the cause is the "PRAGMA empty_result_callbacks = ON;" SQL query. It works as expected if this is off. ---- The title is misleading. This problem has nothing to do with the BEGIN ON CONFLICT ROLLBACK. The trouble was that the internal SQLite callback that handled reading the schema out of SQLITE_MASTER could not handle a null argv value that appeared when EMPTY_RESULT_CALLBACKS was turned on. #cfe8bd 405 todo fixed 2003 Jul anonymous 2003 Jul 1 1 Missing complete unix source tarballs A compelete, unix tarball is not present on the downloads page. I have a sqlite-2.8.0.tar.gz on my machine, so I know that it used to exist. Please make one available. I'm running MacOSX, so the RPMs can't be used. Thanks! #f2dcdc 403 code active 2003 Jul anonymous 2003 Jul 4 4 Two small fixes in .spec file for RPMS 1. The sqlite.pc isn't packaged in the sqlite-devel package. Simply add in the package %files section: {quote: %{_libdir}/pkgconfig/*.pc} 2. There is not %post and %postun: Need to run /sbin/ldconfig in both sections. #cfe8bd 401 code fixed 2003 Jul anonymous 2003 Jul 2 3 Source downloads considered useless.. I'm an OSX user, and have previously downloaded source tarballs for sqlite 2.8.0. I'd like to be able to download 2.8.4, but you don't offer a source tarball, just a useless zip file and several rpms. Please consider packaging the source tarball again. I'll use the cvs checkout in the meantime... #cfe8bd 400 code fixed 2003 Jul anonymous 2003 Jul 3 4 shell.c, when readline() not avail, getline() conflicts with stdio's I need to undefine READLINE_FLAGS in my makefile, because my system does not have readline(). This results in the following compilation error: ../src/shell.c:94: conflicting types for `getline'{linebreak} /include/stdio.h:435: previous declaration of `getline' In sqlite/src/shell.c, a locally declared getline() routine is substituted for readline(). On my particular system, this causes a conflict (as seen above) with stdio.h. My solution was to simply replace all occurences of "getline" with something else like "mygetline" in this file. Not sure if others are likely to encounter this. I am compiling for ARM. But this fix will not affect systems that are currently working.{linebreak} Buzz{linebreak} buzzweetman@hotmail.com #c8c8c8 399 event closed 2003 Jul anonymous 2003 Jul drh 3 3 SELECT COUNT(*) FROM TABLE when using with the DLL, it return count(*). While modifying: /* If this is the first row, then generate an extra row containing ** the names of all columns. */ if( p->nRow==0 ){ p->nColumn = nCol; for(i=0; irc = SQLITE_NOMEM; return 1; } strcpy(z, colv[i]); } //WHEN YOU REMOVE THIS LINE, IT FIX THIS PROBLEM. p->azResult[p->nData++] = z; } }else if( p->nColumn!=nCol ){ sqliteSetString(&p->zErrMsg, "sqlite_get_table() called with two or more incompatible queries", 0); p->rc = SQLITE_ERROR; return 1; } I do not understand the description of the problem. And the line that is marked as being removed appears to be an essential part of SQLite - removing it creates an error. No changes. ---- The originator further describes the error as returning the text string 'count(*)' instead of an integer which is the actual count. ---- I Think I see the difficulty here. The user is expecting the 0th element of the 0th result row returned by the query "SELECT COUNT(*) FROM tablename" to be the actual count when it is instead the column name. The data rows start after the row of column names. I will email the poster. #cfe8bd 397 code fixed 2003 Jul anonymous Unknown 2003 Jul 4 3 tests attach-5.1 and attach2-1.1 fail on w2k mingw Building from CVS 17-Jul-2003 (version 2.8.4+) the 'make test' fails; this is on Win2k with Mingw. Two edits to the tests remedy the problem. In attach-5.1 add the line db2 close after the line db close otherwise the file delete of test2.db fails. After attach2-1.1 add do_test attach2-1.2 { catchsql { DETACH t2; } } {0 {}} otherwise the file delete of test2.db fails. -- e #cfe8bd 396 code fixed 2003 Jul anonymous Unknown 2003 Jul 3 2 AGGREGATE FUNCTION WITH LIMIT SELECT MAX(FIELD) FROM TABLE LIMIT 0,100 Hang SQLITE. This works when I try it. No database hang. If this is still causing a problem, please provide full details and I will look at it again. ---- Further correspondance with the discoverer of this problem has enabled me to decode the cryptic error description above. The following SQL results in an "illegal instruction" error in the VDBE: create table t(a integer primary key); select max(a) from t limit 1; #f2dcdc 395 code active 2003 Jul anonymous Unknown 2003 Jul 4 4 Error opening db on Mac OS X not reported correctly 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? #cfe8bd 394 code fixed 2003 Jul anonymous Parser 2003 Jul 4 1 SELECT 1; syntax throw run-time compiler warning *SELECT 1 AS ItemID, 2 AS Item2ID;* _(no FROM clause)_ syntax works but throws a compiler run-time warning about the variable cont being used without being initialized _(debug mode in MSVC7.1)_. It is defined on line 361 in sqliteWhereBegin() in where.c. I am not sure if this syntax is intended to work with sqlite, but it is allowed in MS Sql Server, and presumably other database engines as well. I personally find it much cleaner than *SELECT 1 AS ItemID, 2 AS Item2ID FROM sqlite_master LIMIT 1;* or similar. My proposal is to simply initialize this variable to 0 when defined to avoid receiving this run-time assertion. Therefore where.c line 361 becomes: int brk, cont = 0; /* Addresses used during code generation */ Kevin Alons In a SELECT with no WHERE clause, the "cont" variable is never initialized. It is then copied into variable "brk" which is never used. So this is not really a bug. But I'll initialize the variable if that is what it takes to get MSVC to work. #cfe8bd 393 code fixed 2003 Jul anonymous Unknown 2003 Jul 3 4 UNION and LIMIT incorrectly I have two databases, both identical in structure; main.db :- create table dictionary (word); insert into dictionary values ('steve'); user.db :- create table dictionary (word); insert into dictionary values ('dave'); I open the main database and attach the second; attach "user.db" as user; I then run a UNION query on both tables to see if a word exists in either table; select word from dictionary where word='steve' union select word from user.dictionary where word='steve' limit 1; This produces 'steve' Run it again but look for 'dave' select word from dictionary where word='dave' union select word from user.dictionary where word='dave' limit 1; This produces nothing........ Increase the limit to 2; select word from dictionary where word='dave' union select word from user.dictionary where word='dave' limit 2; And I get 'dave' #c8c8c8 392 event closed 2003 Jul anonymous Shell 2003 Jul anonymous 1 1 Unable to link libsqlite.so file on SunOS 5.8 {linebreak}After I compiled the source files, I tried to link my own test file with libsqlite.so, and I got an error as below. {linebreak}$ cc -o SQLiteTest SQLiteTest.c -L . -R . -lsqlite {linebreak}Undefined _________________________ first referenced {linebreak}symbol ____________________________ in file {linebreak}sqlite_version------------------------------>./libsqlite.so {linebreak}sqlite_interrupt---------------------------->./libsqlite.so {linebreak}sqliteBtreeFactory------------------------>./libsqlite.so {linebreak}sqlite_freemem---------------------------->./libsqlite.so {linebreak}sqliteInit---------------------------------->./libsqlite.so {linebreak}sqlite_create_function--------------------->./libsqlite.so {linebreak}sqlite_open------------------------------->SQLiteTest.o {linebreak}sqliteRollbackAll------------------------->./libsqlite.so {linebreak}sqlite_error_string------------------------>./libsqlite.so {linebreak}sqlite_busy_timeout---------------------->./libsqlite.so {linebreak}sqlite_create_aggregate------------------>./libsqlite.so {linebreak}sqlite_last_insert_rowid------------------>./libsqlite.so {linebreak}sqlite_function_type---------------------->./libsqlite.so {linebreak}sqlite_exec------------------------------->SQLiteTest.o {linebreak}sqlite_close------------------------------>SQLiteTest.o {linebreak}ld: fatal: Symbol referencing errors. No output written to SQLiteTest {linebreak}Please instruct me how I can solve this problem. Thank you very much! I don't have SunOS and so I do not have any idea why your software is not working. But it appears to be a compilation problem, not an SQLite problem. So the bug report does not really belong here. Try asking for help on the SQLite newsgroup. This is a duplicate of ticket #389. #c8c8c8 390 code closed 2003 Jul anonymous Shell 2003 Jul 3 4 database creation Using sqlite to create a database when one does not yet exist, does not work until you do some dummy select. sqlite db314 .exit at the prompt (in a dosbox and no file shows up in the explorer) sqlite db314 select * from users; .exit at the prompt (in a dsobox and the file shows up as en empty file) This is a feature, not a bug. By delaying the creation of the database, you don't get an empty database if you mistype the name of database on the "sqlite" command line. Example: Suppose you want to look at database "fuzzy.db" but you mistype the name as "duzzy.db". As currently implemented, you can immediately type ".exit" to leave sqlite and no new files are created. #c8c8c8 389 event closed 2003 Jul anonymous Shell 2003 Jul 1 1 Undefined symbol {linebreak}$ cc -o SQLiteTest SQLiteTest.c -L . -R . -lsqlite {linebreak}Undefined _________________________ first referenced {linebreak} symbol ____________________________ in file {linebreak}sqlite_version------------------------------>./libsqlite.so {linebreak}sqlite_interrupt---------------------------->./libsqlite.so {linebreak}sqliteBtreeFactory------------------------>./libsqlite.so {linebreak}sqlite_freemem---------------------------->./libsqlite.so {linebreak}sqliteInit---------------------------------->./libsqlite.so {linebreak}sqlite_create_function--------------------->./libsqlite.so {linebreak}sqlite_open------------------------------->SQLiteTest.o {linebreak}sqliteRollbackAll------------------------->./libsqlite.so {linebreak}sqlite_error_string------------------------>./libsqlite.so {linebreak}sqlite_busy_timeout---------------------->./libsqlite.so {linebreak}sqlite_create_aggregate------------------>./libsqlite.so {linebreak}sqlite_last_insert_rowid------------------>./libsqlite.so {linebreak}sqlite_function_type---------------------->./libsqlite.so {linebreak}sqlite_exec------------------------------->SQLiteTest.o {linebreak}sqlite_close------------------------------>SQLiteTest.o {linebreak}ld: fatal: Symbol referencing errors. No output written to {linebreak}SQLiteTest #c8c8c8 388 code closed 2003 Jul anonymous Unknown 2003 Jul 2 1 sqlite-2.8.4.tar.gz doesn't have the Constants.java file Can't compile unless the Constants.java file is included You are mistaken. No file named "Constants.java" has ever been a part of SQLite. SQLite does not have anything to do with java. Perhaps you are trying to compile another package that uses SQLite and the file you need is missing from that other package. #cfe8bd 387 code fixed 2003 Jul anonymous Parser 2003 Jul 1 1 Parse has problems with parser names ... SELECT TW_Method.primaryKey primaryKey,TW_Method.name name,TW_Method.timeStamp timeStamp,TW_Method.version version,TW_Method.userName userName,TW_Method.trace trace,TW_Method.className className,TW_Methods.packageRef packageRef,TW_Method.sourceCodeID sourceCodeID,TW_Method.protocolName protocolName,TW_Blob.blobData blobData,TW_Blob.blobType blobType FROM TW_Methods, TW_Method, TW_Blob WHERE TW_Methods.methodRef = TW_Method.primaryKey AND TW_Method.sourceCodeID = TW_Blob.primaryKey AND packageRef = 161 AND primaryKey NOT IN ( SELECT methodRef FROM TW_Methods WHERE packageRef = 159 ) : ambiguous column name: primaryKey ambiguous column name: primaryKey The parser has problems with the alias names ... No change. It appears that Oracle, PostgreSQL, and SOLID all work the same way. SQLite could be changed so that it would prefer a name assigned by AS over a regular column name, but a survey on the SQLite mailing list suggested that people do not want this. They prefer the current behavior. I will attach diffs against the expr.c source module that could be used to give precedence to AS-clause names. #f2dcdc 386 new active 2003 Jul anonymous 2003 Jul 5 1 compile on WinCE ? 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 #cfe8bd 385 new fixed 2003 Jul anonymous 2003 Jul 4 4 NULL args for output variables to sqlite_step cause access violation The three output arguments to the sqlite_step() function all cause an access violation if a NULL pointer is passed. These arguments should be checked for NULL before updating the output variable (like the pzErrmsg argument to other sqlite functions). This will avoid the access violation exception, and would allow the caller to signal that they did not require that portion of the output. This could be useful if the names have already been retrieved by the execution of another VM previously. Additional VMs could be passed NULL for the pazColnames argument and then sqlite_step would not have to build the column names array. I'm not sure how useful calling this function with a NULL value for the pN argumnet would be, but it should be allowed for consistancy (and to avoid the access violation). #cfe8bd 384 new fixed 2003 Jul anonymous 2003 Jul 4 4 NULL argument for pzTail to sqlite_compile causes access violation The third, pzTail argument to sqlite_compile can not be NULL. If it is, an access violation occurs. The sqlite_compile function should check if this argument is NULL and not update the output variable if it is (in the same way as the pzErrmsg pointer is handled). Many times the caller will be passing a single SQL statement, and does not need the tail of the statement (which is an empty string) set. This change would allow the caller to pass NULL for the third argument and avoid having to declare a dummy char pointer variable to pass to sqlite_compile(). #cfe8bd 383 code fixed 2003 Jul anonymous Unknown 2003 Jul 1 3 sqlite_changes returns wrong value with non-callback API The actual values returned by sqlite_changes() do not agree with the description in section 3.2 of the C/C++ API documentation at http://www.hwaci.com/sw/sqlite/c_interface.html when used with the non-callback API. The docs say it will return the number of rows changed since the last sqlite_compile. It actually returns the number of rows changed by any unfinalized VM's and the last finalized VM. I have attached a simple test program that demonstrates the problem. It simply executes two VMs that each insert a single row into a table. Running it with no arguments causes the first VM to be left un-finalized until the end. In the case the second call to sqlite_changes returns the incorrect value 2. Running it with any argument causes the first VM to be finalized before the second is executed. In this case the expected result is returned. This bug causes a problem with Marco Wobben's SQLite dbExpress driver for Borlands Delphi and C++ environments. The Borland dbExpress libraries leave commands unfinalized while executing other commands, and at the same time check the number of rows affected by the commands. If the number of affected rows is more or less than expected, it throws an exception. Updated the documentation to be more explicit about exactly what sqlite_changes returns. I noticed that the revised documentation is not being distributed on the web site yet (as of 2003-07-15). Perhaps there something else you need to do to make this happen. #c8c8c8 382 code closed 2003 Jul Unknown 2003 Jul 2 2 Triggers stop firing under certain situations I have encountered a very strange problem with sqlite (tested with 2.8.4 and latest post 2.8.4 code base using MSVC7.1). I have a table with a temp AFTER UPDATE trigger (also occurs with AFTER INSERT) defined. I start a transaction, create a temp table, then do an update on the table with the temp AFTER UPDATE trigger. I then call splite_exec with a callback function that returns false on it's first invocation (preventing further records from being retrieved). After this, no triggers fire for that instance of sqlite. Requirements to see the error: 1) have a trigger defined (AFTER INSERT or AFTER UPDATE, maybe others) 2) create a table (temp or non-temp) 3) call sqlite_exec with a callback that returns a non-zero result 4) do these things inside an explicit transaction future updates/inserts will not fire triggers defined in the db... The only workaround I can find is to not return a non-zero result from callbacks... Kevin Alons Additional Info: Here is a quick c routine to duplicate the problem. ==== #include "sqlite/sqlite.h" static int static_Callback(void *instance, int argc, char **argv, char **azColName) { return 1; } int main() { sqlite* db; db = sqlite_open("c:\\test.db", 0, 0);{linebreak} sqlite_exec(db, "CREATE TABLE Test (a);\n", 0, 0, 0);{linebreak} sqlite_exec(db, "INSERT INTO Test (a) VALUES ('Test1');", 0, 0, 0);{linebreak} sqlite_exec(db, "CREATE TABLE TrigResult (a);", 0, 0, 0);{linebreak} sqlite_exec(db, "CREATE TEMP TRIGGER trigTest_AU AFTER UPDATE ON Test FOR EACH ROW BEGIN INSERT INTO TrigResult (a) VALUES (new.a); END;", 0, 0, 0);{linebreak} //trigger fires just fine{linebreak} sqlite_exec(db, "BEGIN; UPDATE Test SET a = 'Test2'; COMMIT;", static_Callback, &static_Callback, 0);{linebreak} // select a single row (but use a callback that returns non-zero to terminate){linebreak} sqlite_exec(db, "BEGIN; SELECT Count(*) FROM Test; COMMIT;", static_Callback, &static_Callback, 0);{linebreak} // trigger no longer fires {linebreak} sqlite_exec(db, "BEGIN; UPDATE Test SET a = 'Test3'; COMMIT;", 0, 0, 0);{linebreak} sqlite_exec(db, "BEGIN; UPDATE Test SET a = 'Test4'; COMMIT;", 0, 0, 0);{linebreak} // 'Test2' will be in the TrigResult table, but not 'Test3' or 'Test4'{linebreak} sqlite_close(db);{linebreak} } Hmmm... Is the CREATE TRIGGER inside the same transaction that for which the callback returns non-zero? A non-zero callback return causes the transaction to rollback which effectively deletes the trigger. Could that be the source of your problem? No, the create trigger wasn't inside the transaction... I posted the test code previously, but later realized that it had errors that precluded it from properly identifying the problem. Instead I have created a new ticket (#420 for an enhancement that proposes a solution that works for me related to cancelling a callback). I am closing this ticket and hoping you can review my ticket #420 and include it (or something similar) in future sqlite releases. #f2dcdc 381 new active 2003 Jul anonymous 2003 Jul 1 3 Support for DJGPP and DOS 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:_ {linebreak} Use ROM-DOS 7.1(from datalight) #c8c8c8 380 code closed 2003 Jul anonymous Unknown 2003 Jul 2 2 "uniqueness constraint failed" on insertion of distinct rows The below happens when running the 2.8.2-2 debian package, accessing sqlite through version 0.4.3 of the Python bindings. The attached script permits reproduction of the issue. Note that the failing constraint is that on the primary key, "(filename, revision)", though *both* filename and revision are different between the two rows (the former changing from 11 to 111 and the latter from '1.1' to '1.10'). Works as designed. See http://www.sqlite.org/datatypes.html. The SQL to reproduce the observed behavior is as follows: create table revision ( changeset integer, filename string, revision string, primary key (filename, revision), unique (filename, changeset) ); insert into revision values(11, 'controller/Controller.java', '1.1'); insert into revision values(111, 'controller/Controller.java', '1.10'); The uniqueness constraint that fails is the one associated with the primary key. The datatype "string" on both the FILENAME and REVISION columns does not contain characters BLOB, CHAR, CLOB, or TEXT so it is interpreted as a numeric datatype. Hence '1.1' is equal to '1.10'. The filenames are also the same so the uniqueness check fails. The solution here is to change the datatype of FILENAME and REVISION to "TEXT". The following SQL works as desired: create table revision ( changeset integer, filename text, revision text, primary key (filename, revision), unique (filename, changeset) ); insert into revision values(11, 'controller/Controller.java', '1.1'); insert into revision values(111, 'controller/Controller.java', '1.10'); #c8c8c8 379 new closed 2003 Jul anonymous 2003 Jul 5 1 use \' and \" instead of '' and "" only It would be nice if insert into tb1(1, 'something \'weird\' happens'); can be implemented instead of only insert into tb1(1, 'something ''weird'' happens'); The consensus on the mailing list is that this is a bad idea and should be rejected. #cfe8bd 378 doc fixed 2003 Jul anonymous Shell 2003 Jul 5 4 sqlite command line utility still needs file name According to the Wiki (InMemoryDatabase) the sqlite utility can now be given a file name of :memory: to create an in-memory db. That appears to work fine. The same wiki page also indicates that if the sqlite utility is given no file name it defaults to creating an in-memory db. *That does not appear to work* as shown here: ~# sqlite Usage: sqlite [OPTIONS] FILENAME [SQL] Use the -help option for additional information ~# sqlite -version 2.8.4 ~# myconfig Linux 2.4.19; libc.so.6 2.2.5; gcc 2.95.3 I corrected the text on the Wiki page. #cfe8bd 377 code fixed 2003 Jul anonymous 2003 Jul 1 3 Comparisons of integer primary key to float are erroneous The integer-primary-key always compares < the float. This crops up in practice when you do something like select * from tbl where key < (select avg(key) from tbl); If avg(key) turns out to be a float, you get the whole table; if you change the comparison to >, you get nothing. (The behavior is the same with constants, but that's less likely in practice.) #c8c8c8 375 new closed 2003 Jul anonymous 2003 Jul anonymous 4 4 I'm missing DB metadata. I'm either unable to find any doc on the page or it's a missing feature.{linebreak}{linebreak} I'm looking for a command(s) that return the DB metadata like tablenames, fieldnames and fieldtypes, index.{linebreak} This would make it possable to create frontend GUI's using PHP for example. Or dyn. add missing fields a.s.o. -- sam RTFFAQ: http://www.sqlite.org/faq.html#q9 #c8c8c8 374 code closed 2003 Jul anonymous Pager 2003 Jul 1 1 btree crash in moveto - sqlitepager_get I don't use the whole SQLite, just the Btrees. This bug only happens when I make a change in the database, close the transaction, open a new transaction, create a cursor a call sqliteBtreeMoveto(...). Then it crashes in sqlitepager_get(...) at this code: if( pPager->aInJournal && (int)pgno<=pPager->origDbSize ){ sqliteCheckMemory(pPager->aInJournal, pgno/8); assert( pPager->journalOpen ); pPg->inJournal = (pPager->aInJournal[pgno/8] & (1<<(pgno&7)))!=0; pgno/8 is too big. When I put another code working with Btree between the two transactions, the crash doesn't happen. Direct use of the btree layer is not supported. The btree interface may change in unpredictable ways from one release to the next. If you use the btree interface, you run the risk that a future version of SQLite might break your code. That said, we would still like to understand the problem you are seeing. But without an actual test case or example code to produce the error, there is not much we can do. #c8c8c8 372 event closed 2003 Jul anonymous Unknown 2003 Jul anonymous 1 1 tcl.h missing in windows source code I have download windows source code from http://www.sqlite.org/download.html I'm trying to build a C++ Builder Component (for borland fan) to make SQLite available inside C++ Builder EDI. It seems that "tcl.h" is missing. *[C++ Error] tclsqlite.c(19): E2209 Unable to open include file 'tcl.h'* Where can I get full source code ? (is SQLite community interested by such a component) Assuming you need TCL scripting integration then you can get it from here: http://tcl.sourceforge.net/ If you're not interested in TCL integration then don't compile/link the files which need it. ---- I don't know who entered the remarks above, but they are exactly right. If you don't want the TCL integration, don't compile the files that use it. Case closed. #cfe8bd 354 code fixed 2003 Jun anonymous Unknown 2003 Jul 3 2 ATTACH DATABASE call asserts in build.c in Debug Mode in MSVC7.1 From Version 2.8.3 to latest code, I get an ASSERT in build.c (line 1699: Expression: p == pIndex) when trying to attach a database using the following syntax: ATTACH DATABASE 'c:\test.db' AS Attached; If I use the debug version of the compiled dll (using MSVC) I get this error. I think the ASSERT is in error, because I can use the non-debug compiled dll with normal operation, and no side-effects. Even the simplest case demonstrates this behaviour for me. I created c:\test.db with one table, using the following create statement: CREATE TABLE Test (TestID INT PRIMARY KEY, TestString TEXT NULL); INSERT INTO Test VALUES TestString, 'X'); I then ran the above ATTACH DATABASE statement (attaching the same db to itself), and the assertion is raised. If I continue (ignoring the assertion), the table is attached normally and can be queried and DETACHED (with no assertion). I get the ASSERT failure as described above. #cfe8bd 346 code fixed 2003 Jun anonymous BTree 2003 Jul 3 3 Problem with LIMIT 0 SELECT * FROM my_table LIMIT 0; Will return all rows from my_table rather then returning nothing. Works as designed. A LIMIT of zero means that there is no limit. This is documented. I'm told that other SQL database engines work the same way. No change. ---- Further investigation reveals that other SQL database engines return zero rows on LIMIT 0. Use LIMIT -1 to turn off the limit. This change has now been implemented. #cfe8bd 318 code fixed 2003 May anonymous Unknown 2003 Jul drh 1 1 dl-minimal.c: 128: realloc: Asseration failure... 369 if( rc!=SQLITE_OK ){ (gdb) n 381 sqliteRegisterBuiltinFunctions(db); (gdb) n 382 rc = sqliteInit(db, pzErrMsg); (gdb) n Inconsistency detected by ld.so: dl-minimal.c: 128: realloc: Assertion `ptr == alloc_last_block' failed! Program exited with code 0177. I am using an FPC binding available from: http://befpc.sourceforge.net/sqlite_fpc_beos.zip I have compiled and installed sqlite 2.8.0, the shell works perfectly, have created and used databases manually. I have not tested any C written code however, am trying to use FPC bindings... cheers James PS: prologic at prologitech dot com should you need to contact me... This was a problem using FPC in that SQLite expects to be able to move around the buffers passed to it (So I've been told by the FPC Developers). FPC's default memory manager is slightly different so in order to remedy this you must use the C memory manager unit that comes with FPC. ie: uses cMem; cheers James #c8c8c8 261 code closed 2003 Mar anonymous Unknown 2003 Jul 2 3 Non Callback Finalize Bug Using the non-callback api's I still need to "step" until the "eof" is triggered. Otherwise the "finalize" will fail. Unable to reproduce. I am able call sqlite_finalize() at any time without problems. > Sorry, my fault. everything is ok for this report. #c8c8c8 196 code closed 2002 Nov anonymous BTree 2003 Jul 4 3 there are the same record in a table,why? there are the same record in a table,why? how to do? I do not know what this ticket means... #f2dcdc 184 new active 2002 Oct mike 2003 Jul drh 5 3 auto update mechanism for CVS is it possible to set up CVS in such a way that we are notified of activities on tickets, and check-ins? #c8c8c8 119 doc closed 2002 Jul anonymous 2003 Jul 5 5 How to Compile Sqlite.dll With VC++ How to Compile Sqlite.dll With VC++ or Else Language This is documented for the current version of VC++ in the following web page: http://cvs.hwaci.com/sqlite/wiki?p=HowToCompileWithVsNet #cfe8bd 367 code fixed 2003 Jun anonymous Unknown 2003 Jun 4 1 soundex bug In func.c line 293: sqlite_set_result_string(context, zResult, "?000", 4); should be changed to: sqlite_set_result_string(context, "?000", 4); #f2dcdc 366 new active 2003 Jun anonymous Unknown 2003 Jun drh 4 3 Functions sqlite_(en/de)code_binary() not in sqlite.h The handy utility functions sqlite_encode_binary() and sqlite_decode_binary() from encode.c don't have any declarations in sqlite.h #cfe8bd 365 code fixed 2003 Jun anonymous VDBE 2003 Jun 3 4 Can not define SQLITE_OMIT_AUTHORIZATION Problem: if one uncomments the /*#define SQLITE_OMIT_AUTHORIZATION 1 */ in sqliteint.h then the library can not be built, generating errors in some of the files (parser.c, delete.c and some others.) This is a bug in the definition of sqliteAuthCheck, very easy to address. To fix it, change line 1183 of sqliteint.h from # define sqliteAuthCheck(a,b,c,d) SQLITE_OK to # define sqliteAuthCheck(a,b,c,d,e) SQLITE_OK This appears to be a duplication of ticket #353 which has already been fixed. #cfe8bd 364 code fixed 2003 Jun anonymous 2003 Jun 3 3 Assert when doing SELECT ROWID,* against a VIEW When SELECTing a ROWID against a VIEW, the sqlite command-line utility asserts: sqlite> CREATE VIEW v1 AS SELECT * FROM t1,t2 WHERE t1.a = t2.a; sqlite> SELECT * FROM v1; zzz|xxx|yyy|zzz|aaa|bbb yyy|zzz|xxx|yyy|iii|jjj sqlite> SELECT ROWID,* FROM v1; ./src/vdbe.c:4224: failed assertion `pC->pCursor!=0' Abort #f2dcdc 363 new active 2003 Jun anonymous VDBE 2003 Jun jadams 5 5 sqlite support domain as user defined type sqlite support domain as user defined type #f2dcdc 362 event active 2003 Jun anonymous Shell 2003 Jun jadams 4 2 Problem with select count select count() nonetable; select count without FROM always return 1, not return error message :-) #cfe8bd 361 code fixed 2003 Jun anonymous Unknown 2003 Jun anonymous 3 3 main.c doesn't compile when SQLITE_OMIT_TRACE=1 There are some #ifdef missing in main.c. Also settings SQLITE_OMIT_AUTHORIZATION=1 causes some warnings about the number of arguments in sqliteAuthCheck. I think a parameter is missing in the sqliteAuthCheck definition in sqliteInt.h The SQLITE_OMIT_AUTHORIZATION error has already been reported (see ticket #353) and fixed. The SQLITE_OMIT_* macros are designed to remove extraneous features in order to save code space. But SQLITE_OMIT_TRACE was not removing very much code. So I have removed all SQLITE_OMIT_TRACE macros from the code. Tracing is now always enabled. #cfe8bd 360 code fixed 2003 Jun anonymous Unknown 2003 Jun 2 3 "not N between n and m" in trigger dumps core create table foo (bar integer default 1 not null); create trigger foo_insert before insert on foo for each row begin select case when (not new.bar between 0 and 20) then raise (rollback, 'aiieee') end; end; insert into foo (bar) values (1); #c8c8c8 359 code closed 2003 Jun anonymous 2003 Jun 1 1 sum() returns incorrect value The sum() statement on the 8th field below should return 0.00 sqlite> select * from gentrn where glt_cono = 1 and glt_acno = 6130; 1|6130|200203|20020331|4| 73|3.81|-1224.53|0.0|ACM|N|N|N 1|6130|200203|20020331|5| 302|3.71|74.60|0.0|DU B|N|N|Y 1|6130|200203|20020331|5| 302|3.71|590.43|0.0|marx|N|N|Y 1|6130|200203|20020331|5| 9980|3.71|244.5|0.0|kriel|N|N|Y 1|6130|200203|20020331|5|9909979|3.71|315.0|0.0|kriel|N|N|Y 1|6130|200205|20020531|4| 70|5.81|-92.10|0.0||N|N|N 1|6130|200205|20020531|5| 250302|5.71|92.10|0.0|MARX|N|N|Y 1|6130|200209|20020930|2| 270902|9.21|-284.80|0.0|mulligan|N|N|N 1|6130|200209|20020930|5| 902|9.71|284.80|0.0|DIETRICH|N|N|Y sqlite> select sum(glt_tramt) from gentrn where glt_cono = 1 and glt_acno = 6130; -1.13686837721616e-13 sqlite> A more lucid error report might have omitted all the irrelavent fields. Like this: SELECT glt_tramt FROM gentrn WHERE glt_cono=1 AND glt_acno=6130; -1224.53 74.60 590.43 244.5 315.0 -92.10 92.10 -284.80 284.80 The answer you are getting is very close to zero. The difference is due to the fact that several of the numbers you are adding (ex: -1224.53) cannot be exactly represented in a finite-length binary number. So your CPU is using an approximation. And when you do a subtraction of two approximation, the error term gets very big relative to the result. If you only want two digits of precision in your result, use the build-in SQLite function round(). Like this: SQLITE round(sum(gmt_tramt),2) FROM ... ***Works As Designed*** #c8c8c8 358 code closed 2003 Jun anonymous Unknown 2003 Jun 1 1 Problems with inserting file (.bmp; .jpg) in BLOB field create table pic (id integer, p blob); insert into pic (id, p) values (1, 'c:/somedir/somefile.bmp'); //...or similar syntaxis - Don't work copy pic(p) from 'c:/somedir/somefile.bmp' where id = 1; //...or similar syntaxis - Don't work Neither are suppose to work. See the documentation or ask questions on the mailing list for additional help. ---- _2005-Oct-03 02:47:54 by anonymous:_ {linebreak} mind telling us how, then? ---- _2005-Oct-03 05:53:52 by anonymous:_ {linebreak} If you're reading this, you should see links entitled "documentation" and "mailing list" at the top of the page. Follow them. Your problem is that you appear to expect that if you specify a filename as an argument to an INSERT statement involving a BLOB field, SQLite will insert the *content* of the file into the row. In fact, SQLite (or, for that matter, any SQL-based data management system) will insert the *name* of the file. If you want to insert the content, you'll have to first read it itself. #f2dcdc 356 new active 2003 Jun anonymous VDBE 2003 Jun 5 2 Returns real error codes 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:_ {linebreak} 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. #cfe8bd 355 code fixed 2003 Jun anonymous BTree 2003 Jun 4 3 Compile warning when NDEBUG is defined In btree.c, allocateSpace() has an unused variable, "cnt", when NDEBUG is defined. #cfe8bd 353 code fixed 2003 Jun anonymous 2003 Jun 4 3 Compile errors when SQLITE_OMIT_AUTHORIZATION is defined When SQLITE_OMIT_AUTHORIZATION is turned on, the sqliteAuthCheck() stub macro only has 4 arguments, where the real function expects 5, causing compile errors. Also this flag causes a warning in trigger.c that sContext is unused because all the functions are stubbed out. Suggest this workaround: # define sqliteAuthContextPop(a) ((void)(a)) #cfe8bd 352 code fixed 2003 Jun anonymous Shell 2003 Jun 3 3 The sqlite shell ignores empty lines inside SQL strings *Problem:* Running the following SQL in the sqlite shell results in the empty lines disappearing: create table foobar (x); insert into foobar values ('This is a text with several empty lines'); *Brute force fix:* --- shell.c 19 May 2003 23:55:30 -0000 1.80 +++ shell.c 14 Jun 2003 13:13:14 -0000 @@ -1002,7 +1002,7 @@ seenInterrupt = 0; } if( p->echoOn ) printf("%s\n", zLine); - if( _all_whitespace(zLine) ) continue; + /*if( _all_whitespace(zLine) ) continue;*/ if( zLine && zLine[0]=='.' && nSql==0 ){ int rc = do_meta_command(zLine, p); free(zLine); *Proper fix:* Make the shell recognize when it is inside of a string which hasn't been terminated yet. #cfe8bd 351 code fixed 2003 Jun anonymous Pager 2003 Jun 2 3 Journal pager playback doesn't secure exclusive access The sqlitepager_get() routine opens the journal file using sqliteOsOpenReadWrite(), while the comment suggests it intends to gain exclusive access. The journal is then read and played back without obtaining exclusive access or even using a read lock. I think this could cause some very serious issues in certain conditions. The journal file is never open except when there is a write lock (a.k.a an exclusive lock) on the main database file. So even though the journal file itself is not locked, the database file is, which prevents other threads and/or processes from accessing the the journal. #cfe8bd 350 code fixed 2003 Jun anonymous Unknown 2003 Jun 2 3 LEFT JOIN works improperly on static inner queries and views Lets say I have 2 tables, "Objects" and "Properties", that look like that (fictive crapy example so don't tell me my datamodel sucks hahaha!): *:Objects{linebreak} OBJECT_ID OBJECT_NAME --------- ----------- 1 Toto 2 Titi 3 Tutu 4 Tata *:Properties FOREING_OBJECT_ID PROPERTY_NAME PROPERTY_VALUE ----------------- ------------- -------------- 1 TYPE MyClass 1 VALUE AnyValue 2 TYPE String 2 VALUE Testing 2 LENGTH 7 3 TYPE String If I do the following SQL statament, I get the following result which is OK: SELECT o.object_id, p.property_name, p.property_value FROM objects AS o LEFT JOIN properties AS p ON o.object_id = p.foreing_object_id; OBJECT_ID PROPERTY_NAME PROPERTY_VALUE --------- ------------- -------------- 1 TYPE MyClass 1 VALUE AnyValue 2 TYPE String 2 VALUE Testing 2 LENGTH 7 3 TYPE String 4 But if I do the following query, I get only the following results wich, from my point of view isn't good: SELECT o.object_id, p.property_value FROM objects AS o LEFT JOIN (SELECT * FROM properties WHERE property_name = 'VALUE') AS p ON o.object_id = p.foreing_object_id; OBJECT_ID PROPERTY_VALUE --------- -------------- 1 AnyValue 2 Testing I would have expected to get: OBJECT_ID PROPERTY_VALUE --------- -------------- 1 AnyValue 2 Testing 3 4 The same problem occurs if I create views out of my inner queries. It seems to be the same problem as in #306 that should have been fixed by version 2.8.1 I believe. This problem is similar to #306 in that it results from the query optimizer being overly aggressive in its attempts to optimize LEFT OUTER JOINs. But the specific cause the problem is different. #cfe8bd 347 code fixed 2003 Jun anonymous BTree 2003 Jun 4 3 Workaround for warning that print_node() in btree_rb.c is unused Although this function is intentionally unused, it can cause a compiler warning. A possible workaround: static void print_node(BtRbNode *pNode) { char * str = append_node(0, pNode, 0); printf(str); /* avoid compiler warning that function is not used */ (void)print_node; } #cfe8bd 345 event fixed 2003 Jun anonymous BTree 2003 Jun 4 4 repeated returns Two repeated returns at function memRbtreeRollbackCkpt(), on file btree_rb.c, line 1329. May cause some compilers problems. #c8c8c8 344 event closed 2003 Jun anonymous 2003 Jun 1 1 select SELECT OBJECTID, OBJECTTYPE, VID_IMOT.name, IMOTI.plsn_no, IMOTI.no_kv, IMOTI.parcel, IMOTI.imm_area, IMOTI.mestnost, IMOTI.address, IMOTI.komentar, 0, IMOTI.MUNID, IMOTI.KVID, IMOTI.STRID, IMOTI.STREETNUM, IMOTI.BLOCK, IMOTI.ENTR, IMOTI.ET, IMOTI.APART FROM OBJECT_STATUS AS OS INNER JOIN IMOTI ON OS.OBJECTID=IMOTI.IMOT_ID INNER JOIN VID_IMOT ON IMOTI.VID = VID_IMOT.ID WHERE DOC_ID IN(SELECT DOC_ID FROM DOKUMENTI WHERE IZDATEL = 1 AND NO_AKT = '1' AND ENDDATE IS NULL) AND DOC_ID IN (SELECT MAX(DOC_ID) FROM OBJECT_STATUS WHERE OBJECTID = OS.OBJECTID AND DOC_ID <= 1000 AND ENDDATE IS NULL AND TYPE = 1) AND OS.type = 1AND OS.EndDate Is Null AND IMOTI.EndDate Is Null AND OS.OBJECTTYPE <= 6 ORDER BY OBJECTID I do not understand what this ticket means. #c8c8c8 343 new closed 2003 Jun anonymous Parser 2003 Jun 3 1 insert single quote value in SQL statement I cannot insert value the single quote, "'". sqlite> create table test(word varchar(30)); sqlite> insert into test values('test"'); sqlite> insert into test values('test2\''); ...> ...> ; ...> ; I know the other RDBMS already support this, "\'". Thanks. In standard SQL, the way to include a single quote in a string is to double it, like in Pascal. Example: INSERT INTO test VALUES('Hi, Y''all'); ^^-- evaluates to a single embedded quote. The use of a backslash is nonstandard and could (in theory) break well-formed SQL scripts. Therefore, this change request is rejected. #cfe8bd 342 code fixed 2003 Jun anonymous 2003 Jun 5 3 vxprintf() makes invalid assumptions about size of pointer and long On lines 392, 404, and 514 of printf.c, vxprintf() makes casts from pointers to longs. On some systems, these types are different sizes (32 and 64 bits respectively, for example), so this can cause warnings during compilation on gcc with the warning levels set high enough. #cfe8bd 341 code fixed 2003 Jun anonymous VDBE 2003 Jun 4 3 vdbe.c calls access() instead of sqliteOsFileExists() In sqliteVdbeMakeReady(), there is a call to access(). It is not safe to assume that access() is available on every platform, so it should use the wrapper function sqliteOsFileExists() instead: _:#ifdef MEMORY_DEBUG _::if( sqliteOsFileExists("vdbe_trace") ){ _:::p->trace = stdout; _::} _:#endif Also this block can be removed: _:#ifdef MEMORY_DEBUG _::extern int access(const char*,int); _:#endif #cfe8bd 340 code fixed 2003 Jun anonymous 2003 Jun 1 2 ATTACH database needs an authorization hook When used with the PHP bindings, ATTACH database presents a security risk in that it can bypass the safe_mode settings and give access to files that are otherwise off-limits. The only workaround for those worried by this is to use an older version of sqlite. It would be great if you could provide me with a patch that implements an authorizer callback. I can merge this into the PHP bundled sqlite library and rest easier until the next release. [We are planning to go "gold" with the sqlite extension in the next couple of weeks and demonstrate it at the Linux Tag conference in July] #cfe8bd 337 code fixed 2003 Jun anonymous Unknown 2003 Jun 4 4 .dll produces database files claiming version 2.0.1 I recently downloaded and started experimenting with the precompiled .dll. I quickly threw together a test bed in a console app. (using VC++ 6) and started playing. I noticed that when I opened a database file with notepad, that the version line appears to be an older version. Is this truly the version of the code that is compiled in the .dll, or did you just forget to update the version string before creating the .dll. I'd really appreciate it if you could get back to me on this. Thanks! -Jeff Luckett I'm guessing it says version "2.1" not "2.0.1". This is by design. See section 3.1 of http://www.sqlite.org/fileformat.html. #cfe8bd 336 code fixed 2003 Jun anonymous 2003 Jun 4 2 Compiler warnings on SQLite 2.8.3 Compiler warnings of SQLite 2.8.3, on VC++ 7.1 [source file (line) : warning] vdbe.c(2289) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data pager.c(947) : warning C4018: '>=' : signed/unsigned mismatch os.c(1006) : warning C4101: 'tmpOsType' : unreferenced local variable btree.c(2480) : warning C4018: '<' : signed/unsigned mismatch insert.c(751) : warning C4700: local variable 'extra' used without having been initialized pager.c(499) : warning C4018: '>' : signed/unsigned mismatch The uninitialized variable on line insert.c:751 is a real bug that was introduced by check-in [999]. The others are just nuisance warnings but have been fixed nevertheless. #f2dcdc 335 event active 2003 Jun anonymous Unknown 2003 Jun drh 2 2 ChangeCount still failing 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? #cfe8bd 334 code fixed 2003 Jun drh CodeGen 2003 Jun 1 1 REPLACE statement corrupts indices The following sequence of SQL statement will corrupt the index used to implement the UNIQUE constraint. The result will be that the SELECT statement at the end will return a single row of data: a=1, b=4. CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE); INSERT INTO t1 VALUES(1,2); INSERT INTO t1 VALUES(2,3); REPLACE INTO t1 VALUES(1,4); SELECT * FROM t1 WHERE b=2; This bug appears to have been here since the ON CONFLICT logic was first added in versoin 2.3.0, nearly a year and a half. #cfe8bd 333 code fixed 2003 Jun anonymous Unknown 2003 Jun 1 1 Temp Triggers cause update/delete statement failure with explicit transaction If a temp update trigger containing an insert statement (which selects data from a table) is created on a non-temp table, and an update statement is executed this table within an explicit transaction, that statement will fail with the following error: "SQL error or missing database. SQL logic error or missing database" See the small attached sample script that will demonstrate the problem. Additionally, I have found that delete triggers have the same type of bug, if a temp delete trigger that matches the above criteria is defined, then the same error message will be generated for a delete action on the table with the same type of WHERE clause as the update examples. TIA, Kevin #bde5d6 332 code tested 2003 May anonymous Unknown 2003 Jun 5 1 Dropping a temp trigger causes an access violation Dropping a temp trigger (created using CREATE TEMP TRIGGER syntax) using DROP TRIGGER syntax causes an access violation (terminates sqlite), at least when compiled as a dll using MSVC7.0. TIA, Kevin the latest code [as of 6/18/2003] has rectified this (might have been fixed 2.8.3, I didn't check). Definitely should be fixed in 2.8.4. #f2dcdc 331 new active 2003 May anonymous Unknown 2003 Jun mike 5 5 Went to compile Win32 project and found a missing header reference 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. #cfe8bd 323 code fixed 2003 May anonymous CodeGen 2003 Jun 1 1 Assertion failed by attaching a file Testing the new features of SQLite, I got an 'Assertion failed' by merging a files, which contains the same table, with the same UNIQUE INDEXES. sqlite.out test.db SQLite version 2.8.2 Enter ".help" for instructions sqlite> create table xxx(tel integer); sqlite> CREATE UNIQUE INDEX myindex on xxx(tel); sqlite> exit sqlite.out test1.db SQLite version 2.8.2 Enter ".help" for instructions sqlite> create table xxx(tel integer); sqlite> CREATE UNIQUE INDEX myindex on xxx(tel); sqlite> attach database 'test.db' as newdb; sqlite.out: sqlite/src/build.c:1629: sqliteCreateIndex: Assertion pTab->iDb==pParse->iDb || isTemp==1' failed. #c8c8c8 320 doc closed 2003 May anonymous 2003 Jun jplyon 5 3 PRAGMA documentation should include numeric values of settings Documentation for PRAGMAs should include the numeric values since that is what the sqlite utility shows. E.g. sqlite> PRAGMA default_synchronous; 1 sqlite> But the documentation shows values of FULL, NORMAL and OFF, doesn't mention which one of these is == 1. Documented all PRAGMA integer values. #cfe8bd 262 new fixed 2003 Mar anonymous Unknown 2003 Jun 4 4 Non Callback is Slow on scripts Performance was and is great using the callback api. I could create 14 tables do 6000 inserts within a single transaction in less than 1.5 seconds. Now I'm using the non-callback mechanism and the script needs to be run until the "Tail" of the statement to be executed is nil (or empty string!). This takes ages to finish... :( See remarks on ticket #261. #f2dcdc 273 new active 2003 Mar drh CodeGen 2003 Mar drh 1 1 Make NULL_ALWAYS_DISTINCT a pragma rather than a compile-time option 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. #f2dcdc 271 event active 2003 Mar anonymous Unknown 2003 Mar drh 3 2 'make test' fails on MacOS X 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. {linebreak} {linebreak}---- from 'make test' with or without -DSQLITE_TEST=1 {linebreak} trans-9.1... {linebreak} Error: no such function: randstr {linebreak} trans-9.2.1-0... {linebreak} Error: cannot start a transaction within a transaction {linebreak} trans-9.2.2-0... {linebreak} Error: cannot start a transaction within a transaction {linebreak} trans-9.2.9-0... {linebreak} Error: no such function: randstr {linebreak} trans-9.3.1-0... {linebreak} Error: cannot start a transaction within a transaction {linebreak} trans-9.3.2-0... {linebreak} Error: cannot start a transaction within a transaction {linebreak} trans-9.3.9-0... {linebreak} Error: no such function: randstr {linebreak} trans-9.4.1-0... {linebreak} Error: cannot start a transaction within a transaction {linebreak} trans-9.4.2-0... {linebreak} Error: cannot start a transaction within a transaction {linebreak} trans-9.4.9-0... {linebreak} Error: no such function: randstr {linebreak} trans-9.5.1-0... {linebreak} Error: cannot start a transaction within a transaction {linebreak} *** Giving up... {linebreak} 11 errors out of 13684 tests {linebreak} Failures on these tests: trans-9.1 trans-9.2.1-0 trans-9.2.2-0 {linebreak} 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 {linebreak} trans-9.4.2-0 trans-9.4.9-0 trans-9.5.1-0 {linebreak} make: *** [test] Error 1 {linebreak} {linebreak}---- from 'make': {linebreak} ld: multiple definitions of symbol _btree_native_byte_order {linebreak} auth.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} btree.lo definition of _btree_native_byte_order in section (__DATA,__data) {linebreak} build.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} delete.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} expr.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} func.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} hash.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} insert.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} main.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} os.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} pager.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} ld: multiple definitions of symbol _journal_format {linebreak} btree.lo definition of _journal_format in section (__DATA,__common) {linebreak} pager.lo definition of _journal_format in section (__DATA,__data) {linebreak} ld: multiple definitions of symbol _pager_refinfo_enable {linebreak} btree.lo definition of _pager_refinfo_enable in section (__DATA,__common) {linebreak} pager.lo definition of _pager_refinfo_enable in section (__DATA,__data) {linebreak} parse.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} printf.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} random.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} select.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} table.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} tokenize.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} update.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} util.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} vdbe.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} where.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} trigger.lo definition of _btree_native_byte_order in section (__DATA,__common) {linebreak} make: *** [libsqlite.la] Error 1 _2004-Aug-14 00:40:23 by anonymous:_ {linebreak} On Mac OSX 10.3.5 with sqlite 3.0.4, "make test" resulted in:{linebreak} _: 0 errors out of 22420 tests I suggest this bug be closed. ---- _2004-Nov-09 20:48:41 by anonymous:_ {linebreak} Server compiled fine here on Mac OS X 10.3.6, none of the tests fail. #c8c8c8 267 code closed 2003 Mar anonymous Unknown 2003 Mar anonymous 1 4 sqlite.dll / sqlite.def does not export an Init function My error: Gerhard Haering (PySQLite co-author) pointed out that PySQLite is statically linked with sqlite - I was confusing things by explicitly adding a naked copy of sqlite.dll I removed that, it works. Case closed. Thanks. I just downloaded the latest Windows binary DLL, filesize 102627. Trying to use it with PySQLite & Python. At import sqlite an error is raised: Import error: dynamic module does not define init function (initsqlite) I looked in sqlite.def and there is no reference to an init function being exported. I also looked in the .dll and son't see it there either. Is this an error in the DLL/def, or am I missing something? Thanks. John Hall. #c8c8c8 265 new closed 2003 Mar anonymous Parser 2003 Mar drh 2 3 SQLITE does not like prefixed columns Queries like "SELECT . FROM
" perform OK. when you do the same with updates however, SQLITE does not like the prefixed columns and the query fails. i.e.: "UPDATE
SET
. = " will not work, while the statement "UPDATE
set = " works fine. SQL92 does not allow "SET
. = ". SQLite complies with the standard. For that reason, I'm changing this into an enhancement request. You are right. I made use of some classes that were originally built for MySQL (which does support this). I amended the classes for use with ODBC/SQLITE and ran into this 'problem'. It is not necessary to change SQLITE for this. Thanks. #f2dcdc 263 new active 2003 Mar anonymous CodeGen 2003 Mar 1 4 sqlite locking strategy can lead to deadlock 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. #c8c8c8 260 doc closed 2003 Mar anonymous 2003 Mar 5 4 may i add a contributed by to the wiki HowToCompile ? i just added the last two "HowToCompile" infos to the wiki and wondered why nobody let his contact adress like mail behind the contribution, may this be added or is this permitted ? Bye Bj�rn You should feel free to leave your own e-mail address on wiki contributions if you like. Doing so is neither forbidden nor required. CVSTrac takes care to avoid exposing e-mail addresses to anonymous users. This is done (in a likely vain attempt) to prevent spammers from harvesting those addresses. But if you are already on all the spam lists (like I am) and don't mind making your e-mail address public, then by all means do so. #cfe8bd 258 code fixed 2003 Feb anonymous Parser 2003 Mar 3 3 sqlite_compile doesn't work with (some?) PRAGMAs It appears that sqlite_compile() returns an error when given a pragma, e.g., "PRAGMA SHOW_DATATYPES=ON;" It would be nice to always be able to use the no-callback API without pre-parsing the sql string. #cfe8bd 257 code fixed 2003 Feb anonymous VDBE 2003 Mar 4 3 sqliteVdbeList should return SQLITE_DONE not SQLITE_OK When using the no-callback API to process EXPLAIN queries, the last call of the VM returns OK not DONE. The last line of sqliteVdbeList is: return p->rc==SQLITE_OK ? SQLITE_OK : SQLITE_ERROR; and it never seems to return SQLITE_DONE. This behavior is inconsistent with normal queries, and with the documentation, and makes it difficult to make a reliable general purpose query processor with the no-callback API. #c8c8c8 251 code closed 2003 Feb anonymous 2003 Mar 1 1 ORDER BY doesn't work on TIMESTAMP column type Link http://sqlite.org/datatypes.html says sqlite supports TIMESTAMP type. I created table with TIMESTAMP column type. When I use "<" (less than) or ORDER BY clause on that column response is not expected. ORDER BY on INTEGER or FLOAT works fine. Is it not supported for TIMESTAMP? Following gives the steps I followed. SQLite version 2.7.1 Enter ".help" for instructions sqlite> create table date1(date timestamp, id INTEGER); sqlite> select * from date1; sqlite> insert into date1 values ('Feb 03 2003', 1); sqlite> insert into date1 values ('Feb 02 2003', 2); sqlite> insert into date1 values ('Jan 02 2003', 3); sqlite> select * from date1 order by date; date id ----------- ---------- Feb 02 2003 2 Feb 03 2003 1 Jan 02 2003 3 sqlite> select * from date1; date id ----------- ---------- Feb 03 2003 1 Feb 02 2003 2 Jan 02 2003 3 sqlite> select * from date1 where date < 'Feb 03 2003'; date id ----------- ---------- Feb 02 2003 2 sqlite> Thanks, Latha SQLite works as designed. Use the ISO-8601 date format to get SQLite to sort dates in chronological order. #cfe8bd 250 code fixed 2003 Feb anonymous Unknown 2003 Mar 2 1 SQLite_Changes increments with new non-callback Using the new non-callback mechanism in the DbExpress driver surfaced a bug in sqlite_changes. Documentation tells me it returns the number of rows affected in the latest SQLite_Exec call. Since I'm using SQLite_Compile, SQLite_Step and SQLite_Finalize, the result of SQLite_Canges seems to increment every time this SQLite_Compile is used. Could it be this doesn't reset the ChangeCount somehow? If it is a bug, please fix and release quickly. ;) sqlite_changes() should return the number of changes in the most recent sqlite_exec() call, or in all sqlite_step() calls after the most recent sqlite_compile() call. The documentation has been updated to reflect this and new test cases have been added to make sure this is the way things work. #f2dcdc 330 code active 2003 May anonymous VDBE 2003 May 3 4 Aggregator's error are ignored 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 ? #c8c8c8 329 code closed 2003 May anonymous Unknown 2003 May 3 3 sqlite_get_table() returns 1 row when there should be none I have code which calls sqlite_get_table() with SQL like: "select max(id) from people where id > 100 and id < 1000" I get a row returned, which has the value NULL. I would expect to get nothing returned, since there is no id in the range. An aggregate without a HAVING clause should always returns at least one row, I am told. The current behavior is correct. Perhaps you should try this: SELECT id FROM people WHERE id>100 AND id<1000 ORDER BY id DESC LIMIT 1; #c8c8c8 328 code closed 2003 May anonymous Unknown 2003 May 2 1 Trigger accessing temp table now does not work With Sqlite 2.8.0, regular table triggers had access to temp tables for selects and update/insert/delete functionality. With Sqlite 2.8.2, the following error occurs (when attempting a select on a temp table from a regular table [non-temp, non-attached] trigger): SQL error: table "Table_Name" is not in database "main" Was this change in behaviour inadvertent or intentional? Obviously I am interested in preserving the previous behaviour if at all possible. TIA, Kevin The ability of 2.8.0 to access a temporary table from within a non-temporary trigger was considered a bug and was fixed for 2.8.2. TEMP triggers can access the main database, however. Consider what could happen if these were not the case. Process A could create a TEMP table X and a persistent trigger to fill that table. Process B can see the persistent trigger but not the table X. This means that whenever process B does anything that fires the trigger, the trigger will fail and the operation will abort. From the point of view of process B, the database schema has been corrupted. Requiring that persistent triggers not be able to access TEMP tables avoids this corruption. What possible reason could you have for wanting things to be otherwise? If you have a TEMP table that you want to be filled or queried by a trigger, then make the trigger TEMP too. That way, when the connection dies and the TEMP objects are automatically deleted, the table and trigger are dropped together and the database continues to work. #f2dcdc 326 new active 2003 May anonymous 2003 May 4 4 Request for additional callback for various functions 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 #c8c8c8 325 code closed 2003 May anonymous Parser 2003 May 3 3 Memory Leak with a cancelled sqlite_exec() using a callback routine Memory leak: Using sqlite_exec with a callback function, if false is returned in the callback (cancelling the query), 31 bytes are leaked. A new leak occurs everytime a query is cancelled in this manner. This leak occurs even if there is only 1 row to return and false is returned in the first callback. Tested with a C++ application compiled with MSVC7 under WinXPsp1. Identical behaviour observed with versions 2.8.0 and 2.8.2. this was my own fault! I wasn't calling sqlite_freemem() on the returned error message from sqlite_exec(). Oops... Just want to voice my appreciation for this product. It really is an awesome embedded database... #f2dcdc 321 new active 2003 May anonymous 2003 May 4 3 Make SQLITE_ISO8859 and SQLITE_UTF8 overridable by compiler define 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. #c8c8c8 319 code closed 2003 May anonymous Unknown 2003 May 1 1 Large Encoded Strings Get Truncated Large strings get truncated. Is there an undocumented limitation on characters? There is a limit of 1MB of data per row. This is documented. If you exceed the limit you get an error - nothing is ever silently truncated. Please provide additional information and include a test case (as an attachment) so that your problem can be debugged. ----- In private correspondence, the originator reports that the problem was caused by unencoded '\000' characters in the string. Works as designed. #cfe8bd 317 code fixed 2003 May jplyon CodeGen 2003 May 2 3 ATTACH fails for external database containing an index Using ATTACH on an external database containing an index fails. The problem occurs when sqliteInitOne() rebuilds the internal structures for the attached database. The original SQL statement that created the index is replayed. When it is parsed, sqliteSrcListAppend() tries to create that index for the main (0) database instead of the database being attached. After that the sqliteCreateIndex() call fails. Note that sqliteSrcListAppend() doesn't take a Parse* argument, so we can't use context information stored in it to find the real database to use. I'm not sure whether it's better to patch the SrcList after the fact or not. TRIGGERs and FOREIGN KEYS will probably have to be checked for the same kind of problem. #cfe8bd 315 code fixed 2003 May anonymous Unknown 2003 May 3 3 Usage of potentially changed address Hi, When looking through the code, I noticed something strange (to me). It is in table.c (sqlite 2.8.0) at line 172: if( res.nAlloc>res.nData ){ char **azNew; azNew = realloc( res.azResult, sizeof(char*)*(res.nData+1) ); if( res.azResult==0 ){ sqlite_free_table(&res.azResult[1]); return SQLITE_NOMEM; } res.azResult = azNew; } *pazResult = &res.azResult[1]; if( pnColumn ) *pnColumn = res.nColumn; if( pnRow ) *pnRow = res.nRow; Why is this not (something) like this: if( res.nAlloc>res.nData ){ char **azNew; azNew = realloc( res.azResult, sizeof(char*)*(res.nData+1) ); if( azNew==0 ){ // changed sqlite_free_table(&res.azResult[1]); // this is dangerous: // after realloc this is // freed (so undefined) return SQLITE_NOMEM; } res.azResult = azNew; res.nAlloc = res.nData+1; // added } *pazResult = &res.azResult[1]; if( pnColumn ) *pnColumn = res.nColumn; if( pnRow ) *pnRow = res.nRow; The call to sqlite_free_table() should be safe because according to the realloc() documentation, if realloc() returns NULL, the original memory allocation should be unchanged. Of course, just because the documentation says it does not mean that the realloc() implementation really works that way. So just to be safe, an extra test for NULL was added inside sqlite_free_table() too. #c8c8c8 314 event closed 2003 May anonymous Unknown 2003 May 4 4 Memory usage Hello. I recently began to use sqlite, but I'm stopped by the following consideration. Let's say we have a table created via CREATE TABLE foobar (ID INTEGER PRIMARY KEY); Then we do some inserts (of NULL value), e.g. 1000 transactions, each with 50 inserts. What struck me is that sqlite then have a memory consuption (according to top(1)) of 6.8% on a 256Mo-RAM system. Even MySQL stops to 3.7% after several days of intensive use :) The problem is even more visible when using the Python bindings; for about 15000 inserts in one transaction, 20% of the memory is used, and isn't freed even when the connection object is destroyed. I cannot yet trace where it goes. I'm currently investigating this using Valgrind, but it doesn't show any memory leak. So, is this normal, or is this really a "bug" ? Anyway, I'm going to try to analyze and fix it. After some heavy requests, my Python script uses up to 90% of the physical memory :) Thanks for your work :) BTW, my system is Slackware 8.1, with standard gcc (2.95-3) and glibc (2.2.5). I'm not able to reproduce this effect. Can you provide more details? In attempting to reproduce the result described above, I ran a test which created a table as described above, then did 5000 transactions each containing 250 INSERTs as follows: INSERT INTO foobar VALUES(NULL); That's a total of 1.25 million inserts. The final database was 25MB in size. But at no time during the test did the size of the SQLite process exceed 1468 pages (RSS and SIZE) or 0.1% of memory. Added by fraca7: Sorry, false alert. The memory leak isn't in sqlite, and I was fooled by valgrind when trying to detect it :) #cfe8bd 313 code fixed 2003 May anonymous Unknown 2003 May 2 3 Creating a table with a specific name crashes SQLite. The following statement crashes SQLite: create table CategoryCategory ( c integer ); The following variants of that statement do not: create table 'CategoryCategory' ( c integer ); create table CategoryCategorx ( c integer ); create table CategoryCategoryx ( c integer ); I too see this problem, on release builds but not debug builds, compiled with Visual Studio.NET 2003. It also occurs with the official sqlite.exe which was compiled with MinGW so it is not compiler-specific. (I hope I'm using this wiki correctly) ---- Wow! Good catch! The problem was in a hash function that was suppose to always return a non-negative number. In computing the hash, a negative number might result but this was being dealt with by the following line of code: if( h<0 ) h = -h; return h; The above should always make h a non-negative number, right? Well, not if the original hash is -214783648 (or 0x80000000). For that one value for h stays negative when you takes it's negative. To fix the problem, I changed the code to return h & 0x7fffffff; This is a mistake I've been making for years. It appears throughout my code. I've got to go back and change it all. But notice that the error only occurs in about 1 out of every 4 billion hashes. Which explains why I've never seen the problem before now. #cfe8bd 311 code fixed 2003 May anonymous 2003 May 3 3 configure fails with non gcc compilers due to non escaped \n in test The following is a screenshot of the make failure in SQLite 2.7.6: ----------- configure: creating ./config.status config.status: creating Makefile (cd ../sqlite_source/ux/build; make) sed -e s/--VERS--/`cat ../sqlite/VERSION`/ \ -e s/--ENCODING--/ISO8859/ \ ../sqlite/src/sqlite.h.in >sqlite.h echo '#include ' >temp.c echo 'int main(){printf(' >>temp.c echo '"#define SQLITE_PTR_SZ %d\n",sizeof(char*));' >>temp.c echo 'exit(0);}' >>temp.c cc -g -o temp temp.c "temp.c", line 3: newline in string literal "temp.c", line 4: newline in string literal "temp.c", line 5: syntax error before or at: exit cc: acomp failed for temp.c *** Error code 2 make: Fatal error: Command failed for target `config.h' ----------- The make succeeds on systems where gcc is installed. The following is the compiler version on the failing system (Solaris 2.6 with no gcc compiler): ----------- cc -V cc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2 ----------- The symptom is reproducible on systems with more recent compilers. The cause is the following code in the makefile. ----------- config.h: echo '#include ' >temp.c echo 'int main(){printf(' >>temp.c echo '"#define SQLITE_PTR_SZ %d\n",sizeof(char*));' >>temp.c echo 'exit(0);}' >>temp.c $(BCC) -o temp temp.c ./temp >config.h rm -f temp.c temp ----------- The problem is that echo statements are preprocessing the \n in the printf format string. The resulting file looks like this: ----------- #include int main(){printf( "#define SQLITE_PTR_SZ %d ",sizeof(char*)); exit(0);} ----------- The gcc compiler accepts a string constant with an embedded new line, however the Sun compiler objects. The apparent fix is escape the \n in the printf statement: echo '"#define SQLITE_PTR_SZ %d\\n",sizeof(char*));' >>temp.c #cfe8bd 310 code fixed 2003 May anonymous Pager 2003 May 3 3 win32 locking error This is a rather queer problem - perhaps more windows related than SQLite: I have a sqlite database hosted on a win98 "server", through normal windows filesharing. Only one client active at a time. When the client is run on the "server", or from another win98 box on the network, no problems. However, when the client runs from a win2k workstation, sqlite_open fails after blocking for a while. The problem seems to be with win32 LockFile not succeeding - I don't know whether changing share or lock modes could help this, nor whether it's a win32 problem. I don't need a fix as I've put a linux distribution on the server, which works with both 9x and NT clients, but I thought I should report this weird behaviour. I did think there was any easy fix to this problem, but not so. Locking needs to be re-thought to be compatible not only between Win 2000/XP and 95/98/Me, but also between MacOS, Windows (all) and Linux/Unix if possible. Derry Bryson #cfe8bd 309 code fixed 2003 May anonymous Unknown 2003 May 5 5 Source code files are corrupted I've tried to download the src.rpm and the tarball of version 2.8.0 and both seem to be corrupted. This is a duplicate of ticket #308. #cfe8bd 308 todo fixed 2003 May anonymous Unknown 2003 May 1 1 can not unzip downloaded binary files I have downloaded sqllite from the download page using ie and netscape download was successful but I can not unzip the files. It is not possible using windows or linux tools. what am i doing wrong. There is a problem on the main SQLite website. Use the backup site until we can get the problem fixed: _: http://www.hwaci.com/sw/sqlite/ #cfe8bd 306 code fixed 2003 May drh CodeGen 2003 May 1 1 Left outer join fails when right table is a view of a join. If you have a LEFT OUTER JOIN where the right table is a view or subquery that is an INNER JOIN, the optimizer attempts to flatten the subquery - which is incorrect. If the original query is like this: t1 LEFT OUTER JOIN (t2 JOIN t3) The optimizer simplifies this to (t1 LEFT OUTER JOIN t2) JOIN t3 which is not the same thing at all. #c8c8c8 304 code closed 2003 May anonymous Shell 2003 May 3 3 DELETE on read-only db reporting error inconsistently When a user does not have write permission on a database a "DELETE FROM table" statement in sqlite will fail silently, when using "DELETE FROM table WHERE col = 'x'" it fails with the error "SQL error: attempt to write a read-only database". I presume the second case is the correct one. e.g. sqlite> delete from draco_servers; sqlite> delete from draco_servers where generation = 0; SQL error: attempt to write a read-only database Unable to reproduce. #cfe8bd 282 code fixed 2003 Apr anonymous Unknown 2003 May 2 3 Echo "\n" on Solaris causes two linebreaks. Makefile problem. Hi, I tried compiling sqlite 2.8.0 on Solaris 2.7. There was only one glitch, namely the place where the Makefile creates the config.h file. When writing the line with #define SQLITE_PTR_SZ, the echo command includes the string "\n" in the string to be written. On Solaris /bin/sh, this causes echo to issue a linebreak instead of the intended slash-n. The workaround is to write "\\n" instead of "\n" in the makefile. Once this is done, sqlite compiles on Solaris with no problems. I use Sun Forte WS6, that is, Sun's own compilers. The compiler does issue a number of warnings, and I could send you those in a separate ticket if you contact me and ask for it. Things like "statement not reached" and mismatch between unsigned signed versions of types in prototypes and assignments. One way of solving the problem with echo-issuing-a-newline is to write a small script in configure.in which issues an "echo '\n'" command into an empty file and then uses wc -l to count the number of lines. On Solaris /bin/sh, this gives 2: \u@\h:\w$echo '\n' > try.txt{linebreak} \u@\h:\w$wc -l try.txt{linebreak} 2 try.txt{linebreak} On bash, of course, it gives 1: [upet01@upet01 sqlite]$ echo '\n' > try.txt{linebreak} [upet01@upet01 sqlite]$ wc -l try.txt{linebreak} 1 try.txt{linebreak} The point is not to assume you are running under bash, but to test for how the shell deals with newlines. Best regards, Ulrik Petersen #f2dcdc 279 new active 2003 Apr anonymous 2003 May 3 3 WinCE port of CVS version as of 02 Apr 2003 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. #cfe8bd 272 code fixed 2003 Mar anonymous 2003 May 3 3 select on view with where clause does not use index I think the example output says it all (times are milliseconds): Sql: select count(*) from tw_methodsandsourcesview where packageRef=125 Execution time: 3863 , Result Rows: 1 Sql: select count(*) from TW_Methods, TW_Method, TW_Blob WHERE TW_Methods.methodRef = TW_Method.primaryKey AND TW_Method.sourceCodeID = TW_Blob.primaryKey and packageRef=125; Execution time: 8 , Result Rows: 1 Note that the index on TW_Methods.packageRef in this example is a combined one (it's created by PRIMARY KEY (packageRef, methodRef)), although creating a separate index on packageRef alone did not improve performance. Unable to reproduce. The trouble report lacks a definition for the view that is allegedly not using indices. Views created in several test cases do use indices. ---- A script to reproduce the problem is in the join-view.sql attachment. ---- The problem is that subqueries (VIEWs are always treated as subqueries during code generation) that are joins never get folded into the parent query by the optimizer. This is a limitation of the flattenSubquery() routine in select.c and needs to be addressed. ---- drh's notes to self: 1: Add an iCursor field to SrcList_item. This field holds the VDBE cursor number used to access the corresponding table. 2: Number SrcList_items as they are encountered. The numbers need to be close to gether (due to 32-bit bitmaps in where.c) but they need not be consecutive. Can we relax the proximity restriction somehow? 3: The Expr.iTable field is set to SrcList_item.iCursor. 4: No need to pass around the "base" cursor value or store it in Select or {quote: WhereInfo}. 5: Omit the OP_RenameCursor opcode and the ChangeTables() routines. 6: The above simplifications allow flattenSubquery() to push a subquery that is a join up into the parent query. #cfe8bd 256 code fixed 2003 Feb anonymous 2003 May 3 2 Simple Makefile error on HP/UX, may affect other UNIX systems The Makefile generated for HP/UX with the native compiler fails at an early point: echo '#include ' >temp.c echo 'int main(){printf(' >>temp.c echo '"#define SQLITE_PTR_SZ %d\n",sizeof(char*));' >>temp.c echo 'exit(0);}' >>temp.c $(BCC) -o temp temp.c ./temp >config.h rm -f temp.c temp ...should be revised with another escape for the newline: \\n Simple, but fatal mistake. (-: #c8c8c8 511 code closed 2003 Nov anonymous VDBE 2003 Nov 1 1 confused error of nested calling of "sqlite_compile" the calling sequence is as follows void func1() { sqlite *db; sqlite_vm *vm; char *zErrMsg, *zTail, char[1024]; db = sqlite_open("ex1", 0, &zErrMsg); sqlite_compile(db, sql, &zTail, &vm, &zErrMsg); sqlite_step( vm, &nRows, &zValue, &zColName); func2(); func3(); ... sqlite_finalize( vm, &zErrMsg); sqlite_close(db); } void func2() { sqlite_vm *vm; char *zErrMsg, *zTail, char[1024]; sqlite_compile(db, sql, &zTail, &vm, &zErrMsg); sqlite_step( vm, &nRows, &zValue, &zColName); func2(); func3(); ... sqlite_finalize( vm, &zErrMsg); } void func3() { sqlite_vm *vm; char *zErrMsg, *zTail, char[1024]; sqlite_compile(db, sql, &zTail, &vm, &zErrMsg); sqlite_step( vm, &nRows, &zValue, &zColName); ... sqlite_finalize( vm, &zErrMsg); } when executing, it reported an error of SQLITE_MISUSE in func3(), while it ran well in func2(). I am afraid maybe there is any error in the SQL statement. the SQL statement is "select user_id, user_name from t_user_info where depart_id=''" who can give some idea about this question? This is not an SQLite bug. This is a question about how to use SQLite. Questions about how to use SQLite should be directed to the mailing list. No changes to code. Works as designed. #f2dcdc 510 new active 2003 Nov anonymous Unknown 2003 Nov 5 2 trigger: addition of create ability 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 /*{linebreak} create trigger group_make_new after insert on group_list {linebreak} begin {linebreak} /* make table of users for group /* {linebreak} create table group_[new.groupID] ( {linebreak} userID unique, {linebreak} userlevel {linebreak} ); {linebreak} /* insert owner as a member /* {linebreak} insert into group_[new.groupID] values (new.owner,3); {linebreak} end; {linebreak} note: you'll have to fix the comments cause of this posting format.... #f2dcdc 509 event active 2003 Nov anonymous 2003 Nov 5 3 SQLite on Pocket PC - question - how to do that step by step? 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:_ {linebreak} 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:_ {linebreak} 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( iCellhdrOffset+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); ===== #f2dcdc 508 doc active 2003 Nov anonymous 2003 Nov 4 4 Build instructions on home page needs link to page with platform help 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 #c8c8c8 507 code closed 2003 Nov anonymous Unknown 2003 Nov 2 4 string comparison in where-clause of select when having a table with normal strings: "select * from table where field>='A' and field<='B';" you get only fields beginning with an 'A', not also fields beginning with an 'B'. Bug or feature ? I think it is a bug. Workaround is: "select * from table where field>='A' and field<='B~';" 'Bcde'>'B', hence if field is 'Bcde' then select * from table where field<='B'; will return nothing. No changes. Works as designed. #c8c8c8 506 code closed 2003 Nov anonymous 2003 Nov 2 1 Result tuple not formed correctly on select query I use pySQLite, but I've looked in the code and it seems that the problem is in SQLite itself. Querying: "SELECT * from student" gets me the following results using fetchall(): [(1, 'Kees', 'van den', 'Broek', 22)] That's good. Now, I select 1 row: "SELECT lastname from student" with fetchall(), this gives me: [('Broek',)] I think this should be: [('Broek')] So it's a bug, right? This is not an SQLite problem since SQLite doesn't know anything about python lists. If this is really a problem, you should report it on the pySQLite website, not here. #cfe8bd 505 doc fixed 2003 Nov anonymous 2003 Nov 5 3 Typos in SQLite Database File Format document The current version of the SQLite Database File Format document contains three typos in the description of the payload field in the Btree cell structures. Current text is: A cell can have up to 238 byte of payload space. If the payload is more than 238 bytes, then an addition 4 point page number is appended to the cell It should be: A cell can have up to 238 bytes of payload space. If the payload is more than 238 bytes, then an additional 4 byte page number is appended to the cell #cfe8bd 502 doc fixed 2003 Nov anonymous BTree 2003 Nov 5 3 Typos in Database File Format documentation The current version of the SQLite Database File Format document contains two typos in the description of the Keysize field in the Btree cell structures. The current text is: The size of the key is a 24-bit where the upper 8 bits are taken from by 8 and the lower 16 bits are token from bytes 4 and 5 It should be: The size of the key is a 24-bit where the upper 8 bits are taken from byte 8 and the lower 16 bits are taken from bytes 4 and 5 #f2dcdc 501 doc active 2003 Nov anonymous Unknown 2003 Nov anonymous 4 4 missing sqlite_encode_binary 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. #f2dcdc 500 doc active 2003 Nov anonymous Unknown 2003 Nov 4 4 Discrepancies in comments in encode.c 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. #f2dcdc 498 new active 2003 Nov anonymous Unknown 2003 Nov 4 4 Suggestion: Allow named parameters. 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. #c8c8c8 497 new closed 2003 Nov anonymous Unknown 2003 Nov 3 3 not able to escape quotes I am not able to 'escape' quotes. I.e. insert into table values("a","b","". I know i could use ' but this is not always a solution. It could be expected that you should enter \" or \' to accept a quote in the string. It's not a bug, but a feature request. Perhaps there is another solution here? The SQL standard way of doing this is to double the quoting characters - either two ' in a row or two " in a row. Backslashes are not an SQL quote character and if implemented would break many valid SQL scripts. INSERT INTO table VALUES("a","b",""); See also the documentation on the "%q" conversion character for sqlite_exec_printf() and its cousins. This should be in the FAQ... #f2dcdc 496 build active 2003 Nov anonymous 2003 Nov 1 1 SQLite Ignores Autoconf Options 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. #f2dcdc 495 build active 2003 Nov anonymous 2003 Nov 1 1 Makefile syntax errors 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? #c8c8c8 494 new closed 2003 Nov anonymous 2003 Nov 4 4 No way to get a list of table columns without parsing the schema It would be very nice to have a way to get a list of column names and types in a table, without having to parse the schema. PRAGMA table_info(); #f2dcdc 493 event active 2003 Nov anonymous Unknown 2003 Nov 3 3 Problem compiling sqlite # 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 #c8c8c8 492 code closed 2003 Nov anonymous Unknown 2003 Nov 2 4 database image is malformed I did this: drop table offer; create table offer; load data into table offer; ( there was index on that table ) On original machine (i386) all is peachy, but when I transfer file to mipsel machine I get: "database image is malformed" whenever I do 'select count(*) from offer', most other things work ok ( select * from offer works fine for example ). As a workaround I dumped the database to file and re-created everything from scratch. Oh, and web-based forms are not the best medium for filling reports, we've got e-mail for that. Bug summitter reports that the problem has now been traced to parts of the system that are unrelated to SQLite. #f2dcdc 491 new active 2003 Nov anonymous 2003 Nov 4 4 Want to use SET col = 'val' with INSERT statement 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:_ {linebreak} 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:_ {linebreak} My vote on this one too! When this is implemented, we can finally switch with our entire product range to sqlite :). #f2dcdc 490 new active 2003 Nov anonymous VDBE 2003 Nov xdong 4 3 a few api improvements for recordset operations 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 #cfe8bd 488 doc fixed 2003 Nov anonymous 2003 Nov 5 4 Lemon Parser Generator page is outdated There are many links from different places to http://www.hwaci.com/sw/lemon/ But looks like this page is currently outdated and does not contain the latest version of Lemon. Many people choosing parser generator may find this page and think that is has the latest version available. By the way, I was one of those people :-) I considered Lemon to be used in a commercial project I currently work on. But I found a license in a parser template file quite confusing. Fortunately, I have downloaded SQLite sources a bit later and found an updated version of Lemon with much less restrictive license! Putting a notice on that page stating that the latest Lemon version can be obtained from SQLite sources would probably help. Thanks for making a great tool. #cfe8bd 487 code fixed 2003 Nov anonymous 2003 Nov 2 2 mac os x build via pear creates invalid bundle If I go through the usual steps to build sqlite via pear install on mac os x 10.2.8, it ends up creating a .so that will not load via the php dl() or automatically via the php.ini. A dynamic library is created instead of a bundle. This causes an error when you try to load the library: cat example <. 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{linebreak} 494a495,497{linebreak} > if test "$found" = "yes"; then{linebreak} > AC_CHECK_HEADER(history.h, [found=yes], [found=no]){linebreak} > fi{linebreak} 500,501c503,507{linebreak} < TARGET_READLINE_INC="-I$dir/include"{linebreak} < break{linebreak} ---{linebreak} > AC_CHECK_FILE($dir/include/history.h, found=yes, found=no){linebreak} > if test "$found" = "yes"; then{linebreak} > TARGET_READLINE_INC="-I$dir/include"{linebreak} > break{linebreak} > fi{linebreak} 505,506c511,515{linebreak} < TARGET_READLINE_INC="-I$dir/include/readline"{linebreak} < break{linebreak} ---{linebreak} > AC_CHECK_FILE($dir/include/readline/history.h, found=yes, found=no){linebreak} > if test "$found" = "yes"; then{linebreak} > TARGET_READLINE_INC="-I$dir/include/readline"{linebreak} > break{linebreak} > fi{linebreak} #f2dcdc 478 new active 2003 Oct anonymous Parser 2003 Nov drh 1 3 select into is lacking hi, thanks for sqlite. i accidentally tryed a "select into" statement and found it is not parsed by sqlite. best regards, alex #c8c8c8 476 doc closed 2003 Oct anonymous 2003 Nov 3 3 Define for omitting time and date functions There is a define for omitting time and date functions defined in sqliteInt.h (SQLITE_OMIT_TIMEDATE_FUNCS). However, the code in func.c to omit this is: #ifndef SQLITE_OMIT_DATETIME_FUNCS (notice the swap of DATE and TIME in the name). You can solve this PR by just making them consistent. #f2dcdc 473 build active 2003 Oct anonymous 2003 Nov drh 3 3 makefile's target_source fails to create opcodes.c 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. #f2dcdc 472 new active 2003 Oct anonymous VDBE 2003 Nov 5 5 [Patch] Using localtime instead UTC time to 'now' --- 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,<m); + lot = mktime(<m); + gmtime_r(&t, <m); + ltmsec = lot - mktime(<m); + *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. #cfe8bd 460 new fixed 2003 Sep anonymous VDBE 2003 Nov 5 5 [Patch] extending copy command for dump file of PostgerSQL pg_dump. Patch file is {link: http://database.sarang.net/database/sqlite/forpgdump.diff here} --- vdbe.c.orig Sun Sep 7 07:18:08 2003 +++ vdbe.c Wed Sep 24 15:43:37 2003 @@ -4092,6 +4092,29 @@ while( (c = p->zLine[n])!=0 ){ if( c=='\\' ){ if( p->zLine[n+1]==0 ) break; + else { + /* for using file of pg_dump by iosephATuriDOTsarangDOTnet */ + switch(p->zLine[n+1]){ + case 'b': + p->zLine[n+1] = '\b'; + break; + case 'f': + p->zLine[n+1] = '\f'; + break; + case 'n': + p->zLine[n+1] = '\n'; + break; + case 'r': + p->zLine[n+1] = '\r'; + break; + case 't': + p->zLine[n+1] = '\t'; + break; + case 'v': + p->zLine[n+1] = '\v'; + break; + } + } n += 2; }else if( c=='\n' ){ p->zLine[n] = 0; #f2dcdc 456 build active 2003 Sep anonymous 2003 Nov anonymous 1 1 compilation problem under winnt 4 using Lcc-win32 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? #f2dcdc 414 code active 2003 Jul anonymous VDBE 2003 Nov 3 4 sqlite_compile() and database schema changes 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 #f2dcdc 398 build active 2003 Jul anonymous Unknown 2003 Nov 3 3 configure.ac is wrong for Windows Mingw/Msys 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." #c8c8c8 371 event closed 2003 Jul anonymous 2003 Nov 1 1 crash in conflict.test I have compiled sqlite 2.8.4 for windows (using borland c++ 5.5) and while running the tests (all.test), tcl (checked with both 8.4.2 and 8.4.3) crashed while executing conflict.test. the crash occurs in do_test_conflict-1.0 (it crashes before the end of the execsql in that proc). the lines are: CREATE TABLE t1(a, b, c, UNIQUE(a,b)); CREATE TABLE t2(x); SELECT c FROM t1 ORDER BY c; i have checked, the same lines in memdb.test also cause a crash. regards, s. boehme #f2dcdc 339 build active 2003 Jun anonymous Shell 2003 Nov 2 3 readline headers not found (because of readline/ prefix) Hi, I have GNU readline in /usr/local/include/readline : $ ls -l /usr/local/include/readline/{linebreak} total 32{linebreak} -rw-r--r-- 1 root bin 1846 Mar 6 1996 chardefs.h{linebreak} -rw-r--r-- 1 root bin 3200 Mar 6 1996 keymaps.h{linebreak} -rw-r--r-- 1 root bin 9952 Mar 6 1996 readline.h{linebreak} The shell program references the readline header-files as # include {linebreak} # include {linebreak} 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{linebreak} 40,41c40,41{linebreak} < # include {linebreak} < # include {linebreak} ---{linebreak} > # include {linebreak} > # include {linebreak} Best regards, Ulrik Petersen #f2dcdc 338 new active 2003 Jun anonymous Unknown 2003 Nov 5 1 lowerFunc and upperFunc Fail on foreign characters 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] >= '�' && z[i] <= '�' ) || ( z[i] >= '�' && z[i] <= '�' ) ) 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] >= '�' && z[i] <= '�' ) || ( z[i] >= '�' && z[i] <= '�' ) ) z[i] = tolower(z[i]); } } #f2dcdc 303 build active 2003 May anonymous Unknown 2003 Nov a.rottmann 4 4 Makefile issues 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:_ {linebreak} 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:_ {linebreak} I should really switch the stuff to use automake, plus using the conventional --with-foo-includes flags instead of config_ environment variables. #f2dcdc 268 new active 2003 Mar anonymous Parser 2003 Nov 1 3 columns of subselects containing joins are not recognized 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. #f2dcdc 259 new active 2003 Mar anonymous CodeGen 2003 Nov 1 2 ORDER BY queries including an integer primary key don't use index 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. #c8c8c8 248 code closed 2003 Feb anonymous Unknown 2003 Nov 1 2 SQLColumn function in ODBC returns incorrect datatype This is a bug in the ODBC driver for SQL Lite. The SQLColumn function returns a data of 'text' for every column and its size is set to 0. According to the SQLGetTypeInfo method, there is no type where the name is 'text' We are the makers of WinSQL, an ODBC tool that allows users to connect to any ODBC compliant data source. You can download this tool from http://www.synametrics.com/winsql. One of our mutual client has submitted a bug on our site but since it is related to the ODBC driver, I wanted to submit a bug report here. Thanks, Imran. CHW writes: _: As far as I understand, that is related to the ODBC driver only, but is in consequence of the typelessness of SQLite. Using the SQLColumns() ODBC API function a data source can be queried to obtain column information of a table (data type, column name etc.) The column's data type is reported as a data source specific string, 'text' in this case, but normally what SQLite "pragma table_info('table')" returns. The ODBC type which matches that data source specific type is returned as an integer code, e.g. SQL_INTEGER, SQL_VARCHAR etc. Another ODBC API function SQLGetTypeInfo() can be used to retrieve a standardized result set describing the data types which the data source knows about. That result set is hard wired in the ODBC driver and does not have the mentioned 'text' type. Thus, the problem sits in the schema of that specific database which does not have "create table" statements which fit the hard wired SQLGetTypeInfo() information. To fix it, I would have to "pragma table_info()" all tables of the opened data base and construct a result set for SQLGetTypeInfo() using some heuristic. However, it is questionable if this is worth the work, since the default fallback type is always a ODBC string type which fits SQLite perfectly. #f2dcdc 235 new active 2003 Jan anonymous Unknown 2003 Nov chw 5 1 Local language do not support! 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. */ ----------------------------------------------------------------- #f2dcdc 209 new active 2002 Dec anonymous BTree 2003 Nov 1 1 update libtool 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. #c8c8c8 201 doc closed 2002 Dec anonymous Unknown 2003 Nov 1 1 it is very well if there is a table lock! but ... it is very well if there is a table lock! but ... Don't know what this means.... #c8c8c8 115 new closed 2002 Jul anonymous Unknown 2003 Nov 1 5 table_info() missing datatypes Asking SQLite for table information as in "PRAGMA table_info(sometable)" does not return the datatypes in the CallBack routine. Setting "PRAGMA show_datatypes=ON" makes the CallBack return datatypes for column names for regular queries but this does not help the table_info call. 2003-01-18: I'm not able to reproduce this now. There have been a lot of fixes and enhancements since this issue was written. I'm going to assume it is fixed. #f2dcdc 486 new active 2003 Oct anonymous VDBE 2003 Oct 5 4 index on expressions (general solution to case-insensitive problem) 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. #f2dcdc 485 new active 2003 Oct anonymous BTree 2003 Oct 5 4 Comparing strings: user defined callback, strcoll? 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. #f2dcdc 479 new active 2003 Oct anonymous Parser 2003 Oct drh 4 3 Sequences 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:_ {linebreak} Any plans to add sequences? #c8c8c8 475 code closed 2003 Oct anonymous 2003 Oct 1 1 question:how to use the sqlite in my VC6 project? If somebody can give me some advice to use sqlite source in VC6 project instead of DLL? thanks a lot This is a question for the mailing list, not a bug report. #c8c8c8 474 code closed 2003 Oct anonymous Unknown 2003 Oct 4 1 Problem with showing the datatypes of columns of a empty table When turned on, the SHOW_DATATYPES pragma causes extra entries containing the names of datatypes of columns to be appended to the 4th ("columnNames") argument to sqlite_exec() callbacks. But if the table is empty,sqlite_exec() callbacks will never be called.So we can never show the names of datatypes of columns of a empty table in this way. See the documentation on the EMPTY_RESULT_CALLBACKS pragma at http://www.sqlite.org/lang.html#pragma. #c8c8c8 471 code closed 2003 Oct anonymous Parser 2003 Oct 5 1 Parser accepts faulty SQL SQL parser doesn't complain when I enter a SQL with syntax error ("INTEGER id PRIMARY KEY" instead of "id INTEGER PRIMARY KEY") xxxx@lilly(~/pym)$ sqlite xx.db{linebreak} SQLite version 2.8.6{linebreak} Enter ".help" for instructions{linebreak} sqlite> create table xx (INTEGER id PRIMARY KEY, dsc);{linebreak} sqlite> insert into xx values(NULL, "xx");{linebreak} sqlite> select * from xx;{linebreak}{linebreak} |xx This is a feature, not a bug. The line "INTEGER id PRIMARY KEY" declares a column names "INTEGER" of type "id" which is the primary key for the table. SQLite is deliberately flexible in its parsing (accepting words like "INTEGER" as a column name and "id" as a type name) in order to be compatible with as many other database engines as possible. #cfe8bd 468 code fixed 2003 Oct anonymous 2003 Oct 2 2 DROP TRIGGER w/ single quotes doesn't work. I think I may have found a bug in the drop trigger command. I tried to drop a trigger with single quotes around the name in case it was a key word and it errors even though it doesn't error when creating the trigger.{linebreak} {linebreak} SQLite version 2.8.6{linebreak} Enter ".help" for instructions{linebreak} sqlite> create table t (a,b,c);{linebreak} sqlite> create trigger 'trig' after insert on t begin update t set c=5; end;{linebreak} sqlite> insert into t values (1,2,3);{linebreak} sqlite> select * from t;{linebreak} 1|2|5{linebreak} sqlite> drop trigger 'trig';{linebreak} SQL error: no such trigger: trig{linebreak} sqlite> .schema t{linebreak} create table t (a,b,c);{linebreak} create trigger 'trig' after insert on t begin update t set c=5; end;{linebreak} sqlite> drop trigger 'trig';{linebreak} SQL error: no such trigger: trig{linebreak} {linebreak} #c8c8c8 467 code closed 2003 Sep anonymous Unknown 2003 Oct 2 1 Problem with renaming fields If I have a table named 'Properties' with two fields, 'propName' and 'propValue' This SQL: SELECT propValue as title FROM properties WHERE propName = "title"; will return 0 entries where there exists valid results. The SQL parser does not seem to like that 'title' is used twice (once in the SELECT clause and once in the WHERE clause) This SQL Does work: SELECT propValue as _title FROM properties WHERE propName = "title" becuase _title != title. Try it!{linebreak} CREATE TABLE Properties (propName char(50), propValue char(50));{linebreak} INSERT INTO Properties values ("title","test1");{linebreak} INSERT INTO Properties values ("title","test2");{linebreak} INSERT INTO Properties values ("title","test3");{linebreak} INSERT INTO Properties values ("creator","test4");{linebreak} INSERT INTO Properties values ("creator","test5");{linebreak} SELECT propValue as title FROM Properties WHERE propName = "title";{linebreak} --> returns 0 entries - should have returned 'test1','test2',test3'{linebreak} {linebreak} SELECT propValue as title_x FROM Properties WHERE propName = "title";{linebreak} -->test1{linebreak} -->test2{linebreak} -->test3{linebreak} {linebreak} SELECT propValue as title FROM Properties WHERE propName = "creator";{linebreak} -->test4{linebreak} -->test5{linebreak} It appears to break when {linebreak} SELECT field1 as xxxx FROM table WHERE field2 = "xxxx";{linebreak} when xxxx=xxxx{linebreak} thanks- Shannon A name in double-quotes (ex: "title") resolves to a column name if it can and to a string literal if not column is available with that name. Use single-quotes (ex: 'title') for a pure string literal. No changes. Works as designed. #f2dcdc 243 new active 2003 Feb anonymous Unknown 2003 Oct anonymous 3 4 Performance problem with MSVC precompiled DLL 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 #f2dcdc 128 event active 2002 Jul anonymous Unknown 2003 Oct 4 4 Workaround for problem reported in ticket 127- 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. #f2dcdc 465 new active 2003 Sep anonymous 2003 Sep 4 3 data types should be implemented as formated strings 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. #f2dcdc 463 event active 2003 Sep anonymous 2003 Sep 2 1 list index out of bounds(1) 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;_{linebreak} *Delphi code:*{linebreak} procedure TForm1.Edit1Change(Sender: TObject);{linebreak} var t:string;{linebreak} baza:TSQLiteDB;{linebreak} i:integer;{linebreak} begin{linebreak} t:=edit1.Text;{linebreak} ListBox1.Clear;{linebreak} if (DataBaseName<>'') then begin{linebreak} baza:=TSQLiteDB.Create(nil,DataBaseName);{linebreak} baza.sql:='select filename from baza where filename like "'+t+'%" order by filename';{linebreak} baza.ExecSQL;{linebreak} baza.Open;{linebreak} if baza.RecordCount>0 then begin{linebreak} baza.First;{linebreak} while not baza.EOF do begin{linebreak} ListBox1.Items.Add(baza.Fields['filename']);{linebreak} baza.Next;{linebreak} end;{linebreak} end;{linebreak} baza.Close;{linebreak} FreeAndNil(baza);FreeAndNil(i);{linebreak} end;{linebreak} end;{linebreak} #f2dcdc 462 event active 2003 Sep anonymous 2003 Sep 2 1 list index out of bounds(1) 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. #cfe8bd 461 code fixed 2003 Sep anonymous CodeGen 2003 Sep 3 3 Nulls are incorrectly returned on an indexed column Sqlite behaves differently with nulls depending on whether you have an index or not. Without indices, nulls are handled correctly, but with indices, they are not. I noticed the problem when doing a join, but here is a simpler example provided by DRH on the sqlite message group. >CREATE TABLE t(x,y); >INSERT INTO t VALUES(1,11); >INSERT INTO t VALUES(2,NULL); >SELECT x FROM t WHERE y=NULL; >The above (without an index) correctly returns an empty set. >But if you add an index: >CREATE INDEX i1 ON t(y); >SELECT x FROM t WHERE y=NULL; >In this case, you get a result of "2". Which, if I understand >NULLs correctly, is wrong. #cfe8bd 459 new fixed 2003 Sep xdong Unknown 2003 Sep xdong 5 5 adding releasemode option to allow libtool link release when you compile the sqlite by using the autoconf tools, it only produce the version control binary: libsqlite.so libsqlite.so.0 and libsqlite.so.0.0.0, and it will not work if you just want to using libsqlite.so alone. In certain case, like you jar the .so binary file and ship it with your product, you may want a stand-alone worked binary file. libtool do have an option "-release VERSION". so sqlite autoconfg should allow build to generate libsqlite-2.8.6.so instead of libsqlite.so.0.0.0 as an option. The default setting will keep sam.e used as: ./configure --enable-releasemode=yes #cfe8bd 458 new fixed 2003 Sep xdong Unknown 2003 Sep xdong 5 5 configure file and libtool doesnot work for cross compiling This is the auto-config problem occured at cross-compile SQLite to xscale or arm target with certain tool-chain. a related work-around can be find at http://www.kecher.de/howtos/SQLite-JDBC-Howto.html The fix will submot a modified configure file with a latest version of libtool. #f2dcdc 457 new active 2003 Sep anonymous 2003 Sep 1 1 Ported to NetWare I've ported SQLite to work on NetWare 5.1 and 6.x. The database file location must be an NSS volume. #c8c8c8 455 doc closed 2003 Sep anonymous 2003 Sep 4 2 undocumented functions: sqlite_mprintf,and sqlite_vmprintf I just would like to notice that those two functions (sqlite_mprintf, and sqlite_vmprintf) remain undocumented since ages, and make port coders' work unnecessarily hard. They're very useful and they've been around for a while, so I guess it's somewhat stable code, but the only way to know how they work is either looking at the code, or navigating through google looking for how to escape code in SQLite. Any chances you could add one line explaining how it works? Undocumented code is ~ unusable code Sorry, I found the documentation. It seems it's somewhat hidden, but it's there. #f2dcdc 454 new active 2003 Sep anonymous 2003 Sep 4 4 schema column types with parenthesis to automatically invoke functions 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. #cfe8bd 453 code fixed 2003 Sep anonymous Parser 2003 Sep 3 3 "SELECT a, b FROM tt;-" Crashes SQLite GPF on "SELECT a, b FROM tt;-" ** $Id: tokenize.c,v 1.60 2003/05/04 18:30:59 drh Exp $ ln 230: case '-': { if( z[1]==0 ) return -1; if( z[1]=='-' ){ ln 430: pParse->sLastToken.n = sqliteGetToken((unsigned char*)&zSql[i], &tokenType); i += pParse->sLastToken.n; ** @(#) $Id: sqliteInt.h,v 1.196 2003/08/09 21:32:28 drh Exp $ ln 547: struct Token { const char *z; /* Text of the token. Not NULL-terminated! */ unsigned dyn : 1; /* True for malloced memory, false for static */ unsigned n : 31; /* Number of characters in this token */ }; --------------------------------- Error: unsigned n = -1 --------------------------------- My solution (not good): /* ** Return the length of the token that begins at z[0]. Return ** 1 if the token is (or might be) incomplete. Store the token ** type in *tokenType before returning. */ static int sqliteGetToken(const unsigned char *z, int *tokenType){ int i; + *tokenType = TK_ILLEGAL; switch( *z ){ case ' ': case '\t': case '\n': case '\f': case '\r': { for(i=1; isspace(z[i]); i++){} *tokenType = TK_SPACE; return i; } case '-': { - if( z[1]==0 ) return -1; + if( z[1]==0 ) return 1; Now, i have errmsg: 'unrecognized token: "-"' #f2dcdc 450 new active 2003 Sep anonymous Shell 2003 Sep 5 4 Make HTML Output XHTML compliant 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 (s, ... as well as for .... 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:_ {linebreak} Capitals tags aren't xhtml. {linebreak} 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. {linebreak} Keep on going with this beautiful program. #cfe8bd 1682 code fixed 2006 Feb anonymous Unknown 2006 Feb 4 4 accessing temp database causes crash If the temp database is not referred to at all the following statement causes a crash. PRAGMA temp.table_info('mytable'); Yes, this refers to a non existent table, in a non existent database, so it is not a very interesting bug, but I guess the program should not crash. No problems in 3.3.3 #f2dcdc 1679 new active 2006 Feb anonymous 2006 Feb 4 4 SQLite requires code modification to replace memory allocation funcs 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. #c8c8c8 1678 code closed 2006 Feb anonymous Unknown 2006 Feb 1 1 error select like select * from tResult where tex like '%ra%' (result = 0) select tex from tResult where id = 3229 (tex = "...Oracle...") http://www.aidagw.com/files/dba.zip _2006-Feb-15 03:24:37 by drh:_ {linebreak} The query works correctly on the command-line shell. This is probably a bug in sqlite3explorer. #c8c8c8 1676 code closed 2006 Feb anonymous 2006 Feb 2 2 When binding the wrong type sqlite3 bails out but retuns an SQLITE_OK I'm not using sqlite api directly but please, bear with me :) Using Qt 4.1.0 version of sqlite driver ( sqlite 3.2.7 according to sqlite3.h ) When I do a prepared insert and bind a QByteArray to a field that is of type varchar in the create table, Qt will call a bind to blob instead of bind to text. The query isn't executed, but Qt still receives an SQLITE_OK instead of a more proper SQLITE_MISMATCH. I was going to report this to Trolltech, but it seams to me this really is a bug with sqlite, I can't find anything wrong with their code. _2006-Feb-11 21:08:07 by drh:_ {linebreak} SQLite allows you to insert any data type into any column (except, of course for INTEGER PRIMARY KEY columns which must be an integer.) This is a feature, not a bug. See http://www.sqlite.org/faq.html#q3 ---- _2006-Feb-13 02:46:32 by anonymous:_ {linebreak} As I have said, *it does not get executed*! It says it was OK but the database contains *no new rows*. ---- _2006-Feb-13 02:52:12 by anonymous:_ {linebreak} Sorry for submitting so fast, I got really frustrated that the report wasn't carefully read, I hope you can understand. I did some small amount of step into the sqlite library to debug the code, and I don't know why it fails to execute ( even thought it says it did ). I do know that when the bind_blob call was replaced by a bind_text, it worked just fine, and I could later on load the data back. ---- _2006-Feb-13 12:37:09 by drh:_ {linebreak} If you want anybody to look into this, you are going to have to supply some additional clues, such as: *: The exact SQL text of the INSERT statement that fails. *: The schema of the database you are running the statement against. *: The text you are binding against the SQL statement. *: What you are doing to determine that the INSERT is not working. ---- _2006-Feb-14 02:14:24 by anonymous:_ {linebreak} I'm unable to reproduce anymore, sorry that I wasted your time. Tried to build a small test case for several hours but nothing seams to make it fail. Maybe it was some typo of my part. #f2dcdc 1675 new active 2006 Feb anonymous 2006 Feb 5 4 sqlite3_db_dup() ? 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. #cfe8bd 1674 code fixed 2006 Feb anonymous 2006 Feb 3 3 sum(-9223372036854775805) returns integer -9223372036854775808 SUM() of very large integer results incorrect value. $ sqlite3 SQLite version 3.3.4 Enter ".help" for instructions sqlite> select sum(-9223372036854775805); -9223372036854775808 sqlite> select typeof(sum(-9223372036854775805)); integer #c8c8c8 1673 code closed 2006 Feb anonymous Shell 2006 Feb 3 3 constraint using "in" -- bug 1645 revisited create table junk(x text check(x in ( 'abc' ))); insert into junk values( 'x' ); SQL error: constraint failed also the error message must identify which constraint failed: #1648 _2006-Feb-11 05:48:05 by anonymous:_ {linebreak} that was supposed to be insert into junk values( 'a' ); which also fails ---- _2006-Feb-11 08:55:47 by anonymous:_ {linebreak} create table junk(x text check(x in ( 'a', 'b', 'c' ))); ? ---- _2006-Feb-11 14:06:50 by anonymous:_ {linebreak} Oops, I must have been thinking of a different programming language. Thanks, please close this. #cfe8bd 1672 code fixed 2006 Feb anonymous Unknown 2006 Feb 1 1 Deadlock when multithreading on unix The code for aquiring the mutex in os_unix.c leads to deadlocks: void sqlite3UnixEnterMutex(){ #ifdef SQLITE_UNIX_THREADS pthread_mutex_lock(&mutex1); if( inMutex==0 ){ pthread_mutex_lock(&mutex2); mutexOwner = pthread_self(); } pthread_mutex_unlock(&mutex1); #endif inMutex++; } void sqlite3UnixLeaveMutex(){ assert( inMutex>0 ); #ifdef SQLITE_UNIX_THREADS assert( pthread_equal(mutexOwner, pthread_self()) ); pthread_mutex_lock(&mutex1); inMutex--; if( inMutex==0 ){ pthread_mutex_unlock(&mutex2); } pthread_mutex_unlock(&mutex1); #else inMutex--; #endif } note: a thread 1 can own mutex2 thread 2 will take mutex1 in order to take 2 but wait for thread 1 thread 1 will not be able to unlock mutex2 because lock1 is locked. resolution: I put together a patch that implements recursive locks properly (and now my application seems to work properly). It would probably be nice to use the pthread recursive mutex when available, after detecting with configure that they are available see PTHREAD_MUTEX_RECURSIVE_NP and PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP. Those recursive mutex have the advantage that they would be maintained by the pthread guys :) Cheers Nicolas #cfe8bd 1671 new fixed 2006 Feb anonymous Parser 2006 Feb drh 5 4 Support '@' as a named parameter prefix Adding this little teensy *case '@':* at line 264 in tokenize.c will save hundreds of developers from having to retool all their SQL when converting their code over from SQL Server and Sql Mobile ... Let the defection begin! #cfe8bd 1670 code fixed 2006 Feb anonymous 2006 Feb 1 3 sum() still returns wrong result - the sequel The following session shows that after checkin 3064 the sum function can still return an incorrect result. SQLite version 3.3.3 Enter ".help" for instructions sqlite> create table t(a integer); sqlite> insert into t values( (1<<62) ); sqlite> insert into t values( (1<<62) ); sqlite> insert into t values( (1<<62) ); sqlite> insert into t values( (1<<62) ); sqlite> insert into t values( 1 ); sqlite> insert into t values( -(1<<62) ); sqlite> insert into t values( -(1<<62) ); sqlite> insert into t values( -(1<<62) ); sqlite> insert into t values( -(1<<62) ); sqlite> select * from t; 4611686018427387904 4611686018427387904 4611686018427387904 4611686018427387904 1 -4611686018427387904 -4611686018427387904 -4611686018427387904 -4611686018427387904 sqlite> select sum(a) from t; 0 This happens because the intermidiate result overflowed, which caused a loss of precision in the floating point implementation so that the result is not exact. The result is correct in floating point because the result 0 is approximately equal to the correct result 1 given the 64 bit precision of the long double accumulator. You just can't do exact aritmetic using floating point. At some point point you will run out of precision. SQLite needs to check for overflow after each step, once it has overflowed, it can't be guaranteed to get the exact result, so it should signal the error then. It can't simply check the result once after everything is done. It won't know if it lost precision during an intermediate step. _2006-Feb-09 22:11:37 by drh:_ {linebreak} There is a philosophical difference in the design of SQLite and the design of the standard SQL language. Standard SQL requires that everything be perfect or else it throws an error and gives up. SQLite, in contrast, will try to muddle through when it finds an problem. The most obvious example of this philosophical difference is SQLite's use of manifest typing and its willingness, for example, to store a TEXT value in a column of type INTEGER. The SQL standard requires the database engine to throw an exception when one attempts to store a string in a numeric column. But SQLite openly and proudly defies this requirement and stores the string anyway. The forgiving nature of SQLite is a deliberate feature, not a bug. It leads to more ductile applications that fail gracefully. The SQL standard approach of throwing an error leads to brittle software that fails abruptly and without warning. The behavior of SUM() on a integer overflow is another example of this philosophical difference. The SQL standard wants us to throw an exception. But the desire of SQLite to fail gracefully suggests a different design. The fix to this ticket, and to tickets #1669 and #1664, is for SUM() to return a integer result only if all its non-NULL inputs are integers and the result is exact. If any input to SUM() is a string or BLOB or real number, or if integer overflow occurs during any point in the calculation, then SUM() returns a floating point value, which in some circumstances might be an approximation of the true sum. In this way, you always get an answer which is usually very close to correct. SUM() now never gives an error. ---- _2006-Feb-10 18:13:31 by anonymous:_ {linebreak} I respectfully disagree with this decision. This implementation makes it much harder for a user who needs to get an exact result. In many cases an approximate result is not useful, it maybe no better than a random number. If the database can't generate an exact result when the user is taking specific steps to get one, it should say so in no uncertain terms. SQLite is now encoding the exactness of the result in the type of the result. In order to use this information in SQL the user will be forced to execute the sum twice, once to check the type, and a second time to get the actual result. select case when typeof(sum(a)) = 'integer' then sum(a) else NULL -- would like to throw error here but can't end from t; or select (typeof(sum(a)) = 'integer') as exact, sum(a) from t; Without CSE optimization this will double the execution time for these queries. This will be a bigger problem with large tables where the user is more likely to be concerned about overflow. Furthermore, if the result of the sum is used in some other calculation, the user must now separate that calculation into multiple SQL statements so that he can check the type of the sum results to ensure it is still exact before it is used for further calculations. There are many ways that the type of the intermediate results can be lost. This is particularly problematic for subselect used in other statements such as inserts or updates. update t2 set b = (select sum(a) from t) - (select sum(a) from t3); Whereas, if an integer sum reports overflow errors as the SQL standard calls for, and the user really wants to get an approximate sum, it can be done quite simply by casting the values to approximate floating point values before summing them. select sum(cast a as real) from t; If the user wants approximate results and doesn't want to receive overflow errors they can simply declare the column real, or leave the column type undeclared. The undeclared type is more in keeping with the manifest typing of SQLite. In these cases SQLite can perform an approximate sum and the user will never receive an overflow error. Overflow errors would only be generated if the user has taken specific steps to request exact arithmetic, and SQLite is unable to provide an exact answer. Overflow errors, when generated, would be detected automatically by the caller's normal error checking functions. This is particularly important when using a wrapper. The wrapper will handle this error like any other SQLite error, whereas it may not provide access to the type of the result and will certainly make checking for inexact result errors different, and usually more difficult, than all other errors. Furthermore, I find your descriptions of the SQL standard and SQLite's features somewhat disingenuous. The standard does not require perfection or it gives up. It detects and reports conditions that make it impossible to keep its contract with the user. And SQLite does not muddle through when it finds a problem. There is no problem in your example, because SQLite was designed to allow any type of value to be inserted into any column. SQLite also fails abruptly and without warning when it does detect a problem. It doesn't muddle through corrupt database files, or illegal SQL statements. Very often, generating an incorrect result is not failing gracefully, it is just failing. This implementation assumes that users would always prefer to get an approximate but possibly grossly incorrect result rather than getting either an exactly correct result or a direct notification that an exact result could not be generated. A standard implementation would provide the exact result or a normal error. It would only generate an error if the user took specific steps to ask for exact calculations (by declaring the columns integer), and SQLite couldn't perform the calculation exactly. Furthermore, it would provide a simple method to generate an approximate result if that is what the user really wanted. And finally, SQLite would still perform the current approximate sum for all columns with real, untyped, or mixed data types, just as it does now. ---- _2006-Feb-10 18:49:27 by drh:_ {linebreak} Applications for which an approximate SUM() is a problem are welcomed, encouraged even, to register their own SUM() implementation using the {link: http://www.sqlite.org/capi3ref.html#sqlite3_create_function sqlite3_create_function()} API. Unlike other database engines, SQLite is designed to be customized, on a connection-by-connection basis. If you are unhappy with the current implementation of SUM(), then please by all means overload it with a different implementation that better suits your needs. You can used the existing implementation in func.c as a basis for your modified version. ---- _2006-Feb-10 18:56:06 by anonymous:_ {linebreak} Unfortunately that solution is not available to users of the sqlite3.exe shell or any number of other database administration tools. It can only be used by creating a custom program an using the API functions, or some wrapped version of them, to install the user defined functions. This is not a general solution to the problem. #cfe8bd 1669 code fixed 2006 Feb anonymous 2006 Feb 1 3 sum() still returns wrong result The following trace shows that the new sum() function in CVS head silently returns the wrong answer when an overflow ocurrs. SQLite version 3.3.3 Enter ".help" for instructions sqlite> create table t (a integer); sqlite> insert into t values( (1<<62)-1 ); sqlite> insert into t values( (1<<62)-1 ); sqlite> insert into t values( (1<<62)-1 ); sqlite> select * from t; 4611686018427387903 4611686018427387903 4611686018427387903 sqlite> select sum(a) from t; -9223372036854775808 From the SQL:1999 standard (where TXA is the set of values to be summed): If SUM is specified, then the result is the sum of the values in TXA. If the sum is not within the range of the declared type of the result, then an exception condition is raised: data exception - numeric value out of range. SQLite should detect the overflow and report the error. It should not produce an incorrect result. _2006-Feb-09 17:59:25 by anonymous:_ {linebreak} While reviewing the changes made by checkin 3061 http://www.sqlite.org/cvstrac/chngview?cn=3061 that was supposed to have fixed the sum function, I noticed that the step counter for the sum() function was changed to an unsigned 32 bit value, while the counter for the count() function was changed to a signed 64 bit value (effectively 63 bits). This seems strange. In addition I noticed that the counter for the variance and std deviation functions remains as a signed 32 bit value (effectively 31 bits). We now have 3 different values for the maximum number of rows that these functions can operate on. Furthermore, the API defines a function sqlite3_aggregate_count() that is supposed to return the number of steps for any aggregate function, but it is not used by any of the existing aggregate functions. It currently returns a signed 32 bit count so it is limited to the lowest number of result rows. It seems to me that sqlite3_aggregate_count should be changed to return a 64 bit value (i64, since that is more tan enough for the largest possible database). Then the existing aggregate funcions should be modified to remove their own independant and redundant counters, and instead use the sqlite3_aggregate_count() function to get the number of rows they have operated on. This is, of course, an change to the public API which may have compatability implications for some users. This change is one that should probably be made since the users existing functions will generate incorrect results if they are used on a large database where the actual number of rows processed exceeds the 31 bit range of the existing sqlite3_aggregate_count() function. Some users with small databases won't care about this "theoretical" problem, but SQLite won't notify them when the cross the line and it becomes a real problem. #c8c8c8 1668 event closed 2006 Feb anonymous Shell 2006 Feb drh 2 3 datetime modifiers "enf of *" and "group * by" do not work datetime('now','localtime','group hours by 8'); {linebreak} results in an empty string, not the result as explained in the wiki page {linebreak} datetime('now','end of day'); {linebreak} the same unexpected empty result. It seems that "end of" and "group by" modifiers do not work with version "3.3.3 stable". _2006-Feb-09 23:00:09 by drh:_ {linebreak} Those keywords are extensions that were added by an anonymous poster. You can find his patches further down on the web page. The keywords described have never been a part of the core SQLite. #c8c8c8 1667 code closed 2006 Feb anonymous BTree 2006 Feb danielk1977 1 1 Database corruption when db file hits 1 GB with auto_vacuum (3.3.3) After a few inserts sqlite3_step fails with the error "database disk image is malformed". I noticed that this problem only occurs if I have the pragma "auto_vacuum = 1". The db size on disk is about 1GB at the time. The thing is that after this occurs, the db doesn't seem to be corrupted (I can add/remove things from the table from the command line utility on the same db). I reproduced this on windows and linux. I replicated this problem in a test case (it takes a a minute or so to hit 1 GB). _2006-Feb-09 01:11:18 by anonymous:_ {linebreak} I forgot to mention that I reproduced this problem on Linux Fedora Core 3 and Windows XP Pro SP2 (I don't think it maters, but who knows...). ---- _2006-Feb-10 08:33:19 by danielk1977:_ {linebreak} As far as I can see, this bug should not have actually corrupted any databases. Any attempt to create an auto-vacuum database bigger than 1GB will have caused the transaction to fail with an SQLITE_CORRUPT error. Should be fixed in cvs now. Thanks for taking the time to write the test case. #cfe8bd 1666 code fixed 2006 Feb anonymous 2006 Feb 3 3 sqlite3_analyzer has 32-bit overflow errors I'm analyzing a sqlite3 database that is greater than 4GB in size. I get 32-bit overflows in the total payload for the database and some other statistics. Please use 64-bit integers if possible. Thanks! (Otherwise it's a quite handy tool that I thought I'd have to write myself.) _2006-Feb-15 02:51:53 by anonymous:_ {linebreak} Thanks! - arun [at] coverity.com #cfe8bd 1665 code fixed 2006 Feb anonymous Unknown 2006 Feb drh 1 1 Memory corruption using ALTER TABLE This occurs in windows using the following code which is designed to deliberately exacerbate the problem:
 sqlite3 *pcnn; while(1){   DeleteFile("test.db");   sqlite3_open("test.db", &pcnn);   sqlite3_exec(pcnn, "CREATE TABLE foo (\   a_2 TEXT NOT NULL ON CONFLICT REPLACE DEFAULT '' COLLATE NOCASE\   )", NULL, NULL, NULL);   sqlite3_exec(pcnn, "ALTER TABLE foo ADD COLUMN a_6 INTEGER", NULL, NULL, NULL);   sqlite3_close(pcnn); } 
The bug only occurs when COLLATE NOCASE is added to column a_2. #cfe8bd 1664 code fixed 2006 Feb anonymous 2006 Feb 1 1 sum() returns wrong result The following sqlite shell trace shows a case where sqlite's sum() function returns the wrong result while summing integer values. SQLite version 3.3.2 Enter ".help" for instructions sqlite> create table tt(a integer); sqlite> insert into tt values(1); sqlite> insert into tt values(1<<62); sqlite> select * from tt; 1 4611686018427387904 sqlite> select sum(a) from tt; 4611686018427387904 sqlite> select (1<<62) + 1; 4611686018427387905 sqlite> _2006-Feb-08 16:50:24 by drh:_ {linebreak} sum() accumulates its results in a 64-bit float (a "double"). We could change it to use a 64-bit integer when summing only integer values, but then you run into a problem with integer overflow. We would need to detect when overflow occurred and then switch to using a double. But how do you detect integer overflow on addition in ANSI-C? If you have any suggestions, I would like to hear them. ---- _2006-Feb-08 16:58:55 by anonymous:_ {linebreak} Just keep a running total as a double and as a 64 bit int and then compare them to decide which one to use. ---- _2006-Feb-08 17:17:34 by anonymous:_ {linebreak} In addition to the keeping a 64 bit int sum and a double sum, if all of the sum inputs are integer and the absolute value of the double sum is less than the maximum size of the mantissa of a double ((1<<52)-1) then use the 64 bit int sum. Otherwise use the double sum. But you still have problems with integer accuracy over the maximum mantissa size. Barring using a 128 bit integer (or using an arbitray precision math library) emulated in software for the integer sum, there's not much you can do about that. ---- _2006-Feb-08 17:40:39 by anonymous:_ {linebreak} You can detect integer addition overflow by checking the signs of the argumnets and the result. You have had an overflow only if you sum two positive numbers and get a negative result, or sum two negative numbers and get a positive result. c = a + b; if( (a>=0 && b>=0 && c<0) || (a<0 && b<0 && c>=0) ) /* overflow detected */ Summing a positive and a negative number can't overflow. Summing two values with the same sign and getting a result with the same sign means the sum didn't overflow. ---- _2006-Feb-08 18:17:11 by anonymous:_ {linebreak} The SQL standard requires that result of SUM must be within the range of the source data type, and that the result must be exact numeric if the source is exact numeric. This means that SUM must detect overflow and return an overflow error result if an overflow ocurrs while summing integers. It cannot switch to an approximate (i.e. double) result type. This avoids the problem of summing many small values (or more usually a few large values and many small values) and getting an incorrect result. If you were to try to switch result types after overflow, you would convert a large value near (1<<63) into a double with only 52 bits of mantissa. This sum will not increase any more if you are summing values less than about 11 bits, even if you sum millions of rows of these values. The SUM function in SQLite should only switch to a double result if one of the arguments is real (because of its manifest typing). Now it's summing approximate values and should return an approxiamte result. And anyone who uses floating point math should know they need to be careful when summing values on different orders of magnitude. ---- _2006-Feb-08 20:33:43 by anonymous:_ {linebreak} I have attached a patch to func.c that implements full integer sum, avg, and total functions with overflow detection and reporting. ---- _2006-Feb-08 20:42:07 by anonymous:_ {linebreak} While making changes to func.c for integer sums I noticed that the row count for the count and average functions are limited to signed 32 values. This puts a practical limit on the number of rows in a database that may be less than that imposed by the size of the database file. For these functions to operate correctly they can only be used on tables with less than 2^31 rows. The documentation for SQLite says it supports database files up to 2^41 bytes. This means that a database with a single table with rows less than about 2^10 bytes can become to large to use with the existing count() and avg() functions. Perhaps these counters should be changed to 64 bit values. #f2dcdc 1663 new active 2006 Feb anonymous Unknown 2006 Feb 4 4 Suggestion: DATETYPE field type using David Tribble's work? 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:_ {linebreak} What advantage does David Tribble's datetype design have over the existing date and time support in SQLite? Why should we change? #cfe8bd 1661 code fixed 2006 Feb anonymous Unknown 2006 Feb 3 4 The following never returns in v2.8.16 : select 1 limit 1 offset 1; The following all sit at 100% cpu and never return: SELECT 1 LIMIT 0 OFFSET 1; SELECT 1 LIMIT 1 OFFSET 1; SELECT 1 LIMIT 9 OFFSET 1; SELECT 1 LIMIT 0 OFFSET 9; SELECT 1 LIMIT 1 OFFSET 9; SELECT 1 LIMIT 9 OFFSET 9; _2006-Feb-06 17:19:21 by drh:_ {linebreak} The general policy for maintenance of SQLite version 2 is to fix bugs that might result in data loss or database corruption or other serious malfunctions. For more mundane problems like the one reported here, our advice is to code around the problem in the application by not doing the particular SQL that is causing problem or else upgrade to SQLite version 3. #cfe8bd 1660 code fixed 2006 Feb anonymous 2006 Feb danielk1977 1 1 OS memory allocation functions may round-up the requested size OS memory allocation functions may round-up the requested size but sqlite allocation routines (sqlite3MallocRaw() and sqlite3Realloc()) do not take into an account this fact. For example: sqlite3MallocRaw() may be called with its "n" argument equal to 35, but the actual allocated size will be 36. Because of that handleSoftLimit() will be called with 35 as an argument when the memory is allocated and with 36 as an argument when the memory is deallocated. At some point the assert inside handleSoftLomit() will fail: "assert( pTsd->nAlloc>=0 );". Proposed fix: void *sqlite3MallocRaw(int n){ void *p = 0; < if( n>0 && !sqlite3MallocFailed() && !handleSoftLimit(n) ){ < while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) ); < if( !p ){ < /* If the allocation failed, call handleSoftLimit() again, this time < ** with the additive inverse of the argument passed to < ** handleSoftLimit() above. This is so the ThreadData.nAlloc variable is < ** still correct after a malloc() failure. < */ < (void)handleSoftLimit(n * -1); -> if( n>0 && !sqlite3MallocFailed()){ -> while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) ){ -> } -> if(p){ -> /* Find the size of the allocated cell and add it to -> ** the per-thread allocated memory amount. */ -> n = OSSIZEOF(p); -> if(handleSoftLimit(n) != 0){ -> OSFREE(p); -> return 0; -> } -> } -> else { sqlite3FailedMalloc(); OSMALLOC_FAILED(); } void *sqlite3Realloc(void *p, int n){ if( sqlite3MallocFailed() ){ return 0; } if( !p ){ return sqlite3Malloc(n); }else{ void *np = 0; < if( !handleSoftLimit(n - OSSIZEOF(p)) ){ < while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) ); < if( !np ){ < /* If the allocation failed, call handleSoftLimit() again, this time < ** with the additive inverse of the argument passed to < ** handleSoftLimit() above. This is so the ThreadData.nAlloc variable is < ** still correct after a malloc() failure. < */ < (void)handleSoftLimit(OSSIZEOF(p) - n); < sqlite3FailedMalloc(); < OSMALLOC_FAILED(); -> int old_size = OSSIZEOF(p); -> while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) ){ -> } -> if(np){ -> int new_size = OSSIZEOF(np); -> if(handleSoftLimit(new_size - old_size) != 0){ -> OSFREE(np); -> return 0; } < } -> } -> else{ -> sqlite3FailedMalloc(); -> OSMALLOC_FAILED(); -> } return np; } } ----------------------- But I think the fix is not very good because it changes the working logic of these functions. Initally it was: "allocate TLS data and if the TLS is not 0 then allocate the requested amount of memory". The fix changes it to "allocate the requested amount of data and if successfull then allocate the TLS. If the last operation fails, free the allocdated memory and return 0." _2006-Feb-06 12:44:56 by anonymous:_ {linebreak} another important thing is to handle memory alignment... some processor do not accept odd memory addresses, so this must be carefully checked ---- _2006-Feb-06 14:03:05 by danielk1977:_ {linebreak} I think the alignment issues are taken care of by the underlying sqlite3OsMalloc() API. malloc() is usually defined to return a block suitably aligned for any data. ---- _2006-Feb-06 19:49:32 by drh:_ {linebreak} Check-in [3056] breaks all kinds of things. The regression test fails early and often. #c8c8c8 1659 event closed 2006 Feb anonymous Shell 2006 Feb anonymous 1 2 Sqlite.exe .import stopped working in latest 3.3.3 release (Win32) The .import function in SQLite.exe (Win32) does not work. In Previous 3.3.2b it worked fine. I am using the same batch scripts in a cmd prompt on WinXP as before. sqlite3.exe test.db ".import data.txt table1 ;" _2006-Feb-06 12:41:14 by drh:_ {linebreak} Duplicate of #1651. Already fixed by [3047]. #cfe8bd 1658 code fixed 2006 Feb anonymous 2006 Feb 3 4 SQLITE3.EXE program crash ***BUG CREATE TEMP VIEW People AS Select FirstName from People; This is accepted. But SELECT rowid FROM temp.people; Gives a program crash sqlite> CREATE TEMP VIEW People AS Select firstname from people; sqlite> select * from temp.people; C:\SQLite\ImportUnit\Test> Workaround: CREATE TEMP VIEW People AS SELECT firstName FROM main.People; #cfe8bd 1657 code fixed 2006 Feb anonymous 2006 Feb 1 1 Disk I/O error when used on memory filesystem With sqlite 3.2.7 I have an application that works on memory filesystem /dev/shm but when upgrading to 3.3.3 it shows the error "disk I/O error" even trying with sqlite shel gives the same error. My platform is linux knoppix4.02 interesting with suse7 it works ! The sqlite 3.2.7 shell works fine where the 3.3.3 doesn't but only on knoppix4.02, on disk filesystem both works. _2006-Feb-06 10:55:49 by anonymous:_ {linebreak} I have the same problem with SQLite 3.3.3 under AIX 4.3.3.0 but only with permanent data storage. There is no problem with in memory databases: $ ./sqlite3 test.db SQLite version 3.3.3 Enter ".help" for instructions sqlite> create table test (c1); SQL error: disk I/O error sqlite> .quit $ ./sqlite3 :memory: SQLite version 3.3.3 Enter ".help" for instructions sqlite> create table test (t1); sqlite> .quit Permissions under the tested directory are OK. Previously created databases can be opened but there is no way to modify either the structure or the data. SQLite 3.3.3 was configured with : ./configure --enable-threadsafe --enable-cross-thread-connections --enable-tempstore ---- _2006-Feb-06 12:45:34 by drh:_ {linebreak} Does the problem go away if you recompile with -DSQLITE_DISABLE_DIRSYNC=1 Please let me know. If it does, I will try to come up with a fix. ---- _2006-Feb-06 15:42:22 by anonymous:_ {linebreak} Yes, the problem was solved by recompiling with the provided options. Thanks! #cfe8bd 1654 code fixed 2006 Feb anonymous VDBE 2006 Feb 1 1 crash when executing query on Intel builds We experience a crash in Intel builds of sqlite (both on Windows and Mac OS X Intel) when executing a specific (rather simple) query with a given database. We've seen sporadic crashes on Intel with similar backtraces, which may have been caused by the same problem, but this time, we got a database and a single query that will reliably trigger the crash: Open the attached database "AdminDatabase.db" in sqlite3 and execute the following query: SELECT sd_packages.id FROM sd_packages WHERE UniqueID IN ('71E6D020-59B2-41E3-96BC-EA24DE232A7C'); This crashes sqlite3 (both the commandline tool and our embedded build) on Mac OS X Intel and Windows XP with the following backtrace (from sqlite3 tool on Mac OS X Intel): Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x00015399 in sqlite3MemCompare (pMem1=0xbfffed50, pMem2=0xbfffed10, pColl=0x4002b0) at ../src/vdbemem.c:599 #2 0x00014303 in sqlite3VdbeRecordCompare (userData=0x4074b0, nKey1=75, pKey1=0x180a3e5, nKey2=75, pKey2=0x406ef0) at ../src/vdbeaux.c:1808 #3 0x0001d859 in sqlite3BtreeMoveto (pCur=0x406e00, pKey=0x406ef0, nKey=75, pRes=0xbffff088) at ../src/btree.c:3409 #4 0x00040434 in sqlite3VdbeExec (p=0x1806c00) at ../src/vdbe.c:2922 #5 0x0001170b in sqlite3_step (pStmt=0x1806c00) at ../src/vdbeapi.c:222 #6 0x00019bb0 in sqlite3_exec (db=0x400180, zSql=0x406c20 "SELECT sd_packages.id FROM sd_packages WHERE UniqueID IN ('71E6D020-59B2-41E3-96BC-EA24DE232A7C');", xCallback=0x31a9 , pArg=0xbffff2a4, pzErrMsg=0xbffff1ec) at ../src/legacy.c:78 #7 0x00006211 in process_input (p=0xbffff2a4, in=0x0) at ../src/shell.c:1487 #8 0x00006a32 in main (argc=2, argv=0xbffffc34) at ../src/shell.c:1777 (I haven't tried any other Intel platforms) The database schema of the enclosed database has been modified with _ALTER TABLE ... ADD COLUMN ..._, in case this matters. Also, when running the sqlite3 tool, make sure that you enter the crashing statement as the first: I found that running a _.schema_ command before executing the statement will cause the statement to execute without crashing. #f2dcdc 1653 new active 2006 Feb anonymous CodeGen 2006 Feb 4 5 SQLITE_OMIT_COST_REORDERING ? 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. #cfe8bd 1652 code fixed 2006 Jan anonymous CodeGen 2006 Feb 3 4 sorting ASC vs DESC changes number of returned rows Changing the order by clause from ASC to DESC changes the number of returned rows in this query:
 SELECT urls.url_id FROM (SELECT urls.url_id AS urls_url_id FROM urls ORDER BY urls.url_id DESC LIMIT 2 OFFSET 0) AS rowcount,  urls LEFT OUTER JOIN tags ON urls.url_id = tags.url_id  WHERE rowcount.urls_url_id = urls.url_id ORDER BY urls.url_id DESC 
returns 0 rows. When changing DESC to ASC the query returns a few rows. This funny query is generated by sqlalchemy when a limited number of urls is loaded while eagerly loading the tags. The schema is very simple:
 CREATE TABLE urls(url_id, ...);  CREATE TABLE tags(         tag VARCHAR(20) NOT NULL,         url_id INTEGER NOT NULL REFERENCES urls(url_id),         UNIQUE (tag, url_id) ); 
explain with DESC:
 addr  opcode          p1          p2          p3 ----  --------------  ----------  ----------  --------------------------------- 0     Noop            0           0 1     Integer         2           0 2     MustBeInt       0           0 3     Negative        0           0 4     MemStore        0           1 5     Integer         0           0 6     MustBeInt       0           0 7     Negative        0           0 8     MemStore        1           1 9     OpenVirtual     0           1 10    Goto            0           69 11    Integer         0           0 12    OpenRead        1           2 13    SetNumColumns   1           7 14    Last            1           25 15    MemIncr         1           0 16    IfMemPos        1           18 17    Goto            0           24 18    MemIncr         0           25 19    Rowid           1           0 20    MakeRecord      1           0 21    NewRowid        0           0 22    Pull            1           0 23    Insert          0           0 24    Prev            1           15 25    Close           1           0 26    Noop            0           0 27    Integer         0           0 28    OpenRead        2           2 29    SetNumColumns   2           7 30    Integer         0           0 31    OpenRead        3           3 32    SetNumColumns   3           2 33    Integer         0           0 34    OpenRead        6           5           keyinfo(1,BINARY) 35    Last            2           65 36    MemInt          0           2 37    Rowid           2           0 38    NotNull         -1          41 39    Pop             1           0 40    Goto            0           60 41    MakeRecord      1           0           i 42    MemStore        3           0 43    MoveGe          6           60 44    MemLoad         3           0 45    IdxGE           6           60          + 46    RowKey          6           0 47    IdxIsNull       1           59 48    IdxRowid        6           0 49    MoveGe          3           0 50    MemInt          1           2 51    Rewind          0           59 52    Column          0           0 53    Rowid           2           0 54    Ne              361         58          collseq(BINARY) 55    Rowid           2           0 56    Column          3           0 57    Callback        2           0 58    Next            0           52 59    Next            6           44 60    IfMemPos        2           64 61    NullRow         2           0 62    NullRow         6           0 63    Goto            0           50 64    Prev            2           36 65    Close           2           0 66    Close           3           0 67    Close           6           0 68    Halt            0           0 69    Transaction     0           0 70    VerifyCookie    0           6 71    Goto            0           11 72    Noop            0           0  different lines in the explain with ASC: 35    Rewind          2           65 64    Next            2           36 
_2006-Jan-31 23:29:39 by drh:_ {linebreak} 1: There are two occurrences of DESC in your query. Which one did you indent to change to ASC? 2: I tried every combination of DESC and ASC in your query and they all seem to work for me. If you still think this is a problem, please provide a reproducible script that demonstrates the error. ---- _2006-Feb-01 00:20:25 by anonymous:_ {linebreak} You are right. I played a bit with it and noticed that it happened with my "production" db but not with a small subset. It turns out that a url without tags triggers this behaviour. Complete script:
 BEGIN TRANSACTION; CREATE TABLE urls(         url_id INTEGER NOT NULL PRIMARY KEY,         url VARCHAR(255) NOT NULL,         title VARCHAR(255) NOT NULL,         create_ts VARCHAR(20) NOT NULL , comment, cache_file, cache_index); INSERT INTO "urls" VALUES(1, 'http://mail.python.org/pipermail/python-list/1999-October/012917.html', 'Passing file descriptors in Python?', '2006-01-08 19:04:01', NULL, NULL, NULL); INSERT INTO "urls" VALUES(2, 'http://abridgegame.org/darcs/', 'darcs', '2006-01-08 19:04:01', NULL, NULL, NULL); CREATE TABLE tags(         tag VARCHAR(20) NOT NULL,         url_id INTEGER NOT NULL REFERENCES urls(url_id),         UNIQUE (tag, url_id) ); INSERT INTO "tags" VALUES('darcs', 2); INSERT INTO "tags" VALUES('dev', 2); INSERT INTO "tags" VALUES('version', 2); INSERT INTO "tags" VALUES('python', 1); INSERT INTO "tags" VALUES('dev', 1); INSERT INTO "tags" VALUES('api', 1); CREATE INDEX tags_for_url ON tags(url_id);  SELECT urls.url_id FROM (SELECT urls.url_id AS urls_url_id FROM urls ORDER BY urls.url_id DESC LIMIT 3 OFFSET 0) AS rowcount,  urls LEFT OUTER JOIN tags ON urls.url_id = tags.url_id   WHERE rowcount.urls_url_id = urls.url_id ORDER BY urls.url_id DESC; select "result: 6 rows: ok";  SELECT urls.url_id FROM (SELECT urls.url_id AS urls_url_id FROM urls ORDER BY urls.url_id DESC LIMIT 3 OFFSET 0) AS rowcount,  urls LEFT OUTER JOIN tags ON urls.url_id = tags.url_id   WHERE rowcount.urls_url_id = urls.url_id ORDER BY urls.url_id ASC; select "result: 6 rows: ok";   select "inserted new url without tag"; INSERT INTO "urls" VALUES(3, 'http://www.spiegel.de/', 'SPIEGEL ONLINE - Nachrichten', '2006-01-08 19:04:01', NULL, NULL, NULL);  SELECT urls.url_id FROM (SELECT urls.url_id AS urls_url_id FROM urls ORDER BY urls.url_id DESC LIMIT 3 OFFSET 0) AS rowcount,  urls LEFT OUTER JOIN tags ON urls.url_id = tags.url_id   WHERE rowcount.urls_url_id = urls.url_id ORDER BY urls.url_id DESC; select "result: 0 rows: not ok"; SELECT urls.url_id FROM (SELECT urls.url_id AS urls_url_id FROM urls ORDER BY urls.url_id DESC LIMIT 3 OFFSET 0) AS rowcount,  urls LEFT OUTER JOIN tags ON urls.url_id = tags.url_id   WHERE rowcount.urls_url_id = urls.url_id ORDER BY urls.url_id ASC; select "result: 6 rows: ok";  COMMIT; 
---- _2006-Feb-01 00:24:38 by anonymous:_ {linebreak} tested binary is http://www.sqlite.org/sqlite3-3.3.3.bin.gz. ---- _2006-Feb-01 02:28:28 by drh:_ {linebreak} The bug appears unrelated to the DESC and ASC. It seems to be in the table reordering logic of the query optimizer - code introduced in version 3.2.3. Your work-around until this is fixed is to use a CROSS JOIN instead of a comma join, to force a particular join order as described on the QueryPlans wiki page. ---- _2006-Feb-01 08:57:55 by anonymous:_ {linebreak} Thank you for your fast response and your great database. #c8c8c8 1296 new closed 2005 Jun anonymous Unknown 2006 Feb 5 5 Nested Transactions needed Nested transactions are essential in several places. _2005-Jun-29 08:39:13 by anonymous:_ {linebreak} Here is another one who needs nested transactions! ---- _2005-Jun-29 21:23:52 by anonymous:_ {linebreak} Me too. One more. This would be very helpful. ---- _2006-Feb-11 23:07:14 by anonymous:_ {linebreak} Isn't this pretty easy to implement? Just a simple nest counter? It'd be very nice if SQLite would support this. ---- _2006-Feb-11 23:44:01 by drh:_ {linebreak} It is easy enough to add it in a wrapper. This is not something that belongs in the core. #cfe8bd 1651 code fixed 2006 Jan anonymous Shell 2006 Jan 1 1 .import doesn't work in 3.3.3 I have copies of 3.3.1 and 3.3.2. I run a script against those to import several csv files. They work fine. In 3.3.3, the script to create the schema works. The .import commands do nothing. _2006-Jan-31 18:39:55 by anonymous:_ {linebreak} Using the shell directly, no script. .read [ a script to create the schema ] works fine .import [ a csv file ] returns immediately, no error message, no effect. #cfe8bd 1650 code fixed 2006 Jan anonymous Unknown 2006 Jan 3 4 Third parm of sqlite3_prepare is ignored. The doc for sqlite3_prepare states: If the next argument, "nBytes", is less than zero, then zSql is read up to the first nul terminator. If "nBytes" is not less than zero, then it is the length of the string zSql in bytes (not characters). It seems like no matter what value is in the thrid parm, it is ignored and zSql is read up to the first nul char. Thanks #cfe8bd 1649 doc fixed 2006 Jan anonymous 2006 Jan drh 4 1 changes.tcl incorrect in latest checkin In [3038], changes.tcl says "3.3.3 beta" instead of "stable". #f2dcdc 1647 doc active 2006 Jan anonymous Unknown 2006 Jan paul 3 1 i want to use this lib in my project 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:_ {linebreak} This is not a bug report. Please use the mailing list for this type of question. #cfe8bd 1646 doc fixed 2006 Jan anonymous 2006 Jan 3 4 API doc clarification for bind_text: utf8 bytes or chars? The API documentation for "sqlite3_bind_text" says that: "...In those routines that have a fourth argument, its value is the number of bytes in the parameter. This is the number of characters for UTF-8 strings and the number of bytes for UTF-16 strings and blobs. ..." The fourth argument seems to be also the number of bytes (not characters) for UTF-8 strings. If I specify the number of characters, the strings are truncated. #cfe8bd 1645 code fixed 2006 Jan anonymous Shell 2006 Jan 2 3 constraint using "in" create table emp1(id text unique, sex text check( sex in( 'M','F' ))); insert into emp1 values( '1','M'); the above create statement SUCCEEDS, the insert FAILS create table emp2(id text unique, sex text check( sex = 'M' or sex ='F' )); insert into emp2 values( '2','M'); the above create statement SUCCEEDS, the insert FAILS _2006-Jan-29 02:33:50 by anonymous:_ {linebreak} oops, I meant to say that the second insert SUCCEEDS #cfe8bd 1644 code fixed 2006 Jan ghaering VDBE 2006 Jan 3 3 CREATE TEMP/DROP TEMP do not modify schema cookie It appears that CREATE TEMP VIEW and a corresponding DROP VIEW do not modify the schema cookie of the main schema. A pysqlite user was having the problem (http://lists.initd.org/pipermail/pysqlite/attachments/20060124/b373999a/testpysqlite.py) that
 CREATE TABLE ... CREATE TEMP VIEW as something SELECT_STATEMENT_1 DROP TEMP VIEW ... CREATE TEMP VIEW AS something else SELECT_STATEMENT_1 
that here, the SELECT_STATEMENT_1 was still referring to the temporary view that has even been deleted in the meantime. A SQLite developer should be able to verify my interpretation of the problem quite quickly. _2006-Jan-30 13:43:50 by drh:_ {linebreak} Consider the following SQL: CREATE TABLE t1(a); INSERT INTO t1 VALUES(1); CREATE TABLE t2(b); INSERT INTO t2 VALUES(99); CREATE TEMP VIEW v1 AS SELECT * FROM t1; So there are two table, T1 and T2, and a view that is really just an alias for T1. If you then call sqlite3_prepare() on the following statement: SELECT * FROM v1; SQLite uses the view to translate this statement into: SELECT * FROM t1; It then compiles the translated version of the statement. For more complex views the transformation is more complex, but it really amounts to the same kind of thing. SQLite treats views as compile-time macros. Suppose, then that after compiling the statement above, the view definition is changed: DROP VIEW v1; CREATE TEMP VIEW v1 AS SELECT * FROM t2; The schema cookie for the temp database does in fact change. But because the precompiled query never refers to the temporary database, it is not invalidated. If you run the precompiled query, you will get results consistent with SELECT * FROM t1; In a way, this makes sense. The results you are getting are consistent with the view as it was defined at the time when the statement was prepared. If you finalize and reprepare the original statement, it will be recompiled as SELECT * FROM t2; So, I think what this ticket is asking for is that statements always uses the definition of a view as it exists at the time that the statement is executed, not the definition of the view as it was at the time the statement was prepared. That makes sense, I suppose. But I am not yet 100% certain that the current behavior is wrong. I need to think about this some more. ---- _2006-Jan-30 13:48:27 by drh:_ {linebreak} I could easily fix this by simply invalidating all prepared statements after any CREATE VIEW or DROP VIEW. But if I do that I fear there will follow an avalanche of complaints about new SQLITE_SCHEMA errors that were not appearing before. ---- _2006-Jan-30 14:55:55 by ghaering:_ {linebreak} But with the current situation prepared statements will work wrong (i. e. on an outdated schema - if we consider the views to be part of the schema). I think we should go for correctness in this case. ---- _2006-Jan-30 14:59:53 by ghaering:_ {linebreak} I can follow your logic how the current behaviour would make sense if you think in terms of prepared statements. If you use higher-level interfaces like the Python DB-API via pysqlite, however, or your TCL binding for that matter, you don't actively use prepared statements - instead the interface uses them transparently using a statement cache. And then, you will currently get unexpected results, because no SQLITE_SCHEMA is raised for the old statement in the cache, and hence it is not recompiled. ---- _2006-Jan-30 15:15:32 by drh:_ {linebreak} Another variation on this same problem: CREATE TABLE t1(a,b,c); -- prepare some statement that accesses table T1 CREATE TEMP TABLE t1(x,y,z); -- Run the prepared statement. It uses MAIN.T1, not TEMP.T1. Checking schema cookies will not help us here. It appears the only solution is to invalidate all prepared statements after any schema change. ---- _2006-Jan-31 10:10:41 by ghaering:_ {linebreak} Thanks for your commit, it seems I'll have to try the development branch of SQLite soon! By the way I was surprised that your code example works at all:
 CREATE TABLE foo ... CREATE TEMP TABLE foo ... 
I would have expected that to fail with an error message about an already existing object. That's probably just an implementation detail of temporary objects in SQLite - I don't consider it an error. ---- _2006-Jan-31 13:54:03 by drh:_ {linebreak} Creating a TEMP table with the same name as a persistent table was not allowed in SQLite version 2.x. But the restriction was relaxed beginning in version 3.0.0. The reason: To prevent code that creates TEMP tables from breaking if a persistent table with the same name gets added to the schema. #e8e8bd 1643 doc review 2006 Jan anonymous 2006 Jan 1 2 database-name.table-name not working for "PRAGMA table_info" + friends The following pragmas do not allow to specify tables in attached databases if there is a table with the same name in the main database as well: *: PRAGMA foreign_key_list(table-name); *: PRAGMA index_info(index-name); *: PRAGMA index_list(table-name); *: PRAGMA table_info(table-name); The recommended syntax to refer to tables in attatched databases ("Tables in an attached database can be referred to using the syntax database-name.table-name." [ATTACH DATABASE documentation]) does not work for the above PRAGMAs. Instead, SQLite returns error 1 with message 'near ".": syntax error'. GUI database managers like {link: http://www.yunqa.de/delphi/sqlitespy/ SQLiteSpy }need theses pragmas to support the "database-name." prefix to retrieve detailed information about all tables and indexes, even those with duplicate names in attached databases. Syntax is: PRAGMA databasename.table_info(tablename) ---- _2006-Jan-28 10:47:02 by anonymous:_ {linebreak} Thanks for the immediate fix. Any chance this pragma syntax will also make it into the docs? This was already requested in ticked #1308 six months ago. Please do so - there are just three lines missing to the PRAGMA documentation to avoid erroneous tickets of this kind in the future. #c8c8c8 1642 code closed 2006 Jan anonymous 2006 Jan 4 4 single time leaks in sqlite3_prepare() In 3.3.2 the first call to sqlite3_prepare() leaks exactly 42 memory blocks per application session, regardless of number of opened/closed databases or statements executed. Next calls to sqlite3_prepare() don't leak. In 3.3.1 there was leak in sqlite3_execute() but it disappeared in new version. I use BCB 6.4, my own allocator based on dlmalloc and preprocessed sources. There's slight chance it is caused by my code since I do: #define free my_free and taking pointer to original free() is still possible. The extra allocations in the first call to sqlite3_prepare() likely occur as the database schema is being loaded. These blocks should be freed when the database handle is closed. Please post the code that produces the memory leak. ---- _2006-Jan-30 23:06:30 by drh:_ {linebreak} No code was ever posted to demonstrate the problem. We will assume, there for, that this is not really a bug. #c8c8c8 1641 doc closed 2006 Jan anonymous 2006 Jan 5 4 Very minor documentation thing http://www.sqlite.org/datatype3.html In the datatype documentation for COLLATE, it states that the "left operand determines the collation sequence used". But, in the examples, the "right operand" is used. Column a is defined as BINARY, coloumn d is defined as NOCASE, and the example states: -- Text comparison is performed using the NOCASE collation sequence. SELECT (a = d) FROM t1; The same holds for the other examples. I assume, because of their consistency, the examples are right and the docs are wrong? In this case the examples were wrong. Cvs is now corrected, the live website will catch up next release. #c8c8c8 1640 code closed 2006 Jan anonymous VDBE 2006 Jan 3 2 Can't get error message from sqlite3_result_error sqlite3_errmsg doesn't return proper error message from sqlite3_result_error if query is executed by sqlite3_step. For example, #include #include "sqlite3.h" int main(void) { const char *sql = "select 'a' like 'b' escape 'cd'"; sqlite3 *db; sqlite3_stmt *stmt; int ret; char *err; sqlite3_open(":memory:", &db); ret = sqlite3_exec(db, sql, NULL, NULL, &err); printf("exec=%d\n", ret); printf("exec:err=%s\n", err); printf("exec:errmsg=%s\n", sqlite3_errmsg(db)); sqlite3_prepare(db, sql, -1, &stmt, NULL); ret = sqlite3_step(stmt); printf("step=%d\n", ret); printf("step:errmsg=%s\n", sqlite3_errmsg(db)); sqlite3_close(db); return 0; } $ ./testprogram exec=1 exec:err=ESCAPE expression must be a single character exec:errmsg=ESCAPE expression must be a single character step=1 step:errmsg=SQL logic error or missing database $ Maybe derived from check-in [2982]. The error message is available via sqlite3_errmsg() only after sqlite3_finalize() or sqlite3_reset() is called on the statement handle. #f2dcdc 1638 warn active 2006 Jan anonymous 2006 Jan 3 2 rows place change and some row element missing 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 #f2dcdc 1637 code active 2006 Jan anonymous Parser 2006 Jan 4 4 Multiple JOIN USING() doesn't work.
 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 1636 todo active 2006 Jan anonymous Shell 2006 Jan drh 4 3 stdev does not work 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? #f2dcdc 1635 doc active 2006 Jan anonymous 2006 Jan 4 4 SQLite Ticket "Version" field 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. #cfe8bd 1634 code fixed 2006 Jan anonymous CodeGen 2006 Jan 3 3 LIMIT in nested select not working properly When a limit is included in a nested select, the result is not as expected. Example: {linebreak} CREATE TABLE a(id, x);{linebreak} INSERT INTO "a" VALUES(1, '1');{linebreak} INSERT INTO "a" VALUES(2, '2');{linebreak} INSERT INTO "a" VALUES(3, '3');{linebreak} CREATE TABLE b(a_id, x);{linebreak} INSERT INTO "b" VALUES(1, '1a');{linebreak} INSERT INTO "b" VALUES(1, '1b');{linebreak} INSERT INTO "b" VALUES(1, '1c');{linebreak} INSERT INTO "b" VALUES(1, '1d');{linebreak} INSERT INTO "b" VALUES(2, '2a');{linebreak} INSERT INTO "b" VALUES(2, '2b');{linebreak} INSERT INTO "b" VALUES(3, '3a');{linebreak} INSERT INTO "b" VALUES(3, '3b');{linebreak} INSERT INTO "b" VALUES(3, '3c');{linebreak} the query{linebreak} SELECT a.id, a.x, b.x FROM (SELECT id FROM a LIMIT 5) AS rowcount, a LEFT OUTER JOIN b ON a.id = b.a_id WHERE rowcount.id = a.id; returns{linebreak} 1|1|1a{linebreak} 1|1|1b{linebreak} 1|1|1c{linebreak} 1|1|1d{linebreak} 2|2|2a{linebreak} I expect there to be 5 a's with all matching b's. The result should be the same as SELECT a.id, a.x, b.x FROM a LEFT OUTER JOIN b as there are less then 5 a's. This construct with nested select with limit us used by sqlalchemy ( www.sqlalchemy.org ) when loading a limited number of a's while eagerly loading the dependent b's. _2006-Jan-21 17:18:46 by anonymous:_ {linebreak} Simpler example of the sub-select LIMIT bug: sqlite> select sqlite_version(*); 3.2.8 CREATE TABLE t1(a); INSERT INTO "t1" VALUES(1); INSERT INTO "t1" VALUES(2); INSERT INTO "t1" VALUES(3); The following query should produce 6 rows: sqlite> select * from t1, (select * from t1 limit 2); 1|1 1|2 Also, the following two queries should produce the same number of rows : sqlite> select * from (select * from t1 limit 3), (select * from t1 limit 2); 1|1 1|2 2|1 sqlite> select * from (select * from t1 limit 2), (select * from t1 limit 3); 1|1 1|2 ---- _2006-Jan-21 19:23:20 by anonymous:_ {linebreak} Workaround: always specify OFFSET for each LIMIT clause. sqlite> select sqlite_version(*); 3.2.8 CREATE TABLE t1(a); INSERT INTO "t1" VALUES(1); INSERT INTO "t1" VALUES(2); INSERT INTO "t1" VALUES(3); sqlite> select * from t1, (select * from t1 limit 2 offset 0); 1|1 1|2 2|1 2|2 3|1 3|2 sqlite> select * from (select * from t1 limit 3 offset 0), (select * from t1 limit 2 offset 0); 1|1 1|2 2|1 2|2 3|1 3|2 sqlite> select * from (select * from t1 limit 2 offset 0), (select * from t1 limit 3 offset 0); 1|1 1|2 1|3 2|1 2|2 2|3 -- original bug report query sqlite> SELECT a.id, a.x, b.x FROM (SELECT id FROM a LIMIT 5 OFFSET 0) AS rowcount, a LEFT OUTER JOIN b ON a.id = b.a_id WHERE rowcount.id = a.id; 1|1|1a 1|1|1b 1|1|1c 1|1|1d 2|2|2a 2|2|2b 3|3|3a 3|3|3b 3|3|3c ---- _2006-Jan-21 19:59:01 by anonymous:_ {linebreak} UNTESTED fix for ticket #1634 --- select.c-328 2006-01-21 14:53:44.000000000 -0500 +++ select.c 2006-01-21 14:46:26.000000000 -0500 @@ -34,6 +34,11 @@ Select *sqlite3SelectNew( ){ Select *pNew; pNew = sqliteMalloc( sizeof(*pNew) ); + if (pLimit != 0 && pOffset == 0) { + /* workaround for ticket #1634 */ + static const Token zero = { "0", 0, 1 }; + pOffset = sqlite3Expr(TK_INTEGER, 0, 0, &zero); + } assert( !pOffset || pLimit ); /* Can't have OFFSET without LIMIT. */ if( pNew==0 ){ sqlite3ExprListDelete(pEList); ---- _2006-Jan-21 20:41:56 by anonymous:_ {linebreak} When above patch was applied to sqlite-3.2.8, "make test" did not produce any new regressions and it correctly processed the queries mentioned in this ticket. ---- _2006-Jan-21 21:55:55 by drh:_ {linebreak} The problem appears to have been introduced in version 3.1.2 by check-in [2316] for ticket #1096. The root cause of the problem is that there is inadequate testing of the logic for deciding whether or not to flatten subqueries. #cfe8bd 1632 code fixed 2006 Jan anonymous VDBE 2006 Jan 3 3 sqlite3_result_error doesn't work in user defined aggregate function There is no way to cause error in user defined aggregate function. In xFinal, isError is ignored. In xStep, sqlite3_result_error causes core dump. Here is stack trace at sqlite3_result_error in xStep. #0 0x00000490 in ?? () #1 0x08064690 in sqlite3VdbeMemRelease (p=0xbffff394) at ../sqlite-3.2.8/src/vdbemem.c:227 #2 0x08064ab8 in sqlite3VdbeMemSetStr (pMem=0xbffff394, z=0x808f0ab "internal XXX error", n=-1, enc=1 '\001', xDel=0xffffffff) at ../sqlite-3.2.8/src/vdbemem.c:416 #3 0x080618d4 in sqlite3_result_error (pCtx=0xbffff38c, z=0x808f0ab "internal XXX error", n=-1) at ../sqlite-3.2.8/src/vdbeapi.c:96 #4 0x080530f6 in implodeStep (context=0xbffff38c, argc=1, argv=0x80a40e0) at ./func.c:1743 #5 0x080880e4 in sqlite3VdbeExec (p=0x80a1b88) at ../sqlite-3.2.8/src/vdbe.c:4250 #6 0x08061b14 in sqlite3_step (pStmt=0x80a1b88) at ../sqlite-3.2.8/src/vdbeapi.c:217 #c8c8c8 1631 code closed 2006 Jan anonymous 2006 Jan 2 3 Sqlite3 reports fdatasync type referenced symbol not found on Solaris Recently I built and installed SQLite 3.2.8 for our Trac 0.9.3 upgrade. I have started using !StarOffice 8 (Product Update 1) with unixODBC 2.2.11 to interface to SQLite 3.2.8. Unfortunately, although 3.2.7 "Now compiles on Solaris and OpenBSD and other Unix variants that lack the fdatasync() function" it doesn't appear to be cleanly worked around between applications. When adding a new table using the !StarOffice 8 design view, on saving the new table and modifying the database schema the response is the crash of the application and the following on the console: anthony@mayhem:/home/anthony>ld.so.1: soffice.bin: fatal: relocation error: file /opt/local/lib/libsqlite3.so.0: symbol fdatasync: referenced symbol not found Killed What can be done to work around this missing function more gracefully? _2006-Jan-19 04:45:49 by anonymous:_ {linebreak} I found that fdatasync is actually supported in Solaris. The build should use libposix4.so under Solaris 8/9 #ls -la /usr/lib | grep libposix4.so lrwxrwxrwx 1 root root 16 Nov 25 2003 libposix4.so -> ./libposix4.so.1* lrwxrwxrwx 1 root root 12 Nov 25 2003 libposix4.so.1 -> ./librt.so.1* #nm /usr/lib/libposix4.so |grep fdatasync [283] | 9712| 12|FUNC |GLOB |0 |9 |fdatasync [54] | 0| 0|FILE |LOCL |0 |ABS |fdatasync.c ---- _2006-Jan-23 00:27:36 by drh:_ {linebreak} See tickets #1604, #1580, #1548, #1545, #1467, and #1465. #cfe8bd 1630 code fixed 2006 Jan anonymous 2006 Jan drh 1 1 The TLS data is allocated/deallocated multiple times This becomes a serious problem. Before the fix of #1623 the thread data was allocated once and possibly destroyed once per thread life-time. Now this happens often. But it seems that sqlite does not expect that sqlite3ThreadData() may return a NULL pointer, which was acceptable before the fix of #1623. But now sqlite often allocates/deallocates the TLS data and under "Out-of-memory" conditions sqlite3ThreadData() may return a NULL pointer. In which case this code: void sqlite3_thread_cleanup(void){ ThreadData *pTd = sqlite3ThreadData(); memset(pTd, 0, sizeof(*pTd)); sqlite3ReleaseThreadData(); } crashes the application, if there is no allocated TLS block and sqlite3ThreadData() will try to allocate a new one but fails because there is not enough memory. #cfe8bd 1629 code fixed 2006 Jan anonymous 2006 Jan drh 1 1 The fix for #1623 causes an assert in sqlite3MallocAllow() The test code: (SQLITE_MEMDEBUG macro is defined and set to 1) sqlite3 *dbHandle = NULL; int rc = sqlite3_open("abc.db", &dbHandle); sqlite3_close(dbHandle); The asserting place is in util.c file: void sqlite3MallocAllow(){ assert( sqlite3ThreadData()->mallocDisallowed>0 ); sqlite3ThreadData()->mallocDisallowed--; } It happens because of the sequence in main.c file, sqlite3_close() function: sqliteFree(db); sqlite3MallocAllow(); sqlite3ReleaseThreadData(); return SQLITE_OK; sqliteFree(db) will free the TLS data (yes, it happens with the new changes applied in os_win.c file) The next call, sqlite3MallocAllow() will allocate a new TLS and of course assert on line: assert( sqlite3ThreadData()->mallocDisallowed>0 ); because this is a new TLS block and mallocDisallowed is 0. Thanks. Should be fixed now. #cfe8bd 1628 code fixed 2006 Jan anonymous 2006 Jan 4 4 pragma integrity_check returns "OK" on a corrupt database I have a corrupt database (the database is attached to this ticket) for which "pragma integrity_check" returns a number of errors followed by the string "OK". The database is actually corrupt so the string "OK" should not be there. _2006-Jan-18 13:42:26 by anonymous:_ {linebreak} There were two checkins, [2744] and [2746], that dealt with problems in this pragma. Does the problem still exist in 3.3.1 (the checkins wouldn't have made it into 3.2.8)? #f2dcdc 1627 warn active 2006 Jan anonymous 2006 Jan 4 4 warnings on BCB and how to resolve them + couple of minor fixes 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> }else if( (int)d1> }else if( (int)d2hdrOffset+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> assert( p2<(int)nField ); line 1967: if( avail>=payloadSize ){ ==>> if( avail>=(int)payloadSize ){ line 2019: if( !zRec && avail> if( !zRec && avail<(int)offset ){ line 2034: for(i=0; 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 on Borland. I suggest to add: #if (defined __BORLANDC__) # include #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> 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> 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 #f2dcdc 1626 new active 2006 Jan anonymous Unknown 2006 Jan 4 4 ALTER TABLE BUG/MISHEAVIOR 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:_ {linebreak} 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:_ {linebreak} ok, lets not do "intelligent" quoting. what about the quote format ? should it not be DOUBLE quotes, instead of single ? #cfe8bd 1625 warn fixed 2006 Jan anonymous Unknown 2006 Jan 3 3 Compiler errors in building Sqlite3 from source Running into problems with MetroWerks CodeWarrior C++ compiler in trying to port SQLIte 3 to an OS not currently supported as standard. 1) The name 'operator' is used twice as a member name in structures and the compiler is rejecting these instances as this is a reserved word... *: In 'where.c' in 'struct WhereTerm' (I changed to 'uOperator' to acheive a compile) *: In 'parse.c' in 'struct LikeOp' (I changed to 'tOperator' to achieve a compile) 2) The assumption was made in a header file that 'unsigned' is always 32 bits, despite have a length specific definition to use. Specifically in 'sqliteInt.h' in 'struct Token', the use of 'unsigned' had to be replaced with 'u32'. #c8c8c8 1624 code closed 2006 Jan anonymous 2006 Jan drh 1 1 OSMALLOC(int n) implementation does not allow OOM testing util.c, "static void * OSMALLOC(int n)" function. If the "Out of memory" condition is simulated at operating system level, without using the sqlite tools for that, OSMALLOC() asserts if the allocation fails: if( !failMalloc() ){ u32 *p; p = (u32 *)sqlite3OsMalloc(n + TESTALLOC_OVERHEAD); assert(p); sqlite3_nMalloc++; applyGuards(p); linkAlloc(p); return (void *)(&p[TESTALLOC_NGUARD + 2*sizeof(void *)/sizeof(u32)]); } This makes impossible the "Out of memory" testing. _2006-Jan-17 15:36:36 by danielk1977:_ {linebreak} Can you compile without the SQLITE_MEMDEBUG macro defined for the purposes of this OOM testing? This will get you around the problem in ticket #1618 too. #c8c8c8 1623 code closed 2006 Jan anonymous 2006 Jan drh 1 1 ThreadData instance never gets freed The test code is: (SQLITE_ENABLE_MEMORY_MANAGEMENT macro defined) sqlite3* dbHandle = NULL; int err = sqlite3_open16("c:\\a.db", &dbHandle); sqlite3_close(dbHandle); sqlite3_close() invokes sqlite3OsThreadSpecificData() with "-1" argument. But the memcmp() call returns non-zero value, because some ThreadData data members are not 0. For example: nMaxAlloc = 9140 mallocDisalloved = 1 zFile = "legacy.c" iLine = 71 Because memcmp() returns non-zero value, the code inside the "if" statement is never called and the tls block - never freed. #f2dcdc 1622 code active 2006 Jan danielk1977 2006 Jan 1 1 Compiling with OMIT_PRAGMA causes an error in the test suite 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". #f2dcdc 1621 code active 2006 Jan danielk1977 2006 Jan 5 5 Compiling with OMIT_FLOATING_POINT causes a segfault in the test suite Compiling with OMIT_FLOATING_POINT causes a segfault in the test suite. #c8c8c8 1620 todo closed 2006 Jan anonymous 2006 Jan 1 1 error database or disk is full Hello, here is another sqlite 3.3.1 disk full error. I am using a 2GB genotype database with approx 75 Million records and 4x 10-char-columns where I am trying to add another chunk of the same size with ".import FILE TABLE". Breaks after the same time used for importing the first chunk. I expected that under XP up to 100 GB should be possible. Previous suggestions at the mailing list do not work. I have - full read/write access rights - no autoincrement index - no problem with disk space (>10GB free) - no problem with memory (always >150 MB free) - no indication for any hardware failure according to sysinternal tools Thanks for all, Matthias _2006-Jan-17 17:02:54 by anonymous:_ {linebreak} solved - seemed that an FAT formatted partition prohibited adequate growth - maybe this could be added to the FAQ? #cfe8bd 1619 code fixed 2006 Jan anonymous 2006 Jan drh 1 1 Can't compile sqlite with SQLITE_ENABLE_MEMORY_MANAGEMENT Here is the list with the errors: ---------------------------------- Error : 'useMemoryManagement' is not a struct/ union/class member pager.c line 1721 Error : ';' expected pager.c line 1722 Error : undefined identifier 'pTsd' pager.c line 1723 Error : undefined identifier 'pTsd' pager.c line 1724 Error : declaration syntax error pager.c line 1727 Error : declaration syntax error pager.c line 1728 Error : 'useMemoryManagement' is not a struct/ union/class member pager.c line 2092 Error : ';' expected pager.c line 2093 Error : illegal assignment to constant pager.c line 2094 Error : declaration syntax error pager.c line 2095 Error : declaration syntax error pager.c line 2097 Error : declaration syntax error pager.c line 2098 Error : declaration syntax error pager.c line 2099 Error : declaration syntax error pager.c line 2100 Error : identifier 'sqlite3FreeX(void *)' redeclared pager.c line 2103 Error : was declared as: 'void (void *)' now declared as: 'int (...)' pager.c line 2103 Error : identifier expected pager.c line 2104 Error : identifier expected pager.c line 2105 Error : illegal function definition pager.c line 2110 Error : illegal function definition pager.c line 2111 Error : identifier expected pager.c line 2112 Error : identifier expected pager.c line 2113 Error : illegal function definition pager.c line 2124 Error : identifier expected pager.c line 2125 Error : identifier expected pager.c line 2127 Error : illegal function definition pager.c line 2128 Error : identifier expected pager.c line 2129 Error : ';' expected pager.c line 2130 Error : identifier expected pager.c line 2131 Error : ')' expected pager.c line 2132 Error : illegal function definition pager.c line 2133 Error : identifier expected pager.c line 2134 Error : undefined identifier 'pPg' pager.c line 2135 Error : declaration syntax error pager.c line 2137 Error : declaration syntax error pager.c line 2138 Error : declaration syntax error pager.c line 2139 Error : declaration syntax error pager.c line 2140 Error : declaration syntax error pager.c line 2141 Error : declaration syntax error pager.c line 2142 Error : declaration syntax error pager.c line 2143 Error : declaration syntax error pager.c line 2144 Error : identifier 'pager_refinfo(struct PgHdr *)' redeclared pager.c line 2145 Error : was declared as: 'void (struct PgHdr *)' now declared as: 'int (...)' pager.c line 2145 Error : identifier expected pager.c line 2146 Error : illegal function definition pager.c line 2148 Error : identifier expected pager.c line 2149 Error : illegal function definition pager.c line 2150 Error : identifier expected pager.c line 2151 Error : pointer/array required pager.c line 2152 Error : illegal implicit conversion from 'int' to 'struct PgHdr *' pager.c line 2153 Error : declaration syntax error pager.c line 2155 Error : Compile failed #c8c8c8 1618 code closed 2006 Jan anonymous 2006 Jan drh 1 1 Problematic ENTER_MALLOC() macro definition sqliteInt.h file, the macro definition is: #define ENTER_MALLOC (\ sqlite3ThreadData()->zFile = __FILE__, sqlite3ThreadData()->iLine = __LINE__ \ ) But if that's the first sqlite3ThreadData() call, the function will try to allocate a block of memory. If the allocation fails, sqlite3ThreadData() returns NULL and "NULL->File" will crash the application. _2006-Jan-16 14:35:48 by danielk1977:_ {linebreak} True statement. But the ENTER_MALLOC macro is only enabled when memory-debugging is turned on during testing. Under these circumstances we don't expect a "real" malloc() failure - just the ones that we engineer for testing purposes. #c8c8c8 1617 code closed 2006 Jan anonymous 2006 Jan drh 1 1 Memory allocation routines always return non-zero value os_common.h file, functions: ---------------------------- void *sqlite3GenericMalloc(int n){ char *p = (char *)malloc(n+8); assert(n>0); assert(sizeof(int)<=8); if( p ){ *(int *)p = n; } return (void *)(p + 8); } void *sqlite3GenericRealloc(void *p, int n){ char *p2 = ((char *)p - 8); assert(n>0); p2 = (char*)realloc(p2, n+8); if( p2 ){ *(int *)p2 = n; } return (void *)((char *)p2 + 8); } ---------------------------- It is obvious that even if the memory allocation fails these functions won't return 0! In this case they return 0x00000008 which makes impossible usual "if(!p)" testing for failed memory allocation. #cfe8bd 1616 warn fixed 2006 Jan anonymous 2006 Jan drh 2 2 RVCT compiler warnings when making sqlite build Here is the list with the RVCT warnings: ------------------------------------------- Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : ^ Warning : void sqlite3MallocClearFailed(); Warning : void sqlite3MallocClearFailed(); Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types alter.c line 1 Warning : ^ Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types attach.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types analyze.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types build.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1293-D: assignment in condition btree.c line 5267 Warning : #1293-D: assignment in condition unknown file line 1 Warning : ^ Warning : #1293-D: assignment in condition btree.c line 5268 Warning : (rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur)) || Warning : ^ Warning : #1293-D: assignment in condition btree.c line 5269 Warning : (rc = sqlite3pager_write(pPage->aData)) Warning : ^ Warning : #1293-D: assignment in condition btree.c line 4 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types auth.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types complete.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : ^ Warning : void sqlite3MallocClearFailed(); Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types callback.c line 1 Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types date.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types delete.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types func.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types expr.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types hash.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types insert.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types legacy.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types main.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types os.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types pager.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types parse.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types printf.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types prepare.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types pragma.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types table.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types select.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types random.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types tokenize.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types update.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types trigger.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types utf.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types vacuum.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1293-D: assignment in condition util.c line 554 Warning : while( !(p = OSMALLOC(n)) && sqlite3_release_memory(n) ); Warning : ^ Warning : #1293-D: assignment in condition util.c line 584 Warning : while( !(np = OSREALLOC(p, n)) && sqlite3_release_memory(n) ); Warning : ^ Warning : #1293-D: assignment in condition util.c line 737 Warning : if( db && (db->pErr || (db->pErr = sqlite3ValueNew()))!=0 ){ Warning : ^ Warning : #257-D: const variable "zeroData" requires an initializer util.c line 1327 Warning : static const ThreadData zeroData; Warning : ^ Warning : #257-D: const variable "zeroData" requires an initializer util.c line 5 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types vdbeapi.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types vdbeaux.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types vdbe.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types vdbefifo.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types vdbemem.c line 1 Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types sqliteInt.h line 1756 Warning : void sqlite3MallocClearFailed(); Warning : ^ Warning : #1295-D: Deprecated declaration sqlite3MallocClearFailed - give arg types where.c line 1 #cfe8bd 1615 warn fixed 2006 Jan anonymous 2006 Jan drh 2 2 Metrowerks CodeWarrior compiler errors when build sqlite Here is a list with the reported by CodeWarrior errors when making sqlite build: ------------------------------------------------------- Error : illegal implicit conversion from 'int *' to 'unsigned int *' btree.c line 3351 pCell += getVarint32(pCell, &dummy); Error : illegal implicit conversion from 'long long *' to 'unsigned long long *' btree.c line 3353 getVarint(pCell, &nCellKey); Error : illegal implicit conversion from 'const unsigned char *' to build.c line 1553 Error : 'const char *' build.c line 1553 p->addColOffset = 13 + sqlite3utf8CharLen(zName, pCons->z - zName); Error : illegal implicit conversion from 'int *' to 'unsigned int *' build.c line 2365 pIndex->aiRowEst = (int *)(&pIndex->aiColumn[nCol]); Error : illegal implicit conversion from 'const unsigned char *' to build.c line 3157 Error : 'const char *' build.c line 3157 char *z = sqliteStrNDup(pName1->z, pName1->n); Error : illegal implicit conversion from 'unsigned char[4]' to 'char *' pager.c line 458 put32bits(ac, val); Error : illegal implicit conversion from 'unsigned char *' to 'char *' pager.c line 469 put32bits(ac, val); Error : illegal implicit conversion from 'void *' to 'char *' os_common.h line 157 Error : illegal implicit conversion from 'char *' to 'unsigned char *' vdbe.c line 2025 Error : Compile failed Error : illegal implicit conversion from 'unsigned char *' to 'char *' vdbeaux.c line 445 Error : illegal implicit conversion from 'char *' to 'unsigned char *' vdbeaux.c line 447 _2006-Jan-16 15:33:22 by danielk1977:_ {linebreak} Check-in [2959] addresses at least some of these problems. Please advise if any remain. Thanks. #cfe8bd 1614 code fixed 2006 Jan anonymous 2006 Jan 2 2 sqlitedll-3_3_1.zip contain no DLL As the summary indicates, there is no DLL in the download. I dug a little deeper and tried compiling the DLL myself and incountered the following errors: sqlite3.exp:fake:(.edata+0xd8): undefined reference to `_sqlite3_enable_memory_management' sqlite3.exp:fake:(.edata+0x138): undefined reference to `_sqlite3_release_memory' sqlite3.exp:fake:(.edata+0x180): undefined reference to `_sqlite3_soft_heap_limit' By removing the following exports from the sqlite3.def file, the DLL compiled without any problems. I tried defining SQLITE_ENABLE_MEMORY_MANAGEMENT, on the compiler line to just encounter more problems: pager.c: In function `sqlite3pager_open': pager.c:1721: error: structure has no member named `useMemoryManagement' pager.c: In function `sqlite3pager_close': pager.c:2092: error: structure has no member named `useMemoryManagement' util.o:util.c:(.text+0x5): undefined reference to `_sqlite3pager_release_memory' Question: Should the DLL be compiled with 'memory management' by default? And if so, why does it still not compile if defined? _2006-Jan-16 02:31:05 by anonymous:_ {linebreak} When supplying the Windows DLL, could you consider applying the fix outlined in http://www.sqlite.org/cvstrac/tktview?tn=1474 $(TCC) -shared -o sqlite3.dll $(TOP)/sqlite3.def -Wl,"--strip-all" $(REAL_LIBOBJ) When "strip" is run as a seperate step from the link phase it produces a Windows DLL that is not relocatable and fails to work with Windows XP in some non-english locales. Or just don't strip the DLL at all - it works equally well. #c8c8c8 1613 new closed 2006 Jan anonymous 2006 Jan 4 4 "between" doesn't take advantage of indexes "x > min AND x < max" is the same speed as "x BETWEEN min AND max" normally, but considerably faster (impromptu benchmark says 5x) after indexing -- For now I'm using "less and greater" as I need the speed, but would like "between" to work as it looks nicer in context... _2006-Jan-15 17:16:12 by drh:_ {linebreak} Support for optimizing the BETWEEN operator was added to version 3.2.3. There are no plans to back-port these enhancements to the 2.x series. #c8c8c8 1612 code closed 2006 Jan anonymous 2006 Jan 1 3 "malformed database schema" when opening 3.2.8 database with SQLITE_OM Please compile the following code with SQLITE_OMIT_UTF16 defined. It opens a database file created with SQLite3 3.2.8 and fails when preparing the statement, returning "malformed database schema". There are no problems when SQLITE_OMIT_UTF16 is not defined. The database file in question is attached to this ticket. ---- #include #include "sqlite3.h" //--------------------------------------------------------------------------- sqlite3 *db = 0; void ExecSql (char *sql) { sqlite3_stmt *stmt; int rc; rc = sqlite3_prepare (db, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { printf(sqlite3_errmsg (db)); return; }; rc = sqlite3_step(stmt); while (rc == SQLITE_ROW){ printf("Data\n"); rc = sqlite3_step(stmt); } rc = sqlite3_finalize (stmt); if (rc != SQLITE_OK) printf("%d\n", rc); } //--------------------------------------------------------------------------- #pragma argsused int main(int argc, char* argv[]) { sqlite3_stmt *stmt; int rc; char * c; sqlite3_open("SQLite_328.db3", &db); ExecSql("SELECT * FROM Files;"); sqlite3_close(db); scanf ("*%c"); return 0; } _2006-Jan-15 14:27:08 by anonymous:_ {linebreak} It is a utf-16 database. The error message is not particularly good I suppose. ---- _2006-Jan-16 09:53:54 by anonymous:_ {linebreak} I was not (and still I am not) aware of the fact that there are UTF-16 and non-UTF-16 databases in SQLite. I was always under the impression that SQLITE_OMIT_UTF16 excludes only the interface to UTF-16. But even not using the UTF-16 interface, SQLite still stores all data UTF-8 internally IMO. So I don't see why there should be problems opening a database created without SQLITE_OMIT_UTF16 with an aplication compiled with SQLITE_OMIT_UTF16. I anyone can shed some light on this issue, please do so. ---- _2006-Jan-16 11:53:28 by anonymous:_ {linebreak} My sincere appologies for this ticket - it is not a bug. For anybody having the same problem, below follows a description of what I did wrong and how I changed it to the better. I created the attached database file with _sqlite3_open16_. My *error* was not to notice that _sqlite3_open16_ sets the database's encoding to UTF-16 by default, an important little detail which I generously overlooked in the documentation: _:"If the database file does not exist, then a new database will be created as needed. The encoding for the database will be UTF-8 if sqlite3_open() is called and UTF-16 if sqlite3_open16 is used." Obviously, SQLite3 can not read UTF-16 with support for UTF-16 excluded by SQLITE_OMIT_UTF16. As a *solution*, I change the database's encoding to UTF-8 with calling PRAGMA encoding = "UTF-8"; before creating any tables. It now opens perfectly even with SQLITE_OMIT_16 defined. #cfe8bd 1611 code fixed 2006 Jan anonymous 2006 Jan 4 3 sqlite3_close on wrong thread returns SQLITE_OK but leaks filehandle I just found that my code is leaking filehandles left and right, finally traced it back to sqlite3OsClose(). It's failing the CHECK_THREADID and returning the SQLITE_MISUSE code to tell me that I should be closing the database in the same thread I created it, but the return value is ignored all the way up the call chain to sqlite3_close(). I built with --enable-threadsafe. I think maybe I haven't seen this before because I disabled threadsafe previously and had forgotten that when I updated sqlite.. This is on OS X, FWIW. _2006-Jan-16 00:34:32 by anonymous:_ {linebreak} Better later than never: ( #1417 ){linebreak} and long life to happy open source contributions...{linebreak} http://www.sqlite.org/cvstrac/chngview?cn=2944 #c8c8c8 1610 code closed 2006 Jan anonymous 2006 Jan 1 2 SQLITE_OMIT_SUBQUERY can cause access violation The following code creates a scenario which, when compiled with SQLITE_OMIT_SUBQUERY, causes an access violation with Borland's C++ Builder. ---- #include #include "sqlite3.h" //--------------------------------------------------------------------------- sqlite3 *db = 0; void ExecSql (char *sql) { sqlite3_stmt *stmt; int rc; rc = sqlite3_prepare (db, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { printf(sqlite3_errmsg (db)); return; }; rc = sqlite3_step(stmt); while (rc == SQLITE_ROW){ printf("Data\n"); rc = sqlite3_step(stmt); } rc = sqlite3_finalize (stmt); if (rc != SQLITE_OK) printf("%d\n", rc); } #pragma argsused int main(int argc, char* argv[]) { sqlite3_stmt *stmt; int rc; /* Create a new, empty database. */ sqlite3_open("test.db3", &db); ExecSql ( "CREATE TABLE IF NOT EXISTS Files (" "ID integer primary key," "Name Text," "Parent Integer," "Type Integer," "Size Integer," "Time Double," "Attr Integer," "Desc Text," "Hash Integer);"); ExecSql ("CREATE INDEX IF NOT EXISTS Files_Parent_Type ON Files (Parent, Type);"); /* The following line creates an access violation in vdbemem.c, line 116: memcpy(z, pMem->z, n ); Cause: Write of address 000008. Apparently, pMem->z is NULL and has not been properly initialized. !!!! The problem only shows only if compiled with SQLITE_OMIT_SUBQUERY !!!! */ ExecSql ( "SELECT \"ID\" FROM \"Files\" WHERE \"Parent\"=? " "AND \"Type\" IN (0,1) ORDER BY \"Type\" DESC, \"Name\" COLLATE NOCASE;"); sqlite3_close(db); return 0; } Could this error have been caused by building part of the library with OMIT_SUBQUERY defined and part without? I would have expected all three statements to fail, because neither the EXISTS nor IN keywords are defined when OMIT_SUBQUERY is defined. The fix for this, and a few other things for OMIT_SUBQUERY mode is in [2943]. As a general rule, anyone using any of the SQLITE_OMIT_ compilation symbols should be running the test suite if at all possible. #c8c8c8 1609 code closed 2006 Jan anonymous Unknown 2006 Jan 2 3 ALTER TABLE ADD COLUMN failed if table name has multibyte character ALTER TABLE ADD COLUMN is failed if table name has multibyte character. $ sqlite3 SQLite version 3.2.8 Enter ".help" for instructions sqlite> create table "" (X); -- is GREEK ALPHA sqlite> alter table "" add column(Y); alter table "" add column Y text; SQL error: malformed database schema - near ",": syntax error In alter.c, nested SQL uses 'substr' and 'length' functions which count *characters*, but p->addColOffset is counted by *bytes* in build.c. #cfe8bd 1608 doc fixed 2006 Jan anonymous 2006 Jan 4 3 Yet undocumented: create table IF NOT EXISTS The new 3.3.0 feature "create table IF NOT EXISTS" is not yet documented. #cfe8bd 1607 code fixed 2006 Jan anonymous 2006 Jan 1 1 sqlite3_set_authorizer causes subsequent access violation After registering an authorizer callback function on an open database handle, the Windows DLL causes an access violation during the next sqlite3_prepare. No other database functions are issued between these two calls. The error is not present in 3.2.8. _2006-Jan-13 01:28:38 by drh:_ {linebreak} The regression test suite for SQLite attached 16 different authorizer functions and they all seem to work fine. Unable to reproduced based on available information. ---- _2006-Jan-13 13:00:25 by anonymous:_ {linebreak} The following code throws the access violation with Borland's C++ Builder: #include #include "sqlite3.h" //--------------------------------------------------------------------------- #pragma argsused int authorizer_callback (void* a,int b,const char* c,const char* d,const char* e,const char* f) { return SQLITE_OK; }; //--------------------------------------------------------------------------- char *sql = "SELECT name FROM " "(SELECT * FROM \"sqlite_master\" UNION ALL SELECT * FROM \"sqlite_temp_master\") " "WHERE \"type\"=\'table\' " "ORDER BY \"name\";" ; //--------------------------------------------------------------------------- #pragma argsused int main(int argc, char* argv[]) { sqlite3 *db = 0; sqlite3_stmt *stmt; int rc; /* Create a new, empty database. */ sqlite3_open("test.db3", &db); sqlite3_set_authorizer (db, authorizer_callback, NULL); /* The following call causes an access violation in auth.c, line 146: zDBase = db->aDb[iDb].zName; // <- Access violation here! With no authorizer callback, it executes gracefully. */ sqlite3_prepare (db, sql, -1, &stmt, 0); rc = sqlite3_step(stmt); while (rc == SQLITE_ROW){ printf("%s\n", sqlite3_column_text(stmt, 0)); rc = sqlite3_step(stmt); } sqlite3_finalize (stmt); sqlite3_close(db); return 0; } //--------------------------------------------------------------------------- #c8c8c8 1606 code closed 2006 Jan anonymous 2006 Jan 1 1 sqlite3_prepare16 broken Example: The following SQL PRAGMA table_info ("TableName"); compiles with UTF-16 sqlite3_prepare16, but calling sqlite3_step next returns SQLITE_DONE instead of SQLITE_ROW even though the table is present in the database. There seems to be no problems with ANSI sqlite3_prepare. _2006-Jan-13 01:25:20 by drh:_ {linebreak} Works fine when I try it. ---- _2006-Jan-13 02:20:16 by anonymous:_ {linebreak} This is a result of a code change in prepare16 between version 3.2.8 and the 3.3.0 alpha. 3.2.8 converted the utf16 to utf8 with this code:{linebreak} pTmp = sqlite3GetTransientValue(db);{linebreak} sqlite3ValueSetStr(pTmp, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);{linebreak} zSql8 = sqlite3ValueText(pTmp, SQLITE_UTF8);{linebreak} {linebreak} 3.3.0 uses:{linebreak} zSql8 = sqlite3utf16to8(zSql, nBytes);{linebreak} {linebreak} The problem is that many people are/were passing the length of the UTF16 string in characters instead of bytes. It worked (even if it was wrong) in previous versions, but now it doesn't. ---- _2006-Jan-13 09:40:51 by anonymous:_ {linebreak} Thanks for pointing out the important difference between characters and bytes in UTF-16 mode! I was indeed one of those who passed the wrong length, and it always worked because previous versions apparently payed no attention to the length parameter. I remember that this subject came up on the mailing list some time ago. Fortunately, this appears to be fixed with 3.3.0. Looking forward to adapting my code ... #cfe8bd 1605 code fixed 2006 Jan drh VDBE 2006 Jan 1 1 Assertion fault when trying to LIKE a BLOB in UTF-16 mode. The following SQL generates an assertion fault: PRAGMA encoding=utf16; CREATE TABLE t1(a); INSERT INTO t1 VALUES(x'6100620063006400'); SELECT * FROM t1 WHERE a LIKE 'ab%'; #cfe8bd 1604 build fixed 2006 Jan anonymous 2006 Jan 4 3 opcode generation fails on solaris 8 due to ancient awk This is related to bugs 1075, 1161, 1372 and probably others. The crappy default awk on Solaris 8 still has problems with your opcode generation script, despite the substitution of sub() for gsub(). Rather than tweaking the script, I'd suggest changing the Makefile to use /usr/xpg4/bin/awk on Solaris machines, which works fine. Or does this fall into the "not maintaining the autoconf stuff, just fix the makefile yourself" category? :-) _2006-Jan-11 23:48:19 by drh:_ {linebreak} How about just: export PATH=/usr/xpg4/bin:$PATH before you run make? ---- _2006-Jan-12 15:59:47 by anonymous:_ {linebreak} Sure, that works, and that's what I did. But I did that after a) being able to see that the problem was the awk script, and b) searching the bug system to find out that others had run into a similar problem, which claimed to be fixed (the gsub() vs. sub() issue). So even though my problem wasn't the same, I tried the xpg4 version, and it worked. I don't see why the makefile (or configure) can't detect that it's running on Solaris, and modify the path itself. Or even just always add /usr/xpg4/bin; adding a non-existent directory to the PATH should be a NOOP for non-solaris systems. Or even just a note in the README would be useful. ---- _2006-Jan-12 16:59:47 by drh:_ {linebreak} Can you suggest a patch? ---- _2006-Jan-14 00:50:08 by anonymous:_ {linebreak} Yes, I'll do a patch. It turns out that there's a library problem on Solaris 8 also; it needs -lrt to get fdatasync. Also need to test on AIX. Should I submit via this ticket, is the mailling list a better place? ---- _2006-Jan-14 02:32:03 by drh:_ {linebreak} There is an "[Attach]" button on this page. Click it and upload the file to there. There is a 100KiB size limit, but surely you patch will fit in that amount of space.... ---- _2006-Jan-18 21:12:04 by anonymous:_ {linebreak} I've attached two patches, as described. The patches were tested on Solaris 8, AIX 5.1, and Debian Linux "sarge". I doubt the patch is substantial enough to merit copyright, but just in case: I, Steve Greenland (steveg@lsli.com), hereby assign copyright for these patches to D. Richard Hipp. Share and enjoy. #cfe8bd 1603 code fixed 2006 Jan anonymous 2006 Jan 5 5 better customization of macro N_GUARD in utils.c In utils.c the #define N_GUARD 2 could be #ifndef N_GUARD # define N_GUARD 2 #endif #c8c8c8 1602 code closed 2006 Jan anonymous 2006 Jan 4 5 likely typo in shell.c shell.c, line 834, function resolve_backslashes(): The statement c =- '0'; should be perhaps c -= '0'; Duplicate of #1575. Already fixed. #cfe8bd 1601 code fixed 2006 Jan anonymous Unknown 2006 Jan anonymous 1 2 3.3.0 multithreaded apps memory leak In os_win.c function sqlite3WinThreadSpecificData line 1178, the memory allocated by pTsd = sqlite3OsMalloc(nByte) is never freed. Therefore in multithreaded apps, this memory leak is accumulative. BTW, in this function pTsd does not need to be static. Also (not related to this), if one wants to use a custom function like the legacy.c and using the dll provided, there is no way of calling (nor simulate) the code (since called functions are not public): if( sqlite3ThreadData()->mallocFailed ){ rc = SQLITE_NOMEM; sqlite3MallocClearFailed(); } SQLite should now automatically deallocate the TLS when it is no longer being used. If in doubt, there you can also call the new sqlite3_thread_cleanup() API to make absolutely sure that the TLS has been deallocated. But that should be redundant. #cfe8bd 1600 new fixed 2006 Jan anonymous 2006 Jan 5 4 WinCE locking implementation Attached is a patch for os_win.c to implement file locking on Windows CE platforms that lack LockFile/UnlockFile/LockFileEx functionality. The potential problems brought up on the list have been addressed, and the code should have minimal impact on the file size. #c8c8c8 1599 doc closed 2006 Jan anonymous 2006 Jan 5 5 Typo in FAQ not quite fixed [2912] changed "leter let you puts," which had two typos, into "later let you puts" which has only one :) #e8e8bd 1598 code review 2006 Jan anonymous 2006 Jan 3 2 Incorrect case-insensitive comparison of non-latin UTF-8 characters Sqlite incorrectly compares case-insensitivly UTF-8 non-latin characters. I created a patch that fixes this problem and posted it to the mailing list. I wonder if someone could review my patch and eventually include it in the main project. Regards Stanislav Nikolov _2006-Jan-10 22:49:08 by drh:_ {linebreak} The sqlite3_create_collation() and sqlite3_create_function() APIs exists for the purpose of allowing users to define comparisons and any other operations in any way they see fit. There is no need to make changes to the SQLite core to accomodate cyrillic comparisons. Indeed, there are good reasons not to, namely if we correctly compare cyrillic, we should also need to correctly compare chinese, japanese, and korean to name but a few. Very quickly the comparison functions can grow to be many many times larger than the rest of SQLite. We conclude, therefore, that this is all best left to the discretion of the programmer who uses SQLite in their project. Hence we provide the afore mentioned sqlite3_create_collation() and sqlite3_create_function() APIs. ---- _2006-Jan-11 00:24:50 by anonymous:_ {linebreak} Okay, let me try that again. First, the patch I created does not correspond only to Cyrillic letters, but also to the Greek and the accented characters up to U+044F. According to UNICODE.ORG there are actually five alphabets in the world (of which one does not use cases anymore) that have different cases: (from http://www.unicode.org/reports/tr21/tr21-5.html#Introduction) Case is a normative property of characters in specific alphabets (Latin, Greek, Cyrillic, Armenian, and archaic Georgian) whereby characters are considered to be variants of a single letter. These variants, which may differ markedly in shape and size, are called the uppercase letter (also known as capital or majuscule) and the lower­case letter (also known as small or minuscule). The uppercase letter is generally larger than the lowercase letter. Alphabets with case differences are called bicameral; those without are called unicameral. Therefore, I don't think someone will need support for case-insensitive comparison for Japanese, Chinese or Korean characters and I guess that adding support for the remaining Armenian alphabet is a matter of minutes and will not add up to the complexity of the code. Of course, perhaps it is possible for every project and/or developer to design their own "collation schemes" but I don't find it very practical. I can't really see the reason behind rejecting the patch. Perhaps you could actually look at it ? Regards, Stanislav Nikolov ---- _2006-Jan-11 00:33:19 by drh:_ {linebreak} Please attach the patch to this ticket. ---- _2006-Jan-11 00:52:38 by drh:_ {linebreak} OK, I was able to reconstruct the patch from the mailing list. I observer that as written it increases the size of the SQLite library by a little over 4KiB. That might not seem like much, but embedded device manufacturers (that is to say, most of my paying customers) are _very_ sensitive to this kind of library size growth. I will look into reducing the size somewhat and getting it into a future release as a compile-time option. ---- _2006-Jan-11 03:10:09 by drh:_ {linebreak} Based on what I can glean from http://www.unicode.org/Public/UNIDATA/CaseFolding.txt, the case folding table in the patch seems to be incomplete. A full unicode case folding table would need to be much larger. Perhaps somebody with more experience in unicode case folding can comment. ---- _2006-Jan-11 09:52:38 by anonymous:_ {linebreak} I think that the size of the library could be effectivly shrunk if we don't use an array, because over 50% of the information is redundant. I think that the same effect could be achieved by changing sqlite3UpperToLower[] to a function, and in there to check for the ranges of the capital letters (that is, we need to check for 4-5 different regions and return x+20 ort x+1 for capital letters for example). I can try do that? ---- _2006-Jun-08 10:32:06 by anonymous:_ {linebreak} Has anybody worked on this lately? This is quite an issue if you happen to use non-latin chars. Keep up the good work. Anze ---- _2006-Oct-11 10:58:15 by anonymous:_ {linebreak} could you tell me how to run the patch for WindowXP? Thanks a lot. #cfe8bd 1596 doc fixed 2006 Jan anonymous 2006 Jan 5 5 obsolete MakeIdxKey opcode references in vdbe.c and documentation Please replace the obsolete opcode MakeIdxKey with MakeRecord in vdbe.c and documentation. Or is it supposed to be MakeIdxRec? _2006-Jan-10 19:06:10 by anonymous:_ {linebreak} Is this comment correct considering the usage of the opcode below? Or should it read "The top of the stack holds a SQL index key made using the MakeRecord instruction."? vdbe.c: /* Opcode: IdxInsert P1 * * ** ** The top of the stack holds a SQL index key made using the ** MakeIdxRec instruction. This opcode writes that key into the ** index P1. Data for the entry is nil. select.c: 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); ... sqlite3VdbeAddOp(v, OP_MakeRecord, -N, 0); sqlite3VdbeAddOp(v, OP_Distinct, iTab, sqlite3VdbeCurrentAddr(v)+3); sqlite3VdbeAddOp(v, OP_Pop, K, 0); sqlite3VdbeAddOp(v, OP_Goto, 0, addrRepeat); VdbeComment((v, "# skip indistinct records")); sqlite3VdbeAddOp(v, OP_IdxInsert, iTab, 0); ... case SRT_Union: { sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, NULL_ALWAYS_DISTINCT); if( aff ){ sqlite3VdbeChangeP3(v, -1, aff, P3_STATIC); } sqlite3VdbeAddOp(v, OP_IdxInsert, iParm, 0); break; ... aff = sqlite3CompareAffinity(pEList->a[0].pExpr, aff); sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &aff, 1); sqlite3VdbeAddOp(v, OP_IdxInsert, (iParm&0x0000FFFF), 0); ...etc #c8c8c8 1595 doc closed 2006 Jan anonymous 2006 Jan 4 1 tcl-devel is required to build. This requirement is not listed tcl-devel is an unlisted prerequisite _2006-Jan-10 17:33:29 by drh:_ {linebreak} TCL is required to build the TCL langauge bindings and to run the regression tests. It is *not* required to build the SQLite library. #c8c8c8 1594 code closed 2006 Jan anonymous BTree 2006 Jan danielk1977 2 2 Schema pointer is freed twice Introduced in checkin #2859 ? btree.c @@ -1556,6 +1719,9 @@ /* Close the pager and free the shared-btree structure */ assert( !pBt->pCursor ); sqlite3pager_close(pBt->pPager); + if( pBt->xFreeSchema && pBt->pSchema ){ + pBt->xFreeSchema(pBt->pSchema); + } During sqlite3_close() the above function is called which frees the schema. Afterwards, in build.c, sqlite3ResetInternalSchema() is called which attempts to free the same schema pointer again. The pointers inside are often no longer valid so it results in a fault. #cfe8bd 1593 code fixed 2006 Jan anonymous BTree 2006 Jan drh 1 2 error compiling with #define SQLITE_OMIT_AUTOVACUUM last CVS checkout doesn't compile with SQLITE_OMIT_AUTOVACUUM defined because it relies on iDb member that was removed from Index structure. Changing the code in function destroyTable() at build.c seems to be working...
 #ifdef SQLITE_OMIT_AUTOVACUUM   Index *pIdx;   int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);   destroyRootPage(pParse, pTab->tnum, iDb);   for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){     destroyRootPage(pParse, pIdx->tnum, iDb);   } #else 
#f2dcdc 1591 build active 2006 Jan anonymous 2006 Jan 3 2 Missing TEXE suffix in linking and install rules for sqlite3 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{linebreak} $(LTINSTALL) sqlite3$(TEXE) $(DESTDIR)$(exec_prefix)/bin{linebreak} instead of{linebreak} $(LTINSTALL) sqlite3 $(DESTDIR)$(exec_prefix)/bin{linebreak} 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). #cfe8bd 1590 code fixed 2006 Jan anonymous 2006 Jan drh 4 2 select.c uninitialized variable The variable "addr" in line 390 of select.c is used without being initialized. Introduced in checkin #2889 #cfe8bd 1589 doc fixed 2006 Jan anonymous 2006 Jan 4 4 Has the SQLite website's "Append Remarks" behavior changed? I'm trying to append remarks to a (closed) ticket, but I get these choices when I click on "Append Remarks" within a ticket viewing page: Ticket Create a new Ticket with a defect report or enhancement request. Browse Browse the CVS repository tree. Reports View summary reports of Tickets. Timeline View a chronology of Check-Ins and Ticket changes. Wiki View the Wiki documentation pages. Search Search for keywords in Tickets, Check-ins, Wiki pages, and/or Filenames Login Log in. Which option do I select to append remarks to a ticket? I don't recall seeing this screen before. _2006-Jan-08 19:18:55 by anonymous:_ {linebreak} That's a bug. See http://www.cvstrac.org/cvstrac/tktview?tn=541 The upper "Append Remarks" link works correctly. #f2dcdc 1588 new active 2006 Jan anonymous 2006 Jan 4 4 common subexpression elimination not performed in SELECT 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:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 1587 code fixed 2006 Jan anonymous Unknown 2006 Jan 3 3 Timezone is parsed reversely Timezone option in date-time string is parsed reversely at line 239 of date.c. {linebreak} According to ISO 8601, '2004-04-01T12:00:00-05:00' must be parsed as '2004-04-01T17:00:00 UTC'. #cfe8bd 1586 new fixed 2006 Jan anonymous 2006 Jan 2 3 ORDER BY with LIMIT clause is sub-optimal in speed and memory usage SELECTs with an ORDER BY and a LIMIT clause on very large tables/views with millions of rows are sub-optimal in both speed and memory usage. For example: CREATE TABLE t1(a,b,c); INSERT INTO "t1" VALUES(4, 5, 6); INSERT INTO "t1" VALUES(9, 12, 10); INSERT INTO "t1" VALUES(900, -23.4, 8900); INSERT INTO "t1" VALUES(190, 3, -8.9003); INSERT INTO "t1" VALUES(400, 450, 550); INSERT INTO "t1" VALUES(5400, 1450, 3445); INSERT INTO "t1" VALUES(321, 345, -0.0342); INSERT INTO "t1" VALUES(34, 8888, 2382344); INSERT INTO "t1" VALUES(-900000.0, -3478000.0, 10); INSERT INTO "t1" VALUES(999, 888, 777); INSERT INTO "t1" VALUES(9, -888, 7.77); CREATE VIEW View1 as select (aa.a*bb.b-cc.c+dd.a*ee.b-ff.c*gg.a) as V from t1 aa, t1 bb, t1 cc, t1 dd, t1 ee, t1 ff, t1 gg; The following query will take a great deal of time, exhaust all memory on my machine (several hundred Megs) and crash: select V from View1 order by V LIMIT 5; Patch with fix will be uploaded shortly. _2006-Jan-08 06:26:18 by anonymous:_ {linebreak} I had an initial fix that looked much like Check-in [2887] but I thought that the extra four or five opcodes in the inner loop in pushOntoSorter was less efficient than changing OP_IdxInsert for this very common operation. Be aware that when adding LIMIT+OFFSET blindly together for the count you get different behavior in odd-ball cases like this: CREATE TABLE abc(a); INSERT INTO "abc" VALUES(11); INSERT INTO "abc" VALUES(33); INSERT INTO "abc" VALUES(22); INSERT INTO "abc" VALUES(57); INSERT INTO "abc" VALUES(-9); -- should return 57, -9 select * from abc order by a=a limit -1 offset 3; -- should return 11, 33, 22, 57 select * from abc order by a=a limit 4 offset -10; -- should return 11, 33, 22, 57 select * from abc order by a=a limit 4 offset -2; The suggested patch set the OFFSET memory register value to zero if it was negative before adding it to the LIMIT for this reason. Also, if LIMIT < 0, you should not add OFFSET to it, since you want all the rows kept. Such negative LIMIT/OFFSET silliness probably should be undefined, but the suggested patch had logic to preserve the old SQLite behavior. #cfe8bd 1585 code fixed 2006 Jan anonymous 2006 Jan 1 1 Global mutex not released if pthread_key_create fails. Correct me if I'm wrong, but if the call to pthread_key_create fails SQLite's global mutex is not released in sqlite3UnixThreadSpecificData. This regression was introduced in [2818]. I've included a patch, against the latest cvs revision, which should correct this issue. Index: os_unix.c =================================================================== RCS file: /sqlite/sqlite/src/os_unix.c,v retrieving revision 1.77 diff -u -w -r1.77 os_unix.c --- os_unix.c 6 Jan 2006 21:52:50 -0000 1.77 +++ os_unix.c 6 Jan 2006 23:40:59 -0000 @@ -1678,6 +1678,7 @@ int rc; rc = pthread_key_create(&key, deleteTsd); if( rc ){ + sqlite3OsLeaveMutex(); return 0; } keyInit = 1; #cfe8bd 1584 code fixed 2006 Jan anonymous Unknown 2006 Jan 1 5 Solaris 8: bus error when /dev/urandom is not readable We had an Solaris 8 installation with access rights for /dev/urandom as 0600. By calling sqlite3 as normal user to create a new database we got a bus error (sqlite3 was compiled using gcc 4.0.2). The following patch solve the problem on our systems: --- src/os_unix.c.orig 2006-01-05 09:41:41.629961000 +0100 +++ src/os_unix.c 2006-01-05 12:07:05.045764000 +0100 @@ -1369,7 +1369,8 @@ int pid, fd; fd = open("/dev/urandom", O_RDONLY); if( fd<0 ){ - time((time_t*)zBuf); + time_t tTime=time(NULL); + memcpy(zBuf, &tTime, sizeof(tTime) ); pid = getpid(); memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid)); }else{ #c8c8c8 1582 code closed 2006 Jan anonymous Shell 2006 Jan anonymous 1 1 the sqlite328.exe generates Application error -memory cold not be read both DLL (sqlite3_exec())and EXE generates application error "memory cold not be read" (the type of error for the dll depends on the compiler) in case of wrong query (a missed table is used). scenario:(under WIN XP) the database contains: CREATE TABLE logs(msg TEXT, timestamp INTEGER, dbtime TEXT); and when i apply: SELECT * FROM logs WHERE logs.id >= (SELECT head FROM logs_base) UNION ALL SELECT * FROM logs LIMIT (SELECT lmt FROM logs_base) ; (the table "logs_base" is omit) ... the application error is generated (instead of warning for the shell and errorcode for DLL). #c8c8c8 1581 code closed 2006 Jan anonymous 2006 Jan 4 3 incompatible pointer types lead to compilation errors When compiling SqLite 3.2.8 on MacOSX using CodeWarrior 9.x a couple of files cannot be compiled because of implicit pointer conversions Example: file alter.c line 445 sqlite3StrNDup_ is defined as: char *sqlite3StrNDup_(const char*, int,char*,int); But in alter.c line 445 pColDef->z is used as the first argument which is not a const char*. Hartwig _2006-Jan-04 23:50:58 by drh:_ {linebreak} That would be a bug in CodeWarrior, not in SQLite. In ANSI C, a function that takes const char* should also be able to accept a char* argument. Going the other way is a problem: A function that takes char* should not be able to accept a const char* argument. But the way that SQLite is doing it here is correct. #c8c8c8 1580 code closed 2006 Jan anonymous 2006 Jan 4 2 3.2.8 does not compile under Solaris 10 After running ./configure --enable-threadsafe make in the base directory, compilation stops and complains of the unresolved symbol fdatasync. Looking at the man page for fdatasync(), it seems like -lrt is needed as an extra library for fdatasync() to be available. Adding -lrt to the list of libraries to link agains solves the problem. _2006-Jan-04 12:28:26 by drh:_ {linebreak} Duplicate of #1467. Already fixed. #c8c8c8 1579 code closed 2006 Jan anonymous Shell 2006 Jan anonymous 1 1 database locked I'm using JSP to connect sqlite and it works fine.but in the middle the database gets locked.Can you tell me at what instances the database gets locked. _2006-Jan-02 12:47:42 by drh:_ {linebreak} That would be a question for the mailing list. Tickets are for reporting bugs. #cfe8bd 1572 code fixed 2005 Dec anonymous Parser 2006 Jan 2 1 Null Mallocation Hello, There is a little problem in a call to sqliteMalloc in sqlite3_exec (legacy.c:71){linebreak} Here is the *bad* line : {linebreak} {quote: azCols = sqliteMalloc(2*nCol*sizeof(const char *));}{linebreak} Here is the *corrected* line :{linebreak} {quote: azCols = sqliteMalloc((nCol ? 2*nCol : 1)*sizeof(const char *));} {linebreak} ---- _:And here is a short explanation of the problem : when you call a malloc of 0, it *may* say not enough memory, despite you have. And it *may* return you a null pointer in some weird implementation of malloc. Furthermore, some tools like libefence or valgrind will stop to this point. I've found this with libefence, for example. and there is plenty of exec call without columns. BEGIN; and END; statement, for instance. It's a major defect since it can cause very very strange behaviour. #cfe8bd 1554 code fixed 2005 Dec anonymous Parser 2006 Jan 3 3 sqlite3_prepare ignores nBytes parameter sqlite3_prepare (and sqlite3_prepare16) take as 3rd argument the number of bytes in the sql source string to use as a parameter named _nBytes_. According to the {link: http://sqlite.org/capi3ref.html#sqlite3_prepare documentation}: _: _If the next argument, "nBytes", is less than zero, then zSql is read up to the first nul terminator. If "nBytes" is not less than zero, then it is the length of the string zSql in bytes (not characters)._ However, according to the source in {link: http://www.sqlite.org/cvstrac/rlog?f=sqlite/src/prepare.c prepare.c} ({link: http://www.sqlite.org/cvstrac/getfile/sqlite/src/prepare.c?v=1.4 rev 1.4}), this parameter is completely ignored. I don't know whether this parameters was only used historically (in which case the documentation needs to be updated) or whether it should be honored, but isn't (in which case the code needs to be fixed). #cfe8bd 1524 code fixed 2005 Nov anonymous Pager 2006 Jan 2 3 Crash when using pragma auto_vacuum with :memory: database Open an in-memory database using sqlite3_open(":memory:"). Then execute "PRAGMA auto_vacuum=true;" on that database. (Yes, I know it's goofy. I did it by mistake, but wound up spending an hour debugging the problem.) On the first attempt to access the database, SQLite crashes at line 2527 of sqlite3pager_get (on the call to sqlite3OsRead). If you compile with SQLITE3_DEBUG enabled, you fail the assert( MEMDB==0 ) a few lines earlier. #cfe8bd 1486 code fixed 2005 Oct anonymous 2006 Jan 4 3 schema which is stored in sqlite_master was not complete when I execute the sql {linebreak} "CREATE Unique INDEX index4 On Test3 ('A') on conflict ignore"{linebreak} .It was executed correctly. Then I query the schema in sqlite_master{linebreak} I found that the schema was CREATE Unique INDEX index4 On Test3 ('A'), the conflict algorithm part in create sql was disappeared. {linebreak} whether it is a bug or not? #cfe8bd 1479 code fixed 2005 Oct anonymous Unknown 2006 Jan 1 3 SQLITE_ALTER_TABLE not authorized for "alter table ... add ...;" When executing a "ALTER TABLE TableName ADD ColumName;" command, the authorizer callback function is not called with the SQLITE_ALTER_TABLE parameter as Arg2. The SQLITE_ALTER_TABLE is, however, called for the "ALTER TABLE OldTableName RENAME TO NewTableName;" command. My view is that it should be called for both ALTER TABLE commands. Otherwise customer might be unintendedly allowed to add columns to existing databases. #cfe8bd 1467 build fixed 2005 Oct anonymous 2006 Jan 1 1 3.2.7 on Solaris still chokes on fdatasync 3.2.7 changes: Now compiles on Solaris and OpenBSD and other Unix variants that lack the fdatasync() function However, the 3.2.7 configure generated Makefile breaks:
  gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I../src -DNDEBUG -DTHREADSAFE=0 -DSQ LITE_OMIT_CURSOR -DHAVE_READLINE=0 -o .libs/sqlite3 ../src/shell.c  ./.libs/libs qlite3.so -lcurses -R/usr/local/lib Undefined                       first referenced  symbol                             in file fdatasync                           ./.libs/libsqlite3.so ld: fatal: Symbol referencing errors. No output written to .libs/sqlite3 collect2: ld returned 1 exit status *** Error code 1 make: Fatal error: Command failed for target `sqlite3' 
_2005-Oct-06 06:43:06 by anonymous:_ {linebreak} Solaris 8/9/10 have the fdatasync function in librt library. The function prototipe is in unistd.h. Linking with -lrt the linker error goes away. ---- _2006-Jan-10 11:54:55 by anonymous:_ {linebreak} Still broken in 3.2.8. ---- _2006-Jan-10 12:13:07 by drh:_ {linebreak} Version 3.2.8 does not contain check-in [2741]. The problem has been fixed in CVS HEAD. #cfe8bd 1399 new fixed 2005 Aug anonymous 2006 Jan 4 4 Please add "DROP IF EXISTS" support Hi! Just voting for DROP table IF EXISTS. It's mighty useful when you've got your schema stored in a file and you keep killing and regenerating the database. I'm doing this a whole lot during early development of a Ruby on Rails webapp. It'd be nice if sqlite didn't whine about the table not existing when I just drop it unconditionally. Thanks! #f2dcdc 867 new active 2004 Aug anonymous Parser 2006 Jan 3 2 update on multiple tables 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:_ {linebreak} I would prefer another syntax - using a SELECT as the source for data to be updated. UPDATE SET =... WHERE = ... SELECT FROM WHERE =... 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:_ {linebreak} 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 #c8c8c8 679 code closed 2004 Mar anonymous Unknown 2006 Jan a.rottmann 2 1 database closed i am using sqlite with delphi7 and it was great untill i got a errore database locked when i try to do insert. i cant unlock it and if i change the database to a new one i get the same error . the progrem i am making is for a stand alone one computer one database no multi user. _2004-Mar-31 15:01:43 by drh:_ {linebreak} The error report does not describe how to reproduce the problem. It does not specify the SQLite version number. No contact information is provided. From the quality of the error report, one may infer that the problem is a result of a user error. Insufficient data is available for further analysis. #f2dcdc 1902 new active 2006 Jul anonymous Parser 2006 Jul 5 3 allow alternate INSERT syntax using SET foo=bar 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 #f2dcdc 1901 code active 2006 Jul anonymous Unknown 2006 Jul adamd 2 2 problem in select request with a alias table 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:_ {linebreak} 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:_ {linebreak} I had a similar problem with SQLite in PHP, see my bug report here: http://bugs.php.net/bug.php?id=40064 #f2dcdc 1900 code active 2006 Jul anonymous Unknown 2006 Jul a.rottmann 1 1 CURRENT_TIMESTAMP keyword not inserting UTC date in column 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:_ {linebreak} *doesnt get a UTC timestap ---- _2006-Jul-31 00:38:49 by anonymous:_ {linebreak} Works fine for me. What's the exact syntax of your INSERT statement? #f2dcdc 1898 doc active 2006 Jul anonymous 2006 Jul 5 4 sqlite3_progress_handler still marked experimental in documentation 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... #f2dcdc 1896 new active 2006 Jul drh 2006 Jul 1 1 All extensions to be statically linked 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 1895 doc active 2006 Jul anonymous 2006 Jul anonymous 4 3 IS operator not documented 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:_ {linebreak} 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. #c8c8c8 1894 event closed 2006 Jul anonymous Unknown 2006 Jul 4 3 "library routine called out of sequence" when using progress (TCL) If one use progress to register a callback and that callback themselves contain a sqlite-command, a "library routine called out of sequence"-error occur. Example-code (tclsh): load tclsqlite3.dll sqlite3 db "" proc test {} {db eval "SELECT count(*) FROM sqlite_master"} db progress 1 {test} db eval "CREATE TABLE test(v1 text)" _2006-Jul-19 18:26:58 by anonymous:_ {linebreak} A similar problem was reported for version 3.3.5 and has now (3.3.6) been fixed (ticket #1827). #cfe8bd 1892 code fixed 2006 Jul anonymous Parser 2006 Jul 4 5 Degenerate code action causes parser crash. This is really not a big deal, but if you specify an empty code action for a rule, it crashes the parser. (Adding a space between the braces fixes the problem). Tested: linux PPC and x86 I think the code at the end of translate_code() doesn't expect a NULL ptr. Adam
 --- file funky.lemon --- program ::= STMT. {} --- end file ---  command: ./lemon funky.lemon Segmentation fault  Here's a stack trace: Program received signal SIGSEGV, Segmentation fault. 0x1000d9d4 in strhash (x=0x0) at lemon.c:4124 4124      while( *x) h = h*13 + *(x++); (gdb) bt #0  0x1000d9d4 in strhash (x=0x0) at lemon.c:4124 #1  0x1000e078 in Strsafe_find (key=0x0) at lemon.c:4255 #2  0x1000da50 in Strsafe (y=0x0) at lemon.c:4137 #3  0x1000a508 in translate_code (lemp=0x7ffff9d8, rp=0x100297b8)     at lemon.c:3272 #4  0x1000cd6c in ReportTable (lemp=0x7ffff9d8, mhflag=0) at lemon.c:3852 #5  0x10004110 in main (argc=2, argv=0x7ffffaf4) at lemon.c:1507 #6  0x0febc04c in __libc_start_main (argc=2, ubp_av=0x7ffffaf4, ubp_ev=0x0,     auxvec=0x7ffffb60, rtld_fini=0, stinfo=0x10010088,     stack_on_entry=0x10009374) at ../sysdeps/powerpc/elf/libc-start.c:178 
#c8c8c8 1891 code closed 2006 Jul anonymous Shell 2006 Jul pweilbacher 4 4 OS/2 may not have access to C:\ drive OS/2 can be installed/booted from non-C:\ partitions. Assuming all attempts to set home_dir fail and C:\ isn't accessible (a Windows partition, for example) the code fragment: -#if defined(_WIN32) || defined(WIN32) || defined(__OS2__) if (!home_dir) { home_dir = "c:"; } would fail. _2006-Jul-17 00:14:09 by drh:_ {linebreak} The solution is to set the HOME environment variable, I think. The supplied patch seems wrong in a number of ways. For one, it uses "c%" rather than "%c" inside an sprintf(). And for another, the first argument to the same sprintf() appears to be a NULL pointer. ---- _2006-Jul-25 13:19:32 by anonymous:_ {linebreak} Same problem applies to Windows NT series OS (NT/2000/XP/...). #f2dcdc 1890 code active 2006 Jul anonymous Unknown 2006 Jul 3 4 double quotes ("") in a query are ambiguous sqlite> SELECT "uuid" FROM objects LIMIT 1;{linebreak} b43c9cdc-0dc8-11db-9475-080020a846a9{linebreak} sqlite> SELECT "uuidx" FROM objects LIMIT 1;{linebreak} uuidx{linebreak} 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:_ {linebreak} 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:_ {linebreak} Perhaps what we need then is a big fat warning in the manual :) - Peter ---- _2006-Jul-17 00:06:41 by drh:_ {linebreak} 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:_ {linebreak} lang_expr.html seems like an obvious choice; perhaps also a sidenote on FAQ question 16 - Peter #cfe8bd 1889 new fixed 2006 Jul drh 2006 Jul 1 1 Make sqlite3_interrupt() accessible from the TCL interface This would avoid the need for command-abort hacks such as described near the bottom of http://wiki.tcl.tk/2633 #c8c8c8 1888 code closed 2006 Jul anonymous Unknown 2006 Jul anonymous 1 1 connetion to db extremely slow I use SQLite 2.8.14 under PHP 5.0.5 on a Linux machine. My PHP code Even just the connection to DB_SQLITE_DBNAME . ".db" is terribly slow!! When I try to run a query, it just runs forever, no timeout, no result. What's up with this??? I can't change SQLite version, since I'm not server admin or something. I heard (and saw in the tests) that SQLite is a fast db machine, but this is terrible! Please take your concerns to the SQLite mailing list. Instructions for using the mailing list can be found at http://www.sqlite.org/support.html #cfe8bd 1887 code fixed 2006 Jul anonymous TclLib 2006 Jul 1 1 Bad result on empty [db onecolumn] When =[db onecolumn]= query result is empty, the intepreter result is untouched. So if a function is called in the query, its result is returned as result of =[db onecolumn]=. To correct the problem, change in tclsqlite.c, 1.163, line 1566: if( pRet ){ if( rc==TCL_OK ){ Tcl_SetObjResult(interp, pRet); } Tcl_DecrRefCount(pRet); } by: if( pRet ){ if( rc==TCL_OK ){ Tcl_SetObjResult(interp, pRet); } Tcl_DecrRefCount(pRet); }else{ if( rc==TCL_OK ){ Tcl_ResetResult(interp); } } #cfe8bd 1886 code fixed 2006 Jul drh 2006 Jul 1 1 Memory leak when malloc fails There are many potential memory leaks and some null pointer deferences when malloc fails in the middle of the addWhereTerm() function of select.c. Discovered by a Klocwork scan. #f2dcdc 1885 code active 2006 Jul anonymous Shell 2006 Jul 2 3 sqlite3 .mode insert and .dump do not list column names for selects 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{linebreak} sqlite> select * from users;{linebreak} ed 2006-07-05 52{linebreak} sqlite> .mode insert{linebreak} sqlite> select abs_tgt from users;{linebreak} INSERT INTO table VALUES(52);{linebreak} sqlite> Obviously the workaround is to hand edit the output SQL _2006-Jul-11 10:20:08 by anonymous:_ {linebreak} I've just noticed it doesn't include the table name in the INSERT statements either. #f2dcdc 1884 code active 2006 Jul anonymous 2006 Jul 3 2 pragma table_info caches results from previous query 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. #c8c8c8 1883 code closed 2006 Jul anonymous 2006 Jul 1 2 "no such table error" using sqlite-odbc driver I have found a serious bug in the sqite-odbc driver. I wrote a simple test program which uses two ODBC connections to an sqlite database. The first connection is used to issue a "create table" query. The second one is used to do a "select" on this table. The select query reports an error : "no such table". However if you use the same connection for the create and select statement, everything is alright. My version of sqlite is 3.3.6 built from tarball. Sqlite-odbc version is 0.66. The program runs on linux Mandrake 10.1 with 2.4.28 kernel with tls and O(1) patch, glibc 2.3.3-21mdk. I have written a similar program which uses only the sqlite library, it works well with one or two connections. That's why I think the bug comes from sqlite-odbc. I will attach the program. To compile it with two distinct connections: gcc sqlite.c -o sqlite -lodbc And with only one connection: gcc -DSAME_CONNECTION sqlite.c -o sqlite -lodbc Please submit this problem to odbc author as it is not the Sqlite problem. #f2dcdc 1882 code active 2006 Jul anonymous 2006 Jul 1 1 Wrong algorithm of SQLITE_VERSION_NUMBER calculation 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). #c8c8c8 1881 code closed 2006 Jul anonymous Parser 2006 Jul anonymous 2 1 error in inserting strings with single quotes underlying is the insert query in which we are trying to insert a data with value as 'hello' insert into Probes(Name) values(''hello''); this insert query is giving sql error as SQL Error: near "hello": syntax error Is it possible to insert a data with single quotes? _2006-Jul-05 11:45:01 by anonymous:_ {linebreak} String literals in SQL queries are delimited with single quotes. To insert single quote as part of literal string, you need to escape each of those single quotes that are part of string literal it self with 2 single quotes. So in this case you'll need one single quote as a delimiter, and then 2 more that would represent one single quote that is actually part of your data. Like this: insert into Probes(Name) values('''hello'''); #c8c8c8 1880 code closed 2006 Jul anonymous 2006 Jul 3 3 Errors testing sqlite 3.3.6 $ make test ./libtool --mode=link gcc -s -O3 -march=i686 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src -DNDEBUG -DSQLITE_ALLOW_XTHREAD_CONNECT=1 -I/usr/local/include -DTHREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=1 -DSQLITE_OMIT_CURSOR -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 \ -DTEMP_STORE=3 -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/local/lib -ltcl8.5 -ldl -lpthread -lieee -lm gcc -s -O3 -march=i686 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src -DNDEBUG -DSQLITE_ALLOW_XTHREAD_CONNECT=1 -I/usr/local/include -DTHREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=1 -DSQLITE_OMIT_CURSOR -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 -DTEMP_STORE=3 -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/local/lib -ltcl8.5 -ldl -lpthread -lieee -lm creating testfixture ./testfixture ./test/quick.test aggerror-1.1... 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 [...] date-3.17... Ok /tmp/sqlite-3.3.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 64) make: *** [test] Error 1 The test scripts only work with Tcl version 8.4. They have not been ported to Tcl 8.5. #cfe8bd 1879 doc fixed 2006 Jul anonymous 2006 Jul 4 4 Perl is spelt Pearl on the http://www.sqlite.org page tssia #c8c8c8 1520 new closed 2005 Nov anonymous 2006 Jul 4 4 sqlite3_column_type do not work for empty table for expty table can not resolve the type of the field. _2006-Jul-18 07:14:38 by anonymous:_ {linebreak} This is also the case for calling sqlite3_column_type on columns from a table that failed to join (such as with a LEFT JOIN). sqlite3_column_type() returns 0 for that column index. ---- _2006-Jul-18 10:09:58 by drh:_ {linebreak} sqlite3_column_type() returns the data type of a specific element of a table. An empty table has no elements, so clearly sqlite3_column_type() will not work. Perhaps you want the results of sqlite3_column_decltype() instead. For the second (unrelated) problem mentioned above, please provide example code so that I can reproduce it. ---- _2006-Jul-19 19:00:57 by anonymous:_ {linebreak} Please disregard the second case. I determined I was trying to get the column type using an invalid index (out of bounds). #f2dcdc 1878 code active 2006 Jun anonymous CodeGen 2006 Jun 2 3 No index used when specifying alias name in ORDER BY clause 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:_ {linebreak} 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:_ {linebreak} As a workaround try "ORDER BY 1" ---- _2006-Jul-03 08:41:01 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} SQLite really needs a way to explicitly state which index(es) to use. Perhaps something similar to Oracle's comment hints. #cfe8bd 1877 code fixed 2006 Jun anonymous VDBE 2006 Jun 2 2 problems with compiling with -DSQLITE_OMIT_VIRTUALTABLE
 There's a problem with compiling with SQLITE_OMIT_VIRTUAL_TABLE. There are 4 functions that still begin used (and referenced) in pager.c:  sqlite3.lib(parse.obj) : error LNK2001: unresolved external symbol _sqlite3VtabArgExtend sqlite3.lib(parse.obj) : error LNK2001: unresolved external symbol _sqlite3VtabArgInit sqlite3.lib(parse.obj) : error LNK2001: unresolved external symbol _sqlite3VtabBeginParse sqlite3.lib(parse.obj) : error LNK2001: unresolved external symbol _sqlite3VtabFinishParse 
Also, there's a possible (??) bug. In the start of OP_Destroy: switch at vdbe.c, there's the code: case OP_Destroy: { int iMoved; Vdbe *pVdbe; int iCnt = db->activeVdbeCnt; #ifndef SQLITE_OMIT_VIRTUALTABLE iCnt = 0; for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){ if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->inVtabMethod<2 && pVdbe->pc>=0 ){ iCnt++; } } #endif ... The iCnt is assigned two times: first with db->activeVdbeCnt and second with 0 (zero). and if you comment with defining SQLITE_OMIT_VIRTUALTABLE you get a warning here. So, if this is correct, you could change this to: case OP_Destroy: { int iMoved; int iCnt; #ifndef SQLITE_OMIT_VIRTUALTABLE Vdbe *pVdbe; iCnt = 0; for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){ if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->inVtabMethod<2 && pVdbe->pc>=0 ){ iCnt++; } } #else iCnt = db->activeVdbeCnt; #endif ...
#c8c8c8 1876 event closed 2006 Jun anonymous Unknown 2006 Jun 4 4 Creating table disrupts previously prepared statement This sequence of API calls fails: open exec(create table a) prepare(insert into a) exec(create table b) prepare(insert into b) bind(statement a) step(statement a) * fails * Moving creation of table b ahead of prepare for table a works _2006-Jun-28 10:34:45 by drh:_ {linebreak} Yes. Schema changes, ATTACH or DETACH, VACUUM, and various other actions all invalidate prepared statements, requiring them to be recompiled. ---- _2006-Jun-29 01:59:26 by anonymous:_ {linebreak} Would it be possible to get a specific error returned, such as 'stale statment' or 'schema changed' rather than 'SQL error or missing database'? ---- _2006-Jun-29 07:26:12 by anonymous:_ {linebreak} A subsequent call to sqlite3_finalize() or sqlite3_reset() should return SQLITE_SCHEMA. The error message at that point is more descriptive. #cfe8bd 1875 code fixed 2006 Jun anonymous 2006 Jun 1 3 EXPLAIN crashes in strlen The following segfaults on Mac OS X 10.4 PowerPC: CREATE TABLE BAR(bar INTEGER NOT NULL, baz INTEGER NOT NULL, biz INTEGER NULL, buzz INTEGER NULL); explain select * from BAR where bar in (0,1) and baz in (0,1) and (biz in (0,1) or buzz in (0,1)); Stack trace: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x56000000 0x90002d28 in strlen () (gdb) bt #0 0x90002d28 in strlen () #1 0x0023fc9c in sqlite3VdbeList (p=0x1800c00) at ./src/vdbeaux.c:659 #2 0x0023e530 in sqlite3_step (pStmt=0x1800c00) at ./src/vdbeapi.c:219 #3 0x00247238 in sqlite3_exec (db=0x4001b0, zSql=0x4039d0 "explain select * from foo where bar in (0,1) and baz in (0,1) and (biz in (0,1) or buzz in (0,1));", xCallback=0x34b0 , pArg=0xbffff0dc, pzErrMsg=0xbffff058) at ./src/legacy.c:78 #4 0x00005a6c in process_input (p=0xbffff0dc, in=0x0) at ./src/shell.c:1495 #5 0x00006280 in main (argc=2, argv=0xbffffafc) at ./src/shell.c:1786 Applied [3314] and [3315] and verified that EXPLAIN now works. ---- _2006-Jun-27 20:51:13 by anonymous:_ {linebreak} I had forgotten to mention that this was against 3.3.6; I applied those two checkins to the 3.3.6 sources. #f2dcdc 1874 new active 2006 Jun anonymous CodeGen 2006 Jun 2 3 IN is much slower than making separate queries 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:_ {linebreak} [3315] fixed the EXPLAIN crash, so I've attached EXPLAIN output for the IN query. ---- _2006-Jun-27 22:01:31 by drh:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 1873 code fixed 2006 Jun drh 2006 Jun 1 1 DETACH while query is running results in crash 1: Open a database. 2: ATTACH a second database 3: prepare a SELECT statement that returns 2 or more rows from the second database. 4: step the query once. 5: DETACH the second database 6: step the query again. You get an error. 7: finalize the query and you get an assertion fault or segfault. _2006-Jun-27 16:40:05 by danielk1977:_ {linebreak} [3312] modifies the library so that the attempt to detach the database in step 5 results in a "database is locked" error. #f2dcdc 1872 code active 2006 Jun anonymous 2006 Jun 4 3 sqlite3_open doesn't support RFC1738 format for filename 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) #f2dcdc 1871 event active 2006 Jun anonymous 2006 Jun 2 3 VACUUM should not change 3.x file format 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 1870 code closed 2006 Jun anonymous 2006 Jun 2 2 dbWriteTable in RSQLite can't write strings that contain commas. Currently if your data.frame contains any character strings with commas the intermediate CSV file used in the sqliteWriteTable will cause errors. Here I slightly alter the sqliteWriteTable routine to support text with commas. sqliteWriteTable <- function (con, name, value, row.names = TRUE,...) { fn <- tempfile("rsdbi") on.exit(unlink(fn), add = TRUE) dots <- list(...) safe.write(value, file = fn, batch = dots$batch, row.names = FALSE,sep="\t") a <- list(con = con, name = name, value = fn, header = TRUE, sep="\t") do.call("sqliteImportFile", c(a, dots)) } _2006-Jun-26 06:11:22 by anonymous:_ {linebreak} sqliteWriteTable <- function (con, name, value, row.names = TRUE,...) { fn <- tempfile("rsdbi") on.exit(unlink(fn), add = TRUE) dots <- list(...) safe.write(value, file = fn, batch = dots$batch, row.names = FALSE,sep="\t") a <- list(con = con, name = name, value = fn, header = TRUE, sep="\t") do.call("sqliteImportFile", c(a, dots)) } For greater certainty, I think the original poster is talking about an SQLite-related module that allows users of the (very wonderful) statistical programming language R (a free implementation of S-Plus) to import SQLite datasets. ---- _2006-Jun-26 09:51:04 by drh:_ {linebreak} This system is for reporting bugs against the SQLite core. Please report bugs against RSQLite to the creators of that software. We have no ability to work on RSQLite. #f2dcdc 1869 doc active 2006 Jun anonymous Unknown 2006 Jun anonymous 4 4 Website typo 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. #c8c8c8 1868 code closed 2006 Jun anonymous Shell 2006 Jun 4 4 where a = b = c Shouldn't this be a syntax error? create table t( catch text, me text ); select * from t where catch = me = 'if you can'; _2006-Jun-23 13:57:40 by drh:_ {linebreak} The expression is correct (according to SQLite at least - other SQL parsers might disagree). It parses this way: (a = b) = c The (a=b) part evalutes to a boolean (0 or 1) then it compares the 0 or 1 result to c. #f2dcdc 1867 code active 2006 Jun anonymous BTree 2006 Jun 1 3 Access Violation after set a new page_size 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]
#c8c8c8 1866 event closed 2006 Jun anonymous 2006 Jun 1 1 SQLite.NET ExecuteNonQuery() limit of text size SQLite.NET ExecuteNonQuery() does not allow CommandText to be more than 110 K, it was found out by experimental way. If text is more than 110 K it gives exception, "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." _2006-Jun-22 15:06:37 by drh:_ {linebreak} This site is for the SQLite core only. The .NET wrappers (there are several) are all developed separately. Use google to find the right site. #c8c8c8 1865 code closed 2006 Jun anonymous 2006 Jun 1 2 Encoding problem using order by As I understand SQLite should be using OS functions to sort strings in order by clause, but non ASCII characters are not sorted correctly. Example: CREATE TABLE proba ( id INTEGER PRIMARY KEY, tekst TEXT ); INSERT INTO proba VALUES(1,'Cicak'); INSERT INTO proba VALUES(2,'Čičak'); INSERT INTO proba VALUES(3,'Dida'); SELECT * FROM proba ORDER BY tekst ASC; Expected results: 1|Cicak 2|Čičak 3|Dida Actuall results: 1|Cicak 3|Dida 2|Čičak Tested platforms: WinXP SP2, Ubuntu By default, sqlite sorts strings in memcmp() order. If you need it to do anything else you need to define and use a "collation sequence". See section 7 of this for more detail: http://www.sqlite.org/datatype3.html #f2dcdc 1864 new active 2006 Jun anonymous 2006 Jun drh 3 3 List availabe SQL functions 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.{linebreak} 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:_ {linebreak} Perhaps this could be done using a {link: wiki?p=VirtualTables virtual table}. ---- _2006-Jun-21 20:15:27 by anonymous:_ {linebreak} 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? #cfe8bd 1863 secure fixed 2006 Jun anonymous Unknown 2006 Jun drh 2 3 authorizing load_extension() This is probably somewhere on the TODO list already, but it scares me enough that I won't take that chance. There needs to be some mechanism to dynamically block =load_extension()= from being called from an arbitrary SQL query. In the current implementation, near as I can see, there's absolutely no way to prevent user-defined queries, even with an authorizer, from invoking =load_extension()= on any library, including something the user cooked up. I'd strongly suggest an authorizer call with =SQLITE_LOAD= or =SQLITE_EXTENSION= or something, with the library path and init function as arguments, so we can filter this stuff. c. _2006-Jun-21 03:59:38 by anonymous:_ {linebreak} If you let your users create and execute SQL directly already, this extension poses no additional risk. ---- _2006-Jun-21 09:35:54 by drh:_ {linebreak} For something like CVSTrac that allows users to enter arbirary SQL, it is probably best to completely disable the load_extension() function by replacing with a simple function that throws an exception. Just call sqlite3_create_function() to overload it. Meanwhile, I'll think about an easier way to do this, and perhaps even turning load_extension() off by default. ---- _2006-Jun-21 09:37:34 by drh:_ {linebreak} I was, at one time, thinking about added in exec() SQL function that took as its argument SQL text and executed it. Clearly such a function would have the same issue. I wonder if we need some kind of sandboxing mechanism that would allow these functions to exist but to be turned off for user-supplied SQL... ---- _2006-Jun-21 10:45:00 by anonymous:_ {linebreak} Isn't this more dangerous than just executing arbitrary SQL. It allows users who are able to get a file to the system to execute _any_ code in the file ??? Like, say, system("rm -rf ~/") :-/ ---- _2006-Jun-21 11:20:18 by anonymous:_ {linebreak} Replacing =load_extension()= with a simple function would be effective, but only where a developer can actually change the application _and_ get that change pushed out to every user who might accidentally upgrade to SQLite 3.3.7. And you just know how easy it is to get people to upgrade applications whenever you want ;) Turning off =load_extension()= by default gets around this, but it means that a developer can't have both extension loading _and_ the ability to allow users to execute restricted queries without a whole lot of fancy footwork (assuming it was possible to turn it one and off at will). On the other hand, if someone is already using an authorizer properly (i.e. by whitelisting rather than blacklisting), the new functionality will be denied by default and _not_ create a security hole, even if the application developer does nothing. The authorizer _is_ your sandbox for user queries. If you wanted to get fancy, it should be easy to add a =SQLITE_FUNCTION= authorizer type in order to allow developers to block functions. Overkill, though... It's only needed for functions with nasty side-effects like =load_extension()= and =winRebootSystemWithoutAsking()=. The =exec()= function doesn't have even _close_ to the same problem since the authorizer should already be in place, so the executed SQL wouldn't be able to do anything not already allowed. See the f_option() function in /cvstrac/db.c for an example of something which already works this way. ---- _2006-Jun-21 15:14:37 by anonymous:_ {linebreak} The real issue here is that load_extension() should not be an SQL function at all, but a PRAGMA. PRAGMAs change the way the database operates. Load_extension fits into this category. It does not make sense to have this mechanism accessed from SQL. SQL Functions should not have side effects, and especially not side effects that outlive the statement. Even better, the load extension mechanism should be table driven at database load via a system table of some sort. It makes sense for custom functions to be automatically loaded with the database that contains expressions with those functions (in views, etc). This would also allow non-programming users of the unmodified sqlite3.dll to gain the benefit of downloading custom SQLite extension libraries and have them work with their databases with little effort. ---- _2006-Jun-21 17:19:18 by anonymous:_ {linebreak} A =PRAGMA= would work for me. Any application using the authorizer which allows unconditionally allows =PRAGMA= is already doomed. Personally, I don't have a preference either way as long as the behaviour defaults to safe and is controllable by the application somewhere, ideally through the pre-existing filtering mechanism. I suspect that one of the ideas behind using the =load_extension()= function from =SELECT= was to make it easy for applications to roll their own extension loading. i.e.: SELECT load_extension(path,entryfunc) FROM extensions; A standard mechanism for finding and loading extensions is a fine idea, as long as the SQLite application gets to choose whether this system table gets honoured or not (default is no, of course) and gets to filter which extensions are actually loaded (via the authorizer, for example, except we'd really need all of the =PRAGMA= parameters to do a proper job of it). Otherwise, you make a SQLite database a vector for all kinds of trouble. ---- _2006-Jun-21 17:36:02 by drh:_ {linebreak} How about a new API that must be called to enable extension loading. Perhaps something like: sqlite3_enable_extension_loading(db); If you do not call this, you do not get any extension loading capability, so there is no danger to legacy applications that just happen to link against a newer version of SQLite. I'd rather not create yet another API. I thought about adding a pragma to enable extension loading, but if a user can enter arbitrary SQL, the authorizer might not block the PRAGMAs correctly and so the user might still be able to enable extensions. But with an API, that will never be possible with explicit support from the application. Maybe the API should be this: sqlite3_enable_potentially_dangerous_stuff(db); ---- _2006-Jun-21 18:00:46 by anonymous:_ {linebreak} Better would be: sqlite3_allow_extension_loading(db,onoff); The scenario I'm thinking about is 1: application starts 2: application opens SQLite database 3: sqlite3_allow_extension_loading(db,1); 4: application loads some extensions 5: sqlite3_allow_extension_loading(db,0); 6: sqlite3_set_authorizer(db,some_callback_fn); 7: application runs untrusted query Don't get me wrong; the extension functionality is a _good thing_ and it opens up a lot of possibilities. But there's a time for extensions to be loaded (i.e. during application setup) and a time for them to _not_ be loaded (when you don't trust the query), and I think the application should be able to make that policy decision. Even better would be to go beyond the on/off decision and use something like: sqlite3_allow_extension_loading(db,some_filter_callback); where the filter could make an informed decision about what extensions are loaded (i.e. is the library file root-owned and not user writable, is the file cryptographically signed by the same key as the current application, etc). But that's basically equivalent to having the extension loader call the authorizer callback with a =SQLITE_LOAD_EXTENSION= type and the filename/entry as the arguments, so we're starting to go in circles... ---- _2006-Jun-21 18:53:39 by drh:_ {linebreak} The problem with a new authorization type for load_extension is that authorization has (until now) always been checked at compile-time (during sqlite3_prepare) whereas a load_extension check would need to occur at run-time. This could cause problems for applications that only enable the authorizer for the duration of sqlite3_prepare() and then turn it off for sqlite3_step(). ---- _2006-Jun-21 19:03:01 by anonymous:_ {linebreak} A compile-time flag ought to be sufficient to disable the load extension functionality. Perhaps it should be compiled off by default. Only more experienced programmers would allow the loading of extensions. These same programmers would also take more precautions in not running arbitrary SQL statements. Question: is loading the same extension library more than once a NOP? i.e., could I call load_extension() in a view definition to guarantee my extensions are loaded whenenever a certain view is queried? ---- _2006-Jun-21 19:18:33 by anonymous:_ authorization has (until now) always been checked at compile-time Ah. In that case, a simple on-off flag is about the best bet. Smarter filtering would require custom application code regardless of how it was done, so the developer might as well just override the =load_extension()= function. A compile-time flag ought to be sufficient to disable the load extension functionality. Makes the assumption that the SQLite developers have any control over how SQLite gets packaged for other distributions. It's a pretty safe bet that for some distribution, somewhere, a packager is going to enable extension loading by default because it happens to scratch their personal itch. ---- _2006-Jun-21 23:31:36 by anonymous:_ {linebreak} "...somewhere, a packager is going to enable extension loading by default because it happens to scratch their personal itch." And such a hypothetical innovative packager would be prevented changing a simple compile-flag or calling a method to enabling load_extension() how? ---- _2006-Jun-21 23:46:40 by anonymous:_ {linebreak} The solution is pretty simple: 1. Make a white list of permissable loadable library names in an environmental variable, let's say something like: SQLITE_EXTENSIONS="myextlib1,myextlib2,myextlib3" If that environmental variable is not set or is an empty string, do not allow the loading of any shared library extension. In situations where the OS does not have a concept of environmental variables, it will probably not have shared library support either, so no issue there. 2. Do not allow absolute paths in shared library names (i.e., no occurances of '/' or '\'). All library names must be relative and without a suffix. The user is responsible in setting up the appropriate LD_LIBRARY_PATH or equivalent. The suffix is automatically appended as per the OS shared library suffix. 3. Mandate a single entry point function name. Do not allow the user to specify his/her own shared library entry point function. Allowing the user to specify a custom function name can easily lead to exploits. ---- _2006-Jun-23 13:16:05 by anonymous:_ * Make a white list of permissable loadable library names... * Do not allow absolute paths in shared library names... That might be okay for the sqlite3 command-line, but it imposes unreasonable restrictions on applications using SQLite. For example, some/many applications will =chdir()= into some data directory before doing work and that's almost certainly _not_ where the extensions are found. * Mandate a single entry point function name... Allowing multiple entry points means that a developer could package up a set of SQLite extensions in a single library file and the user could pick and choose what specific modules are actually used. Consider, for example, a string manipulation module with different entry points for different character encodings. If the option is available to enable/disable extension loading as needed, and the ability is there to override the =load_extension()= call with a version doing custom filtering, then I don't see any need for additional restrictions. Expecially since, if you wanted a "standard" set of restrictions and/or a "standard" way to find and load extensions from a database, it should be trivial to write a function which (a) enables extension loading, (b) overrides the =load_extension()= function with a filter, and (c) loads any extensions found in the "extensions" table of the current database. =sqlite3_load_database_extensions(sqlite3* db);=, for example. ---- _2006-Jun-27 18:03:19 by anonymous:_ {linebreak} It is unfortunate that the ability to load extensions is turned off by default. Now applications that do not provide source code and link with a static SQLite library cannot be extended. Other than the SQLite website itself, how many programmers allow people to execute random SQL fragments? ---- _2006-Jun-27 19:33:45 by anonymous:_ {linebreak} Um... Maybe I'm misunderstanding you. It sounds like: 1: you're using an application 2: where the developer won't release the source code 3: won't make some change you want 4: won't change the software so you can make the change yourself and you think the problem is that the SQLite developers won't override the application developer's decisions? It's _not_ a question about whether or not end-users can do "secure" queries. Fundamentally, it's about who gets to decide whether or not an application gets extended; the application developer, or the SQLite developer. #f2dcdc 1862 code active 2006 Jun anonymous TclLib 2006 Jun tclguy 1 1 SQLite cannot load/import data from file 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:_ {linebreak} This is a duplicate of #1797 #f2dcdc 1861 code active 2006 Jun anonymous Pager 2006 Jun 1 1 Problem in using Triggers and multithreading 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? #f2dcdc 1860 doc active 2006 Jun anonymous Pager 2006 Jun danielk1977 1 1 Problem in using SQLite3 with trigger and multithreading 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. #c8c8c8 1859 code closed 2006 Jun anonymous Unknown 2006 Jun danielk1977 4 3 Wrong calculation og log2() in check-in [3274] This part of check-in [3274] look odd to me: + /* Approximation of log2(nRow). */ + for( ii=0; ii<(sizeof(int)*8); ii++ ){ + if( nRow & (1<estimatedCost = (double)ii; + } + } If you only want the MSB, then loop from sizeof(int)*8 to 0, and break when a set bit is seen (faster ?!!). Or if you want all bits to matter, then use "+=", not "=" Erling Jacobsen, linuxcub@email.dk _2006-Jun-20 11:26:43 by anonymous:_ {linebreak} Probably the first. Thinking about it, adding (with +=) will make things worse. But the loop can be made faster ... ---- _2006-Jun-26 07:22:11 by anonymous:_ {linebreak} Poster is right, this is a bit lazy and can be improved upon. But the block in question comes from test code, not from the library itself, and the same function - echoBestindex() - test function has some other *really* inefficient stuff too. So for now leave things as they are. #f2dcdc 1858 doc active 2006 Jun anonymous 2006 Jun 5 5 Typo: Pearl -> Perl sqlite/www/index.tcl 1.139 s/Pearl/Perl/g #f2dcdc 1857 code active 2006 Jun anonymous 2006 Jun 3 4 Can't use ISO 8601 dates with time zone designator 'Z' 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.{linebreak} This is the format generated by 'svn log --xml'. More details of the format at {link: 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'. #f2dcdc 1856 code active 2006 Jun anonymous 2006 Jun 2 3 SQLITE_OMIT_UTF16 breaks 'make test' 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. #c8c8c8 1855 doc closed 2006 Jun anonymous 2006 Jun 5 5 how to configure SQLite with jboss i want to configure SQLite with jboss server.anybody can help me in doing this _2006-Jun-19 09:59:20 by drh:_ {linebreak} Please ask on the SQLite mailing list. See http://www.sqlite.org/support.html for instructions on how to subscribe to the mailing list. Please use ticket for reporting bugs, not for asking questions. #c8c8c8 1854 event closed 2006 Jun anonymous 2006 Jun 3 3 i am unable to view the tables by using .tables command i am unable to view the tables created by using .tables ,once after coming out of the sqlite prompt. _2006-Jun-19 09:48:07 by drh:_ {linebreak} The .table command is a artifact of the command-line shell. It is not built into the SQLite core library. #f2dcdc 1853 code active 2006 Jun anonymous 2006 Jun 3 4 sqlite3_analyzer-3.3.4 integer overflows on large database 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:_ {linebreak} 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; #c8c8c8 1852 code closed 2006 Jun anonymous 2006 Jun 4 5 AUTOINC NOT NULL problem The INSERT fails with "SQL error: t.ID may not be NULL". CREATE TABLE t (ID INT AUTOINC NOT NULL); {linebreak} INSERT INTO t VALUES (null); _2006-Jun-17 23:55:30 by drh:_ {linebreak} OK. You declared a column to be NOT NULL and you tried to insert a NULL into it and you get an error. What exactly where you expecting to happen? If you want autoincrement, declare the column to be INTEGER PRIMARY KEY. ("INTEGER" spelled out, not abbreviated to "INT".) #f2dcdc 1851 code active 2006 Jun anonymous Unknown 2006 Jun 2 1 USE "ORDER BY" error on uClinux 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:_ {linebreak} 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:_ {linebreak} I'm just wondering that SQLite 3.2.8 runs on this uClinux system OK but SQLite 3.3.5 is error. #f2dcdc 1850 code active 2006 Jun anonymous Unknown 2006 Jun 2 1 NUMERIC data type ERROE when read on uClinux 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:_ {linebreak} 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. #cfe8bd 1849 code fixed 2006 Jun anonymous VDBE 2006 Jun 1 3 EXPLAIN segfault on linux (3.3.6 and 3.3.5 and 3.3.2) while building sqlite 3.3.6 with no configuration options on Linux, explain segfaults. Example of session dump: tester@ ~ $ tar xzfp sqlite-3.3.6.tar.gz tester@ ~ $ cd sqlite-3.3.6 tester@ ~/sqlite-3.3.6 $ ./configure --prefix=`pwd`/install ... (no configuration errors) ... make -j 5 ... (no build errors) ... the defines are: -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_CURSOR these were not specified by me but by autotools. tester@ ~/sqlite-3.3.6 $ ./sqlite3 SQLite version 3.3.6 Enter ".help" for instructions sqlite> create table T (i integer); sqlite> explain select * from t; Segmentation fault Backtrace information follows: Core was generated by `./bin/sqlite3'. Program terminated with signal 11, Segmentation fault. warning: Can't read pathname for load map: Input/output error. Reading symbols from /home/tester/sqlite-3.3.6/install/lib/libsqlite3.so.0...done. Loaded symbols for /home/tester/sqlite-3.3.6/install/lib/libsqlite3.so.0 Reading symbols from /lib/libreadline.so.5...done. Loaded symbols for /lib/libreadline.so.5 Reading symbols from /lib/libc.so.6...done. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/libncurses.so.5...done. Loaded symbols for /lib/libncurses.so.5 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 Reading symbols from /lib/libgpm.so.1...done. Loaded symbols for /lib/libgpm.so.1 Reading symbols from /lib/libnss_compat.so.2...done. Loaded symbols for /lib/libnss_compat.so.2 Reading symbols from /lib/libnsl.so.1...done. Loaded symbols for /lib/libnsl.so.1 Reading symbols from /lib/libnss_nis.so.2...done. Loaded symbols for /lib/libnss_nis.so.2 Reading symbols from /lib/libnss_files.so.2...done. Loaded symbols for /lib/libnss_files.so.2 #0 0xb7db5473 in strlen () from /lib/libc.so.6 gdb> bt #0 0xb7db5473 in strlen () from /lib/libc.so.6 #1 0xb7ef4b6e in sqlite3VdbeList (p=0x8063658) at vdbeaux.c:659 #2 0xb7ef33db in sqlite3_step (pStmt=0x8063658) at vdbeapi.c:219 #3 0xb7efc55b in sqlite3_exec (db=0x8060cb0, zSql=0x8062770 "explain select * from t;", xCallback=0x80497f0 , pArg=0xbfd19810, pzErrMsg=0xbfd197a8) at legacy.c:78 #4 0x0804acef in process_input (p=0xbfd19810, in=0x0) at shell.c:1495 #5 0x0804d104 in main (argc=0x1, argv=0xbfd1adc4) at shell.c:1786 Apparently the error occurs in sqlite3VdbeList which calls strlen with an invalid pointer. Although this is probably not relevant, this is my compiler: gcc -v Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.4/specs Configured with: /var/tmp/portage/gcc-3.4.4-r1/work/gcc-3.4.4/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.4.4 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.4 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.4/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.4/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/include/g++-v3 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --enable-java-awt=gtk --enable-languages=c,c++,java --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8) I will try to actually debug the code to see whats going on. I have had similar behaviour with versions 3.3.5 and 3.3.2. The problem is in vdbeaux.c at line 659, where at one point ''pMem->n = strlen(pMem->z);'' when ''pMem->z'' is a NULL pointer. _2006-Jun-15 10:49:34 by anonymous:_ {linebreak} Bug #1242 is similar to this one. ---- _2006-Jun-15 12:30:20 by drh:_ {linebreak} As part of the build process, SQLite generates a C file named "opcodes.c". This file contains a single constant array of strings that is used to translate opcode numbers into opcode names for use by EXPLAIN. The only way I can see that you could be getting this error is if opcodes.c is not being generated correctly. Can you please attach a copy of your opcodes.c file for analysis. ---- _2006-Jun-19 09:41:54 by anonymous:_ {linebreak} Bug #1110 is exaclty the same. ---- _2006-Jun-19 09:48:08 by anonymous:_ {linebreak} (I am not the original poster of this problem, but I have the same problem.) The opcodes.c looks like: /* Automatically generated. Do not edit */ /* See the mkopcodec.awk script for details. */ #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) | | defined(SQLITE_DEBUG) const char *const sqlite3OpcodeNames[] = { "?", }; #endif This happens, because in the 'Makefile' there is the statement sort -n -b +2 opcodes.h | $(NAWK) -f $(TOP)/mkopcodec.awk >opcodes.c but newer versions of the sort-command do no longer allow this syntax! You have to use sort -n -b -k 2 opcodes.h | $(NAWK) -f $(TOP)/mkopcodec.awk >opcodes.c and then the test will suceed! Regards and thanx for such a fine DB! ---- _2006-Jun-20 07:18:41 by anonymous:_ {linebreak} Just a hint: The problem with 'sort' is discussed here: #1696 #cfe8bd 1848 code fixed 2006 Jun anonymous Parser 2006 Jun drh 1 1 C++ ism on generated parse.c from latest CVS head
 On line 1391 of generated parse.c, there's a C++ ism that stops SQlite get compiled on MSVC++ compiler (but it stills compiling on gcc, possibly a gcc compiler bug).  The int j declaration is in a incorrect position and it's declared after some code if YYFALLBACK is defined. Look the code:    if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){     if( iLookAhead>0 ){   #ifdef YYFALLBACK       int iFallback;            /* Fallback token */       if( iLookAhead %s\n",              yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);         }   #endif         return yy_find_shift_action(pParser, iFallback);       }   #endif   #ifdef YYWILDCARD       int j = i - iLookAhead + YYWILDCARD;       if( j>=0 && jint j should be declare just after the if ( iLookAhead> 0) { statement to follow C code style, just like:    if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){     if( iLookAhead>0 ){       int j;   #ifdef YYFALLBACK       int iFallback;            /* Fallback token */       if( iLookAhead	
#cfe8bd	1847	new	fixed	2006 Jun	anonymous		2006 Jun		4	4	Unhelpful error text	There are several built in undocumented limits in SQLite.  For example when registering a function name, it can't be longer than 255 chars and can't take more than 127 arguments.  If a developer violates those limits, then SQLITE_ERROR (1) is returned, but the text is "Not an error".  This gives no clue as to what has gone wrong.  In my case I am providing a Python wrapper, so the Python coder really doesn't know why this is happening.	
#c8c8c8	1846	code	closed	2006 Jun	anonymous		2006 Jun		1	1	Memory leak after returning error message	There is a memory leaking after returning error message:    SQLite3_Open(':memory:',db);   SQLite3_Exec(db,'DROP TABLE TEST',NIL,NIL,ErrMsg);   SQLite3_Exec(db,'DROP TABLE TEST',NIL,NIL,ErrMsg);   ...   SQLite3_free(ErrMsg);  This will return error message to ErrMsg to both SQLite3_Exec() calls. According to SQLite sources, memory for ErrMsg is allocated every time by malloc(), which causes memory manager to report memory leaking. Using realloc instead (when ErrMsg pointer is non NIL) will probably solve the problem.  It is slow and a bit unpractical using SQLite3_free(ErrMsg) after every SQLiteAPI call which use ErrMsg.	_2006-Jun-13 20:19:53 by drh:_ {linebreak} You are requesting that *pzErrMsg be automatically freed if it is reused.  This is a reasonable idea.  But it is not how SQLite is documented to work.  To make this change now would not be backward compatible.  It may well break existing code that follows the documentation.  For that reason, we must reject the feature request.  Note that you can write a simple wrapper around sqlite3_exec() or whatever other APIs you are using, to accomplish the the automatic freeing effect that you desire.
#cfe8bd	1845	code	fixed	2006 Jun	anonymous	Unknown	2006 Jun		3	3	soundex(null) causes access violation	using the windows binary for version 3.3.5 soundex of a NULL value causes an Access Violation Exception.	_2006-Jun-13 19:29:24 by drh:_ {linebreak} The soundex() function is not supported.  It does not appear in any standard build.  You have to compile with -DSQLITE_SOUNDEX=1 to enable it.  The soundex() function is not tested in any of the regression tests. The soundex() function might not be in any subsequent release.  Even if it is in a future release, it might not work.  If it is removed, the removal of soundex() will probably not be announced.  The bottom line is you should probably not be using the built-in soundex() function.  Use your own instead.  Nevertheless, the reported problem has been fixed. (However, since soundex() is an untested function, the fix is also untested.)
#c8c8c8	1844	warn	closed	2006 Jun	anonymous		2006 Jun		2	3	compiler warnings with gcc 3.3.4 on Tru64 V5.1B	Here are few warnings you might want to fix since they seem to be actual bugs on 64-bit systems:   table.c: In function `sqlite3_get_table':   table.c:149: warning: cast to pointer from integer of different size   table.c: In function `sqlite3_free_table':   table.c:194: warning: cast from pointer to integer of different size   vdbemem.c: In function `sqlite3ValueText':   vdbemem.c:779: warning: cast from pointer to integer of different size  For the first two cases changing 'nData' in 'TabResult' and local variable 'n' from 'int' to 'long' fixes the problem on LP64 systems but not on LLP64 systems such as Windows.  In the third case cast the pointer to a 'long' instead of an 'int'. Same remark about LLP64 though.	_2006-Jun-12 13:09:21 by drh:_ {linebreak} The warnings in table.c are false.  Line 779 of vdbemem.c for version 3.2.8 is in the middle of a header comment to a function and is several dozen lines removed from sqlite3ValueText(). So I do not have any idea what line that is referring to.  ---- _2006-Jun-12 13:55:28 by anonymous:_ {linebreak} It's SQLite 3.3.6 not 3.2.8.  I have no idea what went wrong, I remember typing 3.3.6.  ---- _2006-Jun-12 13:59:00 by anonymous:_ {linebreak} Line 779 of vdbemem.c looks like:      if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&(int)pVal->z) ){  and the problem is the int cast.  Lines 149 and 194 of table.c look like:      res.azResult[0] = (char*)res.nData;      n = (int)azResult[0];  and the problem is conversion from/to pointer to/from int.  ---- _2006-Jun-12 14:24:30 by drh:_ {linebreak} None of these things are actual problems.  ---- _2006-Jun-12 19:03:00 by anonymous:_ {linebreak} Ah, good. I guess that's not a problem because the cast order is always:      32-bit integer -> 64-bit pointer           res.nData -> res.azResult[0]      64-bit pointer -> 32-bit integer     res.azResult[0] -> n  and there's even an assert() to ensure that there's no truncation in that order:   assert( sizeof(res.azResult[0])>= sizeof(res.nData) );  Still, it could be a good idea to work around the warnings, and since the warnings seem to occur with gcc only, it could be fixed on LP64 systems Unix/Linux/Mac only by using 'long' instead of 'int'. I don't know, maybe it's not worth the pain.
#c8c8c8	1843	code	closed	2006 Jun	anonymous		2006 Jun		3	2	compile with gcc 3.3.4 on Tru64 V5.1B	The version of SQLite 3.2.8 bundled with Qt 4.1.* doesn't build on Tru64 V5.1B:  $ gcc -c -g -D_REENTRANT -Wall -W -fPIC  -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED [...] ../../../3rdparty/sqlite/os_unix.c [...] ../../../3rdparty/sqlite/os_unix.c:832:63: operator '&&' has no right operand [...]  I can't decide whether it's a compiler bug or an SQLite bug. See for yourself the attached build session.  In any case it's easy to work around, you just need to change from:   defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO>0  to:   defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO>0)  The relevant code is not used anymore in SQLite 3.3.*. I doubt you're willing to release SQLite 3.2.9 just to fix this build issue, but I thought I'd report this issue nevertheless because the same problem could be found in SQLite 3.3.*. For now SQLite 3.3.6 builds just fine on the same platform, but such preprocessor directives could fail if using different compiler options.	_2006-Jun-12 12:51:12 by drh:_ {linebreak} I think this is a compiler bug.  But it is simple enough to work around if it comes up again.  Just report it and we will implement the fix then.  ---- _2006-Jun-12 19:38:39 by anonymous:_ {linebreak} Indeed this looks like a compiler bug.  The problem is that the actual bug is the parentheses fixing the error. Indeed parentheses did fix the error with gcc 3.4.4 on Tru64 but they don't fix the problem with gcc 4.1.1 on Linux:    foo.c:2:25: error: operator '>' has no left operand  or Sun's cc 5.5 on Solaris:    "foo.c", line 2: missing operand   "foo.c", line 3: warning: empty translation unit   cc: acomp failed for foo.c  or HP's aCC A.03.57 on HP-UX:    Error 123: "foo.c", line 2 # Syntax error in '#if' or '#elif' directive.       #if defined(FOO) && (FOO>0)                               ^  I'm not sure how to fix this if the _POSIX_SYNCHRONIZED_IO issue or a similar issue of macro constants defined to no value occurs again. This looks like a shortcoming of the C pre-processor.  ---- _2006-Jun-19 12:08:25 by anonymous:_ {linebreak} Aaargh... The solution is easy, just need to change from:  #if defined(FOO) && (FOO>0) to:  #if defined(FOO) && (FOO-0>0) That's a standard workaround for the C preprocessor.  Anyway, I wasn't able to find similar problems in SQLite 3.3: all "#if" and ">" or "<" combinations involve SQLite internal macros and I doubt these internal macros can be defined to nothing.
#c8c8c8	1842	code	closed	2006 Jun	anonymous	Unknown	2006 Jun	anonymous	1	1	The field data saved in the table is corrupt	The field data saved in the table is corrupt.  -------------detail----------------------------  we executed the SQL: select * from etolldata where dutyid='352EC3C196F7DA119FF200D0F864D127'  and we got:  352EC3C196F7DA119FF200D0F864D127 .... 352EC3C196F7DA119FF200D0F864D127 .... 352EC3C196F7DA119FF200D0F864D127 .... 352EC3X/F7DA119FF200D0F864D127 .... 352EC3C196F7DA119FF200D0F864D127 .... 352EC3C196F7DA119FF200D0F864D127 .... 352EC3C196F7DA119FF200D0F864D127 ....  notice the fourth record, the content of field 'DutyID' is corrupt.	_2006-Jun-12 03:17:20 by anonymous:_ {linebreak} You've provided no information that could help in tracking down the problem. The issue could very well be bad RAM, or a faulty hard disk, and not SQLite for all we know.  ---- _2006-Jun-12 11:10:04 by drh:_ {linebreak} I agree with the remarks by anonymous above.  This bug report gives us no information that can be used to track down the error, or even to suggest that the error is in SQLite.  Probably this is a bug in the application that is using SQLite or possibly in the wrapper for whatever language is being used.
#c8c8c8	1841	warn	closed	2006 Jun	anonymous		2006 Jun	mani	3	2	a scan in safe mode says my sqlite file is wrong size	I'm having trouble opening my new computer so I opened it in safe mode. After a disk check it says the two sqlite files are the wrong size. Is this a big problem?	_2006-Jun-12 11:21:43 by drh:_ {linebreak} The description above gives no context information.  So, I will have to take a wild guess at what is happening.  I'm guessing that the OS is windows since Linux does not normally have anything called "safe mode".  Also, most Linux distributions use either ext3 or reiserfs, both of which will automatically repair file metainformation after an unclean shutdown.  It is unclear what an "sqlite" file is.  From the lack of useful information in the trouble report, I assume that the reporter is not a programmer.  I am guessing that the user is using AOL and has a disk full of "sqlite" files caused by the Mcafee virus scanner bug documented at http://tinyurl.com/pobqu  If my guesses above are correct, then the answer is "no" - this does not matter in the least.
#c8c8c8	1840	code	closed	2006 Jun	anonymous	Unknown	2006 Jun		4	4	sqlite3_get_table returns null pointer for aggregate queries	Simply put, it appears that aggregate queries on empty tables produce an output different from a non-aggregate function on a similarly empty table.  The following query: "select max(hnd) from mytable where 0=1;" put in sqlite3_get_table returns an array of two pointers, one for the column name, the other is null.  However, the following query: "select hnd from mytable where 0=1;" put in sqlite3_get_table returns an array of one pointer, pointing to the column name.  I'm sorry I cannot provide a sample of my code. I'm using an obscure language called J and it would be more trouble for you to try and find why it happened. It's no big trouble getting around the null pointer, but I was curious about this difference.	_2006-Jun-12 11:08:00 by drh:_ {linebreak} The behavior you describe above is correct.  The aggregate query should return a single row with a value of NULL.  Consider a slightly different query:      SELECT count(*) FROM mytable WHERE 0=1  Most people expect this to return a count of 0, not an empty set. If you agree that the above should return 0, then consider this:      SELECT count(*), max(hnd) FROm mytable WHERE 0=1  By adding the count(*) to your original query above, should that cause the query to change from returning no rows to returning one row?  That seems very wrong.  The correct and consistent thing to do is to return one row in an aggregate query even if there are no rows of input.  ---- _2006-Jun-17 00:10:47 by anonymous:_ {linebreak} Makes sense. Thanks for taking the time to clear that up.
#cfe8bd	1839	build	fixed	2006 Jun	anonymous		2006 Jun		1	4	attempting to compile loadext.c fails	System Version: Mac OS X 10.3.9 (7W98) Kernel Version: Darwin 7.9.0  [Dads-Computer:~/dev/sqlite] tjhart% gcc -v Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs Thread model: posix gcc version 3.3 20030304 (Apple Computer, Inc. build 1671) [Dads-Computer:~/dev/sqlite] tjhart% uname -a Darwin Dads-Computer.local 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC  Power Macintosh powerpc   gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I../sqlite/src -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_CURSOR -c ../sqlite/src/loadext.c  -fno-common -DPIC -o .libs/loadext.o ../sqlite/src/loadext.c: In function `sqlite3CloseExtensions': ../sqlite/src/loadext.c:285: error: `SQLITE_LIBRARY_TYPE' undeclared (first use in this function) ../sqlite/src/loadext.c:285: error: (Each undeclared identifier is reported only once ../sqlite/src/loadext.c:285: error: for each function it appears in.) ../sqlite/src/loadext.c:285: error: parse error before ')' token make: *** [loadext.lo] Error 1	_2006-Jun-11 17:07:42 by anonymous:_ {linebreak} The 3.3.6 source tarball from the downloads page compiles just fine. This is the CVS Tip as of June 11, 2006
#f2dcdc	1838	code	active	2006 Jun	anonymous		2006 Jun		5	5	test types3-1.3 fails on 64-bit Linux	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.	
#f2dcdc	1837	new	active	2006 Jun	anonymous	Pager	2006 Jun		4	4	Deadlock detection would be best reported using explicit error code.	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:_ {linebreak} 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:_ {linebreak} 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.
#cfe8bd	1836	new	fixed	2006 Jun	pweilbacher	Shell	2006 Jun		4	3	Further OS/2 updates	shell.c cannot yet be compiled (with all compilers) on OS/2 and not always does OS_OS2 get defined correctly in os.h.	_2006-Jun-12 12:57:15 by drh:_ {linebreak} At this point in history, OS2 is an obscure and seldom used platform.  For that reason, I'd like to keep the Watcom project file out of the source tree.  You are welcomed to leave it as an attachment on this ticket or add it as an attachment on a wiki pages.  Perhaps it would be worthwhile for you to create a new wiki page describing how to build for OS2 on various platforms.
#c8c8c8	1835	code	closed	2006 Jun	anonymous	Unknown	2006 Jun		1	2	Memory leak on sqlite3_step with Select with no result row	Memory leak on sqlite3_step with Select with no result row  Create table eventsout (mobpid integer primary key, eventdate text, eventtime text, senddate text, sendtime text, eventid integer, eventdata blob);  Select EventID, MobPID, EventDate, EventTime, EventData from eventsout where SendDate is NULL order by EventDate, EventTime;  sqlite3_step on that select consumes about 4KB of memory that is not returned on free-statement.  (Also tested SQLite 3.2.2 with same code; no memory problem !)  System: WindowsXP VS.Net 2005; using sqlite sources	_2006-Jun-08 12:59:38 by drh:_ {linebreak} Unable to reproduce.  Extensive internal checks inside SQLite reveal no memory leaks.  {link: http://valgrind.org/ Valgrind} also finds nothing.  Perhaps you have omitted you call to sqlite3_finalize?
#c8c8c8	1834	code	closed	2006 Jun	anonymous		2006 Jun		5	5	Can't create database with the é name (french E)	Hello, Can't create database with the é name (french E)	_2006-Jun-07 17:59:29 by drh:_ {linebreak} You have to pass the filename to sqlite3_open() as UTF-8. You cannot use the microsoft codepage.
#f2dcdc	1833	doc	active	2006 Jun	anonymous	Unknown	2006 Jun	drh	4	3	PRAGMA legacy_file_format not documented	[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).	
#c8c8c8	1832	code	closed	2006 Jun	anonymous		2006 Jun		1	1	Segmentation fault when placing a 0 limit on a joined subquery.	A segmentation fault occurs when running a nested query with a 0 limit on the inner query.  SQL commands to recreate the problem:    CREATE TABLE a (id INTEGER PRIMARY KEY);   CREATE TABLE b (id INTEGER PRIMARY KEY);   SELECT * FROM (SELECT * FROM a LIMIT 0) JOIN b;  SQLite should crash when trying to handle the SELECT.  Note that the following SELECT statement does *not* cause a crash:    SELECT * FROM (SELECT * FROM a LIMIT 1) JOIN b;  This bug only appears to occur on some architectures. It occurs on an Intel web server that I am working on but not on my desktop PowerPC Mac. The output of "uname -a" for the Intel machine is:    Linux www2 2.6.15-1-486 #2 Mon Mar 6 15:19:16 UTC 2006 i686 GNU/Linux  (Apologies if I've misclassified this ticket.)	_2006-Jun-06 17:50:24 by drh:_ {linebreak} Duplicate of #1784 and #1793.
#cfe8bd	1831	code	fixed	2006 Jun	anonymous	Unknown	2006 Jun	anonymous	2	1	Crash when using a certain type of index	I managed to get SQLite to crash by executing the code below. To reproduce the problem, copy & paste the following lines to the SQLite command-line shell. I'm using Win2K Pro and the shell utility downloadable from http://www.sqlite.org/sqlite-3_3_5.zip.  The crash can be prevented by A) not creating the index, or B) leaving either n1 or n2 out of the index definition, or C) uncommenting the line INSERT INTO t2 VALUES( 8, 1, '123' );  In other words, if we have an index on both the n1 and n2 columns of the t1 table, and the innermost subselect produces no results, a crash occurs.   
 -- Drop'n'Create DROP INDEX idx; DROP TABLE t1; DROP TABLE t2; CREATE TABLE t1( id INT PRIMARY KEY, n1 INT, n2 INT, name TEXT ); CREATE TABLE t2( n2 INT, dt INT, val );  -- val has no affinity  -- Insert some rows INSERT INTO t1 VALUES( 1, 5, NULL, 'jkl' ); INSERT INTO t1 VALUES( 2, 6, 5, 'def' ); INSERT INTO t1 VALUES( 3, 7, 6, 'abc' ); INSERT INTO t1 VALUES( 4, 8, 6, 'ghi' ); -- INSERT INTO t2 VALUES( 8, 1, '123' );  -- Create index CREATE INDEX idx ON t1( n1, n2 );  -- Query SELECT n1 FROM t1 WHERE name = 'abc' AND n2 IN (     SELECT n1     FROM t1     WHERE name = 'def'     AND n1 IN (         SELECT n2         FROM t1         WHERE Name = 'ghi'         AND n1 IN (             SELECT n2             FROM t2             WHERE val = '123'         )     ) AND n2 IN (         SELECT n1         FROM t1         WHERE name = 'jkl'     ) ); 
Thank you for a very clean and concise bug report! I wish that all bug reports where as easy to read and as easy to reproduce as this one. As it happens, this is the same problem that was reported in ticket #1807 and has already been fixed by [3184]. #cfe8bd 1830 code fixed 2006 Jun anonymous Unknown 2006 Jun 2 1 Problem with INNER JOIN following LEFT JOIN to table with UNIQUE INDEX If executing a SELECT statement with an INNER JOIN following a LEFT JOIN to a table that has a UNIQUE INDEX defined, incorrect values are returned. To illustrate this, execute the following SQL: CREATE TABLE parent1 ( parent1key INTEGER, child1key NVARCHAR, Child2key NVARCHAR, child3key NVARCHAR ); CREATE TABLE child1 ( child1key NVARCHAR, value NVARCHAR ); CREATE UNIQUE INDEX PKIDXChild1 ON child1 ( child1key ); CREATE TABLE child2 ( child2key NVARCHAR, value NVARCHAR ); INSERT INTO parent1 ( parent1key, child1key, child2key ) VALUES ( 1, 'C1.1', 'C2.1' ); INSERT INTO child1 ( child1key, value ) VALUES ( 'C1.1', 'Value for C1.1' ); INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.1', 'Value for C2.1' ); INSERT INTO parent1 ( parent1key, child1key, child2key ) VALUES ( 2, 'C1.2', 'C2.2' ); INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.2', 'Value for C2.2' ); INSERT INTO parent1 ( parent1key, child1key, child2key ) VALUES ( 3, 'C1.3', 'C2.3' ); INSERT INTO child1 ( child1key, value ) VALUES ( 'C1.3', 'Value for C1.3' ); INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.3', 'Value for C2.3' ); SELECT parent1.parent1key, child1.value, child2.value FROM parent1 LEFT OUTER JOIN child1 ON child1.child1key = parent1.child1key INNER JOIN child2 ON child2.child2key = parent1.child2key; Note that the results are as follows: 1|Value for C1.1|Value for C2.1 2|Value for C1.1| 3|Value for C1.3|Value for C2.3 The second row is incorrect and the results should be: 1|Value for C1.1|Value for C2.1 2||Value for C2.2 3|Value for C1.3|Value for C2.3 If the CREATE UNIQUE INDEX... statement is removed from the above SQL and the test repeated, the results are then correct! _2006-Jun-06 11:28:15 by drh:_ {linebreak} This appears to be a continuation of ticket #1652 which I did not quite get completely fixed. ---- _2006-Jun-06 13:08:55 by anonymous:_ {linebreak} It may be worth noting for users with earlier versions of SQLite that the CROSS JOIN recommended workaround for the related ticket #1652 also works for this query: SELECT parent1.parent1key, child1.value, child2.value FROM parent1 LEFT OUTER JOIN child1 ON child1.child1key = parent1.child1key CROSS JOIN child2 ON child2.child2key = parent1.child2key; #c8c8c8 1829 code closed 2006 Jun anonymous 2006 Jun 1 1 Odbc driver parameter bind offset pointer does not work ODBC driver does not use parameter bind offset pointer: SQLSetStmtAttr and SQL_SQL_ATTR_PARAM_BIND_OFFSET_PTR does not work I can provide a sample project demonstrating this defect if needed. _2006-Jun-05 01:09:02 by anonymous:_ {linebreak} ODBC problems should be reported to its creator, or perhaps the SQLite mailing list. This is a bug system for the SQLite library only. #c8c8c8 1828 code closed 2006 Jun anonymous 2006 Jun 1 3 if not exists doesn't work with a qt program I'm designing. I can work around this in the code by not checking for an error, but it would be nice to have this work properly. Error: near "NOT": syntax error Unable to execute statement where my statemet is: create table if not exists agent(id int primary key, firstname varchar(25), lastname varchar(25)) _2006-Jun-02 17:25:26 by drh:_ {linebreak} Works when I try it. Are you sure you are linking against version 3.3.5 and not an earlier version of SQLite from before it support IF NOT EXISTS? You can check by invoking "SELECT sqlite_version()" from within your program. #f2dcdc 1817 new active 2006 May anonymous 2006 Jun 1 2 Patch to enable SQLite again on OS/2 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. #cfe8bd 1803 code fixed 2006 May anonymous Unknown 2006 Jun 3 3 sqlite3WinOpenReadWrite() passes wrong share parms to CreateFile() In os_win.c, sqlite3WinOpenReadWrite() uses the windows API CreateFile() to open the database file. It passes FILE_SHARE_READ|FILE_SHARE_WRITE as the share parameter when it tries to open the file read/write, but when it tries read-only, it uses FILE_SHARE_READ. This precludes the current process or any other process on this or any other machine from subsequently opening the file read/write. Processes that open the file previous to this one are still read/write. Note that this messes up wrappers that have no choice but to determine at the time of sqlite3_open if the file is read/write or read-only. In normal operation, the read-only state is stored by the wrapper at the beginning of program operation (say, as read/write), then, if a read-only process opens after the read/write process, but before the read/write does anything to the file, the read/write process will actually open the file _then_, and SQLite will return an error: "SQL Logic error or Missing database", because it actually gets opened read-only by sqlite3WinOpenReadWrite(). Fix by replacing FILE_SHARE_READ with FILE_SHARE_READ|FILE_SHARE_WRITE. _2006-May-12 16:22:30 by anonymous:_ {linebreak} I am beginning to wonder how this works. I posted this ticket here and posted a question about the code on the mailing list but have gotten no response. And it's not that I am a lonely guy waiting for some attention, I just think that this really is a potentially serious issue. Has anyone read this ticket? If so, are there any comments? ---- _2006-May-12 17:50:19 by anonymous:_ {linebreak} I have read both, the mailing list report and the bug report, and to be honest I am not sure what you are reporting. I think you are saying that the open flags used for a read only connection prevents read/write access by another process using another connection. But I'm not sure. Since there is no mechanism for specifying the open mode on sqlite3_open, I can only assume that it is deriving the mode from the access allowed by the storage (i.e. read only on read only media, say CD, or a file system directory with read only access for the current user). Your report implies that FILE_SHARE_READ with not allow the file to be opened for writing by any other user. If this is the case, then there does seem to be an issue, since another user (with write access allowed to the file and its directory) should be able to open the file for writing. SQLite's internal locking should resolve conflicts between readers and writers as they access the tables in the database. ---- _2006-May-12 20:31:39 by anonymous:_ {linebreak} It is entirely likely that I am not as clear as I think I am. Your analysis is essentially correct. In addition, consider the following scenario: Process A opens a database as read/write using sqlite3_open, but performs no activity on the file (the file is not actually opened by SQLite because it has not yet called sqlite3WinOpenReadWrite()). In the cource of looking at the file, the wrapper used by Process A has determined that the database should be available for writing. Later on, process B opens the same database as read-only because the user has lower access rights. Process B then reads something from the database. The share flags passed to CreateFile() in sqlite3WinOpenReadWrite() place a file lock on the database, preventing any subsequent opens for writing. Later still, process A decides it is time to write to the database. Somewhere in SQLite, a call is made to sqlite3WinOpenReadWrite() and the file is opened for read-only access (because of the share parameters passed to CreateFile() by process B), and the subsequent attempt to write to the database fails. The user of process A sees the error "SQL Logic error or missing database". What is worse is that if process B had not opened the database, or if it had read/write rights to the file, the error would not have occurred. This would be difficult to track down. ---- _2006-May-25 16:12:55 by anonymous:_ {linebreak} I am still not sure how this open source thing works. I have posted in lay-programmer's terms where the problem lies and how to fix it. What usually happens next? ---- _2006-May-25 16:30:07 by anonymous:_ {linebreak} You could grab SQLite from CVS, alter the code, and then run the test suite on your platform. If there are no regressions, post a patch (cvs diff -u) of the proposed change to the ticket or the mailing list for discussion. ---- _2006-Jun-01 20:14:38 by anonymous:_ {linebreak} I tried getting to the cxvs repository with cvsnt. Here is the trace: E:\cvsnt>cvs -d :pserver:anonymous@www.sqlite.org:/sqlite login Logging in to :pserver:anonymous@www.sqlite.org:2401:/sqlite CVS password: ********* cvs [login aborted]: connect to www.sqlite.org:2401 failed: No connection could be made because the target machine actively refused it. I really have no idea about cvs and wonder if it wouldn't be much easier (and less error-prone) for someone else to do this instead. ---- _2006-Jun-01 22:26:58 by anonymous:_ {linebreak} I have modified the current CVS source with this proposed change and run the test suite with no failures. I have also attached a patch to os_win.c that implements this change. ---- _2006-Jun-02 11:53:33 by anonymous:_ {linebreak} this is a important fix. will it be incorporated into SQLite ? ---- _2006-Jun-02 14:22:11 by anonymous:_ {linebreak} The sqlite3WinOpenReadOnly() routine suffers the same problem. It doesn't honor sharing flags on CreateFileA/W calls. If you open a database using it, you get a exclusive access to the file. See what is needed to fix this issue:

   ...    if( zWide ){     h = CreateFileW(zWide,        GENERIC_READ,        0,        NULL,        OPEN_EXISTING,        FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,        NULL     );     sqliteFree(zWide);   }else{ #if OS_WINCE     return SQLITE_NOMEM; #else     h = CreateFileA(zFilename,        GENERIC_READ,        0,        NULL,        OPEN_EXISTING,        FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,        NULL     ); #endif      ... 
They need to be changed to:
   ...    if( zWide ){     h = CreateFileW(zWide,        GENERIC_READ,        FILE_SHARE_READ | FILE_SHARE_WRITE,        NULL,        OPEN_EXISTING,        FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,        NULL     );     sqliteFree(zWide);   }else{ #if OS_WINCE     return SQLITE_NOMEM; #else     h = CreateFileA(zFilename,        GENERIC_READ,        FILE_SHARE_READ | FILE_SHARE_WRITE,        NULL,        OPEN_EXISTING,        FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,        NULL     ); #endif      ... 
#cfe8bd 1771 code fixed 2006 Apr anonymous Shell 2006 Jun 5 4 sqlite3 -version should return 0 Is there any specific reasons that "sqlite3 -version" is returning 1 instead of 0? I am using sqlite3 -version to store the sqlite3 version in one of my build scripts, inside MAKEFILE, and I have to do "-sqlite3 -version" to get make to ignore the error. As I understand, most of the tools return 0 for a -version or --version query. #cfe8bd 1696 build fixed 2006 Feb anonymous Unknown 2006 Jun 4 4 obsolete "sort +4" and friends Makefile.in and main.mk use outdated syntax for some utilities. They invoke "sort +4" and "sort -n -b +2". These should operate on the file called "+4" or "+2" according to the most recent POSIX versions. GNU coreutils hence fails on them unless a special variable is set that forces an older POSIX standard. Please replace these calls with the more standard "sort -k 5" and "sort -n -b -k 3". These files also contain a "tail -1". GNU coreutils 5.2.x refused it, however, 5.9x allows it again. But to be more consistent with POSIX standard, I highly recommend to use "tail -n 1" here. PS: I have no information about other platforms than GNU/Linux whether this newer syntax works there. Maybe some auto-detection logic would be needed too. _2006-Mar-03 19:57:31 by drh:_ {linebreak} If it is true that posix has changed in a backward incompatible way as decribed above, then my suspicions that the posix committee is run by Dilbert's pointy-headed boss are confirmed. If you are going to change the way "sort" and "tail" work, why not just delete them from the system all together, since they have now become useless for any script or Makefile that intends to be portable. I have no intention of cooperating with changes to posix that are not backwards compatible and I will resist them for as long as possible. ---- _2006-Mar-06 17:29:43 by anonymous:_ {linebreak} While the decision to change the POSIX utilities in backward incompatible ways is regrettable, that decision has already been made. Your protests will probably fall on deaf ears (if any at all). Your inflexibility in adapting to these changes will only hurt those who use SQLite. It will have no effect on those responsible for producing the POSIX standard. ---- _2006-Mar-06 17:59:12 by drh:_ {linebreak} There is a simple work-around: People running on new (a.k.a "broken") posix systems can compile from the pre-processed source code just like Windows users have always had to do. The change in posix simply means that the configure script will not work any more. I seriously doubt that SQLite is the only project that new posix has broken. I will personally be in no hurry to add validity to the posix committee's folly by changing SQLite to use their new, broken design. If this issue is important to you and you care to submit patches, I will consider them. Just do not look to me to go cleaning up the mess that the posix committee has made of things. #f2dcdc 1743 code active 2006 Mar anonymous Parser 2006 Mar 3 3 A very very deep IN statement failure 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 #f2dcdc 1742 code active 2006 Mar anonymous Unknown 2006 Mar drh 2 3 ORDER BY on more than one column causes a big slowdown 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:_ {linebreak} 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:_ {linebreak} Note also that this behavior is being exhibited when sorting on *indexed* columns ---- _2006-Mar-29 01:50:38 by drh:_ {linebreak} Some examples would be helpful. ---- _2006-Mar-29 18:11:43 by anonymous:_ {linebreak} Most definitely! I will attach a sample 3.3.4 database dump, that displays this behavior. #f2dcdc 1741 warn active 2006 Mar anonymous VDBE 2006 Mar 5 4 unused variable with SQLITE_OMIT_UTF16 defined 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. #c8c8c8 1739 code closed 2006 Mar anonymous Unknown 2006 Mar 4 1 sqlite3_bind_int on UPDATE * SET COLUMN1='Test' WHERE ID=? I've got the following problem:{linebreak} SQL: UPDATE SOFTWARE SET Title=? WHERE ID=?{linebreak}{linebreak} My code:{linebreak} sqlite3_bind_text(res, 0, "Test", -1, SQLITE_STATIC);{linebreak} sqlite3_bind_int64(res, 1, 1); // This should update ID=? to ID=1{linebreak}{linebreak} Right? The function succeeds (including sqlite3_step), but it doesn't update the row with ID=1{linebreak} It seems that there's a bug in the bind, because when I write the ID# in the SQL, it works _2006-Mar-28 19:17:59 by anonymous:_ {linebreak} Parameter indexes are 1-based, not zero based. ---- _2006-Mar-28 19:28:53 by anonymous:_ {linebreak} Thnx... Just found out, wanted to post it =P very dump mistake =P #c8c8c8 1738 code closed 2006 Mar anonymous Unknown 2006 Mar a.rottmann 1 1 The function "sqlite3_get_table" doen't do well with blob data. When I get my blob data in my database using function "sqlite3_get_table", I find that it will loss some data. I think that the function "sqlite3_get_table" refers to the "strlen", so it will cut some data which it has '\0' in it. _2006-Mar-28 12:23:18 by drh:_ {linebreak} The sqlite3_get_table() API is not intended for use with BLOBs. This is a legacy API held over from the days before SQLite supported BLOBs. If you need to access a BLOB, use the sqlite3_prepare()/sqlite3_step()/sqlite3_finalize() API chain. #cfe8bd 1737 code fixed 2006 Mar anonymous Unknown 2006 Mar 1 1 Duplicate name object created I was using the "SQLite Administrator" while met with this bug on Windows 2003 SP1 Simplifed Chinese: The reproduce procedure: 1, Create a table. 2, Create a trigger, 3, Uses "Database/Database SQL" to show the database schema, like the following: CREATE TABLE "Test" ( "Name" NVARCHAR(500) NOT NULL PRIMARY KEY ); CREATE TRIGGER "Test2" AFTER INSERT ON "Test" FOR EACH ROW BEGIN Select count(*) from Test ; END; 4, Use "Query/Query with Result", An error saying that an object named "Test" is already exists. 5, Remove the "Create Table" statement. And issue the "Query/Query with Result" again. One more trigger with the name "Test2" was created. _2006-Mar-28 12:29:04 by drh:_ {linebreak} This appears to be a bug in SQLite Adminstrator, not in SQLite. SQLite Adminstrator is a separate project that happens to use SQLite. The bugs reported here are for SQLite only. We have no ability to fix or modify the SQLite Administrator tool. I checked on the SQLite Administrator website and I do not see any links there for reporting bugs. Does anybody know how to report a bug against SQLite Administrator? ---- _2006-Mar-28 23:05:50 by anonymous:_ {linebreak} Hello, iam the developer of SQLite Administrator. I got a Mail today with a Bugreport for this Problem. But this problem is by sqlite itself! So i said to the user he schould report this here. I tried your Commandline Tool: c:\Downloads\sqlite>sqlite3 test.s3db SQLite version 3.3.4 Enter ".help" for instructions sqlite> select * from sqlite_master ...> ; table|temp|temp|2|CREATE TABLE "temp" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(10) NULL ) table|sqlite_sequence|sqlite_sequence|3|CREATE TABLE sqlite_sequence(name,seq) trigger|test1|temp|0|CREATE TRIGGER "test1" AFTER UPDATE OF "NAME" ON "temp" FOR EACH ROW BEGIN update temp set name = new.name where id = old.id; END sqlite> create trigger "test1" after update of "name" on "temp" for ...> each row begin update temp set name = new.name where id = old.id; end ...> ; sqlite> select * from sqlite_master ...> ; table|temp|temp|2|CREATE TABLE "temp" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(10) NULL ) table|sqlite_sequence|sqlite_sequence|3|CREATE TABLE sqlite_sequence(name,seq) trigger|test1|temp|0|CREATE TRIGGER "test1" AFTER UPDATE OF "NAME" ON "temp" FOR EACH ROW BEGIN update temp set name = new.name where id = old.id; END trigger|test1|temp|0|CREATE TRIGGER "test1" after update of "name" on "temp" for each row begin update temp set name = new.name where id = old.id; end sqlite> so it exists 2 triggers with the same name now, if i execute a "drop trigger test1;" statement now, the cmdline tool will crash. #c8c8c8 1736 code closed 2006 Mar anonymous Unknown 2006 Mar 4 4 #define SQLITE_OMIT_ALTERTABLE causes unresolved externals When I defined SQLITE_OMIT_ALTERTABLE and SQLITE_OMIT_REINDEX (and couple of other options) I got linker errors: parse.obj : error LNK2001: unresolved external symbol _sqlite3AlterBeginAddColumn@8 parse.obj : error LNK2001: unresolved external symbol _sqlite3AlterFinishAddColumn@8 parse.obj : error LNK2001: unresolved external symbol _sqlite3AlterRenameTable@12 parse.obj : error LNK2001: unresolved external symbol _sqlite3Reindex@12 Using Intel C++ 7.0 plugged in VC++ 6 IDE, 3.3.4 fully generated source. _2006-Mar-28 06:54:24 by anonymous:_ {linebreak} I now realize that one should re-generate parser.c for changed settings. #f2dcdc 1735 code active 2006 Mar anonymous Unknown 2006 Mar 1 3 Encoding problem 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:_ {linebreak} 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:_ {linebreak} 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 -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. #c8c8c8 1734 code closed 2006 Mar anonymous Parser 2006 Mar drh 5 5 when not null is before integer primary key, syntax error occurs SQLite version 3.3.4 Enter ".help" for instructions sqlite> create table test (id not null integer primary key); SQL error: near "integer": syntax error sqlite> _2006-Mar-27 15:01:22 by anonymous:_ {linebreak} this is a incorret SQL statement. must be CREATE TABLE test (id integer not null primary key) #f2dcdc 1733 code active 2006 Mar anonymous VDBE 2006 Mar drh 4 3 Unaligned Access on ia64: aggregate_context ptr isn't 16-bytes aligned 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:_ {linebreak} Additional details can be found in this mailing list thread: http://thread.gmane.org/gmane.comp.db.sqlite.general/18144 #f2dcdc 1732 doc active 2006 Mar anonymous 2006 Mar 5 5 Info on Home page 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% #f2dcdc 1731 doc active 2006 Mar anonymous 2006 Mar 5 5 Typo in select4.test # 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 #c8c8c8 1730 new closed 2006 Mar anonymous 2006 Mar 2 5 referential integrity do u have any plan to support referential integrity _2006-Mar-24 19:10:04 by drh:_ {linebreak} Please ask questions like this on the mailing list. Tickets are for reporting bugs. See http://www.sqlite.org/support.html for instructions on how to subscribe to the mailing list. #c8c8c8 1729 code closed 2006 Mar anonymous 2006 Mar 1 1 SQLite loses precision on 64-bit integers I need full precision on 64-bit integers that I insert into SQLite. If I put in 15687216181554097151, I need to pull out 15687216181554097151 instead of 1.56872161815541e+19. I am working with 64-bit integers as my primary datatype and so the loss of precision is a deal-breaker for my project. _2006-Mar-24 16:56:19 by drh:_ {linebreak} SQLite uses 64-bit *signed* integers having a range of -9223372036854775808 to 922372036854775807. The number you specify is outside of this range, cannot be represented as a 64-bit signed integer, and is therefore converted into a floating point value. There are no plans to modify SQLite to support larger integers at any time in the near future. ---- _2006-Mar-24 16:59:59 by anonymous:_ {linebreak} Actually the field I'm storing that in is of type "BIGINT UNSIGNED". ---- _2006-Mar-24 17:02:50 by drh:_ {linebreak} There are also no plans to modify SQLite to support unsigned integers. ---- _2006-Mar-24 17:27:50 by anonymous:_ {linebreak} Yes, but SQLite doesn't support unsigned ints. You will have to cast your unsigned ints to signed ints before saving them into the sqlite database, and similarly cast them from signed back to unsigned when you retreive them. The biggest difficulty will ocurr if you are doing comparisons in your queries. You will need to convert simple comparisons into a more comlex comparisons that handle the wrapping of your large unsined values into negative values. For comparisons like x > k; if k converts to a positive signed value you need (x > k OR x < 0) if k converts to a negative signed value you need (x > k AND x < 0) Similarly for comparisons like x < k; if k >= 0, (x < k AND x >= 0) if k < 0, (x < k OR x >= 0) Also, you will need to define a custom collation function to sort by your unsigned values if you need to do sorts on those values. ---- _2006-Mar-24 18:04:20 by anonymous:_ {linebreak} He could always create functions to do the unsigned comparisions he needs. #cfe8bd 1728 code fixed 2006 Mar drh VDBE 2006 Mar 1 1 Integrity_check fails after dropping tables in autovacuumed database The following SQL code reports database corruption: PRAGMA auto_vacuum=1; CREATE TABLE t1(a, b); CREATE INDEX i1 ON t1(a); CREATE TABLE t2(a); CREATE INDEX i2 ON t2(a); CREATE TABLE t3(a); CREATE INDEX i3 ON t2(a); CREATE INDEX x ON t1(b); DROP TABLE t3; PRAGMA integrity_check; DROP TABLE t2; PRAGMA integrity_check; DROP TABLE t1; PRAGMA integrity_check; The corruption report is an illusion - the database is not damaged in any way. SQLite has just become confused. Closing and reopening the database clears the problem. #cfe8bd 1727 code fixed 2006 Mar drh 2006 Mar 1 1 Assertion fault on autovacuum :memory: database When run against a :memory: database, the following SQL causes an assertion fault: PRAGMA auto_vacuum=1; CREATE TABLE t1(a); CREATE TABLE t2(a); DROP TABLE t1; #c8c8c8 1725 code closed 2006 Mar anonymous 2006 Mar 2 1 sql "HAVING" fails to filter query grouping "UNION ALL" subqueries Hi, the following query results empty but if you replace "UNION ALL" with "UNION" only sql sqlite works nice meaning that some records are listed. "HAVING" clause with "UNION ALL" seems to filter too much. If you need more details on it please ask me thanks in advance Federico & Claudio
 SELECT date_time as date_time,  Object as object,  SUM(Kpi.shoaddintranodebatt) AS shoaddintranodebatt,  SUM(Kpi.rtwp_max)            AS rtwp_max FROM (  SELECT datetime(strftime('%Y-%m-%d %H:00:00',                    G_PMClass4_cell.date_time)) as date_time,   G_PMClass4_cell.object as object,   SUM(shoAddIntraNodeBAtt) AS shoAddIntraNodebAtt,   null as rtwp_max  FROM G_PMClass4_cell  GROUP BY   datetime(strftime('%Y-%m-%d %H:00:00',                              G_PMClass4_cell.date_time)),   G_PMClass4_cell.object  UNION ALL  SELECT datetime(strftime('%Y-%m-%d %H:00:00',                    G_PMClass7_cell.date_time)) as date_time,   G_PMClass7_cell.object as object,   null as shoaddintranodebatt,   avg(uurectotalwbpwr_3)*0.1-112 AS RTWP_MAX  FROM G_PMClass7_cell  GROUP BY   datetime(strftime('%Y-%m-%d %H:00:00',                    G_PMClass7_cell.date_time)),   G_PMClass7_cell.object ) Kpi GROUP BY date_time,object HAVING shoaddintranodebatt > 1 
_2006-Mar-25 14:20:26 by drh:_ {linebreak} Without additional information on your schema, the content of your database, and what output you expected, I cannot reproduce this problem. If you believe this is a real problem, you will do well to resubmit this bug with test script that can be fed into the SQLite command-line client that will demonstrate the problem. Please be sure to explain how the output of the test script deviates from what you expected. #c8c8c8 1724 code closed 2006 Mar anonymous Shell 2006 Mar anonymous 1 1 sqlite doesn't work with "cifs-mounted-directories" I mounted a directory an a Windows-2000-Prof. System with cifs. I see that directory and I can edit files and start programs. But: I like to use sqlite. When I start sqlite on the host, it works perfectly. When I start sqlite from mounted directory, I get the following message: SQLite version 3.3.4 Enter ".help" for instructions sqlite> .databases Error: disk I/O error What's wrong ? _2006-Mar-25 14:10:14 by drh:_ {linebreak} This sounds like a bug in the CIFS filesystem implementation. #c8c8c8 1723 code closed 2006 Mar anonymous 2006 Mar 1 1 Crash (floating point error) when dealing with BIGINT datatypes I have a field in one of my tables which has type BIGINT UNSIGNED. Originally I was filling this with the contents of a 32-bit integer, as that's what I was using for a datatype in my software. When I switched that to 64bit integers and started constructing my queries by ulltoa()ing the 64bit values, SQLite crashed unmercifully: "INSERT INTO BD_functions VALUES (1509960689, 27, 41, 7, 13760289937621738947, 1, 0, 0, 0);" This gives a rather puzzling floating point exception. I have tested putting a smaller value in place of the fifth entry, and there is no crash. _2006-Mar-21 14:28:56 by drh:_ {linebreak} Unable to reproduce. If you still think this problem is in SQLite and not in your own code, then please provide a specific example that fails. Also tell us whether you compiled SQLite yourself or used a precompiled binary and what OS you are running. ---- _2006-Mar-22 12:47:39 by anonymous:_ {linebreak} I am running Windows XP, and I have compiled SQLite into my application. I have narrowed down the crash much further and even fixed it in my copy by modifying the SQLite source code. I noticed that the application only crashes with BIGINT values which are large enough to be signed. I.e. those values >= 0x8000000000000000. To test this I wrote a program that inserted values ranging from 0x7ffffffffffffff0 upwards, and sure enough it crashed once it hit 0x80..... Given the query in the opening of this ticket, the BIGINT UNSIGNED crash takes place on the following callpath: applyAffinity calls sqlite3VdbeIntegerAffinity. This is the sixth time applyAffinity is called for this query. The following line in sqlite3VdbeIntegerAffinity crashes: pMem->i = pMem->r; I replaced the following line in vdbeInt.h from 'i64' to 'u64' and the crash went away: struct Mem { u64 i; /* Integer value. Or FuncDef* when flags==MEM_Agg */ I'm not entirely sure why the crash is happening, or why this fixes it, but there you go. While I'm here, is there any way to keep SQLite from losing precision on my BIGINT values? I need the full, lossless representation, not approximated mantissa + exponent. ---- _2006-Mar-22 14:32:46 by anonymous:_ {linebreak} What compiler are you using? Can you post this test program? ---- _2006-Mar-22 14:35:02 by drh:_ {linebreak} Still unable to reproduce. I tried the following script on both Linux and WinXP: CREATE TABLE t1(a INTEGER); INSERT INTO t1 VALUES(9223372036854775806); -- 0x7ffffffffffffffe INSERT INTO t1 VALUES(9223372036854775807); -- 0x7fffffffffffffff INSERT INTO t1 VALUES(9223372036854775808); -- Ox8000000000000000 INSERT INTO t1 VALUES(9223372036854775809); -- Ox8000000000000001 SELECT * FROM t1; It works fine. I do not know what you could be doing to get it to fail. There is nothing wrong with the line of code where the failure occurs. Your fix, however, will break lots of other things. ---- _2006-Mar-22 14:44:59 by anonymous:_ {linebreak} drh, try "BIGINT UNSIGNED" instead of INTEGER? _: _drh:_ BIGINT UNSIGNED and INTEGER mean the same thing to SQLite. ---- _2006-Mar-22 14:55:59 by anonymous:_ {linebreak} you're trying to reproduce this with the latest cvs head checkout or with 3.3.4 released source ? _: _drh:_ I tried both. ---- _2006-Mar-22 14:59:29 by anonymous:_ {linebreak} I, the original poster, am using the 3.3.4 released codebase, compiled with gcc 3.4.4 (mingw release). I am in the process of creating a small application to try to demonstrate this issue (my original crashing application is proprietary code, as a plugin to something else, so A) it would be of no use to anybody B) I can't release that). ---- _2006-Mar-22 19:09:03 by anonymous:_ {linebreak} I still can't quite figure out what's going on. Below is the sample program. If I compile this standalone, it does work. If I compile this into my plugin, I get the crash, unless I apply the changes to the Mem struct that I described earlier. /* sqltest.hpp */ #include "sqlite/sqlite3.h" #include #include #define msg printf class SQLTest { private: sqlite3 *sql_db; public: char *exec_query_no_callback(const char *query) { if(!sql_db) { msg("SQL ERROR! Trying to write to database which is not open.\n"); return ""; } char *emsg; if ( sqlite3_exec(sql_db, query, NULL, 0, &emsg) != SQLITE_OK ) { msg("SQL ERROR!\nQuery: '%s'\nError: '%s'\n", query, emsg); return emsg; } return NULL; }; bool Initialize() { int rc; char *result; rc = sqlite3_open("c:\\bd_temp\\bah.db", &sql_db); if( rc ) { msg("Can't open database: %s\n", sqlite3_errmsg(sql_db)); sqlite3_close(sql_db); sql_db = NULL; return 0; } return 1; } bool Test() { if( !Initialize() ) { msg("Initialization failed!\n"); return 0; } exec_query_no_callback("CREATE TABLE BD_functions ( " " address BIGINT UNSIGNED UNIQUE NOT NULL, " " signature_a INTEGER UNSIGNED NOT NULL, " " signature_b INTEGER UNSIGNED NOT NULL, " " signature_c INTEGER UNSIGNED NOT NULL, " " prime_product BIGINT UNSIGNED NOT NULL, " " usable_name BOOL NOT NULL, " " is_recursive BOOL NOT NULL, " " is_thunk BOOL NOT NULL, " " is_library BOOL NOT NULL); "); unsigned long address_base = 0x12345678; for(unsigned long long prime = 0x7ffffffffffffff0LL; prime <= 0x800000000000000FLL; ++prime) { char buf[5000], ullbuf[100]; ulltoa(prime, ullbuf, 10); sprintf(buf, "INSERT INTO BD_functions VALUES (%d, 1, 2, 3, %s, 1, 0, 0, 0);", address_base++, ullbuf); exec_query_no_callback(buf); } } }; /* test.cpp */ #include "sqltest.hpp" int main(int, char **) { SQLTest sqle; sqle.Test(); } ---- _2006-Mar-22 23:42:28 by anonymous:_ {linebreak} it's looking like your caller program (or another plug-in for your program) is changing the fp87 flags of your fpu unit. the exception is floating point exception, isn't it ? #cfe8bd 1721 code fixed 2006 Mar anonymous Parser 2006 Mar 3 3 wrong column names in a compound select when used as a subquery Shouldn't the following statements result in syntax errors? Or are UNIONs supposed to work like this? sqlite_version(*) 3.3.4 sqlite> select 1 as a, 2 as b UNION ALL select 3 as b, 4 as a; a|b 1|2 3|4 sqlite> select * from (select 1 as a, 2 as b UNION ALL select 3 as b, 4 as a) where b = 3; b|a 3|4 sqlite> select * from (select 1 as a, 2 as b UNION ALL select 3 as b, 4 as a) where b = 2; sqlite> select * from (select 1 as a, 2 as b UNION ALL select 3 as e, 4 as b) where b = 2; e|b 1|2 sqlite> select * from (select 1 as a, 2 as b UNION ALL select 3 as e, 4 as b) where b > 0; e|b 1|2 3|4 _2006-Mar-25 16:22:44 by anonymous:_ {linebreak} I don't think these queries are invalid by SQL standards, but they do show an inconsistancy in SQLite's column name lookup algorithm for subqueries. sqlite> select 1 as a, 2 as b UNION ALL select 3 as b, 4 as a; a|b 1|2 3|4 Considering the previous select results, I would expect the following select to return no rows: sqlite> select * from (select 1 as a, 2 as b UNION ALL select 3 as b, 4 as a) where b = 3; b|a 3|4 The other queries are just variations on this. ---- _2006-Mar-26 16:39:43 by anonymous:_ sqlite/test/select4.test 1.18 -> 1.19 +# Make sure the names of columns are takenf rom the right-most subquery +# right in a compound query. Ticket #1721 I think you mean left-most? #f2dcdc 1720 new active 2006 Mar anonymous 2006 Mar 3 4 Actions made by a trigger are not triggered 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} Finally I've found the limitation here : http://www.sqlite.org/omitted.html #f2dcdc 1719 code active 2006 Mar anonymous 2006 Mar 4 4 Solaris 8(SQL: bus error while creating temporary file 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)); } #f2dcdc 1718 new active 2006 Mar anonymous 2006 Mar 1 1 allow *.sqlite as parameter to sqlite3_analyzer 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.. #cfe8bd 1717 code fixed 2006 Mar drh CodeGen 2006 Mar drh 1 1 CHECK constraints always use ABORT conflict resolution When CHECK constraints fail, they always cause the operation to ABORT. Alternative conflict resolution algorithms such as REPLACE, IGNORE, FAIL, or ROLLBACK are ignored. REPLACE does not make sense for the resolution of a CHECK constraint. If REPLACE is specified, then the algorithm should be IGNORE. The other algorithms: IGNORE, FAIL, and ROLLBACK, all do make sense and should be implemented. #cfe8bd 1716 doc fixed 2006 Mar anonymous 2006 Mar 5 4 sqlite3_db_handle() has wrong documented signature Hi again! A doc correction: http://sqlite.org/capi3ref.html#sqlite3_db_handle says that the signature for sqlite3_db_handle() is: int sqlite3_db_handle(sqlite3_stmt*); The sources define it as: vdbeapi.c:sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt) Take care, ----- stephan #c8c8c8 1715 doc closed 2006 Mar anonymous 2006 Mar 5 4 int sqlite3_release_memory(int) documented but not implemented http://sqlite.org/capi3ref.html#sqlite3_release_memory That function doesn't appear to be implemented anywhere, nor does the SQLITE_ENABLE_MEMORY_MANAGMENT macro (referenced by the docs) appear to be used anywhere: me@host:src/sqlite-3.2.7 >grep sqlite3_release_memory $(find . -type f) me@host:src/sqlite-3.2.7 >grep ENABLE_MEMORY_MANAGMENT $(find . -type f) (no results) _2006-Mar-13 14:29:38 by drh:_ {linebreak} These features added in version 3.3.0. #f2dcdc 1714 code active 2006 Mar anonymous CodeGen 2006 Mar 4 4 Slow query when tables in 2 different files 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 #cfe8bd 1713 code fixed 2006 Mar anonymous Unknown 2006 Mar 2 2 Cannot open datafiles in folders with special characters I'm using SQLite on Windows and place a data file in the users Application Data folder. A pretty big problem was found today. A French user reported that my application could not open its datafile. It turns out his name has an accented e in it (é), and that SQLite cannot access datafiles in folders with special characters such as that. My datafile was in C:\documents and settings\hisname withé\Application Data\AppName\database.dat The error returned by open(.) is SQLITE_CANTOPEN. _2006-Mar-10 17:12:47 by anonymous:_ {linebreak} See ticket #1533 for a discussion about the problem. ---- _2006-Mar-15 22:15:02 by anonymous:_ {linebreak} OK, I read about the issue in that case, but I don't get it. I'm not much into these charset issues. Is there a workaround or is somebody working on a fix? This problem causes my application to fail on many French PCs :-( ---- _2006-Mar-16 11:00:59 by anonymous:_ {linebreak} The current solution is either to stick to version 3.2.5 or convert the file path string to UTF-8. ---- _2006-Mar-25 14:04:50 by drh:_ {linebreak} The filename input to sqlite3_open() must be UTF-8, not whatever codepage happens to be active in windows. THe documentation has been enhanced to emphasize this. #c8c8c8 1712 code closed 2006 Mar anonymous 2006 Mar 1 1 aggregate function return empty row select sum(disk_size) from tblStudies this command returns row on sqlite3_step (empty row, with MEM_Null records) even on zero database. should return error on fetch _2006-Mar-25 15:56:08 by drh:_ {linebreak} I think sum() an empty set is suppose to return NULL. I admit that this is a useless return value but it is apparently what SQL requires. #cfe8bd 1711 code fixed 2006 Mar anonymous 2006 Mar 1 2 Wrong header names when using subselects with 3.3.4 (3.3.1 is OK) Note '
' in the dump below. 3.3.1 gives '' there (as expected). c:\sqlite>sqlite334.exe -echo -header -html :memory: < test.sql create table test_table (test_field integer); insert into test_table values (1); select test_field+1 as test from test_table; select test from (select test_field+1 as test from test_table); #cfe8bd 1709 code fixed 2006 Mar anonymous 2006 Mar 1 1 sqlite3_column_name not apply column alias for views create table a (i integer); create view v_a as select i as Col1 from a; select Col1 from v_a sqlite3_column_name return i instead expected Col1! It happens for 3.3.4. In 3.3.1 was correct. _2006-Mar-08 12:56:58 by anonymous:_ {linebreak} this is the same problem as ticket #1688 #c8c8c8 1708 code closed 2006 Mar anonymous Unknown 2006 Mar anonymous 4 3 Spurious warning: no such table: faculty(1) at dbdimp.c line 269 This was discovered using the Perl module DBD::SQLite V 1.11, which I believe, from its change log, ships with V 3.2.7 of SQLite. The error msg is: DBD::SQLite::db do failed: no such table: faculty(1) at dbdimp.c line 269 at /perl/site/lib/CGI/Appl ication/Demo/Create.pm line 201. What follows is from an email I wrote to a Perl user who reported this problem to the (Perl module) CGI::Session mailing list: I tested SQLite with my module CGI::Application::Demo, which is designed to probe strange environments, by patching the config file cgi-app-four.conf. And I get the same error! It's caused by a bug in SQLite, which emits this error when you create the database file (as in dsn=dbi:SQLite:dbname=/temp/cgi-app-demo.db) for the first time, and then try a command such as eval{$$self{'_dbh'} -> do("drop table $table_name")}; The program I was running to prove this (under Win2K) is create.pl, which ships with CGI::Application::Demo The error msg is emitted despite the eval. By running create.pl repeatedly, with and without first deleting /temp/cgi-app-demo.db, proves that if the database file is present, SQLite does not emit this msg, but if the database file is absent, so that running the program must create it, then the error msg is emitted by the drop table statement. In your case, some other stmt causes the error, but it's the same problem. I believe that the problem arises with the very first SQL command executed after the database file is created. _2006-Mar-07 11:49:36 by anonymous:_ {linebreak} this bug should be addressed to DBD::SQLite developers, not to SQLite developers. Or ask the mailing list. ---- _2006-Mar-07 14:41:52 by drh:_ {linebreak} I concur with the anonymous poster above. This ticket should be moved to the DBD::SQLite page at cpan. http://search.cpan.org/dist/DBD-SQLITE/ #c8c8c8 1707 code closed 2006 Mar anonymous Unknown 2006 Mar 4 4 Internal data are not naturaly aligned, which could affect perfomance The code arrange internal data not naturally aligned. This effects performance on some arches (Alpha in my case). For example: build.c around line number 2359 there is a code - pIndex = sqliteMalloc( sizeof(Index) + /* Index structure */ sizeof(int)*nCol + /* Index.aiColumn */ sizeof(int)*(nCol+1) + /* Index.aiRowEst */ sizeof(char *)*nCol + /* Index.azColl */ sizeof(u8)*nCol + /* Index.aSortOrder */ nName + 1 + /* Index.zName */ nExtra /* Collation sequence names */ ); if( sqlite3MallocFailed() ) goto exit_create_index; pIndex->aiColumn = (int *)(&pIndex[1]); pIndex->aiRowEst = (unsigned *)(&pIndex->aiColumn[nCol]); pIndex->azColl = (char **)(&pIndex->aiRowEst[nCol+1]); pIndex->aSortOrder = (u8 *)(&pIndex->azColl[nCol]); The alignment of azColl structure member is determined by allocation of previous members. But alignment of azColl should be equal to sizeof(char *) because it is array of pointers. There should be padding used or some other alignment techniques. Thank you, _2006-Mar-06 14:55:20 by drh:_ {linebreak} Already fixed in 3.3.4. See check-in [3079]. #c8c8c8 1706 code closed 2006 Mar anonymous 2006 Mar 1 2 Group operations like ORDER BY don't work after renaming a table Once a table is renamed, group operations like ORDER BY do not work on that table anymore. _2006-Mar-06 12:00:47 by drh:_ {linebreak} Unable to reproduce. If you want to reopen this ticket, please provide a specific example of a sequence of SQL statements that exhibits the alleged malfunction. --------------------------------------------------- Reopening this with how-to-reproduce instructions. Open the attached db using sqlite3 (3.3.4) and run the query "SELECT * FROM Undo_Data;". This shows that there are rows in the table and when you run the query "SELECT * FROM Undo_Data ORDER BY EntryId;", it returns 0 rows. EntryId is of type INTEGER affinity. Since the tracking system doesn't allow us to attach a file at the same time as we edit the ticket, will attach the file in the next update... Thanks, Subhash ---- _2006-Mar-06 15:15:27 by drh:_ {linebreak} I can clearly see that the database you provide is corrupt. The question is, how did it get that way. The only hint you have provided is that you did some "rename table" actions. I am unable to reproduce the problem here. If you want me to fix this, please provide details of how you generated the error. Showing me the database after the error is some help, but not much. What I really need to know is what you did you to get the database into its current state. For me to learn this, you need to communicate it to me in the trouble ticket because I cannot read your mind. As a temporary workaround, you can clear the problem using either of the following commands: REINDEX; VACUUM; #c8c8c8 1705 code closed 2006 Mar anonymous Unknown 2006 Mar 4 4 Default column constant doesn't assign value on NULL insert Running on Windows XP with sqlite 3.3.4, I create a table with one column having a default value of CURRENT_TIMESTAMP. But when inserting into this table with a NULL for that column, I get an error instead of the column getting the default value. Here is the output: _:sqlite3 test.db _:SQLite version 3.3.4 _:Enter ".help" for instructions _:sqlite> CREATE TABLE undo ( _::idx INTEGER NOT NULL, _::date_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, _::sql TEXT NOT NULL, _::PRIMARY KEY (idx), _::UNIQUE (idx) _::); _:sqlite> insert into undo values (NULL,NULL,'test string'); _:SQL error: undo.date_time may not be NULL So I tried again with a constant for the default with the same results. _:sqlite> CREATE TABLE redo ( _::idx INTEGER NOT NULL, _::date_time TIMESTAMP NOT NULL DEFAULT 'ABC', _::sql TEXT NOT NULL, _::PRIMARY KEY (idx), _::UNIQUE (idx) _::); _:sqlite> insert into redo values (NULL,NULL,'insert into etc'); _:SQL error: redo.date_time may not be NULL _:sqlite> It appears that the not null constraint is processed first and prevents the default from being assigned. _2006-Mar-03 19:33:52 by drh:_ {linebreak} I am told that the SQLite's current behavior is correct. If you want to insert the default value, omit the column from the VALUES clause completely. If you explicitly say NULL then a NULL will be inserted. #f2dcdc 1704 new active 2006 Mar anonymous 2006 Mar 4 3 extern "C" block in sqliteInt.h 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. #f2dcdc 1703 new active 2006 Mar anonymous Pager 2006 Mar 2 3 Second parameter to gettimeofday() in os_unix.c should be NULL 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. #f2dcdc 1702 new active 2006 Mar anonymous 2006 Mar 5 4 feature request: API to write in-memory DB to file. 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:_ {linebreak} There have been already good solutions. Watch this wiki page. http://www.sqlite.org/cvstrac/wiki?p=InMemoryDatabase #f2dcdc 1701 doc active 2006 Mar anonymous 2006 Mar drh 3 1 3.3 build option not documented? 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:_ {linebreak} 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. #f2dcdc 1700 code active 2006 Mar anonymous Parser 2006 Mar 2 2 Handling column names for aliased queries is broken 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. #cfe8bd 1699 code fixed 2006 Mar anonymous Unknown 2006 Mar 1 2 round(X) does not work correctly when nested in some functions Observe the following interactive session:{linebreak} =sqlite> select (round(50.1));{linebreak} 50{linebreak} sqlite> --The next command should return 1{linebreak} sqlite> select (round(50.1) = 50);{linebreak} 0{linebreak} sqlite> select max(1,round(50.1));{linebreak} 50{linebreak} sqlite> select min(1,round(50.1));{linebreak} 1{linebreak} sqlite> --The next command should return 50{linebreak} sqlite> select min(100,round(50.1));{linebreak} 100{linebreak}= _2006-Mar-02 02:40:53 by anonymous:_ {linebreak} Another example:{linebreak} =sqlite> select max(100,50);{linebreak} 100{linebreak} sqlite> select max(100,round(50.1));{linebreak} 50{linebreak}= ---- _2006-Mar-02 06:04:38 by anonymous:_ {linebreak} damn, you guys rock. #f2dcdc 1698 build active 2006 Mar anonymous 2006 Mar 1 1 sqlite_4y6ngs9FlYvAMGO 0kb 3/1/2006 1:16 PM 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:_ {linebreak} 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. #cfe8bd 1697 code fixed 2006 Mar drh CodeGen 2006 Mar drh 1 1 Segfault while executing SELECT The following SQL generates a segfault: CREATE TABLE t1(a,b,c); CREATE TABLE t2(p,q); CREATE INDEX i1 ON t2(q); SELECT a FROM t1 LEFT JOIN t2 ON b=p WHERE q= (SELECT max(m.q) FROM t2 m JOIN t1 n ON n.b=m.p WHERE n.c=1); _2006-Mar-01 23:29:50 by drh:_ {linebreak} This problem only comes up when an aggregate subquery is used as part of an expression in a WHERE clause constraint (but not an ON clause constraint) that also involves the left table in a LEFT OUTER JOIN. It is not clear to me why anybody would ever really want to do this. #cfe8bd 1695 code fixed 2006 Feb anonymous 2006 Mar anonymous 1 1 Database file not loading ... I can't load database file if path to this file contains a Russian letters. _2006-Feb-28 06:12:05 by anonymous:_ {linebreak} What character encoding does your pathname use? ---- _2006-Feb-28 07:39:27 by anonymous:_ {linebreak} In fact i don't know what charaster encoding used in my OS version (I have Windows XP sp2 installed on my computer), but seems like it's named "windows-1251". ---- _2006-Feb-28 08:17:10 by anonymous:_ {linebreak} I'm pretty sure SQLite expects a UTF-8 encoding, and a Windows-1251 encoding would be misinterpreted (in UTF-8, any code point above 127 is expected to be encoded as at least two bytes, whereas 1251 allows single-byte encodings in the 128-256 range). ---- _2006-Feb-28 12:56:29 by anonymous:_ {linebreak} Thanks you for the answer. I understand, that a problem in difference between UTF-8 and windows-1251 encodings, but why I can load database file if I have SQLite library version 3.2.1, and I can't load the same file if have library version 3.3.4, is it a bug, or it's a feature? ---- _2006-Mar-01 00:57:07 by anonymous:_ {linebreak} This change in behavior may have appeared after checkin 2656 which was first release in version 3.2.6. ---- _2006-Mar-01 02:03:31 by anonymous:_ {linebreak} And now, if I understand you correctly, I must convert my file path into UTF-8, and it will work? ---- _2006-Mar-02 07:21:01 by anonymous:_ {linebreak} Problem is in utf8ToUnicode function. Russian version of WinXP uses ANSI encoding for russian-specific letters instead UTF8. But first call WinAPI MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0) for getting needed size of output buffer not failed when found an invalid input character. For the second argument MB_ERR_INVALID_CHARS, it will do one. Patch SQLite. In the file "os_win.c" replace the line 138 "nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0)*sizeof(WCHAR);" with a "nByte = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, zFilename, -1, NULL, 0)*sizeof(WCHAR); if(!nByte) return 0;" and rebuild the library. This will work. ---- _2006-Mar-03 14:13:14 by anonymous:_ {linebreak} Thanks. ---- _2006-Mar-25 15:58:28 by drh:_ {linebreak} The filename argument to sqlite3_open() must be UTF-8. ---- _2006-Mar-31 12:48:05 by anonymous:_ {linebreak} The function =utf8ToUnicode=, and using it functions, still have bad logic. For incorrect input utf8 string =utf8ToUnicode= will return incorrect unicode string. Zero returned *only* when =sqliteMalloc= was failed. In a code for Windows, returned by =utf8ToUnicode= null pointer force call of ANSI version Win32 API. Very strange behavior. If the system have no memory, only need is return SQLITE_NOMEM error. But if incorrect input string may cause zero result of =utf8ToUnicode=, trying to call ANSI API is not so stranger. In my previous post i describe need corrections. In addition, in the =winceCreateLock= =zName= is not analyzed for zero. Best regards, Alex. #f2dcdc 1693 new active 2006 Feb anonymous Parser 2006 Mar 4 4 Parser sensitive to position of word AUTOINCREMENT 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. #c8c8c8 1692 code closed 2006 Feb anonymous 2006 Mar 1 2 Collation dont work in functions If a columns is defined with a collation: SELECT .... WHERE a='kalle'; works fine. But SELECT ..... WHERE COALESCE(a,'xxx')='kalle'; or SELECT ..... WHERE LOWER(a)='kalle'; dont call the userdefined collate-function. No function seems to result is a call to the collation-function, _2006-Feb-28 07:40:45 by anonymous:_ {linebreak} Using: CAST(col AS TEXT COLLATE 'swedish') dont work either. ---- _2006-Mar-03 19:47:11 by drh:_ {linebreak} This is how SQLite is documented to work. A collating function is only used for comparisons if either the left or right operand is a column that has a collating function. If you think there should be a design change so that collating functions are used for comparisons of arbitrary expressions, then make your case on the SQLite mailing list. Your work-around is to to sqlite3_create_function() to create a suitable comparison function at the same time you register your collating sequence. For example: SELECT ... WHERE compare_swedish( coalesce(a,'xxx'), 'kalle'); #c8c8c8 1691 code closed 2006 Feb anonymous Unknown 2006 Mar 3 3 sqlite3_sleep not built I just compiled 3.3.4 on windows using mingw. The sleep function is not included in the library. It looks like the file experimental.c is not included in the build. I don't know yet if anything else is affected by this. _2006-Mar-03 20:07:01 by drh:_ {linebreak} The functions in experimental.c are experimental. They are not an official part of the build. You can add them to the build if you want to use them. They are not needed by any other part of the system. #f2dcdc 1689 new active 2006 Feb anonymous 2006 Mar 2 4 triggers and temporary tables
 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:_ {linebreak} 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:_ {linebreak} 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 :) #cfe8bd 1688 code fixed 2006 Feb anonymous VDBE 2006 Mar danielk1977 3 2 Incorrect column names when doing select on views Consider the following SQL schema:
 CREATE TABLE 't1' (   'col1' INTEGER,   'col2' INTEGER );  CREATE VIEW 'v1' AS SELECT col1 as A, col2 as B FROM t1;  INSERT INTO 't1' VALUES (1, 2); INSERT INTO 't1' VALUES (3, 4); 
When explicitly requesting the column names on the 'v1' view, the returned names are the column names of 't1' and not the defined aliases in 'v1'. Eg:
 SQLite version 3.3.4 Enter ".help" for instructions sqlite> .headers on sqlite> select A, B from v1; col1|col2 1|2 3|4 sqlite> select * from v1; A|B 1|2 3|4 
Version 3.3.3 of SQLite behaves correctly:
 SQLite version 3.3.3 Enter ".help" for instructions sqlite> .headers on sqlite> select A, B from v1; A|B 1|2 3|4 sqlite> select * from v1; A|B 1|2 3|4 
The patch below fixes this problem in SQLite 3.3.4:
 diff -u -r sqlite-3.3.4.orig/src/select.c sqlite-3.3.4/src/select.c --- sqlite-3.3.4.orig/src/select.c      2006-02-22 18:27:28.000000000 +0100 +++ sqlite-3.3.4/src/select.c   2006-02-22 18:28:53.000000000 +0100 @@ -2857,6 +2857,13 @@    v = sqlite3GetVdbe(pParse);    if( v==0 ) goto select_end;  +  /* Identify column names if we will be using them in a callback.  This +  ** step is skipped if the output is going to some other destination. +  */ +  if( eDest==SRT_Callback ){ +    generateColumnNames(pParse, pTabList, pEList); +  } +    /* Generate code for all sub-queries in the FROM clause    */  #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) 
This code was moved at the end of the function in [3069]. I suppose that this modification does not play well with certain code paths but I did not investigate further. This behaviour is problematic when indexing a result set by column name (with the latest Ruby bindings for example). -- Julien Perrot _2006-Feb-23 18:44:12 by anonymous:_ {linebreak} You are not alone in being impacted by this change in behavior. The proposed fix is appreciated as a work-around however we're hopeful that an official fix can be offered soon. ---- _2006-Feb-23 19:09:56 by anonymous:_ {linebreak} Pardon the "me too" comment, but column names resulting from queries involving views have always been a weak spot in SQLite. If you search the bug database you will see around a dozen similar reports. You basically have to use "AS" all over the place to work around these problems. ---- _2006-Feb-23 19:48:55 by drh:_ {linebreak} A big reason that this has never been fixed is because I have no idea of what the "correct" behavior is suppose to be. If somebody can write of a document that specifies what column names coming out of a query or a view are "suppose" to be, then i would have something to try to code against. I suggest putting the specification on the wiki where it can be reviewed and edited by the community. ---- _2006-Feb-24 05:22:55 by anonymous:_ {linebreak} http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt Please refer to sections "6.4 ", "7.5 ", "7.9 " and "11.19 ". Here's one that might be fixed in a recent release (I have not tried). *: The same shall not be specified more than once in the . CREATE TABLE t1(a,b); INSERT INTO "t1" VALUES(3, 4); INSERT INTO "t1" VALUES(4, 5); INSERT INTO "t1" VALUES(6, 7); CREATE TABLE t2(a,b); INSERT INTO "t2" VALUES(4, 5); CREATE VIEW v1 as select * from t1, t2; sqlite> select * from t1, t2; a|b|a|b 3|4|4|5 4|5|4|5 6|7|4|5 sqlite> select * from v1; a|b|a:1|b:1 3|4|4|5 4|5|4|5 6|7|4|5 sqlite> select sqlite_version(*); sqlite_version(*) 3.2.8 ---- _2006-Feb-24 10:40:02 by drh:_ {linebreak} The sql1998.txt document is 686 pages of ambiguous gobbledygook. It is clearly the work of a committee. If you want me to change SQLite to be in better "compliance" with this document, then you will greatly expediate the process by providing a consise, coherent translation of the parts of this document that you want SQLite to comply with. Otherwise, SQLite is what it is and is unlikely to change soon. ---- _2006-Feb-24 12:22:43 by anonymous:_ {linebreak} I did those test on SQL Server 2005 Express ------------------------------------------- CREATE TABLE t1(a int, b int) ; INSERT INTO t1 values (3, 4) INSERT INTO t1 values (4, 5) INSERT INTO t1 values (5, 6) ; CREATE TABLE t2(a int, b int) ; INSERT INTO t2 VALUES(4, 5) ; CREATE VIEW v1 as SELECT a as ColA, b as ColB from t1 ; SELECT * FROM t1 ----------------------- a b ----------- ----------- 3 4 4 5 5 6 (3 row(s) affected) SELECT * from v1 ----------------------- ColA ColB ----------- ----------- 3 4 4 5 5 6 (3 row(s) affected) ----------------------- SELECT * FROM t1, v1 ----------------------------------------------- a b ColA ColB ----------- ----------- ----------- ----------- 3 4 3 4 4 5 3 4 5 6 3 4 3 4 4 5 4 5 4 5 5 6 4 5 3 4 5 6 4 5 5 6 5 6 5 6 (9 row(s) affected) ----------------------------------------------- SELECT * FROM t2, v1 ----------------------------------------------- a b ColA ColB ----------- ----------- ----------- ----------- 4 5 3 4 4 5 4 5 4 5 5 6 (3 row(s) affected) ----------------------------------------------- I noted that SQL Server uses the aliases to return column names (just like SQLite did before 3.3.4 release). Why did SQLite changed this behaviour? ---- _2006-Feb-24 12:24:22 by anonymous:_ {linebreak}
 I did those test on SQL Server 2005 Express ------------------------------------------- //   CREATE TABLE t1(a int, b int) ;  INSERT INTO t1 values (3, 4) INSERT INTO t1 values (4, 5) INSERT INTO t1 values (5, 6) ;  CREATE TABLE t2(a int, b int) ;  INSERT INTO t2 VALUES(4, 5) ;  CREATE VIEW v1 as SELECT a as ColA, b as ColB from t1 ;  SELECT * FROM t1 ----------------------- a           b ----------- ----------- 3           4 4           5 5           6  (3 row(s) affected)  SELECT * from v1 ----------------------- ColA        ColB ----------- ----------- 3           4 4           5 5           6  (3 row(s) affected) -----------------------  SELECT * FROM t1, v1 ----------------------------------------------- a           b           ColA        ColB ----------- ----------- ----------- ----------- 3           4           3           4 4           5           3           4 5           6           3           4 3           4           4           5 4           5           4           5 5           6           4           5 3           4           5           6 4           5           5           6 5           6           5           6  (9 row(s) affected) -----------------------------------------------  SELECT * FROM t2, v1 ----------------------------------------------- a           b           ColA        ColB ----------- ----------- ----------- ----------- 4           5           3           4 4           5           4           5 4           5           5           6  (3 row(s) affected) -----------------------------------------------  I noted that SQL Server uses the aliases to return column names (just like SQLite did before 3.3.4). Why SQLite has changed previous behaviour ? 
I did those test on SQL Server 2005 Express ------------------------------------------- // CREATE TABLE t1(a int, b int) ; INSERT INTO t1 values (3, 4) INSERT INTO t1 values (4, 5) INSERT INTO t1 values (5, 6) ; CREATE TABLE t2(a int, b int) ; INSERT INTO t2 VALUES(4, 5) ; CREATE VIEW v1 as SELECT a as ColA, b as ColB from t1 ; SELECT * FROM t1 ----------------------- a b ----------- ----------- 3 4 4 5 5 6 (3 row(s) affected) SELECT * from v1 ----------------------- ColA ColB ----------- ----------- 3 4 4 5 5 6 (3 row(s) affected) ----------------------- SELECT * FROM t1, v1 ----------------------------------------------- a b ColA ColB ----------- ----------- ----------- ----------- 3 4 3 4 4 5 3 4 5 6 3 4 3 4 4 5 4 5 4 5 5 6 4 5 3 4 5 6 4 5 5 6 5 6 5 6 (9 row(s) affected) ----------------------------------------------- SELECT * FROM t2, v1 ----------------------------------------------- a b ColA ColB ----------- ----------- ----------- ----------- 4 5 3 4 4 5 4 5 4 5 5 6 (3 row(s) affected) ----------------------------------------------- I noted that SQL Server uses the aliases to return column names (just like SQLite did before 3.3.4). Why SQLite has changed previous behaviour ? ---- _2006-Mar-02 13:39:15 by anonymous:_ {linebreak}
 ************************************************************* ** TEST IN MYSQL 5.0.18 ************************************************************* mysql> CREATE TABLE t1 (     -*   col1 INTEGER,     -*   col2 INTEGER     -* ); Query OK, 0 rows affected (0.09 sec) mysql> mysql> CREATE VIEW v1 AS     -* SELECT col1 as A, col2 as B FROM t1; Query OK, 0 rows affected (0.03 sec) mysql> mysql> INSERT INTO t1 VALUES (1, 2); Query OK, 1 row affected (0.03 sec) mysql> INSERT INTO t1 VALUES (3, 4); Query OK, 1 row affected (0.03 sec) mysql> select A, B from v1; +------+------+ | A    | B    | +------+------+ |    1 |    2 | |    3 |    4 | +------+------+ 2 rows in set (0.00 sec) mysql> select * from v1; +------+------+ | A    | B    | +------+------+ |    1 |    2 | |    3 |    4 | +------+------+ 2 rows in set (0.00 sec) *************************************************************  ************************************************************* ** TEST IN SQL SERVER 2005 ************************************************************* CREATE TABLE t1 (     col1 INTEGER,     col2 INTEGER ) ;  CREATE VIEW v1 AS  SELECT col1 as A, col2 as B FROM t1 ;  INSERT INTO t1 VALUES (1, 2) ; >> (1 row(s) affected)  INSERT INTO t1 VALUES (3, 4) ; >> (1 row(s) affected)  select A, B from v1 ; >> A           B >> ----------- ----------- >> 1           2 >> 3           4 >> >>(2 row(s) affected)  select * from v1 ; >> A           B >> ----------- ----------- >> 1           2 >> 3           4 >> >>(2 row(s) affected) *************************************************************  They behave exactly equal in these two databases, and in SQLite 3.3.3 too. I tought the problem was in the implementation of sqlite_column_origin_name API. They must use a separate buffer to store the original column name and the view column name to avoid this problem. 
---- _2006-Mar-07 20:14:04 by anonymous:_ {linebreak}
 Hi  I did the previous test in ORACLE and it behaves like previous remarks (SQL Server and MySQL). This clearly show the common behaviour on all databases (that SQLite 3.3.3 previously has in common), but with the implementation of sqlite_orign_column_name() api, it's like something is broken.  This behaviour change could break a lot of current running code. Please consider fix this with a higher priority in your free time.  cheers  ---- _2006-Mar-08 15:21:59 by anonymous:_ {linebreak} We offered the first remark above and with respect to the 2nd, we are using AS to alias all column names in views since this mitigated other SQLite column naming behavior (and did so portably).  The column_origin_name changes do appear to have resulted in the side effect of aliases being ignored for views where previously they hadn't been.  I'm a relative newbie to this effort recently inheriting responsibility for our position of interest in SQLite - It appears that there are a small set of experts contributing to the code base and my casual observation is that a review of the changes introduced with column_origin_name might be helpful to identify any unintended column naming side effects such as those noted with views.  ---- _2006-Mar-08 18:15:54 by anonymous:_ {linebreak} Same test done on an Sybase ASE Server 12.5.3 (by another anonymous guy :p) :    CREATE TABLE t1 (       col1 INTEGER,       col2 INTEGER   )    CREATE VIEW v1 AS           SELECT col1 as A, col2 as B FROM t1 ;    INSERT INTO t1 VALUES (1, 2) ;   (1 row affected)    INSERT INTO t1 VALUES (3, 4) ;   (1 row affected)=  Result :    1> select A, B from v1   2> go    A           B    ----------- -----------              1           2              3           4    (2 rows affected)    1> select * from v1   2> go    A           B    ----------- -----------              1           2              3           4    (2 rows affected)  ---- _2006-Mar-10 13:06:33 by drh:_ {linebreak} I misread the original problem report and misunderstood the complaint.  I understand what the problem is and agree that it needs to be fixed right away.  Sorry for the confusion.
#c8c8c8	1687	todo	closed	2006 Feb	dougcurrie		2006 Mar		3	3	tclsqlite.c crashes MinGW/MSYS gcc 3.4.5 on WIndows	The macro =EXTERN= is used by tclsqlite but not defined (properly). This causes build on WinXP with MinGW/MSYS to crash.  Suggestion: change all occurances of =EXTERN= to =extern= in tclsqlite.c  Also, this code in tclsqlite.c is unused and should be removed:    /*    * Windows needs to know which symbols to export.  Unix does not.    * BUILD_sqlite should be undefined for Unix.    */    #ifdef BUILD_sqlite   #undef TCL_STORAGE_CLASS   #define TCL_STORAGE_CLASS DLLEXPORT   #endif /* BUILD_sqlite */  e	_2006-Mar-06 22:04:33 by dougcurrie:_ {linebreak} Unfortunately, check-in [3119] doesn't work. The problem is that =EXTERN= *is* defined in tcl.h, and in such a way as to make MinGW 3.4.5 crash. So, conditionally re-defining it doesn't help.  Either every =EXTERN= has to become =extern= , or check-in [3119] has to be reverted, and the preprocessor symbol =BUILD_sqlite= needs to be defined in every target that uses tclsqlite.c.  ---- _2006-Jul-10 21:00:14 by anonymous:_ {linebreak} [Jeff Hobbs]: That is not the correct solution.  It must be just the msys build that isn't configured correctly.  Make sure that you define -DBUILD_sqlite for all Windows-based builds (mingw or MSVC).  Aside from that, it should work fine.  The tcl.h handles DLLEXPORT for both MSVC and GNUC variants on Windows.  You can define BUILD_sqlite for all builds and it wouldn't harm anything either.
#cfe8bd	1684	code	fixed	2006 Feb	anonymous		2006 Mar		2	2	SQLITE_MIN_SLEEP_MS not defined in main.c	On Mac OS X (and probably other unix platforms - not sure about Windows...), the standard busy handler (=sqliteDefaultBusyCallback=) will always call =sqlite3OsSleep= with delay 1000 milliseconds, even though Mac OS X support =usleep= and the =HAVE_USLEEP= macro is set to 1. This slows down multithreaded execution unnecessarily and we're seeing some blocking in our main thread when another thread is accessing the database. If the number of threads accessing the database is large enough, our main thread quite often blocks long enough for the user to notice. This didn't happen quite as easily in sqlite prior to 3.3.  The reason for this problem is that _main.c_, which implements =sqliteDefaultBusyCallback= doesn't include _os_unix.h_, which defines the =SQLITE_MIN_SLEEP_MS= macro to have a value of 1 if the OS supports usleep. However, the implementation of =sqliteDefaultBusyCallback= in _main.c_ checks for this macro. Thus, the conditional code for the =SQLITE_MIN_SLEEP_MS > 1= case is (incorrectly) compiled.  Previous versions (before 3.3.x) included _os_unix.h_ from _os.h_ and thus have this macro defined in _main.c_ where it's used.	
#c8c8c8	1681	code	closed	2006 Feb	anonymous	Unknown	2006 Mar		1	3	After upgrading from 3.2.7 to 3.3.4, problems with umlauts	After upgrading from 3.2.7 to 3.3.4, all umlauts in queries cause syntax errors.	_2006-Feb-16 19:44:46 by anonymous:_ {linebreak} I can confirm this problem. We've been experiencing the same after the upgrade to 3.3.4. Here's an example query:  
 amarok:     [CollectionDB] [ERROR!] near "1": syntax error amarok:     [CollectionDB] [ERROR!] on insert: INSERT INTO tags_temp ( url, dir, createdate, modifydate, album, artist, genre, year, title, composer, comment, track, discnumber, sampler, length, bitrate, samplerate, filesize, filetype ) VALUES ('/home/tester/Shared/Röyksopp - What Else Is There?.mp3','/home/tester/Shared',1121115569,1121115569,19,24,14,'1','What Else Is There?',NULL,'', 7, 0 , 0,317,256,44100,10141380,1) 
---- _2006-Mar-03 19:15:54 by drh:_ {linebreak} I am guessing that this problem is in a wrapper or interface to SQLite and not in SQLite itself. If you disagree, please submit a script that demonstrates the problem when run through the standard SQLite command-line shell. ---- _2006-Mar-13 21:58:29 by anonymous:_ {linebreak} The problem turned out to be that sqlite3_prepare() expects the length as the number of bytes, not characters, and we were passing the latter. This worked with the ASCII subset of UTF-8, but broke otherwise. (Not sure why it worked with previous versions). Solution was to pass -1 so it reads until the null at the end. Just mentioning this here in case others stumble on the same problem. #cfe8bd 1680 build fixed 2006 Feb anonymous 2006 Mar 4 3 configure --enable-debug doesn't enable verbose explain When building sqlite, the configure script says the option --enable-debug should enable the verbose explain output. It doesn't work. In order to get verbose explain output and enable the pragma vdbe_trace command you still need to define the symbol SQLITE_DEBUG in the generated Makefile. #cfe8bd 1662 code fixed 2006 Feb anonymous Unknown 2006 Mar drh 1 3 Wrong CAST result rsp. missing string trimming on number conversions I recognized following problem also much earlier than in version 3.3.3 but unfortunately it persists. {linebreak} Easiest shows up with sqlite3.exe shell (Win XP) but also happens otherwise {linebreak} {linebreak} *select cast('12.34' as real);* {linebreak} {linebreak} will give the correct result *12.34* of numeric type versus {linebreak} {linebreak} *select cast('    12.34' as real);* will give a wrong numeric result *0.0* . However, the typeof(cast(' 12.34' as real)) is numeric as expected. {linebreak} It seems that no trimming of the string is done. On the other hand there is no trim function to do so. {linebreak} Is there any workaround or solution to convert right-padded number formatted strings into numbers? How to eliminate space characters? _2006-Mar-02 12:01:42 by anonymous:_ {linebreak} Any idea how to eliminate the preceding blank characters to cast a string of digits into a number ? ---- _2006-Mar-02 18:35:57 by anonymous:_ {linebreak} I have attached a patch for the source file uitl.c that changes sqlite3AtoF() so that it behaves like strtod(). The modified sqlite3AtoF skips initial leading whitespace. With this change in place SQLite will return the correct result for this cast. The modified SQLite passes all the tests in the test suite. ---- _2006-Mar-03 09:05:26 by anonymous:_ {linebreak} Thank you very much and let't hope the next release will include this. #f2dcdc 1656 doc active 2006 Feb anonymous Parser 2006 Mar 5 4 lemon versions and changelog 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. #f2dcdc 1655 new active 2006 Feb anonymous VDBE 2006 Mar 4 4 Every function can have their private data like agreagates 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:_ {linebreak}
 /* ** 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. #c8c8c8 1639 code closed 2006 Jan anonymous Unknown 2006 Mar 3 3 pkgconfig file in 3.3.1 says version is 3.3 The pkgconfig file included in the 3.3.1 alpha release says the version is "3.3". This means it's not possible to check for 3.3.1 specifically, which is needed to ensure that the threading fixes that went in that release are available. _2006-Jan-31 07:06:30 by anonymous:_ {linebreak} This is causing http://bugzilla.gnome.org/show_bug.cgi?id=329280 ---- _2006-Jan-31 12:49:18 by drh:_ {linebreak} Version 3.3.0 failed to work in many ways. It was out less than one week before 3.3.1 arrived to replace it. I suggest you change your script to check for SQLite version 3.3 or greater and ignore 3.3.0. ---- _2006-Jan-31 18:06:33 by anonymous:_ {linebreak} At least one of our users was running 3.3.0 and was hitting MISUSE errors due to the changes in the threading code, so I don't think I can ignore it. I realize the 3.3.x series is alpha; if anything that makes the need to put micro version numbers in the pkgconfig file more important, so that we can depend on versions after bugs have been fixed. ---- _2006-Jan-31 19:28:27 by drh:_ {linebreak} I do not know what a pkgconfig file is. I do not know where it comes from. I do not know what it is used for. It is not something that I ever wrote. I do not know how to change it. If you want to see this fixed, please submit a patch. #c8c8c8 1592 code closed 2006 Jan anonymous Unknown 2006 Mar 1 2 [patch] fixes for mbcs in os_win.c The recent changes in os_win.c were definitely a step in the right direction for support of non-ASCII file names. However, there's still a problem under the following conditions: *: you are running on a Win9x system *: the system locale is not English, but something that uses a lot of multibyte characters (e.g. Japanese). With the current code, a file name with a multibyte character in it cannot be opened. The UTF-8 filename that is passed via sqlite3_open (or indirectly via sqlite3_open16) is passed directly to the xxxA() functions of Win32. However, the Ansi APIs expect a string encoded with the current codepage. To fix this, the UTF-8 strings have to be converted to mbcs before being passed to the xxxA() functions. The patch appended to this ticket does exactly this. Now multibyte characters are fully supported on Win32. _2006-Mar-25 16:15:05 by drh:_ {linebreak} Issues: *: I have no way to test any of this *: The patch is huge (492 lines) and basically rewrites large sections of os_win.c *: I do not know the author of the patch. *: The author of the patch does not have a copyright release on file. *: The author appears to live in Germany which is a country (I am told) that does not recognize the public domain. Hence German citizens are prohibited from contributing code to SQLite. For these reasons, I cannot directly apply this patch. But if someone can make a case that this really is an issue that needs to be addressed and can suggest less radical changes, I will be attentive. #cfe8bd 1583 code fixed 2006 Jan anonymous CodeGen 2006 Mar 2 4 explain query plan missing length I'm using sqlite v.3.2.8. I think I've found a bug in the explain query plan: After a sqlite3_step call returning SQLITE_ROW from a "explain query plan ..." query, I access the sqlite3_stm* through the normal API to get info from each column. The problem is in the third column "detail", in which the call to sqlite3_column_bytes always (so far) gives 0 (zero) even although there is content after calling sqlite3_column_text. In the shell from the command line this gives the text just because it does not call sqlite3_column_bytes, but strlen's on the value returned from sqlite3_column_text. There is a workaround for me: if sqlite3_column_bytes returns zero and sqlite3_column_text returns != NULL then use strlen. #cfe8bd 1578 doc fixed 2005 Dec anonymous Unknown 2006 Mar 5 4 Typo on http://www.sqlite.org/version3.html page Typo on http://www.sqlite.org/version3.html page. quote: _:A collating sequence is implemented as a function that takes the two strings being compared as inputs and returns negative, zero, or positive if the first string is less than, equal to, or greater than the first. should be: _:A collating sequence is implemented as a function that takes the two strings being compared as inputs and returns negative, zero, or positive if the first string is less than, equal to, or greater than the second. hth #cfe8bd 1570 code fixed 2005 Dec anonymous Unknown 2006 Mar drh 3 3 pragma table_info() incorrect result for columns with NONE affinity If column's datatype is empty string, then *pragma table_info* reports 'numeric' as datatype. This is bug, because such columns have *NONE* affinity. Some programs (GUI shells, object-relational mappers) relies on this incorrect information. example SQL code: create table t1(a numeric, b); pragma table_info(t1); result: cid | name | type | notnull | dflt_value | pk -----+--------+-----------+-----------+--------------+------- 0 | a | numeric | 0 | | 0 1 | b | numeric | 0 | | 0 In this example, type of "b" column displayed as "numeric". This must be displayed as "" (empty string). #c8c8c8 1568 code closed 2005 Dec anonymous Unknown 2006 Mar 1 1 sqlite3_column_decltype( ) returning BadPointer with "UNION" I am using VC++7 as building and given below the code piece in brief that is creating problem ======================================================= char DBName[] = "D:\\MySQLiteDatabase.db"; sqlite3* pDB; sqlite3_open(DBName, &pDB); sqlite3_stmt* pstmt; sqlite3_prepare(pDB, "Select NAME From tblEmp UNION Select NAME From tblEmp", -1, &pstmt, NULL); int iColCount = sqlite3_column_count(pstmt); const char* pColName; pColName = sqlite3_column_name(pstmt, 0); const char* pColType = sqlite3_column_decltype(pstmt, 0); sqlite3_finalize(pstmt); sqlite3_close(pDB); ======================================================== The given SQL is just a example only. The "NAME" column is of VARCHAR type. Each and every line is executing fine, except sqlite3_column_decltype( ) one. It is returning bad pointer (0x00000) for UNION type SQL, but returning column type for other SQLs including "UNION ALL". In our application we have query for each column type. Please treat it urgent and give me some useful tips. Is that a bug? Regards, Pradip Email: pradipkumardas@hotmail.com Phone: +91 (0657) 5573240 (Office) _2006-Mar-03 21:15:09 by drh:_ {linebreak} sqlite3_column_name() returns NULL when it does not know the name of the column. Works as designed and documented. #c8c8c8 1563 code closed 2005 Dec anonymous 2006 Mar 1 1 The system crash when creating a database! in file os_win.c,there is a function: utf8ToUnicode. It seem that the function is error. There is a Call for MultiByteToWideChar, with the code page parameter "CP_UTF8". In fact, our os code page is usually "CP_ACP". So the function return an error result. We are in China, and the os is win2000/2003, the codepage is 936 or 950. _2005-Dec-16 07:44:50 by anonymous:_ {linebreak} error: When calling sqlite3_open to open or create a database,if the path of the database is Chinese, the function will return a "file cannot open" error. Cause that sqlite looks on the path string as a UTF-8 string. Our Modify: 1. os_win.c sqlite3OsFullPathname function commented: Ln813 //zWide = utf8ToUnicode(zRelative); added: zWide = NULL; focus: Don't translate it.The system will do with it well. 2. os_win.c utf8ToUnicode function Modified Ln 90: nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0)*sizeof(WCHAR); To: nByte = MultiByteToWideChar(CP_ACP, 0, zFilename, -1, NULL, 0)*sizeof(WCHAR); Modified Ln 95: using the same modify above. ---- _2005-Dec-16 11:57:26 by anonymous:_ {linebreak} This appears to be a duplicate of #1499. ---- _2006-Mar-25 16:20:47 by drh:_ {linebreak} sqlite3_open() must be called with a UTF-8 filename, not a CP_ACP codepage string. #c8c8c8 1557 event closed 2005 Dec anonymous Parser 2006 Mar 1 1 sqlite core dumps in exprNodeIsConstant Solaris 8.0, Sun C++ 5.6, SQLite 3.2.2 (multi-threaded) Stack trace follows: core 'core' of 7235: ----------------- lwp# 3 / thread# 7 -------------------- ff2b5ad4 exprNodeIsConstant (fda0b4c0, 70, 109b60, 7bf260, 63, ff307450) + 4c ff2b57cc walkExprTree (70, ff2b5a88, fda0b4c0, 0, 0, 27) + 3c ff2b5938 walkExprList (7b6d08, ff2b5a88, fda0b4c0, fe3fc000, fda0ba29, 10dbf4) + 68 ff2b5870 walkExprTree (7b5f68, ff2b5a88, fda0b4c0, b, 313fc, ff3ba3c0) + e0 ff2b5800 walkExprTree (7b6d08, ff2b5a88, fda0b4c0, 0, fda0ba30, b) + 70 ff2b5800 walkExprTree (7b5f70, ff2b5a88, fda0b4c0, ff2e5894, 0, 0) + 70 ff2b5bd4 sqlite3ExprIsConstant (7b5f70, 7b50f0, 8, 2, 1, 0) + 44 ff2b7f60 sqlite3ExprCode (fda0b898, 7bf188, 0, 0, ff31b4e0, 109b69) + 708 ff2e5208 sqlite3Update (17, 109b18, 109b60, 7bf260, 63, ff307450) + 1258 ff2cd9e0 yy_reduce (7be9a0, 9e, 83, fda0b794, 3144c, 0) + 11e0 ff2cfa48 sqlite3Parser (7be9a0, a, fda0b800, fda0b898, 3f, fec26ae8) + 168 ff2e10bc sqlite3RunParser (fda0b898, fda0b9f8, fda0b894, fffffff8, 0, fda0b94d) + 394 ff2d3810 sqlite3_prepare (10a590, fda0b9f8, ffffffff, fda0bd28, 0, 0) + c0 feb9ea88 __1cKECSddStoreGupdate6MrnKECSQdDLiteDB_rnDSdd__v_ (fec45cf8, fda0bd20, 7b7400, fec45c98, 3000, fec45c80) + 7b8 feb9d4fc sdd_read_thread (0, fec45d30, ffffffff, 7b7400, fec45cc0, 1) + f48 fe3eb01c _thread_start (fec45cf8, 0, 0, 0, 0, 0) + 40 Another more detailed stack trace: t@7 (l@3) terminated by signal SEGV (no mapping at the fault address) Current function is nameResolverStep 1039 if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return 1; (dbx 1) where current thread: t@7 =>[1] nameResolverStep(pArg = 0xfda0b5ec, pExpr = 0x70), line 1039 in "expr.c" [2] walkExprTree(pExpr = 0x70, xFunc = 0xff2b6a48 = &`libsqlite3.so.0`expr.c`nameResolverStep(void *pArg, struct Expr *pExpr), pArg = 0xfda0b5ec), line 615 in "expr.c" [3] walkExprList(p = 0x675610, xFunc = 0xff2b6a48 = &`libsqlite3.so.0`expr.c`nameResolverStep(void *pArg, struct Expr *pExpr), pArg = 0xfda0b5ec), line 632 in "expr.c" [4] walkExprTree(pExpr = 0x67c538, xFunc = 0xff2b6a48 = &`libsqlite3.so.0`expr.c`nameResolverStep(void *pArg, struct Expr *pExpr), pArg = 0xfda0b5ec), line 619 in "expr.c" [5] nameResolverStep(pArg = 0xfda0b5ec, pExpr = 0x685df0), line 1136 in "expr.c" [6] walkExprTree(pExpr = 0x685df0, xFunc = 0xff2b6a48 = &`libsqlite3.so.0`expr.c`nameResolverStep(void *pArg, struct Expr *pExpr), pArg = 0xfda0b5ec), line 615 in "expr.c" [7] sqlite3ExprResolveNames(pNC = 0xfda0b5ec, pExpr = 0x685df0), line 1188 in "expr.c" [8] sqlite3Update(pParse = 0xfda0b898, pTabList = 0x67a4f0, pChanges = 0x67a2c0, pWhere = 0x685ec8, onError = 99), line 165 in "update.c" [9] yy_reduce(yypParser = 0x6855c0, yyruleno = 158), line 549 in "parse.y" [10] sqlite3Parser(yyp = 0x6855c0, yymajor = 10, yyminor = RECORD, pParse = 0xfda0b898), line 3270 in "parse.c" [11] sqlite3RunParser(pParse = 0xfda0b898, zSql = 0xfda0b9f8 "UPDATE SDDSTORE SET SDD = ?, TIMESTAMP = DATETIME('NOW','LOCALTIME') WHERE ECORDERID = ?", pzErrMsg = 0xfda0b894), line 399 in "tokenize.c" [12] sqlite3_prepare(db = 0x10a590, zSql = 0xfda0b9f8 "UPDATE SDDSTORE SET SDD = ?, TIMESTAMP = DATETIME('NOW','LOCALTIME') WHERE ECORDERID = ?", nBytes = -1, ppStmt = 0xfda0bd28, pzTail = (nil)), line 435 in "prepare.c" [13] 0xfeb9ea88(0xfec45cf8, 0xfda0bd20, 0x67f0f0, 0xfec45c98, 0x3000, 0xfec45c80), at 0xfeb9ea87 [14] 0xfeb9d4fc(0x0, 0xfec45d30, 0xffffffff, 0x67f0f0, 0xfec45cc0, 0x1), at 0xfeb9d4fb The schema when this occurs is: CREATE TABLE AMENDS (KEY VARCHAR PRIMARY KEY, VALUE INTEGER); CREATE TABLE EXECID (KEY VARCHAR PRIMARY KEY, VALUE INTEGER); CREATE TABLE PERSISTEDID (NAME VARCHAR, VALUE VARCHAR); CREATE TABLE QUOTES (KEY VARCHAR PRIMARY KEY, VALUE INTEGER); CREATE TABLE SDDSTORE (ECORDERID VARCHAR PRIMARY KEY, TIMESTAMP DATE, SDD BLOB); The statement being prepared with sqlite3_prepare is: "UPDATE SDDSTORE SET SDD = ?, TIMESTAMP = DATETIME('NOW','LOCALTIME') WHERE ECORDERID = ?" No other reports of this and unable to reproduce. ---- _2006-Mar-04 14:57:57 by anonymous:_ {linebreak} This was previously fixed. I've detected this bug in Win32 version and it's already fixed. ---- _2006-Apr-03 12:42:47 by anonymous:_ {linebreak} This was actually caused by heap corruption prior to the sqlite api invocation. #c8c8c8 1553 new closed 2005 Dec anonymous 2006 Mar 5 4 API suggestion: sqlite3_has_more_rows() How about: int sqlite3_has_more_rows( sqlite3_stmt * ); returns 0 or 1. ??? This would simplify the creation of C++ iterators for walking result sets. i currently don't know how to check this in an iterator implementation without always doing a call to sqlite3_step(). _2005-Dec-03 17:59:50 by drh:_ {linebreak} SQLite itself has no way of knowing if there are more rows. So it is not clear how such an API could be created. #c8c8c8 1539 code closed 2005 Nov anonymous 2006 Mar 4 4 sqlite3Realloc is a trap for the unwary (I realize this is probably going to sound less like a bug report and more like the ravings of a crackpot, but as I was just bitten by this I thought I should file a bug report. I'd suggest reading it quickly, and deleting it if it doesn't seem like a useful change.) sqlite3Realloc() has a dual personality: if called with a size arg n of 0, it delegates to sqlite3Malloc() which sets the allocated memory to zero, but if called with n > 0, it calls realloc() directly which does not zero the memory. In one sense this behaviour makes sense, because unless provided with more information realloc doesn't know the size of the original allocation, but in another sense it's misleading because having the allocation zeroed in the initial call creates code that works until a reallocation is necessary. Solution 1: rename sqlite3Realloc() to sqlite3ReallocRaw(), and have it call sqlite3ReallocRaw for the initial allocation. For if the caller is already setting the memory to zero, having sqlite3Realloc() sometimes do it for you is superfluous work; and if the caller is not setting the memory to zero, having it done automatically is either unnecessary or potentially masking bugs that will occur only when a reallocation is done. Solution 2: change sqlite3Realloc() to accept three arguments: sqlite3Realloc(ptr, old_size, new_size) and have it zero the memory between old_size and new_size if new_size is greater. This would produce greater symmetry with sqliteMalloc(), and be less hazardous to the unwary. If desired, also create a parallel function sqlite3ReallocRaw() as described above. _2005-Nov-28 17:29:05 by drh:_ {linebreak} One wonders what mischief you were up to when you encountered this problem. ;-) ---- _2006-Mar-25 16:40:05 by drh:_ {linebreak} As goofy as the behavior of sqliteRealloc() seems, there is actually a good reason for it. We sometimes want to use sqliteRealloc() allocate or reallocate a structure with an array appended. After each call to sqliteRealloc() we zero out the new parts of the array. But the structure itself is never zeroed. We depend on sqliteRealloc() to zero the initial allocation for us. See sqlite3_set_auxdata() as an example. #cfe8bd 1533 code fixed 2005 Nov anonymous 2006 Mar 1 1 file os_win.c, function utf8ToUnicode and unicodeToUtf8 BUG file os_win.c, function utf8ToUnicode and unicodeToUtf8,code MultiByteToWideChar(CP_UTF8),WideCharToMultiByte(CP_UTF8), CP_UTF8 should changes -> CP_ACP,because CP_UTF8 not sustain Chinese conversion. _2005-Nov-22 02:25:17 by drh:_ {linebreak} I have no idea what this means. ---- _2005-Nov-22 03:38:57 by anonymous:_ {linebreak} I think he's talking about the considerations discussed in http://www.codeguru.com/forum/archive/index.php/t-231165.html ---- _2005-Nov-23 11:44:10 by anonymous:_ {linebreak} Is using CP_ACP (CodePage_AnsiCodePage) really such a good idea? I suspect the problem is the initial conversion of the filename to UTF-8 which shouldn't have anything to do with the file functions in os_win.c. Since the Chinese code page uses double byte characters I think it simply happened to work in older versions of SQLite since UTF-8 also works with double byte characters and no string conversion was done before SQLite 3.2.6. Hence the filename was intact before 3.2.6. Is support for Chinese characters even possible if SQLite is using UTF-8 internally for filenames? Isn't UTF-16 required for that? Regarding the CodeGuru link; it answers the question "How to convert between ANSI and UNICODE strings?", not "How to convert between UTF-8 and UNICODE strings?" /pLu ---- _2005-Dec-19 00:01:36 by anonymous:_ {linebreak} I think (from a quick examination of the source), that what he is talking about is that the code assumes that the Windows standard codepage for char* filenames is UTF-8, like it is on Unix. Following this assumption, all char* strings that are passed into the API are converted from CP_UTF8 to WCHAR and then used in the WCHAR API. However, in Windows the standard codepage for char* filename strings is the local system characterset which is always CP_ACP on Windows 9x, and usually CP_ACP on NT (although rarely it is CP_OEM, see Win32 function AreFileApisANSI). I assume that this means that any file paths passed into sqlite on Windows will work fine only when they are pure ascii paths. Any ACP char* paths that use non-ASCII characters like Chinese, Japanese, Thai, etc will fail at the UTF8 -> WCHAR conversion. There are a few possible solutions to this problem. 1: Make char* filename APIs expect the string in CP_ACP 2: Document that all char* filenames MUST be converted to UTF-8 before passing them into sqlite. 3: Provide wrapper functions implementing 2. The problem with 1. is that although simple, it prevents full unicode strings, and thus paths using characters outside of the system codepage to be used. I.e. I can't create a file using German umlauts on a Japanese system. This situation is not so uncommon. The problem with 2. is that the user must do their own conversion from CP_ACP (or WCHAR) to UTF-8 prior to calling the sqlite API. If we did 3. then we would supply functions like... sqlite_openA(char* path,...) which expects a CP_ACP path, converts it to UTF-8 and calls sqlite_open(). sqlite_openW(WCHAR* path,...) which expects a UTF-16 path, converts it to UTF-8 and calls sqlite_open(). There is an amount of double handling involved in 3. but API including filepaths are not involved in any performance critical code paths right? Hope this helps. Brodie ---- _2005-Dec-19 00:10:07 by anonymous:_ {linebreak} This bug is caused by the change made in os_win.c version 1.24. See also ticket #1499 (which could be closed and use this instead). My suggestion previously of using sqlite3_openW already exists with sqlite3_open16. All that is needed is LARGE warnings that the char* API requires a UTF-8 string rather than an ANSI string. I would still like to see a wrapper function for Windows users who expect a char* is an ANSI. Creating symbols on Windows of sqlite3_openW == sqlite3_open16 and sqlite3_openA == wrapper around sqlite3_open would match the system default. ---- _2006-Jan-03 08:25:05 by anonymous:_ {linebreak} After investigating a little more, I think that the current solution is incorrect. I suggest that all functions accepting a char* should *on Windows* use the current codepage instead of UTF-8. Although on Unix the normal codepage is UTF-8, on Windows it never is. The current implementation breaks the standard platform behaviour of using char* for multibyte character sets, is confusing for users and breaks compatibility with all earlier versions of sqlite. Even the sqlite utilities themselves fall into the trap, with sqlite3.exe passing the database name from the command line directly into sqlite3_open(char*). The open call expects UTF-8, but the actual encoding is a codepage. Use any non-ASCII characters on the commandline and it will fail. ---- _2006-Jan-09 12:54:10 by anonymous:_ {linebreak} SQLite .NET wrappers on Windows are using UTF-8 strings so reverting os_win.c commit 1.24 will break them and any other Windows program that is using sqlite3_open() according to specification. Admittedly they didn't work before, but that was why I supplied a patch which resulted in os_win.c 1.24. Keep in mind that sqlite3_open() also can be called as a result of SQL statements like "ATTACH DATABASE 'foo.db' AS Bar". Using the current codepage for SQL statements, as suggested to make sqlite3_open() work as before, poses other problems. Inserting a string with international chars using sqlite3.exe seems to incorrectly store it in the DB with the current codepage instead of UTF-8, so sqlite3.exe has to be fixed either way. /pLu ---- _2006-Jan-24 06:12:36 by anonymous:_ {linebreak} The specs can be wrong. I expect that they are written from a unix viewpoint which means the specification of char* as UTF-8 makes sense. This is the standard codepage for internationalization on all versions of unix. It seems to me that the choice of this was by the logic of: char* is the system codepage, system codepage is utf-8 (on unix), therefore char* is utf-8. However on Windows it isn't. I think it makes more sense to define it as system codepage. These changes have broken compatibility with all previous versions of sqlite. The .NET wrappers can easily be changed to call the wide string versions instead. Internally it can also call wide char versions. (where the definition of wide for sqlite is UTF-16). However. If you (or powers that be if not you), decide that utf-8 is better, then another set of char* functions should be provided on Windows platforms. i.e. sqlite3_openA() where A means the system codpage (ala standard MS Win32 naming conventions). This be a wrapper to convert the system codepage to UTF-16 and call the sqlite3_open16 function. i.e. go back to my original suggestion. i.e. in pseudo-code... int sqlite3_openA(char* utf8) { MultiByteToWideChar(utf8, widechar); return sqlite3_open16(widechar); } #define sqlite3_openW sqlite3_open16 This should be in the standard sqlite3 windows distribution. Otherwise the clients of sqlite are doing all of the work that sqlite should be handling for them. We could also provide wrappers for people who are using Windows TCHAR (i.e. standard Win32 definitions), and automatically define the correct sqlite3 symbol depending on if it is a unicode or multibyte build. i.e. users call sqlite3_openT which gets defined to the correct symbol. #ifdef UNICODE # define sqlite3_openT sqlite3_openW #else # define sqlite3_openT sqlite3_openA #endif ---- _2006-Mar-25 14:07:10 by drh:_ {linebreak} The solution is 2: Require that the filename be UTF-8 encoded. The documentation already stated this but it has been further enhanced to emphasize the fact. #c8c8c8 1499 code closed 2005 Oct anonymous 2006 Mar anonymous 3 1 Sqlite 3.2.7 does not support Chinese path. sqlite 3.2.7 does not support Chinese path. function: sqlite3_open unable to open database file But sqlite 3.2.2 support Chinese path. _2005-Dec-19 00:10:27 by anonymous:_ {linebreak} This bug is caused by the change made in os_win.c version 1.24. See also ticket #1533. Brodie #cfe8bd 1827 new fixed 2006 May anonymous TclLib 2006 May 4 4 Tcl-library: SQLITE_MISUSE from progress callback My Tk-application uses a long running sql-query which populates a canvas and stores the canvas ids back into a table. At the same time users can inspect the canvas by clicking on these objects - this involves running some other queries on the same database. These queries fail with SQLITE_MISUSE, which is ok. But any such failure also aborts the long-running main query, and this is a no-no that *must* be avoided. Here's a simplified piece of code that shows the behaviour: sqlite3 db :memory: db eval { create table bar(foo integer primary key); insert into bar values(1); insert into bar values(2); insert into bar values(3); insert into bar values(4); } db progress 10 update after idle { # simulate user query if {[catch { db eval {select count(*) from bar} } errmsg]} { puts "user-query: $errmsg" } else { puts "user-query ok ($errmsg)" } } db eval {begin exclusive transaction} for {set i 0} {$i<1000000} {incr i} { db eval {insert into bar values( NULL );} } db eval {commit} The result is user-query: library routine called out of sequence library routine called out of sequence while executing "db eval {insert into bar values( NULL );}" ("for" body line 2) invoked from within "for {set i 0} {$i<1000000} {incr i} { db eval {insert into bar values( NULL );} }" (file "tst.tcl" line 32) I can get the behaviour that I would like to see by storing the data in a real file instead of ":memory:" and using two different connections to it - in that case the user query would get a "database is locked" error but the main query would be unaffected. I wonder whether it isn't *always* problematic to use an sqlite object from within its own progress callback. If that is true it would in my opinion be preferable to throw a Tcl error whenever this is accidentally attempted. _2006-May-26 18:28:53 by anonymous:_ {linebreak} I'm not sure, but it seems that SQlite3 *doesn't* allow more than one sqlite3_stmt* reading records from the same thread at same time. #c8c8c8 1826 code closed 2006 May anonymous Parser 2006 May anonymous 4 4 Select unused table in from clause produces no results If there is an unused table in the from clause on a join then a select returns no results:
 BEGIN TRANSACTION; CREATE TABLE TP ( TP_ref INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, TP_id VARCHAR(255) NOT NULL ); INSERT INTO "TP" VALUES(1, 'A'); INSERT INTO "TP" VALUES(2, 'B'); INSERT INTO "TP" VALUES(3, 'C'); INSERT INTO "TP" VALUES(4, 'D'); INSERT INTO "TP" VALUES(5, 'E'); COMMIT;  BEGIN TRANSACTION; CREATE TABLE TC ( TC_ref INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, TC_id VARCHAR(255) NOT NULL); INSERT INTO "TC" VALUES(1, 'V'); INSERT INTO "TC" VALUES(2, 'W'); INSERT INTO "TC" VALUES(3, 'X'); INSERT INTO "TC" VALUES(4, 'Y'); INSERT INTO "TC" VALUES(5, 'Z'); COMMIT;  BEGIN TRANSACTION; CREATE TABLE TPC ( TP_ref INTEGER NOT NULL, TC_ref INTEGER NOT NULL, TLE_ref INTEGER, TPC_sca TINYINT NOT NULL, TPC_nbd TIMESTAMP NOT NULL, TPC_pkd TIMESTAMP NOT NULL, TPC_lsn INTEGER NOT NULL );  INSERT INTO "TPC" VALUES(1, 1, NULL, 1, '2006-05-07:23:59:59', '2006-05-07:23:59:59', 12345); INSERT INTO "TPC" VALUES(1, 3, NULL, 1, '2006-05-07:23:59:59', '2006-05-07:23:59:59', 99); INSERT INTO "TPC" VALUES(2, 1, NULL, 1, '2006-05-06:23:59:59', '2006-05-06:23:59:59', 99); INSERT INTO "TPC" VALUES(2, 2, NULL, 0, '2006-05-06:23:59:59', '2006-05-06:23:59:59', 99); INSERT INTO "TPC" VALUES(2, 3, NULL, 1, '2006-05-06:23:59:59', '2006-05-06:23:59:59', 99); INSERT INTO "TPC" VALUES(2, 4, NULL, 0, '2006-05-06:23:59:59', '2006-05-06:23:59:59', 99); INSERT INTO "TPC" VALUES(2, 5, NULL, 1, '2006-05-06:23:59:59', '2006-05-06:23:59:59', 99); INSERT INTO "TPC" VALUES(3, 3, NULL, 0, '2006-05-01:23:59:50', '2006-05-01:23:59:50', 60); INSERT INTO "TPC" VALUES(5, 3, NULL, 1, '2006-05-25 23:59:59', '2006-05-25 00:00:00', 9999); COMMIT;  BEGIN TRANSACTION; CREATE TABLE TLE (TLE_ref INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, TLE_id  VARCHAR(255) NOT NULL); COMMIT;   SELECT pc.TPC_sca, pc.TPC_nbd, pc.TPC_pkd, pc.TPC_lsn FROM TP p, TC c, TLE le, TPC pc WHERE pc.TLE_ref is NULL AND p.TP_id = 'A' AND pc.TP_ref = p.TP_ref AND c.TC_id = 'V' AND pc.TC_ref = c.TC_ref;    SELECT pc.TPC_sca, pc.TPC_nbd, pc.TPC_pkd, pc.TPC_lsn FROM TP p, TC c, TPC pc WHERE pc.TLE_ref is NULL AND p.TP_id = 'A' AND pc.TP_ref = p.TP_ref AND c.TC_id = 'V' AND pc.TC_ref = c.TC_ref; 
The first select will return nothing but when TLE is removed from the from clause then the correct result is returned. _2006-May-26 12:20:44 by drh:_ {linebreak} An inner join with an empty table always gives an empty result. Works as designed. #cfe8bd 1825 code fixed 2006 May anonymous 2006 May 1 1 Crash on ATTACH DATABASE SQLite crashes with an AV. Reproduce it with sqlite3.exe on Windows, any database will do: SQLite version 3.3.5 Enter ".help" for instructions sqlite> attach database ? as ?; #cfe8bd 1824 code fixed 2006 May drh 2006 May drh 1 1 UTF-16 encoding flag not honored when using shared cache When a second database connection in a single thread opens the same database file as the first and shares its cache, and if the database uses a UTF-16 encoding, and if the first connection has already loaded the schema, then the second connection does not realize that the database is UTF-16 and generates incorrect code. The following TCL script (run in the "testfixture" binary built using "make testfixture") illustrates the problem: sqlite3_enable_shared_cache 1 file delete -force test.db test.db-journal sqlite3 db1 test.db db1 eval { PRAGMA encoding=UTF16; CREATE TABLE t1(x,y); INSERT INTO t1 VALUES('abc','This is a test string'); } db1 close sqlite3 db1 test.db puts [db1 eval {SELECT * FROM t1}] sqlite3 db2 test.db puts [db2 eval {SELECT y FROM t1 WHERE x='abc'}] The second SELECT returns nothing. But if you comment out the first SELECT, the SELECT select works correctly. #c8c8c8 1823 code closed 2006 May anonymous 2006 May 1 1 pysqlite2.dbapi2.OperationalError: unable to open database file pysqlite2.dbapi2.OperationalError: unable to open database file _2006-May-23 16:09:56 by anonymous:_ {linebreak} This must be the most useless bug report ever filed here. It provides absolutely no information about the problem supposedly being reported. ---- _2006-May-23 18:03:54 by drh:_ {linebreak} This appears to be a report on an error for PySQLite. There is a separate website covering PySQLite. Please use Google to find it. This site covers only the core SQLite library. #cfe8bd 1821 code fixed 2006 May anonymous 2006 May 2 3 Optimizer causes IN operator to fail when comparing strings & numbers The "IN" operator will fail to return matching values if the data type doesn't match, e.g. when comparing numeric values in the database against a string constant in the query. To see this, create the following database: CREATE TABLE t1 (c1, c2); INSERT INTO t1 VALUES (1, 2); INSERT INTO t1 VALUES (2, 3); Next, execute the following queries, each of which should return one row: SELECT * FROM t1 WHERE c2 IN (2); SELECT * FROM t1 WHERE c2 IN ('2'); However, the second query won't return any data. Since sqlite doesn't care for the data type in all other queries, IMHO, this is wrong. By disabling the optimizer, the correct query result can be obtained: SELECT * FROM t1 WHERE +c2 IN ('2'); _2006-May-23 23:30:44 by drh:_ {linebreak} The following describes how the behavior is documented and (after the changes associated with this ticket) how the system actually works: CREATE TABLE t2(a, b NUMERIC); INSERT INTO t2 VALUES(1,2); INSERT INTO t2 VALUES(3,4); SELECT * FROM t2 WHERE b IN (2); This query returns the row 1,2 as expected. SELECT * FROM t2 WHERE b IN ('2'); This query also returns 1,2. Column b as numeric affinity which causes the '2' on the right-hand side of the IN operator to be coerced into an integer. SELECT * FROM t2 WHERE +b IN ('2'); This query returns no rows. The +b on the left-hand side of the IN operator is an expression now, not a column, so it has no affinity. Hence no coercion occurs on the right-hand side. An attempt is made to compare numeric 2 to string '2' and since those are not equal, nothing matches. SELECT * FROM t2 WHERE a IN (1); This query returns one row as you would expect. SELECT * FROM t2 WHERE a IN ('1'); The column a (unlike column b) has no affinity. So no type coercion occurs on the right-hand side of the IN operator. We end up comparing an integer to a string and get no match. #c8c8c8 1819 code closed 2006 May anonymous Unknown 2006 May persicom 4 3 faulty html code for concatenated field with "<" character Faulty HTML code generated. Sample code below for field "email" stored as john@myisp.com .mode=html{linebreak} .output=body.html select name, hphone,{linebreak} ''||email||''{linebreak} from mydata; Produces the following html code for the email field:{linebreak} TD><a href="mailto:john@myisp.com">john@myisp.com</a> Notice how the first and last "<" are produced as "<" in the generated output file. By the way, I just picked a random person to assign this ticket since I couldn't find a list of who works specific items. _2006-May-23 23:32:31 by drh:_ {linebreak} The .html output format escapes all characters in the result set of the query that are special to HTML. Hence, your < is escaped to <. This is by design and is exactly what you want want to happen if you had an arbitrary text field that just happened to contain a less-than sign. #c8c8c8 1818 code closed 2006 May anonymous Unknown 2006 May drh 3 3 sqlite3_mprintf() misbehaving on %*. formats
 cpb@earth:~/tmp$ cat test_mprintf.c #include  #include  #include   int main( int ac, char *av[] ) {         char *z;          z = sqlite3_mprintf("%.*s", 6, "abcdef  ");         printf( "z = '%s'\n", z );          z = sqlite3_mprintf("%.*q", 6, "abcdef  ");         printf( "z = '%s'\n", z );          z = sqlite3_mprintf("%.*z", 6, strdup("abcdef  "));         printf( "z = '%s'\n", z );          exit(0); } cpb@earth:~/tmp$ gcc test_mprintf.c -lsqlite3 cpb@earth:~/tmp$ ./a.out z = 'abcdef' z = 'abcdef  ' z = 'abcdef  ' 
Either the formatter isn't stopping at the right character count, or it's forgetting the NUL. In any case, it's handling at least one of the three cases incorrectly ;) I suspect this is where http://www.cvstrac.org/cvstrac/tktview?tn=551 came from, so it's possible that CVSTrac's =vxprintf()= would need the same fix. _2006-May-22 22:05:56 by drh:_ {linebreak} The precision is ignored for %q and %Q. I'm not sure the documentation says this anyplace, but there is a comment in the code that does. The use of %z is not allowed in sqlite3_mprintf(). That converter is for SQLite's internal use only. There was a bug that was not enforcing this but it is fixed now. ---- _2006-May-22 22:38:17 by anonymous:_ I'm not sure the documentation says this anyplace Nope. In fact, it strongly suggests that it _should_ work. The documentation says that "All of the usual printf formatting options apply" and (repeatedly) says that "%q" is a substitute for "%s". The documentation doesn't mention %Q at all, but I think there's another ticket open for that. The use of %z is not allowed in sqlite3_mprintf() Not a problem. I only included it as an afterthought to help narrow down the "bug". #f2dcdc 1816 code active 2006 May anonymous VDBE 2006 May 1 2 Database corruption with pragma auto_vacuum 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:_ {linebreak} 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:_ {linebreak} *: 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:_ {linebreak} 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. #f2dcdc 1815 code active 2006 May anonymous Parser 2006 May 3 3 Support of W3C-DTF(ISO8601 subset) is incomplete "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 #f2dcdc 1814 new active 2006 May anonymous 2006 May 3 4 Autoconf support for MacOSX univeral binaries 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
#
---- #f2dcdc 1812 new active 2006 May anonymous 2006 May 4 1 alter table add column default current_timestamp I wish I can alter my schema and add column with non-constant default. How difficult is this compared with constant default? #f2dcdc 1811 doc active 2006 May anonymous 2006 May 5 3 how many open cursors are allowed for one application? I would like to know, how many open cursors allowed at the same time. #f2dcdc 1810 new active 2006 May anonymous 2006 May 3 3 localtime() not threadsafe on UNIX 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 /* 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:_ {linebreak} 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. #f2dcdc 1809 code active 2006 May anonymous CodeGen 2006 May 1 3 Huge slowdown/increased memory use when using GROUP BY on big dataset 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} The slowdown first appears in SQLite 3.2.6 in check-in [2662]. ---- _2006-May-24 13:19:29 by anonymous:_ {linebreak} 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. #c8c8c8 1808 code closed 2006 May anonymous 2006 May 1 1 Wrong index is chosen Simple testcase: sqlite> create table test(guid text, arcid integer, url text, timestamp integer, keeptime integer); sqlite> create index test_idx1 on test(arcid, url); sqlite> create index test_idx2 on test(arcid, timestamp, keeptime); sqlite> explain query plan select guid, timestamp from test where arcid=1 and url='foobar'; 0|0|TABLE test WITH INDEX test_idx2 As you can see, the wrong index is chosen. This was not happening before the optimizer rewrite. If the table is filled with some data and then ANALYZE is executed, the right index is chosen. But if the table is empty, running ANALYZE will not correct the problem. If a order by clause is added, the wrong index is still chosen. Try this: explain query plan select guid, timestamp from test where arcid=1 and url='foobar' order by timestamp; Again, this bug was not present with the old optimizer. ---- _2006-May-18 11:24:57 by drh:_ {linebreak} This is not a bug. The optimizer is making the correct choice in this case, based on the limited information it has available. The optimizer will make a better choice if you run ANALYZE so that it can gather statistics about the table you are querying. Or, you can disable the ORDER BY term as a candidate for using indices by saying: ORDER BY +timestamp #cfe8bd 1807 code fixed 2006 May drh 2006 May drh 1 1 Assertion fault on a particular query. The following SQL causes an assertion fault: CREATE TABLE t1(a,b); CREATE INDEX i1 ON t1(a,b); CREATE TABLE t2(x,y); SELECT a, b FROM t1 WHERE a IN (SELECT x FROM t2 WHERE y=1) AND b IN (SELECT x FROM t2 WHERE y=2); _2006-May-11 13:07:42 by drh:_ {linebreak} A work-around until this problem is fixed is to disqualify the second IN clause from use by indices by adding a unary + to the left-hand side. Like this: CREATE TABLE t1(a,b); CREATE INDEX i1 ON t1(a,b); CREATE TABLE t2(x,y); SELECT a, b FROM t1 WHERE a IN (SELECT x FROM t2 WHERE y=1) AND +b IN (SELECT x FROM t2 WHERE y=2); #cfe8bd 1806 code fixed 2006 May anonymous TclLib 2006 May 3 4 Missing out-of-memory check at db/sqlite3/src/tclsqlite.c:1442 From https://bugzilla.mozilla.org/show_bug.cgi?id=336133: /sqlite/src/tclsqlite.c is missing a null-check in the case of OOM: zErr = malloc(200 + strlen(zFile)); sprintf(zErr,"Error: %s line %d: expected %d columns of data but found %d", zFile, lineno, nCol, i+1); Nickolay #cfe8bd 1805 code fixed 2006 May anonymous Shell 2006 May 3 4 missing out-of-memory check at src/shell.c:1485 From https://bugzilla.mozilla.org/show_bug.cgi?id=336134 : /sqlite/src/shell.c missing an null-check in case of OOM: nSql = strlen(zLine); zSql = malloc( nSql+1 ); strcpy(zSql, zLine); Nickolay #f2dcdc 1804 code active 2006 May anonymous Unknown 2006 May 4 3 Inconsistent value type returned by SUM when using a GROUP BY 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 1801 new active 2006 May anonymous Pager 2006 May owensmk 5 4 Include Support for User-defined Lock Synchronization 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 {link: http://www.gintana.com/sqlite/}. #c8c8c8 1800 new closed 2006 May anonymous 2006 May linus 1 2 possible to have the lastest version of sqlite with PHP 5????? i ve searched a long time, but i didn't found how to get the lastest sqlite version with php ! i only got the the 3.2.8 (if my memory is good), with the pdo_sqlite with php5. There is a way to get the lastest ??? i ve try to manual compil and install the lastest SQLite (all was OK, library installed into /usr/local/lib/ ) Then on my PHP install i ve put --with-sqlite=/usr/local/lib but it when doing the configure . Impossible to find the library.... if someone have the answer. please contact me _2006-May-07 16:23:03 by anonymous:_ {linebreak} They are talking of this install method on the zend site (Installing SQLite) http://www.zend.com/php5/articles/php5-sqlite.php but it look i don't have the library. but i got this into my /usr/local/lib -rw-r--r-- 1 root root 517636 May 7 09:59 libsqlite3.a -rwxr-xr-x 1 root root 825 May 7 09:59 libsqlite3.la lrwxrwxrwx 1 root root 19 May 7 09:59 libsqlite3.so -> libsqlite3.so.0.8.6 lrwxrwxrwx 1 root root 19 May 7 09:59 libsqlite3.so.0 -> libsqlite3.so.0.8.6 -rwxr-xr-x 1 root root 439786 May 7 09:59 libsqlite3.so.0.8.6 ---- _2006-May-07 16:25:10 by anonymous:_ {linebreak} contact me at contact AT super-barre.com ---- _2006-May-08 09:20:52 by anonymous:_ {linebreak} why status is close ? my question is still valable. ---- _2006-May-08 11:16:57 by anonymous:_ {linebreak} i m trying to install sqlite3 with php 4 i ve found the SQLite-1.0.3 from pecl website. which is gave with the version 2.8.14 of sqlite. normal install is like this. phpize; ./configure; make; make install; (that way work but with the bundle version of sqlite). i need to grab the last one . i ve try phpize; ./configure --with-sqlite=../sqlite-3.3.5/src/ (the relative path to the sqlite source) and the ./configure stop with checking for sqlite support... yes, shared checking for sqlite_open in -lsqlite... no configure: error: wrong sqlite lib version or lib not found i ve try ./configure --with-sqlite=/usr/local/lib (its where sqlite have copy the library when installing). and got the same thing ! Please need some help. ---- _2006-May-08 11:19:27 by anonymous:_ {linebreak} this list is used to report bugs of sqlite. this issue is related to php. please ask php mailing list. #f2dcdc 1799 code active 2006 May anonymous Pager 2006 May 2 3 temp_store=MEMORY slower than FILE for large intermediate result sets (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:_ {linebreak} 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. #f2dcdc 1798 doc active 2006 May anonymous 2006 May 5 4 preprocessed is misspelled on download page On the download page you'll find the text "proprocessed". #f2dcdc 1797 code active 2006 May anonymous TclLib 2006 May drh 1 1 COPY command doesn't work in tclsqlite 3.3.5 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} The same problem is present with version 3.3.7 over here. However, the indicated patch seem to work. #c8c8c8 1796 code closed 2006 May anonymous 2006 May 1 1 .import command not working in 3.3.5 The .import seems to be broken. I upgraded to 3.3.5 this morning (from 3.2.7) and code that depends on the TCL COPY command stopped working. I tried the sqlite3 shell, and verified that the .import command is not working either. It will import a one column file into a one column table, but will not do two or more columns. To reproduce: sqlite> create table zyx (col1,col2); sqlite> .import /home/centadm/win_pol4.csv zyx /home/centadm/win_pol4.csv line 1: expected 2 columns of data but found 1 Contents of win_pol4.csv,one line (yes it is a tab between the two columns, doesn't show well in this page): DATA1 DATA2 the tclib COPY command has the same affect, but no error message. _2006-May-05 16:36:02 by drh:_ {linebreak} The default separator is "|". To use a type you first must run .separator \t That should fix your problem with .import. Please provide more details about the TCL COPY command problem. #cfe8bd 1794 code fixed 2006 May anonymous Parser 2006 May 3 2 Sqlite parser produces incorrect error message for missing commas The following code: CREATE TABLE Test(x int32, y int32); SELECT Test.x Test.y FROM Test LIMIT 1; Produces this error: SQL error: no such column: Test.x The correct error message would be something like this: SQL error: near "Test.y": syntax error _2006-May-05 23:05:32 by anonymous:_ {linebreak} you're missing a comma in your sql statement. it should be SELECT Test.x, Test.y FROM Test LIMIT 1 ---- _2006-May-08 17:12:27 by anonymous:_ {linebreak} _:> 2006-May-05 23:05:32 by anonymous:{linebreak} > you're missing a comma in your sql statement.{linebreak} > it should be SELECT Test.x, Test.y FROM Test LIMIT 1{linebreak} I don't think you actually read what he is saying. The bug report is that the error message is incorrect and misleading. Imagine a situation where 30 columns are being queried and somewhere in there a comma is missing; a "no such column" error would be very confusing. ---- _2006-May-08 18:53:43 by anonymous:_ {linebreak} Actually "SELECT Test.x Test.y FROM Test LIMIT 1;" is (and should be) interpreted as "SELECT Test.x AS Test.y FROM...". So the error message from SQLite states just that: there is no Test.x column. ---- _2006-May-09 17:42:57 by anonymous:_ {linebreak} You are right, "SELECT x y FROM Test;" returns "x" renamed to "y". (Although I question whether this "should be" -- i.e. why do we have the "AS" keyword then?) But regarding the error, I am now quite confused. I can simplify the above expression to "SELECT x AS Test.y FROM Test;" which produces the error "no such column: x". But WHICH object is missing the column "x"? The column "x" most certainly does exist in the table Test. Unless I'm missing something, this error message is opaque and misleading. #c8c8c8 1793 code closed 2006 May anonymous 2006 May 2 3 sqlite3.dll crashes when doing an inner join with limit 0 Doing the following select on any table results in a crash select * from (select * from sometable limit 0) inner join sometable; The crash happens in sqlite3.dll and is reproducible in sqlite3.exe. Looks like a duplicate of ticket #1784. #cfe8bd 1792 doc fixed 2006 May anonymous 2006 May 1 1 "commercial" is misspelled on the SQLite license page Commercial is spelled wrong on the copyright page http://www.sqlite.org/copyright.html Not that this is a big deal, but its a big deal to any lawyer reading it. : ) #f2dcdc 1791 code active 2006 May anonymous Unknown 2006 May 1 1 Native threads support for BeOS 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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.) :) #f2dcdc 1790 code active 2006 May anonymous Pager 2006 May 3 3 :memory: performance difference between v2 and v3 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:_ {linebreak} The suggested change makes no difference in performance when I try it. ---- _2006-May-03 21:41:24 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 [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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 1789 doc active 2006 May anonymous Unknown 2006 May drh 4 4 sqlite3_result_error() not adequately documented 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. #c8c8c8 1529 code closed 2005 Nov anonymous 2006 May 1 1 can not uses japanese as table name to create table I am using the sqlite under japanese xp system. I want to create a {linebreak}Japanese name table, below are two create sql script.{linebreak} the First was create correctly, but second was failed.I do not know why.{linebreak}, because the wiki can not display japanese correctly, I will append the sql as attachment. Create TABLE お昼( F1 );(sucess){linebreak} Create TABLE カード( F1 );(failed){linebreak} by the way , I use the sqlite3 commandline utility to execute the sql.{linebreak} _2005-Nov-19 07:37:45 by anonymous:_ {linebreak} sorry I can not find how to attach the sql to the ticket. how to do it? ---- _2005-Nov-19 12:10:32 by anonymous:_ {linebreak} Please use bracket quote.{linebreak} CREATE TABLE [Card] (c); ---- _2005-Nov-19 12:54:50 by anonymous:_ {linebreak} looks like bracket does not work as expected?{linebreak} Create TABLE [お昼]( F1 );(sucess)}{linebreak} Create TABLE [カード]( F1 );(failed){linebreak} ---- _2005-Nov-20 00:39:29 by anonymous:_ {linebreak} I'm japanse and using japanese w2k. {linebreak} but i can't give you an advice any more because your information is too few. If you really wish to solve the problem, please write more in detail. ---- _2005-Nov-20 04:47:21 by anonymous:_ {linebreak} hi, thank you for your help.{linebreak} my sqls are very simple {linebreak} the first successful sql is {linebreak} create table customer(the japanese spelling is torihikisaki) (F1);{linebreak} the second failed sql is {linebreak} create table card(the japansese spelling is ka-do) (F1);{linebreak} ---- _2005-Nov-20 12:19:23 by anonymous:_ {linebreak} Don't forget bracket quote.{linebreak} I tried the sql statement in hiragana, katakata and hankaku by shiftjis, euc-jp and utf-8 encodings from interactive sqlite3 command shell and pipe connection. But I could not make the problem reappear at all. If you got a error message, you must write it. How did the sql fail? ---- _2005-Nov-20 13:09:20 by anonymous:_ {linebreak} Thank you very much for your help! now I can create the table successfully please close this ticket #c8c8c8 2091 code closed 2006 Nov anonymous 2006 Nov 3 3 thread unsafety + solution I've been doing a scan on the PHP codebase looking for the usage of thread unsafe functions and found a number in libsqlite. Ilia Alshanetsky who you probably know has fixed a number of them in the PHP builds, but of course the problem in libsqlite remains. Ilia also suggested I would contact you. I'm not familiar with the sqlite codebase, but the problems are as follows: date.c contains gmtime() (use gmtime_r), localtime() (use localtime_r) and rand() (use rand_r). All mentioned functions are not thread safe and should be replaced by the mentioned thread-safe counterparts. I think it would be wise to grep the rest of sqlite for the usage of these functions as well. Kind regards, Ron Korving Already fixed. See ticket #1906. #f2dcdc 2090 build active 2006 Nov anonymous 2006 Nov 4 3 Test corrupt2.test fails: Solaris 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:_ {linebreak} I should mention that this is SunOS 5.8, and TCL version 8.4.14. ---- _2006-Dec-05 10:22:08 by anonymous:_ {linebreak} 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:_ {linebreak} That worked! Thank you so much! #f2dcdc 2089 code active 2006 Nov anonymous 2006 Nov 3 3 Decouple sqlite_int64 from other 64bit datatypes 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:_ {linebreak} 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)? #cfe8bd 2088 code fixed 2006 Nov anonymous 2006 Nov 1 1 Ticket management problem : type We cannot anymore open a ticket with the correct type. The only choice for a ticket's type is now "code". The edition of a ticket has the same problem. The reports which include type for search criteria are now incomplete. #f2dcdc 2087 new active 2006 Nov anonymous 2006 Nov 3 3 Ability to add a check constraint via the alter table command *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 #f2dcdc 2086 code active 2006 Nov anonymous 2006 Nov 5 4 Alias in update 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. #c8c8c8 2085 code closed 2006 Nov anonymous 2006 Nov 5 4 Round statement with different behavior between 3.2.8 and 3.3.7 *Sqlite 3.2.8* : SELECT ROUND (julianday(datetime('now','localtime')) - julianday (datetime('2005-12-31 12:13:14'))); return : 331 *Sqlite 3.3.7* : SELECT ROUND (julianday(datetime('now','localtime')) - julianday (datetime('2005-12-31 12:13:14'))); return : 331.0 It seems to be due to Sqlite 3.3.5 modification : Change the round() function to return REAL instead of TEXT. Two questions : *:Is this behavior works as designed ? *:What is the best way to retrieve 331 again ? _2006-Nov-27 18:09:38 by anonymous:_ {linebreak} select cast( ROUND (julianday(datetime('now','localtime')) - julianday (datetime('2005-12-31 12:13:14'))) as integer ); ---- _2006-Nov-27 21:34:17 by anonymous:_ {linebreak} Thanks :) #f2dcdc 2084 code active 2006 Nov anonymous 2006 Nov 4 3 Add API function mapping column decl string to SQLite type 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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; } #f2dcdc 2083 code active 2006 Nov anonymous 2006 Nov 4 4 Give more detailed extension loading error information with dlerror 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() #f2dcdc 2082 code active 2006 Nov anonymous 2006 Nov 3 4 UNIX: configure script doesn't enable loading of extensions 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 #f2dcdc 2081 code active 2006 Nov anonymous 2006 Nov doughenry 1 1 sqlite3_column_decltype throws exception, if selection is grouped 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:_ {linebreak} 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. #f2dcdc 2080 code active 2006 Nov anonymous 2006 Nov 4 4 Tranfering large BLOB data not efficient 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:_ {linebreak} 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 #c8c8c8 2079 code closed 2006 Nov anonymous 2006 Nov 1 1 strftime doesn't work in where statement sqlite3 -version 3.3.5 sqlite> select distinct strftime('%H',timeOnly) from sampleData; 14 12 10 09 15 13 11 16 19 sqlite> select count(*) from sampleData where strftime('%H',timeOnly) = 12; 0 Why didn't this return any rows? _2006-Nov-22 02:08:53 by anonymous:_ {linebreak} Try '12' sqlite> select a from (select '12' a) where a=12; sqlite> select a from (select 12 a) where a=12; 12 #cfe8bd 2078 code fixed 2006 Nov anonymous 2006 Nov 2 1 Patch to make PRAGMA backward compatible with 3.3.7 and prior versions While hacking on Ruby on Rails, my co-worker found that some unittests stoped to work. When we started to look deeply we found that it happened after a system upgrade and identified the cause being the sqlite3 packages. I started to research the code to identify where it was happening and discovered it was on PRAGMA output. You can grab more details and a working patch from http://bugs.debian.org/397531 _2006-Nov-21 14:09:34 by anonymous:_ {linebreak} Which PRAGMA option? Can you reproduce this in the SQLite shell (sqlite3)? ---- _2006-Nov-23 21:37:52 by anonymous:_ {linebreak} No. On sqlite it shows the same behaviour IIRC but it fails when you use the library. Please, read the Debian bug report and you'll see all the reasearching I've done to discover where it's caused and how to solve it. ---- _2006-Nov-23 22:39:55 by anonymous:_ {linebreak} The odds of getting a bug fixed are better if you can demonstrate the problem in the sqlite3 shell or supply a small standalone C program. $ ./sqlite3 SQLite version 3.3.8 Enter ".help" for instructions sqlite> create table t1(a text); sqlite> .nullvalue (null) sqlite> pragma table_info(t1); 0|a|text|0||0 SQLite version 3.3.7 Enter ".help" for instructions sqlite> create table t1(a text); sqlite> .nullvalue (null) sqlite> pragma table_info(t1); 0|a|text|0|(null)|0 SQLite version 3.2.2 Enter ".help" for instructions sqlite> create table t1(a text); sqlite> .nullvalue (null) sqlite> pragma table_info(t1); 0|a|text|0|(null)|0 ---- _2006-Nov-23 22:49:08 by anonymous:_ {linebreak} I think I did a bit of research finding the related bug, which patch added it, providing a patch that works and all the rest reported on the Debian bug too. Isn't it enough? ---- _2006-Nov-23 23:00:19 by anonymous:_ {linebreak} Oh, if it were only that simple... ;-) http://www.mail-archive.com/sqlite-users@sqlite.org/msg18994.html #f2dcdc 2077 code active 2006 Nov anonymous 2006 Nov 2 1 Problems with using ASCII symbols 0x80 - 0xFF in database path 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! =(
================================= #f2dcdc 2076 code active 2006 Nov anonymous 2006 Nov a.rottmann 1 1 % exists as value in varchar 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:_ {linebreak} % is not a special character. Can you post a small C program demonstrating the problem? #f2dcdc 2074 code active 2006 Nov anonymous 2006 Nov 4 4 feature request: .dump with page_size 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). #c8c8c8 2073 code closed 2006 Nov anonymous 2006 Nov 4 4 Ordering by a named expression which includes random doesn't work When sorting results by a named expression that includes random() (or another function whose outputs don't depend soley on its inputs), random gets called twice: once for computing the output field, and once for sorting. The following example (using the database example from the man page) illustrates the problem: sqlite> select random() as x from memos order by x; 1225575423885923075 1023558125602533105 _2006-Nov-20 17:11:16 by anonymous:_ {linebreak} SQLite currently copies any matching aliased expressions from the SELECT list to the ORDER BY clause. As result, random() is executed twice - once in the result set for the row and once in the ORDER BY clause. If you wish to preserve this random() value you have to do it in an inner select. select * from (select random() r union all select random() r) order by r; Databases in general do not agree on how random() works. Some optimize the call out altogether and replace it with a constant for the SELECT, and others only return one random value per select statement. #cfe8bd 2072 code fixed 2006 Nov anonymous 2006 Nov 1 1 .dump does not dump create index statements From CVS a few minutes ago... $ ./sqlite3.exe SQLite version 3.3.8 Enter ".help" for instructions sqlite> CREATE TABLE t1(a, b, primary key(b, a)); sqlite> INSERT INTO "t1" VALUES(1, 2); sqlite> CREATE TABLE t2(c, d); sqlite> INSERT INTO "t2" VALUES(3, 4); sqlite> INSERT INTO "t2" VALUES(-30, -40); sqlite> CREATE VIEW v1 as select * from t1, t2 where b>d; sqlite> CREATE INDEX t1_i on t1(a, b); sqlite> CREATE UNIQUE INDEX t2_i on t2(d, c); sqlite> .dump BEGIN TRANSACTION; CREATE TABLE t1(a, b, primary key(b, a)); INSERT INTO "t1" VALUES(1, 2); CREATE TABLE t2(c, d); INSERT INTO "t2" VALUES(3, 4); INSERT INTO "t2" VALUES(-30, -40); CREATE VIEW v1 as select * from t1, t2 where b>d; COMMIT; sqlite> select name, sql from sqlite_master; t1|CREATE TABLE t1(a, b, primary key(b, a)) sqlite_autoindex_t1_1| t2|CREATE TABLE t2(c, d) v1|CREATE VIEW v1 as select * from t1, t2 where b>d t1_i|CREATE INDEX t1_i on t1(a, b) t2_i|CREATE UNIQUE INDEX t2_i on t2(d, c) An older version of SQLite (3.2.2) dumps indexes correctly. I have not tested dumping databases with triggers in the latest CVS. CREATE INDEX and CREATE UNIQUE INDEX statements are not outputted in .dump for the SQLite 3.3.8 release version as well as current CVS. People using the sqlite3 commandline shell for backups and exports should be aware that SQLite 3.3.7 is the last release version that dumps index create statements. ---- _2006-Nov-20 04:55:28 by anonymous:_ {linebreak} There is a typo in the SQL for .dump - "AND AND". This is why INDEX statements are not output: RCS file: /sqlite/sqlite/src/shell.c,v retrieving revision 1.155 diff -u -3 -p -r1.155 shell.c --- src/shell.c 8 Nov 2006 12:25:43 -0000 1.155 +++ src/shell.c 20 Nov 2006 04:40:04 -0000 @@ -986,7 +986,7 @@ static int do_meta_command(char *zLine, ); run_schema_dump_query(p, "SELECT name, type, sql FROM sqlite_master " - "WHERE sql NOT NULL AND " + "WHERE sql NOT NULL " " AND type!='table' AND type!='meta'", 0 ); run_table_dump_query(p->out, p->db, However, with this patch, CREATE VIEW statements are now doubled up: SQLite version 3.3.8 Enter ".help" for instructions sqlite> CREATE TABLE t1(a, b, primary key(b, a)); sqlite> INSERT INTO "t1" VALUES(1, 2); sqlite> CREATE TABLE t2(c, d); sqlite> INSERT INTO "t2" VALUES(3, 4); sqlite> INSERT INTO "t2" VALUES(-30, -40); sqlite> CREATE INDEX t2i on t2(d, c); sqlite> CREATE INDEX t1_i on t1(a, b); sqlite> CREATE UNIQUE INDEX t2_i on t2(d, c); sqlite> CREATE VIEW v1 as select * from t1, t2 where b>d; sqlite> .dump BEGIN TRANSACTION; CREATE TABLE t1(a, b, primary key(b, a)); INSERT INTO "t1" VALUES(1, 2); CREATE TABLE t2(c, d); INSERT INTO "t2" VALUES(3, 4); INSERT INTO "t2" VALUES(-30, -40); CREATE INDEX t2i on t2(d, c); CREATE INDEX t1_i on t1(a, b); CREATE UNIQUE INDEX t2_i on t2(d, c); CREATE VIEW v1 as select * from t1, t2 where b>d; CREATE VIEW v1 as select * from t1, t2 where b>d; COMMIT; I could fix this, but I'm not sure how rootpage works. Are VIEWs and TRIGGERs always guaranteed to have rootpage==0? #cfe8bd 2071 code fixed 2006 Nov anonymous 2006 Nov 1 1 VACUUM doesn't delete temp file on Windows since Check-in [3470] Latest CVS used (after 3.3.8 release). Problem reproducible for both MinGW and Cygwin compilers. I added a printf in vacuum.c to see what was going on: diff -u -3 -p -r1.64 vacuum.c --- src/vacuum.c 10 Oct 2006 13:07:36 -0000 1.64 +++ src/vacuum.c 18 Nov 2006 17:18:07 -0000 @@ -26,6 +26,7 @@ */ static int execSql(sqlite3 *db, const char *zSql){ sqlite3_stmt *pStmt; + printf("execSql: %s\n", zSql); if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ return sqlite3_errcode(db); } I recompiled and then ran the following: $ ./sqlite3 v.db vacuum execSql: ATTACH 'C:\WINNT\etilqs_A4jRmvemfNEpIDM' AS vacuum_db; execSql: PRAGMA vacuum_db.synchronous=OFF execSql: BEGIN EXCLUSIVE; execSql: CREATE TABLE vacuum_db.t1(a, b, primary key(b, a)) execSql: CREATE TABLE vacuum_db.t2(c, d) execSql: CREATE INDEX vacuum_db.t2i on t2(d, c) execSql: INSERT INTO vacuum_db.'t1' SELECT * FROM 't1'; execSql: INSERT INTO vacuum_db.'t2' SELECT * FROM 't2'; execSql: INSERT INTO vacuum_db.sqlite_master SELECT type, name, tbl_name, rootpage, sql FROM sqlite_master WHERE type='view' OR type='trigger' OR (type='table' AND rootpage=0) $ ls -l 'C:\WINNT\etilqs_A4jRmvemfNEpIDM' -rwx------+ 1 Administrator None 5120 Nov 18 12:19 C:\WINNT\etilqs_A4jRmvemfNEpIDM The vacuum temp file was not deleted. It used to be correctly deleted until "Check-in [3470] : VACUUM now uses a temporary file in the official TEMP folder instead of a file in the same directory as the original database". If I revert vacuum.c to r1.63 everything appears to work correctly again. I also noticed that the old vacuum version's temp file used to be created in the same directory as the database. Could the previous behavior be preserved if possible? #f2dcdc 2070 code active 2006 Nov anonymous 2006 Nov 4 4 No error for ambiguous result alias in WHERE clause 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:_ {linebreak} 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. #f2dcdc 2068 code active 2006 Nov anonymous 2006 Nov 4 4 pkgIndex.tcl contains incomplete version number 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. #f2dcdc 2066 code active 2006 Nov anonymous 2006 Nov 2 2 Incorrect error message in the case of ENOLCK 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") #cfe8bd 2065 code fixed 2006 Nov anonymous 2006 Nov 4 4 Make .dump output a few percent smaller When you're dumping a multigigabyte database, saving a few percent on output size helps. This patch changes .dump INSERT format from: INSERT INTO "abc" VALUES(4, 5, 6); INSERT INTO "abc" VALUES(10, 20, 30); INSERT INTO "abc" VALUES(3, 2, 1); INSERT INTO "abc" VALUES(200.345, -34.18404, 2000000000000.0); to: INSERT INTO "abc" VALUES(4,5,6); INSERT INTO "abc" VALUES(10,20,30); INSERT INTO "abc" VALUES(3,2,1); INSERT INTO "abc" VALUES(200.345,-34.18404,2000000000000.0); File output size reduction is more apparent on large tables with dozens of columns. Import times and gzipping such big files is also marginally faster. Index: src/shell.c =================================================================== RCS file: /sqlite/sqlite/src/shell.c,v retrieving revision 1.155 diff -u -3 -p -r1.155 shell.c --- src/shell.c 8 Nov 2006 12:25:43 -0000 1.155 +++ src/shell.c 12 Nov 2006 16:48:17 -0000 @@ -749,7 +749,7 @@ static int dump_callback(void *pArg, int zSelect = appendText(zSelect, zText, '"'); rc = sqlite3_step(pTableInfo); if( rc==SQLITE_ROW ){ - zSelect = appendText(zSelect, ") || ', ' || ", 0); + zSelect = appendText(zSelect, ") || ',' || ", 0); }else{ zSelect = appendText(zSelect, ") ", 0); } #c8c8c8 2064 code closed 2006 Nov anonymous 2006 Nov 3 4 Table Name ignored if table Alias specified Table aliases should not disallow the use of the original table name, they should just be an alternative name for the table if there is no ambiguity. create table t1(a integer); select a, t.a, t1.a from t1 t; SQL error: no such column: t1.a _2006-Nov-11 23:18:19 by anonymous:_ {linebreak} This patch allows table aliases or the original table names to be used in column references within the same SELECT. The sole regression in "make test" was join3-3.1, but its failure seems correct because the SELECT is indeed ambiguous. That test is corrected in this patch. Index: src/expr.c =================================================================== RCS file: /sqlite/sqlite/src/expr.c,v retrieving revision 1.268 diff -u -3 -p -r1.268 expr.c --- src/expr.c 24 Aug 2006 15:18:25 -0000 1.268 +++ src/expr.c 11 Nov 2006 23:15:38 -0000 @@ -863,10 +863,7 @@ static int lookupName( iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( pTab->nCol>0 ); if( zTab ){ - if( pItem->zAlias ){ - char *zTabName = pItem->zAlias; - if( sqlite3StrICmp(zTabName, zTab)!=0 ) continue; - }else{ + if( pItem->zAlias==0 || sqlite3StrICmp(pItem->zAlias, zTab)!=0 ){ char *zTabName = pTab->zName; if( zTabName==0 || sqlite3StrICmp(zTabName, zTab)!=0 ) continue; if( zDb!=0 && sqlite3StrICmp(db->aDb[iDb].zName, zDb)!=0 ){ Index: test/join.test =================================================================== RCS file: /sqlite/sqlite/test/join.test,v retrieving revision 1.22 diff -u -3 -p -r1.22 join.test --- test/join.test 20 Jun 2006 11:01:09 -0000 1.22 +++ test/join.test 11 Nov 2006 23:15:38 -0000 @@ -458,4 +458,15 @@ do_test join-10.1 { } {} } ;# ifcapable subquery +# Ticket #2064: Allow table names and table aliases to coexist +# in column references. +# +do_test join-10.2 { + execsql { + CREATE TABLE t2064(a); + INSERT INTO t2064 VALUES(123); + SELECT a, t.a, t2064.a FROM t2064 t; + } +} {123 123 123} + finish_test Index: test/join3.test =================================================================== RCS file: /sqlite/sqlite/test/join3.test,v retrieving revision 1.4 diff -u -3 -p -r1.4 join3.test --- test/join3.test 19 Jan 2005 23:24:51 -0000 1.4 +++ test/join3.test 11 Nov 2006 23:15:38 -0000 @@ -53,7 +53,7 @@ for {set N 1} {$N<=$bitmask_size} {incr # Error of too many tables in the join # do_test join3-3.1 { - set sql "SELECT * FROM t1 AS t0, t1" + set sql "SELECT * FROM t1 AS a1, t1 AS a2" for {set i 2} {$i<=$bitmask_size} {incr i} {append sql ", t$i"} catchsql $sql } [list 1 "at most $bitmask_size tables in a join"] ---- _2006-Nov-15 05:30:25 by anonymous:_ {linebreak} This proposed syntax might not be standard SQL. PostgreSQL can parse it, but it rewrites the query internally as something completely different: "select t.a, t.a, f.a from t1 t, t1 f;" template1=# create table t1(a integer); CREATE TABLE template1=# insert into t1 values(12); INSERT 17306 1 template1=# insert into t1 values(23); INSERT 17307 1 template1=# select a, t.a, t1.a from t1 t; NOTICE: adding missing FROM-clause entry for table "t1" a | a | a ----+----+---- 12 | 12 | 12 12 | 12 | 23 23 | 23 | 12 23 | 23 | 23 (4 rows) MySQL just chokes on it: mysql> select a, t.a, t1.a from t1 t; ERROR 1109: Unknown table 't1' in field list Could someone with access to other major databases post the output of this SELECT? ---- _2006-Nov-15 20:22:01 by anonymous:_ {linebreak} Both Oracle and Sybase reject t1.a in the example SELECT, so this enhancement request is withdrawn. #f2dcdc 2063 code active 2006 Nov anonymous 2006 Nov 4 4 vtab_err.test fails if sqlite is compiled without -DSQLITE_MEMDEBUG 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. #f2dcdc 2062 code active 2006 Nov anonymous 2006 Nov 4 4 document 'pk' column of PRAGMA table_info() Comment in pragma.c and sqlite.org/pragma.html does not mention the sixth column of PRAGMA table_info(). #f2dcdc 2061 code active 2006 Nov anonymous 2006 Nov anonymous 5 5 cleanup for quickstart.html just compiled the C example from quickstart.html (gcc/glibc Debian SID) a small hint (a bit pea-counting): to avoid warnings either #include for the exit() function or (maybe better) use return instead of calling exit(). #f2dcdc 2059 code active 2006 Nov anonymous 2006 Nov 1 1 Still missing .DEF file from Windows 3.3.8 source code distribution 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:_ {linebreak} Works fine as is with MinGW ./configure && make sqlite3.exe #c8c8c8 2058 code closed 2006 Nov anonymous 2006 Nov 1 1 sum or total result in only 1 row returned If I run the following query it returns 61,000 rows, if I uncomment the sum() or total() (I've tried both) then it returns 1 row. How can I debug this? select f.checksum||f.data_size as [groupby], dups.count as [Occurences], /* total(f.data_size) as [size Total Size], */ path||"\"||name as [Location] from files as f join (select count(*) as count,checksum,data_size from files where is_duplicate=1 and data_size<>0 I can select the sum(data_size) from files with no issue, add a group by, add the where etc, with no problem. group by checksum,data_size) as dups on dups.checksum=f.checksum and dups.data_size=f.data_size _2006-Nov-09 11:15:53 by anonymous:_ {linebreak} The formatter seems to have removed the asterisk from the closing comment in the attached select. ---- _2006-Nov-09 11:19:53 by anonymous:_ {linebreak} In fact, it seems to have removed quite a bit, wish I'd done a preview now :( Here's the correct code:- select f.checksum||f.data_size as [groupby], dups.count as [Occurences], /* total(f.data_size) as [size Total Size], */ path||"\"||name as [Location] from files as f join (select count(*) as count,checksum,data_size from files where is_duplicate=1 and data_size<>0 group by checksum,data_size) as dups on dups.checksum=f.checksum and dups.data_size=f.data_size ---- _2006-Nov-09 13:43:07 by drh:_ {linebreak} TOTAL() and SUM() are aggregate functions and cause the query to become an aggregate query. This is the way it is suppose to work. All other SQL database engines do the same thing. ---- _2006-Nov-09 13:56:00 by anonymous:_ {linebreak} I think you've missed the point, there should be a vast number of rows, the sum or total is failing. Is there a way I can debug this as the database is about 300Mb in size, therefore can't attach it. The group by without the sum() returns 60+ thousand rows, adding the sum shoudl merely add an extra column to the output, not reduce to a single row, the sum should be 1 per grouping. ---- _2006-Nov-09 13:57:25 by anonymous:_ {linebreak} Sorry, just spotted what you mean, I've dropped my group by off the end.... hangs head in shame and withdraws ticket!!!!! ---- _2006-Nov-09 14:10:19 by anonymous:_ {linebreak} Actually, there possibnly is a syntax bug here as I think in other databases you wouldn't be able to output a field that wasn't either an aggregate or in the group by? sqlite is allowing the output but then reducing to a single column #f2dcdc 2057 code active 2006 Nov anonymous 2006 Nov 3 1 full_column_names when 2 or more tables are joined is not working 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:_ {linebreak} Version 3.3.3 as well has the same problem. ---- _2006-Nov-09 09:34:52 by anonymous:_ {linebreak} 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. #cfe8bd 2056 code fixed 2006 Nov anonymous 2006 Nov 2 2 unable to ".quit' or '.exit' SQLite cmdline tool with checkin 3491 it is not possible any more to quit the SQLite commandline tool if using interactive #cfe8bd 2055 code fixed 2006 Nov anonymous 2006 Nov 1 1 [patch] fix build errror (os_win.c) typo, goc is not a variable name, looks like it is intended to use got there. Index: os_win.c{linebreak} ==================================================================={linebreak} RCS file: /sqlite/sqlite/src/os_win.c,v{linebreak} retrieving revision 1.67{linebreak} diff -u -r1.67 os_win.c{linebreak} --- os_win.c 6 Nov 2006 21:20:26 -0000 1.67{linebreak} +++ os_win.c 7 Nov 2006 09:50:15 -0000{linebreak} @@ -997,7 +997,7 @@{linebreak} }{linebreak} if( got==(DWORD)amt ){{linebreak} return SQLITE_OK;{linebreak} - }else if( goc<0 ){{linebreak} + }else if( got<0 ){{linebreak} return SQLITE_IOERR_READ;{linebreak} }else{{linebreak} return SQLITE_IOERR_SHORT_READ;{linebreak} #c8c8c8 2054 code closed 2006 Nov anonymous 2006 Nov 1 1 material to learn SQLite Hai i am new to SQLite where do i get materials to start from basics. _2006-Nov-07 10:09:41 by anonymous:_ {linebreak} There's a link called documentation... http://www.sqlite.org/docs.html In this page there's another link called Sqlite in 5 minutes or less... http://www.sqlite.org/quickstart.html #c8c8c8 2053 code closed 2006 Nov anonymous 2006 Nov 1 1 problem on solaris 10 I make and install sqlite3.3.8 on Solaris 10, i need to vork with tcl, but it didnt work. Example in Quick Start dont work also. I try resolve this problem with wiki, nothing. Error: couldn't load file ... fatal: rellocation error ... symbol fdatasync: referenced symbol not found _2006-Nov-03 12:06:02 by drh:_ {linebreak} See ticket #1545. I am unable to fix this right now because it requires a change to the configure script and autoconf is busted in SuSE 10.1 which is what I have installed on all my systems. #c8c8c8 2052 code closed 2006 Nov anonymous 2006 Nov 1 1 BLOBs still do not work on version 3.0 I use Python 2.5 to access sqlite3: *:Create a pil Image file, then *:convert to string throught img.save to StringIO *:insert into a BLOB column *:Finally try to "select * from tab" ERROR: c.execute('select * from tab order by path') OperationalError: Could not decode to UTF-8 column 'pic' with text 'X`' - i have already a working python program where this same data works fine in a 'dumdbm' database or write, then read a binary files. But I need the sql power, that is why I started trying of sqlite. _2006-Nov-01 23:24:38 by drh:_ {linebreak} This website is for reporting problems about SQLite. Your problem appears to be with Python. #f2dcdc 2051 code active 2006 Nov anonymous 2006 Nov 5 5 minor documentation bug 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 #cfe8bd 2050 code fixed 2006 Nov anonymous 2006 Nov 3 3 Assert typo in sqlite/src/btree.c ? Around line 1083, in sqlite/src/btree.c: assert( pPage->nCell = get2byte(&pPage->aData[hdr+3]) ); Should that be "==" instead of "="? If so, kudos to the typo.pl automatic typo scanner, if not, shame on me :) Daniel _2006-Nov-01 12:08:11 by drh:_ {linebreak} Good eye. This is not really a bug, though, since the code in question is contained within #if 0 ... #endif I'll resolve this issue by removing the dead code. ---- _2006-Nov-01 21:10:36 by anonymous:_ {linebreak} Not a good eye, just using a clever tool IMHO: http://www.cpan.org/authors/id/T/TY/TYPO/ I got a bunch of results regarding sqlite3 as in Mozilla codebase, but I can't figure out which ones are serious (e.g. missing the #if 0) and most are "use of func that can overflow", which I imagine aren't even interesting. Anyway, I can paste the results here, in a new ticket, email you or leave them alone, just let me know :) Daniel #f2dcdc 2046 code active 2006 Oct anonymous 2006 Nov shess 1 1 FTS1 - Error closing database due to unfinished statements 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:_ {linebreak} Attached tighter version of the replication script, generated in isolating what mattered to the bug. #c8c8c8 2040 code closed 2006 Oct anonymous 2006 Nov 1 1 Fatal reloc error: Using sqlite-3.3.6 with apache-2.2.0 on SPARC Solar Hi, I am on a Solaris 8 system. Main package I am trying to use SQLite with is apache. After unbundling all required packages, I get the following message when trying to run the http server I unbundled sqlite-3.3.6-sol8-sparc-local.gz from SUN's sunfreeware site. +++++++++++++++++++++++++++ ftcnssqadal3% !! ./httpd -f /usr/local/apache2/conf/httpd-std.conf ld.so.1: httpd: fatal: relocation error: file /usr/local/apr/lib/libaprutil-1.so.0: symbol sqlite_freemem: referenced symbol not found Killed ftcnssqadal3% --------------------------- Note: all s/w are gotten from http://sunfreeware.com/. They are apache-2.2.0-sol8-sparc-local.gz sqlite-3.3.6-sol8-sparc-local.gz ---------------------------------------- How can I get the "sqlite_freemem" symbol resolved ? Thank you in advance Regards AhLek Chin 617.563.9722 ahlek.chin@fmr.com Similar thing happens in Solaris 9 (x86) : ./apache2 start httpd starting. ld.so.1: httpd: fatal: libsqlite.so.0: open failed: No such file or directory Killed exit status 137 --- Then I create a link for libsqlite.so.0 in /usr/local/lib : ln -s libsqlite3.so.0 libsqlite.so.0 ./apache2 start httpd starting. ld.so.1: httpd: fatal: relocation error: file /usr/local/apr/lib/libaprutil-1.so.0: symbol sqlite_freemem: referenced symbol not found Killed exit status 137 Same versions of packages : apache 2.2.0, sqlite 3.3.6 #f2dcdc 1992 code active 2006 Sep anonymous 2006 Nov shess 1 1 FTS1: Problems after dropping utility tables 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!). #c8c8c8 1973 code closed 2006 Sep anonymous Parser 2006 Nov 1 2 sqlite3_prepare (DLL 3.3.7) exception in two programs I'm using Sqlite3explorer to browse Sqlite databases under Windows. Sometime it shows window "Access violation at address 609306F0 in module sqlite3.dll. Read of address 02DC206F" - just at startup time. When use Sqlite from my own code I also see exceptions at the same address: EXCEPTION! CODE:C0000005 ADDRESS:609306F0 REGISTERS: 279E210 00 00 00 00 00 00 00 58 C7 95 14 40 00 00 00 00 279E220 00 00 00 D0 02 40 00 00 00 00 00 00 00 00 00 00 279E230 AB 03 00 00 2B 00 00 00 53 00 00 00 2B 00 00 00 END OF EXCEPTION REPORT during execute sqlite3_prepare library call. In most cases it works with the same database and same select statements OK, but sometimes gives this error. In the previous Sqlite versions 3.3.4-3.3.6 there is same bug, but access violation address differs: 60925543 or (most often) 6092F520. (The entry point of sqlite3_prepare in 3.3.7 is 0x609263D8). _2006-Sep-10 07:43:20 by anonymous:_ {linebreak} Sorry. 3.3.4 seems to be free of this bug. ---- _2006-Sep-10 15:38:42 by anonymous:_ {linebreak} Some sample code, the SQL statement being prepared, a sample database or some schema info would go a long way toward tracking this down ... ---- _2006-Sep-16 13:31:42 by anonymous:_ {linebreak} Here it is: http://sqlite.snop.ru/sqlite337_bug.zip (1 Mb - sqlite3explorer + DLL + database sample) Sqlite3explorer with sqlite3.3.7 dll unable to show a database structure of test.db3. Replace 3.3.7 with 3.3.4 - and all becomes OK. ---- _2006-Sep-17 01:40:15 by anonymous:_ {linebreak} Works fine in Sqlite3explorer 1.1. No crashes after many repeated attempts. The table names appear garbled since my machine is not configured for the cyrillic character set, but the column names and data appear fine. You should contact the author of Sqlite3explorer, as it is probably an issue in that program. ---- _2006-Sep-19 21:18:19 by anonymous:_ {linebreak} As I wrote before, I have similar problem when use this dll from my own program too. Access violation occures at the same address in the Sqlite3.dll module. Is there debug version of this dll? If it can write debug log, I will send it to you when next exception will be captured. ---- _2006-Sep-19 22:55:22 by anonymous:_ {linebreak} The 3.3.7 DLL worked fine for me. A debug log and the exception stack trace is not useful in solving your problem. Your program may be in error. Please supply the smallest possible C source code that exhibits this crash. Otherwise there is not much we can do to help you. #c8c8c8 1945 code closed 2006 Aug anonymous 2006 Nov 1 1 symbol not found: sqlite_freemem sqlite_freemem Similar thing happens in Solaris 9 (x86) : ./apache2 start httpd starting. ld.so.1: httpd: fatal: libsqlite.so.0: open failed: No such file or directory Killed exit status 137 --- Then I create a link for libsqlite.so.0 in /usr/local/lib : ln -s libsqlite3.so.0 libsqlite.so.0 ./apache2 start httpd starting. ld.so.1: httpd: fatal: relocation error: file /usr/local/apr/lib/libaprutil-1.so.0: symbol sqlite_freemem: referenced symbol not found Killed exit status 137 Same versions of packages : apache 2.2.0, sqlite 3.3.6 #c8c8c8 2049 code closed 2006 Oct anonymous 2006 Oct 1 1 sqlite_HrmKZy6ma4XBUGl is in my temp file and cannot be deleted. the above just showed up and can't be deleted from my temp file. what is it? A bug? thanks for help. Don _2006-Oct-31 21:06:49 by drh:_ {linebreak} This is a problem with Mcafee Anti-virus. See McafeeProblem for additional information. ---- _2006-Nov-01 13:22:08 by anonymous:_ {linebreak} Ideally, the temp file name would be prefixed by the name of the parent application. That should make it easier for users to find the correct people to complain at or, at least, make it harder to find the wrong people. Not sure how feasible this is in Windows. It certainly doesn't appear necessary for non-Windows users. #f2dcdc 2048 code active 2006 Oct anonymous 2006 Oct drh 1 1 table_info on columns with no default value are returned as string On line 486, noDflt is declared as{linebreak} static const Token noDflt = { (unsigned char*)"", 0, 0 };{linebreak} {linebreak} And on line 493:{linebreak} if( pDflt->z ){{linebreak} sqlite3VdbeOp3(v, OP_String8, 0, 0, (char*)pDflt->z, pDflt->n);{linebreak} }else{{linebreak} sqlite3VdbeAddOp(v, OP_Null, 0, 0);{linebreak} {linebreak} So columns with no default value aren't being set to null because the (pDflt->z) condition is non-null. #cfe8bd 2047 code fixed 2006 Oct anonymous 2006 Oct 1 1 Mozilla Patch: Correct Unicode database names in Win95... I just noticed that folks at Mozilla have modified os_win.c to fix a long-standing problem with non-NT Windows systems: For Win95 & Co., SQLite creates UTF-8 encoded file names on disk, just as they are passed to sqlite3_open(). Please see {link: http://lxr.mozilla.org/seamonkey/source/db/sqlite3/src/os_win.c} for their version, which reads and works fine. Would it be possible to merge their changes, especially around =convertUtf8Filename()=, into SQLite? Hints for testing: Even though only the non-NT familiy of Windows (Win95, Win98, WinME) are prone to this bug, their NT-equivalents (WinNT, Win2k, WinXP) can be used for testing as well: Just have the isNT() function return 0 to simulate a non-NT environment. _2006-Oct-27 13:03:17 by drh:_ {linebreak} The Mozilla code is a fork from long ago. If I incorporate their version of os_win.c directly, we'll lose a lot of recent work, such as the WinCE port. I have no ability nor the desire to work on Win95 myself or to try and merge the Mozilla changes back into the SQLite tree. If somebody want to work up a patch that alleges to provide better support for Win95, I will consider inserting such a patch into the source tree. Please note that I do not have the ability to test on a Win95 platform, nor do I plan to acquire such ability. Any Win95 code will be at the same level as the OS/2 code - contributed, untested, and unsupported. ---- _2006-Oct-30 12:57:19 by anonymous:_ {linebreak} Please find attached to this ticket the file os_win_win9x.c where I have merged the Mozilla version of os_win.c with the latest SQLite CVS. The changes enable Win9x systems (Windows 95, Windows 98 and Windows ME) to convert non-ASCII characters into their system character set before passing them on to the various OS file-handling functions. This allows, among others, German Umlauts (äöüÄÖÜ) and French accented characters (áéíóú) to be used as filenames for SQLite databases on those systems which support them. This was not possible with SQLite until now. I have posted this following Richard's invitation to do so (see above). While I realize that the SQLite developers have no intention to support Win9x officially, I also notice that others would very well like it to be part of SQLite, Mozilla being just the most prominent. Therefore I kindly ask anyone interested to review the code on both the NT and non-NT family of the Windows operating system. I hope that the SQLite team will decide to commit it to the source base and make it part of the next release, if possible. Please attach any reports and suggestions below. ---- _2006-Oct-31 11:44:35 by anonymous:_ {linebreak} Many thanks for the fast check-in - very much appreciated! #cfe8bd 2045 code fixed 2006 Oct anonymous 2006 Oct drh 5 4 Enhancement request: add "bail" command to sqlite3 shell I created a patch against 3.3.7 which adds "-bail" and ".bail" commands to the sqlite3 shell. When bail is enabled, the shell will exit with a non-zero return code immediately upon encountering the first SQL error. This is useful when you pass a number of commands to the shell non-interactively and wish to, for example, abandon a transaction if any errors occur. It's also useful because the calling program receives an indication of success or failure. Bail mode works for standard input, init files, .read commands and, for completeness, interactively. I'm using this enhancement in my own project and thought it might be generally useful. _2006-Oct-26 13:02:54 by drh:_ {linebreak} I'm thinking that a better approach is to always abort a script when an error is seen, but continue accepting interactive input after an error. This is not strictly backwards compatible, but I am much less concerned about backwards compatibility of the command-line shell than I am of the SQLite core. Thoughts anyone? ---- _2006-Oct-26 16:13:57 by anonymous:_ {linebreak} Can you please make the default behavior as it was before and continue processing statements even after an error? (And continue log the errors to stderr as you already do). I, and perhaps others, have scripts that depend on this behavior. If a -bail-on-first-error flag or equivalent is specified, then you should exit upon first error. The sqlite3 shell is used by a lot of people for administrative tasks (often in cron jobs), and having backwards compatibility here is a good thing. Alternatively, you could support a -no-bail-or-error sort of flag, but this would require altering users' scripts. #cfe8bd 2044 code fixed 2006 Oct anonymous 2006 Oct 1 1 .dump does not dump create view or create index statements as before Did the behavior of .dump change recently? It used to spit out view definitions as well. SQLite version 3.3.8 Enter ".help" for instructions sqlite> CREATE TABLE abba(a,b); sqlite> INSERT INTO "abba" VALUES(55, 66); sqlite> create view baba as select * from abba; sqlite> .dump BEGIN TRANSACTION; CREATE TABLE abba(a,b); INSERT INTO "abba" VALUES(55, 66); COMMIT; sqlite> .table abba baba where's the definition of the view baba? compare this to an older version of SQLite: SQLite version 3.2.2 Enter ".help" for instructions sqlite> CREATE TABLE abba(a,b); sqlite> INSERT INTO "abba" VALUES(55, 66); sqlite> create view baba as select * from abba; sqlite> .dump BEGIN TRANSACTION; CREATE TABLE abba(a,b); INSERT INTO "abba" VALUES(55, 66); CREATE VIEW baba as select * from abba; COMMIT; _2006-Oct-26 01:12:49 by anonymous:_ {linebreak} .dump does not output indexes any longer? SQLite version 3.3.8 Enter ".help" for instructions sqlite> create table abc(a,b,c); sqlite> insert into abc values(4,5,6); sqlite> create index abc_b on abc(b); sqlite> .dump BEGIN TRANSACTION; CREATE TABLE abc(a,b,c); INSERT INTO "abc" VALUES(4, 5, 6); COMMIT; old version: SQLite version 3.2.2 Enter ".help" for instructions sqlite> create table abc(a,b,c); sqlite> insert into abc values(4,5,6); sqlite> create index abc_b on abc(b); sqlite> .dump BEGIN TRANSACTION; CREATE TABLE abc(a,b,c); INSERT INTO "abc" VALUES(4, 5, 6); CREATE INDEX abc_b on abc(b); COMMIT; ---- _2006-Oct-27 13:17:08 by anonymous:_ {linebreak} I'm trying to determine if this SQLite .dump behavior change was by design or accidental. If the former, what is the correct complete database dump syntax now? This command is frequently used to merge databases in batch mode. ---- _2006-Oct-27 13:21:13 by anonymous:_ {linebreak} I have not verified this, but this patch might be the cause of the .dump behavior change: http://www.sqlite.org/cvstrac/chngview?cn=3416 ---- _2006-Oct-27 13:35:16 by anonymous:_ {linebreak} Sqlite 3.3.7 dumps create views and create index statements correctly. So this problem is new to 3.3.8. I have not tested triggers or other SQL constructs. $ sqlite337 2044.db .dump BEGIN TRANSACTION; CREATE TABLE abba(a,b); INSERT INTO "abba" VALUES(55, 66); CREATE VIEW baba as select * from abba; CREATE INDEX index_abba on abba(b); COMMIT; $ sqlite338 2044.db .dump BEGIN TRANSACTION; CREATE TABLE abba(a,b); INSERT INTO "abba" VALUES(55, 66); COMMIT; ---- _2006-Oct-29 15:32:43 by anonymous:_ {linebreak} I think that this .dump regression is serious enough to warrant a 3.3.9 release. The sqlite3 command line shell is the main tool used for database merges, exports and backups. If no release is done, could you at least make a comment in the Notes section for 3.3.8 that TRIGGERs, VIEWs and INDEXes are not (always?) dumped? #f2dcdc 2043 code active 2006 Oct anonymous 2006 Oct 1 1 Spaces in view statement 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; #c8c8c8 2042 code closed 2006 Oct anonymous 2006 Oct 2 3 Subquery does not return the expected NULL If a one of the fields in a field list gets its values from a subquery then this field will have a value if the subquery returns NULL, of course since this value can be meaningful this causes major problems in the logic of the program using the DB. My current work around is to use another subquery that the count the records that should be returned by the first subquery (0 or 1) soi that I could identify the NULLs Code Ex: select field1, field2, /*The next subquery will return 0 either when the fieldB has 0 or when no record was found*/ (select fieldB from TABLE2 T2 where (T2.fieldA = T1.field1)) as field3 /*An integer field*/, /*The next subquery will return 0 when there is actually no records and 1 when there was a record so we identify NULLs*/ (select count(1) from points_SBL_programs GG where (GG.point = B.point)) as ProgramReallyExists from bicos B inner join pumps P on B.pump_code = P.pump_code where B.status <> 0; _2006-Oct-25 15:05:17 by drh:_ {linebreak} I have read through the description above multiple times, but I still cannot tell if this is a bug report, an behavioral observation, or a feature request. If you are having a problem, please describe what the problem is. If you think SQLite is doing something incorrectly, then provide a reproducible example of the incorrect behavior together with a description of what you think the correct behavior should be. If this is a feature request, please do a better job of saying what feature it is that you want. #c8c8c8 2039 code closed 2006 Oct anonymous 2006 Oct 1 1 How to delete SQLITE Temp files Hundreds of "SQLITE" Temp files are adding up on my company and I am not able to delete them. Please tell me how to do this. I am not an IT or programer. I don't need this program. Thanks, Penne _2006-Oct-24 14:09:52 by anonymous:_ {linebreak} I noticed in the sqlite3 code that temp files are deleted before they are closed in UNIX (by design), and opened with a "delete on close" type of flag on Windows. Obviously, it works fine on those systems, but non-mainstream OSes that do not have such a delete-before-close feature do have the problem of accumulating sqlite_* temp files as the original ticket poster reports. Even on Windows with some mainstream crappy anti-virus software, I still see this sort of thing from time to time. It would be a useful compile-time option to either delete temp files matching a certain pattern with a certain header, or to provide a more non-OS specific way of deleting a temp file that does not rely on delete-on-close OS semantics. ---- _2006-Oct-24 14:29:24 by drh:_ {linebreak} This is bug in McAfee Antivirus, not SQLite. See http://www.sqlite.org/cvstrac/wiki?p=McafeeProblem #cfe8bd 2038 code fixed 2006 Oct anonymous 2006 Oct 3 3 CREATE TRIGGER IF NOT EXISTS fails CREATE TRIGGER IF NOT EXISTS fails, while CREATE TRIGGER is executed normally. _2006-Oct-20 10:32:07 by anonymous:_ {linebreak} Could you provide some examples next time please? It helps a lot when trying to reproduce the bugs... Anyway, the "CREATE TRIGGER IF NOT EXISTS" syntax was added in version 3.3.8. #f2dcdc 2037 code active 2006 Oct anonymous 2006 Oct 1 1 Sqlite3 can't use datafile in Chinese path with Win2000 and WindowsXP. 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:_ {linebreak} 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. #cfe8bd 2036 code fixed 2006 Oct anonymous 2006 Oct shess 1 1 fts2.c: AVs due to incorret memset() and sizeof() - plus fixes *fts2.c* contains a number of improperly memset-initialized variables due to missing dereferences in sizeof(). These go seemingly unnoticed with little data added, but did lead to all sorts of problems as the number of documents increased, including access violations and stack overflows. The fixes below correct all of these problems. As a side-effect, the fixes seems to drop indexing speed seems by almost 100 percent at the begining. However, it raises up to about 50 percent as more documents are being added. I also observerd much more frequent disk writes during indexing with the fixes as compared to before. Line 3514, change: memset(pWriter, 0x55, sizeof(pWriter)); to memset(pWriter, 0x55, sizeof(*pWriter)); Line 3581, change memset(pReader, 0x55, sizeof(pReader)); to memset(pReader, 0x55, sizeof(*pReader)); Line 3593, change: memset(pReader, '\0', sizeof(pReader)); to memset(pReader, 0, sizeof(*pReader)); Line 3876, change memset(pReader, 0x55, sizeof(pReader)); to memset(pReader, 0x55, sizeof(*pReader)); Line 3914, change: memset(pReader, '\0', sizeof(pReader)); to memset(pReader, '\0', sizeof(*pReader)); Line 4010, change: memset(pReader, 0x55, sizeof(pReader)); to memset(pReader, 0x55, sizeof(*pReader)); Line 4251, change memset(&lrs, '\0', sizeof(lrs)); to memset(&lrs, 0, sizeof(lrs)); I've been meaning to make all of the memsets of this form into macros to prevent such errors. Looks like the time has come! ---- _2006-Oct-26 08:50:55 by anonymous:_ {linebreak} Thanks for those fixes, they work just fine. I am closing the ticket. #c8c8c8 2035 code closed 2006 Oct anonymous 2006 Oct jenglish 1 1 lazarus and sqlite3 I'm using lazarus version 0.9.16 with Sqlite 3, and unit TSqlite3DataSet. With sqlite3.exe I create this table: create table producto (codigo varchar(6), ean varchar(15), desc varchar(30), precio numeric(10,2)); then with lazarus I insert 4000 records like this: insert into producto values ( '00011','12312344','test test',3000); I check the result with sqlite3.exe and everything is ok. then I make a recorsed with lazarus, but when I open it I receive this error message: FIELD VARCHAR(6) NOT RECOGNIZED I create the table again: create table producto (codigo varchar, ean varchar, desc varchar, precio numeric(10,2)); I do the insert, and then open the recorsed and obtain the error again, FIELD NUMERIC(10,2) NOT RECOGNIZED. I have to use all fields like varchar, for may application work #c8c8c8 2034 code closed 2006 Oct anonymous 2006 Oct jenglish 1 1 lazarus and sqlite3 I'm using lazarus version 0.9.16 with Sqlite 3, and unit TSqlite3DataSet. With sqlite3.exe I create this table: create table producto (codigo varchar(6), ean varchar(15), desc varchar(30), precio numeric(10,2)); then with lazarus I insert 4000 records like this: insert into producto values ( '00011','12312344','test test',3000); I check the result with sqlite3.exe and everything is ok. then I make a recorsed with lazarus, but when I open it I receive this error message: FIELD VARCHAR(6) NOT RECOGNIZED I create the table again: create table producto (codigo varchar, ean varchar, desc varchar, precio numeric(10,2)); I do the insert, and then open the recorsed and obtain the error again, FIELD NUMERIC(10,2) NOT RECOGNIZED. I have to use all fields like varchar, for may application work _2006-Oct-19 14:59:56 by anonymous:_ {linebreak} Complain to the Lazarus people (or whoever is author of the wrapper). The is not SQLite bug at all and SQLite itself doesn't check the data type (with the exception of INTEGER PRIMARY KEY and type affinity). #c8c8c8 2033 code closed 2006 Oct anonymous 2006 Oct 1 1 SQLite 3.3.8 breaks Rails 1.1.6 (SQLite 3.3.6 OK) Running Typo (a rails application) SQLite 3.3.6 works just fine. Trying SQlite 3.3.8 breaks the application. I belive it is in the way 3.3.8 handles text fields. Typo uses YAML in a text field for its configuration information. SQLite 3.3.6 retrives the YAML configuration, alright, but something in 3.3.8 doesn't and the application breaks. _2006-Oct-19 11:31:03 by drh:_ {linebreak} I suspect that this is the same issue as described in tickets #1968 and #2020. If so, then the problem is not in SQLite but rather that Ruby misuses SQLite in a way that you could get away with in version 3.3.6 but not in 3.3.8. Thus, if my guess is correct, the problem is in Ruby and you should report the problem there. If you can provide me with specific information about what you think SQLite is doing incorrectly, I will be happy to look into the matter. But a vague description about "breaking Ruby" and some speculation about YAML handling (note that SQLite does not know anything about YAML) is not sufficient information on which to base a bug hunt. #f2dcdc 2032 code active 2006 Oct anonymous 2006 Oct 1 1 AV in btree.c running FTS2 compiled with SQLITE_OMIT_SHARED_CACHE 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 2031 code closed 2006 Oct anonymous 2006 Oct 1 1 .DEF file missing from 3.3.8 source code distribution I just downloaded the latest source code distribution of Sqlite v3.3.8 and noticed that a .DEF file needed to build a library is missing from the packages: http://www.sqlite.org/sqlite-source-3_3_8.zip http://www.sqlite.org/sqlite-3.3.8.tar.gz Please check. _2006-Oct-18 12:57:37 by anonymous:_ {linebreak} It is automatically generated during the build. ---- _2006-Nov-09 19:34:28 by anonymous:_ {linebreak} I thought the sqlite-3.3.8.zip archive was supposed to include all of the contents of the src directory **after** it has been processed by the MinGW32 cross-compilation process. I thought the purpose of this zip archive was so folks on Windows that don't have the tools used by the formal build process could still build sqlite. If I am correct, then the zip archive **should** also include the sqlite3.def file. This file is generated, but must be included if one is to successfully build from just the files in the zip archive. Thanks #cfe8bd 2030 code fixed 2006 Oct anonymous 2006 Oct 1 1 CSV output should convert " to "" within values Using the sqlite3 command line tool the only way to handle returns, pipes etc in the output of a SELECt statement, is to use .mode csv. However, if the output contains a quote (") then the out is incorrect, since CSV should show a single " and a double "". Here's an example: CREATE TABLE Test( field1 ); INSERT INTO "Test" VALUES('I said "Hi there"'); .mode csv SELECT * FROM Test; gives: "I said "Hi there"" But the CSV representation should be: "I said ""Hi there""" None of the other output modes provide a non-ambiguous output for all characters. #cfe8bd 2029 code fixed 2006 Oct anonymous 2006 Oct 2 1 SECURITY: SQLite character encoding conversions are insecure SQLite supports automatic conversions from the UTF-8 character encoding to the UTF-16 character encoding but this is done in an insecure fashion. Specifically, there are two problems: *: The UTF8 decoder must not accept overlong encodings, but it does. *: The UTF8 decoder must reject something which would decode to a Unicode code point value between U+D800 and U+DFFF because those don't exist (they conflict with UTF-16 surrogates). It is the responsibility of software performing UTF-8 decoding to ensure that no invalid byte sequences are accepted. In SQLite's case, this is especially because a user of the library might not be aware of the conversion. An example of an exploit would be: *: A script accepts a filename from an untrusted source, stores it in an SQLite database, retrieves it later, and tries to open a file with that name. The script is appropriately vigilent: it cleans ASCII unprintable characters from the filename, filters out ".", "..", "/". But the script is not internationalized (it doesn't need to be; it treats the strings as opaque). *: The SQLite database's encoding is UTF-16 for whatever reason. Thus there is a conversion from UTF-8 to UTF-16 on the way into the database and a conversion from UTF-16 to UTF-8 on the way out. *: A remote user supplies a filename that contains overlong encodings for "/" or "..". *: The remote user is able to create or open arbitrary filenames on the server where SQLite is running. It is wrong to think that the script should have sanitized the UTF-8 overlong encodings. It doesn't know anything about UTF-8! Equally disastrous scenarios can occur even with Unicode-aware software if it assumes SQLite's conversions are correct (a reasonable assumption unless they've gone and looked at the code). The second problem (concerning the surrogates) could be a security flaw if one user of the database uses the UTF-8 library interface and a different user uses the UTF-16 interface. Frankly I don't see why a special UTF-16 interface was developped for SQLite. UTF-16 isn't even interesting because it provides neither the convenience of a fixed length encoding nor the advantages of ASCII compatibility. If something like this was desired, it would have made more sense to follow the C standard and support a multibyte locale based interface on one hand and a wide character (C "wchar_t") interface on the other hand. Let iconv do the work for you. Or maybe use glib and let it do the work for you. Either way this would not have happened. The fix for the second problem is especially simple and costs absolutely nothing in the code: reject 0xED as the initial byte of a UTF-8 sequence. There are no valid Unicode characters that are encoded in UTF-8 beginning with 0xED. The fix for the first problem requires a coupld of lines of code and an extra check at runtime for every character. I tested that SQLite compiles with this patch but I didn't run it. --- utf.c 2006/10/17 19:09:10 1.1 +++ utf.c 2006/10/17 19:17:11 @@ -89,7 +89,7 @@ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 1110zzzz */ -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, +2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 255, 2, 2, /* 11110yyy */ 3, 3, 3, 3, 3, 3, 3, 3, 255, 255, 255, 255, 255, 255, 255, 255, @@ -108,6 +108,13 @@ 63447168 /* (0xF0 << 18) + (0x80 << 12) + (0x80 << 6) + 0x80 */ }; +static const int xtra_smallest_allowed[4] = { +0x0, /* one byte UTF-8 encodes from 0x00 to 0x7F */ +0x80, /* two byte UTF-8 encodes from 0x80 to 0x7FF */ +0x800, /* three byte UTF-8 encodes from 0x800 to 0xFFFF */ +0x10000 /* four byte UTF-8 encodes from 0x10000 to 0x1FFFFF */ +}; + #define READ_UTF8(zIn, c) { \ int xtra; \ c = *(zIn)++; \ @@ -118,6 +125,8 @@ case 2: c = (c<<6) + *(zIn)++; \ case 1: c = (c<<6) + *(zIn)++; \ c -= xtra_utf8_bits[xtra]; \ + if (c < xtra_smallest_allowed[xtra]) \ + c = (int)0xFFFD; \ } \ } int sqlite3ReadUtf8(const unsigned char *z){ _2006-Oct-18 08:22:25 by anonymous:_ {linebreak} A UTF-8 decoder capability and stress test is available here: {link: http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt} The author's main entry point on UTF-8 and potential conversion pitfalls is here: {link: http://www.cl.cam.ac.uk/~mgk25/unicode.html http://www.cl.cam.ac.uk/~mgk25/unicode.html} ---- _2006-Oct-19 01:04:21 by drh:_ {linebreak} Unicode characters U+D000 through U+D7FF are all valid and their UTF-8 representations all begin with 0xED. So the patch supplied in the problem description appears to be incorrect. ---- _2006-Oct-19 18:50:41 by anonymous:_ {linebreak} Thank you for checking my patch and discovering that the solution of rejecting the initial byte of 0xED was flawed. Thanks also for the quick resolution. By the way, you have unnesesary test in your fix: a UTF-16 surrogate pair always decodes to something in planes 1 through 16 (never plane 0) so there is no need to test for a surrogate pair that decodes to a surrogate (but there is no harm in doing it!) #f2dcdc 2028 code active 2006 Oct anonymous 2006 Oct 4 2 FTS1: UNIQUE() expression and UPDATE command not working 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:_ {linebreak} 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. #f2dcdc 2027 code active 2006 Oct anonymous 2006 Oct 1 1 FTS: Phrase searches return Offsets for individual phrase words 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 #f2dcdc 2026 code active 2006 Oct anonymous 2006 Oct 4 5 \n in .output is not allowed even with quote *.output drive:\nabc.txt* {linebreak} *.output e:\new0.txt* {linebreak} *.output z:\new1.txt* {linebreak} *.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:_ {linebreak} How about c:\\new.txt? ---- _2006-Oct-16 11:49:58 by anonymous:_ {linebreak} How about "c:/new.txt"? #f2dcdc 2025 code active 2006 Oct anonymous 2006 Oct drh 5 5 Add pragama command to return loaded extension list How about add a new pragama command to return loaded extension list? #f2dcdc 2024 code active 2006 Oct anonymous 2006 Oct drh 5 5 Add If not exist syntax to Create Virtual Table Parser Enhancement request: is it possible to add If not exist syntax to Create Virtual Table? all other create schema support such syntax. #f2dcdc 2022 code active 2006 Oct anonymous 2006 Oct 1 1 .import command is not working 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:_ {linebreak} A sample SQL schema and a 3 line import file demonstrating the problem would be helpful. ---- _2006-Nov-08 15:48:28 by anonymous:_ {linebreak} 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:_ {linebreak} 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 #c8c8c8 2021 code closed 2006 Oct anonymous 2006 Oct a.rottmann 2 1 Expression Always Returning String I downloaded Sqlite ver 3, and then I started to review sqlite characteristic and behavior, speed, sql compliance, etc. most of all look good and work very well. but I found a big problem, on some expression that allways returns string. for example, I use "SELECT SUM(PRICE*QTY) FROM INVOICE" this returning string rather than float. and I try other functions like COUNT, TOTAL, CAST, Etc. why?????? _2006-Oct-13 11:50:39 by drh:_ {linebreak} Please use the sqlite users mailing list for asking questions about how to use sqlite. Tickets should be used for reporting bugs. For information on how to subscribe to the sqlite mailing list see http://www.sqlite.org/support.html #c8c8c8 2020 code closed 2006 Oct anonymous 2006 Oct 1 1 sqlite3_column_type always returns 1 After executing a query, sqlite3_column_type() always returns 1 regardless of column data type. Works fine in 3.3.6 and 3.3.7 on both, Linux and Windows. Duplicate of ticket #1968 #f2dcdc 2019 code active 2006 Oct anonymous 2006 Oct 1 1 FTS1: Create table in transaction raises Out of Sequence error (21) 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. #cfe8bd 2018 code fixed 2006 Oct drh 2006 Oct drh 1 1 Name resolution problem in correlated compound subqueries. The P.PK name is not resolved in the query at the end of the following script: CREATE TABLE IF NOT EXISTS photo(pk integer primary key, x); CREATE TABLE IF NOT EXISTS tag(pk integer primary key, fk int, name); SELECT P.pk from PHOTO P WHERE NOT EXISTS ( SELECT T2.pk from TAG T2 WHERE T2.fk = P.pk EXCEPT SELECT T3.pk from TAG T3 WHERE T3.fk = P.pk AND T3.name LIKE '%foo%' ); #f2dcdc 2017 code active 2006 Oct anonymous 2006 Oct 1 1 DROP TABLE fails on FTS1 utility tables with certain OMIT_s defined 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. #cfe8bd 2016 code fixed 2006 Oct anonymous 2006 Oct 1 1 Unremoved debug code in fts1_porter.c A line of debug code is still present in fts1_porter.c. The line in question is *line 75*: for(i=0; i 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. #f2dcdc 2012 code active 2006 Oct anonymous 2006 Oct 4 3 trigger4.test aborts "make test" on Windows 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:_ {linebreak} 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. #f2dcdc 2011 code active 2006 Oct anonymous 2006 Oct 3 2 Escaping Porblem with .mode insert (double apostrophe) 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. #f2dcdc 2010 code active 2006 Oct anonymous 2006 Oct 3 3 Timeout ignored in Shared-Cache locking model 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:_ {linebreak} 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. #cfe8bd 2009 code fixed 2006 Oct anonymous 2006 Oct 4 3 sqlite3 shell won't issue prompts without isatty() true when running the sqlite3 shell under emacs on win32, the shell does not print prompts. the reason this occurs is that sqlite3 is checking isatty(stdin) to determine whether it's talking to a terminal or not, and emacs can't perfectly impersonate a terminal on win32. the problem will not occur on unix because emacs on unix can use pseudo-terminals, but win32 has no such facility. other front-ends on win32 would probably have the same problem that emacs does. the usual fix is for the shell to accept a "--interactive" flag which forces it to believe that it's talking to a terminal. see the "buffering in shells" issue mentioned at http://www.gnu.org/software/emacs/windows/big.html#sub-processes _2006-Oct-05 01:29:57 by anonymous:_ {linebreak} As you point out, an explicit interactive flag is the only reliable way to deal with non-UNIX-like OSes and terminals. Please make this flag boolean (--interactive=on|off) to forceably override the default isatty detection either way. #cfe8bd 2008 code fixed 2006 Oct anonymous 2006 Oct 3 3 Linux x86_64 sqlite3utfSelfTest fails assert -O2 gcc 4.1.1 (patch) WRITE_UTF16LE and READ_UTF16LE seem not safe for gcc optimizations with -O2 on Linux x64. distinctagg-2.1... Ok{linebreak} lt-testfixture: ./src/utf.c:581: sqlite3utfSelfTest: Assertion `c==i' failed.{linebreak} make: *** [fulltest] Aborted (Gentoo) Linux localhost 2.6.16-hardened-r11 #8 SMP Fri Sep 29 17:05:46 BST 2006 x86_64 Intel(R) Pentium(R) 4 CPU 2.80GHz GNU/Linux gcc -v Using built-in specs. Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/gcc-4.1.1/work/gcc-4.1.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --enable-multilib --disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu{linebreak} Thread model: posix gcc version 4.1.1 (Gentoo 4.1.1) _2006-Oct-04 14:50:51 by anonymous:_ {linebreak} You can reach me at alejos AT gmail DOT com. Thanks. ---- _2006-Oct-05 11:34:02 by anonymous:_ {linebreak} Hi. I think you missed the unsigned int i on line 559. distinctagg-2.1... Ok{linebreak} lt-testfixture: ./src/utf.c:581: sqlite3utfSelfTest: Assertion `c==i' failed.{linebreak} make: *** [fulltest] Aborted{linebreak} Alejo ---- _2006-Oct-05 13:10:29 by anonymous:_ {linebreak} Thanks! #c8c8c8 2007 code closed 2006 Oct anonymous 2006 Oct 1 1 Server has unexpecedly died/u've found a bug/ i cant connect to hub I can not connect to my hub, I've tried several times to input it manually, and it still does not work. Than after a couple minutes a pop up that states Server has unexpectedly died. You've found a bug :-) shows up. please help _2006-Oct-04 04:00:29 by drh:_ {linebreak} This website is for reporting bugs against SQLite - which does not have a "server" or a "hub" and which is currently at version 3.3.7. I'm not sure what software you are having problems with, but it appears to be something other than SQLite. #c8c8c8 1995 code closed 2006 Sep anonymous 2006 Oct 2 1 SHARED lock does not kick in (DEFERRED does not work ?) According to documentation the SHARED lock should kick in as soon as a SELECT is executed. I tried the following (pseudo) code: sqlite3_prepare(... "SELECT * FROM A_TABLE" ...) sqlite3_step(...) <============================= Another process does an UPDATE sqlite3_finalize(...) The other process is able to do an update so the SHARED lock is NOT active even though the _prepare and _step is called ! Adding a sqlite3_exec(... "BEGIN TRANSACTION" ...) before the _prepare/_step does not help But sqlite3_exec(... "BEGIN IMMEDIATE TRANSACTION" ...) does. With IMMEDIATE a SHARED lock kicks in and in the above the UPDATE fails. Either the docs are wrong, locks get dropped after each _step or there is an error. A workaround is to do a sqlite3_exec(... "BEGIN IMMEDIATE TRANSACTION" ...) before each SELECT but this may be problematic since nested transactions are not supported. _2006-Sep-25 21:09:15 by drh:_ {linebreak} Unable to reproduce. When I run the TCL test script shown below, which implements the pseudo-code above, the UPDATE statement returns an error that the database is locked. file delete -force test.db test.db-journal sqlite3 db1 test.db db1 eval { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); } sqlite3 db2 test.db db1 eval BEGIN db1 eval {SELECT * FROM t1} { db2 eval {UPDATE t1 SET x=x+1} } db1 eval COMMIT There are also a whole bunch of tests in the regression test suite that verify the correction operation in scenarios like this one. I'm thinking this is a problem with a specific SQLite build or else a filesystem that does not support file locking. ------------------- After recompiling SQLite and (probably more important) recreating the database the error went away. Either the database was corrupted in some way or the SQLite version that created the database (3.3.4?) had some kind of bug. My fault, I should have tested with another database. #c8c8c8 1971 code closed 2006 Sep anonymous Unknown 2006 Oct 4 4 66 tests fail out of 26937 I understand that perhaps this is not a very important thing but I wanted to report it nevertheless. I am building sqlite 3.3.7 in a debian sarge box. I prompt make test and I get a long battery of tests running (which is nice). At the end I get a report that says: 66 errors out of 26937 tests Failures on these tests: collate4-4.3 collate4-4.4 corrupt2-1.2 corrupt2-1.3 corrupt2-1.4 corrupt2-1.5 index-11.1 intpkey-3.4 intpkey-3.6 intpkey-3.7 intpkey-3.8 minmax-1.6 minmax-1.8 rowid-4.5 rowid-4.5.1 select2-3.2d select2-3.2e 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 where-1.12 where-1.13 where-1.14 where-1.15 where-1.16 where-1.17 where-1.18 where-1.19 where-1.20 where-1.21 where-1.22 where-1.23 where-1.24 where-1.25 where-1.27 where-2.1 where-2.2 where-2.3 where-2.4 where-2.5 where-2.6 where-2.7 where-3.1 where-3.2 where-3.3 where-5.2 where-5.3 where-5.4 where-5.6 where-5.7 where-5.8 where-5.9 where-5.10 where-5.11 where-5.12 where-5.13 where-5.14 where-5.15 Should I worry about this? _2006-Sep-09 17:40:53 by anonymous:_ {linebreak} I don't see these errors on my machine. Can you post the relevant sections of the log showing the results for each of these failed tests? What version of TCL are you using? I find that some test results are TCL version specific. ---- _2006-Sep-10 11:17:02 by drh:_ {linebreak} It works fine on my SuSE 10.2 box, so in the absence of any additional information that might help me to track down the problem, I am going to assume this is some kind of configuration error during the build. ---- _2006-Sep-10 15:24:57 by anonymous:_ {linebreak} I think this ticket was closed too early, and the original bug reporter should at least be given at least a week to post requested information. His Linux box is running a very popular Linux distro, Debian, and it would be worth following up on for the sake of other Debian users. ---- _2006-Sep-10 16:50:21 by drh:_ {linebreak} Anybody can reopen a ticket. Just click on the "Edit" link near the upper right corner, then go down an modify the status to whatever you want. ---- _2006-Sep-17 16:11:18 by anonymous:_ {linebreak} All failed tests appear to be related to sqlite_search_count. ---- _2006-Sep-18 03:49:09 by anonymous:_ {linebreak} All SQL queries in the failed tests do in fact return the correct results. Just the sqlite_search_count does not match (the last column in each result). This is not a big deal, as this internal variable is only used in debug/test builds and does not exist in a release build. Even so, the non-determinism of sqlite_search_count is odd. Perhaps there is an invalid assumption in the tests themselves and they require re-tooling. ---- _2006-Sep-23 22:24:16 by drh:_ {linebreak} I have Debian Sarge running under VMWare now and I don't get any of the errors reported above. ---- _2006-Sep-24 01:54:42 by anonymous:_ {linebreak} If either of the two Debian bug reporters could list how they configured sqlite and ran the tests, it would be helpful. Judging by the following lines in the test log, I suspect they ran a default configure && make test: Skipping malloc tests: not compiled with -DSQLITE_DEBUG... Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG... I wonder if, by chance, Debian ships with sqlite3 libraries and headers and something is getting inadvertantly mixed up during the build. ---- _2006-Oct-04 16:55:28 by anonymous:_ {linebreak} Hi. Got similar failures for tests related to sqlite_search_count on Gentoo x64 and hardened (stack protection, PaX, Grsecurity). See attach. utf16-rowid-4.5.1...{linebreak} Expected: [3 3]{linebreak} Got: [3 2]{linebreak} open-file-count=0{linebreak} Memory leaked: 0 bytes in 0 allocations{linebreak} Thread-specific data deallocated properly{linebreak} 130 errors out of 80400 tests{linebreak} Failures on these tests: collate4-4.3 collate4-4.4 index-11.1 intpkey-3.4 intpkey-3.6 intpkey-3.7 intpkey-3.8 malloc2.1.5 minmax-1.6 minmax-1.8 printf-8.1 printf-8.2 rowid-4.5 rowid-4.5.1 select2-3.2d select2-3.2e types3-1.3 utf16-collate4-4.3 utf16-collate4-4.4 utf16-index-11.1 utf16-intpkey-3.4 utf16-intpkey-3.6 utf16-intpkey-3.7 utf16-intpkey-3.8 utf16-minmax-1.6 utf16-minmax-1.8 utf16-rowid-4.5 utf16-rowid-4.5.1 utf16-select2-3.2d utf16-select2-3.2e utf16-where-1.1 utf16-where-1.2 utf16-where-1.3 utf16-where-1.4 utf16-where-1.5 utf16-where-1.6 utf16-where-1.7 utf16-where-1.8 utf16-where-1.9 utf16-where-1.10 utf16-where-1.11 utf16-where-1.12 utf16-where-1.13 utf16-where-1.14 utf16-where-1.15 utf16-where-1.16 utf16-where-1.17 utf16-where-1.18 utf16-where-1.19 utf16-where-1.20 utf16-where-1.21 utf16-where-1.22 utf16-where-1.23 utf16-where-1.24 utf16-where-1.25 utf16-where-1.27 utf16-where-2.1 utf16-where-2.2 utf16-where-2.3 utf16-where-2.4 utf16-where-2.5 utf16-where-2.6 utf16-where-2.7 utf16-where-3.1 utf16-where-3.2 utf16-where-3.3 utf16-where-5.2 utf16-where-5.3 utf16-where-5.4 utf16-where-5.6 utf16-where-5.7 utf16-where-5.8 utf16-where-5.9 utf16-where-5.10 utf16-where-5.11 utf16-where-5.12 utf16-where-5.13 utf16-where-5.14 utf16-where-5.15 vtab_err-1.26.3 vtab_err-2.1166 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 where-1.12 where-1.13 where-1.14 where-1.15 where-1.16 where-1.17 where-1.18 where-1.19 where-1.20 where-1.21 where-1.22 where-1.23 where-1.24 where-1.25 where-1.27 where-2.1 where-2.2 where-2.3 where-2.4 where-2.5 where-2.6 where-2.7 where-3.1 where-3.2 where-3.3 where-5.2 where-5.3 where-5.4 where-5.6 where-5.7 where-5.8 where-5.9 where-5.10 where-5.11 where-5.12 where-5.13 where-5.14 where-5.15{linebreak} (Gentoo) Linux localhost 2.6.16-hardened-r11 #8 SMP Fri Sep 29 17:05:46 BST 2006 x86_64 Intel(R) Pentium(R) 4 CPU 2.80GHz GNU/Linux gcc -v Using built-in specs. Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/gcc-4.1.1/work/gcc-4.1.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --enable-multilib --disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 4.1.1 (Gentoo 4.1.1) ---- _2006-Oct-04 18:39:07 by drh:_ {linebreak} The reason I cannot reproduce this is that I'm running off of the latest sources from CVS. This issue has already been fixed. See ticket #1918. ---- _2006-Oct-05 11:04:55 by anonymous:_ {linebreak} Yes, confirmed here on that Gentoo x64. Thanks! #f2dcdc 1820 warn active 2006 May anonymous TclLib 2006 Oct anonymous 5 1 make: *** [tclsqlite.lo] Error 1 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 #f2dcdc 2006 event active 2006 Sep anonymous 2006 Sep 1 1 Strange data in a table. 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);{linebreak} INSERT INTO "TopSites" VALUES(-761955577, 5, 1120);{linebreak} INSERT INTO "TopSites" VALUES(-761955577, 5, 1323);{linebreak} INSERT INTO "TopSites" VALUES(-761955577, 5, 1324);{linebreak} ....................................................... INSERT INTO "TopSites" VALUES(-761955577, 5, 1323);{linebreak} INSERT INTO "TopSites" VALUES(-761955577, 5, 1324);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.bnimanningham.com', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.wellnesscareoncollins.com.au/Chiropractic-Articles.html', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.healthyrisepharmacy.com', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.alextechmelb.com/testimonials.html', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.ecca.com.au/melbourne-contactus.html', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.naturopathicwellness.com.au/additionaltherapies.htm', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.rrr.org.au/sponsors.php', NULL);{linebreak} 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);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.coca.com.au/vic.htm', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.embracechiropractic.com.au', NULL);{linebreak} INSERT INTO "TopSites" VALUES(NULL, 'http://www.cooperchiro.com', NULL);{linebreak} 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){linebreak} {{linebreak} return "INSERT OR ROLLBACK INTO TopSites (XID, YID, URLID) VALUES {linebreak}(" + aX + ", " + aY + ", " + aURLID + ");";{linebreak} }{linebreak} 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:_ {linebreak} This is duplicate of #2005 ---- _2006-Sep-29 14:03:50 by drh:_ {linebreak} I'm thinking this and #2005 represent a bug in whatever Java bindings the reporter is using. #f2dcdc 2005 event active 2006 Sep anonymous 2006 Sep 1 1 Multiple rows with the same primary key, and null values in "not null" 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');{linebreak} INSERT INTO "TopSitesURLs" VALUES(2, 'http://www.wellnesscareoncollins.com.au');{linebreak} INSERT INTO "TopSitesURLs" VALUES(3, 'http://www.oakleighdental.com.au/chirodontics.php');{linebreak} INSERT INTO "TopSitesURLs" VALUES(4, 'http://bacinactionchiropractic.com');{linebreak} INSERT INTO "TopSitesURLs" VALUES(5, 'http://melbourne.zpages.com.au/chiropractors');{linebreak} INSERT INTO "TopSitesURLs" VALUES(6, 'http://myname.chiropractic.com.au');{linebreak} INSERT INTO "TopSitesURLs" VALUES(7, 'http://www.melbournechiropractor.com');{linebreak} INSERT INTO "TopSitesURLs" VALUES(8, 'http://www.chiroweb.net/us/fl_melbourne.html');{linebreak} INSERT INTO "TopSitesURLs" VALUES(9, 'http://www.chiropractor.net.au/aridiskin.htm');{linebreak} INSERT INTO "TopSitesURLs" VALUES(10, 'http://www.melbournechiropractic.com.au');{linebreak} INSERT INTO "TopSitesURLs" VALUES(11, 'http://www.melbournechiropractor.com/index.php?page=privacy.php&pageID=-1');{linebreak} INSERT INTO "TopSitesURLs" VALUES(12, 'http://www.vitaminstoday.com.au/chiropractor/index.php?page=grid');{linebreak} INSERT INTO "TopSitesURLs" VALUES(13, 'http://www.goodechiro.com/index.asp');{linebreak} INSERT INTO "TopSitesURLs" VALUES(14, 'http://www.goodechiro.com/FirstVisit.asp');{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, 'http://www.usenature.com/chirodirectory.htm');{linebreak} INSERT INTO "TopSitesURLs" VALUES(16, 'http://www.melbournemeditationcentre.com.au/courses/teacher.htm');{linebreak} INSERT INTO "TopSitesURLs" VALUES(17, 'http://www.yogatree.com.au/Therapies.htm');{linebreak} ................................................................................... INSERT INTO "TopSitesURLs" VALUES(6259, 'http://www.yarravillehealth.com.au/osteopath-melbourne.html');{linebreak} INSERT INTO "TopSitesURLs" VALUES(6260, 'http://www.worldveganday.org.au/forum/viewtopic.php?p=4543&sid=465ea5c2e7452f6fd23470488e277781');{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(14, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} INSERT INTO "TopSitesURLs" VALUES(15, NULL);{linebreak} 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:_ {linebreak} What tool (and parameters) did you use to dump the database? ---- _2006-Sep-29 13:13:28 by drh:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} An integrity check on this database looks like this:{linebreak} C:\Documents and Settings\stefan matei\Desktop>sqlite3 project.db{linebreak} SQLite version 3.3.4{linebreak} Enter ".help" for instructions{linebreak} sqlite> PRAGMA integrity_check;{linebreak} *** in database main ***{linebreak} On tree page 59 cell 10: 2nd reference to page 1077{linebreak} On tree page 59 cell 10: Child page depth differs{linebreak} On tree page 59 cell 11: Child page depth differs{linebreak} On page 871 at right child: 2nd reference to page 1078{linebreak} sqlite> .quit{linebreak} 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. #f2dcdc 2004 warn active 2006 Sep anonymous 2006 Sep 1 4 vtab.c:142: warning: pointer targets in initialization differ in signe 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)); #c8c8c8 2003 warn closed 2006 Sep anonymous VDBE 2006 Sep 4 4 vdbeaux.c:1585: warning: unused variable 'sqlite3_search_count' Is this a valid fix? #ifdef SQLITE_TEST extern int sqlite3_search_count; #endif Already fixed. See [3419] #cfe8bd 2002 code fixed 2006 Sep anonymous Parser 2006 Sep drh 2 2 Memory leak in select with duplicate colum names Look again. The code that you mentioned in #1952 is only executed once after the loop has finished, but memory is allocated once per loop - so sqliteFree must be called *inside* the loop! #cfe8bd 2001 code fixed 2006 Sep anonymous Unknown 2006 Sep 2 2 Views on altered tables are defect Use the following script to create a table and a view: =CREATE TABLE T1 (C1 TEXT DEFAULT 'C1');{linebreak} INSERT INTO T1 VALUES ('A');{linebreak} ALTER TABLE T1 ADD COLUMN C2 TEXT DEFAULT 'C2';{linebreak} CREATE VIEW V1 AS SELECT * FROM T1;{linebreak}= Now select the content of the table: =SELECT * FROM T1;= The result is as expected: =|C1....|C2....|{linebreak} +------+------+{linebreak} |'A'...|'C2'..|{linebreak}= Now select the content of the view: =SELECT * FROM V1;= The result should be the same as above, but the second column is NULL!: =|C1....|C2....|{linebreak} +------+------+{linebreak} |'A'...|NULL..|{linebreak}= This behavior persists until you do an explicit VACUUM. _2006-Sep-29 10:03:42 by anonymous:_ {linebreak} Works correctly in the latest version from CVS (and 3.3.7 too probably). #c8c8c8 2000 doc closed 2006 Sep anonymous Unknown 2006 Sep 1 3 Teorical questions. Can you put in your documentation of sqlite3 library/db (or answer to me) information about: 1) how many tables may contain a single db ? 2) how many rows may be in the table ? 3) How many databases can be atached for virtual table query? PS: I couldn't find information about these quations in your documentation/ With best regards Sergey. _2006-Sep-28 19:55:56 by drh:_ {linebreak} 1: http://www.sqlite.org/faq.html#q9 2: http://www.sqlite.org/faq.html#q10 3: http://www.sqlite.org/lang_attach.html #c8c8c8 1999 code closed 2006 Sep anonymous Unknown 2006 Sep 3 3 Memmory leak and wrong passed argument to calback function Memmory leak after opening dbase file detailed info and code is on - http://phpfi.com/158092 and there is also a problem when fetching results from SELECT statement, (somethings is wrong with 4th argument of callback function) here is code provided (not standalone) - http://phpfi.com/158094 for details or full source you can contact me via e-mail, i would be glad to help you. greetings, Tomasz Gawęda. _2006-Sep-28 20:01:45 by drh:_ {linebreak} This ticket contains two complaints. The first one is a duplication of ticket #856 and it not a bug. I do not understand the second complaint but I don't think it is a problem either. As best as I can determine, the author is saying that if he accesses memory the bounds of an array he is about to see query results, which is a bug in the demonstration program not in SQLite. #f2dcdc 1998 build active 2006 Sep anonymous 2006 Sep 2 3 prefix option to configure ignored in tclinstaller.tcl 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 #c8c8c8 1997 code closed 2006 Sep anonymous 2006 Sep 2 3 can't select rows if column name is contained in data SELECT * FROM WHERE = ""; fails when is the same as name. Expected that quoted data would be differentiated from column names. _2006-Sep-26 17:42:37 by anonymous:_ {linebreak} Use single quotes. #f2dcdc 1996 new active 2006 Sep anonymous Unknown 2006 Sep drh 2 3 Data type CHAR 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... #f2dcdc 1994 code active 2006 Sep anonymous Parser 2006 Sep 1 3 Columns from nested joins aren't properly propagated 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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). #c8c8c8 1993 event closed 2006 Sep anonymous 2006 Sep 3 1 bit operators problemm I've found this problemm in Sqlite3 for PHP 5.1.4 PDO driver version more than 3.2.8. I'm not shure that is a problemm of SQLite, but nevertheless ... In TABLE a have FIELD (INT UNSIGNED), where bit mask putted. SELECT ... FROM TABLE WHERE FIELD&1 -> WORKS correctly BUT !!!! SELECT ... FROM TABLE WHERE NOT FIELD&1 -> DON'T WORK{linebreak} SELECT ... FROM TABLE WHERE !FIELD&1 -> DON'T WORK{linebreak} SELECT ... FROM TABLE WHERE ~FIELD&1 -> DON'T WORK{linebreak} SELECT ... FROM TABLE WHERE 1&~FIELD -> DON'T WORK All this expressions (NOT FIELD&1, !FIELD&1, FIELD&~1, ~1&FIELD) returns TRUE always _2006-Sep-24 16:13:00 by anonymous:_ {linebreak} Use parantheses. "NOT" has lower precedence than "&" in SQLite. sqlite> select not(7&128), (not 7)&128, not 7&128; 1|0|1 Likewise, "~" has lower precedence than "&". sqlite> select ~7, ~7&128, ~(7&128), (~7)&128; -8|-1|-1|128 #cfe8bd 1991 code fixed 2006 Sep anonymous Unknown 2006 Sep drh 3 3 strftime precision problem When I executed the next query: select strftime('%Y-%m-%d %H:%M:%f', julianday('2006-09-24T10:50:26.047')); it returned 2006-09-24 10:50:26.046 At the same time, I can clearly see, that julianday for that time for .046 and .047 points is returning different numbers. Another way to reproduce: the query select strftime('%Y-%m-%d %H:%M:%f', '2006-09-24T10:50:26.046'); is returning 2006-09-24 10:50:26.045 It seems, there is a bug in the strftime function. _2006-Sep-24 11:57:34 by anonymous:_ {linebreak} Using precompiled .dll 3.3.7 from site under windows. ---- _2006-Sep-24 16:47:18 by anonymous:_ Index: src/date.c =================================================================== RCS file: /sqlite/sqlite/src/date.c,v retrieving revision 1.56 diff -u -3 -p -r1.56 date.c --- src/date.c 8 Sep 2006 12:49:44 -0000 1.56 +++ src/date.c 24 Sep 2006 16:45:03 -0000 @@ -826,7 +826,7 @@ static void strftimeFunc( case 'd': sprintf(&z[j],"%02d",x.D); j+=2; break; case 'f': { int s = x.s; - int ms = (x.s - s)*1000.0; + int ms = (int)((x.s - s)*1000.0+0.49999999999999); sprintf(&z[j],"%02d.%03d",s,ms); j += strlen(&z[j]); break; Results with patch: $ ./sqlite3 SQLite version 3.3.7 Enter ".help" for instructions sqlite> select strftime('%Y-%m-%d %H:%M:%f', julianday('2006-09-24T10:50:26.047')); 2006-09-24 10:50:26.047 sqlite> select strftime('%Y-%m-%d %H:%M:%f', '2006-09-24T10:50:26.046'); 2006-09-24 10:50:26.046 ---- _2006-Sep-24 17:03:07 by anonymous:_ {linebreak} Better patch: Index: src/date.c =================================================================== RCS file: /sqlite/sqlite/src/date.c,v retrieving revision 1.56 diff -u -3 -p -r1.56 date.c --- src/date.c 8 Sep 2006 12:49:44 -0000 1.56 +++ src/date.c 24 Sep 2006 17:01:02 -0000 @@ -825,9 +825,7 @@ static void strftimeFunc( switch( zFmt[i] ){ case 'd': sprintf(&z[j],"%02d",x.D); j+=2; break; case 'f': { - int s = x.s; - int ms = (x.s - s)*1000.0; - sprintf(&z[j],"%02d.%03d",s,ms); + sqlite3_snprintf(7,&z[j],"%02.3f",x.s); j += strlen(&z[j]); break; } which also handles this case: sqlite> select strftime('%Y-%m-%d %H:%M:%f', '2006-09-24T10:50:26.99999'); 2006-09-24 10:50:27.000 ---- _2006-Sep-24 18:42:10 by anonymous:_ {linebreak} Final patch, I swear. ;-) Index: src/date.c =================================================================== RCS file: /sqlite/sqlite/src/date.c,v retrieving revision 1.56 diff -u -3 -p -r1.56 date.c --- src/date.c 8 Sep 2006 12:49:44 -0000 1.56 +++ src/date.c 24 Sep 2006 18:35:44 -0000 @@ -825,9 +825,9 @@ static void strftimeFunc( switch( zFmt[i] ){ case 'd': sprintf(&z[j],"%02d",x.D); j+=2; break; case 'f': { - int s = x.s; - int ms = (x.s - s)*1000.0; - sprintf(&z[j],"%02d.%03d",s,ms); + double s = x.s; + if (s > 59.999) s = 59.999; + sqlite3_snprintf(7,&z[j],"%02.3f",s); j += strlen(&z[j]); break; } also handles the boundary case: sqlite> select strftime('%Y-%m-%d %H:%M:%f', '2006-09-24T23:59:59.999999'); 2006-09-24 23:59:59.999 #f2dcdc 1990 code active 2006 Sep anonymous 2006 Sep 1 1 sqlite3_close doesn't release always the file handle 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 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 1989 build closed 2006 Sep anonymous Unknown 2006 Sep a.rottmann 2 2 100's daily in XP temp folder-Cannot delete w/out reboot-Stop create? This problem has been going on since I installed (2nd one) AOL Safety & Security Center. Not sure what is causing it, however. AOL non committal as always. 100's create daily in my temporary folder in XP. PROBLEM: You can't delete them without a reboot. They just keep on coming along with a "ver.." temp file that you can delete. How do I get these from not creating in the first place? You are about my 15th person/group to ask this question of. Please, someone, help! They are about 3k in size, but when I installed XP over a year ago I wasn't getting these at all. Thank you in advance!! _2006-Sep-23 20:45:10 by drh:_ {linebreak} See http://www.sqlite.org/cvstrac/wiki?p=McafeeProblem #c8c8c8 1988 code closed 2006 Sep anonymous Parser 2006 Sep 2 2 linker error wih SQLITE_OMIT_VIRTUALTABLE There's a problem with compiling with SQLITE_OMIT_VIRTUAL_TABLE. There are 4 functions that still begin used (and referenced) in pager.c: unresolved external symbol _sqlite3VtabArgExtend{linebreak} unresolved external symbol _sqlite3VtabArgInit{linebreak} unresolved external symbol _sqlite3VtabBeginParse{linebreak} unresolved external symbol _sqlite3VtabFinishParse{linebreak} there is a fix in sqliteint.h #ifdef SQLITE_OMIT_VIRTUALTABLE # define sqlite3VtabClear(X) # define sqlite3VtabSync(X,Y) (Y) # define sqlite3VtabRollback(X) # define sqlite3VtabCommit(X) # define sqlite3VtabBeginParse(a,b,c,d) # define sqlite3VtabFinishParse(X,Y) # define sqlite3VtabArgInit(X) # define sqlite3VtabArgExtend(X,Y) #else void sqlite3VtabClear(Table*); int sqlite3VtabSync(sqlite3 *db, int rc); int sqlite3VtabRollback(sqlite3 *db); int sqlite3VtabCommit(sqlite3 *db); void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*); void sqlite3VtabFinishParse(Parse*, Token*); void sqlite3VtabArgInit(Parse*); void sqlite3VtabArgExtend(Parse*, Token*); #endif _2006-Sep-22 19:03:36 by anonymous:_ {linebreak} The lemon parses isn't receiving the -DSQLITE_OMIT_VIRTUALTABLE in command line. This problem is related to the SQLITE makefile, that is ignoring this flag (and also other that I don't remember now). ---- _2006-Sep-23 20:39:40 by drh:_ {linebreak} Anonymous is correct. You have to pass -DSQLITE_OMIT_VIRTUALTABLE to lemon when you are converting parse.y into parse.c. Do this and the problem goes away. #cfe8bd 1987 code fixed 2006 Sep drh 2006 Sep drh 1 1 Malformed database results from changing encoding The "pragma encoding" statement is only suppose to all you to change the database encoding before the database has been created. But sometime, it lets you change the encoding half way in the middle of creating a database. This results in some information being stored as UTF8 and other information being stored as UTF16 - a corrupt database. The following script run against an empty file using the command-line shell will replicate the problem: PRAGMA encoding=UTF16; CREATE TABLE t1(a); PRAGMA encoding=UTF8; CREATE TABLE t2(b); After running the script above, the resulting database is not well-formed. The problem seems to occur only when creating a new database. If the database already exists with the above script is run, the pragmas are ignored and everything works as it is suppose to. The work-around is to not try to change the database encoding after one or more tables have already been created while creating a new database. #cfe8bd 1986 doc fixed 2006 Sep anonymous 2006 Sep 5 4 typo in documentation The page http://www.sqlite.org/lang_createtable.html contains a typo. The sentence: An INTEGER PRIMARY KEY column man also include the keyword AUTOINCREMENT. Should be: An INTEGER PRIMARY KEY column can also include the keyword AUTOINCREMENT. #c8c8c8 1985 doc closed 2006 Sep anonymous 2006 Sep 1 4 how get table names How get table names from single db file with sqlite api? Not only it's described in the FAQ - http://www.sqlite.org/faq.html (question 9), but this is also not a place for asking questions. That's what mailing list is for. #c8c8c8 1984 code closed 2006 Sep anonymous 2006 Sep 1 1 sqlite3_exec problem after execute sqlite3_exec function - azColName[0] was losed when funtion job finished. How i can get again? _2006-Sep-19 12:05:25 by drh:_ {linebreak} The arguments passed into the callback of sqlite3_exec() are ephemeral. You must make a copy if you want them to persist. This is documented behavior. ---- _2006-Sep-19 12:15:14 by anonymous:_ {linebreak} thanks ps. I wanted save the copy :) #f2dcdc 1983 code active 2006 Sep anonymous 2006 Sep 2 2 I/O Error at a size of 4GB and auto_vacuum=1 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. #cfe8bd 1982 code fixed 2006 Sep anonymous 2006 Sep 1 1 FTS1: Database error after deleting and reinserting into FTS table FTS1: Inserting, deleting, and reinserting into FTS table results in database error: drop table if exists x; create virtual table x using fts1 (a); insert into x (a) values ('one two'); insert into x (a) values ('three four'); delete from x where x match ('one'); insert into x (a) values ('one two'); delete from x where x match ('one'); -- Raises "SQL logic or missing database error". #cfe8bd 1981 code fixed 2006 Sep anonymous 2006 Sep 1 1 fts1.c uses strcasecmp instead of sqlite3StrICmp from utils.c fts1.c (lines 2889 and 2892) uses strcasecmp instead of sqlite3StrICmp from utils.c. According to the comments in utils.c, this can lead to confusion with some build systems. _2006-Sep-18 11:22:22 by drh:_ {linebreak} FTS1 is designed so that it can be compiled as a loadable extension. sqlite3StrICmp() is not accessible to loadable extensions. #f2dcdc 1980 code active 2006 Sep drh 2006 Sep 1 1 Initializing FTS1 twice causes it to fail. If you try to load the shared module twice, it causes the module to no longer work. #cfe8bd 1979 doc fixed 2006 Sep anonymous 2006 Sep 4 4 Problem with full text search I build full text search extension as a dynamic loadable library (with a horrible name). I successfully load it at sqlite3 promt: .load Fi_xFts_n1.so Then I go: create virtual table foo using fts1; (By the way the wiki says "using fulltext", but according to code this would not work, you should use "fts1"). I get: SQL error: vtable constructor failed: foo. I think I shouldn't be getting this message. My specs: Debian Sarge Tcl 8.4.13 sqlite 3.3.7 I know I do not give much information here. I am open to do any tests you request or provide any info you need on this. Thanks. jima _2006-Sep-15 21:06:05 by drh:_ {linebreak} The reason for your problem is that the documentation lags woefully behind the code. I'll change this ticket to a documentation problem. ---- _2006-Sep-16 10:34:53 by anonymous:_ {linebreak} Well. I wondered if I could have just edited the wiki page myself to change doc concerning this. Apart from that, if I use the correct line: create virtual table foo using fts1; I get the error I mentioned, so I guess this is not only a documentation problem. ---- _2006-Sep-16 11:24:58 by drh:_ {linebreak} "better error messages from FTS1" would be a reasonable enhancement request. Details of the FTS usage syntax are forthcoming. In the meantime, just do this: CREATE VIRTUAL TABLE whatever USING fts1(content); The "(content)" argument to fts1 is what you are missing. There is a lot more you can put there - which will be explained in the forthcoming documentation. But that should be enough to get you going. ---- _2006-Sep-16 12:02:09 by anonymous:_ {linebreak} Great. With your hint I guess it is enough for the moment for me. Thanks. jima ---- _2006-Sep-19 22:54:29 by adamd:_ {linebreak} I've brought the documentation up to date. I'm marking this fixed. #cfe8bd 1978 event fixed 2006 Sep anonymous 2006 Sep 1 1 Are e-mail addresses from check-in [3417] real ones ? ditto. _2006-Sep-14 18:30:18 by drh:_ {linebreak} Good point. All traces of that file have been removed. #cfe8bd 1977 code fixed 2006 Sep anonymous 2006 Sep 2 1 FTS1: Access violation creating FTS table with no column parameter The following raises a read at address $00000000 access violation: CREATE VIRTUAL TABLE foo using fts1; whereas CREATE VIRTUAL TABLE foo using fts1 (Content); does not. It seems that no default column is automatically inserted if the column specification is missing, or no error message is being issued. _2006-Sep-14 13:57:28 by drh:_ {linebreak} On the latest code in CVS I get an error message: SQL error: vtable constructor failed: foo ---- _2006-Sep-15 15:05:05 by anonymous:_ {linebreak} The error is still there, but my analysis was wrong. The error is caused in fts1.c, line 1672: memset(pSpec, 0, sizeof(pSpec)); pSpec is not dereferenced in sizeof, so the variable is only partially zeroed. Proposed solution (notice the added * astiersk!): memset(pSpec, 0, sizeof(*pSpec)); #cfe8bd 1976 code fixed 2006 Sep anonymous 2006 Sep 4 3 wrong call to set error in vacuum.c At line 317 in file src/vacuum.c there is a call to sqlite3MallocFailed(). The comments says this is done to set the malloc error for the thread. But this call is merely a status checking call. The caller really wants to call sqlite3FailedMalloc(). _2006-Sep-13 19:22:08 by drh:_ {linebreak} A better solution is to remove the whole block of code. Turns out the whole thing was a no-op. #f2dcdc 1975 new active 2006 Sep anonymous 2006 Sep 5 4 Request for sqlite3_table_column_metadata16 It would be nice to have a sqlite3_table_column_metadata16() function as an UTF-16 version of the existing sqlite3_table_column_metadata(). #f2dcdc 1974 code active 2006 Sep anonymous Unknown 2006 Sep 1 1 column type not consistent in views 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 #f2dcdc 1972 code active 2006 Sep anonymous 2006 Sep 2 4 segfault on empty query SQLite 2.8.17 used in latest versions of PHP segfaults with empty query (i.e. " ", 1 whitespace). PHP reproduce code: 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:_ {linebreak} 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:_ {linebreak} "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:_ {linebreak} 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:_ {linebreak} >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(). #c8c8c8 1970 build closed 2006 Sep anonymous Unknown 2006 Sep 4 4 Cannot make Loadable Extensions to work for me. Hi. I hope this is the right place to tell this story. I am building sqlite from sources in a debian sarge box. I am interested in Loadable Extensions. I had to introduce into the Makefile the following lines to enable the loadable extension mechanism: TCC += -DHAVE_DLOPEN and TLIBS += /usr/lib/libdl.so And then I go, no problems building. I have sqlite built with this feature I guess. But the thing is that I cannot make it to work. I prepared a c file following the template given in the wiki. I generated a .so using: gcc -I/path_to_sqlite-3.3.7/src -c -o Extension.o Extension.c And gcc -shared -o Extension.so Extension.o /path_to_libsqlite3.so/libsqlite3.so I linked with this warning: /usr/bin/ld: Warning: size of symbol 'sqlite3_api' changed from 4 to 460 in /path_to_libsqlite3.so/libsqlite3.so But it produced the .so that I wanted. When I do in sqlite3 prompt: .load Extension.so It goes: unable to open shared library [Extension.so] Any clues of what is going on? Perhaps a sample gcc invokation line for building the extension would also be a good thing in the docs. Thank you very much. jima _2006-Sep-10 11:08:48 by drh:_ {linebreak} This is not the right place to tell your story, actually. Tickets are for reporting bugs. You are having difficulting compiling and using SQLite which is not really a bug. For help on compiling and using SQLite, please send your request to the sqlite mailing list. Instructions for joining the mailing list can be found at http://www.sqlite.org/support.html #c8c8c8 1969 code closed 2006 Sep anonymous 2006 Sep 3 2 Degrade of INSERT performance between 3.3.4 and 3.3.6/3.3.7 I don't agree with your resolution, so far. *: Maybe it's not the insert speed that suffered. It looks like it takes longer to parse the statement. *: Your TCL script repeats the same statement 1000 times, while I've inserted 24 different lines (ok, my report was inaccurate in this regard). I don't know, whether TCL's sqlite3 binding has any influence on this. *: I've used the precomiled sqlite3.dll for Windows. *: Can you give me a hint, how to reproduce your test scenario with sqlite3.exe, in a way that it parses and executes the mentioned statement 1000 times? When I put 1000 statements in a file to execute, does sqlite3 parse 1000 statements and then execute 1000 statements or does it 1000 times parse and execute a single statement? _2006-Sep-09 17:45:31 by anonymous:_ {linebreak} If you put 1000 statements in a file then SQLite will parse and execute 1000 statements. ---- _2006-Sep-17 12:29:15 by anonymous:_ {linebreak} The performance degrade is the result of opening the in memory database by using a _NULL_ filename (=sqlite3_open(NULL, &pDB)=). The right way to open an in memory database seems to be =sqlite3_open(":memory:", &pDB)=, as mentioned in InMemoryDatabase on 2006-02-22. #c8c8c8 1968 code closed 2006 Sep anonymous Unknown 2006 Sep 1 2 sqlite3_column_type() returns 1 instead of 0 since 3.3.7 It seems that sqlite3_column_type() now returns 1 where it used to return 0 and moreover it seems that it even returns 1 where it previously returned a different value (like 3). Up to and including version 3.3.6, the following code deduced the column type correctly even for a statement like _: =select * from [report] limit 0= which one might use to just get the column definition of the table _report_:
   for (int i = 0; i < sqlite3_column_count(m_statement); i++)   {     const CString colName = sqlite3_column_name(m_statement, i);      int columnType = sqlite3_column_type(m_statement, i);     if (0 == columnType)     {       const CString colDeclType = sqlite3_column_decltype(m_statement, i);       if (0 == colDeclType.CompareNoCase("TEXT") || colDeclType.IsEmpty())         columnType = SQLITE_TEXT;       else if (0 == colDeclType.CompareNoCase("INTEGER"))         columnType = SQLITE_INTEGER;       else if (0 == colDeclType.CompareNoCase("REAL"))         columnType = SQLITE_FLOAT;       else if (0 == colDeclType.CompareNoCase("BLOB"))         columnType = SQLITE_BLOB;       else if (0 == colDeclType.CompareNoCase("NULL"))         columnType = SQLITE_NULL;       else         ASSERT(false);     }   } 
In case you are looking for a table definition to test with, see ticket #1967. sqlite3_column_type() should only be called after sqlite3_step() has returned SQLITE_ROW. You appear to be calling it before calling sqlite3_step(), in which case the results are undefined. #c8c8c8 1967 code closed 2006 Sep anonymous Unknown 2006 Sep 3 2 Degrade of INSERT performance between 3.3.4 and 3.3.6/3.3.7 I've recognized a severe performance degrade of the INSERT statement in versions 3.3.6/3.3.7 compared to version 3.3.4. What did I do? *: create an empty memory database *: create an empty table by executing the attached statement by sqlite3_exec(m_sqlite3, sql, 0, 0, 0); *: insert 24 rows by executing 24 times the below statement with alternating data by sqlite3_exec(m_sqlite3, sql, 0, 0, 0); Although there are only 24 rows to insert the performance issue is quite noticeable (takes about ten times longer to process). BTW: I know that is recommended to use a prepared statement and the binding functions, but so far it was no bottleneck. _2006-Sep-08 18:24:21 by drh:_ {linebreak} I tried to reproduce this using the test script in the attachment. (insert-speed.txt). I'm getting 562 microseconds per insert for version 3.3.7 and 548 microseconds per insert for version 3.3.3 averaged over 1000 inserts. #c8c8c8 1965 code closed 2006 Sep anonymous 2006 Sep 3 3 sqlite returns wrong error code I found what the problem is that sqlite returns the wrong error code. What happens is next (in version 3.3.7):
-vdbe.c:2593 -> sqlite3BtreeCursor returns code 6 (table locked) => rc = 6
-vdbe.c:2606 -> switch checks rc value
-vdbe.c:2642 -> falls to default which is goto abort_due_to_error (:4975)
-vdbe.c:4980 -> goto vbe_halt (:4947)
-vdbe.c:4948 -> rc > 0 == true
-vdbe.c:4950 -> rc = SQLITE_ERROR <== PROBLEM we forget the correct error code
-vdbe.c:4956 -> return rc (value is 1) == WRONG!
_2006-Sep-08 11:43:29 by drh:_ {linebreak} When sqlite3_step() fails, it always returns a generic error SQLITE_ERROR. To get the specific error code, you have to call sqlite3_reset(). See, for example, tickets #1633, #1366, #1178, #906, and probably a bunch of others. I'm going to go fix the documentation right now.... #cfe8bd 1964 code fixed 2006 Sep anonymous Unknown 2006 Sep anonymous 3 3 datetime function broken
 sqlite> create table xx (x datetime); sqlite> insert into xx values('2005-09-01'); sqlite> select datetime(xx.x,"+0 hours" )  from xx; 2005-09-01 00:00:00 sqlite> select datetime(xx.x )  from xx; 2005-09-01 12:00:00 
#c8c8c8 1963 new closed 2006 Sep anonymous 2006 Sep 2 2 sqlite3_aggregate_context() should be improved For implementing an OO wrapper (Java) around sqlite, I need to save information between aggregation function calls in an object (not in an fix-sized memory block). For this I need a way to somehow attach a callback to the aggregation context, which is called once the aggregate context is no longer needed. In this callback I would finalize (=free/delete) my object. Another reason why this is needed: Imagine an aggregation function "concat(str, ',')" which concatinats aggregated values in a comma seperated list. Since the length of the resulting string is not known in advance, it is not possible to do this with the current sqlite3_aggregate_context() call. _2006-Sep-07 14:48:24 by anonymous:_ {linebreak} This is really easy to do. When your aggregate step() is called for the first time (sqlite3_aggregate_count() == 1) you call sqlite3_aggregate_context() and allocate 1 byte of storage. Then you use the resulting memory pointer as the key part of a static dictionary class of key/value pairs. Allocate your own data and store it in the dictionary and refer to it during step(). When your xFinal() function is called, do your wrapup work, deallocate your memory, remove your dictionary entry, and return the result. ---- _2006-Sep-07 15:16:36 by anonymous:_ {linebreak} Thank you for your suggestion. Under normal conditions, this will work. But what happens in case of an error: Is the xFinal() call guaranteed, even if an error occurs while processing the statement? ---- _2006-Sep-07 16:35:10 by drh:_ {linebreak} xFinal() is always called, even if an error occurs that aborts the query. Some of the built-in aggregate functions depend on this behavior. #c8c8c8 1962 new closed 2006 Sep anonymous 2006 Sep 4 2 sqlite3_column_value() not exported It would be nice to have the sqlite3_column_value() function exported into the DLL. This helps when implementing wrapper classes. _2006-Sep-07 16:39:11 by drh:_ {linebreak} Already fixed. See ticket #1951. #f2dcdc 1961 build active 2006 Sep anonymous 2006 Sep 3 3 3.3.7 : wrong readline.h path in Makefile We have readline.h installed in /usr/local/include/readline. In SQLite it is accessed with : #include But unfortunatly in Makefile, READLINE flags contains : -I /usr/local/include/readline instead of -I /usr/local/include #f2dcdc 1960 code active 2006 Sep anonymous 2006 Sep 4 2 Issues with .import in sqlite.exe 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. #f2dcdc 1959 new active 2006 Sep anonymous 2006 Sep 4 3 Unblockable TEMP TABLES 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 #f2dcdc 1958 code active 2006 Sep anonymous 2006 Sep 4 4 some printf tests fail with Tcl 8.5a5, ok with Tcl 8.4 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:_ {linebreak} 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 #cfe8bd 1957 code fixed 2006 Sep anonymous 2006 Sep 4 4 Incorrect test messages: not compiled with -DSQLITE_DEBUG Skipping malloc tests: not compiled with -DSQLITE_DEBUG... Warning message should be SQLITE_MEMDEBUG in altermalloc.test, attachmalloc.test and malloc2.test: if {[info command sqlite_malloc_stat]==""} { puts "Skipping malloc tests: not compiled with -DSQLITE_DEBUG..." finish_test return } #ifdef SQLITE_MEMDEBUG { "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail }, { "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat }, #endif #c8c8c8 1956 code closed 2006 Sep anonymous 2006 Sep 1 1 ALTER TABLE ADD COLUMN does not support asian language column names. The contents below contain asian characters, to be viewed more correctly, please visit the snapshot at here: http://hiphotos.baidu.com/arloan/pic/item/6db751fb3a1f27166c22ebdb.jpg
 F:\tmp>sqlite test.db SQLite version 3.3.7 Enter ".help" for instructions sqlite> .dump BEGIN TRANSACTION; COMMIT; sqlite> CREATE TABLE FOOBAR ("中文一" integer, "中文二" varchar(32)); sqlite> ALTER TABLE FOOBAR ADD COLUMN "中文三" integer; sqlite> .dump BEGIN TRANSACTION; CREATE TABLE FOOBAR ("中文一" integer, "? "中文三" integer形亩? varchar(32)); COMMIT; sqlite> .exit  F:\tmp> 
_2006-Sep-03 16:22:14 by drh:_ {linebreak} I tried this and it works correctly for me on Linux. SQLite expects to see UTF-8 characters. Perhaps you are using win95 and the asian characters are encoded using a "code page" rather than UTF-8? Or perhaps the DOS box on windows just isn't able to handle UTF-8? Does anybody know? ---- _2006-Sep-03 16:28:14 by anonymous:_ {linebreak} He use gb2312 chinese encoding, not utf8 encoding .So he should convert the text to utf8 encoding to create the table #cfe8bd 1955 code fixed 2006 Sep anonymous 2006 Sep 3 2 [3381] breaks MinGW ./configure && make sqlite3.dll Checkin [3381] makes life difficult for MinGW users. You no longer can build sqlite3.dll with the following command: ./configure && make sqlite3.dll Is there any harm in putting the sqlite3.dll target back into Makefile.in? _2006-Sep-02 13:23:55 by drh:_ {linebreak} The rules no longer work because they depend on sqlite3.def which is no longer part of the source tree. Perhaps you can suggest an alternative set of rules for the Makefile that do not use sqlite3.def or else generate sqlite3.def automatically. For hints on how to generate sqlite3.def automatically, see the mkdll.sh script in the root of the source tree. ---- _2006-Sep-02 14:21:37 by anonymous:_ {linebreak} You could make an sqlite3.def makefile target which is dependent on whatever files it needs for the def file generation. Then you could put the sqlite3.dll target back in Makefile.in, and make it dependent on sqlite3.def. ---- _2006-Sep-02 14:42:12 by drh:_ {linebreak} I do not have access to a windows system on which to develop such rules. Someone will need to submit patches if this is to appear in the source tree. ---- _2006-Sep-02 20:42:57 by anonymous:_ {linebreak} This patch fixes MinGW "./configure && make sqlite3.dll" diff -u -3 -p -r1.156 Makefile.in --- Makefile.in 1 Sep 2006 17:06:20 -0000 1.156 +++ Makefile.in 2 Sep 2006 20:55:46 -0000 @@ -665,7 +665,26 @@ clean: rm -f testfixture$(TEXE) test.db rm -rf doc rm -f common.tcl - rm -f sqlite3.dll sqlite3.lib + rm -f sqlite3.dll sqlite3.lib sqlite3.def distclean: clean rm -f config.log config.status libtool Makefile config.h + +# +# Windows section +# +dll: sqlite3.dll + +REAL_LIBOBJ = $(LIBOBJ:%.lo=.libs/%.o) + +$(REAL_LIBOBJ): $(LIBOBJ) + +sqlite3.def: $(REAL_LIBOBJ) + echo 'EXPORTS' >sqlite3.def + nm $(REAL_LIBOBJ) | grep ' T ' | grep ' _sqlite3_' \ + | sed 's/^.* _//' >>sqlite3.def + +sqlite3.dll: $(REAL_LIBOBJ) sqlite3.def + $(TCC) -shared -o sqlite3.dll sqlite3.def \ + -Wl,"--strip-all" $(REAL_LIBOBJ) + Note that -Wl,"--strip-all" does not corrupt the Windows DLL relocation table unlike the commandline strip command. ---- _2006-Sep-02 22:23:01 by anonymous:_ {linebreak} Interesting... it seems that MinGW does not need a .def file for DLL creation: diff -u -3 -p -r1.156 Makefile.in --- Makefile.in 1 Sep 2006 17:06:20 -0000 1.156 +++ Makefile.in 2 Sep 2006 22:18:08 -0000 @@ -669,3 +669,14 @@ clean: distclean: clean rm -f config.log config.status libtool Makefile config.h + +# +# Windows section +# +dll: sqlite3.dll + +REAL_LIBOBJ = $(LIBOBJ:%.lo=.libs/%.o) + +sqlite3.dll: $(LIBOBJ) $(REAL_LIBOBJ) + $(TCC) -shared -o sqlite3.dll -Wl,"--strip-all" $(REAL_LIBOBJ) + I tested it and it appears to work fine. I don't know if there is any downside. #f2dcdc 1954 code active 2006 Sep anonymous Unknown 2006 Sep 1 1 Dual Core Processor Lockup 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:_ {linebreak} 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. #f2dcdc 1953 code active 2006 Sep anonymous TclLib 2006 Sep 4 3 Fix for false 64-bit comparisons "make test" failures on Cygwin 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} {link: http://sourceforge.net/tracker/index.php?func=detail&aid=1551762&group_id=10894&atid=110894 Cygwin Tcl 8.5 64-bit integer math bug report} {link: http://sourceforge.net/tracker/download.php?group_id=10894&atid=110894&file_id=191898&aid=1551762 Cygwin Tcl 8.5a5 64-bit integer math fix} #c8c8c8 1952 code closed 2006 Sep anonymous Parser 2006 Sep 2 2 Memory leak in select with duplicate colum names reproduce: "select * from a, b ... " where a and b have columns with the same name, e.g. "EntryId" => Memory leaks with "EntryId:1", "EntryId:2"... the error is in the file select.c: /* Make sure the column name is unique. If the name is not unique, ** append a integer to the name so that it becomes unique. */ zBasename = zName; for(j=cnt=0; j>> old zName should be deleted here <<<=== zName = sqlite3MPrintf("%s:%d", zBasename, ++cnt); j = -1; if( zName==0 ) break; } } _2006-Sep-01 14:37:36 by drh:_ {linebreak} Look again. The old value of zName gets freed in the code that follows what you quoted above: if( zBasename!=zName ){ sqliteFree(zBasename); } #cfe8bd 1951 build fixed 2006 Sep dougcurrie 2006 Sep 3 2 symbols missing from sqlite3.def The following symbols seem to be missing from sqlite3.def: sqlite3_clear_bindings sqlite3_sleep ---- These are missing, too, but probably shouldn't be added since they are not in the default build: #ifdef SQLITE_ENABLE_COLUMN_METADATA sqlite3_column_database_name sqlite3_column_database_name16 sqlite3_column_origin_name sqlite3_column_origin_name16 sqlite3_column_table_name sqlite3_column_table_name16 sqlite3_table_column_metadata #endif #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT sqlite3_release_memory sqlite3_soft_heap_limit #endif These symbols are in sqlite3.def but are missing from http://www.sqlite.org/capi3ref.html sqlite3_enable_load_extension sqlite3_get_auxdata sqlite3_libversion_number sqlite3_load_extension sqlite3_set_auxdata sqlite3_snprintf _2006-Sep-01 15:55:14 by drh:_ {linebreak} How do *.def files work? Is it OK to list functions in the *.def file that do not actually appear in the library? If so, then it would be OK to include all possible API functions in the sqlite3.def file - even APIs that were not included in a particular build. But if not, I'll have to add logic to the Makefile that constructs the sqlite3.def file based on compile-time options. I do not program for windows (which is apparently the only system that requires a *.def file - other operating systems can figure out the entry points in a library for themselves.) So I do not really know how def files work. Somebody please enlighten me. ---- _2006-Sep-01 16:01:31 by anonymous:_ {linebreak} It depends on the Windows compiler. It's safer to include just the definitions that acually exist. ---- _2006-Sep-01 16:44:29 by drh:_ {linebreak} (Sigh...) Why does everything have to be at least twice as difficult to do on windows..... #c8c8c8 1950 new closed 2006 Aug anonymous 2006 Sep 4 4 AUTOINCREMENT too picky about type Of these four statements, CREATE TABLE tab (col INT PRIMARY KEY AUTOINCREMENT); CREATE TABLE tab (col INT(11) PRIMARY KEY AUTOINCREMENT); CREATE TABLE tab (col INTEGER PRIMARY KEY AUTOINCREMENT); CREATE TABLE tab (col INTEGER(11) PRIMARY KEY AUTOINCREMENT); only the third one works and the rest gives an error: SQL error: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY But since they're all kind of equivalent, it would be nice if they would all work. _2006-Sep-01 00:15:18 by anonymous:_ {linebreak} They aren't equivalent. Please reread the section on INTEGER PRIMARY KEY at http://sqlite.org/lang_createtable.html. In particular, this: {quote: An INTEGER PRIMARY KEY column man also include the keyword AUTOINCREMENT. The AUTOINCREMENT keyword modified the way that B-Tree keys are automatically generated. Additional detail on automatic B-Tree key generation is available separately.} ---- _2006-Sep-01 00:45:48 by anonymous:_ {linebreak} That's because the average users don't know what is b-tree and are not concerned about the c code but they only think the sqlite supports the common sql language and they use it! I personally the next version of sqlite change the its own policy even it might not be compatible with the former version of sqlite. ---- _2006-Sep-01 01:20:19 by anonymous:_ {linebreak} My vote is also for making INT == INTEGER as far as PRIMARY KEY is concerned. The current distinction is not obvious and not useful to new users of this database. ---- _2006-Sep-01 15:16:23 by drh:_ {linebreak} Backwards compatibility is much more important that the syntactic preferences of new users. ---- _2006-Sep-01 15:35:48 by anonymous:_ {linebreak} Under what circumstance is the current behavior of "INT PRIMARY KEY" useful? Who would want the current less-efficient indexing behavior? #cfe8bd 1899 new fixed 2006 Jul anonymous 2006 Sep drh 5 4 Is it possible add IF NOT EXISTS Create View and Create Trigger Is it possible add IF NOT EXISTS to Create View and Create Trigger and add IF EXISTS to drop trigger statement? By the way , drop view statement support if exists syntax, but the document is not updated. #f2dcdc 1822 code active 2006 May anonymous 2006 Sep 3 3 Table Alias together with Subquery seems not to work proper 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? #c8c8c8 1751 code closed 2006 Apr anonymous Unknown 2006 Sep mike 1 1 sqlite doesn't work on a cifs-mounted drive I use an OpenWRT-Linux (for Linksys-Router). A drive was mounted with cifs. SQLITE works on Linux perfectly. But, then I use a database on mounted drive, I get "I/O Error". root@OpenWrt:/mnt# ./sqlite test.sdb SQLite version 3.3.4 Enter ".help" for instructions sqlite> .databases Error: disk I/O error sqlite> The file test.sdb was created by SQLITE, but SQLITE can't write to this file. _2006-Sep-06 14:58:44 by anonymous:_ {linebreak} Note sure if this helps but: I'm getting the same problem. The setup is a bit odd (involving running fedora5 in a chroot'd jail inside fedora4 where the files are copied into a unionfs mount). The problem appears to occur where, if I open (say) /tmp/sqlite as the database file, then strace shows the /tmp directory being opened and fsync on the descriptor thence returns EINVAL (compared to doing the same in the main fedora4 where the fsync succeeds). If I loop mount a file-based ext2 filesystem into the jail and try the database file in there, it works OK, so I deduce its not the chroot'ing that triggers the problem. Here's the relevant strace bit
 open("/tmp/SQLTest-journal", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0644) = 4 fstat64(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 open("/tmp", O_RDONLY|O_LARGEFILE)      = 5 _llseek(4, 0, [0], SEEK_SET)            = 0 open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 6 read(6, "\371\210\t\266M3<:g\\=Jla\354\35\r7\v\340\257\204\274`"..., 256) = 256 close(6)                                = 0 write(4, "\331\325\5\371 \241c\327\0\0\0\0Q\350\226\332\0\0\0\0\0"..., 24) = 24 _llseek(4, 511, [511], SEEK_SET)        = 0 write(4, "\0", 1)                       = 1 fsync(4)                                = 0 fsync(5)                                = -1 EINVAL (Invalid argument) close(5)                                = 0 close(4)                                = 0 unlink("/tmp/SQLTest-journal")          = 0 
---- _2006-Sep-06 15:23:22 by drh:_ {linebreak} If the directory containing the rollback journal is not fsync()-ed after the rollback journal is created or deleted, then there is a race condition that can lead to database corruption on an untimely power failure. See, for example, ticket #410. SQLite appears to be doing the right thing here. The bug appears to be OpenWRT-Linux, not in SQLite. You can work around the problem by compiling with -DSQLITE_DISABLE_DIRSYNC=1 That macro disables the directory syncing logic. But then if you lose power at exactly the wrong moment and your rollback journal vanishes (or gets moved to /lost+found) and your database is corrupted - don't complain. I better solution, it seems, would be to fix OpenWRT-Linux. #c8c8c8 1481 code closed 2005 Oct anonymous VDBE 2006 Sep 4 4 sqlite 3.2.7 does not report column names properly in joined queries it seems, that ver 2.3.7 does not report the column names properly if one use joined select. Documntation says: ... Normally, such result columns are named . if the SELECT statement joins two or more tables together, or simply if the SELECT statement queries a single table. ... but if I try this: sqlite> pragma short_column_names=0;{linebreak} sqlite> pragma full_column_names=0;{linebreak} sqlite> .header on{linebreak} sqlite> create table t1 (id);{linebreak} sqlite> insert into t1 values (1);{linebreak} sqlite> insert into t1 values (2);{linebreak} sqlite> insert into t1 values (3);{linebreak} sqlite> select * from t1; id{linebreak} 1{linebreak} 2{linebreak} 3{linebreak} sqlite> select * from t1 left join t1 as t2 on t1.id=t2.id;{linebreak} id|id{linebreak} 1|1{linebreak} 2|2{linebreak} 3|3{linebreak} sqlite> column headers are id|id and not t1.id|t2.id _2005-Oct-12 18:06:07 by drh:_ {linebreak} Your work-around it to us an AS clause to specify any column header you want. ---- _2006-Sep-27 18:13:18 by anonymous:_ {linebreak} Duplicate of #1142. #c8c8c8 1477 code closed 2005 Oct anonymous Unknown 2006 Sep 1 2 first "select count(*) from mytable" takes a very long time i have a very big database file (>3.5GB).
when i open it, the first "select count(*) from mytable" takes a very long time (> 15 minutes), then the time is reduces to 3-4 seconds...
result: my application hangs on startup !
(the table has an index, thats maybe not the problem)
example statements:

create table params (id integer, name integer, value ntext)
create index paramsidx on params (id, name)
insert into params (id, name, value) values (1, 0, 'abc1')
insert into params (id, name, value) values (1, 1, 'abc2')
insert into params (id, name, value) values (2, 0, 'xyz1')
insert into params (id, name, value) values (2, 1, 'xyz2')
insert into params (id, name, value) values (2, 2, 'xyz3')
...
insert into params (id, name, value) values (10000000, 0, 'foo1')
insert into params (id, name, value) values (10000000, 1, 'bar2')

it looks like the complete database file is scanned on the first access... even if i access a table with only 1 row it takes a very long time _2005-Oct-14 03:34:24 by anonymous:_ {linebreak} Have you done an EXPLAIN on your query and looked at the results? ---- _2005-Oct-14 08:21:56 by anonymous:_ {linebreak} SQLite version 3.2.7
Enter ".help" for instructions
sqlite> explain select count(*) from sequence;
0|MemNull|0|0|
1|Goto|0|13|
2|Integer|0|0|
3|OpenRead|0|431334|
4|SetNumColumns|0|1|
5|Rewind|0|8|
6|AggStep|0|0|count(0)
7|Next|0|6|
8|Close|0|0|
9|AggFinal|0|0|count(0)
10|MemLoad|0|0|
11|Callback|1|0|
12|Halt|0|0|
13|Transaction|0|0|
14|VerifyCookie|0|9|
15|Goto|0|2|
16|Noop|0|0|
or
sqlite> explain select count(*) from logs;
0|MemNull|0|0|
1|Goto|0|13|
2|Integer|0|0|
3|OpenRead|0|2|
4|SetNumColumns|0|6|
5|Rewind|0|8|
6|AggStep|0|0|count(0)
7|Next|0|6|
8|Close|0|0|
9|AggFinal|0|0|count(0)
10|MemLoad|0|0|
11|Callback|1|0|
12|Halt|0|0|
13|Transaction|0|0|
14|VerifyCookie|0|9|
15|Goto|0|2|
16|Noop|0|0|
sqlite>
... i dont understand this "sql-assembler", but it looks not very time-consuming. ---- _2005-Oct-14 09:28:21 by anonymous:_ {linebreak} In both your cases, steps 6 and 7 indicate a full-table scan. Which is what I suspected; it would be rather hard to implement COUNT(*) any other way. ---- _2005-Oct-17 08:41:49 by anonymous:_ {linebreak} i thougt it is very fast to get the count of rows if the table is indexed... now i tried a "count(id)" instead of a "count(*)" (id is in the index), but it is even slower !!!
ok, i'll try to reorganize some tables and queries...
thanx a lot for your fast answers ! ---- _2005-Oct-21 10:10:11 by anonymous:_ {linebreak} i discovered the following:
if i do just a select on the id-column its veeeeeeery fast !
if i have for example the column 'date' in my query (in the where clause or in the order-by clause) its getting veeeery slow !!!
i expect some million rows, and i think it will be unusable then
any ideas ?

Here is a sample of my database:
  BEGIN TRANSACTION; CREATE TABLE logs (id integer primary key, date integer, type varchar(1), category integer, module ntext, message ntext); INSERT INTO "logs" VALUES(1, 20051021101843460, 'E', 1, 'SYSTEM', 'SYSTEM_EXCEPTION'); INSERT INTO "logs" VALUES(2, 20051021101843491, 'I', 1, 'SYSTEM', 'CREATED_LOGDB'); INSERT INTO "logs" VALUES(3, 20051021101843491, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(4, 20051021101843491, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(5, 20051021101843491, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(6, 20051021101843507, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(7, 20051021101843507, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(8, 20051021101843507, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(9, 20051021101843569, 'D', 1, 'SYSTEM', 'SETTING_CURRENT_LANGUAGE'); INSERT INTO "logs" VALUES(10, 20051021101843632, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(11, 20051021101843788, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(12, 20051021101844585, 'D', 3, 'DEBUG', 'CREATED_EXCEPTION'); INSERT INTO "logs" VALUES(13, 20051021101844601, 'E', 1, 'OPC', 'SYSTEM_EXCEPTION'); INSERT INTO "logs" VALUES(14, 20051021101844616, 'D', 3, 'DEBUG', 'CREATED_EXCEPTION'); INSERT INTO "logs" VALUES(15, 20051021101844632, 'E', 1, 'OPC', 'SYSTEM_EXCEPTION'); INSERT INTO "logs" VALUES(16, 20051021101844647, 'D', 3, 'DEBUG', 'CREATED_EXCEPTION'); INSERT INTO "logs" VALUES(17, 20051021101844663, 'E', 1, 'OPC', 'SYSTEM_EXCEPTION'); INSERT INTO "logs" VALUES(18, 20051021101844679, 'D', 3, 'DEBUG', 'CREATED_EXCEPTION'); INSERT INTO "logs" VALUES(19, 20051021101844694, 'E', 1, 'OPC', 'SYSTEM_EXCEPTION'); INSERT INTO "logs" VALUES(20, 20051021101844694, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(21, 20051021101844835, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(22, 20051021101844835, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(23, 20051021101844882, 'I', 1, 'SYSTEM', 'CONFIG'); INSERT INTO "logs" VALUES(24, 20051021101844897, 'I', 1, 'SYSTEM', 'CONFIG'); INSERT INTO "logs" VALUES(25, 20051021101844897, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(26, 20051021101844897, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(27, 20051021101845882, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(28, 20051021101845897, 'D', 3, 'DEBUG', 'DEBUG');  ... many more lines ...  INSERT INTO "logs" VALUES(454204, 20051021111458816, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454205, 20051021111458816, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454206, 20051021111458847, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454207, 20051021111458847, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454208, 20051021111458847, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454209, 20051021111458863, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454210, 20051021111458863, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454211, 20051021111458863, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454212, 20051021111458879, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454213, 20051021111458879, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454214, 20051021111458879, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454215, 20051021111458894, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454216, 20051021111458894, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454217, 20051021111458894, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454218, 20051021111458910, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454219, 20051021111458910, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454220, 20051021111458910, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454221, 20051021111458926, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454222, 20051021111458926, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454223, 20051021111458926, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454224, 20051021111458941, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454225, 20051021111458941, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454226, 20051021111458957, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454227, 20051021111458957, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454228, 20051021111458957, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454229, 20051021111458973, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454230, 20051021111458973, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454231, 20051021111458973, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454232, 20051021111458988, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454233, 20051021111458988, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454234, 20051021111459004, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454235, 20051021111459004, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454236, 20051021111459004, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454237, 20051021111459020, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454238, 20051021111459020, 'I', 1, 'SYSTEM', 'STOPPING'); INSERT INTO "logs" VALUES(454239, 20051021111459035, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454240, 20051021111459035, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454241, 20051021111459035, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454242, 20051021111459129, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454243, 20051021111459129, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454244, 20051021111459145, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454245, 20051021111459161, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454246, 20051021111459161, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454247, 20051021111459176, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454248, 20051021111459176, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454249, 20051021111459192, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454250, 20051021111459192, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454251, 20051021111459208, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454252, 20051021111459208, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454253, 20051021111459239, 'D', 3, 'DEBUG', 'DEBUG'); INSERT INTO "logs" VALUES(454254, 20051021111509703, 'D', 3, 'DEBUG', 'DEBUG'); CREATE TABLE params (id integer, name integer, value ntext); INSERT INTO "params" VALUES(1, 0, 'System.UnauthorizedAccessException'); INSERT INTO "params" VALUES(1, 1, 'Der Zugriff auf den Pfad d:\src\Triton\LG2\config\EventCategories.xml wurde verweigert.'); INSERT INTO "params" VALUES(2, 0, 'Data Source=d:\src\Triton\LG2\log\2005-10-21\..\log.MCPRunner.sdb;Version=3;UTF8Encoding=True;Cache Size=10000;Synchronous=Full;New=True'); INSERT INTO "params" VALUES(2, 1, 'NBAZ1297'); INSERT INTO "params" VALUES(3, 0, 'adding command ''ListCommands'' (delegate)'); INSERT INTO "params" VALUES(4, 0, 'adding command ''Logger.RebuildCategories'' (delegate)'); INSERT INTO "params" VALUES(5, 0, 'loaded 853 translations'); INSERT INTO "params" VALUES(6, 0, '  loaded 223 translations for language ''de'' (missing 223 translations)'); INSERT INTO "params" VALUES(7, 0, '  loaded 446 translations for language ''en'''); INSERT INTO "params" VALUES(8, 0, '  loaded 184 translations for language ''ko'' (missing 262 translations)'); INSERT INTO "params" VALUES(9, 0, 'en'); INSERT INTO "params" VALUES(10, 0, 'file ''d:\src\Triton\LG2\McpStart.cmd'' not found'); INSERT INTO "params" VALUES(11, 0, 'adding command ''Logging.BackupEvent'' (delegate)'); INSERT INTO "params" VALUES(12, 0, 'OPC_ITEM_ERROR'); INSERT INTO "params" VALUES(12, 1, 'OPC item error: Main.S7.PCIfc.States.Communication: OPCError([0x80004005])'); INSERT INTO "params" VALUES(12, 2, '   d:\src\triton\mcprunner\mcprunnerform.cs:92   d:\src\triton\mcprunner\mcprunnerform.cs:1232 '); INSERT INTO "params" VALUES(13, 0, 'SDevLib.OPC.OPCException'); INSERT INTO "params" VALUES(13, 1, 'OPC item error: Main.S7.PCIfc.States.Communication: OPCError([0x80004005])'); INSERT INTO "params" VALUES(14, 0, 'OPC_ITEM_ERROR'); INSERT INTO "params" VALUES(14, 1, 'OPC item error: Main.S7.PCIfc.States.Control: OPCError([0x80004005])'); INSERT INTO "params" VALUES(14, 2, '   d:\src\triton\mcprunner\mcprunnerform.cs:92   d:\src\triton\mcprunner\mcprunnerform.cs:1232 '); INSERT INTO "params" VALUES(15, 0, 'SDevLib.OPC.OPCException'); INSERT INTO "params" VALUES(15, 1, 'OPC item error: Main.S7.PCIfc.States.Control: OPCError([0x80004005])'); INSERT INTO "params" VALUES(16, 0, 'OPC_ITEM_ERROR'); INSERT INTO "params" VALUES(16, 1, 'OPC item error: Main.S7.PCIfc.States.Equipment: OPCError([0x80004005])'); INSERT INTO "params" VALUES(16, 2, '   d:\src\triton\mcprunner\mcprunnerform.cs:92   d:\src\triton\mcprunner\mcprunnerform.cs:1232 '); INSERT INTO "params" VALUES(17, 0, 'SDevLib.OPC.OPCException'); INSERT INTO "params" VALUES(17, 1, 'OPC item error: Main.S7.PCIfc.States.Equipment: OPCError([0x80004005])'); INSERT INTO "params" VALUES(18, 0, 'OPC_ITEM_ERROR'); INSERT INTO "params" VALUES(18, 1, 'OPC item error: Main.S7.PCIfc.States.Process: OPCError([0x80004005])'); INSERT INTO "params" VALUES(18, 2, '   d:\src\triton\mcprunner\mcprunnerform.cs:92   d:\src\triton\mcprunner\mcprunnerform.cs:1232 '); INSERT INTO "params" VALUES(19, 0, 'SDevLib.OPC.OPCException'); INSERT INTO "params" VALUES(19, 1, 'OPC item error: Main.S7.PCIfc.States.Process: OPCError([0x80004005])'); INSERT INTO "params" VALUES(20, 0, 'using MCP-TestCase ''LG2.alarmperf'''); INSERT INTO "params" VALUES(21, 0, 'adding command ''InvokeCmdOnMCPGuiThread'' (class = ''MCPRunner.InvokeCmdOnMCPGuiThreadCommand'')'); INSERT INTO "params" VALUES(22, 0, 'adding command ''UnitManager.ShowUnitManagerInfoForm'' (class = ''Framework.MCP.Manager.Unit.ShowUnitManagerInfoFormCommand'')'); INSERT INTO "params" VALUES(23, 0, 'MCP-baseDir'); INSERT INTO "params" VALUES(23, 1, 'd:\src\Triton\LG2\'); INSERT INTO "params" VALUES(24, 0, 'MCP-settingsFilename'); INSERT INTO "params" VALUES(24, 1, 'MCPConfig.xml'); INSERT INTO "params" VALUES(25, 0, 'adding command ''MCP.IsStarted'' (delegate)'); INSERT INTO "params" VALUES(26, 0, 'MCP: RemoteCommandServerC.Create'); INSERT INTO "params" VALUES(27, 0, 'loaded FSM ''CommunicationState'', set initstate to ''DISABLED'''); INSERT INTO "params" VALUES(28, 0, 'loaded FSM ''ControlState'', set initstate to ''OFFLINE''');  ... many more lines ...  INSERT INTO "params" VALUES(454204, 0, 'MCP: Framework.MCP.Manager.Alarm.AlarmManagerC.stop'); INSERT INTO "params" VALUES(454205, 0, 'Framework.MCP.Manager.Alarm.AlarmManagerC'); INSERT INTO "params" VALUES(454206, 0, 'MCP: Framework.MCP.ProcessStateC.stop'); INSERT INTO "params" VALUES(454207, 0, 'Framework.MCP.ProcessStateC'); INSERT INTO "params" VALUES(454208, 0, 'MCP'); INSERT INTO "params" VALUES(454209, 0, 'MCP: SDevLib.Commands.RemoteCommandServerC.stop'); INSERT INTO "params" VALUES(454210, 0, 'SDevLib.Commands.RemoteCommandServerC'); INSERT INTO "params" VALUES(454211, 0, 'MCP: SDevLib.Commands.CommandPoolC.stop'); INSERT INTO "params" VALUES(454212, 0, 'SDevLib.Commands.CommandPoolC'); INSERT INTO "params" VALUES(454213, 0, 'MCP: CommManager.MCP.CommManagerC.stop'); INSERT INTO "params" VALUES(454214, 0, 'CommManager.MCP.CommManagerC'); INSERT INTO "params" VALUES(454215, 0, 'MCP: APCMgr.CommManagerAPCC.stop'); INSERT INTO "params" VALUES(454216, 0, 'APCMgr.CommManagerAPCC'); INSERT INTO "params" VALUES(454217, 0, 'MCP: ComponentTree.ComponentTreeC.stop'); INSERT INTO "params" VALUES(454218, 0, 'ComponentTree.ComponentTreeC'); INSERT INTO "params" VALUES(454219, 0, 'MCP: Framework.MCP.Manager.Persistence.PersistenceManagerC.stop'); INSERT INTO "params" VALUES(454220, 0, 'Framework.MCP.Manager.Persistence.PersistenceManagerC'); INSERT INTO "params" VALUES(454221, 0, 'MCP: Framework.MCP.Manager.Recipe.RecipeManagerC.stop'); INSERT INTO "params" VALUES(454222, 0, 'Framework.MCP.Manager.Recipe.RecipeManagerC'); INSERT INTO "params" VALUES(454223, 0, 'MCP: Framework.MCP.Manager.Unit.UnitManagerC.stop'); INSERT INTO "params" VALUES(454224, 0, 'Framework.MCP.Manager.Unit.UnitManagerC'); INSERT INTO "params" VALUES(454225, 0, 'MCP: Framework.MCP.Manager.Unit.ECSUnitManagerC.stop'); INSERT INTO "params" VALUES(454226, 0, 'Framework.MCP.Manager.Unit.ECSUnitManagerC'); INSERT INTO "params" VALUES(454227, 0, 'MCP: Framework.MCP.EquipmentStateC.stop'); INSERT INTO "params" VALUES(454228, 0, 'Framework.MCP.EquipmentStateC'); INSERT INTO "params" VALUES(454229, 0, 'MCP: Framework.MCP.Manager.TransportManagerC.stop'); INSERT INTO "params" VALUES(454230, 0, 'Framework.MCP.Manager.TransportManagerC'); INSERT INTO "params" VALUES(454231, 0, 'MCP: Framework.MCP.Manager.Lot.LotManagerC.stop'); INSERT INTO "params" VALUES(454232, 0, 'Framework.MCP.Manager.Lot.LotManagerC'); INSERT INTO "params" VALUES(454233, 0, 'MCP: Framework.MCP.Manager.Glass.GlassManagerC.stop'); INSERT INTO "params" VALUES(454234, 0, 'Framework.MCP.Manager.Glass.GlassManagerC'); INSERT INTO "params" VALUES(454235, 0, 'MCP: Framework.MCP.Manager.Alarm.AlarmManagerC.stop'); INSERT INTO "params" VALUES(454236, 0, 'Framework.MCP.Manager.Alarm.AlarmManagerC'); INSERT INTO "params" VALUES(454237, 0, 'MCP: Framework.MCP.ProcessStateC.stop'); INSERT INTO "params" VALUES(454238, 0, 'Framework.MCP.ProcessStateC'); INSERT INTO "params" VALUES(454239, 0, 'MCP: SDevLib.Commands.RemoteCommandServerC.Dispose'); INSERT INTO "params" VALUES(454240, 0, 'MCP: SDevLib.Commands.CommandPoolC.Dispose'); INSERT INTO "params" VALUES(454241, 0, 'MCP: CommManager.MCP.CommManagerC.Dispose'); INSERT INTO "params" VALUES(454242, 0, 'MCP: APCMgr.CommManagerAPCC.Dispose'); INSERT INTO "params" VALUES(454243, 0, 'MCP: ComponentTree.ComponentTreeC.Dispose'); INSERT INTO "params" VALUES(454244, 0, 'MCP: Framework.MCP.Manager.Persistence.PersistenceManagerC.Dispose'); INSERT INTO "params" VALUES(454245, 0, 'MCP: Framework.MCP.Manager.Recipe.RecipeManagerC.Dispose'); INSERT INTO "params" VALUES(454246, 0, 'MCP: Framework.MCP.Manager.Unit.UnitManagerC.Dispose'); INSERT INTO "params" VALUES(454247, 0, 'MCP: Framework.MCP.Manager.Unit.ECSUnitManagerC.Dispose'); INSERT INTO "params" VALUES(454248, 0, 'MCP: Framework.MCP.EquipmentStateC.Dispose'); INSERT INTO "params" VALUES(454249, 0, 'MCP: Framework.MCP.Manager.TransportManagerC.Dispose'); INSERT INTO "params" VALUES(454250, 0, 'MCP: Framework.MCP.Manager.Lot.LotManagerC.Dispose'); INSERT INTO "params" VALUES(454251, 0, 'MCP: Framework.MCP.Manager.Glass.GlassManagerC.Dispose'); INSERT INTO "params" VALUES(454252, 0, 'MCP: Framework.MCP.Manager.Alarm.AlarmManagerC.Dispose'); INSERT INTO "params" VALUES(454253, 0, 'MCP: Framework.MCP.ProcessStateC.Dispose'); INSERT INTO "params" VALUES(454254, 0, 'file ''d:\src\Triton\LG2\McpStop.cmd'' not found'); CREATE TABLE glassinfo (id integer, unit integer, subunit integer, glassid ntext, glassslprt ntext, lotid ntext); CREATE TABLE alarms (alarm integer, idIn integer, dateIn integer, idOut integer, dateOut integer, unit ntext, m1 text, m2 text, m3 text, m4 text, m5 text, m6 text, m7 text, m8 text, m9 text, m10 text, m11 text, m12 text); CREATE INDEX logsidx on logs (id, date, type, category, module, message); CREATE INDEX paramsidx on params (id, name); CREATE INDEX glassinfoidx on glassinfo (id); CREATE INDEX alarmsidx on alarms (alarm, idIn, dateIn, idOut, dateOut, unit); COMMIT;  ... sample queries ...  select id, date, type, message, module from logs where date>=20051021102732476 and date<=29991231235959999 and type<>'D' and type<>'I' order by id, date asc LIMIT 30 OFFSET 0 select id, date, type, message, module from logs where date>=20000000000000000 and date<=29991231235959999 and type<>'D' and type<>'I' order by id, date asc LIMIT 30 OFFSET 52988  
---- _2005-Oct-21 18:52:22 by anonymous:_ {linebreak} It would probably be more productive to take this to the mailing list. ---- _2006-Sep-27 18:32:56 by anonymous:_ {linebreak} Creating index on date might help. #f2dcdc 1445 code active 2005 Sep anonymous 2006 Sep 3 3 Errors testing sqlite 3.2.6 (& v3.3.7) $ 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:_ {linebreak} The test scripts do not (yet) work with Tcl 8.5. Use Tcl 8.4. ---- _2005-Sep-20 01:59:42 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} Run the build starting from an empty directory as a non-root user. ---- _2006-Sep-06 13:27:18 by anonymous:_ {linebreak} 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:_ {linebreak} bump. anyone? ---- _2006-Sep-30 22:19:24 by anonymous:_ {linebreak} 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. #f2dcdc 2329 new active 2007 Apr anonymous 2007 Apr 5 4 add a feature to .dump : partial dumps 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 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 #f2dcdc 2328 code active 2007 Apr anonymous 2007 Apr 1 1 Makefile sqlite3.c target breakage for C++ This is generated by "make sqlite3.c": #if 0 extern "C" { #endif _2007-Apr-29 06:02:20 by anonymous:_ {linebreak} 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. #f2dcdc 2327 new active 2007 Apr anonymous 2007 Apr anonymous 2 1 "DELETE" operation makes memory rise 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. #f2dcdc 2326 doc active 2007 Apr anonymous 2007 Apr a.rottmann 5 2 miss one word 'list' 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". #c8c8c8 2325 code closed 2007 Apr anonymous 2007 Apr 1 1 Link Fails w/ SQLITE_OMIT_ALTERTABLE Compiling the windows zip package (sqlite3.c) from 3.3.17 w/ -DSQLITE_OMIT_ALTERTABLE results in these linkage errors: sqlite3/sqlite3.o(.text+0x6a24c):sqlite3.c: undefined reference to `sqlite3AlterBeginAddColumn' sqlite3/sqlite3.o(.text+0x6a39f):sqlite3.c: undefined reference to `sqlite3AlterFinishAddColumn' sqlite3/sqlite3.o(.text+0x6a3c5):sqlite3.c: undefined reference to `sqlite3AlterRenameTable' _2007-Apr-27 17:47:07 by drh:_ {linebreak} Many of the -DSQLITE_OMIT options do not work when you compile from the windows ZIP archive. The files there have already been processed by tools that need to know what is being omitted. If you want to use SQLITE_OMIT compile-time options, you need to compile from sources, not preprocessed files. #cfe8bd 2324 code fixed 2007 Apr anonymous 2007 Apr 2 2 replace('abc', '', 'x') dumps core Replace() function dumps core if the second argument is empty string. $ sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> select replace('abc', '', 'x'); Floating point exception (core dumped) #cfe8bd 2323 code fixed 2007 Apr anonymous 2007 Apr 3 3 invalid TRIM for multibytes Trim (and ltrim, rtrim) doesn't consider multibyte characters. $ sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> select hex(''); -- greek characters CEB1CEB2CEB3 sqlite> select hex(trim('', '')); B2CEB3 #f2dcdc 2322 code active 2007 Apr anonymous 2007 Apr 1 1 Windows error: datetime('2000-10-29 06:00:00','localtime') 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:_ {linebreak} Confirmed Windows bug on Windows 2000 in NY time zone with Y2K7DST OS patch. ---- _2007-Apr-27 22:03:25 by drh:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 2321 code fixed 2007 Apr anonymous 2007 Apr 3 3 sqlite3_value_bytes moves pointer although there is no type conversion The following code may cause segfault when the argv[0] is UTF-8 text after version 3.3.8. const char *p = sqlite3_value_blob(argv[0]); size_t len = sqlite3_value_bytes(argv[0]); if (len > 0 && p && *p) /* SEGFAULT at '*p' */ ... Since sqlite3_value_blob() doesn't convert the type of argv[0], the type of argv[0] is still UTF-8 text just after sqlite3_value_blob(). Although no type conversion is produced at sqlite3_value_bytes() for this reason, sqlite3_value_bytes() invalidates the pointer returned by sqlite3_value_blob() when the pMem->z of argv[0] is not null-terminated. I think, it should be that either to which sqlite3_value_blob() converts the type of argv[0] to BLOB, or sqlite3_value_bytes() doesn't add null-terminator when the argv[0] is UTF-8 text. _2007-Apr-27 04:16:36 by danielk1977:_ {linebreak} I don't think we can make either of the suggested changes without potentially breaking lots of existing code. The best practice is to call _bytes() before either _text() or _blob(). See also: http://www.sqlite.org/capi3ref.html#sqlite3_column_blob ---- _2007-Apr-27 05:53:35 by anonymous:_ {linebreak} Some codes in SQLite are call sqlite3_value_bytes() after sqlite3_value_text(). In replaceFunc, trimFunc, t1_ifnullFunc, test_column_blob. Otherwise, some of such codes are found by {link: http://www.google.co.jp/search?q=sqlite3_column_bytes google} search. *: samples for sqlite3_column_blob *:: {link: http://trac.u-go.net/kombilo/browser/06/libkombilo-branches/hash_center/search.cpp?rev=243#L2747 1} *:: {link: http://biodcv.itc.it/websvn/filedetails.php?repname=BioDCV%20(Biodata%20Distributed%20Complete%20Validation)&path=/tag/0.1/semisupervised/main.c&rev=10&sc=1 2} *: samples for sqlite3_value_blob *:: {link: http://viewmtn.angrygoats.net/revision/file/386bd5fab3b55635765c1f0bc3beddbe970afc8d/database.cc 1} *:: {link: http://utu.devjavu.com/projects/utu/browser/utu-core/src/lang/lua/libluasqlite3.c?rev=34#L1224 2} *:: {link: http://archives.devshed.com/forums/databases-124/using-blobs-in-where-fields-2053309.html A thread of some databases forum} The patch [3391] (or the change of the reference manual in [3834]) breaks these existing codes. #f2dcdc 2320 code active 2007 Apr anonymous 2007 Apr drh 1 1 sqlite3_open(sFN_with_umlaut) 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:_ {linebreak} 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. #cfe8bd 2319 code fixed 2007 Apr anonymous 2007 Apr 4 4 Duplicated test identifiers In examining parts of the test suite I've noticed a couple of places where the test ID is duplicated. It's not important, but it might make examining test results more difficult for those cases. *:rowid-1.9 - is duplicated; the first test checks that 'RowID' works, the second checks for '_rowid_'. *:quote-1.3 - is duplicated (once before 1.3.1 and once after 1.3.3); these are different tests. Hope that helps. #cfe8bd 2318 todo fixed 2007 Apr anonymous 2007 Apr 5 5 http://www.sqlite.org/contrib login broken ERROR: invalid command name "delete" invoked from within "subst {[delete] }" invoked from within "db eval "SELECT rowid, name, size, date, dscrpt, cnt, user FROM file ORDER BY $orderby" { if {$size<10.0*1024.0} { set sz "$size b..." invoked from within "::tws::eval [read $fd [file size $argv1]]" invoked from within "reply-content [::tws::eval [read $fd [file size $argv1]]]" invoked from within "evalfile main.tcl" #c8c8c8 2317 code closed 2007 Apr anonymous 2007 Apr 4 4 Floats rendered to strings differently in WHERE and GROUP BY clauses. SQLite renders floats differently in the WHERE and in the GROUP BY clauses. Observe: sqlite> CREATE TABLE test(x FLOAT); sqlite> INSERT INTO test VALUES (1.0); sqlite> SELECT * FROM test WHERE "A" || x = "A1.0" GROUP BY "A" || x; 1 Note that when rendering x to a string for the WHERE clause, it becomes "1.0", but for the GROUP BY clause, it becomes "1". This behavior seems inconsistent. SQLite 3.3.16 produces the correct result "1.0". #c8c8c8 2316 code closed 2007 Apr anonymous 2007 Apr 4 4 2 prepared statements on same database cause RC = 21 Hi, I used wxSQLite3 to created a database and create 2 prepared statements. I serialized access to both prepared statements (1 mutex for each), but somehow this was interfering with the other thread his calls. What happened was the following: [threadID] function_call ... [2808] sqlite3_reset [2808] sqlite3_bind_text [2352] sqlite3_reset [2808] sqlite3_bind_int [2352] sqlite3_bind_text [2808] sqlite3_bind_int [2352] sqlite3_bind_int [2808] sqlite3_bind_int [2352] sqlite3_bind_int [2352] sqlite3_bind_int [2352] sqlite3_bind_blob [2352] sqlite3_bind_null [2352] sqlite3_bind_int [2352] sqlite3_bind_int [2352] sqlite3_bind_int [2352] sqlite3_step [2808] sqlite3_step So the thread 2808 was interfering with the statement of 2352. I would suspect SQLite to work on the prepared statement only, and only work on the database if it needed to do that (where it would first check the 'state' it was in, and return RC=busy if it was busy). But now it returns RC=21 (invalid sequence), which is a little illogical to me. I solved it by serializing access to the database, not the prepared statements themselves. Greetz, Steven The user seems to have solved their own problem, so I'm not sure why this ticket is here.... #c8c8c8 2315 code closed 2007 Apr anonymous 2007 Apr 1 1 Macro Redefinition Warning When compiling sqlite3.c from the 3.3.16 zip package, Visual Studio 6.0 gives the following warnings: sqlite3.c(57066) : warning C4005: 'ARRAYSIZE' : macro redefinition C:\program files\Microsoft Platform SDK\Include\winnt.h(950) : see previous definition of 'ARRAYSIZE' This occurs when using the latest platform SDK from Microsoft. The code should be #ifndef'd to fix the warning. _2007-Apr-23 18:23:48 by rdc:_ {linebreak} This is a duplicate of ticket #2311 #cfe8bd 2314 code fixed 2007 Apr anonymous 2007 Apr 1 1 SQLITE_OMIT_UTF16 Can't be Defined If you compile sqlite3.c from sqlite-3_3_16.zip in Visual Studio 6.0, you get the following link error if you define SQLITE_OMIT_UTF16: sqlite3.obj : error LNK2001: unresolved external symbol _sqlite3_prepare16_v2 It seems the define no longer works in this version. _2007-Apr-23 17:20:49 by anonymous:_ {linebreak} Do you compile with the sqlite3.def file? In that case, remove the API function from there as well. ---- _2007-Apr-23 17:29:52 by anonymous:_ {linebreak} No, I compiled with only the sqlite3.c file. #f2dcdc 2313 build active 2007 Apr anonymous 2007 Apr 3 3 readline.h is not properly detected 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.) #c8c8c8 2312 code closed 2007 Apr anonymous 2007 Apr mike 1 1 Using ODBC. Only saves first 5 characters of text fields. Can you help I am using the ODBC with Powerbuilder. It is only saving the first 5 characters of any char, text, varchar field. I cannot continue until I have sorted this problem. Is there a setting I need to set in the database to get around this? Please help. Regards John Please post your question on the mailing list. #cfe8bd 2311 code fixed 2007 Apr anonymous 2007 Apr 4 4 redefinition of 'ARRAYSIZE' when compile under microsoft windows, there's a warning about redefinition of 'ARRAYSIZE' in where.c, because microsoft has already define it in winnt.h. I notice that there's an 'ArraySize' in sqliteInt.h, is it a good idea to reuse this definition instead of define a new 'ARRAYSIZE'? _2007-Apr-20 08:08:58 by anonymous:_ {linebreak} Same warning at BCC 5.82, but Open Watcom 1.6 is not. #f2dcdc 2310 code active 2007 Apr anonymous 2007 Apr anonymous 4 4 Problem installing on AIX 5.3, ML5 after successful compile with xlc 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: : /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:_ {linebreak} Haven't used AIX or xLC for 15 years - does IBM still make UNIX machines? #cfe8bd 2309 code fixed 2007 Apr shess 2007 Apr shess 1 1 Assert failure in fts2 MATCH of certain OR cases. If a MATCH query using OR hits on two non-empty doclists where the last two docids aren't the same, the code will overrun one of the doclists. Though this does cause an assertion failure, I *believe* that it will not cause segmentation faults when NDEBUG is set, because of how dlrStep() is structured. #f2dcdc 2308 build active 2007 Apr anonymous 2007 Apr 4 3 make sqlite3.c recreates sqlite3.c even though nothing changed 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:_ {linebreak} 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. #cfe8bd 2307 build fixed 2007 Apr anonymous 2007 Apr 4 4 missing #ifndef SQLITE_OMIT_SHARED_CACHE breaks compilation The source (at least the amalgamation) does not compile with SQLITE_OMIT_SHARED_CACHE defined because of a missing #ifndef statement around line 56457 #cfe8bd 2306 code fixed 2007 Apr anonymous 2007 Apr 4 3 Maybe detective Boolean-expression in sqlite3Expr() ? I've made code-analyze of sqlite3.c (amalgamation) with prefast (include in MS-WINDDK).{linebreak} There may be following potential problems: -> Boolean expression (2 lines): *: #37007: if( pRight->flags && EP_ExpCollate ){ {linebreak} sqlite3.c(37007) : warning 240: ( && ) *: #37012: if( pLeft->flags && EP_ExpCollate ){ {linebreak} sqlite3.c(37012) : warning 240: ( && ) Always evaluates to the Boolean result of .{linebreak} Was the bitwise-and operator intended ?{linebreak} Problem occurs in function 'sqlite3Expr' Best regards,{linebreak} Markus Eisenmann #c8c8c8 2305 doc closed 2007 Apr anonymous 2007 Apr 4 4 Function replace(X,Y,Z) doesn't exist ? sqlite3 SQLite version 3.3.15 Enter ".help" for instructions sqlite> select replace('toto','to', 'ti'); SQL error: no such function: replace Where did the SQLite binary come from? When I compile from source the replace function is there. It's in the pre-compiled shell binaries from the download page too: dan@linux-7qa0:~/tmp> ./sqlite3-3.3.15.bin SQLite version 3.3.15 Enter ".help" for instructions sqlite> select replace('toto', 'to', 'it'); itit sqlite> .quit ---- _2007-Apr-18 09:08:48 by anonymous:_ {linebreak} sorry, you can close this ticket, i have made a mistake ... #f2dcdc 2304 new active 2007 Apr anonymous 2007 Apr 1 1 resolve "databas is locked" problem under DEFERRED transaction under DEFERRED transaction, if there are multiple thread immediate execute writing operation after BEGIN statement,{linebreak} sqlite will direct kick in "database is locked" exception, but if you execute some reading operation before writing operation,{linebreak} 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 } #f2dcdc 2303 code active 2007 Apr anonymous 2007 Apr 1 1 Encrypted databases: No page cache due to problem in pagerSharedLock 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=? #f2dcdc 2302 build active 2007 Apr anonymous 2007 Apr anonymous 4 4 sqlite3 does not honor configure --disable-threads anymore 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 2301 build active 2007 Apr anonymous 2007 Apr 1 1 Latest cvs 3.3.15 fails lock4-1.3 test 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:_ {linebreak} which OS? ---- _2007-Apr-15 11:31:46 by drh:_ {linebreak} 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. #c8c8c8 2300 code closed 2007 Apr anonymous 2007 Apr 1 1 compound query ORDER BY expression problem CREATE TABLE t4(a TEXT, b TEXT); INSERT INTO "t4" VALUES('a','1'); INSERT INTO "t4" VALUES('b','2'); INSERT INTO "t4" VALUES('c','3'); SELECT b from t4 union SELECT 3 b order by b; 3 1 2 3 SELECT b from t4 union SELECT 3 b order by +b; SQL error: ORDER BY term number 1 does not match any result column sqlite> SELECT b from t4 union all select b from t4 order by -b; SQL error: ORDER BY term number 1 does not match any result column _2007-Apr-13 19:17:27 by drh:_ {linebreak} For a compound query, the ORDER BY expressions must be columns in the result set. My understand is that standard SQL requires all ORDER BY expressions everywhere to be expressions from the result set. SQLite relaxes this requirement for single queries, but for compound queries it does require that the order by terms be result set columns. ---- _2007-Apr-13 19:28:04 by anonymous:_ {linebreak} This is not my understanding of common practise. I often ORDER BY columns - or even complex expression - not present in my result set on several different makes of databases. If you make such an exception for a single table but not compound queries, then VIEWs are essentially useless. ---- _2007-Apr-13 19:35:52 by anonymous:_ {linebreak} I stand corrected - ORACLE does not allow ORDER BY expressions not seen in a compound SELECT's SELECT list. ---- _2007-Apr-13 19:43:20 by anonymous:_ {linebreak} The view comment is also wrong, as it transforms this failing query: select 4 b union select 3 b order by -b; SQL error: ORDER BY term number 1 does not match any result column to this: select * from (select 4 b union select 3 b) order by -b; which works. I will close this ticket. #f2dcdc 2299 build active 2007 Apr anonymous 2007 Apr 1 1 Cannot compile sqlite-3.3.15 on linux rhel 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} To be clearer, I think this is a local installation problem, not a bug in SQLite. #cfe8bd 2298 code fixed 2007 Apr anonymous 2007 Apr anonymous 3 2 Sqlite 3.3.15 backs out performance changes introduced in 3.3.14 In 3.3.14 sqlite was changed to keep pages in the page cache unless the file on disk has changed. This resulted in about a 35% increase in performance and considerably reduced disk I/O. In 3.3.15 sqlite does not seem to behave this way. It seems to flush all cache buffers at the end of every statement, reducing the benefits of the page cache that was introduced in 3.3.14 _2007-Apr-12 20:41:26 by anonymous:_ {linebreak} Which checkin are we talking about here? http://www.sqlite.org/cvstrac/rlog?f=sqlite/src/pager.c http://www.sqlite.org/cvstrac/rlog?f=sqlite/src/btree.c #f2dcdc 2297 code active 2007 Apr anonymous 2007 Apr drh 3 3 uninitialized var (with patch) Warnings with amalgamation and NDEBUG. _2007-Apr-12 21:21:29 by drh:_ {linebreak} 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:_ {linebreak} vdbe.c with n, n64, payloadSize and payloadSize64{linebreak} 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).{linebreak} page.c with ro{linebreak} 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'. #cfe8bd 2296 code fixed 2007 Apr anonymous 2007 Apr 3 3 IN clause of UNION of literal SELECT statements with ORDER BY I was trying to test out variations of #2295. These queries are okay: SELECT 3 z union SELECT 2 z order by z; 2 3 SELECT 2 b WHERE b IN (SELECT 3 z union SELECT 2 z); 2 SELECT 2 b WHERE b IN (SELECT 2 z order by z); 2 but you get an error if you put in an ORDER BY with a UNION in the IN clause: SELECT 2 b WHERE b IN (SELECT 3 z union SELECT 2 z order by z); SQL error: ORDER BY term number 1 does not match any result column I can only see generated SQL producing such a query, but there it is. _2007-Apr-12 05:10:04 by anonymous:_ {linebreak} Some more data points: CREATE TABLE t4(a TEXT, b TEXT); INSERT INTO "t4" VALUES('a','1'); INSERT INTO "t4" VALUES('b','2'); INSERT INTO "t4" VALUES('c','3'); This is okay: SELECT 2 b WHERE b IN (SELECT 3 b union SELECT b from t4 order by b); 2 SELECT b from t4 WHERE b IN (SELECT 3 b union SELECT b from t4 order by b); 1 2 3 SELECT b from t4 union SELECT 3 b order by b; 3 1 2 3 Problem appears to be with a literal rightmost SELECT in a UNION within an IN clause: SELECT 2 b WHERE b IN (SELECT b from t4 union SELECT 3 b order by b); SQL error: ORDER BY term number 1 does not match any result column SELECT b from t4 WHERE b IN (SELECT b from t4 union SELECT 3 b order by b); SQL error: ORDER BY term number 1 does not match any result column How's that for obscure? ---- _2007-Apr-12 13:50:15 by anonymous:_ {linebreak} It's not necessarily obscure - I can see such a IN clause being used with a LIMIT. ---- _2007-Apr-12 20:01:59 by anonymous:_ {linebreak} With relational (set-based) operations, the 'order by' in the context of a IN (... order by) is non-sensical and should have no effect on the resulting operation. I could conceive where the order-by may affect the plan used to process the resulting set, but that's an optimizer thing and not a semantic thing. ---- _2007-Apr-12 20:30:08 by anonymous:_ {linebreak} You didn't read the comment above it. This also fails: SELECT b from t4 WHERE b IN (SELECT b from t4 union SELECT 3 b order by b limit 1); ---- _2007-Apr-13 02:52:30 by anonymous:_ {linebreak} Because I was pre-occupied with the original IN/UNION/ORDER BY bug I missed that this result is wrong: SELECT b from t4 union SELECT 3 b order by b; 3 1 2 3 ---- _2007-Apr-13 02:55:09 by drh:_ {linebreak} No. That result is correct. The first 3 is a number. The next 3 rows are all text. Numbers sort before text. ---- _2007-Apr-13 03:06:51 by anonymous:_ {linebreak} I see. sqlite> SELECT b from t4 union SELECT 3 b order by +b; SQL error: ORDER BY term number 1 does not match any result column I understand your question in the mailing list now. #cfe8bd 2295 code fixed 2007 Apr anonymous 2007 Apr 1 1 Subquery fails when "order by" is added (from an email I sent to sqlite-users) On sqlite 3.3.12, I see the following: create table test_in (data text, ordinal text); insert into test_in values ('foo', '0'); insert into test_in values ('bar', '1'); insert into test_in values ('baz', '2'); Running: select count(1) from test_in where ordinal in (select ordinal from test_in); returns "3" as expected. However, if I add an order by to the subquery: select count(1) from test_in where ordinal in (select ordinal from test_in order by ordinal); this returns "0". But note that this works: select count(1) from test_in where rowid in (select rowid from test_in order by ordinal); My actual use case needs the "order by" in the subquery since I also add a "limit 1" clause. #c8c8c8 2293 code closed 2007 Apr anonymous 2007 Apr 2 2 Extra file operations with sub journal when DB in MEM Hi, I working with DB created in MEMORY and exec only SELECT query for It. I have found that sqlite create temp file on file system each time and then delete it. What is the purpose of this temp file. Is it possible to turn off creation of this file? It decrease perfomance on my embended system very much. _2007-Apr-11 01:37:52 by drh:_ {linebreak} I think this is a technical support question, not a bug report. Please ask technical support questions on the SQLite mailing list. See http://www.sqlite.org/support.html for instructions. #c8c8c8 2292 code closed 2007 Apr anonymous 2007 Apr 1 1 VACUUM => constraint failed Behavior not evident in 3.3.13, but exists in 3.3.14/3.3.15.{linebreak} The only difference between the following two SQL files is the position of the value-ful entry. After loading the first file, VACUUM gives rise to "SQL error: constraint failed". The other file allows VACUUMing without incident. ====================================================== Script started on Tue 10 Apr 2007 02:01:18 PM EDT{linebreak} # cat 0{linebreak} BEGIN TRANSACTION;{linebreak} CREATE TABLE userinfo(username TEXT PRIMARY KEY,amid TEXT,uid INTEGER,name TEXT);{linebreak} INSERT INTO "userinfo" VALUES('aaa','00023966',6638,'Alexander^^Au^');{linebreak} INSERT INTO "userinfo" VALUES('aan001',NULL,NULL,NULL);{linebreak} INSERT INTO "userinfo" VALUES('ags001',NULL,NULL,NULL);{linebreak} CREATE UNIQUE INDEX idx_amid ON userinfo(amid);{linebreak} CREATE UNIQUE INDEX idx_uid ON userinfo(uid);{linebreak} COMMIT;{linebreak} #{linebreak} # cat 1{linebreak} BEGIN TRANSACTION;{linebreak} CREATE TABLE userinfo(username TEXT PRIMARY KEY,amid TEXT,uid INTEGER,name TEXT);{linebreak} INSERT INTO "userinfo" VALUES('aan001',NULL,NULL,NULL);{linebreak} INSERT INTO "userinfo" VALUES('aaa','00023966',6638,'Alexander^^Au^');{linebreak} INSERT INTO "userinfo" VALUES('ags001',NULL,NULL,NULL);{linebreak} CREATE UNIQUE INDEX idx_amid ON userinfo(amid);{linebreak} CREATE UNIQUE INDEX idx_uid ON userinfo(uid);{linebreak} COMMIT;{linebreak} #{linebreak} # rm db{linebreak} # sqlite3 -init 0 db{linebreak} Loading resources from 0{linebreak} SQLite version 3.3.15{linebreak} Enter ".help" for instructions{linebreak} sqlite> vacuum;{linebreak} SQL error: constraint failed{linebreak} sqlite> .exit{linebreak} #{linebreak} # rm db{linebreak} # sqlite3 -init 1 db{linebreak} Loading resources from 1{linebreak} SQLite version 3.3.15{linebreak} Enter ".help" for instructions{linebreak} sqlite> vacuum;{linebreak} sqlite> .exit{linebreak} #{linebreak} script done on Tue 10 Apr 2007 02:02:08 PM EDT{linebreak} _2007-Apr-10 19:49:43 by drh:_ {linebreak} This appears to be a duplicate of ticket #2291. #cfe8bd 2291 code fixed 2007 Apr drh 2007 Apr 1 1 VACUUM fails when NULLs appear in a UNIQUE constraint The VACUUM in the following command sequence fails on a constraint error: CREATE TABLE t1(a, b, UNIQUE(a,b)); INSERT INTO t1 VALUES(NULL,0); INSERT INTO t1 VALUES(NULL,1); INSERT INTO t1 VALUES(NULL,1); VACUUM; This problem appears to have been introduced by the new XFER optimization to INSERT that was added by check-in [3643] which first appeared in version 3.3.14. The problem is non-destructive in the sense that no damage is done to the database - you just cannot vacuum it any more. _2007-Apr-10 19:36:22 by anonymous:_ {linebreak} Why are NULLs allowed in PRIMARY KEY at all? ---- _2007-Apr-10 19:49:15 by drh:_ {linebreak} There was a programming error early in the history of 3.x that allowed NULLs in a PRIMARY KEY. it was years before the error was discovered. By that point many applications had come to depend on NULLs being allowed in a PRIMARY KEY. To fix the error would break a lot of applications. See also ProposedIncompatibleChanges #cfe8bd 2290 code fixed 2007 Apr anonymous 2007 Apr 1 1 Using function result text as a function parameter Using function result text as a function parameter produces broken results. $ uname Linux $ ./sqlite3 SQLite version 3.3.15 Enter ".help" for instructions sqlite> select replace('ab', 'b', 'c'); ac sqlite> select hex('ac'); 6163 sqlite> select hex(replace('ab', 'b', 'c')); 0030 _2007-Apr-10 08:02:44 by anonymous:_ {linebreak} This problem seems to be caused only if *: the function result is SQLITE_TEXT, *: the function result is neither SQLITE_TRANSIENT nor SQLITE_STATIC, and *: the following function calls sqlite3_value_blob() before sqlite3_value_bytes(). ---- _2007-Apr-11 07:17:03 by anonymous:_ {linebreak} Hmm... Should not sqlite_column_blob() convert the type into BLOB? It is unclear from the fixed manual that there is the problem in calling sqlite_column_blob() before sqlite_column_bytes() although there is no problem in calling sqlite_column_text() before sqlite_column_bytes(). Above all, the code which calls sqlite_column_bytes() before sqlite_column_blob() seems to have obtained the bytes of TEXT and the pointer of BLOB when the value is TEXT. In addition, the code which calls sqlite_column_bytes() after sqlite_column_blob() was operating without the problem in the version 3.3.7. ---- _2007-Apr-19 05:07:25 by anonymous:_ {linebreak} How is this matter examined now? Is it better to create a new ticket? #cfe8bd 2289 code fixed 2007 Apr shess 2007 Apr shess 1 1 fts1 and fts2 crash when deleting or replacing rows with a null field. Excerpted from fts2m.test: CREATE VIRTUAL TABLE t1 USING fts2(col_a, col_b); INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null); DELETE FROM t1 WHERE rowid = 2; #f2dcdc 2288 code active 2007 Apr anonymous 2007 Apr 4 2 FTS does not support REPLACE 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:_ {linebreak} http://www.mail-archive.com/sqlite-users%40sqlite.org/msg23865.html #cfe8bd 2287 code fixed 2007 Apr anonymous 2007 Apr 1 1 make test fails on latest 3.3.14 cvs code export CFLAGS=-O3 ./configure --prefix=/usr/local make distclean make chown test:test -R . su -c 'make test' test fails with... 4 errors out of 27424 tests Failures on these tests: exclusive2-1.7 \ exclusive2-1.9 exclusive2-2.5 exclusive2-2.8 exclusive2-1.7... Expected: [1] Got: [2] exclusive2-1.9... Expected: [1] Got: [0] exclusive2-2.5... Expected: [5] Got: [3] exclusive2-2.8... Expected: [1 {database disk image is malformed}] Got: [0 {64 e229ff4e200c2a36fb78056cce392a0a}] #cfe8bd 2286 code fixed 2007 Apr drh 2007 Apr 1 1 Extra NULL value returned by a descending SELECT Suppose you have a table like this: CREATE TABLE t(x INTEGER PRIMARY KEY); And you do a descending query of that table: SELECT * FROM t ORDER BY x DESC; If you are half way through the query and you do a DELETE FROM t; The query should stop immediately. But instead, it returns a NULL value, then stops. It works correctly on an ascending SELECT. #cfe8bd 2285 code fixed 2007 Apr drh 2007 Apr 1 1 Rolling back a CREATE TEMP TABLE wedges the database Run this: BEGIN; CREATE TEMP TABLE x(y); ROLLBACK; Any further operations attempted against the TEMP database return an errror. This problem seems to apply to any exclusive-access database (temp databases are a special case of these): PRAGMA locking_style = EXCLUSIVE; BEGIN; CREATE TABLE x(y); ROLLBACK; stuffs up the main database connection. #cfe8bd 2284 build fixed 2007 Apr anonymous 2007 Apr 1 1 make test fails with - undefined external sqlite3_xferopt_count cd sqlite-3.3.14 export CFLAGS=-O3 ./configure --prefex=/usr/local make make test This appears to be an integer from src/test1.c which appears on the gcc line which fails. Unclear what's up here. #f2dcdc 2283 warn active 2007 Apr anonymous 2007 Apr 1 1 Compile warning by VCToolkit2003 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 #f2dcdc 2282 code active 2007 Apr anonymous 2007 Apr 3 4 Update on view with no matching trigger does not raise error 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:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 2281 build fixed 2007 Apr anonymous 2007 Apr 4 4 "CFLAGS=-DSQLITE_DEFAULT_FILE_FORMAT=4" causes alter2.test to fail Our shop needs to be sure that only the latest DB file format is used, so we want to compile that in as default. I did: export CFLAGS='-DSQLITE_DEFAULT_FILE_FORMAT=4' ../sqlite-3.3.13ex/configure --prefix=/opt/sqlite-3.3.13ex make make test And I got the following at the end of the test run: 6 errors out of 24349 tests Failures on these tests: alter2-5.3 alter2-6.2 corrupt2-1.2 corrupt2-1.3 corrupt2-1.4 corrupt2-1.5 make: *** [test] Error 1 [dns@rings sqlite-3.3.13ex-bld]$ I note that the corrupt2-* test-failures were reported and fixed immediately after 3.3.13 was released. With 3.3.13 they appear even without the CFLAGS being set. But the two alter2-* failures occur only with CFLAGS set as shown. I can only guess at TCL's meaning and haven't studied the structure of the test-harness, but I suspect that this is just an annoyance rather than a serious problem... #f2dcdc 2256 new active 2007 Feb anonymous 2007 Apr drh 5 1 Add POSITION() function (SQL-92 standard) 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:_ {linebreak} Yes, this is a function which I often suffered from not being available. #cacae5 2227 new defer 2007 Feb scouten 2007 Apr 5 4 Feature request: CHECKPOINT command We'd like to maintain exclusive access to the database over time. DRH proposed a CHECKPOINT, which would commit the changes made so far, but not end the transaction. _2007-Feb-12 22:46:56 by scouten:_ {linebreak} As we've thought about this more, we think it would be more elegantly implemented as an open_exclusive command using "real" transactions during the execution stream instead of keeping our transactions open indefinitely. ---- _2007-Feb-13 01:26:01 by drh:_ {linebreak} I do not understand the above comment. More explanation would be appreciated. ---- _2007-Feb-15 20:13:07 by anonymous:_ {linebreak} The goal of any of these changes it to prevent sqlite from dumping it's page cache at the end of a transaction. In situations where exclusive access to a sqlite3 database is guaranteed or desired, the overhead of flushing and reloading the cache is unnecessary. Current and suggested workarounds involve keeping a transaction open. The suggested CHECKPOINT fix would allow the sqlite user to keep a transaction open indefinitely and get the benefits of a transaction by issuing a CHECKPOINT where a COMMIT would have previously been issued. Modifying sqlite's transaction paradigm to keep the page cache around indefinitely would take advantage of a side effect of the transaction to solve this issue. Scouten suggests a more declarative way of accomplishing this, by adding a sqlite3_open_exclusive function that did the same thing as sqlite3_open, but informed the pager layer not to flush it's cache at the end of a transaction. ---- _2007-Mar-07 17:48:17 by anonymous:_ {linebreak} CHECKPOINT (as I understand it) would not just be useful to avoid flushing the page cache; it would be useful in cases where a process is running a long, involved update operation, that *can* be restarted from some internal points but one would prefer to avoid it, and if another process comes in and modifies things it would *have* to be restarted. The behavior of flushing out the current journal but not dropping the lock is thus desired for operation semantics, not just efficiency. One example of such an operation is monotone netsync (currently we use drop-and-retake, and hope no other user comes in). ---- _2007-Mar-29 21:36:38 by drh:_ {linebreak} As of earlier this week, there is a new feature in SQLite that will give you something like CHECKPOINT functionality. If you run this macro: PRAGMA locking_mode=EXCLUSIVE; Then locks will increase but will not be released. So as soon thereafter that you get an exclusive lock on the database, you will hold that lock until you either run PRAGMA locking_mode=NORMAL; Or until you close the database connection. While in exclusive access mode like this, you can do as many COMMITs as you want, and be assured that no other process will be able to jump in and modify the database. The page cache is not flushed. And the rollback journal file is truncated but not deleted. We might in the future add a command: COMMIT AND BEGIN That will commit a transaction then immediately start a new transaction without dropping locks even while not in exclusive access mode. COMMIT AND BEGIN is closer to the concept of CHECKPOINT. But for now, exclusive access mode will probably suffice for most peoples needs. ---- _2007-Apr-10 23:27:58 by rdc:_ {linebreak} The SQL:1999 standard uses a feature called CHAINED TRANSACTIONS for this. Basically each COMMIT or ROLLBACK statement can optionally be followed by a chain clause which performs the operation and immediately starts another transaction. COMMIT [AND [NO] CHAIN] ROLLBACK [AND [NO] CHAIN] The optional NO clause does the same thing as a normal commit with no chain clause. #c8c8c8 2178 code closed 2007 Jan anonymous 2007 Apr 1 1 On Windows Vista, a simple select returns different results. A simple query: SELECT value FROM some_pairs WHERE key = 'foo'; The value is supposed to be 100, for example. With different client invoking the sqlite3.dll, sometimes it returns 1, not 100. On other versions of Windows have no problem with the same database file and sqlite3.dll. Please supply a reproducable test case including full schema, data and select statement. ---- _2007-Feb-08 20:20:29 by anonymous:_ {linebreak} After I reboot the Windows Vista, the inconsistency was disappeared... I will try my best to reproduce it ASAP. ---- _2007-Feb-26 04:18:50 by anonymous:_ {linebreak} It's really hard to re-produce the situation. On my Vista, only PieTTY (a custom PuTTY) still has this problem. Since my program with SQLite is a DLL attached to some other application, it's quite complicated to rebuild the whole environment to test it. I have to figure out a more stable and simple way. ---- _2007-Apr-25 09:36:55 by anonymous:_ {linebreak} I guess I found the reason -- not SQLite's fault basically: http://b6s.blogspot.com/2007/04/previous-version-ghost-on-vista-can-be.html Cheers, /Mike T. J. "b6s" Jiang/ #c8c8c8 2605 build closed 2007 Aug anonymous 2007 Aug 1 3 Amalgamated version 3.4.2 doesn't compile (VC++6) In a project that already used versions 3.3.x through 3.3.17 (successfully) in "amalgamated" source, I substituted sqlite3.c and sqlite3.h from version 3.4.2, but I yield three compilation errors: ----------------------------------------------------------------- Compiling... {linebreak} sqlite3.c {linebreak} c:\lavoro\nonclassificato\resanddev\hcsprog\sqlite\sqlite3.c(6187) : error C2133: 'sqlite3UpperToLower' : unknown size {linebreak} c:\lavoro\nonclassificato\resanddev\hcsprog\sqlite\sqlite3.c(9310) : error C2133: 'sqlite3OpcodeNames' : unknown size {linebreak} c:\lavoro\nonclassificato\resanddev\hcsprog\sqlite\sqlite3.c(47159) : error C2133: 'sqlite3IsIdChar' : unknown size {linebreak} Error executing cl.exe. {linebreak} ----------------------------------------------------------------- They all are related to array declaration missing size in brackets. Duplicate of ticket #2574. Already fixed. #f2dcdc 2604 new active 2007 Aug anonymous 2007 Aug 4 4 CREATE VIRTUAL TABLE does not allow IF NOT EXISTS 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. #cfe8bd 2602 code fixed 2007 Aug anonymous 2007 Aug 1 1 ATTACH leaks memory Attaching a non-existing file to an empty database leaks memory. The scenario (Win32): *: Create a new empty database. *: sqlite3_prepare_v2 ( "ATTACH DATABASE 'C:\NonExistantFolder\NonExistantFile.db3' AS a;'); returns SQLITE_OK *: sqlite3_step(); returns SQLITE_ERROR *: sqlite3_finalize(); returns SQLITE_ERROR *: Close database and application. This returns a report about a single leak between 77 and 92 bytes in size. FYI: I also receive a 2nd, but smaller (21-28 bytes), leak when executing an FTS1 SELECT on an attached database. If you can confirm the 1st leak I will provide more information on the 2nd, if it still persists. _2007-Aug-30 14:21:25 by drh:_ {linebreak} I am unable to replicate the problem on Linux. My tests show all allocated memory is freed. Both SQLite's own internal accounting reports this, and valgrind too. We observe that the windows OS driver calls malloc() directly, bypassing SQLites internal memory allocator and its accounting procedures. And we do not know of anything like valgrind for windows. So perhaps there is a leak in the windows OS driver someplace. How do you see this leak, Ralf? What tools are you using? Do you get any indication where the leak is occurring? Can you see anything in the windows OS driver that might be causing the problem? ---- _2007-Aug-30 15:37:03 by anonymous:_ {linebreak} Found it: The if block in os_win.c, starting at line 1136, does not free zConverted after the else. The fix is to move the free(zConverted); line up into the 1st if block: if( h==INVALID_HANDLE_VALUE ){ free(zConverted); if( flags & SQLITE_OPEN_READWRITE ){ return winOpen(0, zName, id, ((flags|SQLITE_OPEN_READONLY)&~SQLITE_OPEN_READWRITE), pOutFlags); }else{ return SQLITE_CANTOPEN; } } #cfe8bd 2600 code fixed 2007 Aug anonymous 2007 Aug 1 1 #ifdef SQLITE_MUTEX_WIN32 naming error in mutex_w32.c? Line 23 in mutex_w32.c checks #ifdef SQLITE_MUTEX_WIN32. However, SQLITE_MUTEX_WIN32 is never defined in the SQLite core. Instead, SQLITE_MUTEX_WIN is (notice the missing 32 postfix). mutex_w32.c line 182 #endif /* SQLITE_MUTEX_WIN */ makes me believe that this is just a spelling error? If there are plans for extra support of non-Win32 platforms (Win64, Windows 3.1), it would be reasonable to choose _WIN32 over just _WIN. But then I suppose that this would also be true for the OS_WIN #define as well? #cfe8bd 2599 code fixed 2007 Aug anonymous 2007 Aug 1 1 OS check in mutex.h has no effect OS check in mutex.h (starting from line 34) dependes on OS autodetection in os.h. However, in sqliteInt.h the statement #include "mutex.h" is in line 76, way before #include "os.h" is followed in line 297. OS autodetection is therefore not taken into account for mutex.h and the library is compiled without mutexes, at least in Win32. It did work before mutex.c was split up for different OSes. #c8c8c8 2596 code closed 2007 Aug anonymous 2007 Aug 2 2 wrong specifier for extern char arrays In 3.4.2 (compared to 3.4.1) the forward declarations of char arrays sqlite3UpperToLower, sqlite3OpcodeNames and sqlite3IsIdChar are labeled with SQLITE_PRIVATE instead of previous extern. This causes problem with amalgamated file - the compiler (Visual C++ 9.0 beta 2) fails to compile it. Putting extern instead of SQLITE_PRIVATE had fixed the problem. Compile with -DSQLITE_PRIVATE=extern or compile a file like this: /* foo.c */ #define SQLITE_PRIVATE extern #include "sqlite3.c" #f2dcdc 2595 doc active 2007 Aug anonymous 2007 Aug 4 4 sqlite3_commit_hook doc typo src/main.c: -** Register a function to be invoked when a transaction comments. +** Register a function to be invoked when a transaction commits. #c8c8c8 2594 code closed 2007 Aug anonymous 2007 Aug 5 4 ability to replace allocator In order to use my own allocator for the SQLite I reimplemented routines sqlite3GenericMalloc, sqlite3GenericRealloc and sqlite3GenericOsFree. SQLite, however, needs some modification to use these functions: (1) The original functions need to be commented out. (2) Functions sqlite3OsMalloc, sqlite3OsRealloc and sqlite3OsFree (in amalgamated code) use specifier SQLITE_PRIVATE (static) and this needs to be removed too. Perhaps the SQLite code may employ macro SQLITE_I_HAVE_MY_OWN_ALLOCATOR or so to do this all w/o need to touch the code. The change of allocator worked well for me (I use Doug Lea's dlmalloc). _2007-Aug-29 22:34:36 by drh:_ {linebreak} Please check the mailing list archives. This is a planned feature for version 3.5.0. ---- _2007-Aug-29 22:56:18 by anonymous:_ {linebreak} What does OBE stand for? ---- _2007-Aug-29 23:45:10 by drh:_ {linebreak} Overcome by events. Normally that means that a ticket is no longer relevant because things have changed since the ticket was written. That does not apply here, exactly, but it was (in my opinion) the best available option for Resolution. #c8c8c8 2593 code closed 2007 Aug anonymous 2007 Aug 1 1 btshared unlock bug You have want to avoid a race condition by zeroing p->locked within the mutex. Otherwise another thread may acquire the lock, set locked to 1 (while still holding the mutex) and then this thread outside the mutex will unintentionally clear it. @@ -191,6 +193,7 @@ p->wantToLock--; if( p->wantToLock==0 ){ + p->locked = 0; sqlite3_mutex_leave(p->pBt->mutex); - p->locked = 0; } } } Haven't looked at the code, there may be other occurances of this. _2007-Aug-28 17:57:26 by drh:_ {linebreak} The p->locked variable is protected by a separate mutex, specifically the mutex at p->pSqlite->mutex. The database handle, the thing that sqlite3_open() returns, is at p->pSqlite. Each such handle has its own mutex. Associated with each database handle is one or more Btree structures, one for each open database. There are typically two of these, one for the main database and another for the TEMP database. New Btree structures are added for each ATTACH. Each Btree is tied to a single database handle so it is protected by the same mutex as the database handle. "p" is a pointer to a Btree in this instance. The guts of a database are contained in a Btshared structure. Btree points to Btshared. But if shared cache is enabled, two or more Btree structures from different database handles might point to the same Btshared. So Btshared needs its own mutex. This new mutex covers only the Btshared. The Btree structure is covered by the original database handle mutex. See also #2578 #c8c8c8 2592 warn closed 2007 Aug anonymous 2007 Aug 1 1 The Entry C:\Windows\Temp\sqlite_z6onAYdsVGqLG3Q is Invalid Everytime I reboot and check disk I get " The Entry C:\Windows\Temp\sqlite_z6onAYdsVGqLG3Q is Invalid I believe this has something to do with skype and all messengers rebooting my PC everytime I try to enable voice Thank you This is a question for a skype group. #cfe8bd 2591 doc fixed 2007 Aug anonymous 2007 Aug 4 4 sqlite3_open() documentation should mention :memory: I could not find information about in-memory database support in SQLite from API docs. In my opinion, sqlite3_open() function call is the place where it should be mentioned that I can give ":memory:"(?) as filename parameter to open in-memory database. #c8c8c8 2590 todo closed 2007 Aug anonymous 2007 Aug danielk1977 2 2 return value of strftime('%s', 'now') being determined as 'text' Hello. SELECT typeof(strftime('%s', 'now')); results 'text'. Is this correct? As strftime('%s', 'now') returns number of seconds since Unix epoch started. Greatings. In my opinion it is correct. strftime returns a formatted string. If for some reason you want the type of the expression to be an integer you could do: SELECT CAST(strftime('%s', 'now') AS INTEGER); #c8c8c8 2589 doc closed 2007 Aug anonymous 2007 Aug danielk1977 4 4 s/effected/affected/ in PRAGMA locking_mode In the last sentence of the documentation for PRAGMA locking_mode, "effected" should be "affected". thanks. #cfe8bd 2588 code fixed 2007 Aug anonymous 2007 Aug 1 1 bug in sqlite3_mutex_leave Race scenario on same mutex leading to corruption: Thread 1 Thread 2 -------------------------- -------------------------- sqlite3_mutex_enter pthread_mutex_lock ok p->owner = Thread 1 p->nRef = 1; sqlite3_mutex_leave p->nRef--; pthread_mutex_unlock ok sqlite3_mutex_enter sqlite3_mutex_enter pthread_equal is true pthread_equal is false pthread_mutex_lock ok p->owner = Thread 2; p->nRef = 1; p->nRef>0 is true p->nRef++; p->nRef is now 2 and the mutex is "owned" by Thread 2. Any data structure protected by this mutex can now be changed by both threads at the same time. Here's a possible pseudo fix:
 Index: src/mutex.c =================================================================== RCS file: /sqlite/sqlite/src/mutex.c,v retrieving revision 1.9 diff -u -3 -p -r1.9 mutex.c --- src/mutex.c 24 Aug 2007 20:46:59 -0000      1.9 +++ src/mutex.c 25 Aug 2007 01:39:10 -0000 @@ -358,6 +358,7 @@ void sqlite3_mutex_leave(sqlite3_mutex *    assert( p->nRef>0 );    p->nRef--;    if( p->nRef==0 ){ +    memset(&p->owner, 0, sizeof(p->owner));      pthread_mutex_unlock(&p->mutex);    }  } 
But even this fix is not guaranteed by POSIX standards, as an opaque pthread_t type when memset to zero may indeed be a valid pthread_t for the first (zeroeth) thread. This could lead to the same race condition and corruption. http://mail-archives.apache.org/mod_mbox/apr-dev/200307.mbox/%3c3F285220.7010501@netscape.com%3e This stuff is difficult to get right. Please consult correct recursive mutex implementations from various multi-threaded open source projects. _2007-Aug-25 02:35:35 by anonymous:_ {linebreak} Furthermore, the pthread_equal man page states: "If either t1 or t2 are not valid thread IDs, the behavior is undefined." http://www.opengroup.org/onlinepubs/009695399/functions/pthread_equal.html Only pthread_create and pthread_self can generate a valid pthread_t thread ID. ---- _2007-Aug-25 02:43:32 by anonymous:_ {linebreak} On POSIX systems that support it you should use PTHREAD_MUTEX_RECURSIVE instead of rolling your own. It is more efficient and guaranteed to be correct. http://www.opengroup.org/onlinepubs/000095399/functions/pthread_mutex_lock.html ---- _2007-Aug-25 03:23:56 by anonymous:_ {linebreak} Amusing back story of recursive POSIX mutexes from one of its creators: http://groups.google.com/group/comp.programming.threads/msg/d835f2f6ef8aed99?hl=en ---- _2007-Aug-25 04:13:08 by drh:_ {linebreak} I believe the problem is fixed by doing the p->nRef>0 test first and then the ownership test second. Rationale: 1: If p->nRef>0 it can only mean that some thread is holding the mutex. we don't know which thread, and the mutex might change owners multiple times before the next test. But we do at least know that somebody has held the mutex in the past. And we also know that p->owner has been initialized. 2: If the second pthread_equal() test is true, that means that the current thread claims to own the mutex. No other thread will ever put the current thread's threadid into p->owner. If p->owner==self, then only the current thread put it there. If another thread had claimed the mutex after the current thread, then the other thread would have changed the value of p->owner before raising p->nRef above zero. We know that p->nRef has been above zero, so the current thread must be the last one to have held the mutex. Hence, the current thread must still own the mutex. The above assumes that pthread_equal() is an atomic operation. In other words, it will not fail with a TRUE return if a separate thread changes the value of p->owner while the current thread is testing it. If p->owner is a multi-word value, then pthread_equal() might not be atomic. But pthread_t is an integer on every implementation of pthreads that I am aware of, so I think this is probably safe in most instances. Please double-check my reasoning above and let me know if I've said or done something goofy. Tnx. ---- _2007-Aug-25 04:25:26 by drh:_ {linebreak} Response to Butenhof: Threading in SQLite is not designed to make it more concurrent. It is designed to make the code safer to use by people who insist on writing multithreaded programs when multithreading really isn't necessary. Each database connection has its own mutex. Any thread using the database connection holds that mutex. So only a single thread can use a particular database connection at a time. The mutex is acquired when the API is entered and released when the API exits. But SQLite is reentrant. Top-level APIs can (and are) invoked as callbacks from within other top-level APIs. The only way to allow reentancy for one thread while excluding other threads (the only way that *I* know of, anyhow) is a recursive mutex. If David Butenhof thinks that recursive mutexes can be eliminated from SQLite by do "careful design", I'd like to hear him tell me how. One suspects that Mr. Butenhof has never tried to build a reentrant library for use in a multithreaded environment.... ---- _2007-Aug-25 04:47:52 by anonymous:_ {linebreak} My first impression is that the fix is not correct. Take a look at this post and the accompanying thread: http://groups.google.com/group/comp.programming.threads/msg/329ba20fe934b5e1?hl=en& pthread_equal() is probably not atomic on HPUX where pthread_t is a struct (of 4 int's as I recall). Nothing in the pthread_equal man page suggests that pthread_equal is guaranteed to be atomic, although on platforms where pthread_t is an int it would obviously be fine. Also, there is no concept of an official invalid pthread_t value - and even if there was, the pthread_equal man page is pretty clear that the result of such a comparison with an "invalid" pthread ID is undefined. For what it is worth, Apache Portable Runtime seems to have given up trying to roll their own recursive mutex on POSIX platforms that do not support PTHREAD_MUTEX_RECURSIVE. I appreciate that your use of recursive mutexes is for correctness and ease of API use. An alternate scheme would be to change the SQLite API to simply pass messages via work queues to a background thread that performs the database operations on your behalf. Much like your previous single thread "server" model. But then you have the headache of making every single SQLite API function work asynchronously - and you still would not improve concurrency on the same database. ---- _2007-Aug-25 05:05:17 by anonymous:_ {linebreak} This is somewhat related. When you work with SMP hardware and various optimizing compilers some things are not obvious. Take a look at the seemingly logical double-checked lock mis-pattern: http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html http://en.wikipedia.org/wiki/Double-checked_locking ---- _2007-Aug-25 14:45:21 by drh:_ {linebreak} Well, it turns out that SuSE Linux does support recursive mutexes after all. But in order to get it to work you have to have a line #define _XOPEN_SOURCE 500 prior to your #include . The value must be exactly 500. What this means is unclear. It is certainly undocumented as far as I can tell. A line such as the above was added to sqliteInt.h and the mutex.c sources were converted to use native recursive mutexes. SQLite now requires support for PTHREAD_RECURSIVE_MUTEX in order to build with SQLITE_THREADSAFE=1 on unix. If you do not have recursive mutexes, then you have to build with SQLITE_THREADSAFE=0. ---- _2007-Aug-25 15:22:39 by anonymous:_ {linebreak} The latest check-in uses the double-checked lock mis-pattern mentioned in an earlier comment.
 +      if( !isInit ){ +        pthread_mutex_lock(&initMutex); +        if( !isInit ){ +          pthread_mutexattr_init(&recursiveAttr); +          pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE); +        } +        isInit = 1; +        pthread_mutex_unlock(&initMutex); +      } 
Although the liklihood of a problem occurring is rare, it is still present. Since SQLite does not create many recursive mutexes I don't think it is worth to try to optimize this case. The calls to pthread_mutexattr_init and pthread_mutexattr_settype are typically very fast. Please consider using this simpler code instead: case SQLITE_MUTEX_RECURSIVE: { p = sqlite3MallocZero( sizeof(*p) ); if( p ){ pthread_mutexattr_t recursiveAttr; pthread_mutexattr_init(&recursiveAttr); pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&p->mutex, &recursiveAttr); p->id = iType; } break; } ---- _2007-Aug-25 16:26:01 by anonymous:_ {linebreak} Forgot the pthread_mutexattr_destroy... case SQLITE_MUTEX_RECURSIVE: { p = sqlite3MallocZero( sizeof(*p) ); if( p ){ pthread_mutexattr_t recursiveAttr; pthread_mutexattr_init(&recursiveAttr); pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&p->mutex, &recursiveAttr); pthread_mutexattr_destroy(&recursiveAttr); p->id = iType; } break; } ---- _2007-Aug-25 16:34:59 by drh:_ {linebreak} You will notice that, unlike the examples cited previously, my double-lock was in fact correct. Nevertheless, your observation that recursive mutexes are rarely allocated (only at sqlite3_open()) and that the initialization and destruction of a pthread_mutexattr_t is relatively cheap are valid. And the code is simpler without the double-lock. So the double-lock has now been removed. ---- _2007-Aug-25 16:48:30 by anonymous:_ {linebreak} Well, I disagree about your double lock being correct. There is a window of failure on SMP machines on some hardware with certain optimizing compilers. http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html Nonetheless, the recursive mutex code as of the latest checkin is fine. The speed of millions of lock/unlock calls of native POSIX recursive mutexes more than makes up for the few cycles of initializing the attribute. Some older OSes will undoubtedly have trouble with _XOPEN_SOURCE, but this is easy enough for the odd port to fix. #f2dcdc 2587 build active 2007 Aug anonymous 2007 Aug 3 4 Build problem when using the SQLITE_OMIT_FLOATING_POINT define. 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. #c8c8c8 2586 code closed 2007 Aug anonymous 2007 Aug 3 3 INSERT of large number fails on Windows When using the windows version of the sqlite3.dll, trying to insert a number larger then what fits in a 64 bits int (so larger then: 9223372036854775807) will give a "Invalid floating point operation" exception. The following code will reproduce this: create table t(a float);{linebreak} insert into t values(2.49190E+26); The command-line tool does not have this problem however. The exception seems to be thrown at this line:{linebreak} pMem->u.i = pMem->r;{linebreak} in the "sqlite3VdbeIntegerAffinity" function in vdbemem.c{linebreak} At least, that is what Visual Studio 8 says. _2007-Aug-24 13:19:25 by anonymous:_ {linebreak} You've changed the floating point accuracy to single precision, probably because you're writing 3D software. Google for "controlfp". http://msdn2.microsoft.com/en-us/library/e9b52ceh(VS.80).aspx #c8c8c8 2584 new closed 2007 Aug anonymous 2007 Aug 1 2 On Windows function sqlite3WinSleep needs to dispatch messages When sqlite is busy, it spins in the loop, re-trying call every 100 ms. On Windows if the caller thread runs a message loop (for example a GUI application of COM call from an appartment), the message loop stops and the application hangs. As a workaround, sqlite function sqlite3WinSleep needs to call PeekMessage with subsequent calls TranslateMessage/DispatchMessage to continue message processing as following:{linebreak} /*{linebreak} ** Sleep for a little while. Return the amount of time slept.{linebreak} */{linebreak} int sqlite3WinSleep(int ms){linebreak} {{linebreak} //----------------------------------------------------------------{linebreak} //The fix starts{linebreak} MSG msg;{linebreak} while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){linebreak} {{linebreak} TranslateMessage(&msg);{linebreak} DispatchMessage (&msg);{linebreak} if (msg.message == WM_QUIT) //Note - need to handle WM_QUIT,posted by PostQuitMessage{linebreak} break;{linebreak} }{linebreak} //The fix ends{linebreak} //-----------------------------------------------------------------{linebreak} Sleep(ms);{linebreak} return ms;{linebreak} }{linebreak} _2007-Aug-23 16:08:43 by drh:_ {linebreak} Processing GUI events is not the business of a database engine. If you need to process GUI events while waiting on a lock, then use the sqlite3_busy_handler() API to register your own busy handler (perhaps using the code shown in the patch) instead of using the built-in sqlite3_busy_timeout(). ---- _2007-Aug-23 17:54:06 by anonymous:_ {linebreak} You should wrap in a thread your db calls if you wan't to process using GetMessage() calls #cfe8bd 2583 build fixed 2007 Aug anonymous 2007 Aug 2 2 3.4.2 fails to build on Solaris due to conflict for B_FALSE and B_TRUE While attempting to build SQLite 3.4.2 on Solaris 10/x86 with gcc 3.4.3, I get this error: gcc -D_REENTRANT -g -O2 -o lemon ./tool/lemon.c ./tool/lemon.c:111: error: conflicting types for 'B_FALSE' /usr/local/lib/gcc/i386-pc-solaris2.10/3.4.3/include/sys/types.h:193: error: previous definition of 'B_FALSE' was here ./tool/lemon.c:111: error: conflicting types for 'B_TRUE' /usr/local/lib/gcc/i386-pc-solaris2.10/3.4.3/include/sys/types.h:193: error: previous definition of 'B_TRUE' was here Here is the conflicting line in /sqlite/tool/lemon.c 111 typedef enum {B_FALSE=0, B_TRUE} Boolean; And the conflict in the gcc version of =sys/types.h=: 190 #if defined(__XOPEN_OR_POSIX) 191 typedef enum { _B_FALSE, _B_TRUE } boolean_t; 192 #else 193 typedef enum { B_FALSE, B_TRUE } boolean_t; 194 #endif /* defined(__XOPEN_OR_POSIX) */ Oddly enough, 3.4.1 built successfully despite having the same code in lemon.c. Possibly some header files have changed and are causing __XOPEN_OR_POSIX no longer to be defined. Workaround: rename B_FALSE to BOOL_FALSE and B_TRUE to BOOL_TRUE throughout lemon.c. #f2dcdc 2582 doc active 2007 Aug anonymous 2007 Aug anonymous 5 5 documenation clarification 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. #c8c8c8 2581 code closed 2007 Aug anonymous 2007 Aug 1 1 ./configure && make broken: new source files: mem[12].c, mutex.c, etc Please apply the diff given by this command to Makefile.in: cvs diff -D'2007-08-14' main.mk _2007-Aug-21 20:31:44 by drh:_ {linebreak} We are in the middle of a major reimplementation of large sections of SQLite. We could fix the makefile, but the build still wouldn't work. So what's the point, really. I promise to fix the makefile before the next release.... #f2dcdc 2580 code active 2007 Aug anonymous 2007 Aug anonymous 1 2 Can't open a query if text to search is Greek 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. #c8c8c8 2578 code closed 2007 Aug anonymous 2007 Aug 1 1 sqlite3BtreeEnter, sqlite3BtreeLeave threading issues p->wantToLock++ is not an atomic operation and must be done within a mutex lock, otherwise its result is undefined. Same goes for "variable--". You need an architecture-specific operations to do that safely between threads. See http://www.mozilla.org/projects/nspr/reference/html/pratom.html and http://lxr.mozilla.org/nspr/source/nsprpub/pr/include/pratom.h#60 for an example.
 void sqlite3BtreeEnter(Btree *p){   Btree *pLater;    /* Some basic sanity checking on the Btree.  The list of Btrees   ** connected by pNext and pPrev should be in sorted order by   ** Btree.pBt value. All elements of the list should belong to   ** the same connection. Only shared Btrees are on the list. */   assert( p->pNext==0 || p->pNext->pBt>p->pBt );   assert( p->pPrev==0 || p->pPrev->pBtpBt );   assert( p->pNext==0 || p->pNext->pSqlite==p->pSqlite );   assert( p->pPrev==0 || p->pPrev->pSqlite==p->pSqlite );   assert( p->sharable || (p->pNext==0 && p->pPrev==0) );    /* Check for locking consistency */   assert( !p->locked || p->wantToLock>0 );   assert( p->sharable || p->wantToLock==0 );    if( !p->sharable ) return;   p->wantToLock++;   if( p->locked ) return;    /* In most cases, we should be able to acquire the lock we   ** want without having to go throught the ascending lock   ** procedure that follows.  Just be sure not to block.   */   if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){     p->locked = 1;     return;   } 
This needs fixing:
 Index: src/btree.c =================================================================== RCS file: /sqlite/sqlite/src/btree.c,v retrieving revision 1.401 diff -u -3 -p -r1.401 btree.c --- src/btree.c 17 Aug 2007 16:50:38 -0000      1.401 +++ src/btree.c 17 Aug 2007 20:42:49 -0000 @@ -1403,8 +1403,8 @@ void sqlite3BtreeEnter(Btree *p){      assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );      assert( !pLater->locked || pLater->wantToLock>0 );      if( pLater->locked ){ -      sqlite3_mutex_leave(pLater->pBt->mutex);        pLater->locked = 0; +      sqlite3_mutex_leave(pLater->pBt->mutex);      }    }    sqlite3_mutex_enter(p->pBt->mutex); @@ -1427,8 +1427,8 @@ void sqlite3BtreeLeave(Btree *p){      p->wantToLock--;      if( p->wantToLock==0 ){        assert( p->locked ); -      sqlite3_mutex_leave(p->pBt->mutex);        p->locked = 0; +      sqlite3_mutex_leave(p->pBt->mutex);      }    }  } 
Otherwise there would be corruption if there was a context switch just after sqlite3_mutex_leave to "if( p->locked ) return;" in sqlite3BtreeEnter() in another thread. You might want to replace the u8's below with int's if you intend to read or write to them outside of a mutex:
 struct Btree {   sqlite3 *pSqlite;  /* The database connection holding this btree */   BtShared *pBt;     /* Sharable content of this btree */   u8 inTrans;        /* TRANS_NONE, TRANS_READ or TRANS_WRITE */   u8 sharable;       /* True if we can share pBt with other pSqlite */   u8 locked;         /* True if pSqlite currently has pBt locked */   int wantToLock;    /* Number of nested calls to sqlite3BtreeEnter() */   Btree *pNext;      /* List of Btrees with the same pSqlite value */   Btree *pPrev;      /* Back pointer of the same list */ }; 
Reading from and writing to a non-machine word (i.e., not an int) variable outside of a mutex is not atomic or threadsafe. MIPS, for example, can only manipulate 32 bit values at a time and must use bit operations and shifting to get at individual characters. If you read a char value at the wrong time it may contain 0, 255 or some other value. _2007-Aug-17 21:32:11 by anonymous:_ {linebreak} These 3 values will likely be stored in the same 32 bit integer: u8 inTrans; /* TRANS_NONE, TRANS_READ or TRANS_WRITE */ u8 sharable; /* True if we can share pBt with other pSqlite */ u8 locked; /* True if pSqlite currently has pBt locked */ Writing to any one of them outside of a mutex in a multithreaded situation can scramble the others' values. ---- _2007-Aug-20 00:49:28 by drh:_ {linebreak} Not a bug. The Btree.wantToLock values are accessed under the sqlite3.pMutex lock - or at least they will be once we get the new threading implementation half way completed. ---- _2007-Aug-20 05:17:47 by anonymous:_ {linebreak} Helgrind is useful to find these sorts of multi-thread race conditions, as well as mutex deadlocks. http://valgrind.org/docs/manual/hg-manual.html #c8c8c8 2577 code closed 2007 Aug anonymous 2007 Aug 5 5 Initilizing pointers to 0 instead of NULL. Is it better to change all initilizations an comparisions of pointers to NULL instead of 0 ? It is only cosmetic change but the code is then more readable. Bartosz _2007-Aug-17 18:15:16 by anonymous:_ Why the ticket was rejected ? If we have eg.: .... *pId = 0; .. what is *pId ? Integer value or pointer to pointer ? I know that name suggest that it is one level pointer but why we can not make reading easier ? Bartosz. ---- _2007-Aug-17 19:48:01 by anonymous:_ {linebreak} Changing 0 to NULL adds no value to the code. 0 is one character. NULL is four characters. Both are valid, but 0 is consistent and predictable on all platforms. NULL requires an #include to work, 0 does not. #c8c8c8 2576 code closed 2007 Aug anonymous 2007 Aug 1 1 Check-in [4239] mutex race conditions Nevermind. I missed seeing SQLITE_MUTEX_STATIC_MASTER. #c8c8c8 2575 code closed 2007 Aug anonymous 2007 Aug 1 1 sqlite3_mutex_enter missing return I know this is experimental #if'd out code, but nonetheless, sqlite3_mutex_enter is missing a return for the final else clause. #cfe8bd 2574 build fixed 2007 Aug anonymous 2007 Aug anonymous 3 3 amalgamation 3.4.2 compile errors The new amalgamation 3.4.2 fails with the following compile errors using Visual C++ (2003 and 2005): sqlite3.c(6187) : error C2133: 'sqlite3UpperToLower' : unknown size sqlite3.c(9310) : error C2133: 'sqlite3OpcodeNames' : unknown size sqlite3.c(47159) : error C2133: 'sqlite3IsIdChar' : unknown size Cause: The 'extern' keyword was replaced by 'SQLITE_PRIVATE' I suspect this should have been the new macro 'SQLITE_EXTERN' Changing from SQLITE_PRIVATE to SQLITE_EXTERN results in a successfull build _2007-Aug-15 10:35:23 by drh:_ {linebreak} The problem is that there is a declaration of the constant: SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[]; Then later the constant is defined with its content: SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = {...}; How does VC++ expect you to declare a static constant with file scope before it is defined? GCC is quite happy with the construct above. ---- _2007-Aug-15 12:56:30 by anonymous:_ {linebreak} VC++ is only happy when you declare it as: SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[256]; It seems it has to know the size upfront. I've also tried various compiler switches, but no postive results. ---- _2007-Aug-15 13:29:05 by anonymous:_ {linebreak} C0x and C++0x seem to allow the construct of forward declaring an unknown sized array of static (file scope) types. I wonder if gcc in --pedantic mode might also complain about it. This compilation set of settings is what perl uses to help guarantee cross-platform portability: gcc -g -O -pedantic -Wall -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wno-long-long ---- _2007-Aug-15 13:29:41 by anonymous:_ {linebreak} Does VC++ allow the same forward declaration without const? SQLITE_PRIVATE unsigned char sqlite3UpperToLower[]; If not, putting the size in advance for the array forward declaration is acceptable. ---- _2007-Aug-15 13:36:57 by anonymous:_ {linebreak} SQLITE_PRIVATE unsigned char sqlite3UpperToLower[]; This produces the same error and also another one: error C2133: 'sqlite3UpperToLower' : unknown size error C2373: 'sqlite3UpperToLower' : redefinition; different type modifiers The second error was to be expected ---- _2007-Aug-15 13:42:36 by anonymous:_ {linebreak} A function could be created to simply return the pointer to the array in question. Seemingly inefficient, but any modern optimizing compiler in the last 5 years would inline this function call away if in the same translation unit, as in the amalgamation. ---- _2007-Aug-15 13:54:05 by anonymous:_ {linebreak} Just change the forward declaration to a pointer: SQLITE_PRIVATE const unsigned char *sqlite3UpperToLower; as well as the implementation: SQLITE_PRIVATE const unsigned char *sqlite3UpperToLower = { ... }; ---- _2007-Aug-15 14:08:11 by anonymous:_ {linebreak} Does VC++ like this? static char* arr; static char* arr; static char arr_impl[] = { 'f', 'o', 'o' }; static char *arr = arr_impl; ---- _2007-Aug-15 15:17:45 by anonymous:_ {linebreak} No, it does not. It gives redefinition warnings on the initializer. I think part of the problem is that 'static TYPE var;' is default initialized when it is seen, and SPACE IS ALLOCATED FOR IT in any compilation unit that sees it. It is not given external scope. What I think I see is that every part of the individual .c files were scanned for file-scope definitions, which were then placed into an internals.h file for inclusion across all things that needed it. What I think you'll see if you look at the .o files for each .c file compiled separately, is a definition for each of the static variables that you were trying to predeclare. I think they'll need extern scope if you want to gain access to them in separate compilation units. And I think it might be better to declare and use the opcodes list, the UpperToLower table, and the character map table as pointers rather than arrays. Or bite the bullet of using extern instead of static. If you want to avoid overrunning the length of the tables you could provide an accessor function when printing the vdbe opcodes which could do range checking. Similarly, you could use something that is C-compiler safe for doing compile-time assertions that the length of the character map and lower-case tables are exactly 256 entries long when initialized. static bool must_be_256_long[sizeof(table)==256]; ---- _2007-Aug-15 15:28:56 by anonymous:_ {linebreak} The compile assert is not portable. static int must_be_256_long[0]; gcc does not complain about this unless the -pedantic flag is used. ---- _2007-Aug-15 15:33:51 by anonymous:_ {linebreak} All the external variables in question should be moved to a seperate vars.h and vars.c file. The amalgamation would have this vars.c file added before all other sqlite3 .h/.c files, and the vars.h file need not be added to the amalgamation at all. vars.h would only be used for non-amalgamation builds. ---- _2007-Aug-15 15:34:14 by anonymous:_ {linebreak} Since it's explicitly defined later, why not just mark the forward declaration as "extern"? This involves removing the SQLITE_PRIVATE in front. VS2005 let it compile for me no problems. ---- _2007-Aug-15 18:05:49 by anonymous:_ {linebreak} gcc will not allow an extern forward declaration followed by a static declaration. For background of why things were done the way they are see Ticket #2554 "Many symbols not marked private/static or SQLITE_API in amalgamation" ---- _2007-Aug-16 13:57:34 by anonymous:_ {linebreak} It seems to me that there are only the three symbols in concern: *: the vdbe opcode-to-string table, which is used in one place and auto-generated into another. *Perhaps* the place that it is used within could #include the auto-generated file, and exclude the auto generated file from the remainder of the compilation. (by naming it with .h, if necessary.) *Alternatively*, it could be encapsulated in an accessor sub-function instead of directly referred to by its array-based name. *: the character map for converting ebcdic to lower-cased ascii, or the similar translation when converting ascii to lower-cased ascii. It's used by one function when converting from a TOKEN to a token ID. It could also be just IN the file marked as SQLITE_PRIVATE and not forward declared at all. *: the upper to lower converter is used in a few places :) . No easy/quick solution for that that doesn't involve a possible decrease in performance based on non-inlined function calls in non-amalgamation compiled libraries. #cfe8bd 2573 doc fixed 2007 Aug anonymous 2007 Aug 3 3 sqlite3_interrupt() + threads sqlite3_interrupt() documentation says that "It is safe to call this routine from a thread different from the thread that is currently running the database operation". It is not true. 1st problem: db may be freed in sqlite3_close() during call to sqlite3_interrupt() - this may cause a crash. 2nd problem: after (db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_BUSY) and before db->u1.isInterrupted = 1; a lot of things can happen. Possibly another statement may be executed - this will interrupt a different statement than was expected. #c8c8c8 2572 warn closed 2007 Aug anonymous 2007 Aug 1 1 Sqlitw error unrecognize token Sqlite error unrecognize token The "is human" test needs to be improved. ---- _2007-Aug-14 21:20:44 by anonymous:_ {linebreak} wa? #c8c8c8 2571 todo closed 2007 Aug anonymous 2007 Aug 1 1 SQLite opening in Access I am trying to open SQLite database through ODBC connections in Microsoft Access 2000. Some tables in Database have Primary key defined . Steps followed:- System DSN TestSQLite is created using Data sources(ODBC) 1)Open Blank access database named db1.mdb 2)Click on FIle->Get External data->Link tables 3)Select - ODBC databases in Files of type in Link Dialog 4)Select Machine data source TestSQLite=20 5)Select All Tables and click Ok 6)If table does not have Primary key ,getting dialog to select unique record identifier. 7)if Primary key is defined in table ,getting error Reserved error (-7748) There is no msg for this error . =20 I can open tables which does not have Primary Key and cannot use MSAccess to open SQLite database through ODBC (if the SQLite database has primary key defined) . Thanks for your help. _2007-Aug-13 21:23:54 by anonymous:_ {linebreak} Install this sqlite odbc driver. http://www.ch-werner.de/sqliteodbc/ #cfe8bd 2570 code fixed 2007 Aug anonymous 2007 Aug 3 3 unportable assumptions in sqlite3AtoF() / cast.test The sqlite3 selftests 3.14, 3.18 and 3.24 fail for me with Expected: [9223372036854774784] Got: [9223372036854773760] Looking at the binary representations one finds that one bit of accuracy is missing (expected 53 bits, got 52 bits). The reason is within sqlite3AtoF(): It uses "long double" internally, and the (simplistic) algorithm does only deliver the expected result if "long double" uses a longer mantissa than "double". This might work on Linux/i386, but on other platforms a "long double" is identical to "double". #c8c8c8 2569 code closed 2007 Aug anonymous 2007 Aug 3 2 Executing a statement causes an AccessViolation Exception Executing follwowing statement causes an AccessViolation Exception:
 select being.bid, bname, bvalue, bsyncstatus, bvalid from being where being.bid in ( select bid from searchidx_Campaign where (   campaign_status_id = 2 or campaign_status_id = 3 ) and id in (select campaign_id from searchidx_CampaignUserStatus             where user_id = 'b37dd383-3c82-4fe1-9285-d4c2bd6e4ca3'               and locked = 0)) 
I tracked the problem down to the 'campaign_status_id = 2 or campaign_status_id = 3' part of the statement. if an 'and' instead of the 'or' is used the Exception doesn't occur ('campaign_status_id = 2 AND campaign_status_id = 3'). It also doesn't matter if there is data in any of the used tables. The exception raises also with empty tables. Used configuration: Windows XP Professional SP2 -> all MS updates installed .NET Framework 2.0 (2.0.50727.832) using c# _2007-Aug-13 10:17:56 by anonymous:_ {linebreak} It would be easier to reproduce if you provided the schema for the tables you use. ---- _2007-Aug-13 14:59:11 by drh:_ {linebreak} I created a schema that allowed the SQL statement to compile and then ran the SQL on version 3.3.4 without any problems. Unable to reproduce. #f2dcdc 2568 new active 2007 Aug anonymous 2007 Aug 3 3 TEMP_STORE is ignored in some cases 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:_ {linebreak} 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:_ {linebreak} Okay, thank you. #f2dcdc 2567 build active 2007 Aug anonymous 2007 Aug 3 2 Build fails to install 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:_ {linebreak} Do you have a patch? #f2dcdc 2566 build active 2007 Aug anonymous 2007 Aug 2 1 fts2 broken after vacuum 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.- #cfe8bd 2565 code fixed 2007 Aug drh 2007 Aug 1 1 Database corruption following ROLLBACK when soft_heap_limit set With {link: /pragma.html#pragma_auto_vacuum autovacuum mode} turned on low {link: /capi3ref.html#sqlite3_soft_heap_limit sqlite3_soft_heap_limit} database corruption results following a {link: /lang_transaction.html ROLLBACK} of a CREATE TABLE. The following script exhibits the problem: -- set sqlite3_soft_heap_limit to 5000 PRAGMA auto_vacuum=1; CREATE TABLE t1(x); INSERT INTO t1 VALUES(hex(randomblob(5000))); BEGIN; CREATE TABLE t2 AS SELECT * FROM t1; ROLLBACK; PRAGMA integrity_check; This problem was discovered following the enhanced sqlite_soft_heap_limit testing facility added by check-in [4202]. As of this writing, it has not been observed in the wild. _2007-Aug-11 11:55:04 by drh:_ {linebreak} **Background** The rollback journal file consists of a header followed by zero or more page records. Each page record contains original database content which can be used to restore the database back to its original state during a ROLLBACK or when the database is being recovered after a power-loss or crash. The header contains, among other things, the "nRec" field which is a count of the number of pages to follows. Whenever changes are flushed to the database file, the size of the journal is padded out to the next multiple of the disk sector size and a new header is written. (This is a defense against certain kinds of file corruption that might occur during a power failure.) A single journal can contain any number of instances of header followed by zero or more pages. While the journal is being constructed, the nRec value is 0. Then, just prior to writing changes back to the database file, the nRec value is changed to the correct number of records in the journal, the journal file is synced to disk, and only then is it safe to write to the database file. This all works great. **The Problem** The problem is that the ROLLBACK command also uses the journal file to restore changes. But the ROLLBACK command treats the nRec==0 value specially. When the ROLLBACK command sees an nRec of 0, it figures that it was just in the middle of doing some changes that haven't yet by written to the database file, so it tries to recompute the "correct" nRec value based on the current file size. The problem arises when a header contains an nRec value which really is suppose to be zero (no pages written into the journal) but that header is followed by one or more additional headers that contain pages that do need to be rolled back. When a journal is being rolled back during recovery, the recovery process sees the zero nRec, skips to the next header, and every thing works peachy. But during the ROLLBACK command, the zero nRec is converted into some positive value based on the journal file size. The new positive nRec is wrong. The ROLLBACK quickly discovers this and ignores the rest of the journal file under the assumption that it corrupted. This results in an incomplete ROLLBACK and database file corruption. **The Fix** The fix in check-in [4208] is to change the ROLLBACK process so that it only applies the special interpretation to an nRec==0 header if it is the very last header in the journal. **Why We Have Not Seen This Before** The problem only comes up when a header is written into the journal with nRec==0 and subsequent headers are written afterwards. This can only happen when the pager is having great difficulty finding new buffers into which new pages can be loaded and is having to spill dirty pages back to the disk. The minimum cache size is 10, and as it turns out a cache size of 10 still gives a handful of buffered pages before a cache spill occurs, even under the most severe circumstances. So even with a very small cache, the nRec field was always ending up larger than 0. But, if you set the soft heap limit to a ridiculously small number - so small that the pager is under continuous pressure to spill pages back to the database file as soon as they are unpinned - then there are cases where the pager will write non-terminal headers to the journal with nRec==0. Hence, as far as we are aware, you cannot hit this problem as long as you leave the soft heap limit disabled (which is the default configuration) or you set the soft heap limit large enough so that there are always enough memory for the pager to hold 10 or more pages in memory at the same time. It is difficult to imagine a real-world system that would do something different, so even though this problem has serious consequences, we cannot see how it might actually come up in practice. The problem was only noticed when we started stress-testing the soft heap limit mechanism by setting very low soft heap limits and running full regression tests. #c8c8c8 2564 event closed 2007 Aug anonymous 2007 Aug anonymous 4 4 in C:\windows\temp are 50 files like sqlite_fMyj88gwaTTNgUF and 0 kb in C:\windows\temp are 50 files like sqlite_fMyj88gwaTTNgUF and 0 kb every day are more files , which program use these files i cannot delete them with windows, clean up service i deleted them in safe mode they keep coming back and adding more files i use windows xp home edition and mcafee told me, it was not mcafee but a windows program thank you for your time jessica _2007-Aug-10 12:18:32 by anonymous:_ {linebreak} http://www.sqlite.org/cvstrac/wiki?p=McafeeProblem #c8c8c8 2563 code closed 2007 Aug anonymous 2007 Aug 1 1 sqlite3_column_database_name16() is broken =sqlite3_column_database_name16()= does not work at all. However I form my query, regardless of how many fields and in what order are returned in result, it always returns NULL for every single column. I'm using this code and it never returned anything but NULL: if ( pStatement) { UINT32 cols = sqlite3_column_count( pStatement); for ( UINT16 currCol = 0; !isDatabaseNameRetrieved && ( currCol < cols ); ++currCol ) { const WCHAR *databaseName = static_cast( sqlite3_column_database_name16( pStatement, currCol ) ); if ( databaseName && *databaseName ) { *dbName = databaseName; isDatabaseNameRetrieved = true; } } } When I stepped through the code I noticed that =MEM_Null= flag check in =sqlite3ValueText()= always fails (flag is always set): static const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){ if( !pVal ) return 0; assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) ); if( pVal->flags&MEM_Null ){ //<--- THIS CHECK IS ALWAYS TRUE return 0; } _2007-Aug-11 16:07:41 by drh:_ {linebreak} The 35 separate test cases in capi3.test and capi3c.test that call this routine all seem to function correction and return non-NULL results. Unable to reproduce. ---- _2007-Aug-14 20:54:58 by anonymous:_ {linebreak} Hmmm. It NEVER worked for me. If I have just main database opened it will return "main" but as soon as I attach another one it starts returning consistently returning NULL. I had the same problem with 3.3.17 and 3.4.0. #c8c8c8 2562 code closed 2007 Aug anonymous 2007 Aug 2 3 Multithreaded transactions deadlock (Windows) Two threads connected to the same database/table and use transactions:
 1. 1st thread: open db3-file 2. 2nd thread: open the same (second connection handle) 3. 1st thread: begin transaction 4. 1st thread: run multiple 'insert' statement 5. 2nd thread: begin transaction (successful return from call) 6. 2nd thread: want to 'insert' but blocked (as expected), start waiting on busy flag 7. 1st thread: last 'insert' was successfull 8. 1st thread: want to 'end' transaction, but blocked (sqlite3_step returns infinite SQLITE_BUSY, WHY?!) 9. 2nd thread: still blocked on first insert attempt 10. So, both threads can't continue execution. 
Workaround: remove 'begin' and 'end' SQL statements from the code - and this works OK, but too slow. _2007-Aug-10 04:13:37 by anonymous:_ {linebreak} You might try BEGIN EXCLUSIVE. You lose parallelism, but it won't deadlock, and the code is simpler. See also: http://www.sqlite.org/capi3ref.html#sqlite3_busy_handler "If SQLite determines that invoking the busy handler could result in a deadlock, it will return SQLITE_BUSY instead. Consider a scenario where one process is holding a read lock that it is trying to promote to a reserved lock and a second process is holding a reserved lock that it is trying to promote to an exclusive lock. The first process cannot proceed because it is blocked by the second and the second process cannot proceed because it is blocked by the first. If both processes invoke the busy handlers, neither will make any progress. Therefore, SQLite returns SQLITE_BUSY for the first process, hoping that this will induce the first process to release its read lock and allow the second process to proceed." ---- _2007-Aug-10 11:36:32 by anonymous:_ {linebreak} Yes, with 'begin exclusive' it works. #cfe8bd 2560 doc fixed 2007 Aug anonymous 2007 Aug 5 4 Documentation typos Normally, I don't log typos, but I draw the line when the product name (sqlite) is in error. I'm joking, right? No, it's true. If you look at the blob example at http://sqlite.org/lang_expr.html it shows: X'53514697465' However, that is an odd number of digits up there, considering that the part between the quotes is supposed to be hex. In fact, it seems to want to spell 'SQLite'. However, that L is having problems. Presumably, there should be a 'C' after the '4'. In http://www.sqlite.org/lang_insert.html the second occurence of 'not' should be 'no'. In http://www.sqlite.org/limits.html the first two occurrences of 'where' should be 'were'. Csaba Gabor from Vienna _2007-Aug-08 23:39:54 by anonymous:_ {linebreak} I reported blob literal issue a couple of months ago. See ticket #2168. I wonder if somebody is going to do something with it. #f2dcdc 2559 code active 2007 Aug anonymous 2007 Aug 4 4 "make clean" does not delete sqlite3.c and tsrc/
 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 
#f2dcdc 2558 code active 2007 Aug anonymous 2007 Aug 2 3 Multiple JOIN USING() gives incorrect results 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:_ {linebreak} 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 #c8c8c8 2557 build closed 2007 Aug anonymous 2007 Aug 3 3 make test errors on Rhel4 x86_64 Hello there, While building sqlite 3.4.1 rpms for Rhel4 on i386 and x86_64, I came across some inconsistent behaviour with "make test". On Rhel4.5 i386, "make test" works fine. However, on Rhel4.5 x86_64, "make test" has two errors which terminate the rpm build process. rpmbuild -bb --with tcl sqlite.spec 2>&1 | tee build.log{linebreak} .{linebreak} .{linebreak} printf-7.5... Ok{linebreak} printf-8.1...{linebreak} Error: integer value too large to represent{linebreak} printf-8.2...{linebreak} Error: integer value too large to represent{linebreak} printf-8.3... Ok{linebreak} .{linebreak} .{linebreak} Thread-specific data deallocated properly{linebreak} 2 errors out of 29903 tests{linebreak} Failures on these tests: printf-8.1 printf-8.2{linebreak} make: *** [test] Error 1{linebreak} error: Bad exit status from /var/tmp/rpm-tmp.97578 (%check){linebreak} My current workaround is to apply a patch which is only applied on x86_64 hardware. Again, thanks for your time and great software. _2007-Aug-07 17:17:39 by drh:_ {linebreak} Neither test is particularly important and both failures problem result from bugs in either TCL or somewhere else in RH, not in the SQLite core. If you want me to look into this, please consider publishing your patch. I have no way to reproduce the problem otherwise. #cfe8bd 2556 todo fixed 2007 Aug anonymous 2007 Aug 5 5 tabs instead of space in some source files There isn't a ticket priority low enough for this item. A few source files use tabs instead of spaces. btree.c expr.c os_unix.c pager.c sqliteInt.h tclsqlite.c test_md5.c trigger.c vdbeaux.c #f2dcdc 2555 new active 2007 Aug anonymous 2007 Aug 1 1 FTS index without original text 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 “xyz” (without one column in which I store ID of the record). After this operation FTS search works good, but unfortunately the table isn’t smaller (I cant’t use vacuum on FTS tables). Is there any other way to have pure text indexes without source level changes? #cfe8bd 2554 code fixed 2007 Aug anonymous 2007 Aug 3 3 Many symbols not marked private/static or SQLITE_API in amalgamation I compiled the amalgamation with SQLITE_API=static and then ran "nm -D" on the resulting output which shows undefined (imported symbols) as well as all symbols that are publicly exported. There are numerous sqlite3 symbols that didn't get marked as SQLITE_API or SQLITE_private. Note that my ultimate goal is for two different versions of SQLite to coexist in the same process. This is especially important on the Mac where many of Apple's own components cause the system SQLite library to be loaded, but is also happening on other operating systems where SQLite is used by system libraries. Here is a real world example of the problems: http://lists.initd.org/pipermail/pysqlite/2007-June/001074.html Here is the begining of the list of public symbols from nm -D: 0000000000017460 T sqlite3BinaryCompareCollSeq 000000000005be20 R sqlite3IsIdChar 000000000026b040 D sqlite3OpcodeNames 000000000005bd20 R sqlite3UpperToLower 000000000005bce0 R sqlite3UtfTrans1 000000000000f0b0 T sqlite3_aggregate_context 000000000000b650 T sqlite3_aggregate_count 000000000026bf60 D sqlite3_apis 000000000001d380 T sqlite3_auto_extension 0000000000016cb0 T sqlite3_bind_blob 0000000000016660 T sqlite3_bind_double 0000000000016650 T sqlite3_bind_int 00000000000165e0 T sqlite3_bind_int64 0000000000016590 T sqlite3_bind_null 000000000000b690 T sqlite3_bind_parameter_count 0000000000020b30 T sqlite3_bind_parameter_index 000000000000b700 T sqlite3_bind_parameter_name 0000000000016ca0 T sqlite3_bind_text 0000000000016c80 T sqlite3_bind_text16 0000000000016520 T sqlite3_bind_value 00000000000164b0 T sqlite3_bind_zeroblob 000000000000b7a0 T sqlite3_blob_bytes 000000000002b790 T sqlite3_blob_close 00000000000478f0 T sqlite3_blob_open 000000000002b870 T sqlite3_blob_read 000000000002b860 T sqlite3_blob_write 000000000000d940 T sqlite3_busy_handler 000000000000da30 T sqlite3_busy_timeout 00000000000165a0 T sqlite3_clear_bindings 000000000000db60 T sqlite3_collation_needed 000000000000dbc0 T sqlite3_collation_needed16 0000000000017a30 T sqlite3_column_blob 00000000000180a0 T sqlite3_column_bytes 0000000000017ad0 T sqlite3_column_bytes16 000000000000b660 T sqlite3_column_count 0000000000016d60 T sqlite3_column_decltype 0000000000016d40 T sqlite3_column_decltype16 _2007-Aug-06 12:06:09 by anonymous:_ {linebreak} Just curious, what do you hope to do with the public API symbols? e.g., sqlite3_column_count. Rename them? ---- _2007-Aug-06 15:59:19 by anonymous:_ {linebreak} The sqlite3.c file is #included into my file that does all the database interfacing. There is no other file in my application that needs access to any sqlite code or data. If all the sqlite3 api had SQLITE_API in front of them (which I define to static) then that would work, but as it stands only some of them have SQLITE_API. ---- _2007-Aug-06 16:09:09 by anonymous:_ {linebreak} You could also load your 2nd sqlite3 code via the dlopen option RTLD_LOCAL. There must be a MacOS equivalent. ---- _2007-Aug-06 18:54:12 by anonymous:_ {linebreak} I am trying to solve this properly for all platforms and in the long term. Remember that I have no control over other libraries in the same process and how they link (and in any case they can link to another library that links to another that finally loads SQLite). SQLite is most of the way there to being totally self contained. It just needs SQLITE_API in front of all api functions, not just some of them and private internal sqlite data should really be marked as such. ---- _2007-Aug-06 23:32:37 by anonymous:_ {linebreak} Apply the patch below to the latest CVS sources, and run "./configure && make clean && make sqlite3.c". This will handle most of the public sqlite3 symbols. This patch addresses a bug in mksqlite3c.tcl that prevented putting SQLITE_API prefixes before the sqlite3_* functions which had more than one underscore in their name (such as sqlite3_aggregate_count), or had a '*' in an unexpected place in the return type (sqlite3BinaryCompareCollSeq). After the patch, these are the only public symbols in the library exposed: sqlite3IsIdChar sqlite3one sqlite3OpcodeNames sqlite3UpperToLower sqlite3_version sqlite3_io_trace sqlite3_mallocHasFailed sqlite3_os_trace sqlite3_temp_directory To prevent collision with another sqlite3 library, in your own C module start out your code as follows, changing 'foo' to a unique name: #define sqlite3IsIdChar foo_sqlite3IsIdChar #define sqlite3one foo_sqlite3one #define sqlite3OpcodeNames foo_sqlite3OpcodeNames #define sqlite3UpperToLower foo_sqlite3UpperToLower #define sqlite3_version foo_sqlite3_version #define sqlite3_io_trace foo_sqlite3_io_trace #define sqlite3_mallocHasFailed foo_sqlite3_mallocHasFailed #define sqlite3_os_trace foo_sqlite3_os_trace #define sqlite3_temp_directory foo_sqlite3_temp_directory #include "sqlite3.c" With this technique you can embed several different version of the sqlite3 library in the same program, assuming you compile your module with: -DSQLITE_API=static -DSQLITE_PRIVATE=static The sqlite3 sources could be reorganized to make these last few sqlite3 symbols private as well, but it would be a pain as these variables are used across several .c files. Patch below ran "make test" without error on Linux. Joe Wilson
 Index: src/loadext.c =================================================================== RCS file: /sqlite/sqlite/src/loadext.c,v retrieving revision 1.23 diff -u -3 -p -r1.23 loadext.c --- src/loadext.c       20 Jul 2007 10:33:59 -0000      1.23 +++ src/loadext.c       6 Aug 2007 23:10:38 -0000 @@ -109,7 +109,7 @@  ** also check to make sure that the pointer to the function is  ** not NULL before calling it.  */ -const sqlite3_api_routines sqlite3_apis = { +static const sqlite3_api_routines sqlite3_apis = {    sqlite3_aggregate_context,    sqlite3_aggregate_count,    sqlite3_bind_blob, Index: src/utf.c =================================================================== RCS file: /sqlite/sqlite/src/utf.c,v retrieving revision 1.52 diff -u -3 -p -r1.52 utf.c --- src/utf.c   23 Jul 2007 19:12:42 -0000      1.52 +++ src/utf.c   6 Aug 2007 23:10:39 -0000 @@ -49,7 +49,7 @@ const int sqlite3one = 1;  ** This lookup table is used to help decode the first byte of  ** a multi-byte UTF8 character.  */ -const unsigned char sqlite3UtfTrans1[] = { +static const unsigned char sqlite3UtfTrans1[] = {    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, Index: tool/mksqlite3c.tcl =================================================================== RCS file: /sqlite/sqlite/tool/mksqlite3c.tcl,v retrieving revision 1.14 diff -u -3 -p -r1.14 mksqlite3c.tcl --- tool/mksqlite3c.tcl 26 Jun 2007 00:52:40 -0000      1.14 +++ tool/mksqlite3c.tcl 6 Aug 2007 23:10:39 -0000 @@ -129,10 +129,12 @@ proc copy_file {filename} {    set tail [file tail $filename]    section_comment "Begin file $tail"    set in [open $filename r] +  set declpattern \ +    {([a-zA-Z][_a-zA-Z0-9* ]+)+(sqlite3[_A-Z][_a-zA-Z0-9]+)\(}    if {[file extension $filename]==".h"} { -    set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \*?(sqlite3[_A-Z][a-zA-Z0-9]+)\(} +    set declpattern "^ *$declpattern"    } else { -    set declpattern {^[a-zA-Z][a-zA-Z_0-9 ]+ \*?(sqlite3[_A-Z][a-zA-Z0-9]+)\(} +    set declpattern "^$declpattern"    }    while {![eof $in]} {      set line [gets $in] @@ -154,7 +156,7 @@ proc copy_file {filename} {        puts $out "#if 0"      } elseif {[regexp {^#line} $line]} {        # Skip #line directives. -    } elseif {$addstatic && [regexp $declpattern $line all funcname] +    } elseif {$addstatic && [regexp $declpattern $line all rtype funcname]                    && ![regexp {^static} $line]} {        # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.        # so that linkage can be modified at compile-time. 
---- _2007-Aug-07 20:51:20 by anonymous:_ {linebreak} The following symbols remain public after Check-in [4197]. missed SQLITE_PRIVATE symbols:
 00003900 R sqlite3_apis 00000008 B sqlite3_io_trace 00000000 B sqlite3_mallocHasFailed 00000004 B sqlite3_os_trace 0000000c B sqlite3_temp_directory 00007c1b R sqlite3_version 
missed SQLITE_API symbols:
 0001d6fb T sqlite3_aggregate_context 0001d8ed T sqlite3_aggregate_count 0003c3e3 T sqlite3_auto_extension 0001ded0 T sqlite3_bind_blob 0001df07 T sqlite3_bind_double ...etc... 96 more... 
This patch addresses the SQLITE_API lines above:
 Index: tool/mksqlite3c.tcl =================================================================== RCS file: /sqlite/sqlite/tool/mksqlite3c.tcl,v retrieving revision 1.15 diff -u -3 -p -r1.15 mksqlite3c.tcl --- tool/mksqlite3c.tcl 7 Aug 2007 17:05:00 -0000       1.15 +++ tool/mksqlite3c.tcl 7 Aug 2007 20:06:34 -0000 @@ -130,10 +130,11 @@ proc copy_file {filename} {    section_comment "Begin file $tail"    set in [open $filename r]    set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+ \*?(sqlite3[a-zA-Z0-9]+)([[;]| =)} +  set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \*?(sqlite3[_A-Z][_a-zA-Z0-9]+)\(}    if {[file extension $filename]==".h"} { -    set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \*?(sqlite3[_A-Z][a-zA-Z0-9]+)\(} +    set declpattern "^ *$declpattern"    } else { -    set declpattern {^[a-zA-Z][a-zA-Z_0-9 ]+ \*?(sqlite3[_A-Z][a-zA-Z0-9]+)\(} +    set declpattern "^$declpattern"    }    while {![eof $in]} {      set line [gets $in] 
---- _2007-Aug-08 00:44:19 by drh:_ {linebreak} Symbols sqlite3_apis, sqlite3_temp_directory, and sqlite3_version are part of the published API and cannot be made private without breaking things. ---- _2007-Aug-08 01:05:24 by drh:_ {linebreak} Turns out sqlite3_io_trace is used externally too. I have checked in fixes for the rest. ---- _2007-Aug-08 01:41:14 by anonymous:_ {linebreak} If the test of the success of these qualifiers is to link different versions of the sqlite3 library into the same binary, then every function and variable must be marked as static, SQLITE_API or SQLITE_PRIVATE (or some other designation like SQLITE_API_VARIABLE, if you like). No function or variable can be without such a qualifier, i.e., public. If sqlite3_apis, sqlite3_temp_directory, and sqlite3_version are part of the published API then they should be marked as SQLITE_API, even though they are not functions. sqlite3_io_trace could be marked as either SQLITE_API or SQLITE_PRIVATE. I don't know which one is more appropriate. void (*sqlite3_io_trace)(const char*, ...) = 0; On Linux, with an updated CVS tree after Check-in [4199] we see that we have 4 public symbols remaining: make distclean ./configure make sqlite3.c gcc -DSQLITE_API=static -DSQLITE_PRIVATE=static -c sqlite3.c nm sqlite3.o | grep -v ' [trUbd] ' 00003900 R sqlite3_apis 00000000 B sqlite3_io_trace 00000004 B sqlite3_temp_directory 00007c1b R sqlite3_version ---- _2007-Aug-08 12:12:06 by drh:_ {linebreak} You now must also do -DSQLITE_EXTERN=static. #c8c8c8 2553 code closed 2007 Aug anonymous 2007 Aug 3 3 AUTOINCREMENT not working when primary key has multiple columns There is one thing which I really miss in SQLite from mySQL, and that is that AUTOINCREMENT-ing does not work when the primary key has multiple columns. AUTO_INCREMENT-ing should work when the last column of the PRIMARY KEY is of type INTEGER. It should work as described in the second example here: http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html In essence, the final column of the primary key gets a value of 1 greater than the largest value in that column where all the other values of the primary key's columns match those of the newly entered row. Why is the useful? As an example, consider that bug reports are being made. The reports are updated. It would make sense for each update to be incrementally numbered within the particular bug that it belongs to. Thanks for considering this, Csaba Gabor from Vienna _2007-Aug-05 17:38:39 by drh:_ {linebreak} AUTOINCREMENT in SQLite works as it is documented to work in SQLite. SQLite is not MySQL. #c8c8c8 2552 code closed 2007 Aug anonymous 2007 Aug 1 3 sqlite3_column_double causes invalid floating point operation We have a table that has values inserted by a Delphi database provider. Using one tool, we can see values in the column as: 0 NULL 0.0 When using a different tool, or our .NET provider, conversion errors are generated. The conversion errors occur on the row that is stored as 0.0. The call stack seems to indicate that sqlite3_column_double is having a problem dealing with the value stored as 0.0. Some of my report is based on third party information and I haven't personally confirmed all details. Let me know if you have further questions. _2007-Aug-03 16:37:35 by anonymous:_ {linebreak} It's likely a bug in the sqlite wrapper library you are using. Post a small standalone C program that only calls the sqlite3 API directly to demonstrate the issue and re-open this ticket. ---- _2007-Aug-03 20:19:20 by anonymous:_ {linebreak} When viewing the data in the sqlite command line utility, it comes across as NaN. It appears that the problem is somehow on the input side. What's not clear is if the NaN was created before being bound to the database or if the NaN value was assigned by the database. #c8c8c8 2551 code closed 2007 Aug anonymous 2007 Aug 3 3 sqlite3 shell gets into bad state with unexpected input The sqlite3 shell can get into a state that you cannot recover from without aborting the process. This happens fairly often on platforms without readline support. 1: build sqlite3 without readline support. 2: run sqlite3 in an xterm (or KDE konsole, probably other terminal programs) 3: at the prompt, press cursor up (probably other 'illegal' characters would suffice as well). 4: hit return Nothing you do at this point will work except for Ctrl-\ to kill the process.
 SQLite version 3.4.1 Enter ".help" for instructions sqlite> ^[[A    ...> .q    ...> ;    ...> select 1;    ...> .q    ...> .h    ...> ;    ...> ; 
_2007-Aug-03 15:00:30 by anonymous:_ {linebreak} Try CTRL+D, worked for me. ---- _2007-Aug-03 21:19:31 by drh:_ {linebreak} The "[A" is the beginning of a quoted identifier. The shell continues to issue the continuation prompt because it is waiting on the "]" to terminate the identifier. Your workaround is to type "];". Works as designed. #c8c8c8 2549 build closed 2007 Aug anonymous 2007 Aug 1 3 3.4.1 fails to upgrade from 3.3.1.7 on freeBSD I use DesktopBSD (freebsd), and I was running the regular software upgrade using the Package Manager. This is the result: ./.libs/libsqlite3.so: undefined reference to `sqlite3Fts2InitHashTable' gmake: *** [sqlite3] Error 1 *** Error code 2 Stop in /usr/ports/databases/sqlite3. *** Error code 1 Stop in /usr/ports/databases/sqlite3. ** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade.64421.1 env DIALOG=/usr/local/bin/kdialog-ports-wrapper UPGRADE_TOOL=portupgrade UPGRADE_PORT=sqlite3-3.3.17 UPGRADE_PORT_VER=3.3.17 make ** Fix the problem and try again. Regards, Arthur This is a bug for the FreeBSD ports maintainers. #f2dcdc 2547 code active 2007 Aug danielk1977 2007 Aug 5 3 Changing db encoding of an attached db can confuse shared cache mode. 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". #c8c8c8 2536 code closed 2007 Jul anonymous 2007 Aug 2 3 Possible non-ID index corruption when max_page_count exceeded Using 3.4.0 or 3.4.1 compiled for windows with -DMULTITHREAD, i seem to have a problem where sqlite3_step() will return SQLITE_ROW even when there are, in fact, no rows that meet the WHERE clause criteria. I'm currently attempting a reversion to 3.3.17 to see how it behaved. create table file_data ( rod blob not null primary key /* always 20 bytes long based on a collision-resistant hash function */ , file_size integer not null , compression_method integer not null , the_data blob not null ); sqlite3_prepare(..., "select file_size, compression_method from file_data where rod = ?"); sqlite3_reset(statement); sqlite3_bind_blob(...,0, ptr, len); sqlite3_step(...) sqlite3_step returned SQLITE_ROW, which was my indication that the result set would be non-empty. So I construct a query_result(statement, bool at_end=false), and then execute sqlite3_get_int64(..., first_column, null=-1) and I get back -1. Before I was passing in null=-1 I was passing in =0, which was a permissible value for file_size. ** keep in mind that my exact sqlite3_api calls might be slightly different, since I have a C++ framework that isolates me from having to continually remember the same API calls. Suffice it to say this code worked (so far as I knew) under 3.3.17. --andy On further research, it appears to be related to max_page_count being exceeded during insertion of a row, leaving behind a primary key reference in the (primary key) index on the BLOB instead of being cleaned up during rollback. _2007-Jul-25 17:38:38 by drh:_ {linebreak} Unable to reproduce. I am unable to make a lot of sense of the description above. I have tried various tests setting a low max_page_count and inserting BLOB-keyed entries into a table until the number of pages overflow, then run sqlite3_step to see what happens. Everything works correctly. I tried lots of different combinations but never could get a failure. ---- _2007-Jul-25 19:17:19 by anonymous:_ {linebreak} MULTITHREAD is the wrong macro, but sqlite compilation defaults to threadsafe anyway. How many threads are you running when this thing happens and what's your relationship of sqlite connections to threads? #cacae5 2499 build defer 2007 Jul anonymous 2007 Aug drh 1 1 undefined reference to `_WinMain@16' when attempting to build I get the error: /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain@16' _2007-Jul-11 18:16:28 by anonymous:_ ls Makefile.in config.sub main.mk sqlite.pc.in Makefile.linux-gcc configure mkdll.sh sqlite3.1 README configure.ac mkopcodec.awk sqlite3.pc.in VERSION contrib mkopcodeh.awk src aclocal.m4 doc mkso.sh tclinstaller.tcl addopcodes.awk ext notes test art install-sh publish.sh tool config.guess ltmain.sh spec.template www ./configure && make install checking build system type... i686-pc-cygwin checking host system type... i686-pc-cygwin checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ld used by gcc... /usr/i686-pc-cygwin/bin/ld.exe checking if the linker (/usr/i686-pc-cygwin/bin/ld.exe) is GNU ld... yes checking for /usr/i686-pc-cygwin/bin/ld.exe option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes checking how to recognise dependent libraries... file_magic ^x86 archive import|^x86 DLL checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking for g77... no checking for xlf... no checking for f77... no checking for frt... no checking for pgf77... no checking for cf77... no checking for fort77... no checking for fl32... no checking for af77... no checking for xlf90... no checking for f90... no checking for pgf90... no checking for pghpf... no checking for epcf90... no checking for gfortran... no checking for g95... no checking for xlf95... no checking for f95... no checking for fort... no checking for ifort... no checking for ifc... no checking for efc... no checking for pgf95... no checking for lf95... no checking for ftn... no checking whether we are using the GNU Fortran 77 compiler... no checking whether accepts -g... no checking the maximum length of command line arguments... 8192 checking command to parse /usr/bin/nm -B output from gcc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking for correct ltmain.sh version... yes checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking whether the gcc linker (/usr/i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes checking whether -lc should be explicitly linked in... yes checking dynamic linker characteristics... Win32 ld.exe checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes configure: creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... /usr/i686-pc-cygwin/bin/ld.exe checking if the linker (/usr/i686-pc-cygwin/bin/ld.exe) is GNU ld... yes checking whether the g++ linker (/usr/i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes checking for g++ option to produce PIC... checking if g++ static flag -static works... yes checking if g++ supports -c -o file.o... yes checking whether the g++ linker (/usr/i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes checking dynamic linker characteristics... Win32 ld.exe checking how to hardcode library paths into programs... immediate appending configuration tag "F77" to libtool checking for a BSD-compatible install... /usr/bin/install -c checking for gawk... gawk Version set to 3.4 Release set to 3.4.0 Version number set to 3004000 checking whether to support threadsafe operation... no checking whether to allow connections to be shared across threads... no checking whether threads can override each others locks... no checking whether to support shared library linked as release mode or not... no checking whether to use an in-ram database for temporary tables... no checking if executables have the .exe suffix... unknown checking host system type... (cached) i686-pc-cygwin checking for Tcl configuration... found /usr/lib/tclConfig.sh checking for existence of /usr/lib/tclConfig.sh... loading checking for library containing tgetent... -ltermcap checking for readline in -lreadline... no checking readline.h usability... no checking readline.h presence... no checking for readline.h... no checking for /usr/include/readline.h... no checking for /usr/include/readline/readline.h... no checking for /usr/local/include/readline.h... no checking for /usr/local/include/readline/readline.h... no checking for /usr/local/readline/include/readline.h... no checking for /usr/local/readline/include/readline/readline.h... no checking for /usr/contrib/include/readline.h... no checking for /usr/contrib/include/readline/readline.h... no checking for /mingw/include/readline.h... no checking for /mingw/include/readline/readline.h... no checking for library containing fdatasync... none required checking for usleep... yes checking for fdatasync... yes configure: creating ./config.status config.status: creating Makefile config.status: creating sqlite3.pc gcc -g -O2 -o lemon.exe ./tool/lemon.c cp ./tool/lempar.c . cp ./src/parse.y . ./lemon.exe parse.y mv parse.h parse.h.temp awk -f ./addopcodes.awk parse.h.temp >parse.h cat parse.h ./src/vdbe.c | gawk -f ./mkopcodeh.awk >opcodes.h sort -n -b -k 3 opcodes.h | gawk -f ./mkopcodec.awk >opcodes.c gcc -g -O2 -o mkkeywordhash.exe ./tool/mkkeywordhash.c ./mkkeywordhash.exe >keywordhash.h sed -e s/--VERS--/3.4.0/ ./src/sqlite.h.in | \ sed -e s/--VERSION-NUMBER--/3004000/ >sqlite3.h rm -rf tsrc mkdir -p tsrc cp ./src/alter.c ./src/analyze.c ./src/attach.c ./src/auth.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/legacy.c ./src/loadext.c ./src/main.c ./src/malloc.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/limits.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 ---- _2007-Jul-11 18:17:17 by anonymous:_ {linebreak} when initially filing this bug, i was told to not paste large screen dumps. i was also promised that i would be able to add an attachment later. however, that option was not given, so I have attached a screen transcript. ---- _2007-Jul-11 18:18:33 by anonymous:_ {linebreak} my email is metaperl at gmail.com ---- _2007-Jul-11 18:38:53 by drh:_ {linebreak} The [Attach] link in the upper-left is what you use to add attachments. The sqlite3.c source file is a library, not a program. If you want to compile a command-line shell, add the "shell.c" source file: cc -o sqlite3 sqlite3.c shell.c ---- _2007-Jul-23 20:35:06 by anonymous:_ {linebreak} I believe this bug report should be reopened because this error comes when you try to configure and compile USING THE DEFAULTS. When you try to do a standard configure and make, it should either try to compile shell.c as is needed or not compile sqlite.c. It shouldn't put in a command that fails the compile by default. Sorry to bother you about this, but I don't see how this isn't a bug or at least a glitch. It's a problem in the configuration and makefile system. ---- _2007-Aug-15 03:26:05 by anonymous:_ {linebreak} Compile and link passed by following patch (at least for me). diff -ru sqlite-3.4.2/Makefile.in sqlite-3.4.2-new/Makefile.in --- sqlite-3.4.2/Makefile.in 2007-08-15 10:37:18.921875000 +0900 +++ sqlite-3.4.2-new/Makefile.in 2007-08-15 10:36:08.750000000 +0900 @@ -681,7 +681,7 @@ mkdir -p doc mv $(DOC) doc -install: sqlite3 libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install} +install: sqlite3$(TEXE) libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install} $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) $(INSTALL) -d $(DESTDIR)$(exec_prefix)/bin ---- _2007-Aug-22 12:33:17 by anonymous:_ {linebreak} Why is this bug closes and marked "not a bug"? sqlite fails on make install on Cygwin (as in untar/configure/make/make install), which is *clearly* a bug. The "fix" posted above does not work, make install fails instantly with tclsh ../sqlite-3.4.2-n/tclinstaller.tcl 3.4 can't read "env(DESTDIR)": no such variable while executing "set LIBDIR $env(DESTDIR)$env(TCLLIBDIR)" (file "../sqlite-3.4.2-n/tclinstaller.tcl" line 11) make: *** [tcl_install] Error 1 ---- _2007-Aug-22 12:53:45 by drh:_ {linebreak} I misread the problem. Cygwin is not a supported platform. So in that sense, this is *not* clearly a bug in SQLite. This is an imcompatibility with Cygwin. We will take the problem under advisement, but since Cygwin is not officially support and because we have many much more serious problems to work on, progress on this is likely to be slow. You can expedite a fix by posting a patch. #c8c8c8 2480 code closed 2007 Jun anonymous 2007 Aug 4 4 typo in faq.tcl --- a/www/faq.tcl +++ b/www/faq.tcl @@ -202,8 +202,8 @@ faq { threads. The sqlite3 pointer must only be used in the same thread in which it was created by sqlite3_open(). If you - break the rules and use an sqlite3 in more than one thread - under these circumstances, then you will likely corrupt some + break the rules and use an sqlite3 pointer in more than one + thread under these circumstances, then you will likely corrupt some internal data structures resulting in a crash.

Under UNIX, you should not carry an open SQLite database across #cfe8bd 2168 doc fixed 2007 Jan anonymous 2007 Aug 4 1 Invalid documentation example - BLOB literal X'53514697465' On expression syntax page there is an invalid BLOB literal example:{linebreak}X'53514697465' sqlite> SELECT X'53514697465';
SQL error: unrecognized token: "X'53514697465'"
{linebreak}I suppose it's because of odd length of the literal. Such an example could be confusing for other users. Maybe you should remark that BLOB literals must have even length. #c8c8c8 1677 new closed 2006 Feb anonymous 2007 Aug 4 3 No way to know if library was compiled with threadsafety There is no way to know if library was compiled with threadsafety enabled. Here is a patch I made that adds both a compile-time define and a function that can be called runtime to check. http://0x63.nu/patches/sqlite-threadsafe-check.patch (I hereby give up all claim of copyright for the patch and put it in the public domain) See Check-in [4350] #f2dcdc 1242 code active 2005 May anonymous Shell 2007 Aug 3 4 EXPLAIN causes segmentation fault on OSX (and linux) 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:_ {linebreak} Try to upgrade to 3.4.2. #f2dcdc 2865 code active 2007 Dec anonymous 2007 Dec 1 2 FTS3 does not build with amalgamation in CVS 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:_ {linebreak} 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:_ {linebreak} It seems that the sqlite3+fts3 amalg can only be built from main.mk, not Makefile. #f2dcdc 2864 doc active 2007 Dec anonymous 2007 Dec 5 3 ext/fts3/README.txt 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:_ {linebreak} 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. #f2dcdc 2863 code active 2007 Dec anonymous 2007 Dec 2 3 test cast-3.14, cast-3.18 and cast-3.24 fail 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 #f2dcdc 2860 todo active 2007 Dec anonymous 2007 Dec 3 1 Database file fragmentation 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). #f2dcdc 2859 code active 2007 Dec anonymous 2007 Dec drh 3 2 Inconsistent column names with DISTINCT Given the following SQL:{linebreak} CREATE TABLE foo(a,b); INSERT INTO foo (a, b) VALUES (1,2); SQLite returns inconsistent column names when using the DISTINCT clause:{linebreak} 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:{linebreak} 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 #f2dcdc 2857 code active 2007 Dec anonymous 2007 Dec 2 2 GROUP BY cost estimate wrong with WHERE clause 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 2856 doc active 2007 Dec anonymous 2007 Dec anonymous 4 3 SQLite Documentation - Tcl API - Link broken On the page "The Tcl Interface to the SQLite library", the link "enable load extension" does not work. #c8c8c8 2855 code closed 2007 Dec anonymous 2007 Dec drh 2 3 Get an error "11:database disk image is malformed" during queries I don't know what has happened to my database and when. I followed every new sqlite version as soon as it got released. So now I am with version 3.5.4 (WinXP) and my database has grown up to a size of about 1.74 GB. It contains only three tables and neither views nor triggers. When I run a query on all records of one table I got the a.m. error message and no results. I was able to query all details by RowID up to and above a small range of only 105 records (out of 345767 ). No problem below and none above. Then I renamed the table, created another table and "insert into .. select from .." one into the other in two steps. ("where RowID between .. and .. or RowID between .. and .." popped up the error message again but running two queries one after the other worked fine. That's my workaround. It is a pitty that I cannot send you an example but I do not know how to shrink the database to only remain with the route cause of trouble. I dropped the other two tables and deleted all records before and after the malformed part but now I cannot vacuum without getting again that message. 1: How may I got this malformed records into my database? How to avoid repetition? 2: How can I eliminate a malformed part out of the database without having to recreate almost everything from scrap? As soon as the malformed records are touched every command stops. Isn't there a possibility to put such records into *quarantine* ?! This would really help to isolate problems and would hopefully give me a chance to send you the damaged records for your analysis to find out what may have happened. The isolation of records may be related to "check integrity" of the database. Another good idea may be to give sqlite.exe a chance to extract isolated part under quaratine from one into another database. - I keep my damaged database for such a case for a while, expecting such a command with the next release. _2007-Dec-21 12:52:51 by drh:_ {linebreak} Information on how to corrupt an SQLite database file can be found at *: http://www.sqlite.org/cvstrac/wiki?p=DatabaseCorruption *: http://www.sqlite.org/atomiccommit.html *: http://www.sqlite.org/lockingv3.html (Section 6.0) To restore data as much as you can from a corrupt database file, do this: sqlite3 corrupt.db .dump | sqlite3 restored.db This ticket reads more like a support request than a bug report. Or perhaps it is a feature request - requesting that corruption be "quarantined". Quarantining bad records merely masks errors and gives no new capabilities so that is not something we are interested in doing. For technical support see *: http://www.sqlite.org/support.html ---- _2007-Dec-21 13:06:46 by anonymous:_ {linebreak} Thank you for your quick response and hints about more info on causes for db corruptions. However, ="sqlite3.exe corrupt.db .dump | sqlite3 restored.db"= did not work because of the malformed records, which interrupted the process after a while of work. - For me it would be enough if ="delete from tbl where RowID between nn and mm"= would work without failing because of using the malformed space. This would be good for healing a db file if the problem could be isolated like in my case. Sorry, if dealing with such problems isn't the right place here. (By the way: the first 5 fields of that table are forming the primary index; there are no other indexes on that table.) I wish you a merry christmas and a happy and successfull new year. ---- _2007-Dec-21 13:08:59 by drh:_ {linebreak} The ".dump" command attempts to work around corruption. If you have some kind of corruption that it is unable to work-around, then append an example database to this ticket and we will reopen the ticket and work on the problem. Without having access to a database that demonstrates the problem, I am afraid there is not much we can do. ---- _2007-Dec-21 14:03:59 by anonymous:_ {linebreak} Well. Didn't know about =.dump= is working around corruption and tried to do this with my database where I eliminated good content around the malformed records. Your recommendation worked without raising the aborting error message. It will not solve the appearance but is a great help to heal the database for continued work. Thank you for this additional information! #c8c8c8 2854 code closed 2007 Dec danielk1977 2007 Dec danielk1977 1 1 BEGIN EXCLUSIVE does not prevent other shared-cache users from reading Subject says it all. Executing a "BEGIN EXCLUSIVE" does not prevent other shared cache users from reading the database. _2007-Dec-20 17:53:32 by danielk1977:_ {linebreak} The attached test file demonstrates the problem. ---- _2007-Dec-20 19:28:29 by anonymous:_ {linebreak} Could this cause unexpected deadlocks? #cfe8bd 2852 code fixed 2007 Dec anonymous 2007 Dec 4 4 sqlite library is sometimes 40K bigger when built on OpenBSD lhsStart not being initialized leads to non-deterministic behavior in parser code generation. The generated code code for parse.c will run correctly, but will be 40K larger if lhsStart is not set to zero after rule struct memory is malloc'ed. See #2835 for details and fix. #cfe8bd 2851 code fixed 2007 Dec anonymous 2007 Dec 1 1 make test double free or corruption error Fresh CVS checkout, ./configure && make && make test
 capi3-13-4... Ok capi3-13-5...*** glibc detected *** capi3-14.1-misuse... Ok capi3-15.1... Error: error code SQLITE_TOOBIG (18) does not match sqlite3_errcode SQLITE_OK (0) capi3-15.2... Expected: [2]      Got: [0] capi3-15.3... Expected: [SQLITE_OK]      Got: [SQLITE_MISUSE] capi3-15.4... Error: (21) library routine called out of sequence capi3-15.5... Error: (21) library routine called out of sequence capi3-15.6... Error: (21) library routine called out of sequence capi3-15.7... Error: (21) library routine called out of sequence capi3-15.8... Error: (21) library routine called out of sequence capi3-16.1... Error: (21) library routine called out of sequence capi3-16.2... Error: (21) library routine called out of sequence capi3-16.3... Error: (21) library routine called out of sequence capi3-16.4... Error: (21) library routine called out of sequence capi3-17.1... Error: (21) library routine called out of sequence capi3-17.2... Ok capi3-17.3...*** glibc detected *** ./testfixture: double free or corruption (!prev): 0x0812d650 *** 
#cfe8bd 2850 code fixed 2007 Dec anonymous 2007 Dec 2 2 CSV output missing quotes if contains equals character Here's yet another bug in the CSV output using the sqlite3 command line tool. Here's a sample of the new bug: .mode csv select 'a=1,234', 'b=5'; gives: a=1,234,b=5 but should give: "a=1,234",b=5 I'm using sqlite 3.4.0 on Mac OS X 10.5.1. CSV (comma separated values) output should show value1,value2,value3 etc. If a value contains a comma, then csv should encapsulate that value in quotes: "value,1",value2,value3. And if a value contains a quote, csv should also encapsulate that value in quotes and show the quote as a double quote, eg "value,1","value ""2""",value3 Sqlite3 seems to ignore the need for quotes in a value that contains an equals "=". I don't know if it also fails with other characters. Needless to say, this messes up the output considerably, placing output in the wrong column. #cfe8bd 2849 doc fixed 2007 Dec anonymous 2007 Dec 5 5 unary operator ! From documentation: "Supported unary prefix operators are these: - + ! ~ NOT" There is no ! operator in sqlite #c8c8c8 2848 code closed 2007 Dec anonymous 2007 Dec 4 4 windows CRLF is incorrectly handled by .dump If I insert a string containing standard windows CRLF (0x0D, 0x0A) into the table, and then try to .dump the table, instead of original CRLF, I get a 'CRCRLF' (0x0D, 0x0D, 0x0A). It is probably not helpful to mention that the column does not use any special collation and that the database is in UTF-8 mode. I am on windows xp, and use original build of sqlite3.exe 3.5.4. I am sorry if this problem already has its own ticket, or if I missed some configuration in sqlite3/dump, but I could not find any such. _2007-Dec-17 14:06:58 by anonymous:_ {linebreak} I can't reproduce this on MS Windows Vista with SQLite v3.5.4. Snippet from .dump output:
 sqlite3 test.db3 .dump | od  --address-radix=x --format=x1a  000060 0d 0a 49 4e 53 45 52 54 20 49 4e 54 4f 20 22 74         cr  nl   I   N   S   E   R   T  sp   I   N   T   O  sp   "   t 000070 65 73 74 31 22 20 56 41 4c 55 45 53 28 31 2c 27          e   s   t   1   "  sp   V   A   L   U   E   S   (   1   ,   ' 000080 61 6c 0d 0a 70 68 61 27 29 3b 0d 0a 43 4f 4d 4d          a   l  cr  nl   p   h   a   '   )   ;  cr  nl   C   O   M   M 000090 49 54 3b 0d 0a          I   T   ;  cr  nl 
Perhaps the extra control character was accidently loaded into the database? ---- _2007-Dec-17 15:18:53 by drh:_ {linebreak} Unable to reproduce on WinXP. ---- _2007-Dec-17 22:12:27 by anonymous:_ {linebreak} Thanks for fast response. The extra 0x0D was surely not in the database. I reviewed my situation over and it looks like a windows shell (cmd.exe) is adding the extra 0x0D as I was redirecting stdout from dump like this: cmd /c sqlite3 test.db3 .dump > test.txt Sorry to blame you. #cfe8bd 2846 build fixed 2007 Dec anonymous 2007 Dec 1 1 --disable-tcl does not work 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/mem4.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 make: tclsh: Command not found make: *** [sqlite3.c] Error 127 _2007-Dec-17 00:45:26 by anonymous:_ {linebreak} Seems the same problem as #2845 #cfe8bd 2845 code fixed 2007 Dec rse 2007 Dec 3 3 SQLite 3.5.4 requires TCL during built-time SQLite 3.5.4 requires TCL during build-time as the generated sqlite3.c is not part of the distribution tarball. This is IMHO a major drawback as SQLite on the one hand is a small light-weight RDBMS without any external dependencies (so even can be used for bootstrapping other tools) and on the other hand SQLite's TCL dependency now requires one to build the TCL interpreter. I strongly recommend to either rewrite the mksqlite3c.tcl in /bin/sh, AWK or C or at least distribute a pre-generated version of sqlite3.c in the distribution tarball with SQLite 3.5.5 and higher. The newly introduced extra dependency to TCL is at least a nasty issue for packagers... _2007-Dec-15 21:10:10 by anonymous:_ {linebreak} There's a "testcli" target added (see Ticket #2838), although I prefer the original way sqlite was built prior to Check-in [4609] for the reasons described in the that ticket. #f2dcdc 2844 build active 2007 Dec anonymous 2007 Dec 4 1 lemon is being built without respecting LDFLAGS 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:_ {linebreak} Why is this important? What LDFLAGS settings might a user want to carry through into lemon? ---- _2007-Dec-17 18:00:59 by anonymous:_ {linebreak} > 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} > 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.) #cfe8bd 2843 code fixed 2007 Dec anonymous 2007 Dec 3 4 Low memory crash in sqlite3ExprCodeAndCache The function sqlite3ExprCodeAndCache() in expr.c includes the four lines: addr1 = sqlite3VdbeCurrentAddr(v); sqlite3ExprCode(pParse, pExpr); addr2 = sqlite3VdbeCurrentAddr(v); if( addr2>addr1+1 || sqlite3VdbeGetOp(v, addr1)->opcode==OP_Function ){ sqlite3VdbeGetOp() can return a NULL pointer (if there have been allocation failures AND (0 <= addr1 < v->nOp) does not hold). This can occur if there are memory allocation failures which prevent sqlite3ExprCode() from adding any vdbe operations (so addr2 is the same as addr1 which is equal to v->nOp). The solution is probably to include a test for allocation failures in the if condition, ie: addr1 = sqlite3VdbeCurrentAddr(v); sqlite3ExprCode(pParse, pExpr); addr2 = sqlite3VdbeCurrentAddr(v); if( !v->db->mallocFailed && (addr2>addr1+1 || sqlite3VdbeGetOp(v, addr1)->opcode==OP_Function ) ){ #f2dcdc 2842 code active 2007 Dec anonymous 2007 Dec 1 1 .import does not recongnise NULL values .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:_ {linebreak} .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. #f2dcdc 2841 todo active 2007 Dec anonymous 2007 Dec 1 1 The sqlite mailing list has become overrun by trolls 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? #cfe8bd 2840 doc fixed 2007 Dec anonymous 2007 Dec 5 4 Punctuation errors in comment The comment relating to the declaration of function sqlite3_reset in the sqlite/src/sqlite.h header has two punctuation errors: ** The sqlite3_reset() function is called to reset a ** [sqlite3_stmt | compiled SQL statement] object. ** back to it's initial state, ready to be re-executed. Should be: ** The sqlite3_reset() function is called to reset a ** [sqlite3_stmt | compiled SQL statement] object ** back to its initial state, ready to be re-executed. If in doubt, see http://www.bristol.ac.uk/arts/skills/grammar/grammar_tutorial/page_13.htm _2007-Dec-13 21:14:37 by drh:_ {linebreak} I observe that "it's" is used where "its" is correct in many comments. But Christopher, if you post one more ticket about this I promise I will ban you from this website forever. One ticket is enough! ---- _2007-Dec-13 21:16:24 by anonymous:_ {linebreak} lol - sorry. #cacae5 2839 new defer 2007 Dec anonymous 2007 Dec 4 4 Deleting row from sqlite_stat1 will not take effect until next connect I noticed if sqlite_stat1 is purged or altered, the query plans remain the same until you disconnect and reconnect to the database. Is this by design? _2007-Dec-13 17:54:02 by drh:_ {linebreak} If you manually mess around with the sqlite3_stat1 table, I don't think it is too much to ask that you restart the connection to make those changes go into effect. To add code for this specialized corner case seems unwarranted. #cfe8bd 2838 code fixed 2007 Dec anonymous 2007 Dec 3 3 Request: use traditional way to build CLI This is a request to revert the recent Check-in [4609] (but keep the large sql max len value) to use the traditional .o files and library. It's more difficult to debug changes when compile errors and gdb line numbers are from the amalgamation sqlite3.c, not the original .c source files. Incremental compile times take longer with the amalgamation as well. Using the amalgamation can also mask missing #include files from .c files which cause compile errors when compiling in the "traditional" .c->.o manner. Such missing header files in certain .c source files may work in the amalgamation due to some other pre-pended .c file that just happened to have included the header file. Also, on some platforms the C compiler cannot compile the sqlite3.c amalgamation with -g (debug) because it is too big. _2007-Dec-13 07:57:04 by anonymous:_ {linebreak} As a compromise, perhaps a new make target "make release" might build an optimized sqlite3 CLI with the sqlite3.c amalgamation, while the default "make" builds via the traditional .c->.o means. ---- Added the "testcli" target for this purpose. #c8c8c8 2837 code closed 2007 Dec anonymous 2007 Dec 2 2 can't build testfixture in latest CVS ./configure && make clean && make testfixture
  gcc -g -O2 -I. -I./src -DNDEBUG -I/usr/include/tcl8.4.13 -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -c ./src/alter.c -o alter.o ./src/alter.c: In function ‘renameTableFunc’: ./src/alter.c:77: error: ‘TK_SPACE’ undeclared (first use in this function) ./src/alter.c:77: error: (Each undeclared identifier is reported only once ./src/alter.c:77: error: for each function it appears in.) ./src/alter.c: In function ‘renameTriggerFunc’: ./src/alter.c:135: error: ‘TK_SPACE’ undeclared (first use in this function) make: *** [alter.lo] Error 1 
_2007-Dec-13 13:22:42 by drh:_ {linebreak} Works for me. Try running configure in a directory separate from the source tree: ../sqlite/configure; make testfixture ---- _2007-Dec-13 16:16:04 by anonymous:_ {linebreak} When I "cvs up -A; cvs diff" the sources show no changes at all. So I tried the following: make clean make distclean ./configure --disable-shared make test But I get the same errors. So I run the old tree and the new tree's alter.c through gcc -E and here's the difference:
 --- ../../sqlite/alter.old      2007-12-13 11:04:15.000000000 -0500 +++ alter.new   2007-12-13 11:04:25.000000000 -0500 @@ -599,7 +599,7 @@  HashElem *sqlite3HashFindElem(const Hash*, const void *pKey, int nKey);  void sqlite3HashClear(Hash*);  # 154 "./src/sqliteInt.h" 2 -# 1 "./src/parse.h" 1 +# 1 "./parse.h" 1  # 155 "./src/sqliteInt.h" 2  # 1 "/usr/include/stdio.h" 1 3 4  # 28 "/usr/include/stdio.h" 3 4 @@ -3532,7 +3532,7 @@        do {          zCsr += len;          len = sqlite3GetToken(zCsr, &token); -      } while( token==TK_SPACE ); +      } while( token==145 );        ((void) (0));      } while( token!=19 && token!=115 );  @@ -3582,7 +3582,7 @@        do {          zCsr += len;          len = sqlite3GetToken(zCsr, &token); -      }while( token==TK_SPACE ); +      }while( token==145 );        ((void) (0));  # 147 "./src/alter.c"        dist++; 
So somehow an old parse.h got copied to to src/ which was the cause of the problem. If I remove src/parse.h as is well and "make test" now builds. Documented in this ticket in case someone else happens to have the same problem in the future. ---- _2007-Dec-13 16:18:16 by anonymous:_ {linebreak} I must have been testing lemon on src/parse.y some time in the past to cause this problem. #c8c8c8 2836 build closed 2007 Dec anonymous 2007 Dec 1 1 Undefined symbol 'OP_StackDepth' There is a error on current cvs version(12/12/07) with "Undefined symbol 'OP_StackDepth'" message. opcodes.h and opcodes.c havn't 'OP_StackDepth' definition currently. Sorry for my short English. _2007-Dec-13 07:41:07 by danielk1977:_ {linebreak} opcodes.c and opcodes.h are auto-generated files (generated based on vdbe.c). Likely your copies have not been regenerated since yesterdays modifications. Try running "make clean" before rebuilding. If that fails, manually remove opcodes.c and opcodes.h from your build directory. #cfe8bd 2835 code fixed 2007 Dec anonymous 2007 Dec 1 1 Lemon memory read/write errors
 $ cat lemonbug.y phrase ::= foo AND A B C foo. phrase ::= foo AND A B C bar. foo ::= BIRD | CAT | DOG. bar ::= CAT | DOG.  $ ./lemon lemonbug.y 1 parsing conflicts.  $ head -23 lemonbug.out State 0:           phrase ::= * foo AND A B C foo           phrase ::= * foo AND A B C bar           foo ::= * BIRD| CAT| DOG                            BIRD shift  2                                shift  2                         phrase accept                            foo shift  5  State 1:           phrase ::= foo AND A B C * foo           phrase ::= foo AND A B C * bar           foo ::= * BIRD| CAT| DOG           bar ::= * CAT| DOG                            BIRD shift  2                                shift  2                                reduce 134589256 ** Parsing conflict **                            CAT shift  4                            foo shift  9                            bar shift  10  valgrind output:  ==11245== Invalid read of size 1 ==11245==    at 0x8049109: SetAdd (lemon.c:4080) ==11245==    by 0x804B083: FindFirstSets (lemon.c:649) ==11245==    by 0x8051919: main (lemon.c:1464) ==11245==  Address 0x416980F is 0 bytes after a block of size 7 alloc'd ==11245==    at 0x401F396: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so) ==11245==    by 0x804AEF3: SetNew (lemon.c:4057) ==11245==    by 0x804AF7D: FindFirstSets (lemon.c:617) ==11245==    by 0x8051919: main (lemon.c:1464) ==11245== ==11245== Invalid write of size 1 ==11245==    at 0x804910C: SetAdd (lemon.c:4081) ==11245==    by 0x804B083: FindFirstSets (lemon.c:649) ==11245==    by 0x8051919: main (lemon.c:1464) ==11245==  Address 0x416980F is 0 bytes after a block of size 7 alloc'd ==11245==    at 0x401F396: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so) ==11245==    by 0x804AEF3: SetNew (lemon.c:4057) ==11245==    by 0x804AF7D: FindFirstSets (lemon.c:617) ==11245==    by 0x8051919: main (lemon.c:1464) ==11245== ==11245== Invalid read of size 4 ==11245==    at 0x8048BF4: actioncmp (lemon.c:365) ==11245==    by 0x8048DBC: merge (lemon.c:1577) ==11245==    by 0x8048E6D: msort (lemon.c:1623) ==11245==    by 0x80512C1: FindActions (lemon.c:966) ==11245==    by 0x805194E: main (lemon.c:1479) ==11245==  Address 0x416B298 is 4 bytes after a block of size 36 alloc'd ==11245==    at 0x401F396: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so) ==11245==    by 0x804ABF2: State_new (lemon.c:4503) ==11245==    by 0x8051015: getstate (lemon.c:759) ==11245==    by 0x805113A: buildshifts (lemon.c:829) ==11245==    by 0x805104E: getstate (lemon.c:766) ==11245==    by 0x805113A: buildshifts (lemon.c:829) ==11245==    by 0x805104E: getstate (lemon.c:766) ==11245==    by 0x805113A: buildshifts (lemon.c:829) ==11245==    by 0x805104E: getstate (lemon.c:766) ==11245==    by 0x805113A: buildshifts (lemon.c:829) ==11245==    by 0x805104E: getstate (lemon.c:766) ==11245==    by 0x805113A: buildshifts (lemon.c:829) ==11245== 
_2007-Dec-12 18:00:29 by anonymous:_ {linebreak} Another grammar with parsing conflicts, different valgrind error:
   article ::= blocks FIN.   blocks ::= block.   blocks ::= blocks block.   block ::= NEWLINE.   block ::= stanza.   block ::= heading.   block ::= stanza heading.   heading ::= HEADING_START text HEADING_END.   stanza ::= text.   stanza ::= stanza NEWLINE text.   text ::= textpiece.   text ::= text textpiece.   textpiece ::= TEXT.   textpiece ::= LINK.  ==11727== Conditional jump or move depends on uninitialised value(s) ==11727==    at 0x804ADBB: CompressTables (lemon.c:3947) ==11727==    by 0x8051A2C: main (lemon.c:1482)  3925 void CompressTables(lemp) 3926 struct lemon *lemp; 3927 { 3928   struct state *stp; 3929   struct action *ap, *ap2; 3930   struct rule *rp, *rp2, *rbest; 3931   int nbest, n; 3932   int i; 3933   int usesWildcard; 3934 3935   for(i=0; instate; i++){ 3936     stp = lemp->sorted[i]; 3937     nbest = 0; 3938     rbest = 0; 3939     usesWildcard = 0; 3940 3941     for(ap=stp->ap; ap; ap=ap->next){ 3942       if( ap->type==SHIFT && ap->sp==lemp->wildcard ){ 3943         usesWildcard = 1; 3944       } 3945       if( ap->type!=REDUCE ) continue; 3946       rp = ap->x.rp; 3947       if( rp->lhsStart ) continue; 
---- _2007-Dec-12 18:14:11 by anonymous:_ {linebreak} "./lemon src/parse.y" also produces: ==12904== Conditional jump or move depends on uninitialised value(s) ==12904== at 0x80523AF: CompressTables (lemon.c:3947) ==12904== by 0x804B015: main (lemon.c:1482) ---- _2007-Dec-12 19:00:41 by anonymous:_ {linebreak} This appears to remedy the Conditional jump error for parse.y. The read/write errors in first grammar remains.
 --- tool/lemon.c        5 Oct 2007 16:16:36 -0000       1.51 +++ tool/lemon.c        12 Dec 2007 19:02:37 -0000 @@ -2100,6 +2100,7 @@ to follow the previous rule.");            psp->prevrule = 0;         }else{            int i; +          rp->lhsStart = 0;            rp->ruleline = psp->tokenlineno;            rp->rhs = (struct symbol**)&rp[1];            rp->rhsalias = (char**)&(rp->rhs[psp->nrhs]); 
---- _2007-Dec-13 23:44:45 by anonymous:_ {linebreak} I originally thought this reading the unitialized memory for rp->lhsStart lemon parser bug was completely inconsequential, but now I see if I apply the following patch and run lemon against parse.y it generates a completely different parse.c file. If the lemon is built with the following patch and your run parse.y against it, lemon will generate a parse.c that is 275868 bytes in size:
 diff -u -3 -p -r1.51 lemon.c --- tool/lemon.c        5 Oct 2007 16:16:36 -0000       1.51 +++ tool/lemon.c        13 Dec 2007 23:37:39 -0000 @@ -2100,6 +2100,7 @@ to follow the previous rule.");            psp->prevrule = 0;         }else{            int i; +          rp->lhsStart = 0xffff; // *** change to zero and rerun            rp->ruleline = psp->tokenlineno;            rp->rhs = (struct symbol**)&rp[1];            rp->rhsalias = (char**)&(rp->rhs[psp->nrhs]); 
While if the rp->lhsStart value is set to 0, it will produce a completely different parse.c file of 122960 bytes. #c8c8c8 2834 event closed 2007 Dec anonymous 2007 Dec 2 1 Is Version 3.1.3 not compatible with 3.5.3 ? I created this table "CREATE TABLE CALCULATION (sceneid INTEGER, calcid INTEGER, data BLOB, timestamp INTEGER, PRIMARY KEY (sceneid, calcid))" with the sqlite version 3.1.3. And now I have updated to version 3.5.3 and it is not possible to read the data from table CALCULATION. But if I create the table only with one primary key (Primary key (sceneid)), than it is possible to read the data. Is it a bug in version 3.5.3 oder in 3.1.3? How can I read the data with a double primary key? _2007-Dec-11 18:43:51 by drh:_ {linebreak} All versions of SQLite are compatible back through version 3.0.0. If you think otherwise, please provide details and we will investigate. I generate a database using your schema and SQLite version 3.1.3 and it works just fine with SQLite version 3.5.3. Unable to recreate the problem... #cfe8bd 2833 doc fixed 2007 Dec anonymous 2007 Dec 5 1 typo on SQLite home page As pointed out by silvestru@molddata.md on the mailing list the phrase "This the homepage for SQLite - ..." should be changed to "This is the homepage for SQLite - ...". We fixed this yesterday. And the homepage is going to be completely replaced tomorrow morning, at which point the issue will become moot. #cfe8bd 2832 code fixed 2007 Dec anonymous 2007 Dec 1 1 Data corruption with UPDATE or DELETE clause ... On any UPDATE or DELETE operation, if a side effect causes other rows in the same table to be deleted, a stack leak can occur. In rare circumstances, database corruption can result. Side effect deletes might be caused by an OR REPLACE clause or by triggers. This bug appears to be in all prior versions of SQLite 3. The original problem description follows: ----- My scenario is rather simple - I have products table, and details table. Producs have unique column called code. Then I have transform table to renumber my products table. I used update or replace constraint, and my data got corrupted. Here's example, I will try to rewrite column names into english, sorry if I make some typo here: sql "create table products (code text primary key, former_code text, typy text, name text, warehouse text)" sql "create table transform (code text, name text, new_code text, former_code text, type text)" no indices (there are in newer version of my code, but simpler the case the better) And now sql code, which corrupts my data (contains a bit of REBOL code):
 sql trim/lines {  update or replace products    set code = (select new_code from transform where transform.code=products.code),         type = (select type from transform where transform.code=products.code)  where exists   (select code from transform where transform.code=products.code) } 
So - I just wonder - I am not fluent in SQL, so I am not sure I should update primary key in products that way? I expect this code would either update codes found for transformation, or it would fail, because such code to translate to would be already present on table, so that would be caught by "or replace" constraint, and such item would be replaced. So - what you suggest now? Is that a bug? Or am I behaving really badly to my data? :-) Tried with 3.5.2, 3.5.3, Windows Vista 32bit .... PS: This text is from my original post to ml - tried to subscribe to ml two times, no luck receiving any message, so posting directly to bugbase. Sorry if the bug is already known ... _2007-Dec-11 14:34:41 by drh:_ {linebreak} What makes you think your data is being corrupted, as opposed to merely transformed in exactly the way you have requested? In other words, why do you think this is a bug in SQLite? ---- _2007-Dec-12 08:22:19 by anonymous:_ {linebreak} If you can see that instead of product code you get characters you even can't write on your keyboard probably, then I think data is being corrupted :-) Here's a screenshot: {link: http://www.xidys.com/pekr/sqlite-insert-or-update-data-corruption.jpg corrupted data?} Cheers, Petr ---- _2007-Dec-12 08:35:14 by danielk1977:_ {linebreak} Can you post a database file and the SQL statement that is causing the corruption? This is likely an encoding problem. Are you inserting UTF-8 text into the database? And handling the returned data as UTF-8? ---- _2007-Dec-12 08:56:10 by anonymous:_ {linebreak} OK, before I post some data, I will try to describe what I did: In products table I have product numbers starting with "9", which are going to be translated into other numbers: 9xxxx.xx ---> 1xxxx.xx 9xxxx.xxA --> 1xxxx.xxA 9xxxx.xxBZ--> 9xxxx.xx I import all data from Excel .csv files. Encoding should be OK imo, as data live in one file. However, I noticed "bug" in my logic. Simply put, to make my life easier, I imported 9xxxx.xxBZ codes into my transform table, thinking that when those codes are at the end of the table, those are OK. But - my update clause (posted in my first request), does not "join data" that safe way, so actually what happens is - if the clause reaches 9xxxx.xxBZ code, it updates it to 9xxxx.xx code, but this code is then once again translated to 1xxxx.xx later in the process. If I don't import 9xxxx.xxBZ codes to the end of the table, my data remain being OK. Where can I send my database? I don't want it being public. Thanks a lot ... Petr ---- _2007-Dec-12 10:25:21 by anonymous:_ {linebreak} OK, here is a reduced recordset without sensitive data. {link: http://www.xidys.com/pekr/inventura.zip corruption data example} Just open the database and apply query as stored in query.txt ---- _2007-Dec-12 11:11:11 by anonymous:_ {linebreak} I can confirm the database corruption as provided in the sample. Before running the SQL in query.txt, =pragma integrity_check= returns 'ok', afterwards it returns these errors: rowid 156 missing from index sqlite_autoindex_products_1 rowid 159 missing from index sqlite_autoindex_products_1 rowid 160 missing from index sqlite_autoindex_products_1 rowid 162 missing from index sqlite_autoindex_products_1 rowid 163 missing from index sqlite_autoindex_products_1 Tested with CVS [4603]. ---- _2007-Dec-12 15:41:33 by anonymous:_ {linebreak} Regarding the test case in Check-in [4614], it produces the same expected result for both 3.5.3 and the latest CVS. No sign of database corruption or valgrind error for 3.5.3 on Linux. Are you certain this isolates the problem? ---- _2007-Dec-12 15:56:02 by drh:_ {linebreak} tkt2832.test provokes the problem if you use the OP_StackDepth opcode from check-in [4612]. The change in [4612], together with additional enhancements that will go in as part of this fix, is designed to head off this kind of bug in the future by making the VDBE very unforgiving to the kinds of code generator errors that caused this problem. #f2dcdc 2831 new active 2007 Dec anonymous 2007 Dec 3 4 alter view 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:_ {linebreak} 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:_ {linebreak} [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. #c8c8c8 2830 code closed 2007 Dec anonymous 2007 Dec 5 5 tkt2822.test refers to tkt2820 ? typo? sqlite/test/tkt2822.test -> 1.1 do_test tkt2820-1.1 { do_test tkt2820-1.3 { do_test tkt2820-1.3 { Thanks. #cfe8bd 2829 code fixed 2007 Dec anonymous 2007 Dec 1 1 Win32: temp files left over in temp area Seems that temp tables generated on the fly for large group by or order by queries do not have their files removed on CloseHandle. This is because the CreateFile is not done with the right flag. Result is that a lot of files are left over in temp directory, even when queries are run properly. This patch seems to fix it (added: SQLITE_OPEN_DELETEONCLOSE): if( flags & (SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_TEMP_JOURNAL - | SQLITE_OPEN_SUBJOURNAL) ){ + | SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_DELETEONCLOSE) ){ _2007-Dec-10 19:54:25 by drh:_ {linebreak} Yikes! I just checked and I have 174260 SQLite temp files in my /var/tmp folder! And cleaning up such a mess is challenging. You cannot do "rm etilqs_*" because the argument list is too long. Even "ls etilqs_*" doesn't work. Here is what I'm doing: ls -U | grep etliqs_ | while read i; do rm $i; done That will have to run for 20 minutes or so to clear out all of the dead files. This problem is serious enough to warrant a new release once we get it fixed. ---- _2007-Dec-10 20:06:32 by anonymous:_ {linebreak} I don't see these temp file on UNIX - which OS is affected by this bug and under what circumstance? ---- _2007-Dec-10 20:50:20 by drh:_ {linebreak} Hmmm. I finally got my /var/tmp folder cleaned up. But now when I rerun the regression suite, no new temp files appear. Perhaps those 174260 temp files came from some older bug that has now been fixed. ---- _2007-Dec-10 21:24:27 by anonymous:_ {linebreak} Did you by chance catch a glimpse of the date of the most recent undeleted tmp files on UNIX? ---- _2007-Dec-11 03:31:38 by drh:_ {linebreak} Sadly, I did not observe the mtimes on any of the files in /var/tmp. Recall that ls was not working very well for me (probably due to the large number of files). I was having to use the -U open (to prevent sorting) in order to get ls to work at all. And I did not have the presence of mind to add a -l to that. Oh well.... ---- _2007-Dec-11 05:26:45 by anonymous:_ {linebreak} find is your friend: find /var/tmp -type f -iname "etliqs_*" -print0 | xargs -r0 rm (yes, you can simplify this a whole lot if you make some assumptions but why bother be unsafe?) #c8c8c8 2828 code closed 2007 Dec anonymous 2007 Dec 1 2 SQLITE_OMIT_SUBQUERY compile error: sqlite3CodeSubselect() missing. The new sqlite3FindInIndex() calls sqlite3CodeSubselect(), but this is kept out if SQLITE_OMIT_SUBQUERY is defined. As it stands now, SQLite does not compiled with SQLITE_OMIT_SUBQUERY defined. #cfe8bd 2827 code fixed 2007 Dec anonymous 2007 Dec 1 1 make test: vacuum2.test did not close all files: 1 Latest unmodified CVS source tree. Run "make test" to see the error.
 vacuum2-1.1... Ok vacuum2-2.1... Ok vacuum2-2.1... Ok vacuum2-3.1... Ok vacuum2-3.2... Ok vacuum2-3.3... Ok vacuum2-3.4... Ok vacuum2-3.5... Ok vacuum2-3.6... Ok vacuum2-3.7... Ok vacuum2-3.13... Ok vacuum2-3.14... Ok vacuum2-3.15... Ok vacuum2-3.16... Ok vacuum2-3.17... Ok vacuum2.test did not close all files: 1  ...  1 errors out of 38209 tests Failures on these tests: vacuum2.test All memory allocations freed - no leaks Maximum memory usage: 14164890 bytes make: *** [test] Error 1 
Note: this does *not* happen if you only run vacuum2.test directory:
 $ ./testfixture test/vacuum2.test vacuum2-1.1... Ok vacuum2-2.1... Ok vacuum2-2.1... Ok vacuum2-3.1... Ok vacuum2-3.2... Ok vacuum2-3.3... Ok vacuum2-3.4... Ok vacuum2-3.5... Ok vacuum2-3.6... Ok vacuum2-3.7... Ok vacuum2-3.13... Ok vacuum2-3.14... Ok vacuum2-3.15... Ok vacuum2-3.16... Ok vacuum2-3.17... Ok 0 errors out of 16 tests All memory allocations freed - no leaks Maximum memory usage: 85541 bytes 
#cfe8bd 2826 build fixed 2007 Dec anonymous 2007 Dec 4 4 test_thread.c won't build if !SQLITE_THREADSAFE || !TCL_THREADS Trying a quick build of the test sources I discovered that test_thread.c won't build the null-test, since it requires tcl.h for a Tcl typedef for the function signature but only includes tcl.h if it thinks it's doing something useful. The following patch fixes the problem:
 diff -cr unpack-orig/sqlite-3.5.3/src/test_thread.c sqlite-3.5.3/src/test_thread.c *** unpack-orig/sqlite-3.5.3/src/test_thread.c Mon Sep 10 11:53:02 2007 --- sqlite-3.5.3/src/test_thread.c Thu Dec  6 14:26:16 2007 *************** *** 18,27 ****   */    #include "sqliteInt.h"    #if SQLITE_THREADSAFE && defined(TCL_THREADS)  - #include    #include    #include   --- 18,27 ----   */    #include "sqliteInt.h" + #include     #if SQLITE_THREADSAFE && defined(TCL_THREADS)    #include    #include  
#f2dcdc 2825 code active 2007 Dec anonymous 2007 Dec 3 3 FormatMessage (win32) should use extra flag and convert from Unicode 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 } 
#c8c8c8 2824 code closed 2007 Dec anonymous 2007 Dec 1 1 enable shared cache problem System info: -Celeron M. -Windows Xp. -Single process. -No thread. Code: int WINAPI WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR lpCMD, int nSCMD) { sqlite3* db; sqlite3_stmt * stm; sqlite3_enable_shared_cache(1); sqlite3_open("db", &db); sqlite3_prepare_v2(db, "ATTACH DATABASE db2 AS d", 24, &stm, 0); sqlite3_step(stm); } The problem: the sqlite3_step(stm) execute for an infinite time. MA _2007-Dec-06 07:56:12 by danielk1977:_ {linebreak} I just tried the following program with the cvs version: #include "sqlite3.h" int main (int argc, char **argv){ sqlite3* db; sqlite3_stmt *stm; sqlite3_enable_shared_cache(1); sqlite3_open("db", &db); sqlite3_prepare_v2(db, "ATTACH DATABASE db2 AS d", 24, &stm, 0); sqlite3_step(stm); return 0; } And the sqlite3_step() did not block for any amount of time. Can you confirm that the code above produces the bug in your environment? Thanks. ---- _2007-Dec-07 13:59:02 by anonymous:_ {linebreak} I have ran more test but the problem is never arised. I think it was generated from code or configuration properties from my system, outside sqlite. MA #c8c8c8 2823 code closed 2007 Dec anonymous 2007 Dec 1 1 query not return values I have a database with this description:
 CREATE TABLE [coletores] (   [coletor] INTEGER NOT NULL ON CONFLICT ABORT PRIMARY KEY,   [senha] NVARCHAR2(20) NOT NULL ON CONFLICT ABORT); CREATE UNIQUE INDEX [SenhaUnica] ON [coletores] ([senha]); 
and contain this data:
 coletor   |   senha    1         43043553 
When i run the query: "select coletor, senha from coletores where senha = '43043553'" query not return values. Works when I try it. Perhaps you have some whitespace on one side of the '43043553' value in the database. Whitespace is significant to SQLite. #cfe8bd 2822 code fixed 2007 Dec anonymous 2007 Dec 3 3 ORDER BY term number 1 does not match any result column in select.c The original problem description is preserved below. This text is summary of what has changed. After this change the algorithm for matching ORDER BY terms is as follows: 1: If an ORDER BY term is a constant integer k then sort by the k-th column of the result set. 2: If an ORDER BY term is a simple identifer (like "x", not "x.y" and not "x.y.z") and if there if the k-th column uses that same identifer as an AS alias, the sort by the k-th column. 3: Otherwise, evaluate the expression which is in the ORDER BY term and sort by the resulting value. For a compound query, the expression in step (3) must exactly match one of the result columns. Also, the three steps are attempted first on the left-most SELECT. If there is a match, the process stops there. If no match is found, the next SELECT to the right is tried. This repeats as necessary until a match is found or until you run out of SELECT statement in which case there is an error. This algorithm differs from all prior versions of SQLite (1.0.0 through 3.5.3) by the addition of step (2). Adding step (2) brings SQLite much closer to the SQL standard. I believe that SQLite is now a superset of the SQL standard. In a compound query, SQL only looks at the left-most SELECT and does not fail over to SELECT statements to the right looking for a match. The difference in SQLite can be considered an extension. The revised algorithm is mostly compatible with the way SQLite has always operated before. But there are a few obscure corner cases where there is a difference. An example of the difference is the following: CREATE TABLE a(x,y); INSERT INTO a VALUES(1,8); INSERT INTO a VALUES(9,2); SELECT x AS y FROM a ORDER BY y; In older versions of SQLite, the SELECT statement above would return 9, 1 since the ORDER BY term evaluated to the expression a.y by rule (3) In the next release, because of the addition of rule (2) above, the result will be 1, 9. -------- *Original Problem Description* Starting from version 3.4.2 I receive errors with queries like: SELECT a.field FROM a UNION ALL SELECT b.field FROM b ORDER BY a.field; or even SELECT a.field FROM a UNION ALL SELECT a.field FROM a ORDER BY a.field; error is: ORDER BY term number 1 does not match any result column Tables are created by: CREATE TABLE a (field); CREATE TABLE b (field); Please note that the above queries worked fine with sqlite 3.2.x or 3.3.x. it's odd that this one doesn't work as well: create table t1(a); create table t2(b); select t1.a from t1 union all select t2.b from t2 order by a; SQL error: ORDER BY term number 1 does not match any result column _2007-Dec-04 04:35:48 by anonymous:_ {linebreak} Analysis from mailing list: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg29701.html It appears as though the /src/select.c (Line1499) changed from: if( iCol<0 && mustComplete ){ to: }else if( mustComplete ){ in version 1.336 of this file - http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/select.c&v1=1.335&v2=1.336 And this change results in this bug. ---- _2007-Dec-04 04:38:57 by anonymous:_ {linebreak} Related to Check-in [3842] : Match ORDER BY terms to columns using names in compound queries. Make sure this works for subqueries, especially in the right-hand side of an IN operator. Ticket #2296. ---- _2007-Dec-04 16:27:41 by anonymous:_ {linebreak} Other databases produce results for the following that differ from sqlite: create table x1(a INT, b INT, c INT); insert into x1 values(1, 2, 3); create table x2(a INT, b INT, c INT); insert into x2 values(9, 0, 4); SELECT x1.b, a FROM x1 UNION SELECT a, b FROM x2 ORDER BY b; SQLite version 3.5.3 sqlite> SELECT x1.b, a FROM x1 UNION SELECT a, b FROM x2 ORDER BY b; x1.b|a 9|0 2|1 versus: mysql> SELECT x1.b, a FROM x1 UNION SELECT a, b FROM x2 ORDER BY b; +------+------+ | b | a | +------+------+ | 2 | 1 | | 9 | 0 | +------+------+ Also, for this SQL: create table x1(a INT, b INT, c INT); insert into x1 values(1, 2, 3); create table g2(x INT, y INT, z INT); insert into g2 values(9, 0, 4); sqlite 3.5.3 produces: sqlite> SELECT x1.b, a FROM x1 UNION SELECT x, y FROM g2 ORDER BY y; x1.b|a 9|0 2|1 compared to an error on other databases that only use the first SELECT to determine ORDER BY/GROUP BY column names: mysql> SELECT x1.b, a FROM x1 UNION SELECT x, y FROM g2 ORDER BY y; ERROR 1054 (42S22): Unknown column 'y' in 'order clause' ---- _2007-Dec-05 05:14:38 by anonymous:_ {linebreak} Another related issue in 3.5.3+ CVS: CREATE TABLE foo(b); These are fine: SELECT 3 b union select b from foo order by b; 3 SELECT b from foo union SELECT 3 b order by b; 3 These have issues: SELECT b from foo union SELECT 3 b order by +b; SQL error: ORDER BY term number 1 does not match any result column SELECT 3 b union select b from foo order by +b; SQL error: ORDER BY term number 1 does not match any result column ---- _2007-Dec-05 05:34:23 by anonymous:_ {linebreak} A problem with expressions in an ORDER BY of a compound statement: CREATE TABLE t1(b); INSERT INTO t1 VALUES(-3); INSERT INTO t1 VALUES(2); -- works, of course select b from t1 order by b*b; 2 -3 -- expression does not work in compound SELECT select b from t1 union all select b from t1 order by b*b; SQL error: ORDER BY term number 1 does not match any result column -- an alias does not help select b as b from t1 union all select b from t1 order by b*b; SQL error: ORDER BY term number 1 does not match any result column select b as b from t1 union all select b as b from t1 order by b*b; SQL error: ORDER BY term number 1 does not match any result column ---- _2007-Dec-08 04:08:53 by anonymous:_ {linebreak} The column heading names in the result set of a compound query are not consistent with regular queries:
 SQLite version 3.5.3 Enter ".help" for instructions sqlite> create table foo(a); sqlite> insert into foo values(1); sqlite> .header on  sqlite> select foo.a from foo; a 1  sqlite> select foo.a from foo union all select foo.a from foo; a 1 1  sqlite> select foo.a from foo union all select foo.a from foo order by 1; foo.a    <===== 1 1  sqlite> select foo.a from foo union all select foo.a from foo group by 1; a 1 1 
---- _2007-Dec-08 17:43:29 by anonymous:_ {linebreak} Possible fix: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg29790.html http://marc.info/?l=sqlite-users&m=119708950929249&q=p3 ---- _2007-Dec-10 19:35:33 by anonymous:_ {linebreak} What should the following return? create table t1(a INT, b INT, c INT); insert into t1 values(1, 2, 4); insert into t1 values(2, -1000, 5); select a, a+b AS c from t1 order by c; sqlite 3.5.3: a|c 1|3 2|-998 mysql and postgres: a | c ---+------ 2 | -998 1 | 3 ---- _2007-Dec-13 08:13:24 by anonymous:_ {linebreak} It's unfortunate that the expression support in compound ORDER BY which existed briefly in CVS for a couple of days was removed: sqlite/test/tkt2822.test 1.2 -> 1.3 - SELECT a+1, b+1 FROM t1 UNION ALL SELECT a, c FROM t2 ORDER BY a+1; + SELECT a, b, c FROM t1 UNION ALL SELECT a AS x, b, c FROM t2 ORDER BY x; It was a useful extension. ---- _2007-Dec-13 16:05:10 by drh:_ {linebreak} The support is still there. We just removed the test case. I'm not sure why. Probably we should put it back... ---- _2007-Dec-13 16:22:42 by anonymous:_ {linebreak} Are you sure? From latest CVS: sqlite> select 3 as A, 6 as B union select 1 as B, 5 as A order by A; 1|5 3|6 sqlite> select 3 as A, 6 as B union select 1 as B, 5 as A order by +A; SQL error: 1st ORDER BY term does not match any column in the result set sqlite> select 3 as A, 6 as B union select 1 as B, 5 as A order by A+1; SQL error: 1st ORDER BY term does not match any column in the result set sqlite> select 3 as A, 6 as B union select 1 as B, 5 as A order by 9*A-A*A; SQL error: 1st ORDER BY term does not match any column in the result set select * from (select 3 as A, 6 as B union select 1 as B, 5 as A) order by 9*A-A*A; 1|5 3|6 ---- _2007-Dec-13 17:01:22 by drh:_ {linebreak} In a compound SELECT, the ORDER BY terms must match an expression in the result set exactly. "A" does not exactly match "+A". But "a+1" does exactly match "a+1". To keep things relatively simple, we do not allow equivalent expressions. "1+a" does not match "a+1". The expressions must be identical (from the point of view of the parser - differences in whitespace don't matter of course since that is all stripped out by the tokenizer.) In a simple SELECT, if an ORDER BY term does not exactly match a result set expression, we can add an additional "virtual" result column to contain the ORDER BY term. But we cannot do that in a compound SELECT because we would have to add such "virtual" columns to all SELECTs in the compound and the ORDER BY expression typically only makes sense for one of them. ---- _2007-Dec-13 17:28:33 by anonymous:_ {linebreak} Some popular databases do in fact add "virtual" columns you describe and support ORDER BY expressions not explicitly mentioned in any compound SELECT. mysql> select 3 as A, 6 as B union select 1 as B, 5 as A order by -A*A; +---+---+ | A | B | +---+---+ | 3 | 6 | | 1 | 5 | +---+---+ It's a useful extension, but not a show stopper. One could manually do to the transformation identified above to make the compound query a subquery and move the ORDER BY to the parent. I don't know if it is any less efficient. #f2dcdc 2821 new active 2007 Dec anonymous 2007 Dec 3 4 hashtable indicies 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:_ {linebreak} 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:_ {linebreak} Everything in sqlite depends on btree indexes. You're talking a major rewrite if you support hash-based or other indexing. #cfe8bd 2820 code fixed 2007 Dec anonymous 2007 Dec 1 1 rollback doesn't work Code:
 #include  #include "sqlite3.h"  sqlite3 *db; static int callback(void *NotUsed, int argc, char **argv, char **azColName){   sqlite3_exec(db, "DROP TABLE t", 0, 0, 0);   printf("%s\n", sqlite3_errmsg(db));   return 0; }  int main() {   sqlite3_open("test.db", &db);   sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS t(a INT)", 0, 0, 0);   sqlite3_exec(db, "select name, type from sqlite_master", &callback, 0, 0);   sqlite3_close(db);   return 0; } 
prints: database table is locked In sqlite rolback is called (I'v checked in older version), but in test.db there is no table 't'. Tested on win2k. _2007-Dec-03 16:31:50 by anonymous:_ {linebreak} What is the desired outcome? ---- _2007-Dec-03 18:28:38 by anonymous:_ {linebreak} No error. Or if error is reported during delete, nothing should be deleted. #c8c8c8 2819 code closed 2007 Dec anonymous 2007 Dec 2 1 Blocking and crashing First it was blocking when using perl lib DBI, i tried to update the packages and finally reinstall them and now i get this:
 mush@server:~$ /usr/bin/sqlite3 ./Bureau/lexfix/lexFix/test.dat SQLite version 3.3.10 Enter ".help" for instructions sqlite> .schema /usr/bin/sqlite3: symbol lookup error: /usr/bin/sqlite3: undefined symbol: sqlite3_enable_load_extension mush@server:~$ /usr/bin/sqlite3 ./Bureau/lexfix/lexFix/test.dat /usr/bin/sqlite3: symbol lookup error: /usr/bin/sqlite3: undefined symbol: sqlite3_enable_load_extension 
I think this is a support request, not a bug report. Please take your comments to the SQLite mailing list. #c8c8c8 2818 code closed 2007 Dec anonymous 2007 Dec 2 4 Comparison of 8 bytes integer numbers is truncated sqlite> select -9223372036854775808>=-9223372036854775808; 1 sqlite> select -9223372036854775809>=-9223372036854775808; 1 sqlite> select -9223372036854875808>=-9223372036854775808; 0 sqlite> select -9223372036854775808>=-9223372036854775808; 1 This is the correct answer. sqlite> select -9223372036854775809>=-9223372036854775808; 1 -9223372036854775809 is *not* an 8-byte integer. The smallest possible 8-byte integer is -9223372036854775808. The -9..809 value is a 64-bit IEEE floating point number: -9.22337203685488e+18. In order to perform the comparison, SQLite converts the number on the right to floating point value. Due to the limited precision of floating point numbers, both values are the same and so the values compare equal to one another. Hence the result shown above is correct. sqlite> select -9223372036854875808>=-9223372036854775808; 0 This is the correct answer. No bugs seen here. #c8c8c8 2817 code closed 2007 Dec danielk1977 2007 Dec danielk1977 1 1 Temp-tables with the same name as database tables can cause corruption Suspect a problem in the CREATE INDEX statement here: CREATE TEMP TABLE abc(a, b, c); CREATE TABLE main.abc(a, b, c); CREATE INDEX main.abc_i ON abc(a, b, c); The attached script demonstrates the problem. #c8c8c8 2816 code closed 2007 Dec anonymous 2007 Dec drh 4 3 .timer missing from CLI .timer not valid for 3.5.2/3.5.3 It works when I try it. ---- _2007-Dec-04 14:48:14 by anonymous:_ {linebreak} No .timer support on Windows. ---- _2007-Dec-04 15:31:30 by drh:_ {linebreak} That is correct - there is no timer support on windows. But on the other hand, we never claimed there was. The ".timer" command does not show up in the help menu on windows. #cfe8bd 2815 doc fixed 2007 Dec anonymous 2007 Dec 2 3 sqlite3_blob_close closes blob even when reporting error! As part of my testing, I open a blob read only and then do some writing to it. On calling sqlite3_blob_close, I get back error 8 (SQLITE_READONLY), but the blob is closed anyway. Normal practise for file like apis is that if close returns an error, the handle remains open. Please either make SQLite match other apis, or update the documentation to mention that the blob handle is always closed no matter what the return. It is probably also a good to mention that the return of close must be checked since that is where errors are returned (ie view it as a commit). The Linux close(2) man page contains advise that translates to sqlite3_blob_close as well http://linux.die.net/man/2/close #f2dcdc 2814 code active 2007 Nov anonymous 2007 Dec 3 3 _XOPEN_SOURCE again 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} See also tickets #2673, #2681, and #2741. ---- _2007-Dec-02 02:08:26 by anonymous:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 2812 new closed 2007 Nov anonymous 2007 Dec 3 4 SQLITE_SECURE_DELETE overwrites with 0, but should use random data Hello Dr. Hipp, SQLITE_SECURE_DELETE overwrites with 0, but should use random data. I'm not an expert in this area, but it also sounds like secure delete should involve random data then writing to disk several times in a row. For the firefox bug that relates to this, please see https://bugzilla.mozilla.org/show_bug.cgi?id=405925 Thanks, -Seth _2007-Nov-29 18:40:32 by anonymous:_ {linebreak} This is a questionable enhancement to security because you cannot ensure where the disk controller will actually write the data on the media. The old fragment may exist elsewhere on the disk. Flash memory cards try to even out where blocks are written to on the media because of the finite number of writes allowed, for example. It's better to encrypt the whole database file. ---- _2007-Nov-29 21:19:34 by anonymous:_ {linebreak} dr. hipp writes: I don't think writing random bits or writing multiple times will help any. There are too many layers (operating system, file system, disk driver, and disk controller) in between SQLite and the oxide for SQLite to really have much control over what is truly stored on media. SQLite might write the same page multiple times, for example, but the OS would likely coalese the writes into a single write. Perhaps we could force multiple writes using fsync() but that would be a *huge* performance penalty. And even if we did, just because we write to the same offset in some file does *not* mean that the information is written to the same place on mass storage. Some filesystems (YAFFS) intentionally spread the writes around to different places for the purpose of wear leveling. And even if the operating system doesn't do this, then on-drive disk controller might. What problem, exactly, are you trying to solve? The existing SQLITE_SECURE_DELETE is adequate to prevent casual snooping. It is not, as you observe, adequate to prevent snooping from major governments. Against a determined adversary, the only sure defense is to physically shred the disk platter. ---- _2007-Nov-29 21:20:33 by anonymous:_ {linebreak} in https://bugzilla.mozilla.org/show_bug.cgi?id=405925#c4, jesse writes: I don't think it's worth the effort and perf hit to attempt to protect Firefox profile data from forensic data recovery. It's really hard to get right, especially at the app level, and we don't want to give users a false sense of security by trying. Any given data is likely to appear in many physical locations on the disk due to swapping, journaling, automated backups, and continuous defragmentation [1]. When you try to overwrite part of a file, you find yourself fighting against optimizations in operating systems and in disks themselves [2]. Data also appears in RAM, which can survive power cycling [2] and is even harder to control. Zeroing sounds reasonable; it will protect against casual snooping, and depending on the file system, might protect against forensic software. But I don't think we should go beyond zeroing (e.g. multiple overwrites) in an attempt to defeat forensic analysis of the physical hard drive and RAM. Extremely paranoid users can use operating system features to encrypt an entire hard drive or automatically do multiple overwrites every time data on disk as it is changed. [1] http://en.wikipedia.org/wiki/Disk_wipe [2] http://en.wikipedia.org/wiki/Data_remanence ---- _2007-Nov-29 21:21:02 by anonymous:_ {linebreak} based on these responses, this seems like a "wontfix" thanks, -Seth #c8c8c8 2804 code closed 2007 Nov anonymous 2007 Dec 1 1 PRAGMA legacy_file_format=OFF setting lost with VACUUM It seems that the PRAGMA legacy_file_format=OFF and the ability to use DESC indexes is lost after two VACUUMs and reconnects.
 $ rm -f foo.db  $ ./sqlite3-3.5.3.bin foo.db SQLite version 3.5.3 Enter ".help" for instructions sqlite> PRAGMA legacy_file_format; 1 sqlite> PRAGMA legacy_file_format=OFF; sqlite> PRAGMA legacy_file_format; 0 sqlite> CREATE TABLE abc(a,b,c); sqlite> CREATE INDEX abc_i on abc(b desc, c asc, a desc); sqlite> explain query plan select * from abc order by b desc, c asc, a desc; 0|0|TABLE abc WITH INDEX abc_i ORDER BY sqlite> vacuum; sqlite> .q  
In the next connection we see that the legacy file format reverted back to 1, but the DESC index is still picked up...
  $ ./sqlite3-3.5.3.bin foo.db SQLite version 3.5.3 Enter ".help" for instructions sqlite> PRAGMA legacy_file_format; 1 sqlite> explain query plan select * from abc order by b desc, c asc, a desc; 0|0|TABLE abc WITH INDEX abc_i ORDER BY sqlite> vacuum; sqlite> .q  
But if connected to another time, the DESC index is not picked up...
  $ ./sqlite3-3.5.3.bin foo.db SQLite version 3.5.3 Enter ".help" for instructions sqlite> PRAGMA legacy_file_format; 1 sqlite> explain query plan select * from abc order by b desc, c asc, a desc; 0|0|TABLE abc 
Actually, this works correctly, though the documentation could be clearer. The legacy_file_format pragma does not tell you the file format of the current database. Rather, it tells you what file format will be used when creating new databases (for example, using ATTACH). The behavior shown above is correct. There is no pragma to tell you what the file format of the current database is. The documentation has been clarified. Two new test cases have been inserted into the test suite to verify that the operation is correct. #c8c8c8 2802 code closed 2007 Nov anonymous 2007 Dec 1 1 SELECT UNION and EXCEPT seem to have a memory allocation bug It seems that SELECT UNION and EXCEPT operators work wrong. It looks like memory access overflow or integer overflow. Well, I have a large text file 'text2.text' (~1.5mg), which contains: 20091208{linebreak} 20216510{linebreak} 20149599{linebreak} 20250484{linebreak} 20211910{linebreak} 20199980{linebreak} ........{linebreak} 20183528{linebreak} 20151994{linebreak} 20179184{linebreak} 20077607{linebreak} 182500 lines in total. The meaning of these numbers is a date in YYYYMMDD format. Numbers are random and unsorted at all. The next file is 'test1.text' is the same as 'test2.text' but without the last 1000 lines. The 'diff' between these files shows the difference in last 1000 lines. Than I execute script: @echo off{linebreak} if exist test.db del test.db{linebreak} rem{linebreak} rem Load data into table 'a'{linebreak} rem It prints 181500{linebreak} sqlite3 test.db "create table a (i1 text)"{linebreak} sqlite3 test.db ".import test1.text a"{linebreak} sqlite3 test.db "select count(*) from a"{linebreak} rem{linebreak} rem Load data into table 'b'{linebreak} rem It prints 182500{linebreak} sqlite3 test.db "create table b (i1 text)"{linebreak} sqlite3 test.db ".import test2.text b"{linebreak} sqlite3 test.db "select count(*) from b"{linebreak} rem{linebreak} rem PROBLEM IS HERE{linebreak} rem Now I am trying to merge the tables 'a' and 'b' via UNION.{linebreak} rem It should print '182500' but it prints '16384' !!!{linebreak} sqlite3 test.db "create table c (i1 text)"{linebreak} sqlite3 test.db "insert into c select * from b union select * from a"{linebreak} sqlite3 test.db "select count(*) from c"{linebreak} rem{linebreak} rem Just a check that EXCEPT also has the same bug.{linebreak} rem It should print 1000, but it prints '0' !!!{linebreak} sqlite3 test.db "select count(*) from (select * from c except select * from b)"{linebreak} I suggest that UNION and EXCEPT has some kind of memory overflow. And also it depends on how strong the numbers in the source text file are shuffled and how wide is the range of the numbers. I can attach my files 'test1.text' and 'test2.text' if needed. My system: CPU Intel Core 2 Duo, 1.06GHz, 2GB RAM. Operating system: Windows XP SP2 (Version 5.1.2600) _2007-Nov-27 23:45:42 by drh:_ {linebreak} UNION and EXCEPT both imply DISTINCT. Since you are dealing with dates, it seems unlikely that you really have 182500 distinct dates. That would span 500 years and your sample data seems to all be from the early part of the 21st century. 16384 distinct dates would span 44 years, which seems more reasonable, given your sample data. The fact that the number is a power of two probably results from a poor-quality PRNG used to generate the same data. You can use UNION ALL to to get the union of two tables without the implied DISTINCT. There is no way to omit the implied DISTINCT from EXCEPT. You will probably need to refactor your query to use the NOT IN operator. ---- _2007-Dec-05 20:10:08 by anonymous:_ {linebreak} Actually, in the real data, when I've got this situation on EXCEPT and UNION, there are some extra fields in the database. Except 'date', there were text fields: 'amount', 'owner', 'descr', 'labels' (it's personal cash accouting database). When the test data was generatated, all fields could have duplicate values, but 'amount' field was generated like: $amount = sprintf( "%d.%02d", rand( 1, 10000 ), rand( 0, 99 ) ); so, it can take 9999999 possible values, which is more than 16384 for sure. And the behaviour of the EXCEPT was completely the same as I've described the the original message of this bug report. That's why I've decided that the key of the problem is just in the amount of data, not in values, and I've reduced the database structure for the bug report to make it more clear (I left only one field 'date'), but the 'bug' (I mean this strange behaviour of the EXCEPT and UNION) still happens in the reduced database structure (with only one field 'date'). So DISTINCT function will not merge all values of 'amount' field into 16384 unique values. What do you think? #f2dcdc 2761 code active 2007 Nov anonymous 2007 Dec 3 3 CLI (shell.c) should be bundled with amalgamation 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:_ {linebreak} I also agree. It is inconvenient to retrieve the matching shell.c from the source tree. #c8c8c8 2758 code closed 2007 Nov anonymous 2007 Dec 1 1 Why this? sqlite3* s1; sqlite3* s2; sqlite3_stmt* stm; sqlite3_open("db", &s1); sqlite3_open("db", &s2); sqlite3_prepare_v2(s2, "SELECT * FROM sqlite_master", 27,&stm, NULL); sqlite3_step(stm); sqlite3_finalize(stm); sqlite3_prepare_v2(s1, "CREATE TABLE C (c1)", 19, &stm, NULL); sqlite3_step(stm); sqlite3_finalize(stm); sqlite3_prepare_v2(s2, "SELECT * FROM C", 15, &stm, NULL); Last row return ERROR n.17 SQLITE_SCHEMA, But All previous statements are finalized. _2007-Nov-05 05:17:04 by danielk1977:_ {linebreak} It's not obvious. Which call is returning SQLITE_SCHEMA? sqite3_prepare_v2() or sqlite3_step()? Are any other processes accessing the same database? Which version of SQLite are you using? Can you post a complete program that demonstrates this? ---- _2007-Nov-05 16:00:54 by anonymous:_ {linebreak} I can reproduce the original poster's findings. For me, the final sqlite3_prepare_v2() returns 17 (SQLITE_SCHEMA). Up to this everything works as documented. I run the posted code unchanged in a single process on Windows XP as main(). The database file does not exist prior to execution. ---- _2007-Dec-13 19:50:15 by rdc:_ {linebreak} This was closed as "can not reproduce", but I think the reported behavior is exactly as expected from SQLite. This program opens two connections to the database file. Runs a query in one which causes SQLite to read the schema. It then adds a table using the second connection. This changes the schema. Finally it tries to execute a query that references the new table using the first connection. This generates an error. I was informed by DanK on the mailing list that this is the normal behavior of SQLite. I thought that the new prepare_v2 API was supposed check if the schema cache was stale, and reload it before generating a schema error, but he said it didn't. Apparently the poster thinks this behavior is strange as well. I think this should be reopened, or re-closed as "works as designed". It should be reproducible (I suspect the test was done using a single connection) and maybe shouldn't have been closed the way it was. #c8c8c8 2724 code closed 2007 Oct anonymous 2007 Dec drh 2 2 Load Ext api missing error_toobig function. Function call for sqlite3_error_toobig is not in the sqlite3Ext.h void (*result_error_toobig)(sqlite3_context*); #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig Without these, externally loadded libs that would like to use error_toobig will not load into sqlite _2007-Dec-13 18:51:28 by drh:_ {linebreak} See ticket #2610. #f2dcdc 2721 code active 2007 Oct anonymous 2007 Dec 2 1 if db file is in a folder with non-ansi character some functions fail If database file is located in directory with some non-ANSI characters (in my case with a Russian subdirectory c:\Мои документы\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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} That appears to be only with INSERT sql statement. Both SELECT and UPDATE work fine with sqlite_prepare16. #c8c8c8 2717 doc closed 2007 Oct anonymous 2007 Dec anonymous 5 5 Document clarification around SQLITE_OMIT_MEMORY_ALLOCATION In the " Moving From SQLite 3.4.2 to 3.5.0" document, section 3.0 it states that "These routines are provided for use by the application. SQLite never invokes them itself. So if the application is providing its own memory allocation subsystem, it can omit these interfaces if desired." This doesn't seem to be correct unless SQLITE_OMIT_LOAD_EXTENSION is defined. If this value is not defined, then the function pointers are assigned in a structure (sqlite3_apis). As stated, they are not used by SQLite proper, but must be defined. In this case, I am unable to link without either defining the functions or building with SQLITE_OMIT_LOAD_EXTENSION defined. _2007-Oct-11 19:45:36 by anonymous:_ {linebreak} It appears that the sqlite3_memory_used() function is required in sqlite3_soft_heap_limit() so my previous comments were not entirely correct. I'm still having a link problem even with the define. ---- _2007-Dec-13 18:48:21 by drh:_ {linebreak} SQLITE_OMIT_MEMORY_ALLOCATION is no longer supported. #cfe8bd 2561 code fixed 2007 Aug anonymous 2007 Dec 1 1 Parser broken -- ORDER BY fails in UNION between two databases To reproduce: 1. Create two simple databases, each with only one table "Table1" containing two fields -- ID (integer primary key) and Name (string); 2. Fill databases with a few records each of sample data; 3. Open one database and attach the other one as "aux"; 4. Try this query: SELECT Table1.Name, Table1.ID FROM main.Table1 UNION SELECT Table1.Name, Table1.ID FROM aux.Table1 ORDER BY Table1.ID; 5. Query fails with message: "SQL error: ORDER BY term number 1 does not match any result column". _2007-Aug-09 05:27:20 by anonymous:_ {linebreak} This doesn't work either: SELECT * FROM main.Table1 UNION SELECT * FROM aux.Table1 ORDER BY Table1.ID ---- _2007-Aug-09 05:28:16 by anonymous:_ {linebreak} WORKAROUND!!! This works: SELECT Table1.name, Table1.ID AS alias FROM main.Table1 UNION SELECT Table1.name, Table1.ID AS alias FROM aux.Table1 ORDER BY alias ---- _2007-Aug-09 05:31:12 by anonymous:_ {linebreak} SELECT Table1.Name, Table1.ID FROM main.Table1 UNION SELECT Table1.Name, Table1.ID FROM aux.Table1 ORDER BY 2; ---- _2007-Aug-10 01:55:58 by anonymous:_ {linebreak} Real problem for me is that this is not working, as previously mentioned: SELECT * FROM main.Table1 UNION SELECT * FROM aux.Table1 ORDER BY Table1.ID Very inconvenient. ---- _2007-Sep-14 07:22:10 by anonymous:_ {linebreak} I also have this problem and had to implement a bit of a dirty workaround to get aliases on the order by column as suggested before. Would be nice if a minor update would come out that fixes this (dont want to install 3.5 ALPHA for a possible future fix) ;-) ---- _2007-Sep-14 08:51:23 by anonymous:_ {linebreak} AUX is in the DOS/Windows world reserved name so maybe it is the source of problems ? ---- _2007-Dec-13 18:58:37 by drh:_ {linebreak} See ticket #2822. #f2dcdc 2508 code active 2007 Jul anonymous 2007 Dec 1 1 utf8ToUnicode() does not work on some WinCE devices 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:_ {linebreak} =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:_ {linebreak} 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:_ {linebreak} 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; } #cfe8bd 2067 code fixed 2006 Nov anonymous 2007 Dec 4 4 Bad syntax caused core dump This is a really small problem but the following malformed syntax will cause a core dump create table course ( c# varchar(5) not null, cname varchar(40) not null, primary key (c#) )grant select on course to public; I was just copying and pasting someone else's entries, I recognize the syntax is not valid. _2006-Nov-15 03:40:32 by drh:_ {linebreak} I always get an error message: SQL error: unrecognized token: "#" Did you build SQLite yourself or are you using one of the prebuilt versions? What OS? ---- _2007-Nov-07 19:31:40 by anonymous:_ {linebreak} This happens to me as well. I'm using the Ubuntu 7.10 repository package $ sqlite test.db SQLite version 2.8.17 Enter ".help" for instructions sqlite> create table S(S# varchar2(2),sname varchar2(10),status number(4),city varchar2(10)); sqlite: ./src/main.c:642: sqlite_exec: Assertion `pVm==0 || sqlite_malloc_failed' failed. Aborted (core dumped) This is most definitely caused by the # character. The sqlite3 package gives the following output: $ sqlite3 pb.db SQLite version 3.4.2 ... SQL error: unrecognized token: "#" So it was apparently already fixed sometime during development... #f2dcdc 1648 new active 2006 Jan anonymous Shell 2007 Dec 4 3 meaningful error message: constraint failed 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:_ {linebreak} actually my testing was better than my typing, I used: check (sex = 'm' or sex = 'f' ) ---- _2007-Oct-25 09:47:14 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 916 new active 2004 Sep anonymous Unknown 2007 Dec 1 1 No delete notification for INSERT OR REPLACE 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:_ {linebreak} 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. #f2dcdc 558 build active 2004 Jan anonymous 2007 Dec 4 4 Makefile.in should honor libdir and bindir 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 368 code active 2003 Jun anonymous 2007 Dec 3 4 UPDATE trigger doesn't fire on INSERT OR REPLACE 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:_ {linebreak} Still repros in 3.0.7 :-( ---- _2007-Dec-17 21:45:03 by anonymous:_ {linebreak} 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. #f2dcdc 2254 new active 2007 Feb anonymous 2007 Feb 5 4 ATTACH support IF NOT ATTACHED statement 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). #cfe8bd 2252 code fixed 2007 Feb drh 2007 Feb drh 1 1 New INSERT optimization bypasses CHECK constraint checks Consider the following code: CREATE TABLE t1(a int, b int, check(b>a)); CREATE TABLE t2(x int, y int); INSERT INTO t2 VALUES(9,1); INSERT INTO t1 SELECT * FROM t2; SELECT * FROM t1 WHERE ba)); CREATE TABLE t2(x int, y int); INSERT INTO t2 VALUES(9,1); INSERT INTO t1 SELECT * FROM t2 WHERE 1; #cfe8bd 2251 code fixed 2007 Feb anonymous 2007 Feb 1 1 sqlite3_column_type gives bad type for sum() .. group by CREATE TABLE A ( A1 DOUBLE, A2 VARCHAR COLLATE NOCASE, A3 DOUBLE ); INSERT INTO A VALUES(39136,'ABC',1201900000); INSERT INTO A VALUES(39136,'ABC',1207000000); running: "select sum(A3) from A group by A1" using C api: sqlite3_prepare_v2, sqlite3_step, sqlite3_column_type sqlite3_column_type will return integer, hence fetching value with sqlite3_column_int will give incorrect sum! without the "group by A1" it returns correct type = real Either use sqlite3_column_int64() in that case, or use sqlite3_column_double() for any numeric type. If column type is integer and column value < 2^31, then cast number to int. ---- _2007-Feb-24 01:17:57 by anonymous:_ {linebreak} Yes, sqlite3_column_double() will work here but this is still a bug. sqlite returns types for columns and sqlite3_column_type returns the wrong type. This used to work with 3.2.x, so it is a new bug and it happens with group by. If all numbers that could be integers are made to be doubles, when reading, then double the memory is wasted. ---- _2007-Feb-24 01:31:19 by anonymous:_ {linebreak} -> why the presence of "group by" makes sqlite3_column_type return int and without group by it returns real. that does not look consistent. i would hope someone is reading the full bug reports. ---- _2007-Feb-24 11:41:43 by drh:_ {linebreak} Here is a related problem: CREATE TABLE t2(a INTEGER); INSERT INTO t2 VALUES(1); INSERT INTO t2 VALUES(1); INSERT INTO t2 VALUES(2); ALTER TABLE t2 ADD COLUMN b INTEGER DEFAULT 9; SELECT a, sum(b) FROM t2 GROUP BY a; The result of the final SELECT statement above should be 1, 18, 2, 9. But instead we get 1, NULL, 2, NULL. Both this issue and the problem originally reported stem from the fact that the GROUP BY processing is not pulling values out of the table correctly. #cfe8bd 2249 code fixed 2007 Feb drh 2007 Feb drh 1 1 OR clause optimizer confused by column affinities In the following SQL, we get results for the first and third query but the second query returns an empty set: CREATE TABLE t1(a TEXT UNIQUE); CREATE TABLE t2(b INTEGER); INSERT INTO t1 VALUES('0123'); INSERT INTO t2 VALUES(123); SELECT 111, * FROM t2 CROSS JOIN t1 WHERE a=b; SELECT 222, * FROM t2 CROSS JOIN t1 WHERE a=b OR a='hello'; SELECT 333, * FROM t2 CROSS JOIN t1 WHERE a=b OR +a='hello'; The reason for the discrepancy is that the second query uses the {link: /optoverview.html#or_opt OR optimization} and the OR optimization is not properly taking into account {link: /datatype3.html#comparisons column affinity rules for comparisons}. #cfe8bd 2248 code fixed 2007 Feb anonymous 2007 Feb 2 1 error evaluating IN statement Hi, The following statement returns 0 when it should return 1: select (CASE WHEN ('00' IN ('00','01')) THEN 1 ELSE 0 END) However, this returns 1: select (CASE WHEN ('00' IN (00,01)) THEN 1 ELSE 0 END) So it seems that t."F" IN (...) fails if the value are strings containing integers. Regards. Francois _2007-Feb-22 21:40:34 by anonymous:_ {linebreak} Simplified test cases: sqlite> select '0' IN ('0'); 0 sqlite> select '0' IN (0); 1 sqlite> select 0 IN (0); 1 sqlite> select 0 IN ('0'); 0 sqlite> select '2' IN ('2'); 0 sqlite> select '2' IN (2); 1 sqlite> select 2 IN (2); 1 sqlite> select 2 IN ('2'); 0 #f2dcdc 2247 doc active 2007 Feb anonymous 2007 Feb 3 3 documentation of DEFUALT cluase in CREATE TABLE should be fixed 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? #f2dcdc 2246 doc active 2007 Feb anonymous 2007 Feb 5 4 SQL docs for CREATE TABLE should include FOREIGN KEY syntax 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 #c8c8c8 2245 new closed 2007 Feb anonymous 2007 Feb a.rottmann 5 1 Union Problem on Empty Table There is problem on union query if source table is empty, and the empty table is the first data source of union. Suppose we have STOCK table contains Fields : Code, Name and Quantity while the table is empty. Then make a union query like this : Select Code, Name, Qty from STOCK union all Select 'SomeCode', 'Some Name', 100 union all Select 'OtheCode', 'OtherName, 25 and the result was : Code Name Qty 100 25 where is the value of "Code" and "Name" ????? _2007-Feb-22 15:45:33 by drh:_ {linebreak} Unable to reproduce. When I try the query shown in the description it works fine. #c8c8c8 2244 code closed 2007 Feb anonymous 2007 Feb danielk1977 1 2 xUpdate in virtual table being called when no record exists I have the following virtual table schema: create virtual table foo using wrsv (a, b, c, d FLOAT, e TEXT); and I insert the following records: insert into foo values(100,100,100,100.1, "100"); insert into foo values(200,200,200,200.2, "200"); insert into foo values(300,300,300,300.3, "300"); insert into foo values(400,400,400,400.4, "400"); which gives me: $ ./sqlite3 < foo a b c d e ---------- ---------- ---------- ---------- ---------- 100 100 100 100.1 100 200 200 200 200.2 200 300 300 300 300.3 300 400 400 400 400.4 400 If I query for records matching `rowid=10' sqlite> select * from foo where rowid=10; sqlite> there are indeed no records. However, if I now use UPDATE to update record 10 using: sqlite> update foo set e="hello world" where rowid=10; then this record ends up being inserted (via xUpdate) into the virtual table. Looking at the documentation for xUpdate I see that the following condition is being met: argc > 1 && argv[0] == NULL: a new row is inserted with rowid argv[1]. The types argv[0] and argv[1] are SQLITE_NULL. I double-checked my xEof method and that returns 1 (EOF) during xOpen/xFilter. I changed my build to use "-DSQLITE_DEBUG=1" and touched vdbe_explain and vdbe_trace. (The output is below - lines beginning with WRSV_TRACE are from my module.) From a cursory glance at the trace I see that wrsv_eof returns EOF (1) but then the stack is populated with column values - all NULL. If the existing record cannot be found then the insert/update should not happen. At the moment I'm getting a new record inserted into the DB which is not correct. Any light you can shed on this would be appreciated. sqlite> update foo set e="hello world" where rowid=10; VDBE Program Listing: SQL: [update foo set e="hello world" where rowid=10;] 0 Goto 0 32 1 Noop 0 0 2 OpenEphemeral 1 6 3 VOpen 0 0 vtab:8149200:80BFC80 4 Integer 10 0 5 Integer 1 0 6 Integer 0 0 7 VFilter 0 19 8 VRowid 0 0 9 VColumn 0 0 # foo.a 10 VColumn 0 1 # foo.b 11 VColumn 0 2 # foo.c 12 VColumn 0 3 # foo.d 13 String8 0 0 hello world 14 MakeRecord 6 0 15 NewRowid 1 0 16 Pull 1 0 17 Insert 1 0 18 VNext 0 8 19 Close 0 0 20 Rewind 1 0 21 Column 1 0 22 Dup 0 0 23 Column 1 1 24 Column 1 2 25 Column 1 3 26 Column 1 4 27 Column 1 5 28 VUpdate 0 7 vtab:8149200:80BFC80 29 Next 1 21 30 Close 1 0 31 Halt 0 0 32 Transaction 0 1 33 VerifyCookie 0 1 34 VBegin 0 0 vtab:8149200:80BFC80 35 Goto 0 1 36 Noop 0 0 VDBE Execution Trace: SQL: [update foo set e="hello world" where rowid=10;] 0 Goto 0 32 32 Transaction 0 1 33 VerifyCookie 0 1 34 VBegin 0 0 vtab:8149200:80BFC80 35 Goto 0 1 1 Noop 0 0 2 OpenEphemeral 1 6 3 VOpen 0 0 vtab:8149200:80BFC80 WRSV_TRACE: WRSV_OPEN 4 Integer 10 0 Stack: i:10 5 Integer 1 0 Stack: i:1 i:10 6 Integer 0 0 Stack: i:0 i:1 i:10 7 VFilter 0 19 WRSV_TRACE: wrsv_eof: 1 19 Close 0 0 WRSV_TRACE: wrsv_close 20 Rewind 1 0 21 Column 1 0 Stack: NULL 22 Dup 0 0 Stack: NULL NULL 23 Column 1 1 Stack: NULL NULL NULL 24 Column 1 2 Stack: NULL NULL NULL NULL 25 Column 1 3 Stack: NULL NULL NULL NULL NULL 26 Column 1 4 Stack: NULL NULL NULL NULL NULL 27 Column 1 5 Stack: NULL NULL NULL NULL NULL 28 VUpdate 0 7 vtab:8149200:80BFC80 WRSV_TRACE: wrsv_update: argc = 7 29 Next 1 21 30 Close 1 0 31 Halt 0 0 Thanks for reporting this. See [3652]. #cfe8bd 2242 code fixed 2007 Feb anonymous 2007 Feb 2 3 sqlite3 authorizer is not reentrant The authorizer callback cannot finalize a query. It should be able to as SQLite is reentrant. If you finalize query1 during authorization of a query2 step, then the step fails. This can happen in a garbage collected language as the callback might try to free memory (finalize a completed query). Here is the command to create a database: echo "create table peanuts (x text, y integer);" | sqlite3 test.db Here's the source code: #include #include #include sqlite3* db; sqlite3_stmt* q1; sqlite3_stmt* q2; int free_q1 = 0; void ok(int x) { if (x != SQLITE_OK) { fprintf(stderr, "Died earlier than expected : %d\n", x); exit(1); } } int my_auth(void* u, int x, const char* a, const char* b, const char* c, const char* d) { if (free_q1) { free_q1 = 0; // Here is where re-entrancy breaks ok(sqlite3_finalize(q1)); } return SQLITE_OK; } int main() { int r; ok(sqlite3_open("test.db", &db)); ok(sqlite3_prepare_v2(db, "select x, y from peanuts where y=4 or x='hi';", -1, &q1, 0)); ok(sqlite3_prepare_v2(db, "select * from peanuts;", -1, &q2, 0)); ok(sqlite3_set_authorizer(db, my_auth, 0)); while ((r = sqlite3_step(q1)) == SQLITE_ROW) { } ok(r != SQLITE_DONE); free_q1 = 1; printf("Failing step: %d - %s\n", sqlite3_step(q2), sqlite3_errmsg(db)); return 0; } Here's the (wrong) output: Failing step: 17 - library routine called out of sequence Documentation enhanced to explain that SQLite is not reentrant through the authorization callback function. #c8c8c8 2240 code closed 2007 Feb anonymous 2007 Feb 1 1 Parser command termination problem fails to catch illegal statements Same problem exists in the shell or when a file is piped to sqlite3: SQLite version 3.3.13 Enter ".help" for instructions sqlite> select 'one', 'two' ...> 'three'; one|two sqlite> select current_timestamp ...> junk; 2007-02-19 14:54:35 sqlite> select 'foo' ...> bar; foo _2007-Feb-19 16:01:02 by drh:_ {linebreak} The statements are not illegal. In the first case 'three' is an alias for the second column and in the second case junk is an alias for the first columln. It is as if the keyword AS had been inserted. All SQL database engines that I am aware of work this way. ---- _2007-Feb-19 18:56:27 by anonymous:_ {linebreak} Ugh. Aliases - of course... it must be Monday. ---- _2007-Feb-20 23:38:10 by anonymous:_ {linebreak} Standard SQL does not allow a string literal (in single quotes) as an alias identifier. In standard SQL a quoted identifier (in double quotes) would be allowed as an alias identifier. Furthermore, in standard SQL the first example should still work but for a different reason. The database should concatenate the two string literals ('two' and 'three') that are separated by whitespace only into a single string literal (just as C and C++ do) to produce a single result value of 'twothree'. #c8c8c8 2239 doc closed 2007 Feb anonymous 2007 Feb 1 1 Size of database in Speed Comparison? In the speed comparison, how big is the database? It would be interesting to see speed comparisons with a database with at least 1 gig size. http://www.sqlite.org/cvstrac/wiki?p=SpeedComparison Best Regards The databases in the tests are all quite small and are 100% in the machine's disk cache which positively skews results in SQLite's favor. But this question belongs on the mailing list. #f2dcdc 2238 new active 2007 Feb anonymous 2007 Feb 2 3 Streams as datbase Would it be possible to allow the use of streams as a database source? _2007-Feb-18 03:56:46 by anonymous:_ {linebreak} 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. #f2dcdc 2237 code active 2007 Feb anonymous 2007 Feb 4 4 Test suite regressions using Tcl 8.5 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 ...}] #c8c8c8 2236 code closed 2007 Feb anonymous 2007 Feb 1 1 inserts with selects do not work in 3.1.13 When trying to do an insert via a select statement using the sqlite3 command line tool, it states that there is an SQL error, when there really isn't one: sqlite> insert into snwstaticparam (obj_id, parameter, value) values select obj_id, "A", "2007-02-16" from snwobject where name="IMS-AAA"; SQL error: near "select": syntax error However, please note that the select statement by itself works just fine: sqlite> select obj_id, "A", "2007-02-16" from snwobject where name="IMS-AAA"; 1|A|2007-02-16 sqlite> And if I simply do the insert based on this information, it goes in just fine: sqlite> insert into snwstaticparam (obj_id, parameter, value) values (1, "A", "2007-02-16" ); sqlite> select * from snwstaticparam; 1|1|A|2007-02-16 sqlite> _2007-Feb-16 20:54:22 by drh:_ {linebreak} The correct syntax is: INSERT INTO snwstaticparm(obj_id,parameter,value) SELECT obj_id, 'A', '2007-02-16' FROM snwobject WHERE name='IMS-AAA' #f2dcdc 2235 new active 2007 Feb anonymous 2007 Feb 4 3 Missing xml support in FTS2 for the snippet function The snippet function _may_ output invalid characters when used for an xml stream (like xhtml). Characters &, < and > need to be escaped (&, < >) 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, '', '', '...', 1) from poem where text match 'xml' ;= output should be: =Xml string with special < > & entities= This modification does not affect the default behaviour of the snippet function. Patch included. #c8c8c8 2234 code closed 2007 Feb anonymous 2007 Feb 1 1 3.3.13 is identical to 3.3.12 except VERSION file I just the new 3.3.13 zips, but source is identical to 3.3.12 (except VERSION file). _2007-Feb-16 11:16:22 by anonymous:_ {linebreak} edit ticked is broken... correct is "I just downloaded ".. incorrect! it's indeed different. sorry. #c8c8c8 2232 build closed 2007 Feb anonymous 2007 Feb 3 3 corrupt2.test fails with newer versions of Tcl I commented on the mailing list that corrupt2.test failed on an Ultra 5 running Solaris 9 and DRH replied: I get the same problem on OS-X. But it appears to be a bug in the older version of TCL you have installed, not in SQLite itself. After installing Debian over Solaris 9 I did some testing and duplicated the bug: I was trying to make a test case to report the Tcl bug and noticed that (in 8.5a5 at least) they added some extra file mode tests. After looking at those tests I now think this is a bug in the SQLite test suite. ISTM opening files in corrupt2-1.x with an 'a' flag writes all changes to the end, which is what I'm seeing. 'a' for append. I think the files should be opened with a 'RDWR' flag instead. Making that changes means the tests pass under Tcl 8.5a5 but I haven't tested the other versions of Tcl yet. I don't know why the test passed under Tcl8.4.9 either. There's a simple fix which I've tested on two machines running Debian Linux with various versions of Tcl: s/a/RDRW/ makes corrupt2.test work with Tcl 8.4.9, 8.4.12, 8.4.14 and 8.5a5 on recent versions of Debian/Ubuntu on sparc64 and x86. This problem was fixed a day before the ticket was written. See check-in [3645] #c8c8c8 2230 code closed 2007 Feb danielk1977 2007 Feb danielk1977 1 1 Problem with virtual tables and grouping by aggregate function. There is some problem with the logic for grouping by aggregate functions when querying a virtual table. Using the demo "schema" table from test_schema.c, the first of the following queries works, the following two return NULL: SELECT length(tablename) FROM schema GROUP by tablename; SELECT length(tablename) FROM schema GROUP by length(tablename); SELECT tablename FROM schema GROUP by length(tablename); Background: The "schema" table implements a linear scan strategy only. The following is for vtab2.test. Currently 2-1.2 passes, 2-1.3 and 2-1.4 fail. do_test vtab2-1.2 { execsql { SELECT length(tablename) FROM schema GROUP by tablename; } } {6} do_test vtab2-1.3 { execsql { SELECT length(tablename) FROM schema GROUP by length(tablename); } } {6} do_test vtab2-1.4 { execsql { SELECT tablename FROM schema GROUP by length(tablename); } } {schema} #cfe8bd 2229 code fixed 2007 Feb anonymous 2007 Feb 1 2 Complex triggers can blow up sqlite I'm making an Audio Filesystem and I decided to try to put some of the smarts into triggers. I use them for refcounting and automatically deleting things that have no references left. However when I put several tables together and the triggers, it segfaults. I tried making sense of a debug version of the library, but I wasn't seeing anything obvious. I think the issue is triggers triggering operations that trigger triggers again etc. I used the following type of code to hopefully end off the chain (which I hope shouldn't cause a trigger as nothing will match): CREATE TRIGGER RDelAlbumTrack AFTER DELETE ON Track BEGIN UPDATE Album SET refs=refs-1 WHERE id=old.album; DELETE FROM Album WHERE id=old.album AND refs<=0; END; _2007-Feb-13 12:45:50 by drh:_ {linebreak} The attached script is truely a remarkable specimen. When SQLite generates its VDBE code, it expands triggers in-line. You have deeply nested triggers, which leads to a lot of expansion. The VDBE program for a typical SQL statement is usually less than 100 instructions. The VDBE program for the DELETE statement at the end of the attached script was a whopping 1430046 instructions in length! In the course of a VDBE program, SQLite opens various cursors into tables or indices of the database. There is a 16-bit counter on the number of these cursors. The cause of the segfault is that you overflowed that counter. The program for the DELETE statement needs 81352 separate cursors. I discovered all of this by changing the size of the counter to 32-bits. Why have it 16-bits in the first place, you ask? SQLite is used a lot in embedded applications where those extra 2 bytes of memory usage make a big difference. I'll change the cursor counter to be 32 bits for now, as a quick interim fix. But for the long-term, a proper fix is to rework the TRIGGER logic to use subroutines rather than expanding each trigger in-line. This change will also likely enable recursive triggers, which we need in order to implement referential integrity with cascading deletes. So the change has been planned for a long time, we just haven't gotten around to it yet. Once that change is in place, I'll change the cursor counter size back to 16 bits for the embedded folks. ---- _2007-Feb-13 12:48:49 by anonymous:_ {linebreak} instead of having refs you should try my way of deleting: CREATE TRIGGER RDelAlbumTrack AFTER DELETE ON Track{linebreak} FOR EACH ROW{linebreak} BEGIN{linebreak} DELETE FROM Album{linebreak} WHERE id=OLD.album{linebreak} AND NOT EXISTS (SELECT * FROM Track WHERE album=OLD.album);{linebreak} END{linebreak} i think it's less complex than yours! it may happen that you delete album and there is some tracks if you have arror with dealing your refs. it is better to calculate number of tracks (group, count() etc. in select) than keep number of tracka in album table. ---- _2007-Feb-17 23:40:10 by anonymous:_ {linebreak} Well, in those cases it is much more possible. The main reason for the logic was the many to many relationships. I wanted the whole linkage system to handle pruning of Artists and Genres on its own. These can be referenced from Tracks, Albums, and Volumes (multiple per record.) Also from eachother. The extension to one to many linkages was mostly because I was already using the system for many to many. Thanks for the suggestion though, I may be able to shortcut things (and make things faster) by doing this in the one to many cases. #f2dcdc 2226 code active 2007 Feb scouten 2007 Feb 5 4 Report on unused indices (and tables?) After exercising a particular database heavily, it would be nice to know which indices (and possibly tables) have not been used at all. #f2dcdc 2225 code active 2007 Feb scouten 2007 Feb 5 4 Request count of number of inserts and deletes from the free page list 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:_ {linebreak} The issue of database fragmentation is also addressed by ticket #2075 (a ticket which I had overlooked prior to today.) #f2dcdc 2224 new active 2007 Feb scouten 2007 Feb 4 4 Option to have one-bit "journal should exist" flag 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:_ {linebreak} 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. #f2dcdc 2222 build active 2007 Feb anonymous 2007 Feb 4 4 Type mismatch in fts2.c [5091] when compile as fastcall or stdcall 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 #f2dcdc 2221 new active 2007 Feb anonymous 2007 Feb drh 3 4 Store blobs using inode-like lookup of pages rather than linked list 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. #f2dcdc 2220 new active 2007 Feb anonymous 2007 Feb drh 2 4 fsck for database files 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. #f2dcdc 2219 code active 2007 Feb shess 2007 Feb shess 2 2 Creating an fts table in an attached database works wrong. 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. #f2dcdc 2218 code active 2007 Feb anonymous 2007 Feb 3 4 select columns from views with table prefix 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"! #cfe8bd 2217 code fixed 2007 Feb anonymous 2007 Feb pamg 1 2 Incorrect result after first deleting operation (PRAGMA count_changes) Hello, I have a same problem with sqlite. Can you help me? Attach contain minimal test program with my problem. Delete "test.db" file if it exists. 1) After creating database structure SQLite version 3.3.12 Enter ".help" for instructions sqlite> select * from rhAccountData; sqlite> select * from rhFolder; 1|0|Free sqlite> 2) After inserting one account row INSERT INTO rhAccountData VALUES(NULL,NULL,'Account'); SQLite version 3.3.12 Enter ".help" for instructions sqlite> select * from rhAccountData; 1|2|Account sqlite> select * from rhFolder; 1|0|Free 2|0|Account 3|2|First 4|2|Second 5|2|Third 6|2|Fourth sqlite> 3) After deleting one folder row with ROWID = 2 DELETE FROM rhFolder WHERE ROWID = 2; SQLite version 3.3.12 Enter ".help" for instructions sqlite> select * from rhAccountData; sqlite> select * from rhFolder; 2|0|Account >>> this ERROR: should be 1|0|Free sqlite> 4) If repeat INSERT INTO rhAccountData VALUES(NULL,NULL,'Account'); SQLite version 3.3.12 Enter ".help" for instructions sqlite> select * from rhAccountData; 1|3|Account sqlite> select * from rhFolder; 2|0|Account 3|0|Account 4|3|First 5|3|Second 6|3|Third 7|3|Fourth sqlite> 5) that after DELETE FROM rhFolder WHERE ROWID = 3; Result is correct SQLite version 3.3.12 Enter ".help" for instructions sqlite> select * from rhAccountData; sqlite> select * from rhFolder; 2|0|Account sqlite> Help me please, where I make mistake ? Best regards, Dmitriy Shadrin Used precopiled version sqlite3.dll for Windows from this site ---- _2007-Feb-06 07:28:10 by anonymous:_ {linebreak} If you remove "PRAGMA count_changes = 1;" you will get the results you expected. The presence of PRAGMA count_changes will change the result of your DELETE statement. BEGIN IMMEDIATE TRANSACTION; PRAGMA auto_vacuum = 1; PRAGMA count_changes = 1; -- comment out this line PRAGMA case_sensitive_like = 0; PRAGMA encoding = "UTF-16"; PRAGMA temp_store = FILE; CREATE TABLE rhFolder ( rhFolderId INTEGER PRIMARY KEY, rhOwnerId INTEGER, rhFolderName TEXT ); CREATE TABLE rhAccountData ( rhAccountId INTEGER PRIMARY KEY, rhFolderId INTEGER, rhAccountName TEXT ); INSERT INTO rhFolder VALUES(NULL,0,'Free'); CREATE TRIGGER fk_insert_AccountToFolder BEFORE INSERT ON rhAccountData FOR EACH ROW BEGIN INSERT INTO rhFolder VALUES(NULL,0,new.rhAccountName); END; CREATE TRIGGER fk_insert_after_AccountToFolder AFTER INSERT ON rhAccountData FOR EACH ROW BEGIN UPDATE rhAccountData SET rhFolderId = ( SELECT MAX(rhFolderId) FROM rhFolder) WHERE rhAccountId = (SELECT MAX(rhAccountId) FROM rhAccountData); INSERT INTO rhFolder VALUES ( NULL, (SELECT rhFolderId FROM rhAccountData WHERE rhAccountId = (SELECT MAX(rhAccountId) FROM rhAccountData)), 'First'); INSERT INTO rhFolder VALUES ( NULL, (SELECT rhFolderId FROM rhAccountData WHERE rhAccountId = (SELECT MAX(rhAccountId) FROM rhAccountData)), 'Second'); INSERT INTO rhFolder VALUES ( NULL, (SELECT rhFolderId FROM rhAccountData WHERE rhAccountId = (SELECT MAX(rhAccountId) FROM rhAccountData)), 'Third'); INSERT INTO rhFolder VALUES ( NULL, (SELECT rhFolderId FROM rhAccountData WHERE rhAccountId = (SELECT MAX(rhAccountId) FROM rhAccountData)), 'Fourth'); END; CREATE TRIGGER fk_delete_Folder BEFORE DELETE ON rhFolder FOR EACH ROW BEGIN DELETE FROM rhFolder WHERE rhOwnerId = OLD.rhFolderId; DELETE FROM rhAccountData WHERE rhFolderId = OLD.rhFolderId; END; COMMIT; INSERT INTO rhAccountData VALUES(NULL,NULL,'Account'); DELETE FROM rhFolder WHERE ROWID = 2; SELECT * FROM rhFolder; Result with "PRAGMA count_changes = 1": 2|0|Account Result without "PRAGMA count_changes = 1": 1|0|Free Is this behavior expected? The documentation states: PRAGMA count_changes; PRAGMA count_changes = 0 | 1; "Query or change the count-changes flag. Normally, when the count-changes flag is not set, INSERT, UPDATE and DELETE statements return no data. When count-changes is set, each of these commands returns a single row of data consisting of one integer value - the number of rows inserted, modified or deleted by the command. The returned change count does not include any insertions, modifications or deletions performed by triggers." ---- _2007-Feb-06 14:46:40 by anonymous:_ {linebreak} I believe that "PRAGMA count_changes = 1" should be a passive thing - it should not change the behavior of any DELETE or TRIGGER. This seems to be a bug. ---- _2007-Feb-07 01:53:29 by anonymous:_ {linebreak} Thanks for fast response! #cfe8bd 2216 code fixed 2007 Feb anonymous 2007 Feb 4 4 sqlite3ExprCompare() returns false for sqlite3ExprDup() result Should sqlite3ExprCompare() return true (meaning the same) for two expressions created with sqlite3ExprDup()? Currently it returns false if either expression has a Select component - event though sqlite3ExprDup() duplicates that component as well. Should a sqlite3SelectCompare() function be implemented? Not sure -- I got lost in the code trying to follow sqlite3ExprCompare()'s use, but thought it best to do a drive by bug report just in case. #f2dcdc 2215 code active 2007 Feb anonymous 2007 Feb 1 2 error messages in virtual table are not propagated 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; inConstraint; ++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 #f2dcdc 2214 code active 2007 Feb anonymous 2007 Feb 5 4 lemon generates bad error messages for %destructor 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 #c8c8c8 2213 code closed 2007 Feb danielk1977 2007 Feb danielk1977 1 1 Bug handling strings that are not nul-terminated. If a user-function has an sqlite3_value* containing a string that has a non-nul-terminated internal representation, multiple calls to sqlite3_value_text() may return distinct pointers. Calls to sqlite3_value_bytes() may also invalidate pointers returned by previous calls to sqlite3_value_text(). Compile and load the attached extension, then execute: SELECT user_function(user_function('hello')); an assert() fails if the bug exists. The bug is that the sqlite3VdbeMemNulTerminate() function is not setting the MEM_Term flag. #c8c8c8 2212 code closed 2007 Feb anonymous 2007 Feb 5 4 function request: sqlite3_bind_literal() The following idea just came to mind, as it would simplify some of my client code a bit: int sqlite3_bind_literal( sqlite3_stmt * st, int index, char const * str ); str is bound to the statement in an unquoted/unescaped fashion. The main use for this is to bind function calls or sqlite3 special var names, including NULL. e.g.: sqlite3_bind_literal( myStatement, 1, "current_timestamp" ); sqlite3_bind_literal( myStatement, 2, "some_function()" ); sqlite3_bind_literal( myStatement, 3, "NULL" ); Naturally, there should also be a sqlite3_bind_literal16() as well. :) ----- stephan at s11n dot net _2007-Feb-06 23:45:29 by drh:_ {linebreak} An interface such as requested above would required that the underlying bytecode for a statement be modified on the fly. Currently, the bytecode is generated once when sqlite3_prepare() is called and never changes thereafter. Changing the bytecode after the fact is both expensive and impractical. Better to rerun sqlite3_prepare(). #cfe8bd 2211 code fixed 2007 Feb anonymous 2007 Feb 1 3 select A.*, B.* from A join B where A.id=B.a_id order by A.id, B.value in sqlite 3.3.12, ORDER BY fails when the column is derived from a LEFT OUTER JOIN clause. This error does not exist in sqlite 3.2.7, but I have seen this issue in versions earlier than that so this is likely a re-introduction of an old issue. Create two tables with a parent-child foreign key relationship: create table A( id integer primary key, value varchar(30) ); create table B( id integer primary key, a_id integer references a(id), value varchar(30) ); insert data corresponding to two rows in A each with two child rows in B, where we will produce a reverse ordering of the "B" string values: insert into A values (1, 'Avalue1'); insert into A values (2, 'Avalue2'); insert into B values (1, 1, 'Bvalue4'); insert into B values (2, 1, 'Bvalue3'); insert into B values (3, 2, 'Bvalue2'); insert into B values (4, 2, 'Bvalue1'); Selecting from the join of A and B, ordering by both A.id and B.value produces the correct results: select A.*, B.* from A join B on A.id=B.a_id order by A.id, B.value; 1|Avalue1|2|1|Bvalue3 1|Avalue1|1|1|Bvalue4 2|Avalue2|4|2|Bvalue1 2|Avalue2|3|2|Bvalue2 changing the join to a LEFT OUTER join renders the "B.value" ordering not functional: select A.*, B.* from A left outer join B on A.id=B.a_id order by A.id, B.value; 1|Avalue1|1|1|Bvalue4 1|Avalue1|2|1|Bvalue3 2|Avalue2|3|2|Bvalue2 2|Avalue2|4|2|Bvalue1 the results for the above two queries should be identical (as they are in 3.2.7). _2007-Feb-04 19:29:07 by anonymous:_ {linebreak} Bug was apparently introduced between 3.3.8 and 3.3.9. This will produce the correct result: select A.*, B.* from A left outer join B on A.id=B.a_id order by +A.id, B.value; Also, if "INTEGER PRIMARY KEY" is not used, it produces the right result in latest CVS: CREATE TABLE A( id integer, value varchar(30) ); INSERT INTO "A" VALUES(1,'Avalue1'); INSERT INTO "A" VALUES(2,'Avalue2'); CREATE TABLE B( id integer, a_id integer references a(id), value varchar(30) ); INSERT INTO "B" VALUES(1,1,'Bvalue4'); INSERT INTO "B" VALUES(2,1,'Bvalue3'); INSERT INTO "B" VALUES(3,2,'Bvalue2'); INSERT INTO "B" VALUES(4,2,'Bvalue1'); select A.*, B.* from A left outer join B on A.id=B.a_id order by A.id, B.value; 1|Avalue1|2|1|Bvalue3 1|Avalue1|1|1|Bvalue4 2|Avalue2|4|2|Bvalue1 2|Avalue2|3|2|Bvalue2 Perhaps the checkin referred to by this change log caption may be related: "Optimizer does a better job of using indices to satisfy ORDER BY clauses that sort on the integer primary key". ---- _2007-Feb-04 19:33:17 by anonymous:_ {linebreak} Check-in [3536] The query optimizer does a better job of optimizing out ORDER BY clauses that contain the rowid or which use indices that contain the rowid. ---- _2007-Feb-05 13:16:25 by drh:_ {linebreak} The following script is sufficient to reproduce: CREATE TABLE t1(a INTEGER PRIMARY KEY, b); CREATE TABLE t2(x INTEGER PRIMARY KEY, y); INSERT INTO t1 VALUES(1,'one'); INSERT INTO t1 VALUES(2,'two'); INSERT INTO t2 VALUES(1,99); INSERT INTO t2 VALUES(2,88); SELECT * FROM t1 JOIN t2 ON a=x ORDER BY a,y; The theory that the problem was introduced by [3536] seems very likely to me. ---- _2007-Feb-05 22:33:12 by anonymous:_ {linebreak} Your test case returns the correct values in 3.3.12 and in the latest CVS. I do not believe it identifies the problem. Here's a better test case: CREATE TABLE t1(a INTEGER PRIMARY KEY, b); INSERT INTO "t1" VALUES(1,10); INSERT INTO "t1" VALUES(2,20); CREATE TABLE t2(x, y); INSERT INTO "t2" VALUES(1,5); INSERT INTO "t2" VALUES(1,3); INSERT INTO "t2" VALUES(1,4); select * from t1 left join t2 on a=x order by a,y; a|b|x|y 1|10|1|5 1|10|1|3 1|10|1|4 2|20|| select * from t1 left join t2 on a=x order by +a,y; a|b|x|y 1|10|1|3 1|10|1|4 1|10|1|5 2|20|| select sqlite_version(); 3.3.12 The patch in question makes the assumption that if an INTEGER PRIMARY KEY rowid is the first column then you can disregard all subsequent columns in the ORDER BY. But you cannot make this assumption with a LEFT JOIN for obvious reasons. #cfe8bd 2210 doc fixed 2007 Feb anonymous 2007 Feb 5 4 Typos in PRAGMA legacy_file_format; http://www.sqlite.org/pragma.html#modify 1) "...which might *to* be readable or writable by older versions..." Suspect we want "might not be" instead of "might to be". 2) "This flag only *effects* " Suspect "affects" was intended. 3) "It has no effect on databases that already *exists*." Suspect "exist" was intended. _submitted in attempt to be helpful -- and not in complaint._ #c8c8c8 2209 doc closed 2007 Feb anonymous 2007 Feb 5 5 Wrong Comment in the change #3622 In the change #3622 comment says: /* ** ** Changing this from a 64-bit to a 32-bit type limits the number of ** tables in a join to 32 instead of 64. But it also reduces the size ** of the library by 738 bytes on ix86. */ Is it OK in the coherency with : Allow up to 64 tables in a join (the number of bits in a long long int). The old limit was 32 tables. ?? _2007-Feb-01 13:54:43 by anonymous:_ {linebreak} The existing comment is correct and useful. It tells SQLite embedders how to reduce code size by limiting the number of tables in a join to 32, from the default of 64. #cfe8bd 2208 todo fixed 2007 Jan anonymous 2007 Feb 1 1 SQLite CVSTrac attachment corruption? The attachment http://www.sqlite.org/cvstrac/attach_get/311/patch-for-int32-support2.txt on the page http://www.sqlite.org/cvstrac/tktview?tn=2089 appears to be garbage. It used to work (i.e., be a well-formed downloable ASCII diff) when this ticket was first created. _2007-Jan-31 14:31:57 by anonymous:_ {linebreak} _(cpb here)_ Probably related to: http://www.cvstrac.org/cvstrac/tktview?tn=575 In a nutshell, it looks like there was something broken with either how the attachment was uploaded, CVSTrac 1.2.1 (or prior), the SQLite 2 database dump, the corresponding SQLite 3 import, or the attachment "encoded string" to BLOB conversion. Whichever one it is, the net effect is that a small number of attachments (nowhere near all of them) got truncated during the 2.0.0+ upgrade. I thought it was something in my test project because it didn't show up in my main development project. I'll need to look into it a bit, but reproducing it could be difficult at this point. ---- _2007-Jan-31 14:35:11 by anonymous:_ {linebreak} Hmmm... that's a whole lot worse than what ¤http://www.cvstrac.org/cvstrac/tktview?tn=575 talks about. I was getting truncation, not this wholesale corruption. ---- _2007-Jan-31 16:16:45 by anonymous:_ {linebreak} I can confirm that the attachments on the ticket in question were correct downloable files just after they were first posted. Unrelated CVSTrac issue: has the functionality surrounding Append Remarks changed? You get sent to the sqlite main page after answering the skill testing question instead of going to the append remarks screen. ---- _2007-Jan-31 16:38:46 by drh:_ {linebreak} I saved the V2 database from CVSTrac 1.2.1, so we should be able to recover the attachments. I'll get to that when I get a spare moment... ---- _2007-Jan-31 17:00:14 by anonymous:_ {linebreak} The attachment corruption is not isolated to just the original ticket. Here's another one: http://www.sqlite.org/cvstrac/tktview?tn=1924 http://www.sqlite.org/cvstrac/attach_get/274/sqlite337-union-and-constants-opt-v2.diff.txt ---- _2007-Jan-31 17:30:15 by anonymous:_ {linebreak} _(cpb, again)_ I've re-opened both {link:http://www.cvstrac.org/cvstrac/tktview?tn=575 #575} (attachment corruption) and {link:http://www.cvstrac.org/cvstrac/tktview?tn=617 #617} (captcha redirect). ---- _2007-Jan-31 23:48:12 by anonymous:_ {linebreak} Only thing I can think of is that there's an encoding conversion using =sqlite3_value_text()= where it should be =sqlite3_value_blob()=. {link:http://www.cvstrac.org/cvstrac/chngview?cn=930 [930]} will do the trick if that's the case. ---- _2007-Feb-11 10:50:10 by drh:_ {linebreak} When upgrading a CVSTrac database from version 1.2.1 to 2.0.x it is necessary to convert the attachments using the attachdump.c program found in the CVSTrac source tree. See http://www.cvstrac.org/cvstrac/chngview?cn=931 This has now been done. #f2dcdc 2204 new active 2007 Jan anonymous 2007 Feb 5 3 Stable, documented metadata interface 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:_ {linebreak} 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:_ {linebreak} Pragma table_info is documented at http://www.sqlite.org/pragma.html#schema ---- _2007-Jan-31 19:31:48 by anonymous:_ {linebreak} 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:_ {linebreak} 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). #cfe8bd 2201 code fixed 2007 Jan anonymous 2007 Feb 1 1 copy in tclsqlite doesn't work To reproduce: Do something like: sqlite3 db :memory: ..create tables etc and.. db copy replace mytable $filename ";" .. wont work. ---- Then, a fix: It seems there is likely old api being used for sqlite3_prepare.. attached is a diff to fix it, please include to cvs. #cfe8bd 2195 code fixed 2007 Jan anonymous 2007 Feb 1 3 OS X: "database locked" when trying to use a database on DVD-ROM Hi, I get the "Error: database is locked" when trying to do anything (select, pragma, getting file version etc) with a database stored on a DVD-ROM under OS X. This happens with the (fairly old) version 3.1.3 bundled with OS X, and also with the (less old) version 3.3.8 in a custom-built PHP interpreter. According to ktrace/kdump, just before printing the error sqlite tried a F_SETLK on the file, and got errno=45 Operation not supported. The DVD has an ISO filesystem on it (not HFS), IIRC it worked fine when we tried HFS (I did not try hybrid ISO/HFS). The Mac is a Macbook (intel processor). Suggestions for fixes: *: do not attempt to lock database files that do not have write permission *: also check for ENOTSUP everywhere EINVAL is checked after trying F_SETLK. Thanks, Julien Plissonneau Duquene _2007-Jan-26 19:25:41 by drh:_ {linebreak} Apple ships a customized version of SQLite with their OSes that (I believe) works around this problem by testing for what type of locks are supported on each volume and using the appropriate locking mechanism. You can enable this support by compiling with -DSQLITE_ENABLE_LOCKING_STYLE=1 We hope to enable this support by default in a future release, but it has not been testing on non-OS-X systems yet so that will have to wait. ---- _2007-Feb-02 19:02:54 by anonymous:_ {linebreak} Hi, More details on this one: The problem only shows on ISO 9660 rock ridge images, there is no locking problem at all on iso9660 non-RR images. The version 3.1.3 that Apple bundles with Mac OS 10.4 has the problem too. I tested 3.3.12 with -DSQLITE_ENABLE_LOCKING_STYLE=1 and it works around the issue. I still think that testing for ENOTSUP would solve that particular problem faster in the mainstream code, since SQLITE_ENABLE_LOCKING_STYLE uses statfs() which is not standardized across platforms, and problems begin at #include ... #f2dcdc 2075 code active 2006 Nov anonymous 2007 Feb 3 3 Improve VACUUM speed and INDEX page locality 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} Any harm in checking in the simple patch above for the 3.3.13 release? ---- _2007-Feb-13 12:51:47 by drh:_ {linebreak} 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:_ {linebreak} 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 #f2dcdc 2060 code active 2006 Nov anonymous 2007 Feb 1 1 Table references enclosed in parenthesis become "invisible" 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 1966 build closed 2006 Sep anonymous Unknown 2007 Feb 3 4 Add a --disable-readline option to configure The configure script assumes that there is a version of readline available. It does some searching to find readline and will only decide that there is no readline and set TARGET_HAVE_READLINE to 0 if it fails the search. This does not work when cross-compiling because the checks it does to find readline fail when cross-compiling. I would like a --disable-readline (or --without-readline) option to configure that skips all the checks and just sets TARGET_HAVE_READLINE to 0. I have attached a possible implementation, but I can't seem to test it because the configure fails for me if I run autoconf. _2006-Sep-08 18:07:43 by drh:_ {linebreak} See my comment on check-in [3307]: I recently upgraded to SuSE 10.2 and now autoconf is busted on my system. Hence, I cannot regenerate the configure script from the configure.ac file. I'll keep you patched configure.ac around, but for the time being there is nothing I can do with it. Sorry. ---- _2007-Feb-17 11:16:06 by vapier:_ {linebreak} i've posted a patch to the mailing list to clean up the readline handling http://thread.gmane.org/gmane.comp.db.sqlite.general/26261 ... which is now merged into cvs #c8c8c8 1545 build closed 2005 Nov anonymous Shell 2007 Feb 4 4 Solaris systems require -lrt to link sqlite3 sqlite3 fails to build on solaris 8 with a link error. The name fdatasync is not found. This is because on solaris systems fdatasync requires a -lrt switch on the link command, because the name is declared in librt.so while on linux it's in libc.so _2005-Dec-28 00:22:56 by anonymous:_ {linebreak} I ran in to the same problem on Solaris 8 with version 3.2.8. I have a patch to configure.ac and Makefile.in that fixed the problem, but I'm not sure how best to submit them. You can contact me via email if you want the patch. Thanks, Tim Mooney Tim.Mooney@ndsu.edu ---- _2005-Dec-28 01:01:27 by anonymous:_ {linebreak} Use the "Attach" link above to attach your patch to this ticket. {link: attach_add?tn=1545 Here's} a direct link to do the same. ---- _2007-Feb-17 14:56:09 by vapier:_ {linebreak} this should be fixed in current cvs: AC_SEARCH_LIBS(fdatasync, [rt]) #f2dcdc 2206 new active 2007 Jan anonymous 2007 Jan 5 4 Support for foreign key constraints in virtual tables 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. #f2dcdc 2205 build active 2007 Jan anonymous 2007 Jan anonymous 1 1 Problem while using with tcl on ARM 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. #f2dcdc 2203 code active 2007 Jan anonymous 2007 Jan 2 3 table_info pragma "default" column format changed? 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:_ {linebreak} One of your fellow Railers requested this change: Ticket #2078 ---- _2007-Jan-29 22:10:55 by drh:_ {linebreak} See also ticket #1919 which might also be an issue here. ---- _2007-Jan-29 22:33:19 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 2202 new active 2007 Jan anonymous 2007 Jan 5 4 function request: sqlite3_attach() 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. #f2dcdc 2200 new active 2007 Jan anonymous 2007 Jan 5 4 threadsafe status not reported in .pc file 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 #f2dcdc 2199 build active 2007 Jan anonymous 2007 Jan 1 1 configure doesn't find libreadline if its in uncommon place 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 #f2dcdc 2198 new active 2007 Jan anonymous 2007 Jan 5 4 API: opening only existing databases 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):{linebreak} create_or_access_existing -- works in both cases{linebreak} 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. #c8c8c8 2197 code closed 2007 Jan anonymous 2007 Jan 4 5 invalid(?) join syntax results in runnable sql code While learning about JOINs from this page: http://en.wikipedia.org/wiki/Join_(SQL) i think i quite accidentally found a bug in sqlite3. First, the tables: stephan@owl:~/tmp> sqlite3 foo.db SQLite version 3.3.11 Enter ".help" for instructions sqlite> create table em (name,dept); sqlite> create table dept(name,id); sqlite> insert into dept values('Sales',31); sqlite> insert into dept values('Engineering',33); sqlite> insert into dept values('Clerical',34); sqlite> insert into dept values('Marketing',35); sqlite> insert into em values('Smith',34); sqlite> insert into em values('Jones','33'); sqlite> insert into em values('Robinson',34); sqlite> insert into em values('Jasper',36); sqlite> insert into em values('Steinberg', 33); sqlite> insert into em values('Rafferty',31); Now the query as it SHOULD be: sqlite> select em.name,dept.name from em inner join dept on em.dept = dept.id; Smith Clerical Robinson Clerical Steinberg Engineering Rafferty Sales No problem, of course However, the first time i entered the query i made what would appear to be a gross syntactical mistake, but it still runs with the same results as above: sqlite> select em.name,dept.name from em inner join dept on dept where em.dept = dept.id; Smith Clerical Robinson Clerical Steinberg Engineering Rafferty Sales The erroneous part is the extra stuff around 'inner join dept on dept where...'. Maybe this is a bug, maybe not. If it is, i suspect that the fix lies in parser.y. If it's not a bug, then let's just call it a fluke or a misunderstanding on my part and close this ticket. :) ----- stephan (stephan at s11n dot net) _2007-Jan-27 02:22:38 by drh:_ {linebreak} By virtue of the fact that "dept" is a unique column name within the query and the value of "dept" is always true, the query with the wrong syntax really is valid SQL and really does do the same thing as the correctly formatted query. This is not a bug. #c8c8c8 2196 code closed 2007 Jan anonymous 2007 Jan 5 3 Bug in PRAGMA full_column_names with SELECT * SQLite version 3.3.11{linebreak} Enter ".help" for instructions{linebreak} sqlite> pragma full_column_names;{linebreak} 0{linebreak} sqlite> pragma full_column_names=1;{linebreak} sqlite> pragma full_column_names;{linebreak} 1{linebreak} sqlite> .headers on{linebreak} sqlite> create table t(a);{linebreak} sqlite> insert into t values ('hello');{linebreak} sqlite> select a from t;{linebreak} t.a{linebreak} hello{linebreak} sqlite> select * from t;{linebreak} a{linebreak} hello{linebreak} sqlite>{linebreak} Shouldn't that last query's column be "t.a"? _2007-Jan-26 23:19:38 by anonymous:_ {linebreak} You need both: PRAGMA full_column_names=1; and PRAGMA short_column_names=0; It doesn't make any sense to me either. ---- _2007-Jan-27 00:10:42 by drh:_ {linebreak} The current behavior is for backward compatibility issues going back to the 2.1 series. #cfe8bd 2194 code fixed 2007 Jan anonymous 2007 Jan 4 4 possible multiple inclusion with vdbeInt.h header file vdbeInt.h should have #if to prevent multiple inclusion. #ifndef _VDBEINT_H_ #define _VDBEINT_H_ : : : #endif _2007-Jan-26 15:42:35 by drh:_ {linebreak} Why? vdbeInt.h is not #include-ed multiple times anywhere in the core source code and it is not intended for external use. Providing protection from multiple inclusions seems pointless. ---- _2007-Jan-26 19:59:37 by anonymous:_ {linebreak} In order to get a slight speed improvement (~2%), I created a single .c file that #included all the other .c files (this gives the compiler more chances for optimization). The vbdeInt.h thus got included multiple times, and was hoping to be able to avoid having to make this change with every release. ---- _2007-Jan-26 21:07:37 by drh:_ {linebreak} OK, that is something I've never thought of before. But it makes sense. #cfe8bd 2193 code fixed 2007 Jan anonymous 2007 Jan 4 4 incorrect prototypes in tokenize.c in file tokenize.c in function sqlite3RunParser() the prototypes: extern void *sqlite3ParserAlloc(void*(*)(int)); extern int sqlite3Parser(void*, int, Token, Parse*); should be: extern void *sqlite3ParserAlloc(void*(*)(size_t)); extern void sqlite3Parser(void*, int, Token, Parse*); as this is how they are implemented in parse.c. #cfe8bd 2192 code fixed 2007 Jan drh 2007 Jan 1 1 Assertion fault on a deeply nested view The following script causes a assertion fault in the code generator for compound SELECT statements:
 -- Raw data (RBS) --------  create table records (   date          real,   type          text,   description   text,   value         integer,   acc_name      text,   acc_no        text );  -- Direct Debits ---------------- create view direct_debits as   select * from records where type = 'D/D';  create view monthly_direct_debits as   select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value     from direct_debits    group by strftime('%Y-%m', date);  -- Expense Categories --------------- create view energy as   select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value     from direct_debits    where description like '%NPOWER%'    group by strftime('%Y-%m', date);  create view phone_internet as   select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value     from direct_debits    where description like '%BT DIRECT%'       or description like '%SUPANET%'       or description like '%ORANGE%'    group by strftime('%Y-%m', date);  create view credit_cards as   select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value     from direct_debits where description like '%VISA%'    group by strftime('%Y-%m', date);  -- Overview ---------------------  create view expense_overview as   select 'Energy' as expense, date, value from energy   union   select 'Phone/Internet' as expense, date, value from phone_internet   union   select 'Credit Card' as expense, date, value from credit_cards;  create view jan as   select 'jan', expense, value from expense_overview where date like '%-01';  create view nov as   select 'nov', expense, value from expense_overview where date like '%-11';  create view summary as   select * from jan join nov on (jan.expense = nov.expense);  -- This causes a segfault select * from summary; 
This problem was found by Andy Chambers and reported on the SQLite mailing list. _2007-Jan-26 15:05:54 by drh:_ {linebreak} Simpler test case:
 CREATE TABLE t1(a,b); CREATE VIEW v1 AS   SELECT * FROM t1 WHERE b%7=0 UNION SELECT * FROM t1 WHERE b%5=0; CREATE VIEW v2 AS SELECT * FROM v1 WHERE b%2==0; CREATE VIEW v3 AS SELECT * FROM v1 WHERE b%3==0; CREATE VIEW v4 AS SELECT * FROM v2 JOIN v3 ON v2.a=v3.a; SELECT * FROM v4; 
---- _2007-Jan-26 15:16:57 by drh:_ {linebreak} An even simpler example: CREATE TABLE t1(a,b); CREATE VIEW v1 AS SELECT * FROM t1 WHERE b%7=0 UNION SELECT * FROM t1 WHERE b%5=0; CREATE VIEW v2 AS SELECT * FROM v1 AS x JOIN v1 AS y ON x.a=y.a; SELECT * FROM v2; The problem appears to be that we are trying to compile the SELECT of the inner view (the v1 view) twice. ---- _2007-Jan-26 17:46:53 by anonymous:_ {linebreak} Any chance of doing the parse tree resolution (i.e., sqlite3SelectResolve()) on all the nodes in the entire tree recursively before _any_ VDBE opcodes are generated? This would greatly simplify adding new SQL source-level optimization passes to SQLite. #cfe8bd 2191 code fixed 2007 Jan anonymous 2007 Jan 4 3 Minor C++/C linkage compatibility issue in sqlite3.h The sqlite3.h file defines SQLITE_STATIC and SQLITE_TRANSIENT as macros which then expand in their usage context, giving the function pointer types linkage which depends on whether they're in an extern "C" block or not when used from C++ code. The patch below adds a typedef to ensure that these are pointers to "C" functions, and hence makes them usable directly from portable C++ code. Sun CC and Comeau's C++ compiler both issue warnings/errors about normal uses of SQLITE_STATIC and SQLITE_TRANSIENT from C++ code with the current distribution version of sqlite3.h. This was covered in the mailing list in the thread "Fix for sqlite3.h in version 3.3.10". --- sqlite3.h.dist Fri Jan 19 11:58:35 2007 +++ sqlite3.h Fri Jan 19 12:00:40 2007 @@ -1186,8 +1186,9 @@ ** the near future and that SQLite should make its own private copy of ** the content before returning. */ -#define SQLITE_STATIC ((void(*)(void *))0) -#define SQLITE_TRANSIENT ((void(*)(void *))-1) +typedef void (*sqlite3_destructor_type)(void*); +#define SQLITE_STATIC ((sqlite3_destructor_type)0) +#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) /* ** User-defined functions invoke the following routines in order to #c8c8c8 2190 code closed 2007 Jan anonymous 2007 Jan 3 4 bogus lines on "left join" with a "where right_table.column is NULL" Refer to the attached file left_join_bug.sql for the following discussion. When I run sqlite3 on this script, I get this output: shell-prompt> /usr/mbench2.2-nightly/bin/sqlite3 Clearly, the last line ("both|default both||") is bogus. A left join on the my_key column being equal will produce a line both|default both|both|current both And the "WHERE current_settings.my_key IS NULL" clause should exclude that line, resulting in no "both" line. Change the "IS NULL" to "IS NOT NULL", or get rid of the WHERE clause altogether, and you get the expected output, containing one "both" line with no null values. Just to check that it wasn't me misunderstanding what should happen, I ran the same script through mysql. Results were as expected; no "both" line: shell-prompt> mysql --version mysql Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i686) using readline 4.3 shell-prompt> mysql -D test I built the binary myself from the sqlite-3.3.10.tar.gz tarball I downloaded from your site. Built on CentOS 4.4 thusly: shell-prompt> configure --prefix=/my/path --disable-tcl && make && make install I have a workaround. I was wanting to use the SELECT statement in the script as part of a larger statement. I wanted to select my_key and my_value out of both tables such that any my_key value that occurred in either table would show up exactly once. If the my_key value occurred in the current_settings table, then (regardless of what was in default_settings), current_settings.my_value would be chosen. Otherwise, default_settings.my_value would be chosen. A left-join statement that should yield these results would be: SELECT * FROM current_settings UNION SELECT default_settings.* FROM default_settings LEFT JOIN current_settings ON default_settings.my_key = current_settings.my_key WHERE current_settings.my_key IS NULL; However, because of the cited bug, this statement results in a line from each table whenever a my_key occurs in both, instead of just the one from current_settings. The workaround is to use a sub-select, thusly: SELECT * FROM current_settings UNION SELECT * FROM default_settings WHERE my_key NOT IN (SELECT my_key FROM current_settings); This works correctly. So I'm ok for now. This appears to a duplicate of ticket #2189. #cfe8bd 2189 code fixed 2007 Jan anonymous 2007 Jan 1 4 Incorrect results on LEFT JOINs with IS NULL condition in WHERE clause Incorrect results are produced by LEFT JOINs that included in the WHERE clause an IS NULL constraint for the right table of the LEFT JOIN (bug seems to be not completely fixed in 3.3.11). Steps to reproduce the problem: C:\Temp>sqlite3 test1.db{linebreak} SQLite version 3.3.11{linebreak} Enter ".help" for instructions{linebreak} sqlite> CREATE TABLE test(col1 TEXT PRIMARY KEY COLLATE NOCASE);{linebreak} sqlite> INSERT INTO test(col1) values('a');{linebreak} sqlite> INSERT INTO test(col1) values('b');{linebreak} sqlite> INSERT INTO test(col1) values('c');{linebreak} sqlite> CREATE TABLE test2(col1 TEXT PRIMARY KEY COLLATE NOCASE);{linebreak} sqlite> INSERT INTO test2(col1) values('a');{linebreak} sqlite> INSERT INTO test2(col1) values('b');{linebreak} sqlite> INSERT INTO test2(col1) values('c');{linebreak} sqlite> SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1 WHERE t2.col1 IS NULL;{linebreak} a|{linebreak} b|{linebreak} c|{linebreak} and the last result is incorrect, since no rows should be returned. _2007-Jan-25 14:25:13 by anonymous:_ {linebreak} Is there a way to get SQLite to disable certain optimizations via a PRAGMA? #f2dcdc 2188 doc active 2007 Jan anonymous 2007 Jan 5 4 Doc bug in src/vdbe.c, should s/P1/P2/ in NotFound # 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 #f2dcdc 2187 todo active 2007 Jan anonymous 2007 Jan 3 4 RAISE in trigger not being caught by CONFLICT clause in calling SQL 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);{linebreak} CREATE TRIGGER abc_insert BEFORE INSERT ON abc BEGIN{linebreak} SELECT CASE WHEN (new.a > 2) THEN{linebreak} RAISE(ABORT, 'error here'){linebreak} END;{linebreak} END;{linebreak} BEGIN;{linebreak} INSERT INTO abc VALUES (1);{linebreak} -- This should raise error but not rollback{linebreak} INSERT INTO abc VALUES (4);{linebreak} -- This should raise error and rollback{linebreak} INSERT OR ROLLBACK INTO abc VALUES (4);{linebreak} -- Check to see if ROLLBACK performed (which it hasn't){linebreak} SELECT * FROM abc;{linebreak} #c8c8c8 2186 code closed 2007 Jan anonymous 2007 Jan drh 1 1 database seems to be corrupted during a huge transaction During a huge transaction delete, update and insert of some records fails. In this transaction schema changes are done too (in this concrete example in one column of a table null values are allowed - nothing more). On delete and update some records could not be found (but they definitly exist!). On insert an error code is returned that says that the record already exists (but it does definitly not!). There are a few hundred thousands of deletes, updates and inserts in that transaction, but it already fails after a few thousand operations. We tested the operations without opening a transaction and they succeeded. _2007-Jan-23 13:45:53 by drh:_ {linebreak} Does the database really go corrupt? What happens when you enter PRAGMA integrity_check; after the incident you describe? What errors do you get? Is this reproducible? If so, can you send in a script that will reproduce the problem? Without information on how we might reproduce the problem, it will be difficult to fix. ---- _2007-Jan-24 18:15:46 by drh:_ {linebreak} The person who originally reported this bug now says that the problem was an application error. #f2dcdc 2185 new active 2007 Jan anonymous 2007 Jan 5 3 API access to opened database pathname - helpful for virtual tables 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. #cfe8bd 2184 code fixed 2007 Jan anonymous 2007 Jan drh 1 1 OMIT_SHARED_CACHE: missing #define in loadext.c The following #define seems to be missing from loadext.c to make SQLite compile successfully with -DSQLITE_OMIT_SHARED_CACHE: #ifdef SQLITE_OMIT_SHARED_CACHE # define sqlite3_enable_shared_cache 0 #endif _2007-Jan-22 21:06:29 by anonymous:_ {linebreak} same as #2069 not corrected. #f2dcdc 2183 code active 2007 Jan anonymous 2007 Jan drh 1 1 OMIT_SHARED_CACHE: AV and crash with FTS2 INSERT 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? #f2dcdc 2182 code active 2007 Jan anonymous 2007 Jan 4 4 sqlite3BtreeGetMeta does not check the file format =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:_ {linebreak} (Submitter:) Is there a reason why the file format check doesn't happen in sqlite3_open? #f2dcdc 2181 new active 2007 Jan anonymous 2007 Jan 5 4 Generalize ON CONFLICT to failure trapping for all SQL statements (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. #f2dcdc 2180 new active 2007 Jan anonymous 2007 Jan 5 4 feature request: DROP TABLE IF [EXISTS AND] EMPTY 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:_ {linebreak} 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 #c8c8c8 2179 new closed 2007 Jan anonymous 2007 Jan 4 1 Odbc driver for sqlite takes more time in executing a query. I developed an application for testing the execution time of an query between MS-ACCESS and Sqlite. 1.Sqlite databse when it is accessed through ODBC driver(sqliteodbc.exe), an execution of a query takes 19 secs. 2.when the same query is executed directly(using sqlite3.dll) it takes less than a second. how can i make Odbc driver perform in similar way(fast). Waiting for ur reply at vipul.dpatel@patni.com Regards, Vipul Patel Please send general SQLite questions to the mailing list. #cfe8bd 2177 code fixed 2007 Jan anonymous 2007 Jan 1 3 The same query returns different answers between 3.3.7 and 3.3.9 Using sqlite 3.3.7, the following query returns 984 (which is correct). Using sqlite 3.3.9 or later, the same query returns 10552 (which is wrong!). Here is the query: select count(*) from category left outer join smaincategory on category.category_id = smaincategory.category_id where smaincategory.sma_id is null; The database in question is available at: http://branewave.com/metadata.db.gz (gzipped). It was created using sqlite 3.3.7 (perl DBD::SQLite 1.13). _2007-Jan-18 22:03:31 by drh:_ {linebreak} The change in behavior occured at checkin [3494] which was an enhancements to allow the IS NULL operator to use indices. Investigation is ongoing. ---- _2007-Jan-18 22:55:20 by anonymous:_ {linebreak} Is there a workaround (an equivalent way to write the same query), or am I stuck reverting to 3.3.7? ---- _2007-Jan-18 23:04:54 by drh:_ {linebreak} I'll fix the problem in version 3.3.11 which should be out next week. In the meantime, you can say: +smaincategory.sma_id is null Instead of smaincategory.sma_id as null To work around the problem. The difference is the added unary "+" operator in front of the column name. ---- _2007-Jan-19 15:55:29 by anonymous:_ {linebreak} Cool. Thanks for your quick response! #cfe8bd 2176 code fixed 2007 Jan anonymous 2007 Jan drh 1 2 integrity check can take very long time on large corrupted db Details: File was corrupted after power failure :( 1. File size 898 Mb 2. sCheck.nPage = 898218 in function sqlite3BtreeIntegrityCheck 3. OS - Windows Symptoms 1. After ~20 minutes 198000 pages checked for reference 2. Number of Page Faults in Task Manager increases rapidly My assumption is that cause for this is too many memory reallocations in the call to the checkAppendMsg(&sCheck, 0, "Page %d is never used", i); Suggestion: Stop integrity check after certain number of errors detected. _2007-Jan-20 01:37:44 by anonymous:_ {linebreak} Fixed in the following way typedef struct IntegrityCk IntegrityCk; struct IntegrityCk { BtShared *pBt; /* The tree being checked out */ Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ int nPage; /* Number of pages in the database */ int *anRef; /* Number of times each page is referenced */ char *zErrMsg; /* An error message. NULL of no errors seen. */ int nErrors; /* Number of errors */ }; #ifndef SQLITE_OMIT_INTEGRITY_CHECK #define SQLITE_MAX_ERRORS_REPORTED 1000 /* ** Append a message to the error message string. */ static void checkAppendMsg( IntegrityCk *pCheck, char *zMsg1, const char *zFormat, ... ){ va_list ap; char *zMsg2; if( pCheck->nErrors > SQLITE_MAX_ERRORS_REPORTED ){ // [TIK] Do not report too much errors return; } pCheck->nErrors++; if( pCheck->nErrors > SQLITE_MAX_ERRORS_REPORTED ){ zFormat = "Integrity check - too many errors has been detected, diagnostics is stopped"; zMsg1 = ""; } ---- _2007-Jan-20 16:40:01 by anonymous:_ {linebreak} Does this database corruption happen very often? It may be symptom of an undiagnosed problem; i.e., fsync() does not work on your platform. ---- _2007-Jan-24 01:55:18 by anonymous:_ {linebreak} No, data loss in this case is major but not a critical issue. Db configured to work with PRAGMA synchronous=OFF. Practically this happened once during total power failure. The problems is that application was not started after power was restored, because it was delayed during attempt to verify integrity. #c8c8c8 2174 code closed 2007 Jan anonymous 2007 Jan anonymous 2 3 DBD::SQLite does not return number of rows affected. Count(XXX) OK Using DBD:SQlite perl interface, the number of affected rows is not returned as for the other DBD interfaces. I will investigate if it is the perl side (I have reason to think not). The call returns 0E0 which means "ok, but no rows" but an explicit "select Count(XXX)" returns the correct value. I will return to make a comment if I find it is infact the perl side Many Thanks _2007-Jan-17 09:24:56 by anonymous:_ First ask newsgroup and Perl group. #cfe8bd 2172 code fixed 2007 Jan anonymous 2007 Jan 5 1 crash when lemon (wireshark) is built with -DNDEBUG A bug reported at http:/7wireshark.org in Lemon. I'm unsure if the fix is correct so asking you to have a look. "The exact version is what Gentoo calls wireshark-0.99.2. The exact system is Gentoo Linux 64-bit (amd64). I generally compile with -DNDEBUG defined in CFLAGS. After building Wireshark, it would immediately seg-fault. I knew it had to be me, since none of you wouldn't release software that didn't work at all. :) It appears that the code in tools/lemon/lempar.c that does this: memset(&yygotominor, 0, sizeof(yygotominor)); is needed for more than debugging. I am not 100% sure, but I think leaving out the memset opens the door for some kind of bad data in the other NDEBUG section in lempar.c where: yymsp->minor = yygotominor I fixed it by removing the NDEBUG ifdefs from the memset. Patch will be attached." http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1011 _2007-Jan-16 21:51:21 by anonymous:_ {linebreak} This is just a guess, but the reported bug might be the result of an error in the grammar in =epan/dfilter/grammar.lemon= . In that file, the non-terminal =sentence= (which is the start non-terminal) is declared as having a type and a destructor, but the productions for =sentence= do not create any value. Consequently, without the =memset=, the associated value of the non-terminal will be garbage, which might well cause havoc when the destructor is called in =yy_accept=. lemon checks to make sure that a labeled lhs is assigned to, but does not check that an unlabeled lhs does not have a destructor; consequently, errors of that form are not flagged. It would be easy enough to generate an error message. For example, at around line 3277, along with the check to make sure lhsalias's are used, a check could be added for =!rp->lhsalias && has_destructor( rp->lhs, lemp)=. It would also be good to check that either all or no productions for a non-terminal are labeled; I'll attach a patch a bit later on if I can come up with a good one and nobody gets there before me. -- Rici ---- _2007-Jan-17 16:19:58 by anonymous:_ {linebreak} The patch (not tested very vigorously) is at http://primero.ricilake.net/lemon/lemon.checklhs.patch It correctly picks up the error in wireshark/epan/dfilter/grammar.lemon: wsgrammar.lemon:124: Rule does not generate a value, but non-terminal sentence wsgrammar.lemon:124: has a destructor wsgrammar.lemon:125: Rule does not generate a value, but non-terminal sentence wsgrammar.lemon:125: has a destructor #e8e8bd 2171 code review 2007 Jan anonymous 2007 Jan drh 3 3 Fix a major leakage of token minors in lemon generated parsers Fix a major leakage of token minors in lemon generated parsers due to the fact that lemon was not genmerating destructor code for elements in the RHS of rules without C-code. This is a copy of a fix mafe to the lemon parser used by the wireshark project http://wireshark.org http://anonsvn.wireshark.org/viewvc/viewvc.py/trunk/tools/lemon/lemon.c?r1=20442&r2=20441&pathrev=20442
 --- trunk/tools/lemon/lemon.c 2007/01/15 19:11:29 20441 +++ trunk/tools/lemon/lemon.c 2007/01/15 19:48:06 20442 @@ -3245,6 +3245,8 @@    for(i=0; inrhs; i++) used[i] = 0;    lhsused = 0;  +  if (! rp->code) rp->code = "\n"; +    append_str(0,0,0,0);    for(cp=rp->code; *cp; cp++){      if( safe_isalpha(*cp) && (cp==rp->code || (!safe_isalnum(cp[-1]) && cp[-1]!='_')) ){ @@ -3875,7 +3877,7 @@     /* Generate code which execution during each REDUCE action */    for(rp=lemp->rule; rp; rp=rp->next){ -    if( rp->code ) translate_code(lemp, rp); +  translate_code(lemp, rp);    }    for(rp=lemp->rule; rp; rp=rp->next){      struct rule *rp2; 
It appears that the change in [3593] causes yy_destructor() to be called more than once for tokens, while the one posted here (and applied to wireshark) does not. in the meanwhile I changed the wireshark copy back to have
 if (! rp->code)  rp->code = "\n";     append_str(0,0,0,0);    for(cp=rp->code; *cp; cp++){ 
but there's an issue with this the, generated parser gets
 #line 0 "./dtd_grammar.lemon" 
instead of the number pointing to the line where the rule is. I'll keep investigating and keep you POSTed (literally :-) #f2dcdc 2167 new active 2007 Jan anonymous 2007 Jan 1 3 add sqlite3_copy_bindings (parallel to sqlite3_transfer_bindings) 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. #cfe8bd 2166 code fixed 2007 Jan shess 2007 Jan shess 2 3 fts modules corrupt data during UPDATE. In fts1.c (or fts2.c) index_update(), insertTerms() is called before content_update(). insertTerms() calls sqlite3_value_text() on the inputs, which destructively converts UTF16 to UTF8. Then content_update() is called to write to the content table, and it writes the UTF8, even if the database is in UTF16 form. As far as I can tell, the value's encoding is updated correctly, so this seems like it simply shouldn't be possible. _2007-Jan-13 00:47:45 by shess:_ {linebreak} Simple patch to fts1.c to work around the bug: Index: ext/fts1/fts1.c =================================================================== RCS file: /sqlite/sqlite/ext/fts1/fts1.c,v retrieving revision 1.38 diff -u -d -r1.38 fts1.c --- ext/fts1/fts1.c 10 Oct 2006 23:22:41 -0000 1.38 +++ ext/fts1/fts1.c 13 Jan 2007 00:47:21 -0000 @@ -3082,11 +3082,11 @@ int rc = deleteTerms(v, pTerms, iRow); if( rc!=SQLITE_OK ) return rc; - /* Now add positions for terms which appear in the updated row. */ - rc = insertTerms(v, pTerms, iRow, pValues); + rc = content_update(v, pValues, iRow); /* execute an SQL UPDATE */ if( rc!=SQLITE_OK ) return rc; - return content_update(v, pValues, iRow); /* execute an SQL UPDATE */ + /* Now add positions for terms which appear in the updated row. */ + return insertTerms(v, pTerms, iRow, pValues); } /* This function implements the xUpdate callback; it's the top-level entry #f2dcdc 2165 code active 2007 Jan anonymous 2007 Jan drh 4 3 pager performance and checksum 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:_ {linebreak} 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; } #cfe8bd 2164 code fixed 2007 Jan anonymous 2007 Jan 4 5 Possibly a typo in lemon.c line 3628 of lemon.c: if( action<0 ) action = lemp->nsymbol + lemp->nrule + 2; Should this not be lemp->nstate + lemp->nrule + 2 ? I presume the intent is to output YY_NO_ACTION, rather than some fairly random number. It doesn't seem to make any difference to the functioning of any parser I've tried, though, presumably because it is always (usually?) combined with a lookahead of lemp->nsymbol, which doesn't correspond with any input symbol. Speaking of lemp->nsymbol, that lookahead value is one less than YYNOCODE, although one might expect them to be the same. As far as I can see, it is impossible for a lookahead of YYNOCODE to ever be provided to yy_find_shift_action or yy_find_reduce_action. I don't suppose that's a problem either, but I'm not sure what the intention was, exactly. By the way, I was working on adding yacc-style mid-rule actions to lemon. If you're interested in the code, let me know and I'll backport it to your version. #cfe8bd 2163 code fixed 2007 Jan anonymous 2007 Jan drh 4 3 AreFileApisANSI does not exist in Windows CE My apologies for not catching this sooner from the CVS sources, but the Windows API function AreFileApisANSI() does not exist in Windows CE.{linebreak}{linebreak} I temporarily resolved the issue by adding{linebreak} #define AreFileApisANSI() 1 {linebreak} to the os_win.c file sandwiched between on of the existing{linebreak} #if defined(_WIN32_WCE) {linebreak} blocks. #c8c8c8 2162 code closed 2007 Jan anonymous 2007 Jan 1 1 c code compile fails with "Undefined reference to sqlite3_open()" Hi, I am new to sqlite. My environment is MinGw C compiler, Msys and sqlite3. When I try compiling my c code, I get the following error. "Undefined reference to sqlite3_open()" "Undefined reference to sqlite3_close()" "Undefined reference to sqlite3_exec()" I followed the following steps to install. 1. Download mingw from www.mingw.org 2. Get the sqlite3 source tree 3. Get the makefile attached to #931 4. Make sure you have 'gawk', 'sed' and 'grep' (call grep ggrep, or edit the makefile). Also get upx and install it. 5. Type 'make'. Thanks _2007-Jan-10 18:57:43 by drh:_ {linebreak} Please seek help with project or compiler issues on the sqlite users mailing list. Tickets are for reporting bugs in SQLite itself. #cfe8bd 2161 doc fixed 2007 Jan anonymous 2007 Jan 4 4 Typo in Documentation for callback to sqlite3_exec The description of the callback used in sqlite3_exec reads (in the header file and in the web documentation as well): The 4th parameter is an arbitrary pointer that is passed to the callback function as its first parameter It should read of course The 1st parameter is an arbitrary pointer ... #cfe8bd 2160 doc fixed 2007 Jan anonymous 2007 Jan 4 4 documentation for busy callback wrong In sqlite3.h the paragraph that describes the busy callback reads: If the busy callback is not NULL, then sqlite3_exec() invokes the callback with three arguments. The second argument is the name of the locked table and the third argument is the number of times the table has been busy. It should read If the busy callback is not NULL, then sqlite3_exec invokes the callback with two arguments. The first one is the one given when registering the busy handler (third argument to sqlite3_busy_handler). The second one is the number of times the table has been busy. #cfe8bd 2159 build fixed 2007 Jan anonymous 2007 Jan pweilbacher 3 4 Interrupt OpenWatcom lang. ext. and sqlite3ext.h interrupt, _interrupt, and __interrupt are all OpenWatcom C language extensions. They are expanded to __interrupt which sqlite3__interrupt isn't part of the sqlite3 API. The fix is to test for the compiler (if it is __WATCOMC__) and interrupt is defined. undef interrupt upon a true condition. Diff follows: {linebreak} Index: src/sqlite3ext.h {linebreak} --- src/sqlite3ext.h (revision 46) {linebreak} +++ src/sqlite3ext.h (working copy) {linebreak} @@ -12,7 +12,7 @@ {linebreak} ** This header file defines the SQLite interface for use by {linebreak} ** shared libraries that want to be imported as extensions into {linebreak} ** an SQLite instance. Shared libraries that intend to be loaded {linebreak} -** as extensions by SQLite should #include this file instead of {linebreak} +** as extensions by SQLite should #include this file instead of {linebreak} ** sqlite3.h. {linebreak} ** {linebreak} ** @(#) $Id: sqlite3ext.h,v 1.7 2006/09/22 23:38:21 shess Exp $ {linebreak} @@ -92,9 +92,6 @@ {linebreak} void * (*get_auxdata)(sqlite3_context*,int); {linebreak} int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**); {linebreak} int (*global_recover)(void); {linebreak} +#if __WATCOMC__ && defined(interrupt) {linebreak} +# undef interrupt {linebreak} +#endif {linebreak} void (*interrupt)(sqlite3*); {linebreak} sqlite_int64 (*last_insert_rowid)(sqlite3*); {linebreak} const char * (*libversion)(void); {linebreak} Thanks!! Daniel _2007-Jan-09 14:26:55 by anonymous:_ {linebreak} No need to change the sqlite header files. Just do this in your .c file: #undef interrupt #include "sqlite3ext.h" #c8c8c8 2158 code closed 2007 Jan anonymous 2007 Jan 1 2 SCHEMA error still returned if SQL becomes invalid SQLITE_SCHEMA is still returned if the SQL becomes invalid. eg *: Register collation dummy *: prepare, execute "select .... collate dummy", reset statement *: Unregister collation dummy *: step statement In the last step, the collation name is now an error. SQLite returns SQLITE_SCHEMA. I believe it should return SQLITE_ERROR and the same error data as a fresh prepare would. The expectation is for preparev2 to allow the removal of all SQLITE_SCHEMA handling from code. If cases like this are going to happen then I'll have to have SQLITE_SCHEMA handling code again. And if that is the case then I may as well use the preparev1 api since I'll have to keep a copy of the sql around to rerun prepare with. (ie I'll have to have code that effectively duplicates preparev2). _2007-Jan-09 15:08:43 by anonymous:_ {linebreak} I understand the behaviour, but don't think it is justified. This now means I have to save a copy of the string and re-run prepare in order to get the actual error code (ie the SQL is now invalid). That means I have to have code that duplicates prepare_v2 making prepare_v2 and its extra copy of the string pointles. ---- _2007-Jan-09 15:16:27 by drh:_ {linebreak} The current behavior is OK. You just have to start thinking of SQLITE_SCHEMA as a fatal error, akin to SQLITE_IOERR or SQLITE_FULL, instead of something that requires a retry. We could change theh SQLITE_SCHEMA return to be SQLITE_ERROR, but SQLITE_SCHEMA gives more specific error information so what not use it. After sqlite3_step() returns SQLITE_SCHEMA, the reason for the parse error is available from sqlite3_errmsg(). There is no need to rerun sqlite3_prepare_v2() to find the error text. Documentation and test cases have been updated to try to bring out this point. ---- _2007-Jan-09 15:25:52 by anonymous:_ {linebreak} My problem is a difference in behaviour. If I have invalid SQL and call prepare on a new statement then I get SQLITE_ERROR. If the invalid SQL is re-prepared then I will get SQLITE_SCHEMA. I am using exceptions based on the error code so different exceptions will get raised. The reason why I'll have to run the re-prepare myself is to get consistent behaviour. #c8c8c8 2157 code closed 2007 Jan anonymous 2007 Jan 1 2 Profile called back too many times if a prepare_v2 statement is reused select max(x) from foo drop index foo_x select max(x) from foo The second select re-uses the sqlite3_stmt. If there is a profile callback registered during both selects, then it is called twice on the second select. If I use a new sqlite3_stmt then it is only called once on the second select. Code is attached showing this. Output when statement is reused and hence reprepared internally due to schema change: PCB: 31462312 select max(x) from foo PCB: 11587143 select max(x) from foo PCB: 26553869 select max(x) from foo Output expected, and what you get if a new statement is used: PCB: 31462311 select max(x) from foo PCB: 24582445 select max(x) from foo _2007-Jan-09 03:20:10 by drh:_ {linebreak} This is correct. The statement really does run three times. The second run fails with SQLITE_SCHEMA and is automatically retried. Please use sqlite3_profile() with caution as it is currently undocumented and unsupported at this time. ---- _2007-Jan-09 03:42:05 by anonymous:_ {linebreak} I certainly see your logic, but this results in different behaviour between repeatedly making new statements vs reusing them. preparev2 is generally most useful for the latter case. It would be really nice if the callback wasn't called when a re-prepare happens. That will hide the existence of SQLITE_SCHEMA which was kinda the point of the v2 interface in the first place! ---- _2007-Jan-09 14:03:28 by drh:_ {linebreak} Seems to me that users would want to know about every run of a statement, and their timings, even those runs that abort early with an error and are automatically retried. The purpose of sqlite3_prepare_v2 is not to hide the existance of SQLITE_SCHEMA but rather to fix it so that users do not have to deal with it so much. ---- _2007-Jan-09 14:30:08 by anonymous:_ {linebreak} I disagree with your last comment. It certainly makes their code way more complicated since they will have to be aware of whether statements are reused, which means they also have to know the replacement policy for any statement caching. ie instead of a one to one mapping of callbacks to statements, they now have one or more callbacks per statement. I first discovered this problem with my test suite and it could be nasty trying to code a test for this kind of behaviour. I also have an underlying assumption that the detection and re-preparation take close to zero time. If that is not the case then notifying of the costs makes sense giving the extra complexity. #cfe8bd 2156 code fixed 2007 Jan anonymous 2007 Jan 1 2 Statements re-used from preparev2 crashing on vtable errors I am seeing a second problem when using virtual tables. Code is attached. This is the rough outline: sqlite3_prepare_v2("create virtual table xyzzz using testmod1") vtabCreate returns an error sqlite3_reset(stmt) sqlite3_clear_bindings(stmt) sqlite3_step(stmt) // run it again I don't get a crash if I make a new stmt, only if I reuse one. valgrind report using CVS code current at time of posting. ==11611== Invalid read of size 8 ==11611== at 0x6458550: sqlite3VtabCallCreate (vtab.c:409) ==11611== by 0x647D639: sqlite3VdbeExec (vdbe.c:4559) ==11611== by 0x644F7BA: sqlite3_step (vdbeapi.c:236) #c8c8c8 2155 code closed 2007 Jan anonymous 2007 Jan 4 4 Should %s in strftime() be rounded up? Or should %s it be consistant with %S and truncated to the lower integer? sqlite> select strftime('%s', '2007-01-01 12:34:59'); 1167654899 sqlite> select strftime('%s', '2007-01-01 12:34:59.3'); 1167654899 sqlite> select strftime('%s', '2007-01-01 12:34:59.6'); 1167654900 sqlite> select strftime('%s', '2007-01-01 12:35:00'); 1167654900 The 0.5 second additions can accumulate in a multi-stage date arithmetic to throw the time off by a second or two. All occurances of 0.5 in date.c should be double-checked. _2007-Jan-08 18:56:01 by drh:_ {linebreak} Adding 0.5 and taking the integer part causes it to round to the nearest integer - not round up. Rounding to the nearest integer is an entirely reasonable thing to do, I believe. ---- _2007-Jan-08 19:12:55 by anonymous:_ {linebreak} Arguments could be made for rounding the seconds to the nearest integer or just using integer truncation. man strftime and man mktime for major UNIX variants do not discuss what happens in fractional cases. So I guess it can be implementation defined. #cfe8bd 2154 code fixed 2007 Jan anonymous 2007 Jan 1 2 Getting core dump with reused prepare_v2 statements I implemented a statememt cache in apsw and started getting core dumps. I have attached a simple C program that reproduces the problem. Conceptually the steps are: create table foo(x) insert into foo(99) create index foo_x on foo(x) select max(x) from foo drop index foo_x select max(x) from foo Each uses its own sqlite3_stmt, except the 2nd select re-uses the one from the earlier select. After each statement has run, sqlite3_reset and sqlite3_clear_bindings are run on the statement. The 2nd select should be getting SCHEMA internally and re-preparing the statement, but something is going wrong. Problem reproduced on x86 and amd64 Linux. Here is sample valgrind output: ==18745== Invalid read of size 1 ==18745== at 0x41901C: sqlite3BtreeNext (btree.c:3426) ==18745== by 0x43C872: sqlite3VdbeExec (vdbe.c:3666) ==18745== by 0x40C0CA: sqlite3_step (vdbeapi.c:236) ==18745== by 0x401DF3: dotest (brokes3.c:70) ==18745== by 0x401F86: main (brokes3.c:108) ==18745== Address 0xC4 is not stack'd, malloc'd or (recently) free'd ==18745== ==18745== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==18745== Access not within mapped region at address 0xC4 ==18745== at 0x41901C: sqlite3BtreeNext (btree.c:3426) ==18745== by 0x43C872: sqlite3VdbeExec (vdbe.c:3666) ==18745== by 0x40C0CA: sqlite3_step (vdbeapi.c:236) ==18745== by 0x401DF3: dotest (brokes3.c:70) ==18745== by 0x401F86: main (brokes3.c:108) #cfe8bd 2153 code fixed 2007 Jan drh 2007 Jan 1 1 Error in the strftime() function The following statement: select strftime('%m-%d-%Y %H:%M:%S', julianday('2004-01-01 23:59:59.6', 'utc'), 'localtime'); Returns an invalid time: 01-01-2004 23:59:60 _2007-Jan-08 16:00:35 by anonymous:_ {linebreak} Another test case, not on a date change boundary: sqlite> select strftime('%m-%d-%Y %H:%M:%S', julianday('2004-11-18 17:14:59.6', 'utc'), 'localtime'); 11-18-2004 17:14:60 #c8c8c8 2152 code closed 2007 Jan anonymous 2007 Jan 1 1 there is not tclsqlite.h in sqlite3.3.9 dev c++ of windows doesn't compile sqlite3.3.9 source perhaps there is not tclsqlite.h _2007-Jan-08 13:38:09 by drh:_ {linebreak} There is no file tclsqlite.h on any platform and that file is not mentioned anywhere in the source code. #cfe8bd 2151 code fixed 2007 Jan anonymous 2007 Jan 3 3 attach database fails SQLite version 3.3.9 Enter ".help" for instructions sqlite> attach database z as z; SQL error: unable to open database: z sqlite> attach database zz as z; Attaching any 1-letter file will fail. Tested only on windows 2000 _2007-Jan-08 13:36:54 by drh:_ {linebreak} Works for me on WinXP. ---- _2007-Jan-08 23:29:08 by anonymous:_ {linebreak} I'v tested it on other computer with windows 2000. Still fails. On mac it works. ---- _2007-Jan-09 01:51:01 by drh:_ {linebreak} Looks like a bug in win2k. Your work-around is to always "./" to single-character filenames. I would put a patch into SQLite to do this, but I am reluctant to do so for something as old as win2k. ---- _2007-Jan-09 03:57:45 by anonymous:_ {linebreak} Tested Visual Studio 2005 on W2K the following code: #include #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { TCHAR buf[4096]; TCHAR* tmp; cerr << GetFullPathName (L"z", 4096, buf, &tmp) << endl; return 0; } Got the correct answer: =e:\projects\full_path\full_path\z= This is a version of W2K with all the latest Hotfixes and service packs applied. Anything else I can do to help? #c8c8c8 2150 code closed 2007 Jan anonymous 2007 Jan 3 3 use of %W in strftime produces unreliable results I find that if I execute the following SQL multiple times in succession, I get different values for %W: SELECT strftime('%Y-%W', 'now'); Sometimes I get '2007-01' and other times I get '2007-02'. Blindly adding 0.5 seconds will not work for dates within 0.5 seconds of the next date. With latest CVS change: sqlite> select strftime('%m-%d-%Y %H:%M:%S', julianday('2004-01-01 23:59:59.6', 'utc'), 'localtime'); 01-01-2004 23:59:60 ---- _2007-Jan-08 15:42:27 by anonymous:_ {linebreak} ... or within 0.5 seconds of the next minute, for that matter: sqlite> select strftime('%m-%d-%Y %H:%M:%S', julianday('2004-01-01 17:14:59.6', 'utc'), 'localtime'); 01-01-2004 17:14:60 ---- _2007-Jan-08 15:48:16 by drh:_ {linebreak} This is an unrelated issue and should be in a separate ticket. #cfe8bd 2149 build fixed 2007 Jan pweilbacher 2007 Jan 4 3 BEXE missing for lemon in Makefile.in I notice when compiling on OS/2 that the current Makefile.in does not build or call lemon with an exe extension. $(BEXE) should be added in two places. (I rather open a ticket than checking in directly because I cannot test on other platforms right now.) #f2dcdc 2148 doc active 2007 Jan anonymous 2007 Jan 5 5 3.3.9 changes.html addition - 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. #cfe8bd 2147 new fixed 2007 Jan anonymous 2007 Jan 5 5 Add /contrib/download/ to robots.txt The files in http://www.sqlite.org/contrib/ are each downloaded 15 to 20 times per day by web crawlers (I'm assuming based on the consistant counts each day). Consider adding /contrib/download/ to robots.txt if you want the download counts to reflect actual user downloads. If you don't care, please cancel this ticket. I wonder if I should also reset the download counts? ---- _2007-Jan-06 14:36:32 by anonymous:_ {linebreak} I vote for resetting the counts. #c8c8c8 2146 code closed 2007 Jan anonymous 2007 Jan 1 2 Correlated subqueries as columns of select return a syntax error A correlated sub-query in a column causes the CLP to report a syntax error near the FROM outside of the sub-query. After fighting my own tables and queries, I created the sample table and query in "The Definitive Guide to SQLite" and reproduced the same problem. create table food_types id INTEGER PRIMARY KEY name TeXT ); insert into food_types values(1,"bread"); insert into food_types values(2,"rice"); insert into food_types values(3,"serial"); create table foods ( type_id INTEGER, name TEXT, percentage INTEGER ); insert into foods values(1, "ryebread", 10); insert into foods values(1, "wheatbread", 20); insert into foods values(2, "basamati", 100); insert into foods values(3, "oatmeal", 10); insert into foods values(3, "cornflakes", 10); select (select name from food_types where id = f.type_id) Type, fRoM foods f; _2007-Jan-06 02:11:14 by anonymous:_ {linebreak} remove ',' after type. i think the problem is in your sql code. ---- _2007-Jan-06 03:35:35 by drh:_ {linebreak} You are missing a common after "KEY" in the definition of food_types and you have an extra comma after "Type" in the query. #cfe8bd 2145 build fixed 2007 Jan anonymous 2007 Jan 2 3 Error in "make install" This is a patch
 diff -Naur sqlite-3.3.9/Makefile.in sqlite-3.3.9.new/Makefile.in --- sqlite-3.3.9/Makefile.in    2007-01-03 13:33:39 +0000 +++ sqlite-3.3.9.new/Makefile.in        2007-01-05 22:12:25 +0000 @@ -665,7 +665,7 @@         $(LTINSTALL) sqlite3 $(DESTDIR)$(exec_prefix)/bin         $(INSTALL) -d $(DESTDIR)$(prefix)/include         $(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(prefix)/include -       $(INSTALL) -m 0644 src/sqlite3ext.h $(DESTDIR)$(prefix)/include +       $(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(prefix)/include         $(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig;         $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(libdir)/pkgconfig; 
#cfe8bd 2144 doc fixed 2007 Jan anonymous 2007 Jan 5 3 Cmd shell: Add ".bail" to .help and to website Minor: The new ".bail" and "-bail" options for the command line shell don't seem to appear in the ".help" nor in the website documentation at http://www.sqlite.org/sqlite.html. [Entered here in the spirit of helpfulness rather than of complaint] #cfe8bd 2143 doc fixed 2007 Jan anonymous 2007 Jan 3 3 sqlite3_column_name may return NULL We had a crash reported to us at https://bugzilla.mozilla.org/show_bug.cgi?id=365166 - apparently sqlite3_column_name may return NULL for results of "PRAGMA user_version" query. The documentation says http://www.sqlite.org/capi3ref.html#sqlite3_column_name "The first argument is a prepared SQL statement. This function returns the column heading for the Nth column of that statement, where N is the second function argument. The string returned is UTF-8 for sqlite3_column_name() and UTF-16 for sqlite3_column_name16()." i.e. it implies that a string is always returned. Please either clarify this issue in the docs or fix the code so that it doesn't return NULL. #c8c8c8 2142 build closed 2007 Jan anonymous 2007 Jan 2 2 make fails on cygwin $ uname -a CYGWIN_NT-5.1 aurora 1.5.23(0.156/4/2) 2006-12-19 10:52 i686 Cygwin $ make (many lines deleted) ./libtool --mode=link gcc -g -O2 -DOS_WIN=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 - I. -I../sqlite-3.3.8/src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK =-1 -DSQLITE_OMIT_CURSOR -o libsqlite3.la alter.lo analyze.lo attach.lo auth.lo btree.lo build.lo callback.lo complete.lo date.lo delete.lo expr.lo func.lo hash .lo insert.lo loadext.lo main.lo opcodes.lo os.lo os_unix.lo os_win.lo os_os2.lo pager.lo parse.lo pragma.lo prepare.lo printf.lo random.lo select.lo table.lo t okenize.lo trigger.lo update.lo util.lo vacuum.lo vdbe.lo vdbeapi.lo vdbeaux.lo vdbefifo.lo vdbemem.lo where.lo utf.lo legacy.lo vtab.lo \ -rpath /usr/local/lib -version-info "8:6:8" libtool: link: warning: undefined symbols not allowed in i686-pc-cygwin shared libraries (more lines deleted) $ make install tclsh ../sqlite-3.3.8/tclinstaller.tcl 3.3 can't read "env(DESTDIR)": no such variable while executing "set LIBDIR $env(DESTDIR)[lindex $auto_path 0]" (file "../sqlite-3.3.8/tclinstaller.tcl" line 10) make: *** [tcl_install] Error 1 No problem here. tar xzvf sqlite-3.3.8.tar.gz cd sqlite-3.3.8 ./configure && make ./sqlite3.exe #cfe8bd 2141 code fixed 2007 Jan drh 2007 Jan 1 1 Assertion fault on valid query The following SQL causes an assertion fault: CREATE TABLE tab1 (t1_id integer PRIMARY KEY, t1_desc); INSERT INTO tab1 VALUES(1,'rec 1 tab 1'); CREATE TABLE tab2 (t2_id integer PRIMARY KEY, t2_id_t1, t2_desc); INSERT INTO tab2 VALUES(1,1,'rec 1 tab 2'); CREATE TABLE tab3 (t3_id integer PRIMARY KEY, t3_id_t2, t3_desc); INSERT INTO tab3 VALUES(1,1,'aa'); SELECT * FROM tab1 t1 LEFT JOIN tab2 t2 ON t1.t1_id = t2.t2_id_t1 WHERE t2.t2_id IN (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2 WHERE t3_id IN (1,2) GROUP BY t2_id); #f2dcdc 2140 code active 2007 Jan anonymous 2007 Jan 3 1 sqlite doesn't link to readline 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 #cfe8bd 2139 code fixed 2007 Jan anonymous 2007 Jan 1 1 recent pager_unlock change in CVS I may be wrong, but it looks like there may be possible corruption in the recent checkin [3548] if there is a thread context switch immediately after the OsUnlock() and before invalidating dbSize. +static void pager_unlock(Pager *pPager){ + if( !MEMDB ){ + sqlite3OsUnlock(pPager->fd, NO_LOCK); + pPager->dbSize = -1; + } + pPager->state = PAGER_UNLOCK; +} Shouldn't it be rewritten as the following? static void pager_unlock(Pager *pPager){ pPager->state = PAGER_UNLOCK; if( !MEMDB ){ pPager->dbSize = -1; sqlite3OsUnlock(pPager->fd, NO_LOCK); } } Even if you are confident that the code above was fine, putting a usleep() just before the return in unixUnlock() would exercise this code in multithreaded scenarios and may expose other potential database-corrupting race conditions: sqlite3OsLeaveMutex(); #ifdef SQLITE_TEST_FILE_UNLOCK_RACE /* proposed test */ usleep(500); /* proposed test */ #endif /* proposed test */ pFile->locktype = locktype; return rc; } _2007-Jan-03 16:33:41 by anonymous:_ {linebreak} use sqlite3UnixSleep instead of usleep: sqlite3OsLeaveMutex(); #ifdef SQLITE_TEST_FILE_UNLOCK_RACE /* proposed test */ sqlite3UnixSleep(500); /* proposed test */ #endif /* proposed test */ pFile->locktype = locktype; return rc; } ---- _2007-Jan-03 16:43:19 by drh:_ {linebreak} There is no race condition because each thread has its own private copy of pPager and thus pPager->state. pPager is a substructure hanging off of the sqlite3* pointer that you get back from sqlite3_open(). Remember, SQLite does not allow two or more threads to be using the same sqlite3* pointer at the same instant. Attempts to do so will often result in an SQLITE_MISUSE error. Two or more threads are allowed to use SQLite simultaneously as long each have their own sqlite3* pointers. Commentary: That the above fact is not obvious and requires an experienced programmer to have to stop and think about whether or not this is safe to do is the principle reason why *you should not be using threads in the first place.* Having multiple threads in the same address space is just a bug waiting to happen. Why are you wasting time worrying about the order of assignments and unexpected context swaps? In a single threaded environment this is never an issue and so you never have to waste valuable time thinking about it. And you never can get it wrong resulting in race conditions and subtle bugs. There very few good reasons to have multiple threads in the same address space. 99% of the time, your extra threads will work just as well in a separate process. By putting multiple threads in the same address space, you open yourself up to all kinds of incredibly difficult to reproduce and fix bugs that will plague your project forever. *Just say "No!" to threads.* ---- _2007-Jan-03 18:09:01 by anonymous:_ {linebreak} Just to confirm - the pager bug as described here http://marc.10east.com/?l=sqlite-users&m=116784539701814&w=2 can also happen with multi-process code, where each process is single-threaded? ---- _2007-Jan-03 18:30:52 by drh:_ {linebreak} Correct. The pager bug was observed in a situation where multiple single-threaded processes where competing for the same database file. #c8c8c8 2138 code closed 2007 Jan anonymous 2007 Jan 1 2 COLLATE and multiple order by problem execute: make sql;sh insert.sh{linebreak} My query: ./sql collate.db "SELECT * FROM test ORDER BY name,date"{linebreak} Result:{linebreak} {linebreak} Example 19950101{linebreak} Example 19950302{linebreak} Example 19950306{linebreak} Example 19950131{linebreak} Example 19950202{linebreak} Example 19950607{linebreak} {linebreak} Why isn't the date column sorted out the right order? _2007-Jan-03 16:02:10 by anonymous:_ {linebreak} I forgot to write: this is with hu_HU.UTF-8 locale settings. ---- _2007-Jan-03 17:08:30 by drh:_ {linebreak} There are bugs in the implementation of your comparison function for the MAGYAR collating sequence. You are assuming that the strings are NUL-terminated, which they are not. You also assume that the second string is not shorter than the first, which is not necessarily the case. There my be other bugs - these where the ones I saw on first glance. The first bug above will definately cause the erroneous behavior you observe. ---- _2007-Jan-04 14:18:43 by anonymous:_ {linebreak} I think you are wrong.{linebreak} {linebreak} uncomment the printf line in the sql.c file 93. row.{linebreak} Result:{linebreak} {linebreak} -1 - 79: 'Example' - 'Example'{linebreak} -1 - 79: 'Example' - 'Example'{linebreak} 35 - 39: 'Example' - 'Example'{linebreak} 35 - 39: 'Example' - 'Example'{linebreak} 20 - -1: 'Example' - 'Example'{linebreak} 20 - -1: 'Example' - 'Example'{linebreak} -1 - 3: 'Example' - 'Example'{linebreak} 79 - 3: 'Example' - 'Example'{linebreak} Example 19950101{linebreak} Example 19950302{linebreak} Example 19950306{linebreak} Example 19950131{linebreak} Example 19950202{linebreak} Example 19950607{linebreak} {linebreak} I think my collate function is invoked only for the name column. ---- _2007-Jan-04 15:02:33 by drh:_ {linebreak} Your test proves that I am right. Comparing 'Example' to 'Example' should always return 0. ---- _2007-Jan-04 15:31:32 by anonymous:_ {linebreak} No you aren't right.{linebreak} {linebreak} sqlite> select * from test;{linebreak} Example|19950302{linebreak} Example|19950306{linebreak} Example|19950202{linebreak} Example|19950607{linebreak} Example|19950101{linebreak} Example|19950131{linebreak} sqlite> {linebreak} {linebreak} The first column is always "Example" so the comparsion result must be 0, this is right.{linebreak} But the problem is not here but the second column sorting, named "date".{linebreak} Now I found one workaround for the bug.{linebreak} If I change the "date" column type to VARCHAR, the result is ok.{linebreak} Plase, test this, change in the insert.sh the date column type to VARCHAR and execute:{linebreak}rm collate.db;sh insert.sh;./sql collate.db "SELECT * FROM test ORDER BY name,date"{linebreak} {linebreak} Now the result is ok. ---- _2007-Jan-04 16:09:35 by drh:_ {linebreak} Yes I am right and you are wrong. Because of the problems in the comparsion function, SQLite thinks that some cases of 'Example' in the name column are less than others. The name column is the primary sort key. The date is the secondary sort key and is therefore only used when the primary key compares equal. In other words, the secondary sort key is only used to break a tie in the primary sort key. But ties never happen in the primary sort key due to bugs in your comparision function. So as far as SQLite is concerned, the content of the Date column is irrelevant. ---- _2007-Jan-04 17:21:54 by anonymous:_ {linebreak} Ahh I see now.{linebreak} Big sorry for you.{linebreak} I'm fixed my function and now it's rock. :) #c8c8c8 2137 code closed 2007 Jan anonymous 2007 Jan shess 4 4 I cannot find tcl.h header file. So, I am not able to compile the code I cannot find tcl.h header file. So, I am not able to compile the code. Can you provide me with one. Here it is: {link: http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15740-f97/public/include/tcl.h tcl.h} Kidding aside, you don't need Tcl to build SQLite. It's just for the optional test suite. Anyway, this is a mailing list question and does not belong here. #cfe8bd 2069 code fixed 2006 Nov anonymous 2007 Jan 4 3 compilation problem with SQLITE_OMIT_SHARED_CACHE src/loadext.c 77a78,81{linebreak} > #ifdef SQLITE_OMIT_SHARED_CACHE{linebreak} > # define sqlite3_enable_shared_cache 0{linebreak} > #endif{linebreak} #f2dcdc 1722 new active 2006 Mar anonymous Unknown 2007 Jan 4 2 agregate sum() of strings 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? #f2dcdc 1126 new active 2005 Feb anonymous Unknown 2007 Jan drh 2 3 sqlite 2.8.16 port to djgpp 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 _2005-Feb-16 14:14:56 by drh:_ {linebreak} 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:_ {linebreak} thanks for your time. i will try to compile on linux and compare results. ---- _2005-Oct-11 14:58:05 by anonymous:_ {linebreak} 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:_ {linebreak} it seems someone has accidentally changed the diff i've provided for an invalid binary file. #f2dcdc 2545 code active 2007 Jul anonymous 2007 Jul 1 4 Group by returns table name with field name 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:_ {linebreak} 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:_ {linebreak} Ok, we have created a special support for SQLite. PS: I love this database :) Simple, nice, usefull, quick and easy Regards #cfe8bd 2544 code fixed 2007 Jul rse 2007 Jul 4 3 "sqlite3 foo.db .dump | sqlite3 bar.db" fail because of verbose output A simple "sqlite3 foo.db .dump | sqlite3 bar.db" for upgrading an old database file failed because of the verbose output "Loading resources from [...]/.sqliterc". Although one can use the workaround "sqlite3 -batch foo.db .dump", this is annoying as one stumbles too easily and without any real need over this unimportant verbose output message. I propose two solutions: Either add a similar istty(3) check to shell.c which is already present for stdin or simply drop the verbose message at all. As I cannot decide what is wished here, I will append a patch at least for the istty(3) solution. _2007-Jul-30 19:02:51 by anonymous:_ {linebreak} I agree the warning message is useless. Rather than breaking sqlite3 on platforms without isatty support, please do one of the following instead: *: Get rid of the line altogether *: -- put a comment in front of the line *: if -batch is specified on the command-line, do not print out this line A workaround: sqlite3 -batch -init ignore foo.db .dump | sqlite3 bar.db ---- _2007-Jul-30 19:26:20 by rse:_ {linebreak} The istty(3) is already used by SQLite, so the additional use would make no problem. -- rse #f2dcdc 2543 code active 2007 Jul anonymous 2007 Jul 1 1 Chinese charset not support?? when i create a table. the table name is " " (chinese) after this "alter table   add column aaa text null" error why??/ thank you #c8c8c8 2542 code closed 2007 Jul anonymous 2007 Jul 2 1 select 3/2 * avg(x) gives wrong result
 Try this.  It gives 2 but obviously the answer is 3 since the average of 1,2,3 is 2 and multiplying that by 3/2 gives 3.  C:\tmp2>sqlite3 SQLite version 3.4.0 Enter ".help" for instructions sqlite> sqlite> create table tab (x num); sqlite> insert into tab values (1); sqlite> insert into tab values (2); sqlite> insert into tab values (3); sqlite> select * from tab; 1 2 3 sqlite> select sqlite_version(*); 3.4.0 sqlite> sqlite> select 3/2 * avg(x) from tab; 2.0  
_2007-Jul-30 04:10:09 by anonymous:_ {linebreak} Sorry, please ignore this one. I just released its doing integer arithmetic. #c8c8c8 2541 doc closed 2007 Jul anonymous 2007 Jul danielk1977 4 4 ALTER TABLE RENAME TO doesn't update (all) trigger schema (This might be by design, I didn't see anything in the notes to this effect though). ALTER TABLE RENAME TO doesn't update trigger schema correctly, for example: sqlite> .sc CREATE TABLE t1 ( c1 ); CREATE TABLE t2 ( c1 ); CREATE TRIGGER trg_1 after INSERT ON t1 begin insert into t2 select c1 from t1 where rowid=new.rowid ; end; then sqlite> alter table t1 rename to table1; sqlite> .sc [...] CREATE TRIGGER trg_1 after INSERT ON 'table1' begin insert into t2 select c1 from t1 where rowid=new.rowid ; end; So you can get errors like: sqlite> insert into t1(c1) values('one'); SQL error: no such table: t1 _2007-Jul-28 01:00:05 by anonymous:_ {linebreak} That's not easy to fix. SQLite stores triggers, views, etc as strings in sqlite_master - not in its tokenized form. You basically have to drop the trigger and recreate it. ---- _2007-Jul-28 01:31:35 by anonymous:_ {linebreak} I think you meant to write the following command after the table name was changed: sqlite> insert into table1 values('one'); SQL error: no such table: main.t1 ---- _2007-Jul-30 02:52:13 by danielk1977:_ {linebreak} You need to edit (i.e. drop and recreate) views and statements executed by triggers externally. See the third paragraph here ("If the table being renamed..."): http://www.sqlite.org/lang_altertable.html #f2dcdc 2540 code active 2007 Jul anonymous 2007 Jul 5 4 Display dlopen() errors for errors when loading modules on Unix system 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; #c8c8c8 2538 code closed 2007 Jul anonymous 2007 Jul 1 1 calling sqlite3_interrupt() randomly leaves db->ul.isInterrupted = 1 Using a sequence as follows, all invoked with sqlite3_exec(): BEGIN; ... long running script with many UPDATE/INSERT statements (with triggers firing, etc)... sqlite3_interrupt() is called Often (always?) the next sqlite3_exec call will also return SQLITE_INTERRUPT instead of SQLITE_OK. Apparently there is at least one point in sqlite execution that can be interrupted with sqlite3_interrupt() where db->ul.isInterrupted is not reset to 0, so the next sqlite3_exec() call also to returns SQLITE_INTERRUPT. Since the documentation states that calling sqlite3_interrupt() will rollback any EXPLICIT transactions (why specifically EXPLICIT ?? - I would assume auto [IMPLICIT] transactions would obviously also rollback with a sqlite3_interrupt call), any subsequent action done on the sqlite instance should be SQLITE_OK (or the error specific to that action since the previous call has been fully aborted). This behavior is definitely different than 3.2.8 (the version I am attempting to upgrade from), which works as expected. After much additional testing, I have concluded that this may actually have been due to my error (sqlite3_interrupt() being called again) and not due to sqlite. Sorry for the wasted bandwidth. Please consider the issue closed. #c8c8c8 2537 code closed 2007 Jul anonymous 2007 Jul 4 4 sqlite3_column_type() function problem. Hi, -I prepare a sql query statement ex: Select * from Table1. -I want read some metadata from all fields of the result-set before fetch the first row with the function sqlite3_step(...). -sqlite3_column_name(...), sqlite3_column_origin_name(...), sqlite3_column_table_name(...) are all Ok but sqlite3_column_type(...) returns for all columns -> 5 (NULL). After the first sqlite3_step(...) the type is correct for all columns. _2007-Jul-25 23:07:25 by drh:_ {linebreak} The type can vary from one row to the next. Works as designed. #c8c8c8 2534 code closed 2007 Jul anonymous 2007 Jul danielk1977 2 3 sqlite3_set_auxdata may cause memory to be leaked The routine _sqlite3_set_auxdata()_ may cause memory allocated by the caller to be leaked. Specifically, if the routine fails to allocate memory for its internal array of struct AuxData then the new argument data will not be stored. If the caller included an xDelete callback, this callback will not be stored or called in this circumstance. Given that _sqlite3_set_auxdata()_ does not return an indicator of success or failure, if the routine fails and a xDelete callback has been supplied then the callback routine should be executed before returning to the caller. Makes sense to me. #c8c8c8 2532 code closed 2007 Jul anonymous 2007 Jul 3 4 Endless loop in Parser? After pasting the statement: " create trigger brandattribute_adtr after delete on brand_attribute for each row begin delete from customattributetype where customattributetype.customattributetype_id == old.customattributetype_id end; " the Sqlite command prompt remains in ...> level. I don't know any solution to solve it except typing -C. It seems to be an endless loop in the parser. You need a semi-colon after the DELETE statement. Before "end;". #c8c8c8 2531 code closed 2007 Jul anonymous 2007 Jul a.rottmann 1 1 Can't find head files in icu.c /* Include ICU headers */ #include #include #include #include where can I find them? thanks. _2007-Jul-25 05:14:37 by danielk1977:_ {linebreak} They are part of the ICU library distribution. You need ICU installed to build the sqlite ICU extension. http://icu-project.org/ #f2dcdc 2530 code active 2007 Jul anonymous 2007 Jul 2 3 Unable to write to windows share, even with exclusive lock 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> #c8c8c8 2529 code closed 2007 Jul anonymous 2007 Jul anonymous 1 1 Bug in sqlite3_prepare_v2( ) function In Win 32 console All queries are working which include "SELECT * FROM A WHERE col1 NOT IN ( -1, 6);" "SELECT * FROM A WHERE col2 IN ( 0, 1, 2, 3 );" where A is the table name, col1 is the column label, table values are entered correctly ( checked and verified ) These queries are working perfectly in sqlite3 command prompt and Win32 VC++ console But are not working on Qualcomm chipsets, with REX OS The position where it is returning error is sqlite3_prepare_v2( ) _2007-Jul-24 10:20:40 by drh:_ {linebreak} OK, Vineethev, let's think this through. You admit that everything is working prefectly on Win32 using the sqlite3 command prompt and Win32 VC++ console. You are reporting against SQLite version 3.3.13 which has been used by thousands of thousands of people on diverse systems without problems. You further observe that the queries do not work on Qualcomm chipsets on the REX operating system (which is an OS I have never before heard of and is certainly not directly supported by the SQLite core team.) In other words, everything appears to be working fine everywhere except on Qualcomm chips and REX OS? So what is it that make you think this is a bug in SQLite in the sqlite3_prepare_v2() function and not a bug in either the Qualcomm chips or REX OS or your proprietary port of SQLite to that platform? I am not making fun of you or dismissing your complaint. My question is serious. Why do you think this is a bug in SQLite and not someplace else? Think carefully about that question and answer it as fully and carefully as you can. Because unless you answer that question, there is very little that I or anyone else can do to help you. #cfe8bd 2528 doc fixed 2007 Jul anonymous 2007 Jul 3 2 PRAGMA auto_vacuum documentation mismatch {link: http://www.sqlite.org/pragma.html#pragma_auto_vacuum Pragma documentation} claims that PRAGMA auto_vacuum=incremental setting is not persistent.{linebreak}{link: http://www.sqlite.org/changes.html#version_3_4_1 Changes page} claims the opposite. #c8c8c8 2527 doc closed 2007 Jul anonymous 2007 Jul 4 2 sqlite3_create_module() API documentation missing Documentation for sqlite3_create_module() is missing on page {link: http://www.sqlite.org/capi3ref.html C/C++ API Reference}. The same goes for new sqlite3_create_module_v2(). _2007-Jul-24 10:06:33 by drh:_ {linebreak} This is because the whole virtual table mechanism is still considered highly experimental and subject to change. By writing up an interface in the C-API documentation, we promise to support it from now on. No such promises are made with virtual tables. #cfe8bd 2526 code fixed 2007 Jul anonymous 2007 Jul 2 4 Core dump when issuing a select statement with special having clause When executing the attached script, I get a core dump regarding freeing an invalid pointer. Steps to reproduce: python breaks.py # breaks.py is found below Comments: The error is probably related to the fact that having a having clause with "having cn < max(count(author))" breaks with "missuse of aggregate function count()", but aliasing the column count(author as cn) breaks the checks, and instead the program crashes. I submitted the bug here instead of to pysqlite because the breakage also happens with the command line version of sqlite3. _2007-Jul-23 22:14:11 by drh:_ {linebreak} The following script demonstrates the problem. No need for the python complication: create table t1 (a text, b text, c primary key); insert into t1 values ('x', 'y', NULL); insert into t1 values ('x', 'z', NULL); select count(a) as cn from t1 group by a having cn < max(cn); #cfe8bd 2525 code fixed 2007 Jul anonymous 2007 Jul 1 3 Constraint violations fail silently with "insert or replace" The following code (file "correls.sql") correctly raises a constraint violation: create table if not exists correls ( sym1 varchar, sym2 varchar, correl real, primary key (sym1, sym2), check (correl >= -1), check(correl <= 1)); insert into correls values ("a", "b", -2); Here is the output: # sqlite3 correls.db < correls.sql SQL error near line 5: constraint failed But running the same code with "insert or replace" instead of a plain "insert" will fail silently. The data won't be inserted or updated so integrity is still maintained, but the user will not know that the transaction wasn't successful. #cfe8bd 2524 code fixed 2007 Jul anonymous 2007 Jul 4 4 Missing error check in call to sqlite3PagerWrite() in autoVacuumCommit The Coverity checker found this minor issue. Most of the calls to sqlite3PagerWrite() have the return value checked and appropriate action taken if the call fails. In btree.c, line 2012, there's a call to sqlite3PagerWrite() without a check. Is this a case where the call can't fail, or are we really missing error handling code here? #cfe8bd 2523 code fixed 2007 Jul anonymous 2007 Jul 3 4 Leaked memory on error return from sqlite3VdbeMemTranslate In sqlite3VdbeMemTranslate in utf.c, line 214 has an allocation of memory for zOut. Later, at line 265, there's an early return if memory allocation fails for zExtra. If that return is taken, the allocation for zOut is lost, since it's not been assigned to an outbound variable. This does seem like a rare case, but the fix is easy -- just add the right deallocation here if zOut != zShort. #cfe8bd 2522 code fixed 2007 Jul anonymous 2007 Jul 4 4 wrong sizeof in vdbe.c Harmless, but this can waste memory on platforms where sizeof(int*) > sizeof(int). vdbe.c: - aRoot = sqliteMallocRaw( sizeof(int*)*(nRoot+1) ); + aRoot = sqliteMallocRaw( sizeof(int)*(nRoot+1) ); #cfe8bd 2521 code fixed 2007 Jul anonymous 2007 Jul 2 4 Misplaced prototypes When compiling the amalgamated sqlite3.c, the Digital Mars compiler produces the error sqlite3.c(67876) : Error: no definition for static 'sqlite3ParserFree' Moving the function prototypes at sqlite3.c lines 66302 and 66303 SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); to a position before the respective procedures eliminates the problem. Robert Wishlaw #f2dcdc 2520 new active 2007 Jul anonymous 2007 Jul 4 1 User defined aggregate functions are not reentrant 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:_ {linebreak} related: Ticket #2242: sqlite3 authorizer is not reentrant #cfe8bd 2518 code fixed 2007 Jul anonymous 2007 Jul 2 1 Complex paging problem We are experiencing a very strange and complex problem with SQLite which is very difficult to reproduce. Basically 1. We run some bits to set up the DB. 2. Populate the data base with a load of information on one thread. 3. Then running a query on a different thread: SELECT DISTINCT("SessionID") FROM "mfForm_Welcome" WHERE UID IN (-1, 1) AND "D3_TXTCODE" LIKE "1" ORDER BY SessionID DESC; If the query fails in other words there is no matching data in the table the problem happens if it succeeds the problem doesn't seem to happen. 4. Then we run the function to populating the DB with a load of information. Again on a different thread. As 2. 5. Then running the query again which should succeed fails. SELECT DISTINCT("SessionID") FROM "mfForm_Welcome" WHERE UID IN (-1, 1) AND "D3_TXTCODE" LIKE "1234" ORDER BY SessionID DESC; However if we do this: INSERT INTO mfForm_Welcome (SessionID) VALUES (NULL); DELETE FROM mfForm_Welcome WHERE SessionID IS NULL; Immediately prior to running the query for the second time it succeeds. If we run a query that succeeds at step 2. then everything seem to work ok from then on. It also seems to matter if there are other tables in the DB prior to the one the query is run on. I have been debugging in SQLite and looks to me that the paging system hasn't re-got the data or is in some other way incorrect. In other words the paging stuff isn't reflecting what's on the DB, Possibly it isn't getting invalidated or something. I also got a trace of all the SQL run by the app up to this point. Running this SQL in isolation works OK (Doesn’t give the problem) so probably something to do with having two threads. Sorry if this is a bit hard to follow but we would much appreciate help. SQL Trace: Step 1. This is on thread 1
 CREATE TABLE "mfSysUsers" ("ID" numeric PRIMARY KEY , "Username" text (20) , "Password" text (20) ) CREATE TABLE "mfSysUserPermissions" ("UserID" numeric PRIMARY KEY , "StartUpForm" text (128) , "Flags" numeric ) CREATE TABLE "mfSysUsersToForms" ("PermissionID" numeric PRIMARY KEY , "UserID" numeric , "FormTitle" text (128) , "Flags" numeric ) CREATE TABLE mfSysSyncLog (ID integer IDENTITY PRIMARY KEY, UID integer, Sync nvarchar(19), Type integer, Records integer, FormName nvarchar(32), FailureReason integer) CREATE TABLE mfSysTrackingLog (ID integer IDENTITY PRIMARY KEY, UID integer, LogIn nvarchar(19), LogOut nvarchar(19), FormName nvarchar(32), Session integer) CREATE TABLE "mfForm_Welcome" ("SessionID" numeric PRIMARY KEY , "UID" numeric , "Flags" numeric , "Expiry" numeric , "Spare" numeric , "D3_txtAccessCode" text , "D3_txtMsgDay" text , "D3_txtUser" text , "D3_txtDesc" text , "D3_txtH" text , "D3_txtErr" text , "D3_txtDontSend" text , "D3_DEVICE" text , "D3_txtCode" text ) CREATE TABLE "mFSysVersion" (asdasd CHAR) CREATE INDEX 'IndexUserName_mfSysUsers' ON 'mfSysUsers' (Username ASC ) CREATE INDEX 'IndexUserID_mfSysUsers' ON 'mfSysUsers' (ID DESC ) CREATE INDEX [IdxTrackingLog] ON [mfSysTrackingLog] (ID)  SELECT Username FROM mfSysUsers; SELECT Username FROM mfSysUsers; SELECT Username FROM mfSysUsers WHERE Username='Guest' SELECT Username FROM mfSysUsers WHERE Username='Guest' SELECT Password FROM mfSysUsers WHERE Username='Guest' SELECT Password FROM mfSysUsers WHERE Username='Guest' SELECT ID FROM mfSysUsers WHERE Username='Guest' SELECT ID FROM mfSysUsers WHERE Username='Guest' SELECT StartUpForm, Flags FROM mfSysUserPermissions WHERE UserID = 1; SELECT StartUpForm, Flags FROM mfSysUserPermissions WHERE UserID = 1;  CREATE TABLE "mfForm_Welcome" ("SessionID" numeric PRIMARY KEY , "UID" numeric , "Flags" numeric , "Expiry" numeric , "Spare" numeric , "D3_txtAccessCode" text , "D3_txtMsgDay" text , "D3_txtUser" text , "D3_txtDesc" text , "D3_txtH" text , "D3_txtErr" text , "D3_txtDontSend" text , "D3_DEVICE" text , "D3_txtCode" text ); SELECT MAX(SessionID) FROM "mfForm_Welcome"; SELECT MAX(SessionID) FROM "mfForm_Welcome"; INSERT INTO mfSysTrackingLog (UID, Login, Session, FormName) VALUES (1, '2007-07-17 11:39:25', 1, 'Welcome'); SELECT MAX(ID) FROM mfSysTrackingLog; SELECT MAX(ID) FROM mfSysTrackingLog; 
Step 2. This is on thread 2
 BEGIN; SELECT SessionID FROM "mfForm_PartFields" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PartFields" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testaa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testaa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testbb" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testbb" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Issue Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Issue Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspections Guide" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspections Guide" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Issues" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Issues" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections List" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections List" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspection Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspection Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Menu" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Menu" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCN" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCN" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNStartUp" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNStartUp" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNNoGenerator" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNNoGenerator" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShift" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShift" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_DogFouling" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_DogFouling" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OffenceList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OffenceList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShiftDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShiftDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNMain" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNMain" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditsToClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditsToClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Check Item" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Check Item" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Audit" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Audit" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AIMS" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AIMS" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Main" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Main" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_CheckItemActions" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_CheckItemActions" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_HRA" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_HRA" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_TEST LISTS2" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_TEST LISTS2" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OrderList_OL" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OrderList_OL" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Statement_ST" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Statement_ST" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_LastOrderList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_LastOrderList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_StatementData_SD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_StatementData_SD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Receipt_R" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Receipt_R" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReport_RR" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReport_RR" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Form 1aa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Form 1aa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReportData_RRD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReportData_RRD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testpush" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testpush" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_pushlist" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_pushlist" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_eeeee" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_eeeee" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestData" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestData" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestUpdate" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestUpdate" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobDet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobDet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_userdet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_userdet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_VisitDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_VisitDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Welcome" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Welcome" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Photo" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Photo" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobFields" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobFields" WHERE Flags IN (2,3) GROUP BY SessionID; DROP TABLE 'mfForm_TEST LISTS'; DROP TABLE 'mfForm_Debug'; DROP TABLE 'mfForm_asfsd'; DROP TABLE 'mfForm_Street Issues List'; DROP TABLE 'mfForm_Check Groups'; DROP TABLE 'mfForm_OrderEntry_OE'; DROP TABLE 'mfForm_PCNList'; DROP TABLE 'mfForm_ProductEntry_PE'; DROP TABLE 'mfForm_PushTest'; DROP TABLE 'mfForm_NullTest'; DROP TABLE 'mfForm_Order details'; DROP TABLE 'mfForm_test1'; DROP TABLE 'mfForm_Form 1'; DROP TABLE 'mfForm_Form 3'; DROP TABLE 'mfForm_Form 2'; DROP TABLE 'mfForm_Options'; DROP TABLE 'mfForm_PartDetails'; DROP TABLE 'mfForm_Jobs'; DROP TABLE 'mfForm_Confirm'; DROP TABLE 'mfForm_Unfinished'; DROP TABLE 'mfForm_Errors'; DROP TABLE 'mfForm_JobOptions'; SELECT * FROM "mfSysSyncLog"; SELECT * FROM "mfSysSyncLog"; SELECT * FROM "mfSysTrackingLog"; SELECT * FROM "mfSysTrackingLog"; DELETE FROM mfSysTrackingLog; COMMIT; VACUUM; 
Step 3. This is on Thread 1
 SELECT DISTINCT("SessionID") FROM "mfForm_Welcome" WHERE UID IN (-1, 1) AND "D3_TXTCODE" LIKE "1" ORDER BY SessionID DESC; 
Step 4. This is on thread 2
 BEGIN; SELECT SessionID FROM "mfForm_PartFields" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT name, rootpage, sql FROM 'main'.sqlite_master CREATE TABLE "mfSysUsers" ("ID" numeric PRIMARY KEY , "Username" text (20) , "Password" text (20) ) CREATE TABLE "mfSysUserPermissions" ("UserID" numeric PRIMARY KEY , "StartUpForm" text (128) , "Flags" numeric ) CREATE TABLE "mfSysUsersToForms" ("PermissionID" numeric PRIMARY KEY , "UserID" numeric , "FormTitle" text (128) , "Flags" numeric ) CREATE TABLE mfSysSyncLog (ID integer IDENTITY PRIMARY KEY, UID integer, Sync nvarchar(19), Type integer, Records integer, FormName nvarchar(32), FailureReason integer) CREATE TABLE mfSysTrackingLog (ID integer IDENTITY PRIMARY KEY, UID integer, LogIn nvarchar(19), LogOut nvarchar(19), FormName nvarchar(32), Session integer) CREATE TABLE "mfForm_Welcome" ("SessionID" numeric PRIMARY KEY , "UID" numeric , "Flags" numeric , "Expiry" numeric , "Spare" numeric , "D3_txtAccessCode" text , "D3_txtMsgDay" text , "D3_txtUser" text , "D3_txtDesc" text , "D3_txtH" text , "D3_txtErr" text , "D3_txtDontSend" text , "D3_DEVICE" text , "D3_txtCode" text ) CREATE TABLE "mFSysVersion" (asdasd CHAR) CREATE INDEX 'IndexUserName_mfSysUsers' ON 'mfSysUsers' (Username ASC ) CREATE INDEX 'IndexUserID_mfSysUsers' ON 'mfSysUsers' (ID DESC ) CREATE INDEX [IdxTrackingLog] ON [mfSysTrackingLog] (ID) SELECT SessionID FROM "mfForm_PartFields" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testaa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testaa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testbb" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testbb" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Issue Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Issue Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspections Guide" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspections Guide" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Issues" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Issues" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections List" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Street Inspections List" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspection Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Inspection Photos" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Menu" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Menu" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCN" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCN" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNStartUp" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNStartUp" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNNoGenerator" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNNoGenerator" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShift" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShift" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_DogFouling" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_DogFouling" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OffenceList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OffenceList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShiftDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PCNShiftDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNMain" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_IssuePCNMain" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditsToClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditsToClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Check Item" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Check Item" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Audit" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Audit" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AuditClaim" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AIMS" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_AIMS" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Main" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Main" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_CheckItemActions" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_CheckItemActions" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_HRA" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_HRA" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_TEST LISTS2" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_TEST LISTS2" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OrderList_OL" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_OrderList_OL" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Statement_ST" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Statement_ST" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_LastOrderList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_LastOrderList" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_StatementData_SD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_StatementData_SD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Receipt_R" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Receipt_R" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReport_RR" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReport_RR" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Form 1aa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Form 1aa" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReportData_RRD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_ReceiptReportData_RRD" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testpush" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_testpush" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_pushlist" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_pushlist" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_eeeee" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_eeeee" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestData" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestData" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestUpdate" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_PushTestUpdate" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobDet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobDet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_userdet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_userdet" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_VisitDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_VisitDetails" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Welcome" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Welcome" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Photo" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_Photo" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobFields" WHERE Flags IN (2,3) GROUP BY SessionID; SELECT SessionID FROM "mfForm_JobFields" WHERE Flags IN (2,3) GROUP BY SessionID; DROP TABLE 'mfForm_TEST LISTS'; DROP TABLE 'mfForm_Debug'; DROP TABLE 'mfForm_asfsd'; DROP TABLE 'mfForm_Street Issues List'; DROP TABLE 'mfForm_Check Groups'; DROP TABLE 'mfForm_OrderEntry_OE'; DROP TABLE 'mfForm_PCNList'; DROP TABLE 'mfForm_ProductEntry_PE'; DROP TABLE 'mfForm_PushTest'; DROP TABLE 'mfForm_NullTest'; DROP TABLE 'mfForm_Order details'; DROP TABLE 'mfForm_test1'; DROP TABLE 'mfForm_Form 1'; DROP TABLE 'mfForm_Form 3'; DROP TABLE 'mfForm_Form 2'; DROP TABLE 'mfForm_Options'; DROP TABLE 'mfForm_PartDetails'; DROP TABLE 'mfForm_Jobs'; DROP TABLE 'mfForm_Confirm'; DROP TABLE 'mfForm_Unfinished'; DROP TABLE 'mfForm_Errors'; DROP TABLE 'mfForm_JobOptions'; SELECT * FROM "mfSysSyncLog"; SELECT * FROM "mfSysSyncLog"; SELECT * FROM "mfSysTrackingLog"; SELECT * FROM "mfSysTrackingLog"; SELECT MAX(SessionID) FROM "mfForm_Welcome"; SELECT MAX(SessionID) FROM "mfForm_Welcome"; CREATE TABLE "mfForm_Welcome" ("SessionID" numeric PRIMARY KEY , "UID" numeric , "Flags" numeric , "Expiry" numeric , "Spare" numeric , "D3_txtUser" text , "D3_DEVICE" text , "D3_txtDesc" text , "D3_txtMsgDay" text , "D3_txtCode" text ); INSERT INTO "mfForm_Welcome" (SessionID, UID, Flags, Expiry, Spare, "D3_txtUser", "D3_DEVICE", "D3_txtDesc", "D3_txtMsgDay", "D3_txtCode") VALUES (1,-1,1,0,0,"1", "OEYQB-8LSG1-Y1GRW-RDG9X", "John Smith", "Welcome to the Integral mForms ExpressHaulage sample from Integral Mobile Data", "1234"); COMMIT; VACUUM; 
Step 5. This is on thread 1 and the query that fails but should work!
 SELECT DISTINCT("SessionID") FROM "mfForm_Welcome" WHERE UID IN (-1, 1) AND "D3_TXTCODE" LIKE "1234" ORDER BY SessionID DESC; 
_2007-Jul-19 15:48:30 by anonymous:_ {linebreak} See Ticket #2486: pragma index_list does not detect index created on 2nd connection ---- _2007-Jul-19 16:32:00 by anonymous:_ {linebreak} With multi-threaded programs becoming more prevalent due to multi-core chips, having one thread not know the schema of the database is becoming a problem. ---- _2007-Jul-19 16:37:44 by drh:_ {linebreak} This problem has nothing to do with schema loading. The error is that the change counter in the header of the database file was not being incremented following a VACUUM. ---- _2007-Jul-20 10:48:38 by anonymous:_ {linebreak} Many thanks that seems to have sorted it. #f2dcdc 2517 code active 2007 Jul anonymous 2007 Jul dflam 1 1 exception on reading text in vista but not xp 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:_ {linebreak} 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. #c8c8c8 2516 code closed 2007 Jul anonymous 2007 Jul 3 3 REGRESSION:sqlite3_prepare ignores nBytes parameter Bug described as in Ticket #1554 reappeared in recent versions of sqlite (tested debian 3.3.8, and 3.4.0 built from release tarball). Code snippet :
 int rc = sqlite3_prepare( sqlite_                         , "insert  into JOB_TODO values (24, 1, 4,  'C', 'p', NULL, NULL, 'respawn', '/usr/bin/moma/mbx_selection 2 /tmp/select_pipe_ED2 300 600 \0', NULL, NULL );"                         , 151, &stmt, NULL ) ; 
Fails with error
 unrecognized token: "'/usr/bin/moma/mbx_selection 2 /tmp/select_pipe_ED2 300 600 " 
Looking at the code, we can find the related [3040] CVS commit in prepare.c (as described in ticket #1554), but the bug still occurs _2007-Jul-19 11:11:36 by anonymous:_ {linebreak} sqlite_prepare_v2 has the same problem ---- _2007-Jul-19 12:12:54 by drh:_ {linebreak} The nBytes parameter is working fine. The problem is that SQLite does not accept strings that contain embedded \0 characters. And this is not going to change. If you want to insert a string that contains an embedded \0, use ? for the string in sqlite3_prepare() then bind the string using {link: /capi3ref.html#sqlite3_bind_text sqlite3_bind_text()}. #c8c8c8 2515 code closed 2007 Jul anonymous 2007 Jul 1 1 Entered to ASCII zeros as a text string was return a single zero. I have created a Schema that defines all but one column as a string. When I insert data that is defined as '00', '06', '05', etc. I receive no error for the insertion. But, when I retrieve the data it returns the data with the preceeding zero removed. This should not occur when the data is defined as a string and not defined to be of a numeric type. This does not occur for any other type string data. _2007-Jul-18 21:47:55 by drh:_ {linebreak} Here's what I get: CREATE TABLE t1(x TEXT); INSERT INTO t1 VALUES('00'); SELECT * FROM t1; 00 Unable to reproduce the problem. #cfe8bd 2514 code fixed 2007 Jul anonymous 2007 Jul 3 3 max() and min() is wrong when DESC index exists testcase: sqlite> PRAGMA legacy_file_format=0; sqlite> CREATE TABLE t(a); sqlite> INSERT INTO t VALUES(2); sqlite> INSERT INTO t VALUES(1); sqlite> CREATE INDEX t_a ON t(a DESC); sqlite> SELECT min(a) FROM t; 2 sqlite> SELECT max(a) FROM t; 1 Proposed fix: --- src/select.c~ 2007-06-16 00:31:50.000000000 +0900 +++ src/select.c 2007-07-18 23:48:07.680080000 +0900 @@ -2485,7 +2485,9 @@ static int simpleMinMaxQuery(Parse *pPar if( seekOp==OP_Rewind ){ sqlite3VdbeAddOp(v, OP_Null, 0, 0); sqlite3VdbeAddOp(v, OP_MakeRecord, 1, 0); - seekOp = OP_MoveGt; + seekOp = pIdx->aSortOrder[0]==SQLITE_SO_ASC ? OP_MoveGt : OP_MoveLt; + }else if( pIdx->aSortOrder[0]==SQLITE_SO_DESC ){ + seekOp = OP_Rewind; } sqlite3VdbeAddOp(v, seekOp, iIdx, 0); sqlite3VdbeAddOp(v, OP_IdxRowid, iIdx, 0); #c8c8c8 2513 code closed 2007 Jul anonymous 2007 Jul 1 2 Internal compiler error tclsqlite.c Using make with Windows XP with MSYS and MinGW 3.4.5 after ./configure --with-tcl=C:/dev/Tcl/lib produces this error ./src/tclsqlite.c: In function 'Sqlite3_Init': ./src/tclsqlite.c:2421: internal compiler error: in rest_of_handle_final, at toplev.c:2067 Robert Wishlaw _2007-Jul-17 20:30:28 by drh:_ {linebreak} Seem like an "internal compiler error" is the type of thing you should report to the compiler vendor, not to the makers of the code you are trying to compile.... #f2dcdc 2512 code active 2007 Jul shess 2007 Jul 1 1 FTS virtual table name quoting problem 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:_ {linebreak} 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.". #f2dcdc 2511 code active 2007 Jul anonymous 2007 Jul drh 3 2 Inconsistent Pragma output 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 #f2dcdc 2510 code active 2007 Jul anonymous 2007 Jul 1 1 Vacuum modified FTS2 rowids 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:_ {linebreak} http://www.sqlite.org/cvstrac/chngview?cn=4157 ---- _2007-Jul-17 14:24:29 by anonymous:_ {linebreak} 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:_ {linebreak} Should virtual tables be VACUUMable? What exactly is being vacuumed here - an internal table? ---- _2007-Jul-17 16:34:55 by shess:_ {linebreak} 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:_ {linebreak} 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; inColumn; ++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; inColumn; ++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; inColumn; ++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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 2509 code active 2007 Jul anonymous 2007 Jul 1 1 SQLITE_DATE 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. #cfe8bd 2507 code fixed 2007 Jul anonymous 2007 Jul 1 1 test_expr expr-1.104 fails (64-bit int handling) make test fails with: expr-1.104...make: *** [test] Floating point exception System info: gcc-4.1.2, glibc-2.5-r4, 2.6.22.1 x86_64 _2007-Jul-16 18:56:02 by drh:_ {linebreak} Already fixed. See [4130] and [4131]. #c8c8c8 2505 code closed 2007 Jul anonymous 2007 Jul 1 1 does not return error when use sqlite_open to open an non-sqlite db I use sqlite_open api to open an non sqlite database, for example an exe file.The result of sqlite_open is not an error code but sqlite_ok. Sqlite does not actually read the database file until the first SQL query is executed. So the sqlite3_open succeeds but the first call to sqlite3_prepare_v2() or sqlite3_exec() will return an error. #c8c8c8 2504 build closed 2007 Jul anonymous 2007 Jul 1 1 sqlite 3.4.0 fails to build FreeBSD 6.2 64-bit system Attached is the configure and make output. As this is a FreeBSD 6.2 AMD 64-bit box, several "warning: cast from pointer to integer of different size" in func.c, table.c, and vdbemem.c concern me as potential bugs. Added to the fact the the undefined reference to __isnanl. The warnings also appear in 3.3.17 version of SQLite, which I hadn't noticed before, but the there was no undefined reference preventing the build. _2007-Jul-13 17:13:47 by anonymous:_ {linebreak} submitter: anthony howe, achowe@snert.com ---- _2007-Jul-13 17:34:33 by drh:_ {linebreak} Already fixed by check-in [4103]. #f2dcdc 2503 code active 2007 Jul anonymous 2007 Jul 3 4 sqlite3PagerReleaseMemory does not decrement page count 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:_ {linebreak} Do you have a simple test case that demonstrates this? Put a print statement in pager.c if necessary. #cfe8bd 2502 code fixed 2007 Jul anonymous 2007 Jul 4 4 Digital Mars static library runtime problem When I attempt to use a SQLite 3.4.0 static library built with Digital Mars C/C++, I get these errors sqlite340dm.lib(sqlite340dm) Error 42: Symbol Undefined _sqlite3ParserFree sqlite340dm.lib(sqlite340dm) Error 42: Symbol Undefined _sqlite3Parser sqlite340dm.lib(sqlite340dm) Error 42: Symbol Undefined _sqlite3ParserAlloc If I comment out lines 65930-65932 in sqlite3.c extern void *sqlite3ParserAlloc(void*(*)(size_t)); extern void sqlite3ParserFree(void*, void(*)(void*)); extern void sqlite3Parser(void*, int, Token, Parse*); then the static library works as expected. Robert Wishlaw #c8c8c8 2501 build closed 2007 Jul anonymous 2007 Jul 2 3 limits.h confilct with visual studio limits.h When I include sqlite3.h in my code, and provide the sqlite headers folder to complier include path, limits.h is picked up from sqlite headers even when it must be picked from vc/include, so I get errors compiling other files that we compiling fine. Current workaround is I provide the parent folder of sqlite headers as include path for compiler and instead of #include "sqlite3.h", I do a #include "sqlite-3.4.0/sqlite3.h" _2007-Jul-12 20:39:41 by drh:_ {linebreak} See tickets #2428 and #2495. #c8c8c8 2500 code closed 2007 Jul anonymous 2007 Jul 2 4 Possible memory leak on avr32 arch I am using sqlite in a C written application running on an embedded device based on an avr32 (the 32AP7000) from atmel. It seams that executing some insertion cause a memory leak. The simpliest leaking code is something like this : (The complete code include error check, error messages freeing, and non-infinite loop.) int main(int ac, char **av) { sqlite3 *db; char *zErrMsg = 0; sqlite3_open(DB_PATH, &db)) while (42) sqlite3_exec(db, "INSERT INTO high (io1) VALUES (1);" NULL, NULL, &zErrMsg)); sqlite3_close(db); return 0; } I've tested with both sqlite3.4.0 and 3.3.6-94 binaries. Based on the tests i have done the amount of memory leaking depends on the number of row in the table and the size of the sql statement It also seems that a 'SELECT' sql statement does not leak at all. It also appear that some of the leaking memory is never returned to the system. I suppose that the problem is somewhere between the sqlite memory management system and the device's one. I still can not tell for sure if the problem lie on the sqlite or the board but i have successfuly ported some heavy memory consumer without experiencing such problems. Maybe the software shiped with my board don't have default behavior for some memory managment tasks and cause sqlite not to act as it should ? I am actually working on getting some more informations on how and where it leak. (porting valgrind, dmalloc or something) So i will try to provide some more information as soon as i can. Maybe you can look at the contents of zErrMsg first? ---- _2007-Jul-13 08:16:37 by anonymous:_ {linebreak} I've already checked zErrMsg and freed it if necessary. ---- _2007-Jul-13 08:57:59 by anonymous:_ {linebreak} Sorry i didn't understand i am focussed on "where is my memory" :). If you meens to check what error happen, then i don't get any errors everything goes fine and return is SQLITE_OK. The comportement is good exept that the data segment of a program doing multiple inertions keep growing. ---- _2007-Jul-13 13:37:06 by anonymous:_ {linebreak} Some fresh news. First the memory leaked seems to be correctly freed when the process done, it was my misunderstanding. Next doing a quick wrapper around sqlite3GenericFree and sqlite3GenericMalloc i found something interristing : Each time i am doing an insert some of the memory allocated wont be freed untill calling sqlite3_close, which cause the process to grow. Since the sqlite malloc mecanism is pretty dark to me i still don't understand how such a behavior happen. ---- _2007-Jul-16 13:50:17 by danielk1977:_ {linebreak} Because sqlite3_close() does free the possibly leaked allocations, we can probably assume this is just the pager cache growing normally. See the documentation for the "cache_size" pragma for details. #f2dcdc 2498 code active 2007 Jul anonymous 2007 Jul 3 2 sqlite memory org on linux (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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 2497 code closed 2007 Jul anonymous 2007 Jul 4 2 sqlite3_errcode does not return the proper error code sqlite3_errcode does not return the same result as the last api call when using a progress handler that aborts the connection. sqlite3_step returns SQLITE_ABORT, but sqlite3_errcode is returning SQLITE_ERROR. A test case can be found here: https://bugzilla.mozilla.org/attachment.cgi?id=271753 Downstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=387609 -sdwilsh _2007-Jul-11 06:37:52 by danielk1977:_ {linebreak} When it comes to setting the database error code, sqlite3_step() behaving the same way regardless of whether sqlite3_prepare() or sqlite3_prepare_v2() is used to prepare the query. So when an error is returned from sqlite3_step() on a statement prepared with _v2(), the "real" error code is returned but the database error code is being set to SQLITE_ERROR. I'm thinking we should change to set the database error code and message to the "real" error code in this case. Also, note that this test-case is incompatible with version 3.4.0. In prior versions, if the progress-handler returns non-zero, the statement is halted and SQLITE_ABORT is returned. In 3.4.0, this error code is now SQLITE_INTERRUPT. ---- _2007-Jul-12 16:35:37 by anonymous:_ {linebreak} Thanks for the heads up. -sdwilsh #f2dcdc 2496 code active 2007 Jul anonymous 2007 Jul 5 4 "No such column" error should include table information 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 #c8c8c8 2495 code closed 2007 Jul anonymous 2007 Jul 4 4 standard C library Naming conflict - limits.h "limits.h" You should really avoid using filenames conflicting with the standard C library. It took me a few minutes to figure out why my code was not compiling. Then I realized that was resolving to the SQLITE header. Best Wishes, -David Delaune Software Engineer Marine Technologies, LLC oops, I just found this issue was corrected in ticket 2428. Closing the ticket. -David Delaune #c8c8c8 2494 code closed 2007 Jul anonymous 2007 Jul 1 1 DRow["ID"] = reader.GetString(reader.GetOrdinal("ID")); fails DRow["ID"] = reader.GetString(reader.GetOrdinal("ID")); This fails under Vista Ultimate, succeeds under XP Pro. It is Sqlite 3.1, will upgrading help? Thanks! Jim Please post your question to the author of the sqlite wrapper for whatever language you're using. #c8c8c8 2493 build closed 2007 Jul anonymous 2007 Jul 2 3 Fails to build under GCC-4.1.3 on FreeBSD-6.2 OS: FreeBSD-6.2 When using the build-in gcc 3.4.6 [FreeBSD] 20060305, sqlite3, version 3.3.17 builds fine. However, when using gcc 4.1.3 20070618, sqlite3 version 3.3.17 fails to build. A copy of the failed build attempt is attached. _2007-Jul-09 13:23:38 by anonymous:_ ===> Applying FreeBSD patches for sqlite3-3.3.17 Your SQLite sources have apparently been modified for FreeBSD. This is a question for the BSD port system maintainers or simply google "unable to infer tagged configuration" where you will find many workarounds for your operating system. libtool: link: unable to infer tagged configuration libtool: link: specify a tag with `--tag' gmake: *** [libsqlite3.la] Error 1 *** Error code 2 Stop in /usr/ports/databases/sqlite3. ---- _2007-Jul-21 19:58:11 by anonymous:_ {linebreak} This is a libtool bug that happens when the C compiler you're using is not named 'gcc'. As a workaround in your case: CC=/usr/local/bin/gcc41 ./configure make Above command assumes bash shell. Use appropriate construct for other shells. #c8c8c8 2492 code closed 2007 Jul anonymous 2007 Jul 4 4 Incorrect protoype for function sqlite3_result_zeroblob Line 1859 in sqlite3.h and line 1882 in sqlite3.c void sqlite3_result_zeroblob(sqlite3_context*, int n); should read void sqlite3_result_zeroblob(sqlite3_context*, int); #f2dcdc 2491 code active 2007 Jul anonymous 2007 Jul 1 1 Mingw Warnings w/ 3.4.0 Amalgamation When compiling the 3.4.0 amalgamation sqlite3.c file w/ no defines, you get the following warnings: sqlite3/sqlite3.c: In function `sqlite3BtreeFindCell':{linebreak} sqlite3/sqlite3.c:23249: warning: unused variable `data'{linebreak} sqlite3/sqlite3.c: In function `vxprintf':{linebreak} sqlite3/sqlite3.c:8488: warning: 'xtype' might be used uninitialized in this function{linebreak} sqlite3/sqlite3.c: In function `sqlite3BtreeOpen':{linebreak} sqlite3/sqlite3.c:19488: warning: 'nameLen' might be used uninitialized in this function{linebreak} sqlite3/sqlite3.c: In function `getOverflowPage':{linebreak} sqlite3/sqlite3.c:25386: warning: 'rc' might be used uninitialized in this function{linebreak} sqlite3/sqlite3.c: In function `sqlite3Select':{linebreak} sqlite3/sqlite3.c:56300: warning: 'pEList' might be used uninitialized in this function{linebreak} sqlite3/sqlite3.c:56301: warning: 'pTabList' might be used uninitialized in this function{linebreak} sqlite3/sqlite3.c: At top level:{linebreak} sqlite3/sqlite3.c:16020: warning: 'sqlite3GenericAllocationSize' defined but not used{linebreak} sqlite3/sqlite3.c:6188: warning: 'sqlite3Utf16Substr' declared `static' but never defined{linebreak} sqlite3/sqlite3.c:6307: warning: 'sqlite3Get2byte' declared `static' but never defined{linebreak} sqlite3/sqlite3.c:6309: warning: 'sqlite3Put2byte' declared `static' but never defined{linebreak} sqlite3/sqlite3.c:23248: warning: 'sqlite3BtreeFindCell' defined but not used{linebreak} sqlite3/sqlite3.c:63547: warning: 'sqlite3ParserAlloc' defined but not used{linebreak} sqlite3/sqlite3.c:63673: warning: 'sqlite3ParserFree' defined but not used{linebreak} sqlite3/sqlite3.c:65286: warning: 'sqlite3Parser' defined but not used{linebreak} 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. #c8c8c8 2489 build closed 2007 Jul anonymous 2007 Jul 1 1 Latest cvs 3.4.0 make test fails related to TCL Here's how I'm building. I've tried --disable-tcl and --enable-tcl with no joy. I'm using latest Fedora 7 with tcl-8.4.13 installed. mkdir -p /build/work/sqlite-3.4.0.1 cd /build/work/sqlite-3.4.0.1 unset CDPATH export CFLAGS='-pipe -O3 -g' make distclean cvs -d :pserver:anonymous@www.sqlite.org:/sqlite -r update . ./configure --prefix=/usr/local/pkgs/sqlite-3.4.0.1 --disable-tcl 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 /build/work/sqlite-3.4.0.1/./src/tclsqlite.c:2416: undefined reference to `Tcl_CreateObjCommand' /build/work/sqlite-3.4.0.1/./src/tclsqlite.c:2417: undefined reference to `Tcl_PkgProvide' /build/work/sqlite-3.4.0.1/./src/tclsqlite.c:2418: undefined reference to `Tcl_CreateObjCommand' ... hundreds of errors deleted ... "make test" requires Tcl to function. Post the result of "grep -i tcl config.log" after you run ./configure with no arguments. The key to it working is finding tclConfig.sh
 configure:19220: checking for Tcl configuration configure:19302: result: found /usr/lib/tclConfig.sh configure:19305: checking for existence of /usr/lib/tclConfig.sh ac_cv_c_tclconfig=/usr/lib HAVE_TCL='1' TCL_BIN_DIR='/usr/lib' TCL_INCLUDE_SPEC='-I/usr/include/tcl8.4.13' TCL_LIBS='-ldl  -lpthread -lieee -lm' TCL_LIB_FILE='libtcl8.4.so' TCL_LIB_FLAG='-ltcl8.4' TCL_LIB_SPEC='-L/usr/lib -ltcl8.4' TCL_SRC_DIR='/usr/include/tcl8.4.13' TCL_STUB_LIB_FILE='libtclstub8.4.a' TCL_STUB_LIB_FLAG='-ltclstub8.4' TCL_STUB_LIB_SPEC='-L/usr/lib -ltclstub8.4' TCL_VERSION='8.4' 
---- _2007-Jul-07 03:49:21 by anonymous:_ {linebreak} Ah I see now. I'm using a 64 bit machine so tcl lives in the 64 bit directory hierarchy. Here's how I got most of the tests to run: export CFLAGS='-pipe -O3 -g -DSQLITE_DISABLE_DIRSYNC=1 -Wall' make distclean cvs -d :pserver:anonymous@www.sqlite.org:/sqlite -r update . ./configure --prefix=/usr/local/pkgs/sqlite-3.4.0.1 --enable-tcl --with-tcl=/usr/lib64 This ticket can close. I'll do some further testing and open another ticket about the single thread test that fails. ---- _2007-Jul-07 11:43:05 by drh:_ {linebreak} Please note that this is an open ticketing system. Anybody can close a ticket. You do not need to ask me or Dan to do it. #f2dcdc 2488 new active 2007 Jul anonymous 2007 Jul 5 4 autosize on column output mode in sqlite3 program 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:_ {linebreak} 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:_ {linebreak} 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. {linebreak} 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:_ {linebreak} 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 #f2dcdc 2487 code active 2007 Jul anonymous 2007 Jul 1 1 SQLite database locked error on NFS mounted home dir 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} It's very odd that Apple does not fix their Mac OSX POSIX locks for NFS given their resources. #c8c8c8 2485 code closed 2007 Jul anonymous 2007 Jul 1 2 SQLite + Python segfaults at various places in the code I've been getting segfaults while running unit tests on my code base (http://drproject.org). It is written in Python and uses SQLAlchemy for database abstraction. I believe the Python module is PySQLite2. After taking some core dumps, they all seem to point to SQLite code (but different parts each time). Another guy I'm working with is having similar problems with some code he is working on. I have run memtest over night (turning up nothing), so I don't _think_ it's my machine. I am not sure what would be most helpful for you, so before I start throwing around 20 meg core dumps, I thought I'd check and see what you would prefer. _2007-Jul-04 17:05:32 by anonymous:_ Try the mailing list as your problem is not pure SQLite problem. ---- _2007-Jul-05 06:25:40 by danielk1977:_ {linebreak} If it's different places in the code each time, this really sounds like a corrupted heap. It may be that it is SQLite corrupting the heap, or it may be the wrapper code. Posting to the mailing list is probably the best way to progress this. ---- _2007-Jul-05 13:02:35 by anonymous:_ {linebreak} Setting up and learning the inner workings of another computer language and third party wrappers requires a lot of effort. You greatly increase your odds of finding the source of your bug if you make a small standalone C or Tcl program that demonstrates the problem using only the SQLite API. This eliminates the possibility that the host language or wrapper is corrupting memory or doing something else wrong. Often in the process of creating such a standalone test case, people find their own mistake. #f2dcdc 2484 new active 2007 Jul anonymous 2007 Jul 5 4 Support for RETURNING 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. #c8c8c8 2483 code closed 2007 Jul anonymous 2007 Jul 1 3 like clause not working while using the Trac SCM tool I've experienced some issues with the database usage of the like clause in certain select statements. with values for name such as 'TracIni', 'TracBrowser', 'TracFqastCGI' the following quert does not catch any of the above names: SELECT name FROM wiki WHERE name like 'Trac'; seems to be that this should catch it. _2007-Jul-04 03:56:32 by anonymous:_ {linebreak} To catch the terms you are looking for, wouldn't you need this query: SELECT name FROM wiki WHERE name like 'Trac%' #c8c8c8 2482 code closed 2007 Jul anonymous 2007 Jul 3 4 Possible optimizer bug The versions I have tested are 3.3.5 and 3.4.0. Here you see the same query four times with different table ordering and sometimes an additional OR clause. The queries are executed on an ARM device, but I observed the same behavior on x86. I know that the table ordering makes a difference in query execution time but I'm rather puzzled by the behavior I get here. The "OR 0" doesn't make much sense to me, it was coincidence that I discovered it. 1: The query as intended, this takes a rather long time:{linebreak} "select pr_value from property join item_prop on ip_prop=pr_id where ip_item=1049545 and ip_visible=1 and pr_class=4"{linebreak} Executed once: 127 ms{linebreak} Executed 10 times: 264 ms 2: The same as above but I added a "OR 0" which shouldn't change anything. The same query is now much faster:{linebreak} "select pr_value from property join item_prop on ip_prop=pr_id where ip_item=1049545 and ip_visible=1 and (pr_class=4 OR 0)"{linebreak} Executed once: 4 ms{linebreak} Executed 10 times: 30 ms 3: The same query as 1. but with exchanged table order:{linebreak} "select pr_value from item_prop join property on ip_prop=pr_id where ip_item=1049545 and ip_visible=1 and pr_class=4"{linebreak} Executed once: 3 ms{linebreak} Executed 10 times: 28 ms 4: Added an additional "OR 0" to 3. This is now slower than the previous:{linebreak} "select pr_value from item_prop join property on ip_prop=pr_id where ip_item=1049545 and ip_visible=1 and (pr_class=4 OR 0)"{linebreak} Executed once: 3 ms{linebreak} Executed 10 times: 32 ms The tables used: create table property ( pr_id integer primary key, pr_value text, pr_class int ); create index pr_idx1 ON property(pr_id); create index pr_idx2 ON property(pr_value COLLATE NOCASE); create index pr_idx3 ON property(pr_class); create table item_prop ( ip_item int, ip_prop int, ip_visible int default 1 ); create index ip_idx2 ON item_prop(ip_item); create index ip_idx3 ON item_prop(ip_prop); _2007-Jul-02 16:01:24 by drh:_ {linebreak} Thank you for taking the time to learn enough about the wiki formatting rules to format the problem description so that it is easily readable! We do not normally consider a problem to be a "bug" if it gets the correct answer, even if the answer takes longer than you want to obtain. My understanding is that all of the queries above return the correct answer and you just want them to go faster. This is not a bug. For help in optimizing your queries, please post on the sqlite mailing list. Instructions for subscribing to the mailing list can be found at _: http://www.sqlite.org/support.html You will probably get better results in this case if you do one or both of the following: *: Drop the pr_idx3 index. *: Run the ANALYZE command. ---- _2007-Jul-02 20:55:18 by anonymous:_ {linebreak} Yes, they actually work as expected. Thanks for the hints. The actual reason why I posted this ticket is the weird improve in performance by adding a "OR 0" which doesn't change anything on the query itself. Everything is the same except for this no-op condition. If the optimizer would do such a thing by default (whatever it is that it does) then this could possibly improve the sqlite performance in other scenarios as well. #c8c8c8 2481 code closed 2007 Jul anonymous 2007 Jul 1 3 sqlite leaks memory (after 3.3.13) After upgrade from 3.3.12 to 3.4.0 I noticed an huge negative impact on memory usage of my SQLite-based programs. I suspected a bug in my code. After some debugging, I created a simple program and narrowed this down to the following: 1: this started from 3.3.14 and is still relevant for 3.4.0 2: 3.3.13 was the last version which "worked" as expected Attached is a sample program which demonstrates the problem. sqlite3 command utility exhibits the same increase and the same memory usage patterns. Basically, what happens is that memory allocated by SQLite is first released after call to sqlite3_close(). It seems like the memory usage will eventually "stabilize" and only increase again in smaller chunks. This is on OpenBSD 4.1/i386.
 ssehic@dev-5-i386:/profense/devel$ ls -l /profense/log/logdata.db -rwxrwxr-x  1 _admd  profense  12106752 Jul  1 23:15 /profense/log/logdata.db  ssehic@dev-5-i386:/profense/devel$ sqlite3 /profense/log/logdata.db "select count(*) from log" 156000  ssehic@dev-5-i386:/profense/devel/sqlmem SQLite version 3.3.13 Usage (bytes)               initial, rssize=487424, dsize=241664 Usage (bytes) after SELECT COUNT(*), rssize=1417216, dsize=704512 Usage (bytes)   after sqlite3_close, rssize=1318912, dsize=618496  ssehic@dev-5-i386:/profense/devel/sqlmem SQLite version 3.4.0 Usage (bytes)               initial, rssize=495616, dsize=241664 Usage (bytes) after SELECT COUNT(*), rssize=22118400, dsize=21331968 Usage (bytes)   after sqlite3_close, rssize=1351680, dsize=618496 
I'm sure something like this should not go unnoticed by the developers. However, I can't believe this is specific to OpenBSD. Something changed after 3.3.13 which broke this in a subtle way. Any hints? _2007-Jul-01 23:03:42 by drh:_ {linebreak} Your test program appears to be OpenBSD-specific. I cannot compile it on Linux. So I cannot replicate your problem. We do test SQLite using both its own internal memory leak detection logic and valgrind, and both report no memory leaks over the entire test suite. ---- _2007-Jul-02 07:31:57 by anonymous:_ {linebreak} Yes. The test program is OpenBSD specific, but only the memory reporting stuff (print_memory_usage()). I'll see if I can provide a Linux variant and complete details on how to reproduce the problem. More to come. ---- _2007-Jul-02 09:28:42 by anonymous:_ {linebreak} I think I figured this one out. The problem is only reproducible if the database is created using sqlite3 prior to 3.3.14 and queries are later run on the same database using 3.4.0. This is weird, since the database format should be backwards compatible between releases. However, lots of "performance improvements" went in after 3.3.13. This could have something to do with it. At http://insecure.dk/bin/logdata.db.gz is a test database created with 3.3.12. If you run a "SELECT COUNT(*) FROM log" on that using 3.4.0, you should see the memory usage increase greatly using sqlite3 utility. ---- _2007-Jul-02 10:38:12 by anonymous:_ {linebreak} This ticket can be closed. Increased memory usage is due to my test database (created with 3.3.12) used PRAGMA default_cache_size = 10000; Apparently versions > 3.3.14 allocate all the memory on the first database query. That's why I saw the jump in memory usage. Sorry for the noise. ---- _2007-Jul-02 10:38:41 by drh:_ {linebreak} I downloaded logdata.db from the link above and ran "SELECT count(*) FROM log" against it using the latest version of SQLite from CVS (which i closer to 3.4.1 than to 3.4.0, I suspect). I did this using valgrind: valgrind --leak-check=full --show-reachable=yes \ ./sqlite3 logdata.db 'select count(*) FROM log' Valgrind tells me that 156 bytes of memory were leaked in 11 allocations. All of the leaked memory was allocated by the getpwuid_r() function in glibc - not from SQLite. The total memory allocated was 13,515,680 bytes, which considering that the logdata.db database specifies a cache size of 10,000 pages and you are reading (and thus attempting to cache) the entire 50MB database, this is about what one would expect. I am unable to reproduce the problem. ---- _2007-Jul-02 10:50:40 by anonymous:_ {linebreak} That was my conclusion as well. Thanks again for the great work and unbelievably speedy responses to "bug" reports. #cfe8bd 2475 code fixed 2007 Jun anonymous 2007 Jul 1 3 Handles being left open on unix On unix, I'm seeing processes that have been clone/exec'd inheriting file handles to sqlite databases that were opened in the parent process (and hence subsequently don't/can't get closed in the child process). Which ultimately means that you can't unmount a filesystem. The solution is the FD_CLOEXEC fcntl on the open filehandle, but I'd like to get confirmation from elsewhere/highlight it to DRH/the list to make them aware of it. Tested and fixed by the below patch (against 3.3.6). ==== //depot/qt/4.2/src/3rdparty/sqlite/os_unix.c#2 - /home/bking/depot/qt/4.2/src/3rdparty/sqlite/os_unix.c ==== @@ -701,7 +701,7 @@ OsFile **pId, int *pReadonly ){ - int rc; + int rc, oldflags; unixFile f; CRASH_TEST_OVERRIDE(sqlite3CrashOpenReadWrite, zFilename, pId, pReadonly); @@ -730,6 +730,12 @@ return SQLITE_NOMEM; } TRACE3("OPEN %-3d %s\n", f.h, zFilename); + oldflags = fcntl (f.h, F_GETFD, 0); + if (oldflags >= 0) + { + oldflags |= FD_CLOEXEC; + fcntl (f.h, F_SETFD, oldflags); + } return allocateUnixFile(&f, pId); } @@ -749,7 +755,7 @@ ** On failure, return SQLITE_CANTOPEN. */ int sqlite3UnixOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){ - int rc; + int rc, oldflags; unixFile f; CRASH_TEST_OVERRIDE(sqlite3CrashOpenExclusive, zFilename, pId, delFlag); @@ -772,6 +778,12 @@ unlink(zFilename); } TRACE3("OPEN-EX %-3d %s\n", f.h, zFilename); + oldflags = fcntl (f.h, F_GETFD, 0); + if (oldflags >= 0) + { + oldflags |= FD_CLOEXEC; + fcntl (f.h, F_SETFD, oldflags); + } return allocateUnixFile(&f, pId); } @@ -783,7 +795,7 @@ ** On failure, return SQLITE_CANTOPEN. */ int sqlite3UnixOpenReadOnly(const char *zFilename, OsFile **pId){ - int rc; + int rc, oldflags; unixFile f; CRASH_TEST_OVERRIDE(sqlite3CrashOpenReadOnly, zFilename, pId, 0); @@ -800,6 +812,12 @@ return SQLITE_NOMEM; } TRACE3("OPEN-RO %-3d %s\n", f.h, zFilename); + oldflags = fcntl (f.h, F_GETFD, 0); + if (oldflags >= 0) + { + oldflags |= FD_CLOEXEC; + fcntl (f.h, F_SETFD, oldflags); + } return allocateUnixFile(&f, pId); } @@ -823,6 +841,7 @@ OsFile *id, const char *zDirname ){ + int oldflags; unixFile *pFile = (unixFile*)id; if( pFile==0 ){ /* Do not open the directory if the corresponding file is not already @@ -836,6 +855,12 @@ return SQLITE_CANTOPEN; } TRACE3("OPENDIR %-3d %s\n", pFile->dirfd, zDirname); + oldflags = fcntl (pFile->dirfd, F_GETFD, 0); + if (oldflags >= 0) + { + oldflags |= FD_CLOEXEC; + fcntl (pFile->dirfd, F_SETFD, oldflags); + } return SQLITE_OK; } _2007-Jun-28 23:07:33 by anonymous:_ {linebreak} You'd need #ifdef FD_CLOEXEC around the code at the very least, since some UNIX-like OSes lack this feature. ---- _2007-Jun-29 00:12:29 by anonymous:_ {linebreak} it's not right to fork() and keep using sqlite3 objects handle if I don't misread the documentation. ---- _2007-Jul-02 00:42:22 by anonymous:_ {linebreak} *it's not right to fork() and keep using sqlite3 objects handle if I don't misread the documentation.* That's true, but sqlite without this change is still leaking filehandles (and keeping files open) on a standard practice fork and exec. I discovered it because applications that weren't even using sqlite were holding files open because the parent process had open handles at the point they were created. ---- _2007-Jul-02 21:04:18 by anonymous:_ {linebreak} Which UNIX-like OSes lack this feature? FD_CLOEXEC part of the Single UNIX Specification, Version 2, and POSIX: http://www.opengroup.org/onlinepubs/007908775/xsh/fcntl.h.html #f2dcdc 2469 build active 2007 Jun anonymous 2007 Jul 1 1 test fails on Solaris 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} I can reproduce the problem now on Linux when compiling as follows: gcc420 -g -O2 -Wall ---- _2007-Jul-01 21:50:42 by drh:_ {linebreak} 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
 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; ju.i;    }    aRoot[j] = 0;    popStack(&pTos, nRoot); 
---- _2007-Jul-21 20:31:01 by anonymous:_ {linebreak} 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:_ {linebreak} 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 The FTS1 and FTS2 extensions use the unportable and highly deprecated on all platforms except Apple Mac OS X. The actually is _never_ required on any OS with an at least partly POSIX-conforming API as malloc(3) and friends officially live in since many years. Under FreeBSD the inclusion of since about 2-3 years even causes an "#error" and this way a build failure. So I recommend to just get rid of the at all.
 Index: ext/fts1/fts1.c --- ext/fts1/fts1.c.orig    2007-06-12 14:18:00 +0200 +++ ext/fts1/fts1.c 2007-06-20 18:09:00 +0200 @@ -19,11 +19,7 @@  #endif   #include  -#if !defined(__APPLE__) -#include  -#else  #include  -#endif  #include   #include   #include  Index: ext/fts1/fts1_porter.c --- ext/fts1/fts1_porter.c.orig 2007-06-12 14:18:00 +0200 +++ ext/fts1/fts1_porter.c  2007-06-20 18:09:00 +0200 @@ -26,11 +26,7 @@    #include  -#if !defined(__APPLE__) -#include  -#else  #include  -#endif  #include   #include   #include  Index: ext/fts1/fts1_tokenizer1.c --- ext/fts1/fts1_tokenizer1.c.orig 2007-06-12 14:18:00 +0200 +++ ext/fts1/fts1_tokenizer1.c  2007-06-20 18:09:00 +0200 @@ -18,11 +18,7 @@    #include  -#if !defined(__APPLE__) -#include  -#else  #include  -#endif  #include   #include   #include  Index: ext/fts2/fts2.c --- ext/fts2/fts2.c.orig    2007-06-13 15:29:40 +0200 +++ ext/fts2/fts2.c 2007-06-20 18:10:05 +0200 @@ -269,9 +269,6 @@  #endif   #include  -#if !defined(__APPLE__) -#include  -#endif  #include   #include   #include  Index: ext/fts2/fts2_porter.c --- ext/fts2/fts2_porter.c.orig 2007-06-12 14:18:00 +0200 +++ ext/fts2/fts2_porter.c  2007-06-20 18:09:35 +0200 @@ -26,11 +26,7 @@    #include  -#if !defined(__APPLE__) -#include  -#else  #include  -#endif  #include   #include   #include  Index: ext/fts2/fts2_tokenizer1.c --- ext/fts2/fts2_tokenizer1.c.orig 2007-06-12 14:18:00 +0200 +++ ext/fts2/fts2_tokenizer1.c  2007-06-20 18:09:46 +0200 @@ -18,11 +18,7 @@    #include  -#if !defined(__APPLE__) -#include  -#else  #include  -#endif  #include   #include   #include  
#cfe8bd 2382 doc fixed 2007 May anonymous 2007 Jul 3 3 VACUUM alters/repacks the ROWIDs if no explicit primary key is given *VACUUM* repacks the ROWIDs when no explicit primary key is given. This probably makes sense but scanning over the documentation I didn't see a reference to this (I have used OID as an I for joins in the past without explicitly specifying this so things break in these cases, clearly I shouldn't do this but a minor update to the documentation probably wouldn't hurt?). sqlite> .sc CREATE TABLE t1 ( c1 integer ); sqlite> select oid,* from t1; rowid c1 ---------- ---------- 3 30 sqlite> vacuum; sqlite> select oid,* from t1; rowid c1 ---------- ---------- 1 30 sqlite> .sc CREATE TABLE t2 ( c1 integer primary key ); sqlite> select oid,* from t2; c1 c1 ---------- ---------- 30 30 sqlite> vacuum; sqlite> select oid,* from t2; c1 c1 ---------- ---------- 30 30 _2007-Jul-13 06:40:27 by anonymous:_ {linebreak} I had the same problem; it took me several days to figure out that =VACUUM= was breaking my 'foreign key' relations. Not a single word in a documentation about this, I had to figure out from countless experiments and ensure by reading vacuum source code. I believe that =VACUUM= should use =SELECT ROWID,* FROM ...= to backup the database. In certain application, this issue (bug?) renders the =VACUUM= command unusable. #f2dcdc 2377 build active 2007 May pweilbacher 2007 Jul 4 3 Allow easy DLL build on OS/2 =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:_ {linebreak} 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. #c8c8c8 2243 code closed 2007 Feb anonymous 2007 Jul 2 3 sqlite3 authorizer cannot be exposed in garbage collected languages While a documentation fix (#2242) certainly clarifies that nested subqueries are forbidden, could at least sqlite3_finalize be supported? It would be a shame if languages that are garbage collected (as opposed to reference counted ala TCL) cannot expose the authorizer functionality. _2007-Feb-21 17:08:03 by anonymous:_ {linebreak} Why must garbage be collected in this particular call? Can't you control when and where garbage can be collected in your wrapper API? ---- _2007-Feb-22 02:03:46 by anonymous:_ {linebreak} I can instruct the runtime to disable garbage collection for a critical section. Unfortunately, this is no help: when the 'authorizer' is invoked, it is invoked from C and is thus not in a critical section, yet. Supposing I then marked the entire function body as a a critical section, when I return from the authorizer the critical section would have to end, and a garbage collection would be possible. So unless I could wrap the entire invocation from C as atomic, there's nothing I can do. Sadly, there is no way to specify that garbage collection is impossible for methods called from C (in SML/MLton; maybe java/other languages can do this). This would be a horrible thing to do anyways. Think of a gtk program where all the user code is invoked as a callback. This would mean it was impossible to reclaim memory. ever. ---- _2007-Feb-22 02:55:25 by anonymous:_ {linebreak} There's always a way to control when garbage can be collected. Does SML use a precise or a conservative garbage collector? I suspect that garbage collections in SML are only triggered on calls to any malloc or free call? Running arbitray GC finalization code from a random C function is a recipe for thread deadlock - in both C and Java. So are you assuming only single-threaded code in your API? ---- _2007-Feb-22 16:04:30 by anonymous:_ {linebreak} re: deadlock, finalization will only occure if the resource will never be used again. Also, MLton (at least) does not support multiple system-level threads. When/if it did, the garbage collector would be running in its own thread, and all finalization would occure serialized there. re: controlling garbage collection. I can stop it within a critical section (begin ... end style) and explicitly invoke it. That's all the control I have. re: alloc/free. A programmer has no idea which structures will be allocated on the stack/heap. This is all subject to very complex analysis and optimization by the compiler. Memory is never explicitly allocated or freed in SML. One solution I could probably use is to keep a list of 'freed queries' associated with each database. Then, on every API call using that database, run the finalizers for any queries on the free list. This would might be a good idea anyways in case of concurrent SML implementations. One last question: is it allowed to execute subqueries within a callback from SQLite? I just assumed so, but I also assumed I could execute subqueries as part of authorization (subject to not being stupid and causing infinite recursion). ---- _2007-Feb-23 13:09:04 by anonymous:_ {linebreak} I've implemented the work-around I mentioned: When a query is garbage collected, I move it to a list of queries that need to be finalized for its database. Then, when any API call is made involving that database or its queries, any queries in the free list are finalized. It's not space-safe, but it works. The obvious benefit is also that the finalization will always happen in the same thread as the rest of the API calls made on that database (assuming the user only accesses that SQLite db from one thread). Feel free to close this bug. I would still like to know for documentation purposes if a callback from SQL (aggregate, collation, or scalar) may execute subqueries in computing the result. Also, I still think that allowing the authorizer to make subqueries would be a good idea. It would let you build an access control policy similar to MySQL's (in a table). However, I realize this is a feature request, not a bug. ---- _2007-Feb-23 14:52:41 by anonymous:_ {linebreak} I do agree that SQLite should be made to be reentrant through the authorization callback function, but the new way your wrapper finalizes objects is much safer, more deterministic and relies less on the inner workings of the sqlite3 library. ---- _2007-Feb-23 18:50:45 by anonymous:_ {linebreak} I believe you call new SQL commands from within sqlite registered functions or other callbacks. #f2dcdc 2479 code active 2007 Jun anonymous 2007 Jun 1 1 WinCE regression on some systems. Any db open fails. 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:_ {linebreak} The title is wrong. It should say "Any db open using the UTF-8 API", as using the open16 API will work. #c8c8c8 2478 code closed 2007 Jun anonymous 2007 Jun 2 2 LIMIT and OFFSET abbreviation to LIMIT x,y bug! Statement taken from Apress: The Definitive Guide to SQLite: SELECT * FROM foods WHERE name LIKE 'B%' ORDER BY type_id DESC, name LIMIT 1 OFFSET 2; can be expressed equivalently with SELECT * FROM foods WHERE name LIKE 'B%' ORDER BY type_id DESC, name LIMIT 1,2; SQLite3 3.4.0 bug - The parameters after LIMIT have been reversed in the implementation of this version of SQLite in error!... 2 tuples from the database are returned (LIMIT) and starting from the OFFSET 1 instead of the other way around, 1 tuple starting at offset 2. From the documentation for SELECT: Note that if the OFFSET keyword is used in the LIMIT clause, then the limit is the first number and the offset is the second number. If a comma is used instead of the OFFSET keyword, then the offset is the first number and the limit is the second number. This seeming contradition is intentional - it maximizes compatibility with legacy SQL database systems. SQLite has always been this way. It's a bug in the book. ---- _2007-Jun-29 11:49:02 by drh:_ {linebreak} As an historical curiosity, see ticket #245. #f2dcdc 2476 todo active 2007 Jun anonymous 2007 Jun 4 3 SQLite3 ignores ORDER BY clause when performing SELECT ... GROUP BY 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:_ {linebreak} 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. #f2dcdc 2474 new active 2007 Jun anonymous 2007 Jun 5 4 Multiple-record comma-delineated INSERT command 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:_ {linebreak} 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. #f2dcdc 2473 warn active 2007 Jun anonymous 2007 Jun anonymous 3 2 sqlite memory org. on linux 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:_ {linebreak} There is no bug mentioned in this ticket. ---- _2007-Jun-28 14:09:36 by drh:_ {linebreak} 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. #c8c8c8 2472 code closed 2007 Jun anonymous 2007 Jun 1 1 smart quotes turning question marks while storing in oracle 9i DB whenever end-user copy & paste the statement from the word which contains smart quotes into the java application and submit, it stores in the oracle 9i database. But the smart quotes are getting converted into question mark (?) / reverse question mark symbol. Kindly tell me the solution. Environment: Java 2.0,Jrun 4.0, Oracle 9.2.0.1.0 Where does SQLite figure into the system? #c8c8c8 2471 secure closed 2007 Jun anonymous 2007 Jun 1 1 a bug for 64 bit driver under operation system Firstly,I can't find a 64bit driver just like a.so file under the specail system Unix/Linxu. Secondly,I find a drvier writen by java,but it has many problem while multi threads operate the database. Sometimes I lost all of my data. Can you offer a 64bit driver under Unix/Linux in your website? This is probably better discussed on the mailing list. Any bugs in a java wrapper (which one) can be figured out there too. #cfe8bd 2470 code fixed 2007 Jun anonymous 2007 Jun 1 3 subselects causing reproducable SIGSEGV After upgrade to 3.4.0, I started receiving SIGSEGV on a particular sub-select query. This did *not* happen on 3.3.12. I have not tested versions 3.3.13 - 3.3.17. I've trimmed the original statement down as much as I could. The following statement shows the problem:
 DROP TABLE table_1; DROP TABLE table_2; CREATE TABLE table_1 (col_10); CREATE TABLE table_2 ( col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8, col_9, col_10 ); SELECT col_10 FROM (SELECT table_1.col_10 AS col_10 FROM table_1), (SELECT table_1.col_10, table_2.col_9 AS qcol_9  FROM table_1, table_2  GROUP BY table_1.col_10, qcol_9 ); 
What I've noticed is that it takes at least 10 columns in table_2 before the bug is triggered. Remove one (unused) column and it goes away. Also, removing the second parameter in GROUP BY (eg. qcol_9) makes the bug go away. This is on OpenBSD 4.1 (i386). I'm not familiar with SQLite's internals, but below is a backtrace. Another thing I noticed is that bug is much harder to trigger (like 1 out of 10 times) without any malloc debugging options turned on. See http://www.openbsd.org/cgi-bin/man.cgi?query=malloc.conf&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html With MALLOC_OPTIONS "AFGJP", the bug is triggered each time.
 ssehic@dev-5-i386:/home/ssehic/devel$ sqlite3 test.db SQLite version 3.4.0 Enter ".help" for instructions sqlite> .read sigsegv.sql Segmentation fault (core dumped)  ssehic@dev-5-i386:/home/ssehic/devel$ gdb /usr/local/bin/sqlite3 sqlite3.core GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB.  Type "show warranty" for details. This GDB was configured as "i386-unknown-openbsd4.1"... Core was generated by `sqlite3'. Program terminated with signal 11, Segmentation fault. Reading symbols from /usr/local/lib/libsqlite3.so.9.0...done. Loaded symbols for /usr/local/lib/libsqlite3.so.9.0 Reading symbols from /usr/lib/libreadline.so.3.0...done. Loaded symbols for /usr/lib/libreadline.so.3.0 Reading symbols from /usr/lib/libncurses.so.10.0...done. Loaded symbols for /usr/lib/libncurses.so.10.0 Reading symbols from /usr/lib/libc.so.40.3...done. Loaded symbols for /usr/lib/libc.so.40.3 Reading symbols from /usr/libexec/ld.so...done. Loaded symbols for /usr/libexec/ld.so #0  sqlite3ValueFromExpr (pExpr=0xd0d0d0d0, enc=1 '\001', affinity=208 'Ð', ppVal=0xcfbf1618) at src/vdbemem.c:913 913       op = pExpr->op; (gdb) bt #0  sqlite3ValueFromExpr (pExpr=0xd0d0d0d0, enc=1 '\001', affinity=208 'Ð', ppVal=0xcfbf1618) at src/vdbemem.c:913 #1  0x07f47ef0 in sqlite3ColumnDefault (v=0x7e949000, pTab=0x854d2c80, i=8) at src/update.c:62 #2  0x07f2de40 in sqlite3ExprCodeGetColumn (v=0x7e949000, pTab=0x854d2c80, iColumn=8, iTable=2132004048) at src/expr.c:1683 #3  0x07f2df17 in sqlite3ExprCode (pParse=0xcfbf1a90, pExpr=0x7c2e7880) at src/expr.c:1733 #4  0x07f2e782 in sqlite3ExprCodeExprList (pParse=0xcfbf1a90, pList=0x7f13ccd0) at src/expr.c:2121 #5  0x07f45980 in sqlite3Select (pParse=0xcfbf1a90, p=0x7c2e7d00, eDest=8, iParm=2, pParent=0x7c2e7980, parentTab=1, pParentAgg=0xcfbf18cc,     aff=0x0) at src/select.c:3218 #6  0x07f45cbd in sqlite3Select (pParse=0xcfbf1a90, p=0x7c2e7980, eDest=4, iParm=0, pParent=0x0, parentTab=0, pParentAgg=0x0, aff=0x0)     at src/select.c:2961 #7  0x07f3b2ef in yy_reduce (yypParser=0x7fc1d800, yyruleno=104) at parse.y:369 #8  0x07f3ce04 in sqlite3Parser (yyp=0x7fc1d800, yymajor=1, yyminor={z = 0x1 "", dyn = 0, n = 1066002024}, pParse=0x1) at parse.c:3417 #9  0x07f469a5 in sqlite3RunParser (pParse=0xcfbf1a90,     zSql=0x7f13c600 "SELECT\r\n    col_10\r\nFROM\r\n    (SELECT table_1.col_10 AS col_10 FROM table_1),\r\n    (\r\n        SELECT table_1.col_10, table_2.col_9 AS qcol_9\r\n        FROM table_1, table_2\r\n        GROUP BY table_1.co"..., pzErrMsg=0xcfbf1a8c) at src/tokenize.c:452 #10 0x07f3f5de in sqlite3Prepare (db=0x8693ce00,     zSql=0x7f13c600 "SELECT\r\n    col_10\r\nFROM\r\n    (SELECT table_1.col_10 AS col_10 FROM table_1),\r\n    (\r\n        SELECT table_1.col_10, table_2.col_9 AS qcol_9\r\n        FROM table_1, table_2\r\n        GROUP BY table_1.co"..., nBytes=-1, saveSqlFlag=0,     ppStmt=0xcfbf1bf4, pzTail=0xcfbf1bf8) at src/prepare.c:504 #11 0x07f3f6c9 in sqlite3_prepare (db=0x8693ce00,     zSql=0x7f13c600 "SELECT\r\n    col_10\r\nFROM\r\n    (SELECT table_1.col_10 AS col_10 FROM table_1),\r\n    (\r\n        SELECT table_1.col_10, table_2.col_9 AS qcol_9\r\n        FROM table_1, table_2\r\n        GROUP BY table_1.co"..., nBytes=-1, ppStmt=0xcfbf1bf4,     pzTail=0xcfbf1bf8) at src/prepare.c:616 #12 0x07f59ced in sqlite3_exec (db=0x8693ce00,     zSql=0x7f13c600 "SELECT\r\n    col_10\r\nFROM\r\n    (SELECT table_1.col_10 AS col_10 FROM table_1),\r\n    (\r\n        SELECT table_1.col_10, table_2.col_9 AS qcol_9\r\n        FROM table_1, table_2\r\n        GROUP BY table_1.co"..., xCallback=0x1c001a24 ,     pArg=0xcfbf3af4, pzErrMsg=0xcfbf1c4c) at src/legacy.c:55 #13 0x1c0046a1 in process_input (p=0xcfbf3af4, in=0x24e8f7a0) at src/shell.c:1656 #14 0x1c003286 in do_meta_command (zLine=0x3c000272 "", p=0x7d2a9145) at src/shell.c:1363 #15 0x1c004851 in process_input (p=0xcfbf3af4, in=0x0) at src/shell.c:1616 #16 0x1c004d9f in main (argc=2, argv=0xcfbf4480) at src/shell.c:1991 (gdb) p pExpr->op Cannot access memory at address 0xd0d0d0d0 (gdb) p pExpr $2 = (Expr *) 0xd0d0d0d0 
Looks like a NULL pointer deref. Hope that is enough information. Please let me know if you need anything else. Thanks. _2007-Jun-27 21:46:10 by drh:_ {linebreak} Though you would never know it to read the description, this turns out to be the same problem as #2445. It has already been fixed by [4122]. ---- _2007-Jun-27 22:10:22 by anonymous:_ {linebreak} Even though the bug was fixed, can you add this test case for this anyway, as Dan's test case in Check-in [4122] for this bug failed to crash or give any valgrind error for me with the sqlite 3.4.0 sources. -- no SEGV, nor any valgrind error for 3.4.0 release CREATE TEMP TABLE t1 (a, b, c, d, e); CREATE TEMP TABLE t2 (f); SELECT t1.e AS alias FROM t2, t1 WHERE alias = 1 ; -- SEGV on 3.4.0 release CREATE TABLE table_1 (col_10); CREATE TABLE table_2 ( col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8, col_9, col_10 ); SELECT col_10 FROM (SELECT table_1.col_10 AS col_10 FROM table_1), (SELECT table_1.col_10, table_2.col_9 AS qcol_9 FROM table_1, table_2 GROUP BY table_1.col_10, qcol_9 ); ---- _2007-Jun-28 20:03:38 by anonymous:_ {linebreak} Verified to fix the reported problem on OpenBSD 4.1 with the patch backported to 3.4.0. Thanks guys. You certainly rock. #cfe8bd 2468 doc fixed 2007 Jun anonymous 2007 Jun 5 5 Spelling error in documentation http://www.sqlite.org/capi3ref.html#sqlite3_changes In the last paragraph: (This is much faster than going through and deleting individual elements **form** the table.) _2007-Jun-27 23:58:19 by anonymous:_ {linebreak} When I click on the link that I originally provided, I still see the error. Will it take some time for the change to go through? ---- _2007-Jun-28 00:16:47 by drh:_ {linebreak} The documentation is built automatically and the website is updated when we do a release. If it were a serious error we could manually update the offending document, but this is a simple typo. I think it can wait. ---- _2007-Jun-28 01:37:23 by anonymous:_ {linebreak} Ah, I sort of thought that was the case. Like you said, it's not a big deal, I was just curious how things worked. #f2dcdc 2467 code active 2007 Jun anonymous 2007 Jun 4 4 changes() not reporting correctly after DELETE FROM table 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: *:http://php.scripts.psu.edu/rrf5000/Stuff/checksums/changes_error_example_3.php The original bug description is here: *:http://www.php.net/manual/en/function.sqlite-changes.php#57253 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: *:http://www.sqlite.org/capi3ref.html#sqlite3_changes _2007-Jun-27 20:32:31 by anonymous:_ {linebreak} yeah. delete from [table_name] drops and reconstructs the table again. #cfe8bd 2466 code fixed 2007 Jun anonymous 2007 Jun 5 5 ENCODING not used in Makefile.linux-gcc *ENCODING* isn't used (and if it was I would argue ISO8859 is a horrible default under Linux). Patch to be attached. #cfe8bd 2465 code fixed 2007 Jun anonymous 2007 Jun 4 4 64-bit/tcl regression failure with types3-1.3 types3-1.3... Expected: [wideInt integer] Got: [int integer] from: do_test types3-1.3 { set V [expr {1+123456789012345}] concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] } {wideInt integer} so I guess tcl on (this) 64-bit platform has 64-bit 'integers'? (drh/dan, contact me directly if you want shell access to a 64-bit x86-64 machine) #cfe8bd 2464 code fixed 2007 Jun anonymous 2007 Jun 5 4 error message not set by sqlite3_blob_write Calling sqlite3_blob_write on a readonly blob returns an errorcode as expected, but does not set the error message that is retrieved by sqlite3_errmsg. "not an error" is the return value. #c8c8c8 2463 todo closed 2007 Jun anonymous 2007 Jun anonymous 1 1 Crash after calling sqlite_close() if SQLITE_ENABLE_MEMORY_MANAGEMENT Hi I am using SQLITE amalgamated code to build sqlite static lib which is linked to my code.{linebreak} All the sqlite queries are handled in separate thread. So when the application shuts down, sqlite_close() is called. Following section is executed in sqlite_close()
 for(j=0; j<db->nDb; j++){     struct Db *pDb = &db->aDb[j];     if( pDb->pBt ){       sqlite3BtreeClose(pDb->pBt);       pDb->pBt = 0;       if( j!=1 ){         pDb->pSchema = 0;       }     }   } 
Finally the crash appears in function
 int sqlite3PagerClose(Pager *pPager){ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT   /* Remove the pager from the linked list of pagers starting at   ** ThreadData.pPager if memory-management is enabled.   */   if( pPager==pTsd->pPager ){     pTsd->pPager = pPager->pNext;   }else{     Pager *pTmp;     for(pTmp = pTsd->pPager; pTmp->pNext!=pPager; pTmp=pTmp->pNext){}     pTmp->pNext = pPager->pNext;   } #endif 
Here pTsd appears invalid so assigning to pTmp creates crash. VS Debugger doesnt gives any value for pTsd, just shows it as invalid data. Please have a look at it and let me know if there is some solution.Let me know if further information is needed Thanks{linebreak} anand _2007-Jun-26 18:16:53 by drh:_ {linebreak} When using SQLITE_ENABLE_MEMORY_MANAGEMENT, All interaction with a single sqlite3* handle, including calling sqlite3_close() on that handle, must occur in the same thread that sqlite3_open() was called in. ---- _2007-Jun-26 18:22:35 by anonymous:_ {linebreak} sqlite_close() is being called on same thread from where sqlite_open() is called. {linebreak} I guess this is same issue as raised in Ticket #2357 ---- _2007-Jun-26 23:46:12 by drh:_ {linebreak} When SQLITE_ENABLE_MEMORY_MANAGEMENT is turned on, the sqlite3* handle may not be used in more than one thread. That means if you call sqlite3_open() in thread A and then call sqlite3_prepare() in thread B you have broken the rules and are likely to get this problem. It is not a matter of calling sqlite3_close() in the same thread as sqlite3_open(). You have to call all sqlite3_*() routines in the same thread as sqlite3_open(). ---- _2007-Jun-27 00:09:57 by drh:_ {linebreak} The {link: /faq.html#q6 FAQ} have been updated to description the restriction on SQLITE_ENABLE_MEMORY_MANAGEMENT and threads. Since SQLITE_ENABLE_MEMORY_MANAGEMENT is otherwise undocumented, this is the only place I could find to put the information. #c8c8c8 2462 todo closed 2007 Jun anonymous 2007 Jun 5 5 www.sqlite.org/cvstrac/tktnew suggestion In an effort to increase the value of bug tickets you might consider putting a brief blurb at the top of the http://www.sqlite.org/cvstrac/tktnew html page stressing the value of reproducability of bugs in getting them fixed. Sort of like a bug report check list. For example, a large percentage of bug reports fail to include the schema, valid SQL, or neglect to mention the platform and media on which the database is stored. _2007-Jun-26 22:07:16 by drh:_ {linebreak} This would be an enhancement request for the CVSTrac project. Please go to http://www.cvstrac.org/cvstrac/ and enter your request there. #c8c8c8 2461 code closed 2007 Jun anonymous 2007 Jun 2 3 BLOB retrieval produces garbled data in UTF-16 I came across this when using SQLiteJDBC; see http://groups.google.com/group/sqlitejdbc/t/e4ea318dea31c741 for the original description. From a SQLite3 DB with UTF-16 encoding, retrieving a BLOB which contains a PNG image with the 3.2.7 CLI produces the correct content (displays ëPNG... for the head of the BLOB) and correct length(). In contrast the 3.4.0 CLI shows garbled binary content, but still returns the same length. SQLiteJDBC 0.3.4 now retrieves garbled content of an incorrect (greater) length. Setting up the DB with the same data, but encoding UTF-8 solves this issue, both CLI and SQLiteJDBC are now able to retrieve the BLOB as a valid PNG. This happens on a Win2k system, using the provided SQLite binaries resp. SQLiteJDBC v034 with nested (pure Java) DB engine. _2007-Jun-26 13:47:58 by danielk1977:_ {linebreak} Can you upload a database file that exhibits the problem? Thanks. ---- _2007-Jun-26 14:24:30 by anonymous:_ {linebreak} What does .dump produce for the BLOBs from the native (not nestedvm) sqlite3 commandline shell? ---- _2007-Jun-29 12:50:35 by drh:_ {linebreak} I'm not sure what problem is being reported here. The APIs for retrieving BLOBs from a database appear to work fine, both in our countless tests and on the sample database in the attachments. This is clearly seen in the CLI if you do SELECT hex(avatar), length(avatar) FROM avatars; When the CLI displays a value, it first converts that value to UTF-8 text. If the value is originally a BLOB in a UTF-16 database, then the BLOB is first cast as UTF-16 text then that text is converted to UTF-8. That whole conversion process has changed to become more robust and to fix bugs in between version 3.2.7 and 3.4.0. Are you saying that the current UTF16->UTF8 conversion process is incorrect? If so, can you please provide us with a _well-formed_ UTF16 byte sequence (not a PNG image that is ill-formed UTF16 text) that exhibits the problem? I cannot speak to the problem with SQLiteJDBC since that is outside the scope of this project. ---- _2007-Jun-29 13:12:33 by drh:_ {linebreak} I think I see the problem now. Back in version 3.2.7, if you requested a BLOB as a UTF8 string out of a UTF16 database then SQLite would return the content of that blob directly. No conversions occurred. This is, arguably, incorrect behavior. In version 3.4.0, when you request a BLOB as a UTF8 string out of a UTF16 database, the BLOB is first cast to a UTF16 string, then there is a UTF16->UTF8 conversion. We believe the current behavior is correct. Summary: The 3.2.7 behavior was bug. The 3.4.0 behavior is correct. ---- _2007-Jun-29 13:18:34 by anonymous:_ {linebreak} The commandline sqlite3 shell compiled with NestedVM shows the correct blob value with .dump for the database in question. http://www.sqlite.org/contrib/download/sqlite-java-shell-3.4.0.zip?get=19 When spaces are adjusted for the new .dump INSERT format, it produces the same values as the natively compiled sqlite 3.2.2 shell. So either you're not calling the correct sequence of JDBC statements, or this SQLiteJDBC driver should use the same sequence of sqlite API instructions that sqlite/src/shell.c uses for .dump to process binary values. #c8c8c8 2460 code closed 2007 Jun anonymous 2007 Jun 1 1 VC6 Compile Error When 3.4.0 amalgamation codes are compiled by using MS-VC6 under "Release" Settings, the following error is reported: sqlite3.c(25593) : fatal error C1001: INTERNAL COMPILER ERROR Under "Debug" settings, there is no this error. The previous versions don't have this problem also. _2007-Jun-26 09:47:45 by drh:_ {linebreak} This appears to be a duplicate of #2457. #f2dcdc 2459 code active 2007 Jun anonymous 2007 Jun 4 4 changes() not reporting correctly after "failed" multiline INSERT 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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: *:http://php.scripts.psu.edu/rrf5000/Stuff/checksums/changes_error_example.php *:http://php.scripts.psu.edu/rrf5000/Stuff/checksums/changes_error.php 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. *:http://php.scripts.psu.edu/rrf5000/Stuff/checksums/changes_error_example_2.php ---- _2007-Jun-27 00:25:10 by drh:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} "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: *:http://php.scripts.psu.edu/rrf5000/Stuff/checksums/changes_error_example_4.php 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:_ {linebreak} 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. #c8c8c8 2458 code closed 2007 Jun anonymous 2007 Jun 1 1 sqlite caching results between calls to select on an open database When I open a database and I do a refresh after dropping a table and inserting the same number of row before the drop I am always returned cached data, I don't see the new inserted data? Step to reproduce: you will most likely have to write c/c++ code start with an empty table / database 1. open database 2. create a new table 3. insert 5 rows 4. do a select operation 5. drop the table 6. create a new table 7. insert 5 different rows 8. do a select operation results: I see the old cached rows! expected results: I should see the new insert rows This only happens if you insert the same number of rows you insert before the drop table command. Basically my refresh functionality is broken. If I do all the same 8 steps but on step 7 change the row count up or down by 1 or more I alwasy see the new data, as it should be. _2007-Jun-25 20:45:50 by drh:_ {linebreak} Unable to reproduce. Why do you think that C/C++ code is necessary to reproduce this? Have you left out some steps. Based on your description above, it seems like the following SQL script would suffice: CREATE TABLE t1(a); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); INSERT INTO t1 VALUES(5); SELECT * FROM t1; DROP TABLE t1; CREATE TABLE t2(b); INSERT INTO t2 VALUES(11); INSERT INTO t2 VALUES(12); INSERT INTO t2 VALUES(13); INSERT INTO t2 VALUES(14); INSERT INTO t2 VALUES(15); SELECT * FROM t2; ---- _2007-Jun-25 20:55:08 by anonymous:_ {linebreak} I have 2 processes: i) viewer gui app and ii) a console test logger. The viewer app opens the database table then does selects from the database table each time the refresh button is hit. I do not open and close the database between selects calls in the viewer. The sql statement is however finalized and released and prepared each time using the new sqlite3_prepare16_v2 API. In the test logger app that generates entries, I have a switch that allows me to drop the table before the inserts are done. If the number so rows inserted between drops is different I see fresh data, otherwise I see cached (old) data. Also if I don't drop the table between inserts, then I see fresh data. ---- _2007-Jun-25 20:59:31 by anonymous:_ {linebreak} c/c++ code is necessary because if you use some sqlite shell tool to enter sql statements, the database might be getting open and closed between the steps. If I force the database to open and close between refresh I see fresh data, if I don't I see cached data. ---- _2007-Jun-25 21:04:05 by anonymous:_ {linebreak} Please also use the same table name! ---- _2007-Jun-25 21:13:20 by drh:_ {linebreak} My next test uses two processes. *Process 1:* create table t1(x); insert into t1 values(1); insert into t1 values(2); insert into t1 values(3); insert into t1 values(4); insert into t1 values(5); *Process 2:* select * from t1; *Process 1:* drop table t1; create table t1(x); insert into t1 values(6); insert into t1 values(7); insert into t1 values(8); insert into t1 values(9); insert into t1 values(10); *Process 2:* select * from t1; Process 2 sees 1,2,3,4,5 on the first SELECT and 6,7,8,9,10 on the second SELECT. Still unable to reproduce. What else should I try? Note that the command-line shell does not close or reopen the database between commands. ---- _2007-Jun-25 21:59:20 by drh:_ {linebreak} Thanks you for providing screenshots of the problem in your application, Rajinder. However, those screenshots are no help in isolating this problem. I do not have access to your code and so the screenshoots are useless to me in reproducing the bug. And if I cannot reproduce the problem, I cannot fix it. Recognize that this is not necessarily a error in SQLite. There could be any number of bugs in your application which would give the same symptoms. And so until I have some kind of problem description or test code with which I can reproduce the symptoms here, I am going to assume that the bug is outside of SQLite and leave this ticket closed. ---- _2007-Jun-25 22:10:06 by anonymous:_ {linebreak} I understand, I'll keep you posted if I figure out how you can reproduce this problem in some other way without the benefit of having my source code at your disposal. #f2dcdc 2457 build active 2007 Jun anonymous 2007 Jun drh 1 2 Build fails with internal compiler error (Windows, MS VC++ 6.0) 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} Reboot of the machine is no help. ---- _2007-Jun-25 22:38:18 by anonymous:_ {linebreak} VC 6.0 - what compile flags are you using? ---- _2007-Jun-25 23:11:59 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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... #f2dcdc 2456 new active 2007 Jun anonymous 2007 Jun 5 5 REQ: use index where applicable instead of full table scan 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. #cfe8bd 2455 build fixed 2007 Jun anonymous 2007 Jun drh 2 3 aix linking fails due to missing library When trying to build sqlite 3.4.0 (TEA tarball) on our AIX build box configure was ok, compilation was ok, and then linking of the shared library failed with error: /home/andreask/dbn/lba/night/builds/aix-rs6000/tcl/unix/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry -o libsqlite3.4.0.so tclsqlite3.o fts2amal.o -lpthread -lc -L/home/andreask/dbn/lba/night/builds/aix-rs6000/tcl/unix/aix-rs6000 -ltclstub8.4 noDotA="libsqlite3.4.0.so" *ld: 0711-317 ERROR: Undefined symbol: .isnan* I was able to fix this problem by adding *-lm* to the definition of *LIBS* in the Makefile (hence only severity 2, and this workaround goes into our buildsystem). Note: I do not know how/where to puts this in the TEA buildsystem (configure.in, *.m4, etc.). For that Jeff is more likely to know the answer for. _2007-Jun-25 17:25:51 by drh:_ {linebreak} Check-in [4103] should have already fixed this problem. #cfe8bd 2454 code fixed 2007 Jun drh 2007 Jun 1 1 Leading zeros cause large integers to be convert to floating point. SQLite understands this number as an integer: 9223372036854775807 But the following numbers are understood as floating point values since the number of digits is greater than 19. The leading zeros are not ignored: 09223372036854775807 00000000000000000001 #cfe8bd 2453 code fixed 2007 Jun anonymous 2007 Jun 4 3 Can the amalgamation be made entirely static I would like all the functions in the amalgamation to all be declared static as I #include sqlite3.c into my main file (as I do with my other code) which is all loaded as a shared library. In terms of implementation, my preference would be for each currently public function to be prefixed with SQLITE_API or a similar #define that by default is empty. I would #define it to static. The benefits of this are: *: Even better optimization since the compiler knows the functions can't be called from anywhere else *: Unused functions can be removed by the compiler making my dll smaller *: It would allow multiple versions of SQLite to be used in the same process at the same time. With more and more programs and libraries using SQLite this increasingly becomes a problem. (Will the tls stuff still work correctly with more than one SQLite version in the same process?) _2007-Jun-25 11:47:28 by drh:_ {linebreak} The amalgamation can be made completely static by applying the patch shown at the end of this comment. But that is not something we are interested in doing in the standard release at this time.
 --- mksqlite3c.tcl      19 Jun 2007 15:23:48 -0000      1.12 +++ mksqlite3c.tcl      25 Jun 2007 11:43:47 -0000 @@ -121,9 +121,9 @@    section_comment "Begin file $tail"    set in [open $filename r]    if {[file extension $filename]==".h"} { -    set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \*?sqlite3[A-Z][a-zA-Z0-9]+\(} +    set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \*?sqlite3[_A-Z][a-zA-Z0-9]+\(}    } else { -    set declpattern {^[a-zA-Z][a-zA-Z_0-9 ]+ \*?sqlite3[A-Z][a-zA-Z0-9]+\(} +    set declpattern {^[a-zA-Z][a-zA-Z_0-9 ]+ \*?sqlite3[_A-Z][a-zA-Z0-9]+\(}    }    while {![eof $in]} {      set line [gets $in] 
---- _2007-Jun-26 00:51:42 by drh:_ {linebreak} Here's another idea. I have modified the amalgamation generator to put the macro SQLITE_API in front of every API call. The SQLITE_API macro is normally defined to be nothing. But you can redefine it on the compiler command line: -DSQLITE_API=static In order to make the amalgamation completely static if you want. #c8c8c8 2452 code closed 2007 Jun anonymous 2007 Jun drh 1 1 In Memory Query Performance Hi, When the DB is opened in Memory mode,performance of query does not improve. For table which has 10 columns of type Text and each column having 128bytes data and having a total of 10000 records. Performance is around 2400 records/sec. Any ways to improve it. Thanks in advance. regards ragha This is not a bug report. Please ask questions on the mailing list. ---- _2007-Jun-25 02:39:44 by anonymous:_ {linebreak} Thanks. #c8c8c8 2451 code closed 2007 Jun anonymous 2007 Jun 5 5 vdbe.c comment typo "a P1 parameter of -1" is repeated twice. One of them is wrong. ** database accessed is ((P1+1)*-1). For example, a P1 parameter of -1 ** corresponds to database 0 ("main"), a P1 of -1 is database 1 ("temp"). Thanks. #c8c8c8 2450 code closed 2007 Jun anonymous 2007 Jun 1 1 Crashes and random wrong results with certain column names As reported on mailing list http://www.mail-archive.com/sqlite-users%40sqlite.org/msg25614.html CREATE TABLE "t a" ("c a", """cb"""); INSERT INTO "t a" ("c a", """cb""") VALUES (1, 2); INSERT INTO "t a" ("c a", """cb""") VALUES (11, 12); INSERT INTO "t a" ("c a", """cb""") VALUES (21, 22); SELECT * FROM "t a"; Result-set * expansion was not working for column names that contain quote characters. Thanks for the report. #c8c8c8 2449 doc closed 2007 Jun anonymous 2007 Jun 1 1 BLOB and binary data Does SQLite3 still support binary data in BLOB fields?
 sqlite3 test SQLite version 3.4.0 Enter ".help" for instructions sqlite> CREATE TABLE test(data BLOB); sqlite> INSERT INTO test VALUES("123" || X'00' || "567"); sqlite> SELECT * FROM test; 123 sqlite> SELECT LENGTH(data) FROM test; 3 sqlite> 
_2007-Jun-23 13:14:28 by anonymous:_ {linebreak} The concat operator coerces its arguments to TEXT and returns TEXT. You should make a special function to concat BLOBs, if that's what you want. ---- _2007-Jun-23 14:38:00 by danielk1977:_ {linebreak} It does. But this sort of thing is better asked on the mailing list. ---- _2007-Jun-30 17:04:22 by anonymous:_ {linebreak} my solution as loadable extension:{linebreak} {linebreak} static void concatFunc( sqlite3_context *context, int argc, sqlite3_value **argv ) {{linebreak} unsigned char *pz, *rz;{linebreak} int i, blobSize=0;{linebreak} for(i=0; i create table MYTABLE (name varchar(20),field2 varchar(20)); sqlite> insert into MYTABLE VALUES ("name1","name2"); sqlite> select * from MYTABLE; name1|name2 sqlite> select * from MYTABLE where name="name1"; name1|name2 sqlite> select * from MYTABLE where name="name"; name1|name2 I expected the third sqlquery not to result in any output. It appears that if you use tablename="tablename", you are getting all rows of the table. Am i missing something? Use name='name' instead. "name" means use the column named "name". #cfe8bd 2446 code fixed 2007 Jun anonymous 2007 Jun 1 2 FTS2 Limits Number of Indexed Tables to 3 I wrote my own managed (C++/CLI with Win32) wrapper. That all works fine. I even got the FTS2 installed. However a problem exists with FTS2. When I create my TABLEs (both regular and virtual for FTS2), after 3 FTS2 tables have been created I get an error. The following are my SQL statement constants. It works for the first 3 FTS2 tables then quits on the 4th one (no matter which one it is): #define SONG_LIBRARY_CREATE_AKA_TABLE _T("CREATE TABLE `AlternateSongTitles` (`SongId` INTEGER);") #define SONG_LIBRARY_CREATE_AKA_TEXT_TABLE _T("CREATE VIRTUAL TABLE `AlternateSongTitles_Text` USING FTS2(`AlternateTitle`);") #define SONG_LIBRARY_CREATE_COMPOSER_TABLE _T("CREATE VIRTUAL TABLE `Composers` USING FTS2(`Name`);") #define SONG_LIBRARY_CREATE_INFORMATION_TABLE _T("CREATE TABLE `LibraryInformation` (`Key` TEXT, `Value` TEXT);") #define SONG_LIBRARY_CREATE_PERFORMER_TABLE _T("CREATE VIRTUAL TABLE `Performers` USING FTS2(`Name`);") #define SONG_LIBRARY_CREATE_RELATED_SONGS_TABLE _T("CREATE TABLE `RelatedSongs` (`Song1Id` INTEGER, `Song2Id` INTEGER);") #define SONG_LIBRARY_CREATE_SONG_TABLE _T("CREATE VIRTUAL TABLE `Songs` USING FTS2(`Title`, `Copyright`, `Notes`);") #define SONG_LIBRARY_CREATE_SONG_CCLI_TABLE _T("CREATE VIRTUAL TABLE `SongCCLIData` USING FTS2(`CcliSongId`, `CcliCatalog`, `CcliAdministrator`, `CcliLicensee`, `CcliKeyLine`);") #define SONG_LIBRARY_CREATE_SONG_COMPOSER_TABLE _T("CREATE TABLE `SongComposedBy` (`SongId` INTEGER, `ComposerId` INTEGER);") #define SONG_LIBRARY_CREATE_SONG_KEY_TABLE _T("CREATE TABLE `SongKeys` (`SongId` INTEGER, `Key` TEXT);") #define SONG_LIBRARY_CREATE_SONG_PERFORMER_TABLE _T("CREATE TABLE `SongPerformedBy` (`SongId` INTEGER, `PerformerId` INTEGER);") #define SONG_LIBRARY_CREATE_SONG_THEME_TABLE _T("CREATE TABLE `SongThemes` (`SongId` INTEGER, `ThemeId` INTEGER);") #define SONG_LIBRARY_CREATE_STANZA_TABLE _T("CREATE TABLE `Stanzas` (`SongId` INTEGER, `Label` TEXT, `LabelNumber` INTEGER);") #define SONG_LIBRARY_CREATE_THEME_TEXT_TABLE _T("CREATE VIRTUAL TABLE `StanzasText` USING FTS2(`Text`, `Notes`);") #define SONG_LIBRARY_CREATE_THEME_TABLE _T("CREATE VIRTUAL TABLE `Themes` USING FTS2(`Name`);") The error I get is when I call to execute for SONG_LIBRARY_CREATE_SONG_TABLE: "SQL logic error or missing database". Thanks for your help! _2007-Jun-24 03:53:12 by anonymous:_ {linebreak} Same example in SQL form: CREATE TABLE `AlternateSongTitles` (`SongId` INTEGER); CREATE VIRTUAL TABLE `AlternateSongTitles_Text` USING FTS2(`AlternateTitle`); CREATE VIRTUAL TABLE `Composers` USING FTS2(`Name`); CREATE TABLE `LibraryInformation` (`Key` TEXT, `Value` TEXT); CREATE VIRTUAL TABLE `Performers` USING FTS2(`Name`); CREATE TABLE `RelatedSongs` (`Song1Id` INTEGER, `Song2Id` INTEGER); CREATE VIRTUAL TABLE `Songs` USING FTS2(`Title`, `Copyright`, `Notes`); CREATE VIRTUAL TABLE `SongCCLIData` USING FTS2(`CcliSongId`, `CcliCatalog`, `CcliAdministrator`, `CcliLicensee`, `CcliKeyLine`); CREATE TABLE `SongComposedBy` (`SongId` INTEGER, `ComposerId` INTEGER); CREATE TABLE `SongKeys` (`SongId` INTEGER, `Key` TEXT); CREATE TABLE `SongPerformedBy` (`SongId` INTEGER, `PerformerId` INTEGER); CREATE TABLE `SongThemes` (`SongId` INTEGER, `ThemeId` INTEGER); CREATE TABLE `Stanzas` (`SongId` INTEGER, `Label` TEXT, `LabelNumber` INTEGER); CREATE VIRTUAL TABLE `StanzasText` USING FTS2(`Text`, `Notes`); CREATE VIRTUAL TABLE `Themes` USING FTS2(`Name`); produces these errors: SQL error near line 7: vtable constructor failed: Songs SQL error near line 8: vtable constructor failed: SongCCLIData SQL error near line 14: vtable constructor failed: StanzasText ---- _2007-Jun-24 03:57:46 by anonymous:_ {linebreak} Interesting. It appears to be another quoting issue. The following SQL runs fine: CREATE TABLE AlternateSongTitles (SongId INTEGER); CREATE VIRTUAL TABLE AlternateSongTitles_Text USING FTS2(AlternateTitle); CREATE VIRTUAL TABLE Composers USING FTS2(Name); CREATE TABLE LibraryInformation (Key TEXT, Value TEXT); CREATE VIRTUAL TABLE Performers USING FTS2(Name); CREATE TABLE RelatedSongs (Song1Id INTEGER, Song2Id INTEGER); CREATE VIRTUAL TABLE Songs USING FTS2(Title, Copyright, Notes); CREATE VIRTUAL TABLE SongCCLIData USING FTS2(CcliSongId, CcliCatalog, CcliAdministrator, CcliLicensee, CcliKeyLine); CREATE TABLE SongComposedBy (SongId INTEGER, ComposerId INTEGER); CREATE TABLE SongKeys (SongId INTEGER, Key TEXT); CREATE TABLE SongPerformedBy (SongId INTEGER, PerformerId INTEGER); CREATE TABLE SongThemes (SongId INTEGER, ThemeId INTEGER); CREATE TABLE Stanzas (SongId INTEGER, Label TEXT, LabelNumber INTEGER); CREATE VIRTUAL TABLE StanzasText USING FTS2(Text, Notes); CREATE VIRTUAL TABLE Themes USING FTS2(Name); ---- _2007-Jun-24 16:05:03 by anonymous:_ {linebreak} Using [] or "" for identifiers also works fine: CREATE TABLE "AlternateSongTitles" ("SongId" INTEGER); CREATE VIRTUAL TABLE "AlternateSongTitles_Text" USING FTS2("AlternateTitle"); CREATE VIRTUAL TABLE "Composers" USING FTS2("Name"); CREATE TABLE "LibraryInformation" ("Key" TEXT, "Value" TEXT); CREATE VIRTUAL TABLE "Performers" USING FTS2("Name"); CREATE TABLE "RelatedSongs" ("Song1Id" INTEGER, "Song2Id" INTEGER); CREATE VIRTUAL TABLE "Songs" USING FTS2("Title", "Copyright", "Notes"); CREATE VIRTUAL TABLE "SongCCLIData" USING FTS2("CcliSongId", "CcliCatalog", "CcliAdministrator", "CcliLicensee", "CcliKeyLine"); CREATE TABLE "SongComposedBy" ("SongId" INTEGER, "ComposerId" INTEGER); CREATE TABLE "SongKeys" ("SongId" INTEGER, "Key" TEXT); CREATE TABLE "SongPerformedBy" ("SongId" INTEGER, "PerformerId" INTEGER); CREATE TABLE "SongThemes" ("SongId" INTEGER, "ThemeId" INTEGER); CREATE TABLE "Stanzas" ("SongId" INTEGER, "Label" TEXT, "LabelNumber" INTEGER); CREATE VIRTUAL TABLE "StanzasText" USING FTS2("Text", "Notes"); CREATE VIRTUAL TABLE "Themes" USING FTS2("Name"); ... CREATE TABLE [AlternateSongTitles] ([SongId] INTEGER); CREATE VIRTUAL TABLE [AlternateSongTitles_Text] USING FTS2([AlternateTitle]); CREATE VIRTUAL TABLE [Composers] USING FTS2([Name]); CREATE TABLE [LibraryInformation] ([Key] TEXT, [Value] TEXT); CREATE VIRTUAL TABLE [Performers] USING FTS2([Name]); CREATE TABLE [RelatedSongs] ([Song1Id] INTEGER, [Song2Id] INTEGER); CREATE VIRTUAL TABLE [Songs] USING FTS2([Title], [Copyright], [Notes]); CREATE VIRTUAL TABLE [SongCCLIData] USING FTS2([CcliSongId], [CcliCatalog], [CcliAdministrator], [CcliLicensee], [CcliKeyLine]); CREATE TABLE [SongComposedBy] ([SongId] INTEGER, [ComposerId] INTEGER); CREATE TABLE [SongKeys] ([SongId] INTEGER, [Key] TEXT); CREATE TABLE [SongPerformedBy] ([SongId] INTEGER, [PerformerId] INTEGER); CREATE TABLE [SongThemes] ([SongId] INTEGER, [ThemeId] INTEGER); CREATE TABLE [Stanzas] ([SongId] INTEGER, [Label] TEXT, [LabelNumber] INTEGER); CREATE VIRTUAL TABLE [StanzasText] USING FTS2([Text], [Notes]); CREATE VIRTUAL TABLE [Themes] USING FTS2([Name]); ---- _2007-Jun-24 23:47:27 by anonymous:_ {linebreak} Thanks! That is quite an interesting problem. #c8c8c8 2445 code closed 2007 Jun anonymous 2007 Jun 1 1 crash in sqlite3_prepare16 I just got a crash when using sqlite 3.4.0 inside our app. This is the only time I had it crash so far, so it seems to be a sporadic issue. From the backtrace and investigating the data, I can't see how this would be caused by our application code misbehaving, so I have to assume it's something inside sqlite. Our app does pretty heavy multithreading (and yes, we've built sqlite with --enable-threadsafe), so this may be the reason this only happened once so far? Anyway, the query being compiled is CREATE TABLE __BrowserData__ AS SELECT __lc_license_status_agent_id, __agent_ids_id, __agent_info_id, __lc_license_specs_id, __pseudoRowID__ FROM __BrowserData___View LIMIT 100 =__BrowserData___View= is a temporary view created as: CREATE TEMP VIEW __BrowserData___View AS SELECT (IFNULL(lc_license_status_agent.rowID,'')||':'||IFNULL(agent_ids.rowID,'')||':'||IFNULL(agent_info.rowID,'')||':'||IFNULL(lc_license_specs.rowID,'')||':') as __pseudoRowID__, agent_ids.id AS __agent_ids_id, agent_info.id AS __agent_info_id, lc_license_specs.id AS __lc_license_specs_id, lc_license_status_agent.id AS __lc_license_status_agent_id, lc_license_status_agent.InstallCount AS lc_license_status_agent_InstallCount, agent_ids.AgentName AS column_6b3ec967, lc_license_specs.LicenseType AS lc_license_specs_LicenseType, lc_license_specs.Name AS column_00000001, lc_license_specs.TrackAsMissingSoftware AS lc_license_specs_TrackAsMissingSoftware FROM lc_license_status_agent LEFT JOIN agent_ids ON (lc_license_status_agent.AgentSerial=agent_ids.AgentSerial) LEFT JOIN agent_info ON (agent_ids.id=agent_info.id) LEFT JOIN lc_license_specs ON (lc_license_status_agent.lc_specification_record_id=lc_license_specs.id) WHERE (((lc_license_status_agent_InstallCount = 0 AND lc_license_specs_LicenseType <> 4 AND lc_license_specs_TrackAsMissingSoftware = 1) AND (column_00000001 NOT LIKE 'fdsafdas' ESCAPE '\' ))) ORDER BY column_6b3ec967 COLLATE NOCASE ASC, column_00000001 COLLATE NOCASE ASC (ok, it's ugly, but this is a generated statement). The sqlite database object at this point looks valid to me (although I have to admit that other than checking for obvious garbage values, I can't do too much checking): (gdb) print *fDatabase.fObj->fSQLConnection $2 = { nDb = 5, aDb = 0x17223330, flags = 32768, errCode = 0, errMask = 255, autoCommit = 1 '\001', temp_store = 0 '\0', nTable = 128, pDfltColl = 0x168ceae0, lastRowid = 0, priorNewRowid = 0, magic = -264537850, nChange = 0, nTotalChange = 0, init = { iDb = 0, newTnum = 0, busy = 0 '\0' }, nExtension = 0, aExtension = 0x0, pVdbe = 0x2315600, activeVdbeCnt = 0, xTrace = 0x3594ac , pTraceArg = 0x16af34c0, xProfile = 0, pProfileArg = 0x0, pCommitArg = 0x0, xCommitCallback = 0, pRollbackArg = 0x0, xRollbackCallback = 0, pUpdateArg = 0x0, xUpdateCallback = 0, xCollNeeded = 0, xCollNeeded16 = 0, pCollNeededArg = 0x0, pErr = 0x165ca020, zErrMsg = 0x0, zErrMsg16 = 0x0, u1 = { isInterrupted = 0, notUsed1 = 0 }, xAuth = 0, pAuthArg = 0x0, xProgress = 0x359994 <_CheckForInterrupts(void*)>, pProgressArg = 0x1688dca0, nProgressOps = 20000, aModule = { keyClass = 3 '\003', copyKey = 0 '\0', count = 0, first = 0x0, xMalloc = 0x39a21c , xFree = 0x39a1c8 , htsize = 0, ht = 0x0 }, pVTab = 0x0, aVTrans = 0x0, nVTrans = 0, aFunc = { keyClass = 3 '\003', copyKey = 0 '\0', count = 77, first = 0x1725a0a0, xMalloc = 0x39a21c , xFree = 0x39a1c8 , htsize = 128, ht = 0x21db200 }, aCollSeq = { keyClass = 3 '\003', copyKey = 0 '\0', count = 2, first = 0x16a66530, xMalloc = 0x39a21c , xFree = 0x39a1c8 , htsize = 8, ht = 0x1657b9e0 }, busyHandler = { xFunc = 0x409c4c , pArg = 0x16af16f0, nBusy = 0 }, busyTimeout = 900000, aDbStatic = {{ zName = 0x46d5bc "main", pBt = 0x168beee0, inTrans = 0 '\0', safety_level = 1 '\001', pAux = 0x0, xFreeAux = 0, pSchema = 0x17238010 }, { zName = 0x46bad4 "temp", pBt = 0x0, inTrans = 0 '\0', safety_level = 1 '\001', pAux = 0x0, xFreeAux = 0, pSchema = 0x16ab7ce0 }}, dfltLockMode = 0 '\0' } The backtrace of the thread that crashed was: #0 0x003bef40 in sqlite3ValueFromExpr (pExpr=0x6e67436f, enc=3 '\003', affinity=114 'r', ppVal=0xf089e250) at sqlite/build/sqlite3.c:30197 #1 0x003f9fa8 in sqlite3ColumnDefault (v=0x2315600, pTab=0x170f9410, i=12) at sqlite/build/sqlite3.c:58010 #2 0x003d34f4 in sqlite3ExprCodeGetColumn (v=0x2315600, pTab=0x170f9410, iColumn=12, iTable=6) at sqlite/build/sqlite3.c:40564 #3 0x003d3938 in sqlite3ExprCode (pParse=0xf089ed2c, pExpr=0x16ac0560) at sqlite/build/sqlite3.c:40614 #4 0x003d4e40 in sqlite3ExprIfFalse (pParse=0xf089ed2c, pExpr=0x16ac0510, dest=-11, jumpIfNull=1) at sqlite/build/sqlite3.c:41170 #5 0x00403304 in sqlite3WhereBegin (pParse=0xf089ed2c, pTabList=0x16ae1110, pWhere=0x17238440, ppOrderBy=0xf089e98c) at sqlite/build/sqlite3.c:62143 #6 0x003f6db0 in sqlite3Select (pParse=0xf089ed2c, p=0x172163e0, eDest=7, iParm=1, pParent=0x0, parentTab=0, pParentAgg=0x0, aff=0x0) at sqlite/build/sqlite3.c:56496 #7 0x003dcbd4 in sqlite3EndTable (pParse=0xf089ed2c, pCons=0x0, pEnd=0x0, pSelect=0x172163e0) at sqlite/build/sqlite3.c:44696 #8 0x00404960 in yy_reduce (yypParser=0x2368600, yyruleno=27) at sqlite/build/sqlite3.c:64308 #9 0x00407734 in sqlite3Parser (yyp=0x2368600, yymajor=1, yyminor={z = 0x23802ab "100", dyn = 0, n = 3}, pParse=0xf089ed2c) at sqlite/build/sqlite3.c:65329 #10 0x00408e50 in sqlite3RunParser (pParse=0xf089ed2c, zSql=0x2380200 "CREATE TABLE __BrowserData__ AS SELECT __lc_license_status_agent_id,__agent_ids_id,__agent_info_id,__lc_license_specs_id, __pseudoRowID__ FROM __BrowserData___View LIMIT 100", pzErrMsg=0xf089edf4) at sqlite/build/sqlite3.c:65997 #11 0x003ef480 in sqlite3Prepare (db=0x16af16f0, zSql=0x2380200 "CREATE TABLE __BrowserData__ AS SELECT __lc_license_status_agent_id,__agent_ids_id,__agent_info_id,__lc_license_specs_id, __pseudoRowID__ FROM __BrowserData___View LIMIT 100", nBytes=-1, saveSqlFlag=0, ppStmt=0x170f81d0, pzTail=0xf089ee54) at sqlite/build/sqlite3.c:53254 #12 0x003efa70 in sqlite3Prepare16 (db=0x16af16f0, zSql=0x172597a0, nBytes=348, saveSqlFlag=0, ppStmt=0x170f81d0, pzTail=0xf089ef6c) at sqlite/build/sqlite3.c:53404 #13 0x003efb68 in sqlite3_prepare16 (db=0x16af16f0, zSql=0x172597a0, nBytes=348, ppStmt=0x170f81d0, pzTail=0xf089ef6c) at sqlite/build/sqlite3.c:53435 #14 0x00390cf4 in SQLiteQuery::PrepareStatement (this=0x170f8140) #15 0x0038f6c0 in SQLiteQuery::GetResultSet (this=0x170f8140) #16 0x00390f84 in SQLiteQuery::Execute (this=0x170f8140) #17 0x00110fdc in (anonymous namespace)::CreateBrowserCacheTable (inDatabase=@0x1688dca0, inSelectDataQuery=@0xf08a0580, inCacheColumnTableList=@0xf08a0460, tableList=0x168de190, inNeedPersistentRowIDs=true, inCacheLimit=100) #18 0x0012db9c in GenerateViewProperties (this=0x20dbc00, inDatabase=@0x1688dca0, inCreateBrowserCacheTable=true, inWantPlainSelectQuery=false, inUpdaterThread=0x16a54240) #19 0x0012ebe8 in RecreateViewThread::Run (this=0x16a54240) #20 0x00332f4c in ThreadEntry (inThread=0x16a54240) #21 0x9002be88 in _pthread_body () Now here's a strange thing: The calling function (#1 in the backtrace) executed this code: Column *pCol = &pTab->aCol[i]; sqlite3ValueFromExpr(pCol->pDflt, enc, pCol->affinity, &pValue); Here, i = 12, however pTab only appears to contain 10 column entries: (gdb) print *pTab $4 = { zName = 0x16ad2b90 "lc_license_status_agent", nCol = 10, aCol = 0x16afb2c0, iPKey = 0, pIndex = 0x16ad5b40, tnum = 139, pSelect = 0x0, nRef = 2, pTrigger = 0x0, pFKey = 0x0, zColAff = 0x0, pCheck = 0x0, addColOffset = 518, readOnly = 0 '\0', isEphem = 0 '\0', hasPrimKey = 1 '\001', keyConf = 99 'c', autoInc = 0 '\0', isVirtual = 0 '\0', isCommit = 0 '\0', pMod = 0x0, pVtab = 0x0, nModuleArg = 0, azModuleArg = 0x0, pSchema = 0x16ad7700 } For the records, here's also the contents of pExpr inside sqlite3ExprCode: (gdb) print *pExpr $5 = { op = 149 '\225', affinity = 100 'd', flags = 4, pColl = 0x168ceb08, pLeft = 0x0, pRight = 0x0, pList = 0x0, token = { z = 0x0, dyn = 0, n = 0 }, span = { z = 0x0, dyn = 1, n = 39 }, iTable = 6, iColumn = 12, pAggInfo = 0x0, iAgg = -1, iRightJoinTable = 0, pSelect = 0x0, pTab = 0x170f9410, pSchema = 0x168ea360, nHeight = 2 } as well as the contents of the "wc" variable inside sqlite3WhereBegin, which is executing at this point: /* For a LEFT OUTER JOIN, generate code that will record the fact that ** at least one row of the right table has matched the left table. */ if( pLevel->iLeftJoin ){ pLevel->top = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp(v, OP_MemInt, 1, pLevel->iLeftJoin); VdbeComment((v, "# record LEFT JOIN hit")); for(pTerm=wc.a, j=0; jflags & (TERM_VIRTUAL|TERM_CODED) ) continue; if( (pTerm->prereqAll & notReady)!=0 ) continue; assert( pTerm->pExpr ); --> sqlite3ExprIfFalse(pParse, pTerm->pExpr, cont, 1); pTerm->flags |= TERM_CODED; } } (gdb) print wc $6 = { pParse = 0xf089ed2c, pMaskSet = 0xf089e5c4, nTerm = 10, nSlot = 10, a = 0xf089e6dc, aStatic = {{ pExpr = 0x170e4ad0, iParent = -1, leftCursor = 3, leftColumn = 4, eOperator = 2, flags = 4 '\004', nChild = 137 '\211', pWC = 0xf089e6c8, prereqRight = 0, prereqAll = 1 }, { pExpr = 0x1729f140, iParent = -1, leftCursor = -1, leftColumn = 561, eOperator = 0, flags = 4 '\004', nChild = 0 '\0', pWC = 0xf089e6c8, prereqRight = 0, prereqAll = 8 }, { pExpr = 0x16ac0510, iParent = -1, leftCursor = 6, leftColumn = 12, eOperator = 2, flags = 0 '\0', nChild = 0 '\0', pWC = 0xf089e6c8, prereqRight = 0, prereqAll = 8 }, { pExpr = 0x16ac0600, iParent = -1, leftCursor = -1, leftColumn = -3959, eOperator = 0, flags = 0 '\0', nChild = 255 '\377', pWC = 0xf089e6c8, prereqRight = 0, prereqAll = 8 }, { pExpr = 0x17259d40, iParent = -1, leftCursor = 3, leftColumn = 2, eOperator = 2, flags = 12 '\f', nChild = 0 '\0', pWC = 0xf089e6c8, prereqRight = 2, prereqAll = 3 }, { pExpr = 0x17259e30, iParent = -1, leftCursor = 4, leftColumn = -1, eOperator = 2, flags = 12 '\f', nChild = 0 '\0', pWC = 0xf089e6c8, prereqRight = 4, prereqAll = 6 }, { pExpr = 0x17259f20, iParent = -1, leftCursor = 3, leftColumn = 1, eOperator = 2, flags = 12 '\f', nChild = 0 '\0', pWC = 0xf089e6c8, prereqRight = 8, prereqAll = 9 }, { pExpr = 0x17209b10, iParent = 6, leftCursor = 6, leftColumn = -1, eOperator = 2, flags = 7 '\a', nChild = 35 '#', pWC = 0xf089e6c8, prereqRight = 1, prereqAll = 9 }, { pExpr = 0x16ae10c0, iParent = 5, leftCursor = 5, leftColumn = -1, eOperator = 2, flags = 7 '\a', nChild = 49 '1', pWC = 0xf089e6c8, prereqRight = 2, prereqAll = 6 }, { pExpr = 0x16ae9a20, iParent = 4, leftCursor = 4, leftColumn = 2, eOperator = 2, flags = 7 '\a', nChild = 0 '\0', pWC = 0xf089e6c8, prereqRight = 1, prereqAll = 3 }} } At the time of the crash, no other thread was doing any active work with sqlite. I can't think of any additional info to provide here that would help track this problem down. I hope what I supplied is sufficient to give you a hint where to start looking... I'll save the database, so I can provide you with more information on the exact schema if you need. _sorry for the lengthy report and the ultra-wide formatting, but the stacktrace won't be readable if I divide the lines and I couldn't find a way of attaching things as a separate file_ _2007-Jun-22 13:55:03 by anonymous:_ {linebreak} I just found that I can reproduce this 100% with our application (at least in my current setup - it only happens when I do things in a certain order), so if you need further information, I can probably provide more info. ---- _2007-Jun-22 15:24:00 by anonymous:_ {linebreak} Did you run the test case through valgrind and find anything interesting? ---- _2007-Jun-22 15:33:07 by anonymous:_ {linebreak} The calling function (#1 in the backtrace) executed this code: Column *pCol = &pTab->aCol[i]; sqlite3ValueFromExpr(pCol->pDflt, enc, pCol->affinity, &pValue); Can you print all the arguments in gdb after the crash? pCol *pCol enc &pValue pValue ---- _2007-Jun-22 16:18:38 by anonymous:_ {linebreak} Here's the gdb printout of the parameters of =sqlite3ValueFromExpr= after the crash: (gdb) print pExpr $1 = (Expr *) 0x6e67436f (gdb) print *pExpr Cannot access memory at address 0x6e67436f (gdb) print enc $2 = 3 '\003' (gdb) print affinity $3 = 114 'r' (gdb) print ppVal $4 = (sqlite3_value **) 0xf079c250 (gdb) print *ppVal $5 = (sqlite3_value *) 0x0 Let me know if you need something else (you can also e-mail me at jum at mac dot com) ---- _2007-Jun-22 18:38:47 by anonymous:_ {linebreak} Can you reproduce the crash using only a single thread? ---- _2007-Jun-23 06:19:27 by danielk1977:_ {linebreak} Can you post the database? Or just the contents of the sqlite_master table if you like. Or if you don't want to post it here, can you send it to me at "dan@sqlite.org". Thanks. ---- _2007-Jun-25 07:59:07 by anonymous:_ {linebreak} I can't check whether this happens with just a single thread, since there's no way to have our app launch without background threads and cutting them off would require a major rewrite, so there's not really an easy way to get it single-threaded. However, it is so easy and reliable to reproduce without even having much data or background operations, that I meanwhile doubt it's a thread synchronization issue. ---- Thanks for all the details. #c8c8c8 2444 code closed 2007 Jun anonymous 2007 Jun 2 3 SIGFPE from division of (1<<63)==9223372036854775808 select (1<<63) / -1 or select (1<<63) % -1; blow up. Check-in [3945] looks to be something that has attempted to address this and also added the regression test that SIGFPE's here (expr-1.104 {i1=0} {(-9223372036854775808 % -1)} 0.0). I don't see how this check-in is supposed to work, but clearly the regression test passed somewhere at some point. Some explanation here would be of interest. Tested on 32 & 64-bit Linux systems, from 3.3.3 -> 3.4.0. from vdbe.c: 1183 default: { 1184 i64 ia = (i64)a; 1185 i64 ib = (i64)b; 1186 if( ia==0 ) goto divide_by_zero; ->1187 b = ib % ia; 1188 break; (Sorry this report is terse, it's late here and I'll take another look tomorrow after some sleep). The most obvious fix is this somewhat ugly patch attached (I'm going to argue (i64)1<<63 is more intuitive in this case), but I'm not sure I like it as-is. _2007-Jun-22 15:17:37 by anonymous:_ {linebreak} What compiler version and compile flags are you using? SQLite version 3.4.0 Enter ".help" for instructions sqlite> select (1<<63) / -1; -9223372036854775808 sqlite> select (1<<63) % -1; 0 ---- _2007-Jun-22 16:11:44 by danielk1977:_ {linebreak} Note that in SQLite, a literal -9223372036854775808 is not the same as (1<<63): sqlite> select typeof( (1<<63) ); integer sqlite> select typeof( -9223372036854775808 ); real Which is why: sqlite> select (-9223372036854775808 / -1)>1; 1 sqlite> select ((1<<63) / -1)>1; 0 yet: sqlite> select -9223372036854775808 == (1<<63); 1 Why some systems get a SIGFPE and some systems happily overflow the integer I'm not sure. ---- _2007-Jun-22 21:16:10 by anonymous:_ {linebreak} I see this with 64-bit (x86-64) versions of sqlite, versions shipping by both Red Hat (RHEL and FC), Debian and also versions I build. I'm not able to get it to fail on 32-bit systems and looking at the code that makes sense (the previous reported failure on 32-bit systems was done at 2am or so, so I might have testing in the wrong session when I claimed it broke there). Anyhow, after some sleep I really do think this is a corner case that should be dealt with explicitly. SIGFPE is *bad*. Not noticing the overflow is also *bad*, so I think something like my suggested patch is needed. It's debatable as to whether using 1<<63 or -9223372036854775808 makes the most sense. It probably could be done a little cleaner and a comment wouldn't be the worst idea ever. Maybe another updated regression test or two is needed. I'll happily provide updated patches if there is consensus here. ---- _2007-Jun-22 21:58:14 by anonymous:_ {linebreak} I just uploaded http://www.sqlite.org/cvstrac/attach_get/395/undef-i64-div.patch as an updated solution. May need some work. ---- _2007-Jun-22 22:05:57 by anonymous:_ {linebreak} Surely this is an x86-64 compiler bug. Can you run this in gdb and show a backtrace as well as print out the dividend and divisor? Recompile sqlite3 with no optimization of any kind (replace -O2 with -O0) and repeat these steps. ---- _2007-Jun-22 23:10:32 by anonymous:_ {linebreak} It's not a compiler bug. I can provide all the stack traces and printing you like, but indulge me for a second without using a CPU. For 2s compliment integer math, the issue at hand is that the CPU's range is -(MAX_INT+1) to MAX_INT. So for 64-bit integers this works out to be -9223372036854775808 to 9223372036854775807. Hex representation of that being 0x8000000000000000 to 0x7FFFFFFFFFFFFFFF. 1<<63 is the greatest (absolute) negative value you can have. It's absolute value is greater than what you can represent with a positive integer. The 2s compliment range isn't symmetrical because we have only one 0 (1s compliment is and has -0 and +0 by contrast). So there is no way to do this in integer math for 2s compliment, you either silently get undefined & wrong results (as tested now on 32-bit i386, 32-bit ppc, 64 bit ppc and 32-bit mips) or a CPU exception in the case of x86-64. If you only have a 32-bit intel processor at hand try something like: long foo() { long a = 1; long b = -1; long c; a <<= 31; c = a / b; printf("a=%ld\n", a); printf("b=%ld\n", b); printf("c=%ld\n", c); } main() { foo(); return 0; } (I wrote it like this to make the (dis)assembly easier to follow). So, I'm suggesting something along the changes I posted because of think null/NaN makes more sense than a crash or a wrong value. The alternative is to promote the integer to a real and return the correct value. That doesn't seem useful given this is a corner case and my main concern is really the crash inside the library. ---- _2007-Jun-23 00:35:56 by anonymous:_ {linebreak} Okay, I see what you mean. $ cat foo.c long foo(long a, long b) { a <<= 31; return a / b; } $ gcc -S -O3 -fomit-frame-pointer foo.c $ cat foo.s .file "foo.c" .text .p2align 4,,15 .globl foo .type foo, @function foo: movl 4(%esp), %edx sall $31, %edx movl %edx, %eax sarl $31, %edx idivl 8(%esp) ret The SIGFPE threw me, as this was an integer operation, not floating point. This is just what UNIX happens to call the divide error fault. From an x86 manual for the opcode IDIV: If the dividend is 0 or if the quotient is too large to fit in the result accumulator, a divide error fault occurs. So the long long handling GCC code for 32 bit x86 machines handles this case, while the x86-64 native hardware IDIV instruction does not. Interesting. This is the sort of undefined behavior you get when you go beyond a signed int's limits. ---- _2007-Jun-23 06:03:01 by danielk1977:_ {linebreak} I'm inclined to handle all three cases as special cases. For the two that use the '%' operator, can we not just do the following? if( a==-1 ){ b = 0; }else{ b %= a; } The divide case is a bit trickier I suppose. I think we should either promote the result to a real number or throw an exception (like the divide-by-zero case). Or maybe emulate the behaviour currently produced by 32-bit systems. After all, we allow integer overflow to occur in other cases: sqlite> select ( (1<<62) * 17 ) = (1<<62); 1 So we would make changes so that there are two special cases in SQLite's integer arithmatic: 1) Evaluating (X % -1) is always 0 (this should suit everybody), and 2) Evaluating ((1<<63)/-1) overflows the 64 bit integer and returns (1<<63). Opinions? ---- _2007-Jun-23 07:52:28 by anonymous:_ {linebreak} For the % operator I agree. For he / operator I'm not so sure. Returning (1<<63) is wrong. Some implementations and CPUs will do that sometimes but not all, so there is no precedent. It even depends on the gcc optimization level on some (ie. ppc64). If this was a full-blown data base I would argue we should either return NULL so it's not mistaken as something that's valid or promote it to a real. Given it's a light-weight embedded database and as you point out there are overflows (without promotion) elsewhere, then maybe the right approach for now is to just avoid the SIGFPE crash (except then we will have cases where the results vary between machines or between builds on the same machine in some cases). I'm not sure what implications there are about promotion in these cases, if any. I think that probably requires some more thought. This isn't exactly a new issue, it's been around for a long time without causing (reported) problems so I think it's reasonable to mull this over for a little bit. ---- _2007-Jun-23 13:32:29 by anonymous:_ {linebreak} Doing a mod of -1 is useless anyway, so any result is fine as long as it is the same on all platforms regardless of 32bit or 64bit chip. While we're on the topic, is there an easy way to detect an overflowed integer multiplication in C so that it could be promoted to a double? sqlite> select 15241578750190521 * 15241578750190521; 7423698896135986097 Is it more important to preserve this quirky overflowing 64 bit integer math at the cost of correct floating point math? I think most SQLite end-users (i.e., non-programmers) would expect the latter. Maybe some pragma to control overall integer -> double promtion would be in order here? PRAGMA floating_point_math = on/off; If this proposed floating_point_math were on, then all arguments to multiplication and division would be unconditionally promoted to doubles. #f2dcdc 2443 new active 2007 Jun anonymous 2007 Jun 3 3 sqlite should return different exit codes for different errors 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:_ {linebreak} Just run sqlite3 -batch -bail and grep for the error in the last line. #f2dcdc 2442 doc active 2007 Jun anonymous 2007 Jun 1 4 mailing list link doesn't always exist in website header 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. #c8c8c8 2441 code closed 2007 Jun anonymous 2007 Jun 2 3 Windows only error when deleting tempory files When sqlite creates the temporary journal files, it sets the delete flag to true. On unix systems, this simply sets the file permissions to 0600, which equates to rw-------. On windows, it actually sets the FILE_FLAG_DELETE_ON_CLOSE, and the file gets deleted. However, sqlite then goes through and cleans these files up, so it actually deletes something on unix, but on windows it returns an error because the file no longer exists. When writing cross platform code, this makes things difficult. Since sqlite deletes these journal fils itself, it shouldn't be also setting the delete flag (or alternatively not closing the file). This bug also exists in the latest version (by looking at the code). Downstream Bug (from Mozilla): https://bugzilla.mozilla.org/show_bug.cgi?id=341137 _2007-Jun-21 02:59:12 by anonymous:_ {linebreak} I was under the impression that FILE_FLAG_DELETE_ON_CLOSE doesn't work on all Windows OSes, in particular Windows NT. Any Windows experts care to comment? ---- _2007-Jun-21 12:18:30 by drh:_ {linebreak} I think it is WinCE that does not support FILE_FLAG_DELETE_ON_CLOSE. See ticket #279. Also ticket #2350. For systems that do suppport DELETE_ON_CLOSE, we definitely want to use it. Otherwise, if the process using SQLite shuts down (for example via exit(0)) without first closing its database connection, we do not want temporary files hanging around afterwards. DELETE_ON_CLOSE will remove them automatically. On the other hand, we also want to manually delete temporary files when shutting down for those cases where the DELETE_ON_CLOSE flag does not work. See ticket #2350. SQLite appears to be doing the right thing. It sets DELETE_ON_CLOSE but also makes sure that the file really does delete by manually deleting the file when the database connection is closed. If the DELETE_ON_CLOSE worked right, then there will be nothing to delete when the manual delete comes around. But no harm is done either. I think the correct fix for the original problem is to changes the application so that it no longer upset when someone tries to delete a file that does not exist. The application should ignore the problem and move on. I fail to see how this make it any more difficult to write a cross-platform application. ---- _2007-Jun-21 23:36:08 by anonymous:_ {linebreak} This complicates things for cross platform development because you get different behaviors on different platforms. If you wanted to bring parity across platforms on behavior, you'd ideally unlink the file pointer you have on unix (it looks like os2 has code for automatic deletion as well). Unlinking it will decrement the link count of the file, but removal will not occur until all references to the file are closed. My issue here is that there are different behaviors on different platforms, when sqlite really should behave the same if possible. Ignoring return values of a function isn't the most ideal solution either... ---- _2007-Jun-22 01:56:13 by anonymous:_ {linebreak} I'm not sure what you're talking about. Unix unlink()s temp file on open(). See delFlag. static int sqlite3UnixOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){ int h; CRASH_TEST_OVERRIDE(sqlite3CrashOpenExclusive, zFilename, pId, delFlag); assert( 0==*pId ); h = open(zFilename, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE|O_BINARY, delFlag ? 0600 : SQLITE_DEFAULT_FILE_PERMISSIONS); if( h<0 ){ return SQLITE_CANTOPEN; } return allocateUnixFile(h, pId, zFilename, delFlag); } ... static int allocateUnixFile( int h, /* Open file descriptor on file being opened */ OsFile **pId, /* Write the resul unixFile structure here */ const char *zFilename, /* Name of the file being opened */ int delFlag /* If true, delete the file on or before closing */ ){ unixFile *pNew; unixFile f; int rc; memset(&f, 0, sizeof(f)); sqlite3OsEnterMutex(); rc = findLockInfo(h, &f.pLock, &f.pOpen); sqlite3OsLeaveMutex(); if( delFlag ){ unlink(zFilename); } ---- _2007-Jun-22 15:42:39 by anonymous:_ {linebreak} Thanks to this issue, myself and many others are having our temp folders filled with various etilqs_* files. Please reconsider your decision to not fix this issue. ---- _2007-Jun-22 15:43:52 by anonymous:_ {linebreak} By chance are you using the SQLiteJDBC driver? ---- _2007-Jun-22 15:49:52 by anonymous:_ {linebreak} I'm using a current trunk build of Firefox, which uses the 3.3.17 amalgamation file (as this bug was filed under). ---- _2007-Jun-22 15:57:06 by anonymous:_ {linebreak} I haven't had any problems with etilqs_* temp file on Windows when using the sqlite3 commandline shell, via an SQLite ODBC driver and SQLite native JDBC driver. What is Firefox doing differently? BTW the mozilla ticket you cited was closed as FIXED and I don't see any mention of these temp files. ---- _2007-Jun-22 16:31:41 by anonymous:_ {linebreak} You didn't mention that Mozilla has created its own async file I/O subsystem for SQLite: http://developer.mozilla.org/en/docs/Storage:Performance#Lazy_writing Just have to tweak this async I/O code to not return an error for deleting a file that does not exist. ---- _2007-Jun-22 16:36:39 by anonymous:_ {linebreak} Also, since you've replace all I/O calls to sqlite you must handle the file unlink ref count stuff yourself on Windows, since you're not using the default mechanisms provided by #ifdef OS_WIN in sqlite. ---- _2007-Jun-22 16:54:48 by anonymous:_ {linebreak} If WinCE is the only platform where FILE_FLAG_DELETE_ON_CLOSE doesn't work reliably, I'm not sure why the manual delete can't just live in a CE-specific ifdef. Either way, this seems like an expected error in most cases, and shouldn't require the app to handle it. At the least, documentation about when it is and isn't acceptable to ignore that error seems appropriate, since apparently there isn't any... ---- _2007-Jun-22 17:38:28 by anonymous:_ {linebreak} Our code for async IO is just a wrapper around your IO functions but running on a different thread. In the end, we still call all of your functions: http://mxr.mozilla.org/seamonkey/source/storage/src/mozStorageAsyncIO.cpp#1438 -sdwilsh ---- _2007-Jun-22 18:32:48 by anonymous:_ {linebreak} SQLite was not written with async I/O in mind. As such, if you replace SQLite's I/O functions with your own you must provide identical symantics to the functions you are replacing. It does not seem like you are doing that. ---- _2007-Jun-22 19:40:45 by anonymous:_ {linebreak} In your async IO you seem to put each IO request on a work-queue for another thread to process and then always return success immediately. You can only recognize errors on the _next_ sqlite IO operation - whatever it may be. So you don't have much choice but to do something like this: case ASYNC_DELETE: NS_ASSERTION(sqliteOrigDelete, "No delete pointer"); - rc = sqliteOrigDelete(aMessage->mBuf); + sqliteOrigDelete(aMessage->mBuf); + rc = SQLITE_OK; break; since you do not know the context in which it the file delete is called. I think at the time test_async.c was written SQLite did not generally check the return code of sqlite3OSDelete. It assumed success. Even now, you can see that sometimes its return code is not checked (lines without rc assignments): pager.c: rc = sqlite3OsDelete(pPager->zJournal); pager.c: rc = sqlite3OsDelete(zMaster); pager.c: sqlite3OsDelete(pPager->zJournal); pager.c: sqlite3OsDelete(pPager->zJournal); vdbeaux.c: sqlite3OsDelete(zMaster); vdbeaux.c: sqlite3OsDelete(zMaster); vdbeaux.c: rc = sqlite3OsDelete(zMaster); Because test_async.c was a proof of concept and is not actively tested, you have to check that newer versions of sqlite do not break any of its assumptions. #f2dcdc 2440 code active 2007 Jun rse 2007 Jun 2 2 pkg-config(1) script "sqlite.pc" does not provide Autoconf's LIBS 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 
#f2dcdc 2438 new active 2007 Jun rse 2007 Jun 3 3 More easily allow the building of SQLite with FTS1 and FTS2 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 
#cfe8bd 2437 code fixed 2007 Jun rse 2007 Jun 3 3 Consistently use $(NAWK) in Makefile.in SQLite's Autoconf stuff correctly figures out a decent awk(1) and Makefile.in uses this through the NAWK variable in mostly all places. Except for a single remaining one where IMHO for consistenty reasons it makes sense to also use NAWK. Just search for "awk -f $(TOP)/addopcodes.awk" in Makefile.in to locate the occurence. #cfe8bd 2436 code fixed 2007 Jun rse 2007 Jun 1 1 SQLite has to link against -lm for isnan(3) SQLite since version 3.4.0 uses isnan(3). This is usually provided by libm and hence the SQLite Autoconf glue has to ensure that this library is picked up. Possible patch follows:
 Index: configure.ac --- configure.ac    17 Feb 2007 14:59:18 -0000  1.29 +++ configure.ac    20 Jun 2007 15:11:57 -0000 @@ -551,6 +551,10 @@  #  AC_SEARCH_LIBS(fdatasync, [rt])  +########## +# Make sure isnan(3) is available. +AC_CHECK_LIB(m, isnan) +  #########  # check for debug enabled  AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]), 
#c8c8c8 2435 code closed 2007 Jun anonymous 2007 Jun 1 1 Data corruption in version 3.4.0 When updating to version 3.4.0 a new bug appeared. After executing a statement like "INSERT into xxx (p1, p2, p3) VALUES ( ?, ? ,?)" and binding some string parameters, a statement like "SELECT p1, p2 ,p3 FROM xxx" will return some of the data corrupted. NO changes made to the calling code and it is working just fine with the version 3.2.07. _2007-Jun-20 14:20:36 by anonymous:_ {linebreak} This bug report is not useful in determining if there is a problem. At the very least you'd have to supply working code, or a schema and example SQL statements to reproduce the bug. #cfe8bd 2434 code fixed 2007 Jun anonymous 2007 Jun 5 5 comment typo in analyze.c s/sqlite_stmt1/sqlite_stat1/g src/analyze.c: ** The result is a single row of the sqlite_stmt1 table. The first #cfe8bd 2433 code fixed 2007 Jun rse 2007 Jun 1 2 sqlite CLI's reading of ".sqliterc" broken in 3.4.0 In SQLite 3.4.0 the reading of ~/.sqliterc is broken because of a code change which assumed that a buffer is a C array while it actually is a malloc(3)'ed area. As a result printing to it via sqlite3_snprintf(sizeof(...), ...) prints just sizeof(char *) which is just 4 or 8 bytes ;-) The following patch fixes this. I wanted to commit it myself, but seems like my current "user karma" aka CVS permissions do not (or no longer) allow this. Well, so someone else: please pickup this patch to fix this for SQLite 3.4.1. Thanks.
 Index: shell.c --- shell.c 4 May 2007 13:15:56 -0000   1.162 +++ shell.c 20 Jun 2007 12:49:50 -0000 @@ -1753,6 +1753,7 @@    char *home_dir = NULL;    const char *sqliterc = sqliterc_override;    char *zBuf = 0; +  int n;    FILE *in = NULL;     if (sqliterc == NULL) { @@ -1761,12 +1762,13 @@        fprintf(stderr,"%s: cannot locate your home directory!\n", Argv0);        return;      } -    zBuf = malloc(strlen(home_dir) + 15); +    n = strlen(home_dir) + 15; +    zBuf = malloc(n);      if( zBuf==0 ){        fprintf(stderr,"%s: out of memory!\n", Argv0);        exit(1);      } -    sqlite3_snprintf(sizeof(zBuf), zBuf,"%s/.sqliterc",home_dir); +    sqlite3_snprintf(n, zBuf,"%s/.sqliterc",home_dir);      free(home_dir);      sqliterc = (const char*)zBuf;    } 
#cfe8bd 2432 doc fixed 2007 Jun anonymous 2007 Jun 5 5 Documentation typo in sqlite3_sleep() ** CAPI3REF: Suspend Execution For A Short Time{linebreak} **{linebreak} ** This function causes the current thread to suspect execution ...{linebreak} {linebreak} should be:{linebreak} ... suspend execution ...{linebreak} #cfe8bd 2431 code fixed 2007 Jun anonymous 2007 Jun 2 3 segfault with missing order by expression Simples way to show this (discovered when I mistyped something else): cw@lysdexia:~$ sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> create table t1 ( c1 text ) ; sqlite> select min(c1), c1 from t1 group by ; Segmentation fault (gdb) bt #0 0x0000000000420b84 in sqlite3WhereBegin () #1 0x00000000004538f9 in sqlite3Select () #2 0x000000000044b2b6 in sqlite3Parser () #3 0x000000000040d2fc in sqlite3RunParser () #4 0x000000000040a31c in sqlite3Prepare () #5 0x000000000042281a in sqlite3_exec () #6 0x0000000000403794 in process_input () #7 0x00000000004059d6 in main () 1107 p = pOrderBy->a[0].pExpr; 1108 if( p->op==TK_COLUMN && p->iTable==base && p->iColumn==-1 (gdb) p p $2 = (Expr *) 0x0 _2007-Jun-19 23:28:32 by anonymous:_ {linebreak} This avoids the bug, but I haven't run make test. I can't see a reason for a NULL expritem, though. Index: src/parse.y =================================================================== RCS file: /sqlite/sqlite/src/parse.y,v retrieving revision 1.230 diff -u -3 -p -r1.230 parse.y --- src/parse.y 15 Jun 2007 17:03:14 -0000 1.230 +++ src/parse.y 19 Jun 2007 23:26:24 -0000 @@ -856,7 +856,6 @@ exprlist(A) ::= exprlist(X) COMMA exprit {A = sqlite3ExprListAppend(X,Y,0);} exprlist(A) ::= expritem(X). {A = sqlite3ExprListAppend(0,X,0);} expritem(A) ::= expr(X). {A = X;} -expritem(A) ::= . {A = 0;} ///////////////////////////// The CREATE INDEX command /////////////////////// // ---- _2007-Jun-20 00:25:25 by anonymous:_ {linebreak} The previous patch doesn't take into account SQL functions with no arguments. Index: src/parse.y =================================================================== RCS file: /sqlite/sqlite/src/parse.y,v retrieving revision 1.230 diff -u -3 -p -r1.230 parse.y --- src/parse.y 15 Jun 2007 17:03:14 -0000 1.230 +++ src/parse.y 20 Jun 2007 00:24:51 -0000 @@ -660,7 +660,7 @@ expr(A) ::= CAST(X) LP expr(E) AS typeto sqlite3ExprSpan(A,&X,&Y); } %endif SQLITE_OMIT_CAST -expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(E). { +expr(A) ::= ID(X) LP distinct(D) fn_exprlist(Y) RP(E). { if( Y && Y->nExpr>SQLITE_MAX_FUNCTION_ARG ){ sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X); } @@ -856,7 +856,17 @@ exprlist(A) ::= exprlist(X) COMMA exprit {A = sqlite3ExprListAppend(X,Y,0);} exprlist(A) ::= expritem(X). {A = sqlite3ExprListAppend(0,X,0);} expritem(A) ::= expr(X). {A = X;} -expritem(A) ::= . {A = 0;} + +%type fn_exprlist {ExprList*} +%destructor fn_exprlist {sqlite3ExprListDelete($$);} +%type fn_expritem {Expr*} +%destructor fn_expritem {sqlite3ExprDelete($$);} + +fn_exprlist(A) ::= fn_exprlist(X) COMMA fn_expritem(Y). + {A = sqlite3ExprListAppend(X,Y,0);} +fn_exprlist(A) ::= fn_expritem(X). {A = sqlite3ExprListAppend(0,X,0);} +fn_expritem(A) ::= expr(X). {A = X;} +fn_expritem(A) ::= . {A = 0;} ///////////////////////////// The CREATE INDEX command /////////////////////// // ---- _2007-Jun-20 00:28:06 by anonymous:_ {linebreak} Well, it's no worse than before, but this is still wrong: sqlite> select round(5,); 5.0 ---- _2007-Jun-20 00:44:00 by anonymous:_ {linebreak} Another kick at the can. This can handle SELECT round(5,); correctly: Index: src/parse.y =================================================================== RCS file: /sqlite/sqlite/src/parse.y,v retrieving revision 1.230 diff -u -3 -p -r1.230 parse.y --- src/parse.y 15 Jun 2007 17:03:14 -0000 1.230 +++ src/parse.y 20 Jun 2007 00:42:28 -0000 @@ -660,7 +660,7 @@ expr(A) ::= CAST(X) LP expr(E) AS typeto sqlite3ExprSpan(A,&X,&Y); } %endif SQLITE_OMIT_CAST -expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(E). { +expr(A) ::= ID(X) LP distinct(D) fn_exprlist(Y) RP(E). { if( Y && Y->nExpr>SQLITE_MAX_FUNCTION_ARG ){ sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X); } @@ -856,7 +856,17 @@ exprlist(A) ::= exprlist(X) COMMA exprit {A = sqlite3ExprListAppend(X,Y,0);} exprlist(A) ::= expritem(X). {A = sqlite3ExprListAppend(0,X,0);} expritem(A) ::= expr(X). {A = X;} -expritem(A) ::= . {A = 0;} + +%type fn_exprlist {ExprList*} +%destructor fn_exprlist {sqlite3ExprListDelete($$);} +%type fn_expritem {Expr*} +%destructor fn_expritem {sqlite3ExprDelete($$);} + +fn_exprlist(A) ::= . {A = 0;} +fn_exprlist(A) ::= fn_exprlist(X) COMMA fn_expritem(Y). + {A = sqlite3ExprListAppend(X,Y,0);} +fn_exprlist(A) ::= fn_expritem(X). {A = sqlite3ExprListAppend(0,X,0);} +fn_expritem(A) ::= expr(X). {A = X;} ///////////////////////////// The CREATE INDEX command /////////////////////// // ---- _2007-Jun-20 01:09:40 by anonymous:_ {linebreak} Groan. Forgot about SELECT round(,5); sqlite> select round(,5); SQL error: near ",": syntax error sqlite> select round(,); SQL error: near ",": syntax error sqlite> select round(5,); SQL error: near ")": syntax error sqlite> select round(5); 5.0 sqlite> select round(5,1); 5.0 sqlite> select sqlite_version(); 3.4.0 sqlite> select * from sqlite_master group by; SQL error: near ";": syntax error This patch handles all cases above correctly: Index: src/parse.y =================================================================== RCS file: /sqlite/sqlite/src/parse.y,v retrieving revision 1.230 diff -u -3 -p -r1.230 parse.y --- src/parse.y 15 Jun 2007 17:03:14 -0000 1.230 +++ src/parse.y 20 Jun 2007 01:08:15 -0000 @@ -660,7 +660,7 @@ expr(A) ::= CAST(X) LP expr(E) AS typeto sqlite3ExprSpan(A,&X,&Y); } %endif SQLITE_OMIT_CAST -expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(E). { +expr(A) ::= ID(X) LP distinct(D) fn_params(Y) RP(E). { if( Y && Y->nExpr>SQLITE_MAX_FUNCTION_ARG ){ sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X); } @@ -849,14 +849,21 @@ case_operand(A) ::= . %type exprlist {ExprList*} %destructor exprlist {sqlite3ExprListDelete($$);} -%type expritem {Expr*} -%destructor expritem {sqlite3ExprDelete($$);} -exprlist(A) ::= exprlist(X) COMMA expritem(Y). +exprlist(A) ::= exprlist(X) COMMA expr(Y). {A = sqlite3ExprListAppend(X,Y,0);} -exprlist(A) ::= expritem(X). {A = sqlite3ExprListAppend(0,X,0);} -expritem(A) ::= expr(X). {A = X;} -expritem(A) ::= . {A = 0;} +exprlist(A) ::= expr(X). {A = sqlite3ExprListAppend(0,X,0);} + +%type fn_exprlist {ExprList*} +%destructor fn_exprlist {sqlite3ExprListDelete($$);} +%type fn_params {ExprList*} +%destructor fn_params {sqlite3ExprListDelete($$);} + +fn_exprlist(A) ::= fn_exprlist(X) COMMA expr(Y). + {A = sqlite3ExprListAppend(X,Y,0);} +fn_exprlist(A) ::= expr(X). {A = sqlite3ExprListAppend(0,X,0);} +fn_params(A) ::= fn_exprlist(X). {A = X;} +fn_params(A) ::= . {A = 0;} ///////////////////////////// The CREATE INDEX command /////////////////////// // ---- _2007-Jun-20 01:26:09 by anonymous:_ {linebreak} Simplified: Index: src/parse.y =================================================================== RCS file: /sqlite/sqlite/src/parse.y,v retrieving revision 1.230 diff -u -3 -p -r1.230 parse.y --- src/parse.y 15 Jun 2007 17:03:14 -0000 1.230 +++ src/parse.y 20 Jun 2007 01:23:07 -0000 @@ -660,7 +660,7 @@ expr(A) ::= CAST(X) LP expr(E) AS typeto sqlite3ExprSpan(A,&X,&Y); } %endif SQLITE_OMIT_CAST -expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(E). { +expr(A) ::= ID(X) LP distinct(D) fn_params(Y) RP(E). { if( Y && Y->nExpr>SQLITE_MAX_FUNCTION_ARG ){ sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X); } @@ -849,14 +849,16 @@ case_operand(A) ::= . %type exprlist {ExprList*} %destructor exprlist {sqlite3ExprListDelete($$);} -%type expritem {Expr*} -%destructor expritem {sqlite3ExprDelete($$);} -exprlist(A) ::= exprlist(X) COMMA expritem(Y). +exprlist(A) ::= exprlist(X) COMMA expr(Y). {A = sqlite3ExprListAppend(X,Y,0);} -exprlist(A) ::= expritem(X). {A = sqlite3ExprListAppend(0,X,0);} -expritem(A) ::= expr(X). {A = X;} -expritem(A) ::= . {A = 0;} +exprlist(A) ::= expr(X). {A = sqlite3ExprListAppend(0,X,0);} + +%type fn_params {ExprList*} +%destructor fn_params {sqlite3ExprListDelete($$);} + +fn_params(A) ::= exprlist(X). {A = X;} +fn_params(A) ::= . {A = 0;} ///////////////////////////// The CREATE INDEX command /////////////////////// // ---- _2007-Jun-20 01:41:50 by anonymous:_ {linebreak} More test cases: select * from sqlite_master group by ,; select * from sqlite_master group by ,,; select * from sqlite_master group by 1,; select * from sqlite_master group by ,1; select * from sqlite_master group by ,1,; ---- _2007-Jun-20 02:01:14 by anonymous:_ {linebreak} Latest patch ran "make test" with no new regressions. #cfe8bd 2430 code fixed 2007 Jun anonymous 2007 Jun 3 3 date and strftime functions returns invalid year the command:{linebreak} select strftime('%Y-%m-%d', time) from ticket;{linebreak} shows the wrong result:{linebreak} 3226394-11-26{linebreak} 3226394-11-26{linebreak} 3231515-03-30{linebreak} sqlite>{linebreak} the same happens with:{linebreak} select date(time) from ticket;{linebreak} System:{linebreak} debian etch (4.0){linebreak} trac 0.10.xx{linebreak} _2007-Jun-19 19:12:22 by drh:_ {linebreak} What do you get from this query: SELECT time, strftime('%Y-%m-%d', time) FROM ticket; ---- _2007-Jun-19 19:24:32 by anonymous:_ {linebreak} the result:{linebreak} 1182007765|3231515-03-30{linebreak} ----------------------------------- but I found that the modifier 'unixepoch' results the correct year;-){linebreak} many THX #c8c8c8 2429 code closed 2007 Jun danielk1977 2007 Jun shess 1 3 problem with fts2 snippet() function There's a problem with the snippet() function when the corresponding MATCH expression uses the left-most column of a full-text table. See the attached testfixture script for an example. Suggested patch follows. RCS file: /sqlite/sqlite/ext/fts2/fts2.c,v retrieving revision 1.33 diff -a -u -r1.33 fts2.c --- ext/fts2/fts2.c 12 Jun 2007 18:20:05 -0000 1.33 +++ ext/fts2/fts2.c 19 Jun 2007 15:01:02 -0000 @@ -3105,7 +3105,7 @@ if( p->q.nTerms==0 ) return; pFts = p->q.pFts; nColumn = pFts->nColumn; - iColumn = p->iCursorType; + iColumn = (p->iCursorType - QUERY_FULLTEXT); if( iColumn<0 || iColumn>=nColumn ){ iFirst = 0; iLast = nColumn-1; _2007-Jun-19 18:32:09 by shess:_ {linebreak} Looks like it applies to any but the last two columns. #cfe8bd 2428 build fixed 2007 Jun anonymous 2007 Jun 4 3 sqlite 3.4.0 ships with own 'limits.h' interfering with system one. I have a local build module which untars the sqlite tarball and builds it, some custom extensions, and the (2.5.1) python module using a custom buildsystem. Updating to sqlite 3.4.0 today has made the python module fail to build unless I rename the new sqlite-shipped limits.h (and edit sqliteInt.h); Python.h requires the system limits.h to define UCHAR_MAX (amongst other things), and the sqlite version is being used instead. I'd suggest renaming limits.h to something else (I'm locally patching it to sqlite-limits.h, currently) for the next release; I'd be surprised if I was the only one with this problem. #f2dcdc 2427 doc active 2007 Jun anonymous 2007 Jun 4 3 HTML Tidy warnings on new capi3ref.html 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 declaration line 2 column 1 - Warning: inserting implicit line 3 column 1 - Warning: discarding unexpected line 336 column 1 - Warning: missing before

line 337 column 5 - Warning: inserting implicit line 338 column 13 - Warning: inserting implicit line 338 column 13 - Warning: missing before
   line 352 column 1 - Warning: missing  before 

line 353 column 5 - Warning: inserting implicit line 354 column 13 - Warning: inserting implicit line 354 column 13 - Warning: missing before
   line 368 column 1 - Warning: missing  before 

line 369 column 5 - Warning: inserting implicit line 370 column 13 - Warning: inserting implicit line 370 column 13 - Warning: missing before
   line 380 column 1 - Warning: missing  before 

line 381 column 5 - Warning: inserting implicit line 382 column 13 - Warning: inserting implicit line 382 column 13 - Warning: missing before
   line 398 column 6 - Warning: inserting implicit 

line 402 column 1 - Warning: missing before

line 403 column 5 - Warning: inserting implicit line 404 column 13 - Warning: inserting implicit line 404 column 13 - Warning: missing before
   line 415 column 1 - Warning: missing  before 

line 416 column 5 - Warning: inserting implicit line 417 column 13 - Warning: inserting implicit line 417 column 13 - Warning: missing before
   line 434 column 1 - Warning: missing  before 

line 435 column 5 - Warning: inserting implicit line 436 column 13 - Warning: inserting implicit line 436 column 13 - Warning: missing before
   line 454 column 1 - Warning: missing  before 

line 455 column 5 - Warning: inserting implicit line 456 column 13 - Warning: inserting implicit line 456 column 13 - Warning: missing before
   line 473 column 1 - Warning: missing  before 

line 474 column 5 - Warning: inserting implicit line 475 column 13 - Warning: inserting implicit line 475 column 13 - Warning: missing before
   line 485 column 1 - Warning: missing  before 

line 486 column 5 - Warning: inserting implicit line 487 column 13 - Warning: inserting implicit line 487 column 13 - Warning: missing before
   line 504 column 1 - Warning: missing  before 

line 505 column 5 - Warning: inserting implicit line 506 column 13 - Warning: inserting implicit line 506 column 13 - Warning: missing before
   line 515 column 1 - Warning: missing  before 

line 516 column 5 - Warning: inserting implicit line 517 column 13 - Warning: inserting implicit line 517 column 13 - Warning: missing before
   line 525 column 1 - Warning: missing  before 

line 526 column 5 - Warning: inserting implicit line 527 column 13 - Warning: inserting implicit line 527 column 13 - Warning: missing before
   line 544 column 7 - Warning: inserting implicit 

line 554 column 1 - Warning: missing before

line 555 column 5 - Warning: inserting implicit line 556 column 13 - Warning: inserting implicit line 556 column 13 - Warning: missing before
   line 569 column 1 - Warning: missing  before 

line 570 column 5 - Warning: inserting implicit line 571 column 13 - Warning: inserting implicit line 571 column 13 - Warning: missing before
   line 589 column 1 - Warning: missing  before 

line 590 column 5 - Warning: inserting implicit line 591 column 13 - Warning: inserting implicit line 591 column 13 - Warning: missing before
   line 648 column 1 - Warning: missing  before 

line 649 column 5 - Warning: inserting implicit line 650 column 13 - Warning: inserting implicit line 650 column 13 - Warning: missing before
   line 666 column 1 - Warning: missing  before 

line 667 column 5 - Warning: inserting implicit line 668 column 13 - Warning: inserting implicit line 668 column 13 - Warning: missing before
   line 694 column 1 - Warning: missing  before 

line 695 column 5 - Warning: inserting implicit line 696 column 13 - Warning: inserting implicit line 696 column 13 - Warning: missing before
   line 707 column 1 - Warning: missing  before 

line 708 column 5 - Warning: inserting implicit line 709 column 13 - Warning: inserting implicit line 709 column 13 - Warning: missing before
   line 722 column 1 - Warning: missing  before 

line 723 column 5 - Warning: inserting implicit line 724 column 13 - Warning: inserting implicit line 724 column 13 - Warning: missing before
   line 735 column 1 - Warning: missing  before 

line 736 column 5 - Warning: inserting implicit line 737 column 13 - Warning: inserting implicit line 737 column 13 - Warning: missing before
   line 749 column 1 - Warning: missing  before 

line 750 column 5 - Warning: inserting implicit line 751 column 13 - Warning: inserting implicit line 751 column 13 - Warning: missing before
   line 764 column 1 - Warning: missing  before 

line 765 column 5 - Warning: inserting implicit line 766 column 13 - Warning: inserting implicit line 766 column 13 - Warning: missing before
   line 796 column 1 - Warning: missing  before 

line 797 column 5 - Warning: inserting implicit line 798 column 13 - Warning: inserting implicit line 798 column 13 - Warning: missing before
   line 837 column 1 - Warning: missing  before 

line 838 column 5 - Warning: inserting implicit line 839 column 13 - Warning: inserting implicit line 839 column 13 - Warning: missing before
   line 855 column 1 - Warning: missing  before 

line 856 column 5 - Warning: inserting implicit line 857 column 13 - Warning: inserting implicit line 857 column 13 - Warning: missing before
   line 876 column 1 - Warning: missing  before 

line 877 column 5 - Warning: inserting implicit line 878 column 13 - Warning: inserting implicit line 878 column 13 - Warning: missing before
   line 889 column 1 - Warning: missing  before 

line 890 column 5 - Warning: inserting implicit line 891 column 13 - Warning: inserting implicit line 891 column 13 - Warning: missing before
   line 907 column 1 - Warning: missing  before 

line 908 column 5 - Warning: inserting implicit line 909 column 13 - Warning: inserting implicit line 909 column 13 - Warning: missing before
   line 928 column 1 - Warning: missing  before 

line 929 column 5 - Warning: inserting implicit line 930 column 13 - Warning: inserting implicit line 930 column 13 - Warning: missing before
   line 948 column 1 - Warning: missing  before 

line 949 column 5 - Warning: inserting implicit line 950 column 13 - Warning: inserting implicit line 950 column 13 - Warning: missing before
   line 976 column 1 - Warning: missing  before 

line 977 column 5 - Warning: inserting implicit line 978 column 13 - Warning: inserting implicit line 978 column 13 - Warning: missing before
   line 989 column 1 - Warning: missing  before 

line 990 column 5 - Warning: inserting implicit line 991 column 13 - Warning: inserting implicit line 991 column 13 - Warning: missing before
   line 1004 column 1 - Warning: missing  before 

line 1005 column 5 - Warning: inserting implicit line 1006 column 13 - Warning: inserting implicit line 1006 column 13 - Warning: missing before
   line 1017 column 1 - Warning: missing  before 

line 1018 column 5 - Warning: inserting implicit line 1019 column 13 - Warning: inserting implicit line 1019 column 13 - Warning: missing before
   line 1069 column 1 - Warning: missing  before 

line 1070 column 5 - Warning: inserting implicit line 1071 column 13 - Warning: inserting implicit line 1071 column 13 - Warning: missing before
   line 1083 column 1 - Warning: missing  before 

line 1084 column 5 - Warning: inserting implicit line 1085 column 13 - Warning: inserting implicit line 1085 column 13 - Warning: missing before
   line 1107 column 1 - Warning: missing  before 

line 1108 column 5 - Warning: inserting implicit line 1109 column 13 - Warning: inserting implicit line 1109 column 13 - Warning: missing before
   line 1166 column 1 - Warning: missing  before 

line 1167 column 5 - Warning: inserting implicit line 1168 column 13 - Warning: inserting implicit line 1168 column 13 - Warning: missing before
   line 1198 column 36 - Warning: discarding unexpected 

line 1198 column 40 - Warning: using
in place of

line 1198 column 40 - Warning: replacing

by
line 1203 column 7 - Warning: inserting implicit

line 1215 column 7 - Warning: inserting implicit

line 1222 column 1 - Warning: missing before

line 1223 column 5 - Warning: inserting implicit line 1224 column 13 - Warning: inserting implicit line 1224 column 13 - Warning: missing before
   line 1238 column 1 - Warning: missing  before 

line 1239 column 5 - Warning: inserting implicit line 1240 column 13 - Warning: inserting implicit line 1240 column 13 - Warning: missing before
   line 1259 column 1 - Warning: missing  before 

line 1260 column 5 - Warning: inserting implicit line 1261 column 13 - Warning: inserting implicit line 1261 column 13 - Warning: missing before
   line 1286 column 1 - Warning: missing  before 

line 1287 column 5 - Warning: inserting implicit line 1288 column 13 - Warning: inserting implicit line 1288 column 13 - Warning: missing before
   line 1299 column 1 - Warning: missing  before    line 1300 column 1 - Warning: missing  before    line 1301 column 1 - Warning: missing  before    line 1302 column 1 - Warning: missing  before    line 1303 column 1 - Warning: missing  before    line 1304 column 1 - Warning: missing  before    line 1305 column 1 - Warning: missing  before    line 1306 column 1 - Warning: missing  before    line 1307 column 1 - Warning: missing  before    line 1308 column 1 - Warning: missing  before    line 1309 column 1 - Warning: missing  before    line 1310 column 1 - Warning: missing  before    line 1311 column 1 - Warning: missing  before    line 1312 column 1 - Warning: missing  before    line 1313 column 1 - Warning: missing  before    line 1314 column 1 - Warning: missing  before    line 1315 column 1 - Warning: missing  before    line 1316 column 1 - Warning: missing  before    line 1317 column 1 - Warning: missing  before    line 1318 column 1 - Warning: missing  before    line 1319 column 1 - Warning: missing  before    line 1320 column 1 - Warning: missing  before    line 1321 column 1 - Warning: missing  before    line 1322 column 1 - Warning: missing  before    line 1323 column 1 - Warning: missing  before    line 1324 column 1 - Warning: missing  before    line 1325 column 1 - Warning: missing  before    line 1326 column 1 - Warning: missing  before    line 1327 column 1 - Warning: missing  before 

line 1328 column 5 - Warning: inserting implicit line 1329 column 13 - Warning: inserting implicit line 1329 column 13 - Warning: missing before
   line 1370 column 1 - Warning: missing  before    line 1371 column 1 - Warning: missing  before    line 1372 column 1 - Warning: missing  before    line 1373 column 1 - Warning: missing  before    line 1374 column 1 - Warning: missing  before    line 1375 column 1 - Warning: missing  before    line 1376 column 1 - Warning: missing  before    line 1377 column 1 - Warning: missing  before    line 1378 column 1 - Warning: missing  before    line 1379 column 1 - Warning: missing  before    line 1380 column 1 - Warning: missing  before    line 1381 column 1 - Warning: missing  before    line 1382 column 1 - Warning: missing  before    line 1383 column 1 - Warning: missing  before    line 1384 column 1 - Warning: missing  before    line 1385 column 1 - Warning: missing  before    line 1386 column 1 - Warning: missing  before    line 1387 column 1 - Warning: missing  before    line 1388 column 1 - Warning: missing  before    line 1389 column 1 - Warning: missing  before    line 1390 column 1 - Warning: missing  before    line 1391 column 1 - Warning: missing  before    line 1392 column 1 - Warning: missing  before    line 1393 column 1 - Warning: missing  before    line 1394 column 1 - Warning: missing  before    line 1395 column 1 - Warning: missing  before    line 1396 column 1 - Warning: missing  before    line 1397 column 1 - Warning: missing  before    line 1398 column 1 - Warning: missing  before    line 1399 column 1 - Warning: missing  before    line 1400 column 1 - Warning: missing  before    line 1401 column 1 - Warning: missing  before 

line 1402 column 5 - Warning: inserting implicit line 1403 column 13 - Warning: inserting implicit line 1403 column 13 - Warning: missing before
   line 1455 column 1 - Warning: missing  before    line 1456 column 1 - Warning: missing  before    line 1457 column 1 - Warning: missing  before    line 1458 column 1 - Warning: missing  before    line 1459 column 1 - Warning: missing  before    line 1460 column 1 - Warning: missing  before 

line 1461 column 5 - Warning: inserting implicit line 1462 column 13 - Warning: inserting implicit line 1462 column 13 - Warning: missing before
   line 1476 column 1 - Warning: missing  before    line 1477 column 1 - Warning: missing  before    line 1478 column 1 - Warning: missing  before    line 1479 column 1 - Warning: missing  before 

line 1480 column 5 - Warning: inserting implicit line 1481 column 13 - Warning: inserting implicit line 1481 column 13 - Warning: missing before
   line 1501 column 6 - Warning: inserting implicit 

line 1507 column 1 - Warning: missing before line 1508 column 1 - Warning: missing before

line 1509 column 5 - Warning: inserting implicit line 1510 column 13 - Warning: inserting implicit line 1510 column 13 - Warning: missing before
   line 1523 column 1 - Warning: missing  before    line 1524 column 1 - Warning: missing  before    line 1525 column 1 - Warning: missing  before    line 1526 column 1 - Warning: missing  before    line 1527 column 1 - Warning: missing  before    line 1528 column 1 - Warning: missing  before    line 1529 column 1 - Warning: missing  before    line 1530 column 1 - Warning: missing  before    line 1531 column 1 - Warning: missing  before    line 1532 column 1 - Warning: missing  before    line 1533 column 1 - Warning: missing  before 

line 1534 column 5 - Warning: inserting implicit line 1535 column 13 - Warning: inserting implicit line 1535 column 13 - Warning: missing before
   line 1569 column 1 - Warning: missing  before    line 1570 column 1 - Warning: missing  before 

line 1571 column 5 - Warning: inserting implicit line 1572 column 13 - Warning: inserting implicit line 1572 column 13 - Warning: missing before
   line 1589 column 1 - Warning: missing  before    line 1590 column 1 - Warning: missing  before 

line 1591 column 5 - Warning: inserting implicit line 1592 column 13 - Warning: inserting implicit line 1592 column 13 - Warning: missing before
   line 1615 column 1 - Warning: missing  before    line 1616 column 1 - Warning: missing  before    line 1617 column 1 - Warning: missing  before    line 1618 column 1 - Warning: missing  before 

line 1619 column 5 - Warning: inserting implicit line 1620 column 13 - Warning: inserting implicit line 1620 column 13 - Warning: missing before
   line 1635 column 1 - Warning: missing  before    line 1636 column 1 - Warning: missing  before    line 1637 column 1 - Warning: missing  before    line 1638 column 1 - Warning: missing  before    line 1639 column 1 - Warning: missing  before    line 1640 column 1 - Warning: missing  before    line 1641 column 1 - Warning: missing  before    line 1642 column 1 - Warning: missing  before    line 1643 column 1 - Warning: missing  before 

line 1644 column 5 - Warning: inserting implicit line 1645 column 13 - Warning: inserting implicit line 1645 column 13 - Warning: missing before
   line 1666 column 6 - Warning: inserting implicit 

line 1711 column 1 - Warning: missing before line 1712 column 1 - Warning: missing before

line 1713 column 5 - Warning: inserting implicit line 1714 column 13 - Warning: inserting implicit line 1714 column 13 - Warning: missing before
   line 1746 column 1 - Warning: missing  before    line 1747 column 1 - Warning: missing  before    line 1748 column 1 - Warning: missing  before    line 1749 column 1 - Warning: missing  before    line 1750 column 1 - Warning: missing  before    line 1751 column 1 - Warning: missing  before    line 1752 column 1 - Warning: missing  before    line 1753 column 1 - Warning: missing  before    line 1754 column 1 - Warning: missing  before    line 1755 column 1 - Warning: missing  before 

line 1756 column 5 - Warning: inserting implicit line 1757 column 13 - Warning: inserting implicit line 1757 column 13 - Warning: missing before
   line 1805 column 49 - Warning: inserting implicit 

line 1822 column 14 - Warning: inserting implicit

line 1833 column 41 - Warning: discarding unexpected

line 1833 column 45 - Warning: missing
  • line 1835 column 20 - Warning: discarding unexpected

    line 1835 column 24 - Warning: missing
  • line 1838 column 6 - Warning: inserting implicit

    line 1847 column 6 - Warning: inserting implicit

    line 1855 column 1 - Warning: missing before line 1856 column 1 - Warning: missing before line 1857 column 1 - Warning: missing before line 1858 column 1 - Warning: missing before line 1859 column 1 - Warning: missing before line 1860 column 1 - Warning: missing before

    line 1861 column 5 - Warning: inserting implicit line 1862 column 13 - Warning: inserting implicit line 1862 column 13 - Warning: missing before
       line 1890 column 1 - Warning: missing  before    line 1891 column 1 - Warning: missing  before 

    line 1892 column 5 - Warning: inserting implicit line 1893 column 13 - Warning: inserting implicit line 1893 column 13 - Warning: missing before
       line 1916 column 1 - Warning: missing  before    line 1917 column 1 - Warning: missing  before 

    line 1918 column 5 - Warning: inserting implicit line 1919 column 13 - Warning: inserting implicit line 1919 column 13 - Warning: missing before
       line 1937 column 1 - Warning: missing  before    line 1938 column 1 - Warning: missing  before 

    line 1939 column 5 - Warning: inserting implicit line 1940 column 13 - Warning: inserting implicit line 1940 column 13 - Warning: missing before
       line 1958 column 1 - Warning: missing  before    line 1959 column 1 - Warning: missing  before 

    line 1960 column 5 - Warning: inserting implicit line 1961 column 13 - Warning: inserting implicit line 1961 column 13 - Warning: missing before
       line 1981 column 1 - Warning: missing  before    line 1982 column 1 - Warning: missing  before    line 1983 column 1 - Warning: missing  before 

    line 1984 column 5 - Warning: inserting implicit line 1985 column 13 - Warning: inserting implicit line 1985 column 13 - Warning: missing before
       line 2039 column 1 - Warning: missing  before    line 2040 column 1 - Warning: missing  before 

    line 2041 column 5 - Warning: inserting implicit line 2042 column 13 - Warning: inserting implicit line 2042 column 13 - Warning: missing before
       line 2108 column 1 - Warning: missing  before    line 2109 column 1 - Warning: missing  before    line 2110 column 1 - Warning: missing  before 

    line 2111 column 5 - Warning: inserting implicit line 2112 column 13 - Warning: inserting implicit line 2112 column 13 - Warning: missing before
       line 2139 column 1 - Warning: missing  before    line 2140 column 1 - Warning: missing  before    line 2141 column 1 - Warning: missing  before 

    line 2142 column 5 - Warning: inserting implicit line 2143 column 13 - Warning: inserting implicit line 2143 column 13 - Warning: missing before
       line 2157 column 1 - Warning: missing  before    line 2158 column 1 - Warning: missing  before 

    line 2159 column 5 - Warning: inserting implicit line 2160 column 13 - Warning: inserting implicit line 2160 column 13 - Warning: missing before
       line 2183 column 7 - Warning: inserting implicit 

    line 2183 column 39 - Warning: unescaped & or unknown entity "&azResult" line 2193 column 7 - Warning: inserting implicit

    line 2204 column 1 - Warning: missing before line 2205 column 1 - Warning: missing before

    line 2206 column 5 - Warning: inserting implicit line 2207 column 13 - Warning: inserting implicit line 2207 column 13 - Warning: missing before
       line 2235 column 1 - Warning: missing  before    line 2236 column 1 - Warning: missing  before 

    line 2237 column 5 - Warning: inserting implicit line 2238 column 13 - Warning: inserting implicit line 2238 column 13 - Warning: missing before
       line 2257 column 1 - Warning: missing  before    line 2258 column 1 - Warning: missing  before    line 2259 column 1 - Warning: missing  before 

    line 2260 column 5 - Warning: inserting implicit line 2261 column 13 - Warning: inserting implicit line 2261 column 13 - Warning: missing before
       line 2298 column 20 - Warning: inserting implicit 

    line 2302 column 20 - Warning: inserting implicit

    line 2305 column 20 - Warning: inserting implicit

    line 2308 column 20 - Warning: inserting implicit

    line 2317 column 20 - Warning: inserting implicit

    line 2321 column 1 - Warning: missing before line 2322 column 1 - Warning: missing before

    line 2323 column 5 - Warning: inserting implicit line 2324 column 13 - Warning: inserting implicit line 2324 column 13 - Warning: missing before
       line 2352 column 1 - Warning: missing  before    line 2353 column 1 - Warning: missing  before    line 2354 column 1 - Warning: missing  before    line 2355 column 1 - Warning: missing  before 

    line 2356 column 5 - Warning: inserting implicit line 2357 column 13 - Warning: inserting implicit line 2357 column 13 - Warning: missing before
       line 2423 column 6 - Warning: discarding unexpected 

    line 2423 column 10 - Warning: missing
  • line 2435 column 1 - Warning: inserting implicit

    line 2437 column 1 - Warning: missing before line 2438 column 1 - Warning: missing before

    line 2439 column 5 - Warning: inserting implicit line 2440 column 13 - Warning: inserting implicit line 2440 column 13 - Warning: missing before
       line 2457 column 1 - Warning: missing  before    line 2458 column 1 - Warning: missing  before    line 2459 column 1 - Warning: missing  before    line 2460 column 1 - Warning: missing  before    line 2461 column 1 - Warning: missing  before    line 2462 column 1 - Warning: missing  before    line 2463 column 1 - Warning: missing  before    line 2464 column 1 - Warning: missing  before    line 2465 column 1 - Warning: missing  before    line 2466 column 1 - Warning: missing  before    line 2467 column 1 - Warning: missing  before    line 2468 column 1 - Warning: missing  before    line 2469 column 1 - Warning: missing  before    line 2470 column 1 - Warning: missing  before 

    line 2471 column 5 - Warning: inserting implicit line 2472 column 13 - Warning: inserting implicit line 2472 column 13 - Warning: missing before
       line 2506 column 1 - Warning: missing  before    line 2507 column 1 - Warning: missing  before    line 2508 column 1 - Warning: missing  before    line 2509 column 1 - Warning: missing  before    line 2510 column 1 - Warning: missing  before    line 2511 column 1 - Warning: missing  before    line 2512 column 1 - Warning: missing  before    line 2513 column 1 - Warning: missing  before    line 2514 column 1 - Warning: missing  before    line 2515 column 1 - Warning: missing  before    line 2516 column 1 - Warning: missing  before    line 2517 column 1 - Warning: missing  before 

    line 2518 column 5 - Warning: inserting implicit line 2519 column 13 - Warning: inserting implicit line 2519 column 13 - Warning: missing before
       line 4 column 1 - Warning: 

  • as opposed to ). 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:_ {linebreak} Still an issue in v3.2.5 #f2dcdc 448 new active 2003 Sep anonymous 2003 Sep drh 3 3 a general bug-fix and dos support without lfn 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{linebreak} # define macro1(arg){linebreak} # define macro2(arg){linebreak} #endif{linebreak} if (a){linebreak} macro1(1){linebreak} if (b){linebreak} macro2(2){linebreak} if (c){linebreak} return;{linebreak} will be preprocessed to contain:{linebreak} if (a){linebreak} if (b){linebreak} if (c){linebreak} return;{linebreak} which is equivalent to: if (a && b && c){linebreak} return;{linebreak} as i understand, you meant to write: if (a){linebreak} /*do nothing*/{linebreak} if (b){linebreak} /*do nothing*/{linebreak} if (c){linebreak} return;{linebreak} thus, i've changed the code to: #if !HAVE_READLINE{linebreak} # define macro1(arg) *{}* {linebreak} # define macro2(arg) *{}* {linebreak} #endif{linebreak} 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 #cfe8bd 447 event fixed 2003 Sep anonymous 2003 Sep 3 1 Problems compiling on FreeBSD 4.8-STABLE The generic Makefile won't too well seeing as it's not a Linux system. bash-2.05a$ make{linebreak} make: Permission denied I can't really figure out why it says that. I figured it out by pure fluke :) Use: gmake #f2dcdc 446 doc active 2003 Sep anonymous 2003 Sep drh 3 3 sqlite_compile can return no virtual machine with code SQLITE_OK 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 #f2dcdc 442 new active 2003 Sep anonymous 2003 Sep 5 2 [PATCH] sqlite: allow configure --enable-threadsafe 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. #c8c8c8 715 code closed 2004 Apr anonymous Unknown 2004 Apr 2 3 reference counted file locking attempts to unlock on different thread UNIX multi-threaded only bug. os.c:1523: if( id->pLock->cnt>1 ){ id->pLock->cnt--; rc = SQLITE_OK; }else{ In Linux 2.4.20 fcntl() file locks are owned by specific threads. In multi-threaded use cases, due to lock counting, it is possible that a different thread will attempt to unlock from the thread that locked. This results in a leaked file lock. Because this can only happen for read locks, the visible symptom is the database will be readable but forever unwritable until the program is restarted. The leaked lock can be observed in /proc/locks after the condition has occured. Solution: fcntl() Lock/Unlock for each call to: sqliteOsReadLock() sqliteOsWriteLock() sqliteOsUnlock() Fixed 3 months ago with version 2.8.10. Version 2.8.13 is current. See associated check-ins for more information. #f2dcdc 714 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 3 Change sqlite_decode_binary to return buffer size 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. #f2dcdc 712 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 3 Allow temporary databases to be created in specified folder 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. #f2dcdc 711 new active 2004 Apr anonymous 2004 Apr drh 3 3 Provide a callback function to verify values before insert or update 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:_ {linebreak} use triggers #f2dcdc 710 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 4 Provide the ability to pass a user-data value during sqlite_compile 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. #f2dcdc 707 new active 2004 Apr anonymous Unknown 2004 Apr drh 3 3 how to use internal functions? 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. #c8c8c8 706 build closed 2004 Apr anonymous Unknown 2004 Apr 1 1 undefined reference It builds and ar's and ranlib's fine, but no matter what I do I wind up with this: gcc -g -O2 -Wall -I../sqlite -L../sqlite -lsqlite ../sqlite/libsqlite.a -o main main.o main.o: In function `main': /staff/rakaur/test/src/main.c:23: undefined reference to `sqlite_open' /staff/rakaur/test/src/main.c:28: undefined reference to `sqlite_exec' /staff/rakaur/test/src/main.c:32: undefined reference to `sqlite_close' *** Error code 1 Stop in /staff/rakaur/test/src. *** Error code 1 Stop in /staff/rakaur/test. Do this: gcc -g -O2 -Wall -o main.o main.c ../sqlite/sqlite.a User error. No changes to code. ---- _2004-Apr-26 12:39:11 by anonymous:_ {linebreak} I used -L../sqlite -lsqlite -o bin main.o ../sqlite/libsqlite.a That worked fine. #c8c8c8 704 event closed 2004 Apr anonymous 2004 Apr 5 5 .database && .databases In dot commands, there is ".databases". you can use ".database" and expect the same result. I tested it on Windows 2000 computer. Thanks for your work, D. Richard Hipp! _2004-Apr-24 10:20:34 by drh:_ {linebreak} You can use any unique prefix for the "dot" commands of the shell. The full command is ".databases". But you can also use: .da .dat .data .datab .databa .databas .database Be careful with this, though, since new commands might be added to the shell in the future that might make some of these abbreviations ambiguous. #c8c8c8 701 todo closed 2004 Apr anonymous 2004 Apr drh 3 3 INSERT FAILED? CREATE TABLE TEST (ID INT PRIMARY KEY, [NAME] NVARCHAR(100)) INSERT INTO TEST [NAME] VALUES('ABC') SQL logic error or missing database: near "[NAME]": syntax error Am I wrong? _2004-Apr-23 05:56:52 by anonymous:_ {linebreak} oh, there a character return before "INSERT INTO..." ---- _2004-Apr-23 10:46:34 by drh:_ {linebreak} Operator error. Works as designed. #f2dcdc 700 code active 2004 Apr anonymous VDBE 2004 Apr 2 3 Solaris-sparc segfaults on sum() 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:_ {linebreak} 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:_ {linebreak} > 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:_ {linebreak} 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' , "\020\000\000\000\000\000\002¡\230", '\000' }, 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 699 new active 2004 Apr anonymous 2004 Apr 5 4 Data types and implicit conversions 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:_ {linebreak} You can let DBMS check the dates. But a good Front-End should check the date before trying a wrong 'insert' or 'update'. #f2dcdc 698 code active 2004 Apr anonymous Unknown 2004 Apr 1 3 .mode list - not going to next line To create a comma delimited output file:{linebreak} ------------------------------------------------{linebreak} C:\SQLite>sqlite locate.db{linebreak} SQLite version 2.8.13{linebreak} Enter ".help" for instructions{linebreak} sqlite> .mode list{linebreak} sqlite> .separator ", "{linebreak} sqlite> .output data.cdf{linebreak} sqlite> select * from parts;{linebreak} sqlite> .quit{linebreak} {linebreak} That should create a text file of something like this:{linebreak} 1st rec field 1, 1st rec field 2, 1st rec field 3, 1st rec field 4{linebreak} 2nd rec field 1, 2nd rec field 2, 2nd rec field 3, 2nd rec field 4{linebreak} 3rd rec field 1, 3rd rec field 2, 3rd rec field 3, 3rd rec field 4{linebreak} {linebreak} but it does not provide a line break after each record, so the output looks like this:{linebreak} {linebreak} 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{linebreak} {linebreak} 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:{linebreak} {linebreak} http://www.sqlite.org/sqlite.html {linebreak} {linebreak} 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... {linebreak} {linebreak} Thanks,{linebreak} Tom #c8c8c8 694 code closed 2004 Apr anonymous Unknown 2004 Apr 3 4 uninitialised or unaddressable byte(s) in os.c I'm using SQLite from cvs 2004-04-12 with gcc 3.3.1 Linux 2.4.21-199 When i test my code with valgrind i get following error:
      ====================================================================== ==23150== ERROR SUMMARY: 12 errors from 1 contexts (suppressed: 1 from 1) ==23150== ==23150== 12 errors in context 1 of 1: ==23150== Syscall param write(buf) contains uninitialised or unaddressable byte(s) ==23150==    at 0x4039A108: __GI___libc_write (in /lib/i686/libc.so.6) ==23150==    by 0x4024533E: sqliteOsWrite (os.c:1000) ==23150==    by 0x402470AE: pager_write_pagelist (pager.c:1262) ==23150==    by 0x402483E2: sqlitepager_commit (pager.c:2020) ==23150==  Address 0x415E5252 is 142 bytes inside a block of size 1364 alloc'd ==23150==    at 0x4002CEAF: malloc (vg_replace_malloc.c:160) ==23150==    by 0x40254A1C: sqliteMallocRaw (util.c:268) ==23150==    by 0x402471EC: sqlitepager_get (pager.c:1387) ==23150==    by 0x40230BCA: newDatabase (btree.c:840) --23150-- --23150-- supp:    1 __pthread_mutex_unlock/_IO_funlockfile ==23150== ==23150== IN SUMMARY: 12 errors from 1 contexts (suppressed: 1 from 1) ==23150== ==23150== malloc/free: in use at exit: 128 bytes in 2 blocks. ==23150== malloc/free: 1946 allocs, 1944 frees, 447323 bytes allocated. ==23150== ==23150== searching for pointers to 2 not-freed blocks. ==23150== checked 4115340 bytes. ==23150== ==23150== 128 bytes in 2 blocks are still reachable in loss record 1 of 1 ==23150==    at 0x4002CEAF: malloc (vg_replace_malloc.c:160) ==23150==    by 0x402549BD: sqliteMalloc (util.c:254) ==23150==    by 0x40240E15: rehash (hash.c:172) ==23150==    by 0x40241311: sqliteHashInsert (hash.c:344) ==23150== ==23150== LEAK SUMMARY: ==23150==    definitely lost: 0 bytes in 0 blocks. ==23150==    possibly lost:   0 bytes in 0 blocks. ==23150==    still reachable: 128 bytes in 2 blocks. ==23150==         suppressed: 0 bytes in 0 blocks. --23150--     TT/TC: 0 tc sectors discarded. --23150--            5986 chainings, 0 unchainings. --23150-- translate: new     6886 (116999 -> 1604243; ratio 137:10) ====================================================================== 
    Note the the only change i have made to the cvs is:
     -------------------------------------------- RCS file: /sqlite/sqlite/src/os.c,v retrieving revision 1.66 diff -r1.66 os.c 19a20,21 > #define THREADSAFE 1 > -------------------------------------------- 
    so you need to correct the line number in the above os.c error. Is this an error in my code using SQLite or is this a problem in SQLite? The "problem" reported by valgrind above is benign. It is not a real error. #c8c8c8 693 build closed 2004 Apr anonymous 2004 Apr 1 1 Compiling for freeBSD 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. Used this from the package, with 'make' and "gmake": tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make ;# Run the makefile. FreeBSD is not a supported platform, so this is not an appropriate forum for asking these kinds of questions. Please try posting to the sqlite-users mailing list. Instructions are on the SQLite homepage. ------------- I would also add that there is a port available from the FreeBSD ports collection. Google it. -LPS- 20040414 ---- _2004-Apr-26 03:14:18 by anonymous:_ {linebreak} Why is FreeBSD not a "supported platform"? It's far more common/stable/useful/etc than Linux. You say "no dependancies" but fail to mention gmake and libtool.... #cfe8bd 692 code fixed 2004 Apr anonymous Parser 2004 Apr 3 3 lemon.c:void emit_destructor_code() pointer unitialized Code path: void emit_destructor_code(out,sp,lemp,lineno) { char *cp; // unitialized int linecnt = 0; if( sp->type==TERMINAL ){ cp = lemp->tokendest; if( cp==0 ) return; fprintf(out,"#line %d \"%s\"\n{",lemp->tokendestln,lemp->filename); }else if( sp->destructor ){ cp = sp->destructor; fprintf(out,"#line %d \"%s\"\n{",sp->destructorln,lemp->filename); }else if( lemp->vardest ){ cp = lemp->vardest; if( cp==0 ) return; fprintf(out,"#line %d \"%s\"\n{",lemp->vardestln,lemp->filename); } // no else { } block to catch drop-through for(; *cp; cp++){ Notice that the cp variable is never explicitly initialized, and that the else blocks can fall through. As a result, if none of the if/else branches are taken, the for loop will execute with a garbage pointer. I assume that this never happens in practice, but either adding an else () clause, or setting cp initially to NULL would make debugging easier. #f2dcdc 691 code active 2004 Apr anonymous Unknown 2004 Apr drh 1 1 OS X File Sharing 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 #f2dcdc 689 doc active 2004 Apr anonymous 2004 Apr anonymous 4 4 Old Comment for sqlite_decode_binary in sources ? 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 :) #c8c8c8 688 code closed 2004 Apr anonymous 2004 Apr 1 1 Scope problem in subselect Hi, when using the following SQL-SELECT, I receive an SQL error. SELECT A1.IDENTIFIER, A1.FIRSTNAME, (SELECT COUNT(A2.PHONE) FROM CONTACT A2 WHERE A1.IDENTIFIER = A2.FK_PERSON) AS RELCOUNT FROM PERSON A1; ==> SQL error: no such column: A1.IDENTIFIER Both tables (PERSON and CONTACT) have a column named "IDENTIFIER". The SQL succeeds if I use the following SQL-Select: SELECT IDENTIFIER, FIRSTNAME, (SELECT COUNT(A2.PHONE) FROM CONTACT A2 WHERE IDENTIFIER = A2.FK_PERSON) AS RELCOUNT FROM PERSON; ==> but the IDENTIFIER column reference seems not to be unique anymore... Thanks and best regards, Timo SQLite supports static subqueries only. The subquery cannot refer to a value in the outer query. This is a known and documented limitation of SQLite. You can usually accomplish the same thing with a join. For example: SELECT a1.identifier, a1.firstname, sub.cnt FROM person AS a1, (SELECT count(phone) AS cnt, fk_person FROM contact GROUP BY fk_person) AS sub WHERE a1.identifer = sub.fk_person; #f2dcdc 685 code active 2004 Apr anonymous CodeGen 2004 Apr 1 3 SELECT from a VIEW with GROUP BY 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... #f2dcdc 684 code active 2004 Apr anonymous Unknown 2004 Apr 3 2 Incorrect function result type when using SQLITE_ARGS 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". #f2dcdc 682 new active 2004 Apr anonymous 2004 Apr 5 1 sqlite_aggregate_context() valid in xFunc callback routine 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 #c8c8c8 681 build closed 2004 Apr anonymous CodeGen 2004 Apr 1 1 undefined reference to 'sqlite_open' unable to compile any sqlite APIs. ( included sqlite.h ) getting compiler error: undefined reference to 'sqlite_open' Complaintant provides no information about how he is attempting to compile, so nothing can be done to help him correct his problem. No action taken. #f2dcdc 673 new active 2004 Mar anonymous Shell 2004 Apr 4 3 Format .dump nicer (patch) (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. #cfe8bd 665 code fixed 2004 Mar anonymous 2004 Apr 3 3 Lemon.c + OpenWatcom 1.3 Compilation using OW 1.3 using maximum errorlevel ends with errors. 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 break 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); #f2dcdc 169 new active 2002 Oct anonymous Unknown 2004 Apr anonymous 5 5 CE version 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 #c8c8c8 879 new closed 2004 Aug anonymous 2004 Aug 5 3 Makefile should produce GCC compatible import library for DLL as well The Makefile for sqlite should produce an import library for use with the gcc compiler when the 'implib' target is built. I have attached patch files for Makefile.in for both SQLite 2 and SQLite 3 that will add this capability. This will produce an import library, either libsqlitedll.a or libsqlite3dll.a, in the build directory for the project. _2004-Aug-31 22:27:32 by anonymous:_ {linebreak} It turns out that GCC doesn't need an import library to link to a DLL. It can link directly to the DLL. Who knew? (Well actually Doug Currie did...Thanks for the info.) I have marked this ticket closed since this change is obviously not needed. #f2dcdc 878 build active 2004 Aug anonymous Unknown 2004 Aug 5 5 Wrong shared library file-names 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 #cfe8bd 877 todo fixed 2004 Aug anonymous Parser 2004 Aug 4 2 Binary garbage in preprocessed source file 'parse.c' (3.0.5) In the preprocessed file collection, sqlite-source-3_0_5.zip, the file 'parse.c' contains binary garbage (a 0x01 character) in a comment on line 87 (just above '#define YYCODETYPE unsigned char'). Though this doesn't affect compilation, it triggered a message in my Unix-linefeed-to-Dos-linefeed converter. Stylistically, I think it is a bad idea to have nongraphical, nonwhitespace characters in a sourcefile, even if it is in a comment. And it looks like it actually was a bug in the tool that generated parse.c in the first place. The \001 character was deliberate, not a bug. But the need for that character has long since gone away. So the code in lemon that inserts its has been removed. #c8c8c8 876 code closed 2004 Aug anonymous Unknown 2004 Aug 1 3 select from ... where ... or ... is dead slow on indexed column Create a table test with let's say 500000 rows. The table contains an integer column named catid with unique integers and some text column. Create an index on column catid. Now do (assuming that the catid values stated below exist in the table): SELECT catid FROM test where catid=12345 OR catid=23456; This is *dead* slow. It takes in my case 0.5 seconds where the two required values are spit out fast and then it seems the whole table is continued to be parsed. The only workaround is to do multiple select statements for each catid but this is no solution when you need order by. _2004-Aug-29 11:40:36 by drh:_ {linebreak} OR defeats the optimizer and forces a full table scan. Use the IN operator instead: SELECT catid FROM test WHERE catid IN (12345,23456); ---- _2004-Aug-29 15:13:29 by anonymous:_ {linebreak} More testing results in a more detailed example. There isn't even an index required to show the problem. CREATE TABLE test (foo INTEGER PRIMARY KEY,bar TEXT); INSERT INTO test VALUES(1,"1"); INSERT INTO test VALUES(2,"2"); INSERT INTO test VALUES(3,"3"); INSERT INTO test VALUES(4,"4"); INSERT INTO test VALUES(5,"5"); INSERT INTO test VALUES(6,"6"); PRAGMA vdbe_trace=ON; Now execute: SELECT foo FROM TEST WHERE foo=2; This works fine as expected. Then execute; SELECT foo FROM TEST WHERE foo=2 or foo=3; The whole table is parsed, bad. Now we try to limit the amount of results as we know there are only two results: SELECT foo FROM TEST WHERE foo=2 or foo=3 LIMIT 2; Again, the whole table is parsed, bad. The only way to work around the problem I did find is using a value that is definitely *in* the table, add this value as an 'or' case and keep the old limit: SELECT foo FROM TEST WHERE foo=2 or foo=3 or foo=4 LIMIT 2; This works, ouch. Still the table is sequentially processed, bad. If you look at the traces follow closely the MemIncr usage as this seems to be the culprit for the limit not causing query termination. Further fun: In the 'or' case the table is always sequentially parsed even if the value looked up is the primary key or indexed. This is dead slow and a major performance problem. #cfe8bd 875 code fixed 2004 Aug anonymous VDBE 2004 Aug 1 3 Error when INTERSECTing more than two subqueries. Create a simple table: create temporary table test (label); insert into test values ('aaa'); insert into test values ('abb'); insert into test values ('acc'); insert into test values ('abc'); SELECT * FROM test WHERE label LIKE '%a%'; -> returns four rows. SELECT * FROM test WHERE label LIKE '%a%' INTERSECT SELECT * FROM test WHERE label LIKE '%b%'; -> returns two rows SELECT * FROM test WHERE label LIKE '%a%' INTERSECT SELECT * FROM test WHERE label LIKE '%b%' INTERSECT SELECT * FROM test WHERE label LIKE '%c%'; SQL error: database disk image is malformed Thanks! Demitri #c8c8c8 874 code closed 2004 Aug anonymous Parser 2004 Aug 2 3 Inconsistent treatment of quoted strings: "x" vs 'x' I have seen this problem before, but just now decided to try to get rid of it by upgrading to the latest driver (2.8.15). The problem is a difference in treatment of strings quoted with single quotes vs double quotes. E.g. the phrase WHERE FIELD="XXX" will find nothing but WHERE FIELD='XXX' will find several hits. I will attach a screen shot showing the problem. WIN-XP home SP1 Compaq Presario R3150US, P-IV, 512 MB RAM, 40 GB HDD _2004-Aug-28 16:17:35 by drh:_ {linebreak} "MAIN" resolves to a column named MAIN if such a column exists. Otherwise it is treated as a string. 'MAIN' is always a string. This is as intended and as documented. ---- _2004-Aug-28 17:07:29 by anonymous:_ {linebreak} Wow! Yes, it is documented, but in a very obscure place: in the section about keywords. This is not where one would start looking for the meaning of literal-value seen in the syntax productions. I certainly missed it in 3 years of using SQLite! It would be most helpful if the non-terminal "literal-value" were defined in the Expression syntax, at least to make clear the distinction between single and double quotes. If I had come from a SQL background, this distinction may have been pounded into my head early on. Please have pity on us poor unwashed SQL-tyros and document more prominently this important (and not obvious!) difference. -R. #cfe8bd 871 code fixed 2004 Aug dougcurrie TclLib 2004 Aug 3 1 sqlite_temp_directory only defined in os_unix but used in tcl The variable sqlite_temp_directory is defined in os_unix.c and so is not available on builds for other OSs. However, the variable is referenced in test1.c and makes it impossible to build the testfixture on non-unix platforms. Perhaps the defintion of sqlite_temp_directory should be moved to a more central place, or else the use of it should be made OS_UNIX specific. -- e #cfe8bd 870 code fixed 2004 Aug anonymous 2004 Aug 4 4 Segmentation Fault on sqlite3_step if sqlite3_prepare fails The following code will not execute properly if the table named "example" already exists. The error produced is Segmentation Fault. sqlite3_prepare(db, "CREATE TABLE example (id, example)", -1, &statement, NULL); sqlite3_step(statement); // causes a segmentation fault if the example table already exists sqlite3_finalize(statement); The following code will always execute properly: response = sqlite3_prepare(db, "CREATE TABLE example (id, example)", -1, &statement, NULL); if(response == SQLITE_OK) { sqlite3_step(statement); sqlite3_finalize(statement); } #cfe8bd 869 code fixed 2004 Aug anonymous 2004 Aug drh 3 3 SQLite 2.x: CREATE INDEX and dbl-quoted index names This is a reopen of Ticket#695, the following patch against 2.8.15 provides a fix: diff -ur sqlite.orig/src/build.c sqlite/src/build.c --- sqlite.orig/src/build.c 2004-07-20 02:50:12.000000000 +0100 +++ sqlite/src/build.c 2004-08-25 11:05:42.000000000 +0200 @@ -1557,7 +1557,7 @@ sqliteSetString(&zName, "(", pTab->zName, " autoindex ", zBuf, (char*)0); if( zName==0 ) goto exit_create_index; }else{ - zName = sqliteStrNDup(pName->z, pName->n); + zName = sqliteTableNameFromToken(pName); } /* Check for authorization to create an index. #c8c8c8 868 doc closed 2004 Aug anonymous 2004 Aug 1 1 Conflict resolution fails when attempting to create duplicate key In my code, I always try to create an index. I expect the ON CONFLICT clause to make sqlite ignore any errors but it does not. Example sql: BEGIN; CREATE INDEX foo ON foo_table (foo_col) ON CONFLICT IGNORE; COMMIT; The code above will leave SQLite thinking it's in the middle of a transaction. _2004-Aug-25 11:53:19 by anonymous:_ {linebreak} Of course, it's not "duplicate key". I meant duplicate index. ---- _2004-Aug-25 12:41:52 by drh:_ {linebreak} ON CONFLICT IGNORE causes INSERTs or UPDATEs that cause constraint conflicts to be silently ignored. This is well documented. #c8c8c8 866 code closed 2004 Aug anonymous 2004 Aug 2 3 Breakage when repeatedly creating tables in an attached database
     21:40:44 mag@gaia:~/.imms $ rm -f test.db cluster.db 21:41:11 mag@gaia:~/.imms $ cat sql ATTACH "cluster.db" AS Cluster; CREATE TABLE 'Cluster.Distances' ('x' INTEGER NOT NULL, 'y' INTEGER NOT NULL, 'distance' INTEGER NOT NULL); DETACH Cluster; 21:41:14 mag@gaia:~/.imms $ sqlite3 test.db '.read sql' 21:41:17 mag@gaia:~/.imms $ sqlite3 test.db '.read sql' CREATE TABLE 'Cluster.Distances' ('x' INTEGER NOT NULL, 'y' INTEGER NOT NULL, 'distance' INTEGER NOT NULL); SQL error: table 'Cluster.Distances' already exists 21:41:18 mag@gaia:~/.imms $ sqlite3 test.db 'select * from sqlite_master;' | grep Distances table|Cluster.Distances|Cluster.Distances|2|CREATE TABLE 'Cluster.Distances' ('x' INTEGER NOT NULL, 'y' INTEGER NOT NULL, 'distance' INTEGER NOT NULL) 21:41:21 mag@gaia:~/.imms $ sqlite3 test.db 'DROP TABLE Cluster.Distances;' SQL error: no such table: Cluster.Distances 
    Thanks,{linebreak} Michael Grigoriev _2004-Aug-25 11:05:50 by drh:_ {linebreak} You have a quoting error. 'Cluster.Distances' is the name of a table in the main database. It is the same as main.'Cluster.Distances'. Cluster.Distances is a table named Distances in the Cluster database. Works as designed. #f2dcdc 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 SQLite is configured with: CFLAGS="-DNDEBUG=1" CXXFLAGS="-DNDEBUG=1" ./configure --enable-threadsafe --prefix=/usr ------------------8<------------------ .{linebreak} .{linebreak} .{linebreak} {linebreak} ./.libs/libsqlite3.so: undefined reference to `pthread_create'{linebreak} ./.libs/libsqlite3.so: undefined reference to `pthread_join'{linebreak} collect2: ld returned 1 exit status{linebreak} make: *** [sqlite3] Error 1{linebreak} fel: Dålig slutstatus från /var/tmp/rpm-tmp.33961 (%build){linebreak} {linebreak} {linebreak} RPM-byggfel:{linebreak} Dålig slutstatus från /var/tmp/rpm-tmp.33961 (%build){linebreak} ------------------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:_ {linebreak} You can use the environment variable config_TARGET_LIBS to add any libraries you need to the link. See configure.ac. -- e #f2dcdc 864 build active 2004 Aug anonymous Unknown 2004 Aug 2 2 3.0.4 uses readling 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:_ {linebreak} 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. #cfe8bd 862 code fixed 2004 Aug anonymous VDBE 2004 Aug 2 2 Memory is being freed twice when performing VACUUM on corrupted DB We have found that in some cases memory there's ACCESS VIOLATION error when performing VACUUM on a corrupted database. We have investigated this problem and found that memory is being freed twice when performing VACUUM on corrupted database. The problem is in the following function: sqliteVdbeExec while processing OP_Column. It reserves memory in stack (pTos++;), and after that, because of error due to corrupt databases, it exits OP_Column. As long as previous memory release (macros Release) does not reset MEM_DYN flag, later in SQLFinalize tries to free this memory. Depending on MEM_DYN was set before it happens, it easier works correctly or crashes with ACCESS VIOLATION. We suggest to fix it by reseting flags during release: #define Release(P) if((P)->flags&MEM_Dyn){ sqliteFree((P)->z); P->flags = 0; } _2004-Aug-19 17:57:27 by anonymous:_ {linebreak} We just found out that the same problem present while executing any SELECT operation on a corrupted database, not just VACUUM. #cfe8bd 859 doc fixed 2004 Aug anonymous 2004 Aug 5 4 typo in comment In line 507 of date.c please change "occurrance" to "occurrence". Yes, I know, that's not a serious bug :-) _2004-Aug-17 10:43:42 by drh:_ {linebreak} Fixed. Thanks. I'm sure you'll find many more such errors in the comments if you keep reading.... :-) #c8c8c8 858 code closed 2004 Aug anonymous Unknown 2004 Aug 2 3 core dump when peforming bind The following code creates a simple database and tries to insert a row into the table. When the code is compiled and run, it core dumps inside the sqlite3_bind_double() statement. If the source is changed to not use the bind, there is no coredump and the row is successfully added to the table. ---------------------------------------------------------------------- #include #include #include "sqlite3.h" sqlite3 *db; sqlite3_stmt *pStmt; const char *tail; int main(int argc, char **argv) { sqlite3_open("test.db", &db); sqlite3_prepare(db, "CREATE TABLE t1(a1 FLOAT, a2 FLOAT);", -1, &pStmt, &tail); sqlite3_step(pStmt); sqlite3_finalize(pStmt); sqlite3_prepare(db, "INSERT INTO t1 VALUES(?, 2.5);", -1, &pStmt, &tail); sqlite3_bind_double(pStmt, 1, 5.5); sqlite3_step(pStmt); sqlite3_finalize(pStmt); sqlite3_close(db); exit(0); } _2004-Aug-16 19:10:12 by drh:_ {linebreak} When I compile and run the sample code on Linux (RH 7.2, gcc 2.96) it works fine. Can you provide additional information about your compilation and execution environment so that we can try to reproduce the problem? ---- _2004-Aug-16 19:22:28 by anonymous:_ {linebreak} OS: Solaris 8 Compiler: g++ 3.2.3 ---- _2004-Aug-16 19:27:42 by anonymous:_ {linebreak} Here is how it is being compiled: g++ -o bind.o -c -I/home/wvk/sqlite/3.0.4/sun4v/bld bind.c g++ -o ./bindbug ./bind.o /home/wvk/sqlite/3.0.4/sun4v/bld/.libs/libsqlite3.a ---- _2004-Aug-16 21:20:55 by anonymous:_ {linebreak} I suspect this may be a compile issue with gcc on Solaris. I just rebuilt everything (sqlite3 and bind.c) with the Sun native compiler and the problem went away. Previously, sqlite3 was built with gcc (this is what the configure script selected by default). This is good enough for me (actually, I would prefer to use the native compiler), so we can mark this as fixed unless you are interested in pursuing this further. #cfe8bd 857 event fixed 2004 Aug anonymous 2004 Aug 1 1 Unable to download 3.0.4 precompiled binaries for Linux. http://www.sqlite.org/sqlite3-3.0.4.bin.gz Unable to download. #c8c8c8 856 code closed 2004 Aug anonymous 2004 Aug 1 1 memory leak within sqlite3_open()/sqlite3_close() pair I use SQLite 3.0.4 and I have found that there is memory leak in pair sqlite3_open()/sqlite3_close() functions. The sample program is following: ------------------------------- #include #include int main(int argc, char **argv) { sqlite3 *p_db; int rc; rc = sqlite3_open("./db", &p_db); /* Open the database. */ if (rc != SQLITE_OK) { printf("Could not open database."); exit(1); } /* Close the database. */ sqlite3_close(p_db); return 0; } ------------------------------- If build this sample on Linux/x86 and run under Valgrind using the following command line (I have used 2.1.0 version of the Valgrind): valgrind -q --leak-check=yes --num-callers=12 --show-reachable=yes ./a.out then the Valgrind reports 2 memory leaks (memory allocated in sqlite3_open() has not been freed in sqlite3_close()), Valgrind's error log is following: 128 bytes in 2 blocks are still reachable in loss record 1 of 1{linebreak} at 0x4002582D: malloc (vg_replace_malloc.c:160){linebreak} by 0x4024A4C1: sqlite3Malloc (src/util.c:280){linebreak} by 0x4023639C: rehash (src/hash.c:174){linebreak} by 0x4023677B: sqlite3HashInsert (src/hash.c:337){linebreak} by 0x40239E43: findLockInfo (src/os_unix.c:361){linebreak} by 0x40239F07: sqlite3OsOpenReadWrite (src/os_unix.c:450){linebreak} by 0x4023C570: sqlite3pager_open (src/pager.c:1434){linebreak} by 0x40228598: sqlite3BtreeOpen (src/btree.c:1015){linebreak} by 0x402390E4: sqlite3BtreeFactory (src/main.c:848){linebreak} by 0x4023990F: openDatabase (src/main.c:1160){linebreak} by 0x804859C: main (in /home/vnv/sqlite_bugs/a.out){linebreak} _2004-Aug-16 09:16:26 by anonymous:_ Is it correct: sqlite3 *p_db; int rc; rc = sqlite3_open("./db", &p_db); /* Open the database. */ ^^^^^^ address of pointer ---- _2004-Aug-16 12:48:18 by drh:_ {linebreak} This is *not* a memory leak. SQLite has allocated memory that it will reuse the next time sqlite3_open() is called. #c8c8c8 854 code closed 2004 Aug anonymous Unknown 2004 Aug anonymous 3 1 Index don't work with NULL field I have a 100 MB database and a table which contains 160000 entries. Two fields can contain NULL values. I have create an index on these fields. select count(*) from EXPORTED_FILES where version_name = '6.4'; give the answer immediately but select count(*) from EXPORTED_FILES where version_name is NULL; is as long as select count(*) from EXPORTED_FILES; (1 minute because the database is mount on NFS). _2004-Aug-12 12:08:37 by drh:_ {linebreak} The first query is able to use an index whereas the second query has to do a full table scan. So it is expected that the second query would take longer. #f2dcdc 853 doc active 2004 Aug anonymous Parser 2004 Aug 4 3 syntax of DEFAULT in a CREATE TABLE statement not as documented 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 #f2dcdc 852 doc active 2004 Aug anonymous 2004 Aug 5 4 Typos found in the Syntax documentation 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.{linebreak} ps. SQLite is AWESOME! #f2dcdc 851 doc active 2004 Aug anonymous Parser 2004 Aug 5 2 SQLite allows Zero length table column names 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:_ {linebreak}
     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:_ {linebreak} we can say sqlite allows zero length table & column name. #c8c8c8 850 code closed 2004 Aug anonymous 2004 Aug 1 1 quoted table names not allowed in combination with * select "my table".* from "my table" does not work, while select "my table"."my field" from "my table" does. Reason: when the asterics is handled, the quotes are handled as part of the table name (thus the table will not be found), for single fields the quotes of the table name will be correctly ignored _2004-Aug-09 21:48:53 by drh:_ {linebreak} This is a duplication of ticket #756, which has already been fixed. #c8c8c8 846 code closed 2004 Aug anonymous Parser 2004 Aug 1 1 error(1) at dbdimp.c line 250 [for Statement "PRAGMA table_info(?)"] In the 2.x series, using placeholders with table_info pragma is perfectly legal, while in this version it is not. Whats up with that? dbdimp.c is not a source file in SQLite. I do not believe that wildcards have ever worked inside the table_info() pragma. If they did, it was an accident. ---- _2004-Aug-08 21:11:14 by anonymous:_ {linebreak} >dbdimp.c is not a source file in SQLite. Sorry, dbdimp.c is irrelevant (my bad for revealing that). sqlite3_prepare is generating the error message. is this still by design? how come? #f2dcdc 845 new active 2004 Aug anonymous 2004 Aug 5 4 Support shared-memory databases 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. #cfe8bd 844 code fixed 2004 Aug anonymous VDBE 2004 Aug 1 1 AFTER DELETE trigger has erroneous values in old.X "variables"! CREATE TEMP TABLE Item( a integer PRIMARY KEY NOT NULL , b double NULL , c int NOT NULL DEFAULT 0 ); CREATE TEMP TABLE Undo(UndoAction TEXT); INSERT INTO Item VALUES (1,38205.60865,340); CREATE TEMP TRIGGER trigItem_UNDO_AD AFTER DELETE ON Item FOR EACH ROW BEGIN INSERT INTO Undo SELECT 'INSERT INTO Item (a,b,c) VALUES (' || coalesce(old.a,'NULL') || ',' || quote(old.b) || ',' || old.c || ');'; END; DELETE FROM Item WHERE a = 1; SELECT * FROM Undo; result: INSERT INTO Item (a,b,c) VALUES (1, 38205.60865, 38205.60865); ^^^^^^^^^^^ should be 340 !! -- NOTICE THAT Undo.c contains the same value as Undo.b!!!! This is a major problem... #f2dcdc 843 new active 2004 Aug anonymous Unknown 2004 Aug 3 3 Introducing I64 printf size prefix 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....) #cfe8bd 842 code fixed 2004 Aug anonymous 2004 Aug 2 2 Ignoring an error return from sqlite3_exec causes invalid db. While debugging my sqlite3 support, I managed to repeatably corrupt my database. Here is C code reproducing the problem: sqlite3 * db; int err; #define DOIT(x) { err = (x); cout << #x << " returned " << err << endl; } #define DOEXEC(sql) DOIT(sqlite3_exec(db, sql, 0, 0, 0)) DOIT(sqlite3_open("bad.db", &db)); DOEXEC("create table q (s string, id string, constraint pk_q primary key (id));"); DOEXEC("begin;"); DOEXEC("insert into q (s, id) values ('hello', 'id.1');"); DOEXEC("insert into q (s, id) values ('goodbye', 'id.2');"); DOEXEC("insert into q (s, id) values ('again', 'id.3');"); DOEXEC("end;"); sqlite3_stmt * stmt1; DOIT(sqlite3_prepare(db, "select s, id from q", -1, &stmt1, NULL)); DOIT(sqlite3_step(stmt1)); sqlite3_stmt * stmt2; DOIT(sqlite3_prepare(db, "select rowid, s, id from q where id = 'id.1'", -1, &stmt2, NULL)); DOIT(sqlite3_step(stmt2)); DOIT(sqlite3_finalize(stmt2)); DOEXEC("delete from q where rowid = 1;"); DOIT(sqlite3_finalize(stmt1)); DOEXEC("commit;"); DOIT(sqlite3_close(db)); The delete returns SQLITE_LOCKED, and the commit returns SQLITE_ERROR, all of which I would expect. But the database is left in an invalid state. A row is in the table, but not in the index: sqlite> select * from q; hello|id.1 goodbye|id.2 again|id.3 sqlite> select count(*) from q; 3 sqlite> select count(*) from q where id = 'id.1'; 0 sqlite> pragma integrity_check; rowid 1 missing from index sqlite_autoindex_q_1 wrong # of entries in index sqlite_autoindex_q_1 sqlite> I understand that I shouldn't try to delete a row while a statement is still in the table, but I didn't think I could corrupt the database. --Ned. #f2dcdc 841 code active 2004 Aug anonymous Unknown 2004 Aug 3 2 inner group by query isn't honored by outer count(*) aggregate 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:_ {linebreak} SQLite ignores the ORDER BY clause if there are no aggregate functions. #cfe8bd 839 code fixed 2004 Aug anonymous 2004 Aug 2 2 'int isdigit(int)' causes a crash when inserting a string into a table which contains characters using more than 7 bits, the microsoft C lib throws an assertion and reads from an array of 256 elements at index 2^32+(char)c, which can cause a crash. i fixed this problem, wrote a function sqlite3_isdigit and replaced it all over the code, but it is not a proper solution for every new release of sqlite. _2004-Aug-05 16:09:04 by anonymous:_ {linebreak} I encountered this problem as well. The solution is to compile the code with "char" defined as "unsigned char". For Visual Studio, you need the /J switch to the C compiler. ---- _2004-Aug-05 16:09:23 by anonymous:_ {linebreak} I meant to sign the last remark. --Ned Batchelder. #cfe8bd 838 new fixed 2004 Aug anonymous 2004 Aug 4 2 Change os_common.h to allow SQLITE_DEBUG on Windows. Building with SQLITE_DEBUG doesn't work under Visual Studio .NET because of the assembly code for performance tracking. I moved them into a different define so I could enable the debug and performace stuff separately, as we discussed. #c8c8c8 836 code closed 2004 Aug anonymous 2004 Aug 1 1 sqlite3_prepare() fails when a temp table does not yet exists. can not compile sql statement "SELECT uid FROM ? WHERE ROWID = 1;" fails with error message, near \"?\": syntax error. Error code SQLITE_ERROR. This is because the table does not yet exists because it is temporary table yet created. It would be nice if this check was delayed until sqlite3_bind_text() or sqlite3_step() is called. I am working around this problem by creating a placeholder. The "?" wildcard only works in places where it is valid to put a string literal or numeric constant. The FROM clause is not such a place. #c8c8c8 835 doc closed 2004 Jul anonymous Unknown 2004 Aug 4 4 Locks reference on the FAQ - Read while writing? I am a begginer user. Forgive me if this is a stupid bug report. http://www.sqlite.org/faq.html#q7 reads: "Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. But only one process can be making changes to the database at once." In a recent experiment with the Perl module for SQLite, I found that when one process is writing a table (database?), another process cannot even read it. A user in #perl at freenode confirmed that. Is it what's SQLite supposed to handle it? If so, the aforementioned text should maybe read: "Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. *But no other process can read or write if there is another one changing the database.*" Please forgive me if this is bogus. You are forgiven. #cfe8bd 834 code fixed 2004 Jul anonymous Unknown 2004 Aug 4 3 No equivalent to sqlite_libversion() API call in SQLite3 SQLite 2.8.x API had sqlite_libversion() API call which enabled access to the SQLite version, particularly from the Windows DLL. SQlite 3.0.3 API does not have an equivalent, so it is not possible AFAIK to gain access to the version number of the complied library. Can a sqlite3_libversion() API call be added? #cfe8bd 826 code fixed 2004 Jul drh CodeGen 2004 Aug drh 1 1 Nested views do not process * correctly. Consider the following code: 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; CREATE VIEW tv1b AS SELECT x.id, tx.id FROM x JOIN tempx tx on tx.id=x.id; CREATE VIEW tv2 AS SELECT * FROM tv1 UNION SELECT * FROM tv1b; SELECT * FROM tv2; The final SELECT fails with a "corrupt database" error. The database is not really corrupt. What is happening is that the outer view (tv2) thinks that the result set of the inner view (the union of tv1 and tv1b) has only a single column, when in fact the inner view has two columns. It appears that the "*" is not being processed early enough. A temporary work-around is to explicitly name all columns on nested views instead of using "*". #cfe8bd 786 code fixed 2004 Jun anonymous BTree 2004 Aug drh 1 1 sqlite3 change SQLITE_PAGE_SIZE to 4096 causes assert sqlite3 change SQLITE_PAGE_SIZE to 4096 causes assert _2004-Jul-01 17:46:50 by anonymous:_ {linebreak} I think there are some places where 1024 instead of the macro is used. Change it seems to correct the problem. _2004-Aug-28 by drh:_ {linebreak} Should have been fixed when SQLITE_PAGE_SIZE was removed. #c8c8c8 775 code closed 2004 Jun anonymous Unknown 2004 Aug 1 1 windows sqlite3.dll corrupt? Thank you for changing the name to sqlite3.dll. However, I was not able to load the dll into my components. An attempt to use tdump (a utility to extract exported procedures etc) failed too, so I think that the dll might be corrupted. Can you check? Albert Drent #cfe8bd 774 code fixed 2004 Jun anonymous Unknown 2004 Aug 1 1 sqlite3_exec not exported in windows sqlite.dll I was trying to convert my Delphi components from version 2 to 3. Loading the Windows sqlite.dll I was not able to bind to sqlite3_exec. I know that using prepare and step is the prefered method now, but the sqlite3_exec is still documented. I would like to be able to create my components as flexible as possible, allowing to support both version 2 and 3. However, the dll names are the same. Of course I can rename one of them, but isn't it an idea to rename the sqlite.dll to sqlite3.dll by standard? Best regards, Albert Drent #c8c8c8 733 code closed 2004 May anonymous 2004 Aug anonymous 3 3 About Ticket #731 It seems that Dr. drh misunderstood Ticket #731 the result is foo|bar |baz|frob 1 |fred| |bill 2 |fred| | it shouldn't be because baz is unique. but when we create table with each unique column it is ok. (for example : create table test2 ( foo integer primary key, bar text unique, baz text unique, frob text); ) so Ticket #731 is about the problem that unique() command has. _2004-May-17 11:44:11 by anonymous:_ {linebreak} This is the difference between a compound unique and a individual unique. nothing to be fixed. should be closed. #cfe8bd 249 code fixed 2003 Feb anonymous Unknown 2004 Aug drh 1 1 install OS: windows 2000 It seems like there is a serious memory leak when you create a table with a primary key. This bug is only been tested on a windows 2000 machine, so I am not sure if another OS has the same problem. How to reproduce : sqlite *m_sqliteObj =0; char* errorMessage = 0; int resultCode = 0; char *errmsg =0; m_sqliteObj = sqlite_open("c:\\temp\\testdb.db", 0, &errorMessage); if(errorMessage != 0){ sqlite_freemem(errorMessage); return 1; } for (int x =0; x<1000; x++){ cout << x << endl; Sleep(2) // windows, sleep in milliseconds; resultCode = sqlite_exec(m_sqliteObj,"CREATE TABLE TEST(a integer, primary key(a));",NULL,NULL,&errmsg); if(resultCode !=0 ){ if(errmsg != 0)sqlite_freemem(errmsg); return 1; } resultCode = sqlite_exec(m_sqliteObj,"DROP TABLE TEST;",NULL,NULL,&errmsg); if(resultCode !=0 ){ if(errmsg != 0)sqlite_freemem(errmsg); return 1; } } sqlite_close(m_sqliteObj); return 0; Note: When [primary key(a)] is removed, no leak occurs. Every insert into a table with a primary key defined has also a memory leak. The leak only occurs if the following is true. *: The PRIMARY KEY is specified as a separate clause in the CREATE TABLE statement - not as a modifier to a the datatype of a column. *: The CREATE TABLE statement must fail or the PRIMARY KEY is a single column of type INTEGER. I have been unable reproduce any memory leaks associated with inserts. #f2dcdc 1056 code active 2004 Dec anonymous Shell 2004 Dec 3 3 test pragma-9.4 fails during second pass in "make fulltest" 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 #f2dcdc 1053 code active 2004 Dec anonymous Pager 2004 Dec 3 3 SQLITE_IOERR and strange rollback when db is busy Environment on which bug was found:{linebreak} 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_ .{linebreak} 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. #cfe8bd 1051 code fixed 2004 Dec anonymous Unknown 2004 Dec 2 2 pragma.c code breaks build when SQLITE_DEBUG #defined, fix included A 20 December check-in to src/pragma.c added code which calls sqlite3Malloc. This breaks the build when SQLITE_DEBUG is #defined. The correct call is sqliteMalloc. Here is a patch containing a fix: --- pragma.c.orig Mon Dec 20 14:01:33 2004 +++ pragma.c Thu Dec 23 23:19:56 2004 @@ -389,14 +389,14 @@ if( sqlite3_temp_directory ){ if( strlen(sqlite3_temp_directory) < strlen(zRight) + 1){ sqlite3FreeX(sqlite3_temp_directory); - sqlite3_temp_directory = sqlite3Malloc( strlen(zRight) + 1 ); + sqlite3_temp_directory = sqliteMalloc( strlen(zRight) + 1 ); if( sqlite3_temp_directory==0 ){ goto pragma_out; } sqlite3_temp_directory[0] = '\0'; } }else{ - sqlite3_temp_directory = sqlite3Malloc( strlen(zRight) + 1 ); + sqlite3_temp_directory = sqliteMalloc( strlen(zRight) + 1 ); if( sqlite3_temp_directory==0 ){ goto pragma_out; } It seems likely that the occurrences of sqlite3FreeX in pragma.c should also be replaced by sqliteFree calls. #c8c8c8 1050 doc closed 2004 Dec anonymous 2004 Dec 4 4 Correct front page information - SQLite is not ACID Hi there, You claim on the front page of your site; "Transactions are atomic, consistent, isolated, and durable (ACID) even after system crashes and power failures." However, SQLite does not isolate updates from other operations (that is, reading must stop), so it cannot satisfy the I in ACID. You'd need to implement some kind of consistent read and rollback mechanism to be able to truly claim transaction isolation, which would be a year's project to implement and probably a decade of debugging to get right. Please clarify to something like: "Of the four required transaction processing features of being atomic, consistent, isolated and durable (ACID), SQLite satisfies all but transaction isolation (writing locks the entire database) - even after system crashes and power failures. This is an excellent compromise for many applications, as implementing true transaction isolation is one of the stickiest problems of writing a DBMS. Instead, SQLite focuses on making the other features work well." Sam. _2004-Dec-24 03:35:07 by drh:_ {linebreak} If I interpret the complaint correctly, what Sam is saying is that in SQL code like the following: BEGIN; UPDATE table1 SET x=x+1; SELECT x FROM table1; COMMIT; The SELECT statement sees the new values of table1.x in SQLite whereas in a truely "ACID" database, the table1.x values should not really change until the COMMIT and so the SELECT statement should see the old values of table1.x, not the new values. (Do I understand you correctly Sam?) With SQLite, all threads/processes other than the one thread/process that is making the change do not see the new values of table1.x until the commit occurs. The one thread/process that is making the changes sees all changes immediately, before the commit occurs. I do not know what an SQL database engine should do "really". But I'd be very surprised to learn that other SQL database engines operate differently than SQLite in this regard. Readers are welcomed to enlighten me if I am wrong. So, pending additional information, I will continue to say that SQLite is ACID. ---- _2004-Dec-24 07:37:44 by anonymous:_ {linebreak} "With SQLite, all threads/processes other than the one thread/process that is making the change do not see the new values of table1.x until the commit occurs. The one thread/process that is making the changes sees all changes immediately, before the commit occurs." MS SQLServer behaves exactly like this, besides its logical, makes sense. Mayowa. ---- _2004-Dec-24 08:20:12 by anonymous:_ {linebreak} I based my comment on this behaviour as described in your FAQ (and as I was able to verify using the Perl bindings): http://www.sqlite.org/faq.html#q7 I can see that the situation is not quite as bad as I originally thought; you have correctly described the property of "consistent read", which is one requirement of transaction isolation. If you have that, then that is a very large step towards full blown transaction isolation. To complete ACID support you need to do a little more than this; in a nutshell, it should still work if all threads are writers. Probably the biggest payoff in terms of functionality vs. implementation effort is to not allow threads to commit, if any data that they have selected since they started their transaction has since been altered by a committed transaction. You can still serialise the "commit" phase (ie, avoid having to go to the lengths of finely grained locking necessary to break through to high performance in such scenarios), in effect threads would only lock the database for writing when they are committing their changes. That is something of an oversimplification, as the above (to the extent of my admittedly very limited knowledge) should be roughly enough to get you to the "repeatable read" SQL isolation level. The PostgreSQL documentation has a very good section describing this: http://www.postgresql.org/docs/7.4/interactive/transaction-iso.html Until two threads that claim to be writers can open a sqlite database at the same time, you cannot claim any isolation at all. If two threads can, but they will see each other's commits before they occur, then at least you have the "read uncommitted" transaction isolation level. Which would be a start. I would like to have the opportunity to take up this conversation in a constructive manner; do you have a developer's mailing list, or should I write to the users list? ---- _2004-Dec-24 13:10:58 by drh:_ {linebreak} All transactions in SQLite are serializable. ---- _2004-Dec-26 06:27:21 by anonymous:_ {linebreak} Your reply is fairly terse and irrelevant so I assume that you don't understand what I am getting at. Just bear in mind that stating something so blatantly incorrect, which you have admitted to not understanding, on the front page of your site does not look very good those who do know what it means. Not being ACID makes the library insuitable to a range of uses (which almost certainly also complement the extra great applications that SQLite has). For instance, it is worth considering that the other popular relational library suite - ISAM - was never made ACID (this includes MyISAM and C-ISAM). Please, I advise you to revise your claim of being ACID with a clause that qualifies such support does not extend to concurrent writers. Or add support for concurrent writers, then really grok what this whole "transaction isolation level" thing is about so that you can truthfully claim ACID compliance. ---- _2005-Mar-30 03:31:31 by anonymous:_ {linebreak} SQLite does not allow concurrect writes - it implements a true honest transaction serialization, so it satisfies all the requirements for being ACID. ACID does not require concurrent writes. On the contrary: the highest possible transaction isolation level is TRANSACTION_SERIALIZABLE which implies an implementation which behavies as if transactions are serialized, which in ths case they actually are. SQLite is not supposed to scale to many simultaneous writers and it doesn't claim to, but it offers _complete_ correctness with a moderate performance penalty if transactions are kept short. #cfe8bd 1046 code fixed 2004 Dec anonymous 2004 Dec 2 3 checkin 2170 breaks SQLite An sqlite3.exe shell built from CVS source after checkin 2170 will crash while executing the following query on the attached database file: SELECT * FROM Device_Property_List WHERE device_id = 1; This is actually a complex query using a view to join multiple tables. It seems to trigger a problem in the newly optimized compiler. A shell built from CVS source prior to this checkin works correctly. #c8c8c8 1045 event closed 2004 Dec anonymous 2004 Dec 1 5 MAJOR Problem with accessing databases I am facing very strange problem with sqlite programming interface. I have written a C++ application that opens a database and does some operations. It works fine on my system (Linux 8.0). When I log on to some other machine it opens the database without any error but fails to accept any other command with error "Sql Error: database is locked" I have built sqlite using --enable-threadsafe. Also, my home is on my machine and the system is NFS. The problem happens on any other machine. _2004-Dec-20 15:18:14 by drh:_ {linebreak} Posix advisory locking is broken on many (most?) NFS systems. You are advised not to access an SQLite database on an NFS filesystem. Even if it does work, the database runs the risk of being corrupted. This is a problem with NFS, not with SQLite. #c8c8c8 1044 code closed 2004 Dec anonymous 2004 Dec 3 3 Insert an integer as a string Consider the following code: CREATE TABLE plip (plop INT); INSERT INTO plip VALUES (12); INSERT INTO plip VALUES ('42'); INSERT INTO plip VALUES (' 92'); SELECT * FROM plip; --------- 12 42 92 --------- SELECT * FROM plip WHERE plop=12 --------- 12 --------- SELECT * FROM plip WHERE plop=42 --------- 42 --------- SELECT * FROM plip WHERE plop=92 --------- --------- SELECT sum(plop) FROM plip; --------- 54 --------- I expect the last SELECT to work, and the sum to return 12+42+92 rather than 12+42. Why SQLite do not cast the INT since the field plop is defined as an integer ? I think the third INSERT should be casted as an integer, or should not be inserted, but not a mix of those solutions as it is currently (because the first "SELECT *" works, but WHERE clause doesn't). I know I should not insert an integer with a string, it was an error. But I consider this as a bug, this is not the expected behaviour when you define a field as an INT. _2004-Dec-20 14:14:46 by drh:_ {linebreak} This is a deliberate feature, not a bug. See http://www.sqlite.org/datatypes.html and http://www.sqlite.org/datatype3.html. #f2dcdc 1043 doc active 2004 Dec anonymous 2004 Dec 3 3 SQLITE3_ANY does not exist 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_. #c8c8c8 1042 code closed 2004 Dec anonymous Unknown 2004 Dec 1 2 where does not work SQLite version 3.0.8 Enter ".help" for instructions sqlite> select a from tt where (a>2); select a from tt where (a>2); a ---------- 1 4 4 4 4 4 4 4 sqlite> select a from tt where a>2; select a from tt where a>2; a ---------- 1 4 4 4 4 4 4 4 _2004-Dec-19 12:22:59 by drh:_ {linebreak} Once again, column TT.A is a TEXT or BLOB not an INTEGER. Please read http://www.sqlite.org/datatype3.html #c8c8c8 1041 code closed 2004 Dec anonymous Unknown 2004 Dec 1 1 select x<2 from table does not work anymore I found no documentation of this change. Is it user error, documentation bug, or bug?
     select * from t2; a           b          ----------  ---------- 1           4          2           5          3           6           .show      echo: on   explain: off   headers: on      mode: column nullvalue: ""    output: stdout separator: "\t"     width:  SQLite version 3.0.8 Enter ".help" for instructions sqlite> select a>=2 from t2; select a>=2 from t2; a>=2       ---------- 1          1          1          sqlite> select a=2 from t2; select a=2 from t2; a=2        ---------- 0          0          0          sqlite>   0 19-Sun-03-28-51 ~# db ver sqlite ti select * from t2; a           b          ----------  ---------- 1           4          2           5          3           6           .show      echo: on   explain: off   headers: on      mode: column nullvalue:     output: stdout separator:       width:   SQLite version 2.8.15 Enter ".help" for instructions sqlite> select a>=2 from t2; select a>=2 from t2; a>=2       ---------- 0          1          1          sqlite> select a=2 from t2; select a=2 from t2; a=2        ---------- 0          1          0          sqlite> 
    _2004-Dec-19 12:20:43 by drh:_ {linebreak} If you do SELECT typeof(a) FROM t2; I believe you will find that the T2.A column values are all TEXT or BLOB instead of INTEGER. Such would cause the behavior you observer. The following works: create table t2(a,b); insert into t2 values(1,4); insert into t2 values(2,5); insert into t2 values(3,6); .header on .mode column select * from t2; select a>=2 from t2; select a=2 from t2; #c8c8c8 1038 code closed 2004 Dec anonymous 2004 Dec 2 2 multi-word type names confuse pragma table_info If I create a table and use multi-word types, the type reported by pragma table_info is mangled: sqlite> create table one (i integer shorter, j int longish); sqlite> pragma table_info(one); cid name type notnull dflt_value pk ---------- ---------- -------------- ---------- ---------- ---------- 0 i integershorter 0 0 1 j intlon 0 0 sqlite> create table two (i integer really short, j int really really long); sqlite> pragma table_info(two); cid name type notnull dflt_value pk ---------- ---------- ------------------------- ---------- ---------- ---------- 0 i integerreallyshort,jintre 0 0 1 j intreallyreallylong); 0 0 Duplicate of ticket #934. Fixed for version 3.0.8 by check-in [1990]. Surely the example above is from 3.0.7, not 3.0.8 as reported. #c8c8c8 1037 code closed 2004 Dec anonymous Unknown 2004 Dec 1 1 .Net Interop Problem I wrote a .Net wrapper for sqlite 3.0.8, and everything appeared to work fine. I can create databases, read/write data, etc. Then when switching one of our real applications to sqlite, it would crash randomly while reading data from the database. The prior mdb database, did not have this problem. After spending a few hours on this, I determined the problem to be in the sqlite3.dll. I tried a different version of the sqlite3.dll, dated back to late september (also roughly 40 or so kb larger than the latest version), and it performs with no problems whatsoever. Everything works great now using that older DLL. _2004-Dec-17 22:59:05 by drh:_ {linebreak} Sounds like an application problem or a .net problem to me. And even if it is not, the description is way to vague to do anything that might be considered "debugging". #cfe8bd 1035 code fixed 2004 Dec anonymous Unknown 2004 Dec 1 1 union queries with sub-select tables with limits returns no results Both of these return 3 rows: Select * from (select * from a limit 3) as a; Select * from (select * from b limit 3) as b; But this returns 0 rows: Select * from (select * from a limit 3) as a union select * from (select * from b limit 3) as b; It looks like SQLite's compiler is getting confused by the limit clauses on the sub-selects and adds a limit test to the outer select when it shouldn't. #f2dcdc 1034 build active 2004 Dec anonymous TclLib 2004 Dec 2 4 configure generated Makefile doesn't use TCL on MinGW on Windows 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:_ {linebreak} 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:_ {linebreak} 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.) #cfe8bd 1033 build fixed 2004 Dec anonymous 2004 Dec 4 4 configure --help displays incorrect info for --with-tcl The configure script displays help information when started as configure --help The help information for the --with-tcl option says: --with-tcl directory containing tcl configuration (tclConfig.sh) when it should show that an equal sign is required like this: --with-tcl=DIR directory containing tcl configuration (tclConfig.sh) _2004-Dec-09 22:44:03 by anonymous:_ {linebreak} I have added a patch to correct the configure script usage information. #cfe8bd 1032 new fixed 2004 Dec anonymous VDBE 2004 Dec 2 3 access violation in sqlite3_bind_parameter_index when name is NULL The API function sqlite3_bind_parameter_index() causes an access violation if it is called with a NULL pointer for the name argument. I have attached a patch to correct this problem. If a NULL name pointer is passed an invalid index, 0, will be returned. There is an obvious workaround. Check the name pointer before the call and use an index of zero if it is NULL instead of making the call. _2004-Dec-09 22:56:48 by anonymous:_ {linebreak} I see that you have moved the test of the name pointer inside the for loop. I'm just curious why you think it is better to retest the name pointer each time through the loop? It seems like a waste of cycles (admittedly not many cycles, but a waste non the less) to retest a valid pointer each time through the loop for normal operation. #f2dcdc 1029 doc active 2004 Dec anonymous Unknown 2004 Dec 4 5 SQLITE_ not SQLITE3_ constants in the C/C++ interface . html 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_* #c8c8c8 1028 new closed 2004 Dec anonymous Unknown 2004 Dec 2 2 Without COPY: need alt. method to import data (not .import) I've been using the COPY SQL command to load data from CSV files at run-time from a .NET application. I'm unsure how I would do the same using the sqlite.exe utility's .import command? That would mean I would have to shell out to run the sqlite.exe if it can take commanline params. I would strongly urge the team to reconsider the decision to remove COPY from 3.0. There needs to be a way to import data without using the sqlite.exe utility. Thank you. _2004-Dec-08 15:29:33 by drh:_ {linebreak} Write code to do the import yourself. 1: BEGIN 2: Prepare an INSERT statement with parameters ("?") for all values. 3: Open the text file 4: Read and parse a single line of text 5: Bind parsed fields to parameters in the prepared statement 6: Execute the prepared statement 7: If there is more text to be read, go back to step 4. 8: Finalize the prepared statement. 9: Close the text file. 10: COMMIT #c8c8c8 1027 code closed 2004 Dec anonymous 2004 Dec 1 3 Deletion of records that don't meet the condition set Try this SQL code: CREATE TABLE Test ( foo TEXT); INSERT INTO Test VALUES ("bar"); SELECT * FROM Test; -- there is one record DELETE FROM Test WHERE foo = "foo"; SELECT * FROM Test; -- there are no records The example should show pretty well the bug I'm experimenting. _2004-Dec-07 01:22:20 by drh:_ {linebreak} A string in double-quotes resolves to a column name if there is such a column. So your WHERE clause is equivalent to foo==foo which is always true. You should use single quotes for the string literal. I didn't make this up. That's the way SQL works. #f2dcdc 1026 code active 2004 Dec anonymous Unknown 2004 Dec 3 3 sqlite automake sqlite3.pc file does not have version information 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])) #c8c8c8 1024 code closed 2004 Dec anonymous 2004 Dec 1 1 trunk blob data Blob tuncated by by unencoded '\000', why ? _2004-Dec-01 18:20:21 by drh:_ {linebreak} Is this a question or a bug report? Ask questions on the SQLite mailing list not here. If this is a bug report, I do not understand the problem. #c8c8c8 1023 new closed 2004 Nov anonymous Unknown 2004 Dec 4 4 don't link against pthreads if not configured with --enable-threadsafe Linking against -lpthread when not configured with --enable-threadsafe can, depending on the OS and pthread/c library used, implicitely change the handling of signals for certain c library routines. For sure this happens on linux. Signals are routed then through the included pthread library and EINTR doesn't happen anymore for certain c library calls. This causes non-threaded applications that link against a non-threaded sqlite library to show unexpected behaviour due to the unexpected inclusion of the pthread library. A nice to have would be something like libsqlite.so for non-threaded applications and libsqlite_r.so for theaded applications but this is really a nice to have feature. _2004-Dec-01 18:23:26 by drh:_ {linebreak} Already fixed in version 3.0.8. #c8c8c8 1022 code closed 2004 Nov anonymous 2004 Dec 4 4 Table column naming differs between versions 2.8.15 and 3.0.8 When migrating my code from version 2.8.15 to 3.0.8 I encountered the following issue and want to know if this is now a feature or a bug. The following statement: CREATE TEMP TABLE temp AS SELECT id,title FROM mytable WHERE title LIKE 'Sesame%' creates a table with columns named 'id' and 'title' in both versions 2.8.15 and 3.0.8 However, the following modified statement: CREATE TEMP TABLE temp AS SELECT mytable.id,mytable.title FROM mytable WHERE title LIKE 'Sesame%' will have column names 'id' and 'title' in version 2.8.15 while version 3.0.8 will have column names 'mytable.id' and 'mytable.title' Furthermore, if I follow the above statement with: CREATE TEMP TABLE testing AS SELECT X.* FROM temp AS X then table 'testing' contains rows 'id' and 'title' in version 2.8.15 and 'mytable.id' and 'mytable.title' in version 3.0.8 as expected. However if I change the statement to: CREATE TEMP TABLE testing AS SELECT X.id FROM temp AS X then version 2.8.15 works returning a table with only 'id' as a column. Version 3.0.8 fails because it cannot find a column named 'id' in the table 'temp'. So you would think the following should work for version 3.0.8: CREATE TEMP TABLE testing AS SELECT X.mytable.id FROM temp AS X But this also fails! So how can I make the second select work in version 3.0.8? _2004-Dec-01 18:18:57 by drh:_ {linebreak} Use the AS keyword after column names. Works as designed. #c8c8c8 1021 code closed 2004 Nov anonymous 2004 Dec 1 3 LIKE operator % wildcarding broken Statement, CREATE TEMP TABLE testing AS SELECT title FROM tableA WHERE title LIKE '%Sesame%' returns all rows. Changing the match to 'Sesame%' returns the correct rows. Problem also exists in version 2.8.15 _2004-Dec-01 18:17:38 by drh:_ {linebreak} Unable to reproduce. #cfe8bd 1010 code fixed 2004 Nov anonymous BTree 2004 Dec 3 3 btree.c: "pagesSize" should be "usableSize" for AutoVacuum and MX_CELL In *sqlite/src/btree.c*, many instances of _pBT->pageSize_ should instead be _pBT->usableSize_ in order to preserve the reserved-ness of the reserved portion of each page. Fortunately, the PtrMap mechanism is nicely parameterized on page size and handles the change perfectly. Here are the diffs against a recent CVS download. Please note: most of these changes are to lines added for auto-vacuum support. The MX_CELL* changes, however, are to older lines. $ diff sqlite/src/btree.c.ORIG sqlite/src/btree.c 223c223 < #define MX_CELL_SIZE(pBt) (pBt->pageSize-8) --- > #define MX_CELL_SIZE(pBt) (pBt->usableSize-8) 229c229 < #define MX_CELL(pBt) ((pBt->pageSize-8)/3) --- > #define MX_CELL(pBt) ((pBt->usableSize-8)/3) 417,419c417,419 < ** database page. The first argument to each is the page size used < ** by the database (often 1024). The second is the page number to look < ** up in the pointer map. --- > ** database page. The first argument to each is the size of the usable > ** portion of a page in the database (often 1024). The second is the > ** page number to look up in the pointer map. 479c479 < iPtrmap = PTRMAP_PAGENO(pBt->pageSize, key); --- > iPtrmap = PTRMAP_PAGENO(pBt->usableSize, key); 484c484 < offset = PTRMAP_PTROFFSET(pBt->pageSize, key); --- > offset = PTRMAP_PTROFFSET(pBt->usableSize, key); 512c512 < iPtrmap = PTRMAP_PAGENO(pBt->pageSize, key); --- > iPtrmap = PTRMAP_PAGENO(pBt->usableSize, key); 518c518 < offset = PTRMAP_PTROFFSET(pBt->pageSize, key); --- > offset = PTRMAP_PTROFFSET(pBt->usableSize, key); 1749c1749 < int pgsz = pBt->pageSize; /* Page size for this database */ --- > int pgsz = pBt->usableSize; /* Usable page size for this database */ 1777c1777 < if( PTRMAP_ISPAGE(pBt->pageSize, finSize) ){ --- > if( PTRMAP_ISPAGE(pgsz, finSize) ){ 3094c3094 < if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt->pageSize, *pPgno) ){ --- > if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt->usableSize, *pPgno) ){ 4688c4688 < if( pgnoRoot==PTRMAP_PAGENO(pBt->pageSize, pgnoRoot) || --- > if( pgnoRoot==PTRMAP_PAGENO(pBt->usableSize, pgnoRoot) || 4932c4932 < if( maxRootPgno==PTRMAP_PAGENO(pBt->pageSize, maxRootPgno) ){ --- > if( maxRootPgno==PTRMAP_PAGENO(pBt->usableSize, maxRootPgno) ){ 5574c5574 < (PTRMAP_PAGENO(pBt->pageSize, i)!=i || !pBt->autoVacuum) ){ --- > (PTRMAP_PAGENO(pBt->usableSize, i)!=i || !pBt->autoVacuum) ){ 5578c5578 < (PTRMAP_PAGENO(pBt->pageSize, i)==i && pBt->autoVacuum) ){ --- > (PTRMAP_PAGENO(pBt->usableSize, i)==i && pBt->autoVacuum) ){ #cfe8bd 980 code fixed 2004 Nov anonymous VDBE 2004 Dec 2 4 Two triggers confusing each other In the following program the user function sqlitefunc_create_guid is called twice although it should be called only once. *:What the program does: The program uses two tables: "val" is a table containing some data. Each data entry has a primary key ID and a GUID which is supposed to be a unique identification (the same value is never assigned twice). The GUID is generated by the sqlitefunc_create_guid (just a very simple example implementation). "timestamps" is a table to keep track of the creation or update of objects in the "val" table. The trigger "set_guid" is invoked after inserting data to the val table. It updates the guid column and inserts a timestamp value to track the creation date. The trigger "update_timestamp" is invoked when any element of a "val" entry is updated. It updates the update_ts column of its corresponding timestamp entry. *:What goes wrong: The trigger "update_timestamp" is also triggered by the UPDATE query in the trigger "set_guid". This seems to confuse the virtual machine and the sqlitefunc_create_guid is called a second time. *:Workaround Use "AFTER UPDATE OF data ON val" for the "update_timestamp" trigger. However, I would consider this to be a bug. *:Code #include #include "sqlite.h" const char *init_cmd = "CREATE TABLE val (id INTEGER PRIMARY KEY, guid INT, data TEXT); " "CREATE TABLE timestamps (guid INT, creation_ts INT, update_ts INT); " "" "CREATE TRIGGER set_guid AFTER INSERT ON val " "BEGIN " "UPDATE val SET guid = create_guid(new.id) WHERE id = new.id; " "INSERT INTO timestamps (guid, creation_ts) VALUES ((SELECT guid FROM val WHERE id = new.id), strftime('%s', 'now')); " "END;" "" "CREATE TRIGGER update_timestamp AFTER UPDATE ON val " "BEGIN " "UPDATE timestamps SET update_ts=strftime('%%s', 'now') WHERE guid = old.guid; " "END;"; static void sqlitefunc_create_guid(sqlite_func *context, int argc, const char **argv) { static int count = 0; printf("sqlitefunc_create_guid generates guid %i for id %i\n", count, argv[0]); sqlite_set_result_int(context, count++); } int main(int argc, char **argv) { sqlite *db; char *zErr = 0; db = sqlite_open("trigger.db", 0666, &zErr); sqlite_create_function(db, "create_guid", 1, sqlitefunc_create_guid, 0); sqlite_exec(db, init_cmd, 0, 0, &zErr); sqlite_exec(db, "INSERT INTO val (data) VALUES ('some data')", 0, 0, &zErr); sqlite_close(db); return 0; } _2004-Nov-02 13:12:36 by drh:_ {linebreak} The right-hand side of assignments in UPDATE statements do get evaluated twice when you use triggers. This is of no consequence as long as the right-hand side expression does not have side effects. Here is a short example to illustrate the problem: CREATE TABLE t1(a INTEGER PRIMARY KEY, b); CREATE TABLE log(y,z); CREATE TRIGGER rx AFTER UPDATE ON t1 BEGIN INSERT INTO log SELECT b, new.b FROM t1 WHERE a=new.a; END; INSERT INTO t1 VALUES(1,2); UPDATE t1 SET b=random(); SELECT * FROM log; One might expect the values of log.y and log.z to be the same, but because they come from separate invocations of random(), they are different. This issue is unlikely to ever be fixed in 2.8. Work around the problem by not using expressions in UPDATE statements that have side effects. There are changes in the works for 3.0 that might make a solution to this problem feasible. #cfe8bd 634 warn fixed 2004 Feb anonymous Unknown 2004 Feb 3 3 Compiler warnings when compiling using LCC
     Warning f:\data\source\c\sqlite\vdbeaux.c: 1032  possible usage of sqlite_search_count before definition Warning f:\data\source\c\sqlite\printf.c: 365  indexing array buf[1000] out of bounds (1000) Warning f:\data\source\c\sqlite\printf.c: 376  indexing array buf[1000] out of bounds (1000) Warning f:\data\source\c\sqlite\printf.c: 388  indexing array buf[1000] out of bounds (1000) Warning f:\data\source\c\sqlite\os.c: 1217  no type specified. Defaulting to int Warning f:\data\source\c\sqlite\expr.c: 322  unreachable code Warning f:\data\source\c\sqlite\expr.c: 456  possible usage of db before definition Warning f:\data\source\c\sqlite\date.c: 316  unreachable code Warning f:\data\source\c\sqlite\btree_rb.c: 272  unreachable code Warning f:\data\source\c\sqlite\btree_rb.c: 273  missing return value Warning f:\data\source\c\sqlite\btree_rb.c: 1186  unreachable code Warning f:\data\source\c\sqlite\btree_rb.c: 1187  missing return value Warning f:\data\source\c\sqlite\btree_rb.c: 1209  unreachable code Warning f:\data\source\c\sqlite\btree_rb.c: 1210  missing return value 
    #f2dcdc 633 build active 2004 Feb anonymous 2004 Feb 1 1 new build system does not run correctly under MinGW/MSYS 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. #c8c8c8 632 doc closed 2004 Feb anonymous 2004 Feb 2 2 fix links on wrappers page On http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers please update the following text/links. OLD TEXT: PHP driver for SQLite. (Official) NEW TEXT: PHP 4 extension for SQLite. (Official) NEW URI: http://pecl.php.net/package/SQLite OLD TEXT: PHP PEAR abstraction for SQLite. NEW TEXT: PEAR DB contains an interface for SQLite. NEW URI: http://pear.php.net/package/DB Thanks, --Dan Anonymous users (such as you, Dan) are welcomed and encouraged to edit the wiki pages. #c8c8c8 631 code closed 2004 Feb anonymous Shell 2004 Feb 2 3 command line SQL paramater doesn't work on windows pre-compiled binary Can't perform a sql command as a parameter to the command line. First example shows working internal select statement, second shows sqlite returns nothing. G:\sqlite\sqlite>sqlite exl.db{linebreak} SQLite version 2.8.12{linebreak} Enter ".help" for instructions{linebreak} sqlite> .tables{linebreak} tbl1 tbl2{linebreak} sqlite> select * from tbl1;{linebreak} hello!|10{linebreak} goodbye|20{linebreak} Hew baby|30{linebreak} test2|1234{linebreak} sqlite> .quit{linebreak} {linebreak} G:\sqlite\sqlite>sqlite exl.db 'select * from tbl1'{linebreak} {linebreak} G:\sqlite\sqlite>{linebreak} You have to use double-quotes, not single-quotes, on windows. This is a windows thing. It has nothing to do with SQLite and there is nothing that SQLite can do about it. #c8c8c8 630 code closed 2004 Feb anonymous 2004 Feb 1 1 using uninitialized variable compiler complains about using uninitialized variable in function static int lookupName( Parse *pParse, /* The parsing context */ Token *pDbToken, /* Name of the database containing table, or NULL */ Token *pTableToken, /* Name of table containing column, or NULL */ Token *pColumnToken, /* Name of the column. */ SrcList *pSrcList, /* List of tables used to resolve column names */ ExprList *pEList, /* List of expressions used to resolve "AS" */ Expr *pExpr /* Make this EXPR node point to the selected column */ ) in file expr.c at line # 456, variable db isn't initialized. if( zDb!=0 && sqliteStrICmp(db->aDb[pTab->iDb].zName, zDb)!=0 ){ continue; _2004-Feb-24 20:03:16 by drh:_ {linebreak} Already reported in #604, #612, #616, and #629. Fixed by [1225]. #c8c8c8 629 code closed 2004 Feb anonymous Parser 2004 Feb 3 3 Variable used without having been initialized While compiling expr.c I get the following warning from Visual C++: :\wolfpack\wolfpack\sqlite\expr.c(456) : warning C4700: local variable 'db' used without having been initialized I've checked that db variable and it's created at the beginning of that function and _never referenced again_ until that line where it's used in this way: db->aDb[pTab->iDb].zName This is either dead code or a crash waiting to happen. Duplicate of ticket #604. Already fixed. #c8c8c8 628 code closed 2004 Feb anonymous Pager 2004 Feb 1 3 Assertion failure in syncJournal An assertion failure happens when using cscvs. cscvs is a CVS analysis tool, written in Python, which uses sqlite to store information about CVS "changesets". [Yes, yes, I know: this bug report system is not for cscvs nor the Python binding for sqlite. I'm making the report based on the principle that assertions should not fail in shipping library code. There shouldn't be anything a poorly-written client code (interpreter binding, or a script that uses that binding) can do to make an assertion fail. If the client code does something wrong, it should be an error, not an assertion failure. If sqlite uses assertions for error messages, well, I don't agree with that, but I've filed this bug report in error. Sorry!] The basics: the assertion failure happens when using "cscvs cache -b" to create a new database of CVS changesets. The text output is: python: src/pager.c:1168: syncJournal: Assertion `!pPager->noSync' failed. Some software versions: I'm using Debian GNU/Linux unstable, recently updated. "sqlite -version" gives 2.8.12. The python binding is version 0.4.3. Python itself is at 2.3.3. The cscvs tool can be found here: http://wiki.gnuarch.org/moin.cgi/cscvs I'm using the latest version (cscvs--experimental--1.1--patch-79). The CVS repository I'm using is for the MediaWiki software (http://wikipedia.sourceforge.net/), but I seem to get the same error on any CVS repository I try. I realize this is a terribly annoying bug report, but I figured assertion failures are a big deal, so you'd want to know. I don't like Python, and I don't really care all that much about sqlite. I just figured it's only decent to send in a bug report if you find a problem. _2004-Feb-24 15:50:31 by anonymous:_ {linebreak} OK, so, this seems to be entirely dependent on ticket #615. cscvs uses the synchronous pragma in the middle of a transaction with create table statements in it. Removing the pragma stops the assertion failure. ---- _2004-Feb-24 18:44:58 by drh:_ {linebreak} This is the same problem as ticket #615. #f2dcdc 627 code active 2004 Feb anonymous 2004 Feb 3 3 sqliteRunVacuum returning wrong code? 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:_ {linebreak} 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. #cfe8bd 626 code fixed 2004 Feb anonymous Parser 2004 Feb 2 2 EXPLAIN BEGIN TRANSACTION really starts a transaction In the sqlite command interpreter, entering the following two SQL statements reproduces the bug. EXPLAIN BEGIN TRANSACTION; BEGIN TRANSACTION; Here's the log: c:\temp\sqlite>sqlite foo.db SQLite version 2.8.12 Enter ".help" for instructions sqlite> EXPLAIN BEGIN TRANSACTION; 0|Transaction|0|0| 1|VerifyCookie|0|0| 2|Transaction|1|0| 3|Halt|0|0| sqlite> BEGIN TRANSACTION; SQL error: cannot start a transaction within a transaction sqlite> #c8c8c8 625 code closed 2004 Feb anonymous 2004 Feb 1 1 CORE DUMPED when running sum() in DBD::SQLite The following has the perl script I used to test some function with DBD::SQLite. It turns out to be CORE DUMPED. I really have no idea why!? I can use count(*) min() max() but sum() avg() will result in CORE DUMPED BUS ERROR. Thanks for your help ====================================== $ pico dbi_err.pl UW PICO(tm) 4.2 File: dbi_err.pl Modified #!/usr/bin/perl -w # # ch04/error/ex2: Small example using automatic error handling with # RaiseError, i.e., the program will abort upon detection # of any errors. use DBI; # Load the DBI module my ($dbh, $sth, @row, $h); ### Perform the connection using the Oracle driver $dbh = DBI->connect( "dbi:SQLite:sqlite_db/foo.db", "", "", { PrintError => 0, ### Don't report errors via warn( ) RaiseError => 1 ### Do report errors via die( ) } ); my $version= $dbh->{sqlite_version}; print "The SQLite lib version is $version\n"; ### Prepare a SQL statement for execution $sth = $dbh->prepare( "SELECT name, sum(day) from modules group by name " ); ### Execute the statement in the database $sth->execute( ); ### Retrieve the returned rows of data while ( @row = $sth->fetchrow_array( ) ) { print "Row: @row\n"; } ### Disconnect from the database $dbh->disconnect( ); exit; [ Wrote 35 lines ] $ perl dbi_err.pl The SQLite lib version is 2.8.12 Bus Error - core dumped Since this appears to work with the core SQLite library, it appears to be some kind of DBD::SQLite problem. You should perhaps report the bug there. This site only deals with the core SQLite library. #c8c8c8 624 new closed 2004 Feb anonymous 2004 Feb 1 1 SQLite transaction... Hello, I am using SQLite database as my local database i.e. I am importing data from SQL server or any other database. While writing the data in SQLite database all the inserts are put into a transaction. e.g. BEGIN; Insert into table.. 1st row Insert into table.. 2nd row . . . Insert into table.. 30 thousand row. COMMIT; For about first 5 to 6 thousand records it works pretty fast but after that the speed slows down and after importing 10 thousand records it becomes very slow. Is there any solution to overcome this problem? Thanks, _2004-Feb-23 12:16:53 by anonymous:_ {linebreak} This is definitely the *wrong* place to ask this question. Please post requests like such to the SQLite - Mailing - List (refer to section *Mailing List* at http://www.sqlite.com for futher instructions!!) ---- _2004-Feb-23 13:14:57 by drh:_ {linebreak} The anonymous poster above is correct. This is where you report bugs, not ask questions about usage and performance. #cfe8bd 623 code fixed 2004 Feb anonymous Unknown 2004 Feb 2 3 Erroneous min/max on US zip codes Sorting works correctly, min and max do not, on mixed 5- and 9-digit codes in typical format. sqlite> pragma table_info(zipbug); cid name type notnull dflt_value pk ---------- ---------- ---------- ---------- ---------- -- 0 Xnum integer 0 <> 1 1 Name char(30) 0 <> 0 2 City char(30) 0 <> 0 3 State char(2) 0 <> 0 4 Zip char(10) 0 <> 0 No other indices. sqlite> select * from zipbug order by zip; Xnum Name City State Zip ---------- ---------- ---------- ---------- ---------- 5 Speedy Houston TX 77005-1234 4 Daffy Houston TX 77006 1 Donald San Antoni TX 78249-1495 2 Louis Chandler AZ 85226-1832 3 Elmer Buckeye AZ 85326 sqlite> select min(zip) from zipbug; min(zip) ---------- 77006 sqlite> select max(zip) from zipbug; max(zip) ---------- 85226-1832 _2004-Feb-23 13:13:24 by drh:_ {linebreak} Yikes! This problem arises because functions do not distinguish between text and numeric data types. It will take some serious changes to fix. Several weeks might pass before you see a resolution... #f2dcdc 622 doc active 2004 Feb anonymous 2004 Feb 1 3 Should mention PRAGMA table_info() in FAQ 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. #f2dcdc 621 todo active 2004 Feb anonymous Unknown 2004 Feb anonymous 3 3 Assorted errors running test's on MAC OSX Mac OSX 10.3.2, gcc 3.3 {linebreak} sqlite 2.8.12 built from tarball{linebreak} Running tests gave following errors{linebreak} date-8.1...{linebreak} Expected: [{2003-10-26 12:34:00}]{linebreak} Got: [{2004-02-22 21:46:56}]{linebreak} date-8.2...{linebreak} Expected: [{2003-10-27 12:34:00}]{linebreak} Got: [{2004-02-23 21:46:56}]{linebreak} date-8.3...{linebreak} Expected: [{2003-10-28 12:34:00}]{linebreak} Got: [{2004-02-24 21:46:56}]{linebreak} date-8.4...{linebreak} Expected: [{2003-10-22 12:34:00}]{linebreak} Got: [{2004-02-25 21:46:56}]{linebreak} date-8.5...{linebreak} Expected: [{2003-10-01 00:00:00}]{linebreak} Got: [{2004-02-01 00:00:00}]{linebreak} date-8.6...{linebreak} Expected: [{2003-01-01 00:00:00}]{linebreak} Got: [{2004-01-01 00:00:00}]{linebreak} date-8.7...{linebreak} Expected: [{2003-10-22 00:00:00}]{linebreak} Got: [{2004-02-20 00:00:00}]{linebreak} date-8.8...{linebreak} Expected: [{2003-10-23 12:34:00}]{linebreak} Got: [{2004-02-21 21:46:56}]{linebreak} date-8.9...{linebreak} Expected: [{2003-10-23 12:34:00}]{linebreak} Got: [{2004-02-21 21:46:56}]{linebreak} date-8.10...{linebreak} Expected: [{2003-10-23 18:34:00}]{linebreak} Got: [{2004-02-22 03:46:56}]{linebreak} date-8.11...{linebreak} Expected: [{2003-10-21 12:34:00}]{linebreak} Got: [{2004-02-19 21:46:56}]{linebreak} *** Giving up...{linebreak} 11 errors out of 103 tests{linebreak} 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{linebreak} format3-5.1...{linebreak} Expected: [3 121 3]{linebreak} Got: [3 121 0]{linebreak} format3-5.2...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.3...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.4...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.5...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.6...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.7...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.8...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.9...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} format3-5.10...{linebreak} Expected: [3 121 3]{linebreak} Got: [3 121 0]{linebreak} format3-5.11...{linebreak} Expected: [3 100 3]{linebreak} Got: [3 100 0]{linebreak} *** Giving up...{linebreak} 11 errors out of 48 tests{linebreak} 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{linebreak} index-11.1...{linebreak} Expected: [0.10 3]{linebreak} Got: [0.10 0]{linebreak} index-11.2... Ok{linebreak} 1 errors out of 84 tests{linebreak} Failures on these tests: index-11.1{linebreak} intpkey-3.2... Ok{linebreak} intpkey-3.3...{linebreak} Expected: [5 hello world 2]{linebreak} Got: [5 hello world 0]{linebreak} intpkey-3.4...{linebreak} Expected: [5 hello world 3]{linebreak} Got: [5 hello world 0]{linebreak} intpkey-3.5... Ok{linebreak} intpkey-3.6...{linebreak} Expected: [5 hello world 3]{linebreak} Got: [5 hello world 0]{linebreak} intpkey-3.7...{linebreak} Expected: [5 hello world 11 hello world 5]{linebreak} Got: [5 hello world 11 hello world 0]{linebreak} intpkey-3.8...{linebreak} Expected: [11 hello world 5]{linebreak} Got: [11 hello world 0]{linebreak} intpkey-3.9...{linebreak} Expected: [11 hello world 1]{linebreak} Got: [11 hello world 0]{linebreak} intpkey-4.1... Ok{linebreak} intpkey-4.7...{linebreak} Expected: [11 hello world 1]{linebreak} Got: [11 hello world 0]{linebreak} intpkey-4.8...{linebreak} Expected: [11 hello world 1]{linebreak} Got: [11 hello world 0]{linebreak} intpkey-4.9...{linebreak} Expected: [11 hello world 1]{linebreak} Got: [11 hello world 0]{linebreak} intpkey-4.10...{linebreak} Expected: [-4 y z 1]{linebreak} Got: [-4 y z 0]{linebreak} intpkey-4.11...{linebreak} Expected: [-4 y z 1]{linebreak} Got: [-4 y z 0]{linebreak} *** Giving up...{linebreak} 11 errors out of 54 tests{linebreak} 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{linebreak} ioerr-1.1.3... Ok{linebreak} ioerr-2.1.1...{linebreak} Error: no such function: randstr{linebreak} ioerr-2.1.2... Ok{linebreak} testfixture: can't read "cksum": no such variable{linebreak} while executing{linebreak} "do_test ioerr-2.$n.3 {{linebreak} set r [catch {db eval {{linebreak} VACUUM;{linebreak} }} msg]{linebreak} # puts "error_pending=$::sqlite_io_error_pending"{linebreak} # if {$r} {puts..."{linebreak} ("for" body line 32){linebreak} invoked from within{linebreak} "for {set n 1} {$go} {incr n} {{linebreak} do_test ioerr-2.$n.1 {{linebreak} set ::sqlite_io_error_pending 0{linebreak} db close{linebreak} catch {file delete -force test.db}{linebreak} ca..."{linebreak} (file "../sqlite/test/ioerr.test" line 73){linebreak} memdb-1.1...{linebreak} Error: no such function: randstr{linebreak} memdb-1.2.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} memdb-1.2.2-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} memdb-1.2.9-0...{linebreak} Error: no such function: randstr{linebreak} memdb-1.3.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} memdb-1.3.2-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} memdb-1.3.9-0...{linebreak} Error: no such function: randstr{linebreak} memdb-1.4.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} memdb-1.4.2-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} memdb-1.4.9-0...{linebreak} Error: no such function: randstr{linebreak} memdb-1.5.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} *** Giving up...{linebreak} 11 errors out of 11 tests{linebreak} 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{linebreak} minmax-1.1... Ok{linebreak} minmax-1.2...{linebreak} Expected: [19]{linebreak} Got: [0]{linebreak} minmax-1.3... Ok{linebreak} minmax-1.4...{linebreak} Expected: [19]{linebreak} Got: [0]{linebreak} minmax-1.5... Ok{linebreak} minmax-1.6...{linebreak} Expected: [1]{linebreak} Got: [0]{linebreak} minmax-1.7... Ok{linebreak} minmax-1.8...{linebreak} Expected: [1]{linebreak} Got: [0]{linebreak} minmax-1.9... Ok{linebreak} minmax-1.10...{linebreak} Expected: [19]{linebreak} Got: [0]{linebreak} minmax-2.0... Ok{linebreak} 5 errors out of 38 tests{linebreak} Failures on these tests: minmax-1.2 minmax-1.4 minmax-1.6 minmax-1.8 minmax-1.10{linebreak} rowid-4.5...{linebreak} Expected: [4 3]{linebreak} Got: [4 0]{linebreak} rowid-4.5.1...{linebreak} Expected: [3 3]{linebreak} Got: [3 0]{linebreak} rowid-4.6... Ok{linebreak} rowid-11.4... Ok{linebreak} 2 errors out of 123 tests{linebreak} Failures on these tests: rowid-4.5 rowid-4.5.1{linebreak} select2-3.2d...{linebreak} Expected: [3]{linebreak} Got: [0]{linebreak} select2-3.2e...{linebreak} Expected: [3]{linebreak} Got: [0]{linebreak} select2-3.3...{linebreak} Expected: [29999]{linebreak} Got: [0]{linebreak} select2-4.1... Ok{linebreak} 3 errors out of 19 tests{linebreak} Failures on these tests: select2-3.2d select2-3.2e select2-3.3{linebreak} trans-8.3... Ok{linebreak} trans-9.1...{linebreak} Error: no such function: randstr{linebreak} trans-9.2.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} trans-9.2.2-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} trans-9.2.9-0...{linebreak} Error: no such function: randstr{linebreak} trans-9.3.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} trans-9.3.2-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} trans-9.3.9-0...{linebreak} Error: no such function: randstr{linebreak} trans-9.4.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} trans-9.4.2-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} trans-9.4.9-0...{linebreak} Error: no such function: randstr{linebreak} trans-9.5.1-0...{linebreak} Error: cannot start a transaction within a transaction{linebreak} *** Giving up...{linebreak} 11 errors out of 130 tests{linebreak} 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{linebreak} vacuum-1.1...{linebreak} Error: no such function: randstr{linebreak} testfixture: can't read "cksum": no such variable{linebreak} while executing{linebreak} "do_test vacuum-1.2 {{linebreak} execsql {{linebreak} VACUUM;{linebreak} }{linebreak} cksum{linebreak} } $cksum"{linebreak} (file "../sqlite/test/vacuum.test" line 53){linebreak} where-1.0... Ok{linebreak} where-1.1...{linebreak} Expected: [3 121 3]{linebreak} Got: [3 121 0]{linebreak} where-1.2...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.3...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.4...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.5...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.6...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.7...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.8...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.9...{linebreak} Expected: [3 144 3]{linebreak} Got: [3 144 0]{linebreak} where-1.10...{linebreak} Expected: [3 121 3]{linebreak} Got: [3 121 0]{linebreak} where-1.11...{linebreak} Expected: [3 100 3]{linebreak} Got: [3 100 0]{linebreak} *** Giving up...{linebreak} 11 errors out of 12 tests{linebreak} 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{linebreak} _2004-Feb-20 22:48:00 by anonymous:_ {linebreak} 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] #cfe8bd 620 code fixed 2004 Feb anonymous Shell 2004 Feb 1 1 sqlite executable crashes *Command:* sqlite /tmp/res2.sqlite "SELECT Labels.TotalID, Labels.Label FROM Labels, Dimensions, Charts WHERE Dimensions.Label='sessionreferrer' AND Dimensions.ID=Labels.DimensionID AND Labels.ChartID = Charts.ID AND Charts.name = 'refana1'" *Result:* Segmentation fault. *Database:* See attachment (res2.sqlite). *Version:* philip@dev2 ~ ---> dpkg -l sqlite Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-===================-===================-====================================================== ii sqlite 2.8.12-1 A command line interface for SQLite #c8c8c8 619 code closed 2004 Feb anonymous 2004 Feb 1 1 Multiple BEGIN and COMMIT transaction problem... While doing multiple trnsactions the first transaction is pretty fast but all the following are becoming slow. e.g. BEGIN; Insert Into...1st record Insert Into...2nd record . . Insert Into...1000 record COMMIT; this transaction takes only 4 to 5 seconds but again doing the same BEGIN; Insert Into...1001th record Insert Into...1002nd record . . Insert Into...2000 record COMMIT; takes more time than the first one. multiple BEGIN & COMMIT transactions on the same database are required because at any time I want append the data to SQLite table. Inserting data into an existing database takes more work (and more time) than adding data to a previously empty database. This is *not* a code defect. #c8c8c8 618 code closed 2004 Feb anonymous Unknown 2004 Feb 3 3 fails test btree-1.1.1 Macintosh G4 Desktop 867MHZ DP OSX 10.3.2, gcc 3.3 Built from package sqlite-2.8.12.tar.gz When running test via "make test", run ends with error btree-1.1.1...../sqlite/src/btree.c:2689: failed assertion `pPage->isInit'{linebreak} make: *** [test] Abort trap Duplicate of tickets #376 and #369 #cfe8bd 617 new fixed 2004 Feb anonymous Unknown 2004 Feb 5 4 date() conversion seems to fail on -ve dates Not certain whether this is just a factor of the date handling being new. sqlite> SELECT date(5); -4713-11-29 sqlite> SELECT date('-4713-11-29'); sqlite> Whether that's by design or not, I'm not certain, but most other dates generated by date() are re-parsable by date() so it would seem sensible that -ve dates should be, also. Or maybe it's that date(5) is just invalid and should never have generated such a -ve date. #c8c8c8 616 code closed 2004 Feb anonymous VDBE 2004 Feb 1 1 variable 'db' is not initialized before being used (expr.c line 418) Compiling your most excellent sqlite 2.8.12 with CodeWarrior 8.3. It appears that in the function 'lookupName' the local variable 'db' is never set, but it is used. I'm guessing that expr.c line 418 should be: sqlite *db = pParse->db; This is a duplicate of ticket #604 which has already been fixed. #cfe8bd 615 code fixed 2004 Feb drh Pager 2004 Feb 2 3 Assertion fault in pager when synchronous changed within a transaction The following code causes an assert failure inside pager.c: BEGIN; CREATE TABLE t1(x); PRAGMA synchronous=off; COMMIT; #cfe8bd 614 code fixed 2004 Feb anonymous Shell 2004 Feb 2 1 history not saved after quitting the shell with .quit exiting the sqlite shell using .quit is triggering exit(0), thus bipassing history saving point. return 1 will do the job. #f2dcdc 613 doc active 2004 Feb anonymous 2004 Feb 3 4 Doc is wrong with some prototypes and const is missing for errmsg {link: http://www.hwaci.com/sw/sqlite/c_interface.html 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,{linebreak} _: _char_ *sql,{linebreak} _: int (*xCallback)(void*,int,char**,char**),{linebreak} _: void *pArg,{linebreak} _: char **errmsg{linebreak} );"{linebreak} 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. #cfe8bd 612 code fixed 2004 Feb anonymous 2004 Feb anonymous 3 1 Pointer 'db' not initialized in function lookupname() (expr.c) My VC compiler found this error: C:\Projetos\SqlLite\expr.c(456) : warning C4700: local variable 'db' used without having been initialized It really uses the unitialized pointer... I think it could crash! It was fixed. See Check-in #604 #f2dcdc 611 new active 2004 Feb anonymous VDBE 2004 Feb 1 3 Remove giant SWITCH statement in VM for better portability 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:_ {linebreak} 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:_ {linebreak} _>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:_ {linebreak} 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. #cfe8bd 610 code fixed 2004 Feb anonymous Parser 2004 Feb 5 4 REPLACE INTO syntax not allowed in triggers CREATE TABLE Test1 (x int primary key);{linebreak} CREATE TABLE Test2 (y int primary key);{linebreak} {linebreak} -- trying to create this trigger fails with: SQL error or missing database. near "REPLACE": syntax error{linebreak} CREATE TRIGGER trigTest1_AD AFTER DELETE ON Test1 FOR EACH ROW{linebreak} BEGIN{linebreak} REPLACE INTO Test2 (y) VALUES (old.x);{linebreak} END;{linebreak} {linebreak} --The obvious workaround is:{linebreak} CREATE TRIGGER trigTest1_AD AFTER DELETE ON Test1 FOR EACH ROW{linebreak} BEGIN{linebreak} INSERT OR REPLACE INTO Test2 (y) VALUES (old.x);{linebreak} END;{linebreak} #f2dcdc 609 build active 2004 Feb anonymous Unknown 2004 Feb 1 4 Makefile errors bastion# make{linebreak} "Makefile", line 73: Missing dependency operator{linebreak} "Makefile", line 75: Need an operator{linebreak} "Makefile", line 90: Missing dependency operator{linebreak} "Makefile", line 92: Need an operator{linebreak} 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:_ {linebreak} Also tried with 2.8.13, same exact error. ---- _2004-Mar-15 00:34:54 by anonymous:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 608 code active 2004 Feb anonymous 2004 Feb 3 3 Problem with "pragma show_datatypes = on" and busy timeout 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:_ {linebreak} This problem breaks the auto-typing feature of PySQLite when a busy timeout is used. #c8c8c8 607 code closed 2004 Feb anonymous 2004 Feb 1 1 odbc doesn't like field name date change field name to something like eventdate and it works This site covers the SQLite core only - not the ODBC driver. #c8c8c8 606 code closed 2004 Feb anonymous 2004 Feb 1 1 odbc doesn't like datetime type - returns a null change types to time or date and it will work This site covers the SQLite core only - not the ODBC driver. #cfe8bd 605 warn fixed 2004 Feb anonymous 2004 Feb 1 1 _FILE_OFFSET_BITS redefined os.h src/os.h:42: warning: `_FILE_OFFSET_BITS' redefined {linebreak} #ifndef _FILE_OFFSET_BITS {linebreak} #define _FILE_OFFSET_BITS {linebreak} #endif {linebreak} should do. #cfe8bd 604 warn fixed 2004 Feb anonymous Parser 2004 Feb 4 4 'db' has been referenced but never assigned a value Compiling sources 2.18.2 witch OpenWatcom 1.3beta wcc386 expr.c -wx reports: expr.c(418): Warning! W200: 'db' has been referenced but never assigned a value . . . int cntTab = 0; /* Number of matching table names */ sqlite *db; /* The database */ assert( pColumnToken && pColumnToken->z ); /* The Z in X.Y.Z cannot be NULL */ . . char *zTabName = pTab->zName; if( zTabName==0 || sqliteStrICmp(zTabName, zTab)!=0 ) continue; if( zDb!=0 && sqliteStrICmp(db->aDb[pTab->iDb].zName, zDb)!=0 ){ continue; } . . . Variable db is declared, NOT initialized and referenced. Bartosz Polednia #cfe8bd 603 code fixed 2004 Feb anonymous 2004 Feb 4 4 compile error date.c if SQLITE_OMIT_DATETIME_FUNCS defined Compiling date.c with SQLITE_OMIT_DATETIME_FUNCS errors out: /usr/bin/cc -DSQLITE_OMIT_DATETIME_FUNCS=1 -I. -c date.c date.c:821: error: parse error before '*' token date.c: In function `sqliteRegisterDateTimeFunctions': date.c:826: error: parse error before '*' token date.c:839: error: `db' undeclared (first use in this function) date.c:839: error: (Each undeclared identifier is reported only once date.c:839: error: for each function it appears in.) Must include of os.h and sqliteInt.h even if SQLITE_OMIT_DATETIME_FUNCS is defined! Diff: --- /home/bernd/OS/sqlite/sqlite_src-2.8.12/date.c 2004-02-08 19:08:37.000000000 +0100 +++ date.c 2004-02-10 09:11:05.000000000 +0100 @@ -47,9 +47,9 @@ ** Willmann-Bell, Inc ** Richmond, Virginia (USA) */ -#ifndef SQLITE_OMIT_DATETIME_FUNCS #include "os.h" #include "sqliteInt.h" +#ifndef SQLITE_OMIT_DATETIME_FUNCS #include #include #include #cfe8bd 602 code fixed 2004 Feb anonymous 2004 Feb 1 1 Update tablename set rowid = rowid -1 fails for more than 1000 records I am facing a problem while deleting emails and updating the rowid column in the SQLite table. Here I will try to explain my problem: In my SQLite table I have more than 1000 records ranging from say 1,2,...,1000,1001,...,1111. To delete 1st record using the delete query I wrote the query as follows, delete from tablename where rowid = 1 After successful execution of this query the remaining records in the table ranges from 2,3,...,1000,1001,...,1111. (rowids) Now I want to update the rowid column so that the rowids will be reset to 1,2,...,1000,1001,...,1110 after deleting the first record. To do this I tried the query, which is as follows, update tablename set rowid = rowid - 1 where rowid > 1 so that all the rowids will be reduced by 1 from rowid 2 to 1111 and will be set to 1 to 1110. But when I tried this query it gave me an error "PRIMARY KEY must be unique" but in reality there is no any conflict in rowids. When I executed above query on batches of 1000 records then it worked. update tablename set rowid = rowid -1 where rowid > 1 and rowid <= 1000 result for rowid column = 1,2,3,...,999,1001,...1111 update tablename set rowid = rowid -1 where rowid > 999 and rowid <= 1111 result for rowid column = 1,2,3,...,999,1000,...1110 But this solution is not feasible for me if I have say one lakh records in my database because it is becoming very slow. Can you please help me to overcome this problem? Thanks, SQLite does not guarantee that updates will occur in any particular order. I've added a few lines of code so that, for now, the updates do occur in search order even for large updates. But I do not want to be obligated to maintain this behavior in future releases. Therefore, do not become dependent upon this behavior. #cfe8bd 601 code fixed 2004 Feb anonymous CodeGen 2004 Feb 1 1 Left-join subquery gives incorrect results The following join works: create table t1 (b, c); insert into t1 values ('dog',3); insert into t1 values ('cat',1); insert into t1 values ('dog',4); create table t2 (c, e); insert into t2 values (1,'one'); insert into t2 values (2,'two'); insert into t2 values (3,'three'); insert into t2 values (4,'four'); select t2.c as c, e, b from t2 left join (select b, max(c) as c from t1 group by b) using (c); But if you make the whole thing a subquery, you get incorrect results: select * from ( select t2.c as c, e, b from t2 left join (select b, max(c) as c from t1 group by b) using (c) ); #c8c8c8 600 code closed 2004 Feb anonymous 2004 Feb 1 1 unable to open database file, win32, Java jdbc Using sqlite 2.8.3, windows 2000, Java JDBC, I get an exception: "unable to open database file". It happens during the use of the database, when tring to insert a large amount of data. It is done under a transaction. The same problem does not occur under linux. Please report this problem to the developer of the JDBC driver. #cfe8bd 599 code fixed 2004 Feb anonymous Pager 2004 Feb 1 2 Corrupt problem encountered on Windows NT platform We are very concerned about SQLite corrupt problem on Windows platform. We have written a test that consists of two processes: one inserts records in loop, and the other terminates the first process and starts it again. This test led DB to be corrupted in 5-10 loops in synchronous mode (either NORMAL or FULL), while in synchronous=OFF mode it corrupted in more than 100 loops, and DB could be reopened then (when journal file was deleted). We have analyzed database crash in synchronous mode, and found out that its journal file consists value 0 in the field nRec of its header. Debugging rollback operation helped us find out the corruption reason: the DB file was truncated according to the value "initial database page count"(mxPg) while old page values were not recovered due to 0 in value "number of records in journal" (nRec). Therefore, resulting DB contained links to missing pages (they were deleted by truncate operation). We also found that the actual number of pages in journal file could be calculated using journal file size if nRec field had contained value 0xffffffff instead of 0. There is how the nRec field is initialized in pager_open_journal function (pager.c): rc = write32bits(&pPager->jfd, pPager->noSync ? 0xffffffff : 0); However this field is updated neither in sqlitepager_write (where old page is written to journal before being modified) nor in sqlitepager_commit function (where journal file buffers are flushed and dirty pages are committed to DB). As far as we could find, this field is only updated from function syncAllPages which is called from sqlitepager_get only if there is no place in page cache (which happens not very often). After we replaced code mentioned above with: rc = write32bits(&pPager->jfd, 0xffffffff); to make this field be calculated automatically, we could not corrupt DB file by our test anymore. However we had another problem, instead of DB file we got journal file corrupted. The problem was in its header, which was not written entirely (e.g. only 16 bytes were written so "initial database page count" field was missing), and pager_playback function returned SQLITE_CORRUPT when it tried to read the header of journal file. The next time the DB file opened successfully, because journal file had already been deleted. We tried to solve this problem by modifying pager_open_journal in the way it wrote journal file header into its buffer at first and then wrote the buffer into a file. It seems to help. With this two fixes we haven't managed to corrupt the DB by our test again. We have tested this issue only on Windows platform (on NTFS partition), however it seems to be applicable to any other platforms. Besides, it is possible, that this problem is related to ticket #540. The corruption problem described above is real, but the solution proposed is incorrect. The nRec field of the journal header must be set to 0 initialize. We cannot rely on using the size of the journal file to compute nRec because after a power failure, the size of the journal file might not be correct. The problem was not that nRec is initialized to zero but that nRec is not updated to the correct value prior to beginning a COMMIT. The second problem described above, where database corruption was reported if the journal file header was incomplete, was solved by enhancing the size test on the journal file during journal playback and ignoring journals with incomplete headers. #c8c8c8 597 code closed 2004 Feb anonymous Unknown 2004 Feb 3 2 SELECT * FROM TB_LINFPSP_CONFIG WHERE LINFPSP_CUST_CODE='HBC' Hi, I have created a database called LINFPSP_CONFIG.db and then created a table in it called TB_LINFPSP_CONFIG with the structure CREATE TABLE TB_LINFPSP_CONFIG (LINFPSP_id integer primary key not null, LINFPSP_KEY varchar(200), LINFPSP_VALUE varchar(200), LINFPSP_CUST_CODE varchar(100)) It has following data 1, cust_in_dir_path, c:\projects\test, HBC 1, cust_out_dir_path, c:\projects\test, HBC When I run the query SELECT * FROM TB_LINFPSP_CONFIG WHERE LINFPSP_CUST_CODE='HBC' It returns 0 rows. But when I run query SELECT * FROM TB_LINFPSP_CONFIG WHERE LINFPSP_CUST_CODE like 'HBC' It returns both rows. There is no extra whit space after HBC. When I run the query SELECT * FROM TB_LINFPSP_CONFIG WHERE LINFPSP_KEY="cust_in_dir_name" It returns a proper one row. I tried recreating the database many times but still the same error. I think its a bug. Thanks with best regards, Vikrant It is not possible that the data described above could be in the table described above because the primary key is not unique. If you still think you are seeing a problem, attach a script that can be run using the sqlite shell and which reproduces the problem exactly. User error. No changes to code. #c8c8c8 596 code closed 2004 Feb anonymous 2004 Feb 1 1 sqlite_exec OR sqlite_get_table can not handle empty results sets c++ api the char** results can not be influenced by the application programmer (f.ex. initialized) and given a certain content for testing later. If the result set is empty (and the PRAGMA for empty callbacks is ON) as it is in an empty table. f.ex. SELECT max(id) FROM customer; trying to get the value out of results[0] ==> segmentation fault. Can't work around that bug (it is present in sqlite_get_table and in sqlite_exec). Except not using the api.. but what is it goor for then?! See documentation on the empty_result_callbacks pragma. Works as designed. No changes to code. #c8c8c8 595 code closed 2004 Feb anonymous 2004 Feb 1 4 Big joins dont work as I expect I have a db about 490Mb in size with 3 big tables with 97,000 rows. These are patient, accn (episode) and rpt. All have a key called pnumber (content looks like '03B1234'). Report has a big field report containing 2-4K of HTML. This works: SELECT patient.surname, rpt.labno,accn.requested, rpt.summary from rpt,accn,patient where patient.pnumber = accn.pnumber and rpt.pnumber = accn.pnumber LIMIT 100; SELECT patient.surname, rpt.labno,accn.requested, rpt.summary from rpt,accn,patient where patient.pnumber = accn.pnumber and rpt.pnumber = accn.pnumber and rpt.report like '%carcinoma%' LIMIT 100; I start getting all sorts of duplicate rows and some of the data seems incorrect. ?buffer overflow or something. Version 2.8.11. (It was worse with older version when the simple join without a where statement would generate duplicaes, partially improved by a DISTINCT clause). Could I have an old DLL around? Is my database too big? (I want to quadruple it, too). Especially since I use python pysqlite. I dont really understand where Win XP on my work computer might put dlls. In sufficient data to reproduce. The report above does not provide a schema nor does it provide examples of incorrect output. #cfe8bd 594 code fixed 2004 Feb anonymous 2004 Feb 1 1 TEMP tables not dropped by ROLLBACK if sqlite_interrupt was called -- setup sql{linebreak} CREATE TABLE Test (x int primary key);{linebreak} this sequence doesn't remove temp table(s) created inside a transaction:{linebreak} BEGIN TRANSACTION;{linebreak} CREATE TEMP TABLE tempTest(x int primary key);{linebreak} -- long running insert statement{linebreak} INSERT INTO Test SELECT * FROM tempTest;{linebreak} -- call sqlite_interrupt while the above statement is processing{linebreak} -- the sqlite_exec() call running the INSERT statement returns SQLITE_INTERRUPT{linebreak} ROLLBACK TRANSACTION;{linebreak} -- the temp table tempTest is not removed (it was created inside the transaction!){linebreak} #cfe8bd 593 code fixed 2004 Feb anonymous VDBE 2004 Feb 3 3 Interrupted VACUUM returns SQLITE_ERROR not SQLITE_INTERRUPT If sqlite_interrupt() is called, then the current execution terminates and returns SQLITE_INTERRUPT, unless a VACUUM statement is being executed (which returns SQLITE_ERROR instead). I would consider this unexpected behaviour to be a bug. #f2dcdc 592 event active 2004 Feb anonymous Unknown 2004 Feb 1 1 VIEW produces strange result set 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 ... :( #f2dcdc 591 todo active 2004 Feb anonymous Unknown 2004 Feb anonymous 5 4 "PRAGMA table_info" doesn't show you which column is unique "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. #cfe8bd 583 warn fixed 2004 Jan anonymous Unknown 2004 Feb 4 4 _FILE_OFFSET_BITS redefined on 64bit sparc-sun-solaris
      bash-2.05b$ gcc -v  Reading specs from /opt/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.3.2/specs  Configured with: ./configure --prefix=/opt/gnu --enable-languages=c,c++,objc --disable-nls --enable-shared --enable-threads=posix --with-as=/opt/gnu/bin/as --with-ld=/opt/gnu/bin/ld  Thread model: posix  gcc version 3.3.2    bash-2.05b$ uname -a  SunOS bslw0102 5.8 Generic_108528-11 sun4u unknown SUNW,Ultra-4 Solaris    bash-2.05b$ export CFLAGS="-O2 -fstrength-reduce -ffast-math -fexpensive-optimizations -s -pipe -mhard-float -mfpu -mcpu=ultrasparc -Wall -std=c99"    bash-2.05b$ tar xfz sqlite-2.8.11.tar.gz    bash-2.05b$ cd sqlite    bash-2.05b$ ./configure --prefix=/opt/gnu --with-gnu-ld --enable-tempdb-in-ram --disable-readline --disable-tcl    bash-2.05b$ make    ...lots of compiler output...    In file included from src/func.c:26:  src/os.h:42:1: warning: "_FILE_OFFSET_BITS" redefined  In file included from /usr/include/iso/ctype_iso.h:30,                   from /usr/include/ctype.h:18,                   from src/func.c:21:  /usr/include/sys/feature_tests.h:96:1: warning: this is the location of the previous definition    ...more compiler output...  bash-2.05b$    The above warning is repeated for:    In file included from src/main.c:20:    In file included from src/random.c:21:    In file included from src/tokenize.c:21:    In file included from src/vacuum.c:20:    In file included from src/vdbe.c:49:    In file included from src/vdbeaux.c:18:  
    dirty workaround for sparc-sun-solaris:
     diff -Nur sqlite.orig/src/os.h sqlite/src/os.h --- sqlite.orig/src/os.h        2004-01-11 23:56:52.000000000 +0100 +++ sqlite/src/os.h     2004-01-28 10:01:31.427287000 +0100 @@ -39,7 +39,6 @@  */  #ifndef SQLITE_DISABLE_LFS  # define _LARGE_FILE       1 -# define _FILE_OFFSET_BITS 64  # define _LARGEFILE_SOURCE 1  #endif 
    ---- _2004-Feb-25 20:24:53 by anonymous:_ {linebreak} Same problem as described in #605 Problem is fixed with [1227] #c8c8c8 578 code closed 2004 Jan anonymous 2004 Feb 4 2 calling isdigit in sqliteIsNumber cause asserts (VC.NET) If database contains characters with code >= 0x80, then any SELECT cause hundreds of asserts in isctype.c (68) (VC.NET). As solution, I suggests casting *char* to *unsigned char* before calling isdigit in sqliteIsNumber function as shown here: isdigit((unsigned char)*z); _2004-Feb-25 02:36:00 by drh:_ {linebreak} I believe this is a bug in VC.NET. The problem should be fixed there. ---- _2004-Feb-26 20:49:40 by anonymous:_ {linebreak} I shall not argue :) However, correction of this error in CRT VC.NET is very problematic and is non portable - it is necessary to recompile the standard library for this purpose... And, if you'll look at a code in util.c it is possible to see already available castings: h = (h<<3) ^ h ^ UpperToLower[(unsigned char)*z++]; a = (unsigned char *)zLeft; b = (unsigned char *)zRight; etc... Why not to insert a little more? ;) #cfe8bd 576 code fixed 2004 Jan anonymous CodeGen 2004 Feb 1 2 last_insert_rowid() returns wrong values in triggers on views I have tracked down a what I think is a problem with the last_insert_rowid() function. I also get the same results with the sqlite_last_insert_rowid() API call. If the last insert is done inside a trigger on a view, it does not update the last_insert_rowid() return value. The SQL scrip in the attached file test.sql demonstrates the problem. A log of the execution of this script is also attached in the file test.log. It looked like SQlite did the correct thing in triggers on tables, but after further examination, that is not true. It does not update the last_insert_rowid return value for any inserts inside triggers. I think SQLite should update this variable for every insert into a real table, unless there is some subtlety I haven't considered. It seems to me that the the PutIntKey instruction at line 27 of the first explain output, the insert into a view, should have a p2 parameter of 1 rather than 0. This would allow this instruction to update the lastRowid variable which is returned by last_insert_rowid(). It looks like SQLite is actively avoiding updates to the lastRowid variable inside triggers. The second explain output shows that it only updates this variable at line 20, which correpsonds to the original insert into t3. The insert into t4 caused by the after insert trigger on t3 does not update the lastRowid variable, because the p2 parameter of the PutIntKey instrunction at line 37 is 0. A further update, upon looking into this matter further: This problem has been reported previously under ticket #481 (I know, I should have checked for this first before openeing another ticket. I'm sorry). This behaviour was introduced by the fix to the problem reported on ticket #290. I think both behaviors are unexpected and problematic. The behavior within INSTEAD OF triggers on views makes last_insert_rowid() useless when working with tables that have integer primary keys. The behavior with AFTER triggers on tables prior to the ticket #290 fix was also clearly broken. I think the correct behavior in all cases can be obtained by having SQLite create a seperate context for each trigger. This would require the current value of db->lastRowid to be pushed onto the VDBE stack at the beginning of the trigger. Then allow all inserts to update db->lastRowid so that calls to last_insert_rowid() return the correct value within the trigger. And finally to restore the value of db->lastRowid after the trigger completes. This would provide the correct behavior for AFTER triggers on tables, as well as allow the correct rowids to be obtained for inserts performed inside all triggers. It will also work with nested triggers. The only anomally is that there is still no way to directly obtain the rowid for the principle table in a view if that table use an integer primary key. Perhaps this is not a real problem technically, since the rows in views do not have rowids (the rowid for a view is always NULL). However it is a problem when the user expects the view to have the same semantics as a table with an integer primary key (i.e. he expects to be able to do an insert into the view, and then select last_insert_rowid() to get the rowid assigned to the row(s) inserted). At least with the proposed change the user can update a table to store the value of last_insert_rowid() from within the trigger and then select that value after the insert on the view instead of calling last_insert_rowid(). This is shown in the example below. create table main ( id integer primary key, a ); create table extend ( id integer references main, b ); create view combined as select main.id as id, main.a as a, extend.b as b from main join extend using(id); create table last_insert ( id integer ); create trigger in_combined instead of insert on combined begin //insert into main table insert into main values (new.id, new.a); //export last_insert_rowid out of trigger update last_insert set id = last_insert_rowid(); //insert into extended data table with correct id to // establish relation to main table insert into extend values (last_insert_rowid(), new.b); end; //do test insert into combined view insert into combined values(NULL, 1, 2); //get id needed to re-select the last row inserted into the view select id from last_insert; This is still does not allow tables and views to be treated exactly the same. But it would probably be workable for most applications. The only thing I can think of that would allow the view to behave more like a table is to allow the user to indicate which field in the view should be treated like its rowid. An insert trigger on a view could then update the db->lastRowid variable with the value of this field when the trigger is done. This would invlove substantially more complicated changes to SQLite. #cfe8bd 568 code fixed 2004 Jan anonymous Shell 2004 Feb 2 2 Shell does not handle -init option correctly The SQLite shell does not handle the -init command line option correctly. Currently the filename passed as a parameter to the -init option is parsed as the database file name. This leads to a malformed database file error. I have fixed the shell.c file by adding few small snippets of code. The -init command is added to the set of options with parameters so that it is skipped when looking for the database file name. The current processing of the init file clears the database filename and output file settings established earlier. These values should be saved and restored before and after the callback data is reinitialized. Actually there is no real effect on the output file since it is initially set to stdout, and then reinitialized to zero, which just happens to be the same value. These changes can be applied to shell.c by patching with the attached diff file. #c8c8c8 527 code closed 2003 Dec anonymous Shell 2004 Feb 3 3 Sqlite shell: lack of checks The shell command ('d' not exists): sqlite ./d/myfile Gives an error as follows: SQLite version 2.8.7 Enter ".help" for instructions sqlite> select * from mytable; Unable to open database "./d1/test": unable to open database ./d1/test The error of using a non existant directory should be caught sooner by checking the path and a better error message should be returned.{linebreak} Same problem with a non writable directory. The shell intentionally does not open the database file until the database file is actually used. This avoid creating empty files when misspell the name of the database file. #cfe8bd 504 code fixed 2003 Nov anonymous 2004 Feb 3 3 'INDEX_INFO' PRAGMA returns invalid data if used with non-callback API 'INDEX_INFO' PRAGMA returns invalid data if used with non-callback API Everything uses the non-callback API now. Even sqlite_exec() is implemented using the non-callback API. And the INDEX_INFO pragma works. So this must be fixed. #c8c8c8 499 code closed 2003 Nov anonymous Unknown 2004 Feb 1 3 dot in table name and in column name makes full_column_names unusable if you select a column containing a dot from a table containing a dot and wish to use the full_column_names, there is no clean way to parse the column name. the dot in the table name should be escaped. in select.c: line 783: if( showFullNames || zTab==0 ) zTab = pTab->zName; insert code to escape an eventual '.', like: if (strchr(zTab, '.') != 0) sqliteSetString(&zName, "[", zTab, "]", ".", zCol, 0); else line 784: sqliteSetString(&zName, zTab, ".", zCol, 0); _2004-Feb-25 02:44:45 by drh:_ {linebreak} The full_column_names pragma is a kludge. And it gets used by other kludges all over the place. If I change what it does in any way, it is likely to break lots of code. The current behavior must be preserved to protect backwards compatibility, even if the current behavior is less than optimal. #cfe8bd 481 code fixed 2003 Oct anonymous VDBE 2004 Feb 1 3 last_insert_rowid doesn't work within triggers any more The fix of ticket 290 has introduced a behaviour which is, in my view, buggy (whereas the behaviour described in ticket 290 was simply unexpected, but logical). I use views and triggers to simulate inheritance, with an "Header" table for the parent class, and a number of other tables for the daughter classes. I have made "instead of" triggers for inserting into views which present the whole object. These triggers use last_insert_rowid to link the "parent" part of the object and the "daughter" part. A simplified example of what doesn't work : With the following code : create table test1 (oid integer primary key); create table count (oid integer primary key, cp integer); create view v as select * from test1; create trigger i instead of insert on v for each row begin insert into test1 values (NEW.oid); insert into count values (NULL, last_insert_rowid()); end; insert into v values (5); sqlite> select * from test1; 5 sqlite> select * from count; 1|0 The value of cp is "0", while we were expecting "5". Regards, S. Rosmorduc #f2dcdc 451 build active 2003 Sep anonymous 2004 Feb 1 1 Makefile fails on FreeBSD 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 Makefile apparently depends on the GNU make rather than a standard Unix make: "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 Isn't it possible to stick with a Unix make that way SQLite is more portable. use gmake #cfe8bd 370 code fixed 2003 Jun anonymous 2004 Feb dougcurrie 2 3 make fulltest status on Cygwin, failure on 2 tests 'make fulltest' result: [snip]{linebreak} attach-5.1...{linebreak} Error: error deleting "test2.db": permission denied{linebreak} [...]{linebreak} copy-6.1...{linebreak} Expected: [11 22 33 22 33 44 33 44 55 44 55 66 55 66 77 66 77 88]{linebreak} Got: [11 22 33 22 33 44]{linebreak} [...]{linebreak} 2 errors out of 25972 tests{linebreak} Failures on these tests: attach-5.1 copy-6.1{linebreak} make: *** [fulltest] Error 1{linebreak} NOTE: compiled with __CYGWIN_USE_BIG_TYPES__ (for off_t as 64 bit type). Re-running these tests using Cygwin and SQLite 2.8.11 confirms that all of these problems are fixed, except copy-6.1. The issue with copy-6.1 is that Cygwin converts "\n" to "\r\n" when writing to text files. See: http://cygwin.com/faq/faq_4.html#SEC75 The result is that the file dataX.txt produced by the tcl test tile copy.tst looks like this: Addr 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 2 4 6 8 A C E -------- ---- ---- ---- ---- ---- ---- ---- ---- ---------------- 00000000 3131 7c32 327c 3333 0d32 327c 3333 7c34 11|22|33.22|33|4 00000010 340d 0d0a 3333 7c34 347c 3535 0d0a 3434 4...33|44|55..44 00000020 7c35 357c 3636 0d35 357c 3636 7c37 370d |55|66.55|66|77. 00000030 0d0a 3636 7c37 377c 3838 0d0a ..66|77|88.. So COPY interprets the "\r\r" as end of file. Since this problem is not in SQLite itself, but rather in Cygwin/tcl I am considering this ticket closed. Opening dataX.txt as set f [open dataX.txt w] fconfigure $f -translation binary fixes this problem for Cygwin users; see attached diff (thanks, Ron). #f2dcdc 590 new active 2004 Jan anonymous Parser 2004 Jan 5 4 Treat ` like spaces outside of quoted strings. 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... #f2dcdc 588 new active 2004 Jan anonymous 2004 Jan 5 4 Please provide support for NULLS LAST in ORDER BY clauses. 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) #cfe8bd 587 code fixed 2004 Jan anonymous Unknown 2004 Jan 3 1 easy way to operate on a max () value I also noticed that
      select * from ( select x from y )  
    does not produce the same results as
      select x from y  
    when I tried using that in a workaround.
      explain select max ( timestamp ) from rawlog ;      0|ColumnName|0|0|max ( timestamp )  1|VerifyCookie|0|1408|  2|Integer|0|0|  3|OpenRead|0|3|rawlog  4|Integer|0|0|  5|OpenRead|1|8|ix_rawlog_timestamp  6|Last|1|0|  7|IdxRecno|1|0|  8|Close|1|0|  9|MoveTo|0|0|  10|Column|0|0|  11|Callback|1|0|  12|Close|0|0|  13|Halt|0|0|      explain select max ( timestamp ) - 3600 from rawlog ;      0|ColumnName|0|0|max ( timestamp ) - 3600  1|AggReset|0|1|  2|AggInit|0|0|ptr(0x94ab0)  3|String|0|0|  4|AggFocus|0|0|  5|Integer|0|0|  6|OpenRead|0|3|rawlog  7|VerifyCookie|0|1408|  8|Rewind|0|13|  9|Column|0|0|  10|Integer|0|0|  11|AggFunc|0|1|ptr(0x94ab0)  12|Next|0|9|  13|Close|0|0|  14|AggNext|0|20|  15|AggGet|0|0|  16|Integer|3600|0|3600  17|Subtract|0|0|  18|Callback|1|0|  19|Goto|0|14|  20|Noop|0|0|  21|Halt|0|0|      explain select timestamp - 3600 from ( select max ( timestamp ) as 'timestamp' from rawlog ) ;      0|ColumnName|0|0|timestamp - 3600  1|VerifyCookie|0|1408|  2|Integer|0|0|  3|OpenRead|1|3|rawlog  4|Integer|0|0|  5|OpenRead|2|8|ix_rawlog_timestamp  6|Last|2|0|  7|IdxRecno|2|0|  8|Close|2|0|  9|MoveTo|1|0|  10|Column|1|0|  11|MakeRecord|1|0|  12|NewRecno|0|0|  13|Pull|1|0|  14|PutIntKey|0|0|  15|Close|1|0|  16|Rewind|0|22|  17|Column|0|0|  18|Integer|3600|0|3600  19|Subtract|0|0|  20|Callback|1|0|  21|Next|0|17|  22|Halt|0|0|  
    result of this last query appears blank _2004-Jan-30 01:33:16 by anonymous:_ {linebreak} Here is my workaround:
     explain select timestamp - 3600 as 'timestamp' from rawlog order by timestamp desc limit 1 ;   0|ColumnName|0|0|timestamp 1|Integer|-1|0| 2|MemStore|0|1| 3|Integer|0|0| 4|OpenRead|0|3|rawlog 5|VerifyCookie|0|1537| 6|Integer|0|0| 7|OpenRead|1|4|pk_rawlog 8|Last|1|19| 9|RowKey|1|0| 10|IdxIsNull|0|18| 11|IdxRecno|1|0| 12|MoveTo|0|0| 13|MemIncr|0|19| 14|Column|0|0| 15|Integer|3600|0|3600 16|Subtract|0|0| 17|Callback|1|0| 18|Prev|1|9| 19|Close|0|0| 20|Close|1|0| 21|Halt|0|0| 
    ---- _2004-Jan-30 01:40:33 by drh:_ {linebreak} *: You will get much more pleasing code listings if you first execute *.explain* to set up the column formatting right. *: Any of the following should do what you want: SELECT max(timestamp-3600) FROM rawlog; SELECT max(timestamp)-3600 FROM rawlog; SELECT timestamp-3600 FROM rawlog ORDER BY timestamp DESC LIMIT 1; *: The following _should_ work but does not. This is a bug: SELECT * FROM (SELECT max(timestamp)-3600 FROM rawlog); ---- _2004-Jan-30 02:03:03 by drh:_ {linebreak} I see now. You are trying to get the optimizer to kick in and that only happens if min() or max() appear by themselves on an indexed column. Fair enough. Probably the optimizer should be a little smarter about these things, but for now I'll just fix the bug. ---- _2004-Sep-15 01:25:34 by anonymous:_ {linebreak} i just need to know the definition #c8c8c8 586 code closed 2004 Jan anonymous 2004 Jan 2 1 Memory allocation problem ? Hi, if sqlite can't allocate memory then sets sqlite_malloc_failed variable. The comment says that, if malloc only once fails that sqlite is unusable. Is that true ? What should I do in that case ? thx for help /* ** If malloc() ever fails, this global variable gets set to 1. ** This causes the library to abort and never again function. */ This is a question for the mailing list, not a bug. Works as designed. No changes to code. #c8c8c8 585 code closed 2004 Jan anonymous 2004 Jan 1 1 sqlite is not thread safe Hi, I just downloaded the latest version of sqlite. In documentation I've read that sqlite is thread safe. But in file util.c, linie 27 is declared the global variable: int sqlite_malloc_failed = 0; This is not thread safe for me. sqlite_malloc_failed variable is used in many parts of code. Could You comment this ? ps. sorry for my terrible english The only thing that can happen to the sqlite_malloc_failed variable is that it can get set to 1. After being set to 1, it is never set back to 0 again. This is threadsafe even outside of a mutex. #c8c8c8 584 new closed 2004 Jan anonymous 2004 Jan anonymous 5 1 Cursor support in SQLite hi I am using the sqlite vb wrapper in my application i need to know urgently if cursors are supported by sqlite and if yes how should i use it. This is a question for the mailing list. #cfe8bd 582 build fixed 2004 Jan anonymous 2004 Jan 4 3 no permission to execute install-sh The file install-sh has permissions -rw-rw-r--. On Solaris 5.6, using tcsh, it compiles but it doesn't install. Permissions should be -rwxrwxr--. #c8c8c8 581 code closed 2004 Jan anonymous Parser 2004 Jan 3 1 Failure for lemon.c to compile on MacOSX (fixed as well ;-)) Hi, When compiling on MacOSX 10.3.2 (Panther) I get the following error, In file included from ../tool/lemon.c:10: /usr/include/gcc/darwin/3.3/varargs.h:10:2: #error "GCC no longer implements ." /usr/include/gcc/darwin/3.3/varargs.h:11:2: #error "Revise your code to use ." I updated lemon.c to use stdargs as requested. First use of stdargs so I hope I got it right. The diff is small, [aid:~/tmp] aid% diff lemon-orig.c lemon.c 10c10 < #include --- > #include 73c73 < void ErrorMsg( /* char *, int, char *, ... */ ); --- > void ErrorMsg(char * filename, int lineno, char * format, ... ); 1105,1106c1105 < void ErrorMsg(va_alist) < va_dcl --- > void ErrorMsg(char * filename, int lineno, char * format, ... ) 1108,1110d1106 < char *filename; < int lineno; < char *format; 1119,1122c1115 < va_start(ap); < filename = va_arg(ap,char*); < lineno = va_arg(ap,int); < format = va_arg(ap,char*); --- > va_start(ap,format); All seems to compile now. Unfortantely I don't have another OS (eg. Linux) here to check if it is compatible. Regards, aid This is a duplicate of tickets #280 and #288. The problem was fixed by check-in [905] on 2003-Apr-15 for SQLite version 2.8.1. #c8c8c8 580 code closed 2004 Jan anonymous VDBE 2004 Jan 2 3 Incorrect Select when specifying same field value as column name Select statement gives incorrect results when specifying same field value as column name with the "=", "<", ">", "<>" operators. {linebreak} Test: {linebreak} sqlite> create table test (name varchar); {linebreak} sqlite> insert into test (name) values ("a"); {linebreak} sqlite> insert into test (name) values ("name"); {linebreak} sqlite> insert into test (name) values ("test1"); {linebreak} sqlite> insert into test (name) values ("test2"); {linebreak} sqlite> select * from test; {linebreak} a {linebreak} name {linebreak} test1 {linebreak} test2 {linebreak} {linebreak} sqlite> select * from test where name = "name"; {linebreak} a {linebreak} name {linebreak} test1 {linebreak} test2 {linebreak} {linebreak} sqlite> select * from test where name < "name"; {linebreak} (no results) {linebreak} {linebreak} sqlite> select * from test where name > "name"; {linebreak} (no results) {linebreak} {linebreak} sqlite> select * from test where name <> "name"; {linebreak} (no results) {linebreak} {linebreak} sqlite> select * from test where name like "name"; {linebreak} a {linebreak} name {linebreak} test1 {linebreak} test2 {linebreak} {linebreak} sqlite> select * from test where name like "name%"; {linebreak} name {linebreak} {linebreak} vdbe explain: {linebreak} sqlite> explain select * from test where name = "name"; {linebreak} 0|ColumnName|0|0|name {linebreak} 1|Integer|0|0| {linebreak} 2|OpenRead|0|3|test {linebreak} 3|VerifyCookie|0|276| {linebreak} 4|Rewind|0|11| {linebreak} 5|Column|0|0| *<===== ????!!!!* {linebreak} 6|Column|0|0| {linebreak} 7|StrNe|1|10| {linebreak} 8|Column|0|0| {linebreak} 9|Callback|1|0| {linebreak} 10|Next|0|5| {linebreak} 11|Close|0|0| {linebreak} 12|Halt|0|0| {linebreak} {linebreak} sqlite> explain select * from test where name like "name%"; {linebreak} 0|ColumnName|0|0|name {linebreak} 1|Integer|0|0| {linebreak} 2|OpenRead|0|3|test {linebreak} 3|VerifyCookie|0|276| {linebreak} 4|Rewind|0|12| {linebreak} 5|String|0|0|name% {linebreak} 6|Column|0|0| {linebreak} 7|Function|2|0|ptr(0x451f40) {linebreak} 8|IfNot|1|11| {linebreak} 9|Column|0|0| {linebreak} 10|Callback|1|0| {linebreak} 11|Next|0|5| {linebreak} 12|Close|0|0| {linebreak} 13|Halt|0|0| {linebreak} {linebreak} How to specify "name" is a value and not a column name? Also, any plans to implement sorting in a temp table on disk? (grouping consumes a lot of RAM with large recordsets. Strings in double-quotes (") resolve to column names if they can, then to string literals. Use single-quotes (') if you want the constant to always be a string literal. Works as designed. No changes to code. #c8c8c8 579 code closed 2004 Jan anonymous 2004 Jan 3 1 condition where sqlite_decode_binary will return -1 Hi. Others have reported that sometimes sqlite_decode_binary can fail. I understand it is not part of the official distribution, but I believe lots of people are using it. I had some data where I could reproduce this behavior, as sqlite_decode_binary was sometimes returning -1 after decoding the whole file. The strange part is that with EXACTLY the same data input it will fail sometimes, and not others. I can not explain the situation. Maybe it is caused by compiler optimizations and/or rounding in buffer allocation of the input stream? I saw this on Linux (Slackware 9) and also on Windows XP, always decoding the same data. Below is the revised version that catches this condition in my tests:
      /*original version until the next comment*/  int sqlite_decode_binary(const unsigned char *in, unsigned char *out){    int i, c, e;    int s = strlen(in);    e = *(in++);    i = 0;    while( (c = *(in++))!=0 ){      if( c==1 ){        c = *(in++);        if( c==1 ){          c = 0;        }else if( c==2 ){          c = 1;        }else if( c==3 ){          c = '\'';        }else{           /*here is the problem: it is possible to get here if the              length of your data is uneven and have c with a pixel              value of 0. See that it is not tested above. In my tests             when this happens is always at the end of the decoded             data , so I added the simple assignment below:*/           if (c==0){      return i;   }  /*below here is original code*/   return -1;        }      }      out[i++] = (c + e)&0xff;    }    return i;  }  
    Now, I am not sure if the problem is really here OR in the encoder, since it is strange that the last character in the data stream is 1, followed by a 0. Does the above makes sense to you? Contact me if you need more information. The fact is that with this fix I no longer get this condition, strange as it sounds. sqlite_decode_binary() returns -1 if it receives an ill-formed input string. This is by design. The change suggested above is rejected. If there is a problem here, the problem is with sqlite_encode_binary(). But without additional information (such as a string that sqlite_encode_binary() encodes incorrectly) there is nothing I can do to troubleshoot the problem. No changes to code. #cfe8bd 577 doc fixed 2004 Jan anonymous 2004 Jan 5 3 Typo on main SQLite home page There is a typo on the SQLite home page http://www.hwaci.com/sw/sqlite/ In the section Building From Source it says "Tha latter method is used for all official development" when it should say "The latter method is used for all official development". #cfe8bd 574 code fixed 2004 Jan drh 2004 Jan 1 1 ATTACH fails when invoked from sqlite_compile() The following command fails when invoked using sqlite_compile(). It works fine from sqlite_exec(): ATTACH DATABASE testDB as db; #f2dcdc 572 new active 2004 Jan anonymous Unknown 2004 Jan drh 3 3 sqlite 2.8.11 port to djgpp 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 #c8c8c8 571 code closed 2004 Jan anonymous Unknown 2004 Jan 1 1 Execution of comment via sqlite_step raise Access violation Execution of following script via sqlite_step raise Access violation: DROP TABLE products; --This comment raise exception Works fine when I try it. Probably what happened is that there is no table named "products" in your database. Your call to sqlite_compile() failed and set the VM pointer to NULL. If you did not to check for the error that sqlite_compile() returns and passed the NULL pointer into sqlite_step(), then the sqlite_step() function my segfault when it tries to dereference the NULL pointer. Unable to reproduce. No changes to code. #c8c8c8 570 event closed 2004 Jan anonymous 2004 Jan 5 5 database created on x86 can't work on arm The version of sqlite i am using is 2.8.6. I created the database on x86, then add some data into the database. It worked well on x86. But when i moved it onto the Intel Xscale 255 (also Linux), it returned error (no such table 'XXX') when read from the database. (comment by Justin Fletcher , not the original poster) I have transferred databases created on x86 linux by sqlite 2.8.6 and used them happily on RISC OS (ARM) using sqlite 2.8.9, so I don't personally believe that this is a specifically an ARM problem. ---- Perhaps some kind of NL->NLCR translate occurred when moving the database from one machien to the other. Did you verify the md5 checksum after the move to make sure the file had not changed? For whatever reason, I am unable to duplicate this problem. I've moved massive databases from big-endian to little-endian machines and back again without problems. #cfe8bd 569 code fixed 2004 Jan dougcurrie Pager 2004 Jan dougcurrie 3 3 Newer Cygwin (>1.50) doesn't want __CYGWIN_USE_BIG_TYPES__ In response to tickets #429 #349 #213 the lines if defined(__CYGWIN__) define __CYGWIN_USE_BIG_TYPES__ endif were added to os.h With recent versions of Cygwin these lines in os.h are causing warnings during compile, and aren't adding anything useful to SQLite. So, I am removing them. The Cygwin developers always advised against using __CYGWIN_USE_BIG_TYPES__ this way, and starting with version 1.50 of Cygwin the default is to use type long long for off_t anyway. See http://www.mail-archive.com/cygwin-apps@cygwin.com/msg06854.html #cfe8bd 567 code fixed 2004 Jan anonymous Unknown 2004 Jan 3 3 Erroneous test for rowid >= (fp number) in where clause This may be the same problem that was (partially) fixed under ticket #377. sqlite> select count(*) from stages; 3 sqlite> select rowid, stnum from stages where rowid >= 1.5;--Oops 1|1 2|2 3|3 sqlite> select rowid, stnum from stages where 1.5 <= rowid;--Oops 1|1 2|2 3|3 The condition for error seems to be that the operator be <= or >=, that the rowid be on the 'greater side' of the operator, and that the other operand be floating point. #f2dcdc 566 new active 2004 Jan anonymous Unknown 2004 Jan 4 4 [PATCH] Port of sqlite and lemon to an EBCDIC mainframe 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. #cfe8bd 565 code fixed 2004 Jan anonymous VDBE 2004 Jan 2 3 sqlite: src/vdbe.c:512: sqliteVdbeExec: Assertion `p->tos<=pc' failed. thats what I get:
      > sqlite weblog.db  SQLite version 2.8.10  Enter ".help" for instructions  sqlite> select id from requests where 'xx'IN ( select name from requests );  sqlite: src/vdbe.c:512: sqliteVdbeExec: Assertion `p->tos<=pc' failed.  Abgebrochen  
    the tble was build with CREATE TABLE requests ( id INTEGER primary key, name varchar(255)); I was unable to reproduce this from scratch with a little table. here is a gdb backtrace:
      Program received signal SIGABRT, Aborted.  0x15630cc1 in kill () from /lib/libc.so.6  (gdb) bt  #0  0x15630cc1 in kill () from /lib/libc.so.6  #1  0x15630a45 in raise () from /lib/libc.so.6  #2  0x15631fcc in abort () from /lib/libc.so.6  #3  0x15629f3b in __assert_fail () from /lib/libc.so.6  #4  0x1559d649 in sqliteVdbeExec (p=0x8077f58) at src/vdbe.c:4728  #5  0x1557bed0 in sqliteExec (pParse=0x3fffdb70) at src/build.c:97  #6  0x15590c16 in yy_reduce (yypParser=0x8077908, yyruleno=5) at parse.y:77  #7  0x15591067 in sqliteParser (yyp=0x8077908, yymajor=106, yyminor=        {z = 0x0, dyn = 0, n = 179949744}, pParse=0x0) at parse.c:3946  #8  0x15598f7c in sqliteRunParser (pParse=0x3fffdb70,      zSql=0x805d498 "select id from requests where 'xx' IN ( select name from requests );", pzErrMsg=0x3fffdc58) at src/tokenize.c:450  #9  0x1558a066 in sqliteMain (db=0x804d7d0,      zSql=0x805d498 "select id from requests where 'xx' IN ( select name from requests );", xCallback=0, pArg=0x0, pzTail=0x0, ppVm=0x0, pzErrMsg=0x3fffdc58)      at src/main.c:631  #10 0x1558a273 in sqlite_exec (db=0x804d7d0,      zSql=0x805d498 "select id from requests where 'xx' IN ( select name from requests );", xCallback=0x80494a0 , pArg=0x3fffdca0,      pzErrMsg=0x3fffdc58) at src/main.c:681  #11 0x0804b44a in process_input (p=0x3fffdca0, in=0x0) at src/shell.c:1038  ---Type  to continue, or q  to quit---  #12 0x0804bca1 in main (argc=2, argv=0x3ffff214) at src/shell.c:1329  
    Temporary workaround: select id from requests where 'xx'IN ( select name from requests WHERE NAME NOT NULL ); ^^^^^^^^^^^^^^^^^^^ The problem is fixed in CVS head. The workaround is only for those who have not updated. #f2dcdc 563 new active 2004 Jan anonymous Parser 2004 Jan 4 3 Support for autoincrement type "SERIAL" (from PostgreSQL) 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. #c8c8c8 562 code closed 2004 Jan anonymous Unknown 2004 Jan 2 3 System needs to rename duplicate named columns. If you execute a query with multiple columns and two or more of the columns resolve to the same column name it crashes the system. Ex: Select 1,1 Works fine on 2.8.9. #cfe8bd 561 code fixed 2004 Jan drh Pager 2004 Jan 1 1 Database corruption when using Linux threads Under Linux {quote: (RedHat 7.1 Kernel 2.4.7-10),} if multiple threads within the same process each do separate sqlite_open() calls to the same database then begin editing the database, the database can become corrupted. The problem appears to be a bug in Linux threads, not in SQLite. SQLite is doing everything correctly. Linux threads is not honoring file locks. You can see the problem with linux threads using the program in the first attachment (locktest1.c). Details on what this program does are available in the comments. In brief, you can see the malfunction if you compile this program and run it as follows: ./locktest1 ao ar bo bw bc bo bw The following is what this test does: 1: Thread A opens file "test.file" 2: Thread A gets a read lock on the file. 3: Thread B opens the same file 4: Thread B tries to get a write lock on the file. 5: Thread B closes the file 6: Thread B reopens the file 7: Thread B tries again to get a write lock on the file. The attempt by thread B to get a write lock on the file in step 4 fails, as it should. But the second attempt by B to get a write lock (step 7) succeeds. Step 7 should fail because thread A still has a read lock. From this test I conclude that file locking in linux threads is badly broken. Since SQLite uses file locking to maintain the integrity of the database, using SQLite under linux threads can lead to database corruption. The second attachment (locktest2.c) is the same program as locktest1 except that it runs separate processes instead of separate threads. Locktest2 appears to work. This leads me to believe that the problem is in the pthreads library, not in the linux kernel. Advice from the community on how to deal with this problem will be appreciated. In particular, I am looking for suggestions on how to work around the problem and reports of wheether or not the problem exists on other versions of linux. Please append your analysis and/or advice to the remarks section below. ------ _2004-Jan-11:_ {linebreak} It has now come to light that the analysis above is wrong. The problem is with SQLite - though it stems from a goofy API design for posix advisory locks. It turns out that when you close a file descriptor, all locks on the file of that file descriptor that were created by the current process are cleared. Even locks that had nothing to do with the file descriptor that was closed. So consider would what happen if you execute code like this: db = sqlite_open("test.db", 0, 0); sqlite_exec(db, "SELECT * FROM whatever", callback, 0, 0); Then in the callback you do this: db2 = sqlite_open("test.db", 0, 0); sqlite_exec(db2, "INSERT INTO whatever VALUES(1)", 0, 0, 0); sqlite_close(db2); The INSERT attempt will fail because the database is locked. But when the file descriptor closes after this failed insert attempt, all locks on the database file will be cleared, including the lock on the original database that is doing the SELECT. So the next time the callback is invoked (assuming the WHATEVER table contains two or more rows) there will be no locks, the INSERT will succeed. This will change the database out from under the SELECT, possibly leading to a segfault. In other scenarios, it could lead to a corrupt database. *: Slackware 9.0, Kernel 2.4.20 **kaw<~/c/threadlocktest>$ ./locktest1 ao ar bo bw bc bo bw A(03440) Open rc=5 A(03440) RdLock OK type=0 whence=0 start=0 len=0 pid=0 B(03441) Open rc=6 B(03441) WrLock Err=EAGAIN type=1 whence=0 start=0 len=0 pid=0 B(03441) Close rc=0 B(03441) Open rc=6 B(03441) WrLock OK type=1 whence=0 start=0 len=0 pid=0 **kaw<~/c/threadlocktest>$ ./locktest2 ao ar bo bw bc bo bw A(03445) Open rc=4 A(03445) RdLock OK type=0 whence=0 start=0 len=0 pid=0 B(03446) Open rc=5 B(03446) WrLock Err=EAGAIN type=1 whence=0 start=0 len=0 pid=0 B(03446) Close rc=0 B(03446) Open rc=5 B(03446) WrLock Err=EAGAIN type=1 whence=0 start=0 len=0 pid=0 ----- Resolution: {linebreak} Modified os.c so that calls to close() are embargoed until all locks on the file have cleared. #f2dcdc 560 warn active 2004 Jan anonymous 2004 Jan 4 4 Warnings on commpiling using Visual C++ 6.0 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:_ {linebreak} 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 ;-) #c8c8c8 559 code closed 2004 Jan anonymous Unknown 2004 Jan 1 1 Very slow insert into ... under Win2K The following code needs 40 secs for 1000 inserts. CPU usage in Task manager is alway in the range 0..5% !!! System: P4 2.66, 512 MB, Win2K, MS VC/C++ 6.0 SP5 void CTestDlg::OnTest() { sqlite *db; /* SQLITE.DLL VERSION 2.8.9 */ db = sqlite_open("d:\\test.dbl", 0, NULL); if (db) { int nErr = sqlite_exec(db, "create table data(one varchar(10), two smallint)", NULL, NULL, NULL); if (nErr == 0) { for (int n = 0; n < 1000; n++) { nErr = sqlite_exec(db, "insert into data values('hello!', 10)", NULL, NULL, NULL); if (nErr != 0) break; } } sqlite_close(db); } } This is an operating system problem, not an SQLite problem. Suggested workarounds: *: Enclose all INSERTs within BEGIN and COMMIT. *: Use "PRAGMA synchronous=off" #c8c8c8 557 code closed 2004 Jan anonymous Unknown 2004 Jan 3 1 sqlite_close SQLITE_MAGIC_ERROR reply. I dont understand why you want me to provide some code, I'm using the version 2.8.8 and i make a normal call to sqlite_close using the Dll. the if in bold always return true. So it never close the database. So keep eating memory each time i connect to a new database.

    I dont have make any change into the original code. i just notice this problem.

    void sqlite_close(sqlite *db){
       HashElem *i;
       int j;
       db->want_to_close = 1;
       if( sqliteSafetyCheck(db) || sqliteSafetyOn(db) ){
            /* printf("DID NOT CLOSE\n"); fflush(stdout); */
            return;
       }

    ........
    Ticket 554: sqlite_close SQLITE_MAGIC_ERROR
    I open a database using sqlite_close. and even if i call sqlite_close right after, the variable db->magic is already set to SQLITE_MAGIC_ERROR when entering the function. So the call to sqliteSafetyOn(db) always fails.
    do you have any clues ?
    thanks JP.
    Remarks:
    No clues.
    Because no code was provided, nothing can be done to troubleshoot. This ticket is therefore closed without action. It appears that sqlite_close() is being called while there are still outstanding VMs (VMs that have not been sent to sqlite_finalize()) or perhaps from callback of sqlite_exec(). sqlite_close() is doing the right thing, which is to make a notation to delete itself after all operations currently in progress complete. Works as designed. No changes to code. #c8c8c8 556 warn closed 2004 Jan anonymous CodeGen 2004 Jan 3 4 double to int warnings in date.c lot of double to int warnings in date.c why not use this
      long DateToJulian(int year, int month, int day)  {     if (month > 2) month -= 3; else { month += 9; year--; }       long ta = (146097L * (year / 100)) / 4;     long tb = (  1461L * (year % 100)) / 4;     long tc = (153L * month + 2) / 5 + day + 1721119L;       return (ta + tb + tc);  }    void JulianToDate(long j, int& year, int& month, int& day)  {     long x, y, d, m;       x  = 4 * j - 6884477L;     y  = (x / 146097L) * 100;     d  = (x % 146097L) / 4;     x  = 4 * d + 3;     y += (x / 1461);     d  = (x % 1461) / 4 + 1;     x  = 5 * d - 3;     m  = (x / 153) + 1;     d  = (x % 153) / 5 + 1;       month = (m < 11) ? (int) (m + 2) : (int) (m - 10);     day   = (int) d;     year  = (int) (y + m / 11);  }  
    There are two reasons for not using the code samples shown above: 1: The examples assume an integer julian day. Dropping the fractionaly part of the julian day number would loose the hours, minutes, and seconds. 2: The code above is C++. SQLite is written in C. #c8c8c8 555 code closed 2004 Jan anonymous VDBE 2004 Jan 1 1 sqlite_step and sqlite_compile cause locking problem I may just be mis-understanding how I am supposed to use the sqlite_step interfaces, but it makes little sense to me. (I am using visual C++ 6.0 to compile sqlite). Psudocode follows: #1 I open a connection to the database- pConnection = sqlite_open(sDBPath,0,NULL); #2 I compile a query into a vm: pConnection,"SELECT ROWID,* FROM test_table",&query_tail,&m_pVM,NULL); #3 Step through some records.... #4 Open another connection to the same database pConnection2 = sqlite_open(sDBPath,0,NULL); #5 try to update test_table using sqlite_exec -database_locked #6 try to update test_table using the first connection -database_locked if I finalize the vm- -sqliteok I am very curious over this - how is one supposed to use the step interface if at all times a vm is not finalized it locks the table? Any help would be greatly appreciated. Code works as documented and designed. Refer questions on operation to the mailing list. #c8c8c8 554 code closed 2004 Jan anonymous Unknown 2004 Jan 3 1 sqlite_close SQLITE_MAGIC_ERROR I open a database using sqlite_close. and even if i call sqlite_close right after, the variable db->magic is already set to SQLITE_MAGIC_ERROR when entering the function. So the call to sqliteSafetyOn(db) always fails. do you have any clues ? thanks JP. No clues. Because no code was provided, nothing can be done to troubleshoot. This ticket is therefore closed without action. #c8c8c8 553 code closed 2004 Jan anonymous Pager 2004 Jan 2 2 conversion error in compiling pager.c Excuse me if this is not a bug and I am doing something wrong. This is my first attempt at using SQLITE. I downloaded the source and when I tried to build in Metrowerks Code Warrior, version 4.2.5.766, I got the following error in pager.c: Error : illegal implicit conversion from 'int *' to 'unsigned int *' pager.c line 598 rc = read32bits(format, &pPager->jfd, &nRec); Since I am not a C programmer (yet), I did not try to fix it. I just commented out the line, and then everything went OK. But I suspect things will break with this line commented out. I don't know if it is allowed for me to comment on this, but if you cast to (u32*) it will compile. So the line would look like this: rc = read32bits(format, &pPager->jfd, (u32*)&nRec); Of course, nRec is an int, so I'm not sure how safe that cast really is. #cfe8bd 552 code fixed 2004 Jan drh 2004 Jan 1 1 Integer overflow results in database corruption Beginning with a new database, the following SQL results in a corrupt index, as shown by the final "integrity_check" line: CREATE TABLE t1(a INT UNIQUE); INSERT INTO t1 VALUES(-2147483649); PRAGMA integrity_check; The error does not occur if the value inserted is greater than -2147483648. The problem is a 32-bit integer overflow. greater. #cfe8bd 551 code fixed 2004 Jan anonymous Unknown 2004 Jan 3 3 Date/Time functions: some modifiers cause loss of h:m:s The modifiers 'weekday N', 'N months', and 'N years' cause loss of the time part of the datetime. sqlite> select datetime('now'); 2004-01-05 17:23:58 -- correct day and time of day sqlite> select datetime('now', 'weekday 0'); 2004-01-11 00:00:00 -- correct day, lost time of day sqlite> select datetime('now', '1 month'); 2004-02-05 00:00:00 -- correct day, lost time of day sqlite> select datetime('now', '1 year'); 2005-01-05 00:00:00 -- correct day, lost time of day #f2dcdc 550 new active 2004 Jan anonymous Unknown 2004 Jan anonymous 1 1 change of MASTER_NAME and TEMP_MASTER_NAME definition error 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 {quote: 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* {quote: vacuum.c} *: at line 293 in *int sqliteRunVacuum* *: at line 296 in *int sqliteRunVacuum* {quote: 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* #c8c8c8 549 code closed 2004 Jan anonymous Shell 2004 Jan 1 1 number of week change in wendesday/thursday i want search days in one week, but the weeks start on thursday...? This appears to be a question, not a bug report. #cfe8bd 548 code fixed 2004 Jan anonymous Parser 2004 Jan 3 3 SQLite will abort() when utf-8 character is invalid utf-8 support in SQLite will assert()/abort() when the utf-8 string is invalid. This is a severe problem when SQLite is used as PHP extension working with web server. Here is a work-around patch,
      Index: src/func.c  ===================================================================  RCS file: /sqlite/sqlite/src/func.c,v  retrieving revision 1.34  diff -c -r1.34 func.c  *** src/func.c 23 Dec 2003 02:17:35 -0000 1.34  --- src/func.c 28 Dec 2003 15:07:56 -0000  ***************  *** 123,134 ****      }    #ifdef SQLITE_UTF8      for(i=0; i	
    #c8c8c8	546	code	closed	2004 Jan	anonymous	Pager	2004 Jan		3	3	(Program received signal SIGSEGV) when sqlite_open()	  
      sqlites[0].db = sqlite_open( sqlites[0].dbname, 0, &(sqlites[0].errmsg) );    no malloc() to errmsg.    this full source no errors in Mac OS X.3  but 2 RedHat 7.3 machines make crash       strace    [pid  1941] getcwd("/work/root/board", 5000) = 17   [pid  1941] open("/work/root/board/board_1", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 7   [pid  1941] fstat64(7, {st_mode=S_IFREG|0644, st_size=11628544, ...}) = 0   [pid  1941] --- SIGSEGV (Segmentation fault) ---   [pid  1940] <... poll resumed> [{fd=5, events=POLLIN}], 1, 2000) = -1 EINTR (Interrupted system call)   [pid  1940] --- SIGRT_1 (Real-time signal 1) ---   [pid  1940] sigreturn()                 = ? (mask now ~[TRAP KILL STOP])   [pid  1940] getppid()                   = 1939   [pid  1940] wait4(-1, [WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV], WNOHANG|__WCLONE, NULL) = 1941   [pid  1940] munmap(0xbf600000, 2097152) = 0   [pid  1940] kill(1939, SIGSEGV)         = 0   [pid  1940] _exit(0)                    = ?   <... poll resumed> [{fd=3, events=POLLIN}], 1, 1000) = -1 EINTR (Interrupted system call)   --- SIGSEGV (Segmentation fault) ---   +++ killed by SIGSEGV +++         GDB result    [root@linux board]# gdb ./board   GNU gdb Red Hat Linux (5.2-2)   Copyright 2002 Free Software Foundation, Inc.   GDB is free software, covered by the GNU General Public License, and you are   welcome to change it and/or distribute copies of it under certain conditions.   Type "show copying" to see the conditions.   There is absolutely no warranty for GDB.  Type "show warranty" for details.   This GDB was configured as "i386-redhat-linux"...   (gdb) run   Starting program: /work/root/board/board   [New Thread 1024 (LWP 1914)]   [New Thread 2049 (LWP 1921)]   [New Thread 1026 (LWP 1922)]   THREAD START     Program received signal SIGSEGV, Segmentation fault.   [Switching to Thread 1026 (LWP 1922)]   0x4012802f in chunk_alloc () from /lib/libc.so.6   (gdb) bt   #0  0x4012802f in chunk_alloc () from /lib/libc.so.6   #1  0x401279d0 in malloc () from /lib/libc.so.6   #2  0x40092461 in sqliteMalloc (n=8462) at ./src/util.c:254   #3  0x4008540d in sqlitepager_open (ppPager=0x8a7833c, zFilename=0x804cfe8 "board_1", mxPage=2000, nExtra=280, useJournal=1) at ./src/pager.c:857   #4  0x4007001e in sqliteBtreeOpen (zFilename=0x804cfe8 "board_1", omitJournal=0, nCache=2000, ppBtree=0x8a7820c) at ./src/btree.c:711   #5  0x40083a61 in sqliteBtreeFactory (db=0x8a78200, zFilename=0x804cfe8 "board_1", omitJournal=0, nCache=2000, ppBtree=0x8a7820c) at ./src/main.c:1036   #6  0x40082d95 in sqlite_open (zFilename=0x804cfe8 "board_1", mode=0, pzErrMsg=0x804cc74) at ./src/main.c:447   #7  0x08049f79 in find_sqlite_pool ()   #8  0x080495b6 in query_cache_check ()   #9  0x08049528 in request_parse ()   #10 0x0804929f in proc ()   #11 0x40035f77 in pthread_start_thread () from /lib/libpthread.so.0   (gdb)       package info     [root@linux board]# rpm -qa | grep glibc   glibc-utils-2.2.5-44   glibc-2.2.5-44   glibc-common-2.2.5-44   glibc-debug-static-2.2.5-44   glibc-debug-2.2.5-44   glibc-kernheaders-2.4-7.16   glibc-devel-2.2.5-44   compat-glibc-6.2-2.1.3.2   glibc-profile-2.2.5-44   [root@linux board]# rpm -qa | grep gcc   gcc-chill-2.96-113   gcc-2.96-113   gcc-objc-2.96-113   gcc-java-2.96-113   gcc-c++-2.96-113   gcc-g77-2.96-113   [root@linux board]# cat /etc/redhat-release   Red Hat Linux release 7.3 (Valhalla)       threadsafe compiled, sqlites(sqlite db pool) global variable  
      	Diagnosis:    _: Some other part of the user's      program that is linking against     SQLite has corrupted the malloc() memory pool.     This is not a problem in SQLite - it is a problem     in the program that is calling SQLite.    Rational:    1: It is common for glibc to segfault inside chunk_alloc() after     memory corruption.  2: Hundreds or thousands of people are using sqlite_open() without     any problems.  3: The memory allocation system for SQLite is extensively      instrumented and tested with over 90% code coverage without     any hint of this problem.    No changes to code.
    #cfe8bd	545	code	fixed	2004 Jan	anonymous	BTree	2004 Jan		5	4	Use of uninitialized memory	While running "PRAGMA integriry_check"  with the following stack:      checkTreePage    fileBtreeIntegrityCheck    sqliteVdbeExec    sqliteExec    yy_reduce    sqliteParser    sqliteRunParser    sqliteMain    sqlite_exec    The following code increments a counter that was not initialized:       /* Update freespace totals.     */     pCheck->nTreePage++;   <---- BUG     pCheck->nByte += USABLE_SPACE - pPage->nFree; <--- BUG    The pCheck was allocated on stack:       char *fileBtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){       int i;       int nRef;       IntegrityCk sCheck;    and this specific member was not initialized.  maybe do memset to zero ?	The IntegrityCk.nTreePage and IntegrityCheck.nByte fields were never  used for anything so it matters not that they were uninitialized.  They have now been removed from the structure and the code identified  above as a "bug" has been removed.
    #f2dcdc	544	new	active	2004 Jan	anonymous		2004 Jan		5	4	Feature Request: Indicate UNIQUE columns in table_info.	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.	
    #cfe8bd	534	code	fixed	2003 Dec	anonymous		2004 Jan		2	2	possible bug in sqliteMalloc and sqliteMallocRaw	I think if you try to malloc 0 bytes you will get failure with the current implementations of sqliteMalloc and sqliteMallocRaw. If you turn on MEMORY_DEBUG, then you get sqliteMalloc_, and it has the following line:    if( n==0 ) return 0;    But that line is not in either sqliteMalloc and sqliteMallocRaw and so a 0-byte malloc will fail. I think this manifests itself if you try to create an in-memory database and then try to create a table in that database. A workaround appears to be to add the above line to both sqliteMalloc and sqliteMallocRaw.	
    #f2dcdc	369	code	active	2003 Jun	anonymous		2004 Jan		3	2	Testsuite fails on btree-1.1.1 (Mac OS X, SQLite 2.8.4)	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:_ {linebreak} 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).{linebreak} {linebreak} *:G3 700MHz/640MB iBook 10.2.8{linebreak} Same results as we last spoke.  Fails make test at:{linebreak} btree-1.1.1{linebreak} {linebreak} *:Dual G4 800MHz/1.25GB 10.2.8{linebreak} Same results as we last spoke.  Fails make test at:{linebreak}   btree-1.1.1{linebreak} {linebreak} *:G5 1.6GHz/1.25GB 10.3.2{linebreak} 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.
    #f2dcdc	93	new	active	2002 Jul	anonymous		2004 Jan		3	3	Can't open database when TEMP environment variable is not defined well	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.
    #cfe8bd	29	new	fixed	2002 Apr	anonymous		2004 Jan	drh	3	1	Enhancement of column data types in views	PRAGMA table_info on VIEWs should return the original type  information of those columns which are taken from tables  directly, e.g.      CREATE TABLE A(id integer PRIMARY KEY, name text);      CREATE TABLE B(id integer, descr text);      CREATE VIEW C AS SELECT A1.id AS id, A1.name AS name,      B1.descr AS descr FROM A A1, B B1 WHERE A1.id = B1.id;      PRAGMA table_info(C);    The last statement should return:      0|id|integer|0|   <-- currently the type is "text" for this column    1|name|text|0|    2|descr|text|0|	" ? " ' "
    #f2dcdc	833	todo	active	2004 Jul	anonymous	Unknown	2004 Jul		1	3	port of sqlite 2.8.15 to djgpp	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 	
    #f2dcdc	832	code	active	2004 Jul	anonymous	Unknown	2004 Jul	anonymous	4	4	os_win.c :: sqlite3OsUnlock() method has an unused variable: rc	os_win.c :: sqlite3OsUnlock() method has an unused variable: rc	
    #cfe8bd	831	code	fixed	2004 Jul	anonymous		2004 Jul		4	3	sqlite_mprintf("%q", "") returns random data	sqlite_mprintf("%q", ""); will return a random data due to buffers that are never \0 terminated, causing the copy to grab 1 random byte of memory.	_2004-Jul-27 13:18:59 by anonymous:_ {linebreak} The patch for the problem can be found here: {link: http://bb.prohost.org/sqlite.txt patch}  ---- _2004-Jul-27 13:29:35 by drh:_ {linebreak} Already reported and fixed.  See ticket #812.
    #c8c8c8	830	code	closed	2004 Jul	anonymous		2004 Jul		1	1	sqlite3_get_table() error	excuse me, but i'm french, and it is difficult for speak english !  when i execute sqlite3_get_table() fonction on windows xp, then an error "instruction privilégiée" (in english, "privileged instruction" or perhaps "supervisor instruction" (?))  thanks  Thierry	You didn't give us much information to go on. What was the context of the error. What SQL were you trying to execute. How did you open the database. Was the database initially empty? What was the database schema. Are you using C, C++, or some other language. Etc...  ---- _2004-Jul-27 14:34:55 by anonymous:_ {linebreak} some answers : i use C++, with wraper find at http://dev.int64.org/  My db was not empty when i try the function.  My query was very simply : select * from table.  Structure of my table : index_sp INTEGER PRIMARY_KEY ASC, famille TEXTE NOT NULL, [+ 14 column with TEXTE NOT NULL.]    I open database with sqlite3_open, and after try sqlite3_get_table.   Don't forget i am a newbie for c++, and it is possible my code is not good.    Finally, i try an other issue, and that is run.     Thank you for sqlite, it is a good tool. I use it for  ornithologiques observation for naturel park ( http://grandvoyeux.free.fr )    Thierry.
    #cfe8bd	829	code	fixed	2004 Jul	drh	CodeGen	2004 Jul	drh	1	1	VACUUM fails if there is a UNIQUE index	The VACUUM command does not work if the database being vacuumed contains a UNIQUE index.	
    #f2dcdc	828	warn	active	2004 Jul	anonymous	Unknown	2004 Jul		3	3	integer constants to long	when compiling sqlite3 on windows using msys/mingw I get the following warnings:  src/util.c: In function `sqlite3PutVarint':{linebreak} src/util.c:1022: warning: integer constant is too large for "long" type{linebreak} src/vdbe.c: In function `sqlite3VdbeExec':{linebreak} src/vdbe.c:2917: warning: integer constant is too large for "long" type{linebreak} src/vdbe.c:2924: warning: integer constant is too large for "long" type{linebreak} src/vdbeaux.c: In function `sqlite3VdbeSerialType':{linebreak} src/vdbeaux.c:1440: warning: integer constant is too large for "long" type{linebreak} src/vdbeaux.c:1440: warning: integer constant is too large for "long" type{linebreak}	_2004-Aug-30 16:06:52 by anonymous:_ {linebreak} I had the same problem in Solaris.  ---- _2004-Dec-09 09:31:46 by anonymous:_ {linebreak} 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 ){
    #cfe8bd	827	code	fixed	2004 Jul	anonymous	Unknown	2004 Jul		2	3	sub-select involving random() does not work	say, we have a song database containing some 1000 songs. Now if I want to retrieve 5 random songs from it:  First, using a sub-select statement which works fine with sqlite 2.x (tested with up to 2.8.14) but shows the following erroneous behaviour with 3.0.x (up to x=3 and cvs of 26.7.2004):  frank@moby:~> sqlite3 /tmp/music.db "select id from song where id in ( select id from song order by random(*) limit 5);"    1   2   3   4   5  From all those 1000s of IDs, we just get 1,2,3,4,5 which is not very random.   So let's see what the sub-select itself returns:  frank@moby:~> sqlite3 /tmp/music.db "select id from song order by random(*) limit 5;"    1212   271   65   2508   5232  Strange enough, random() itself works fine.  So let's be explicit:  frank@moby:~> sqlite3 /tmp/music.db "select id from song where id in ( '1212', '271', '65', '2508', '5232' );"    65   271   1212   2508   5232	
    #c8c8c8	825	code	closed	2004 Jul	anonymous		2004 Jul		3	3	lower(X) / upper(X) - not work correctly on non Latin characters	good solution for Win32 is using CharUpper/CharLower API calls instead toupper()/tolower()  Windows NT/2000 or later: To make the conversion, the function uses the language driver for the current language selected by the user at setup or by using Control Panel. If no language has been selected, the system completes the conversion by using internal default mapping. The conversion is made based on the code page associated with the process locale.  Windows 95/98/Me: The function makes the conversion based on the information associated with the user's default locale, which is the locale selected by the user at setup or by using Control Panel. The system does not have language drivers.	SQLite does not attempt to handle locale.  If you want an Upper/Lower function that works for your locale, you are welcomed to write your own and register it using the sqlite3_create_function() API.  ---- _2004-Jul-27 10:14:51 by anonymous:_ {linebreak} I sugges 90% of non-english users make those (add they own lower/upper implementations). Why not to include such common (and universal, based on win32API) functionality ?
    #f2dcdc	824	new	active	2004 Jul	anonymous	Unknown	2004 Jul		5	4	StrSum - new build-in aggreate function suggestion	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 :)	
    #f2dcdc	823	new	active	2004 Jul	anonymous	Unknown	2004 Jul		5	4	absent VERSIONINFO into any Win32 DLL	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:_ {linebreak} I have no idea what a VERSIONINFO resource is.  ---- _2004-Jul-26 15:19:14 by dougcurrie:_ {linebreak} 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
    #f2dcdc	822	code	active	2004 Jul	anonymous	Unknown	2004 Jul	drh	1	4	port of sqlite to dos with djgpp + small general bugfixes	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 	
    #c8c8c8	821	code	closed	2004 Jul	anonymous	BTree	2004 Jul		3	3	Allows string data on indexes INTEGER fields	Hi,  According to http://www.sqlite.org/lang.html#createtable, " However, if primary key is on a single column that has datatype INTEGER, then that column is used internally as the actual key of the B-Tree for the table. This means that the column may only hold unique integer values. (Except for this one case, SQLite ignores the datatype specification of columns and allows any kind of data to be put in a column regardless of its declared datatype.)"  However, I can insert string data into that table.    sqlite> BEGIN TRANSACTION;   sqlite> create table blech (f1 integer);   sqlite> commit; sqlite> BEGIN TRANSACTION; sqlite> insert into blech values (4); sqlite> insert into blech values (8); sqlite> insert into blech values ('5'); sqlite> insert into blech values ('ghmjym'); sqlite> commit; sqlite> BEGIN TRANSACTION; sqlite> create unique index x on blech (f1); sqlite> commit; sqlite> select * from blech; 4 8 5 ghmjym sqlite> BEGIN TRANSACTION; sqlite> insert into blech values ('ghmj'); sqlite> commit; sqlite> select * from blech; 4 8 5 ghmjym ghmj	_2004-Jul-25 15:24:44 by drh:_ {linebreak} F1 is an INTEGER, but it is not a primary key.
    #cfe8bd	818	doc	fixed	2004 Jul	anonymous		2004 Jul		4	3	The SQLite 3 API reference says "sqlite *" instead of "sqlite3 *"	For example, sqlite3_close is described as:  int sqlite3_close(sqlite *);  while sqlite3_open is:  int sqlite3_open(   const char *filename,   /* Database filename (UTF-8) */   sqlite3 **ppDb          /* OUT: SQLite db handle */ );  Shouldn't they both be sqlite3 *, as the sqlite3.h file actually declares them?	_2004-Jul-22 14:36:45 by anonymous:_ {linebreak} Also, some entry points use "db" as the arg name, and others use "pDb".
    #c8c8c8	817	new	closed	2004 Jul	anonymous		2004 Jul		4	2	Return size of blob	It would be usefull to know the size of a blob. So instead of:  const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);  An interface like:  int sqlite3_column_blob(sqlite3_stmt*, int iCol, const void **);  or:  const void * sqlite3_column_blob(sqlite3_stmt*, int iCol, int *);	_2004-Jul-21 13:42:45 by drh:_ {linebreak} sqlite3_column_bytes() returns the number of bytes in a BLOB. I'll improve the documentation to make this clear.
    #f2dcdc	816	doc	active	2004 Jul	anonymous	Unknown	2004 Jul		1	4	sqlite3_changes - absent in sqlitedll-3_0_2.zip	trying to make COM-Wrapper for SQLite in VC++ 6.0. can't find such entry point in any 3.x precompiled win32 dll	
    #f2dcdc	815	build	active	2004 Jul	anonymous		2004 Jul		2	1	SQLite3.dll exports	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	
    #cfe8bd	813	code	fixed	2004 Jul	anonymous		2004 Jul		2	4	LEFT OUTER JOIN give wrong result when an index is present	The following sql script shows that the same query gives different (I think wrong) results when an index is created, while looks good when the index is not there. A thing I noticed is that some different indexes can cause this problem while others don't (see the commented create index lines).      create table main (id int, key varchar(16));     insert into main values (0, 'AAA0');     insert into main values (1, 'AAA1');     insert into main values (2, 'AAA2');     insert into main values (3, 'AAA3');      create table temp (id int, name varchar(40), oid int);     insert into temp values (1, 'OLD', 1);     insert into temp values (1, 'NEW', 1);     insert into temp values (2, 'OLD', 2);     insert into temp values (3, 'NEW', 3);      create table atbl1 (id int, val varchar(10));     insert into atbl1 values (2, 'VAL2');     insert into atbl1 values (3, 'VAL3');      SELECT '################################ without index';     SELECT         main.key,         atbl1.val     FROM         main         LEFT OUTER JOIN atbl1 ON main.id = atbl1.id         LEFT OUTER JOIN temp ON main.id = temp.id     WHERE         temp.name = 'NEW';      CREATE UNIQUE INDEX idx_temp ON temp (name, id);    -- FAIL     --CREATE UNIQUE INDEX idx_temp ON temp (name, oid);   -- FAIL     --CREATE UNIQUE INDEX idx_temp ON temp (oid, name);   -- OK      SELECT '################################ with index';     SELECT         main.key,         atbl1.val     FROM         main         LEFT OUTER JOIN atbl1 ON main.id = atbl1.id         LEFT OUTER JOIN temp ON main.id = temp.id     WHERE         temp.name = 'NEW';      DROP INDEX idx_temp;      SELECT '################################ without index again';     SELECT         main.key,         atbl1.val     FROM         main         LEFT OUTER JOIN atbl1 ON main.id = atbl1.id         LEFT OUTER JOIN temp ON main.id = temp.id     WHERE         temp.name = 'NEW';  Actually I have different, much more complex queries giving spurious results, this one is the one I could strip down more, while still showing the problem, I hope a fix for this works also for the other.	_2004-Jul-19 18:31:08 by drh:_ {linebreak} A simpler test case:    create temp table t1(a integer, b varchar(10));   insert into t1 values(1,'one');   insert into t1 values(2,'two');   insert into t1 values(3,'three');   insert into t1 values(4,'four');    create temp table t2(x integer, y varchar(10), z varchar(10));   insert into t2 values(2,'niban','ok');   insert into t2 values(4,'yonban','err');    select 111,* from t1 left outer join t2 on t1.a=t2.x where t2.z='ok';   select 222,* from t1 left outer join t2 on t1.a=t2.x and t2.z='ok';      create index i2 on t2(z);   select 333,* from t1 left outer join t2 on t1.a=t2.x where t2.z='ok';  The 111 query returns 1 row and the 222 query returns 4 rows. PostgreSQL (which I will take as the gold standard) does the same. Query 333 is a repeat of 111 except that there is now an index on t2.z.  The result of 333 should be the same as 111 - one row. But instead it works like query 222 - four rows of result.
    #cfe8bd	812	code	fixed	2004 Jul	anonymous	Unknown	2004 Jul		3	3	sqlite_mprintf ("%s", "") - "%s" alone with empty string arg fails	The following code results a a string of garbage being returned:     char * ret;    ret = sqlite_mprintf ("%s", "");    printf ("%s\n", ret);  The basic problem is in printf.c.  Since the above never generates any output, vxprintf() never calls the text-consumer function.  This is mout() when called from base_vprintf(), and base_vprintf() relies on mout() appending the end-of-string null byte.  No null byte == garbage returned.  The following patch seemed to work for me:     --- printf.c.orig 2004-06-15 21:50:58.000000000 -0400    +++ printf.c 2004-07-17 12:01:45.875000000 -0400    @@ -227,6 +227,7 @@       int nsd;                   /* Number of significant digits returned */     #endif         +  (*func)(arg,"",0);       count = length = 0;       bufpt = 0;       for(; (c=(*fmt))!=0; ++fmt){    @@ -676,8 +677,8 @@       if( pM->zText && nNewChar>0 ){         memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);         pM->nChar += nNewChar;    -    pM->zText[pM->nChar] = 0;       }    +  pM->zText[pM->nChar] = 0;     }          /*	
    #cfe8bd	811	code	fixed	2004 Jul	drh		2004 Jul	drh	1	1	When ATTACH fails, strange things happen.	
     SQLite version 3.0.2 Enter ".help" for instructions sqlite> ATTACH DATABASE "/nodir/nofile.db" as at1; SQL error: unable to open database: /nodir/nofile.db sqlite> ATTACH DATABASE "/file.db" as at1; SQL error: database at1 is already in use sqlite> DETACH DATABASE at1; SQL error: no such database: at1 
    #c8c8c8 809 code closed 2004 Jul anonymous 2004 Jul 2 1 Sqlite also fetches the hooks Example query: SELECT DISTINCT(name) FROM tabel sqlite_fetch_array (PHP5) gives: (name) => "Someone" But expected: name => "Someone" _2004-Jul-15 12:59:49 by drh:_ {linebreak} When a column in a result set it an expression, SQLite returns the full text of that expression as the column name. If the parentheses are not desired, omit them from the query. Or use an AS clause to rename the result set column. #c8c8c8 808 code closed 2004 Jul anonymous Unknown 2004 Jul 1 1 Lower() function with UNICODE Lower() is with UNICODE not functional... _2004-Jul-15 12:57:57 by drh:_ {linebreak} A correct implementation for lower() for unicode is a large and tricky routine. And there is no consistently available library routine for lower() that SQLite can link against. Users who need a correct lower() behavior in SQL are likely to have a correct C-language implementation of lower() on hand, and can easily use the sqlite3_create_function() API to make that routine available as the lower() SQL function in SQLite. We have no intention of providing a full unicode-correct lower() routine in SQLite at this time. #cfe8bd 807 code fixed 2004 Jul anonymous VDBE 2004 Jul 1 3 Cannot run a prepared CREATE TABLE statement more than once *: Prepare a CREATE TABLE statement. (A CREATE INDEX would probably also cause the same problem.) *: Run it. *: DROP the table that was created. *: Reset the statement *: Run the statement again. A crash occurs the second time the statement is executed. This same bug probably also exists in version 2.8. #cfe8bd 806 code fixed 2004 Jul anonymous VDBE 2004 Jul 3 3 The maximum number of tables allowed in a join is 32. The following sql script works as I expected, it uses 32 tables. If the commented lines are uncommented, the query gives no result. Note that the same holds for plain joins (list of tables in the FROM clause and conditions in the WHERE clause) CREATE TABLE tbl00 (id integer, fld varchar(9)); CREATE TABLE tbl01 (id integer, fld varchar(9)); CREATE TABLE tbl02 (id integer, fld varchar(9)); CREATE TABLE tbl03 (id integer, fld varchar(9)); CREATE TABLE tbl04 (id integer, fld varchar(9)); CREATE TABLE tbl05 (id integer, fld varchar(9)); CREATE TABLE tbl06 (id integer, fld varchar(9)); CREATE TABLE tbl07 (id integer, fld varchar(9)); CREATE TABLE tbl08 (id integer, fld varchar(9)); CREATE TABLE tbl09 (id integer, fld varchar(9)); CREATE TABLE tbl10 (id integer, fld varchar(9)); CREATE TABLE tbl11 (id integer, fld varchar(9)); CREATE TABLE tbl12 (id integer, fld varchar(9)); CREATE TABLE tbl13 (id integer, fld varchar(9)); CREATE TABLE tbl14 (id integer, fld varchar(9)); CREATE TABLE tbl15 (id integer, fld varchar(9)); CREATE TABLE tbl16 (id integer, fld varchar(9)); CREATE TABLE tbl17 (id integer, fld varchar(9)); CREATE TABLE tbl18 (id integer, fld varchar(9)); CREATE TABLE tbl19 (id integer, fld varchar(9)); CREATE TABLE tbl20 (id integer, fld varchar(9)); CREATE TABLE tbl21 (id integer, fld varchar(9)); CREATE TABLE tbl22 (id integer, fld varchar(9)); CREATE TABLE tbl23 (id integer, fld varchar(9)); CREATE TABLE tbl24 (id integer, fld varchar(9)); CREATE TABLE tbl25 (id integer, fld varchar(9)); CREATE TABLE tbl26 (id integer, fld varchar(9)); CREATE TABLE tbl27 (id integer, fld varchar(9)); CREATE TABLE tbl28 (id integer, fld varchar(9)); CREATE TABLE tbl29 (id integer, fld varchar(9)); CREATE TABLE tbl30 (id integer, fld varchar(9)); CREATE TABLE tbl31 (id integer, fld varchar(9)); CREATE TABLE tbl32 (id integer, fld varchar(9)); INSERT INTO tbl00 VALUES (4, 'tbl00_4'); INSERT INTO tbl01 VALUES (4, 'tbl01_4'); INSERT INTO tbl02 VALUES (4, 'tbl02_4'); INSERT INTO tbl03 VALUES (4, 'tbl03_4'); INSERT INTO tbl04 VALUES (4, 'tbl04_4'); INSERT INTO tbl05 VALUES (4, 'tbl05_4'); INSERT INTO tbl06 VALUES (4, 'tbl06_4'); INSERT INTO tbl07 VALUES (4, 'tbl07_4'); INSERT INTO tbl08 VALUES (4, 'tbl08_4'); INSERT INTO tbl09 VALUES (4, 'tbl09_4'); INSERT INTO tbl10 VALUES (4, 'tbl10_4'); INSERT INTO tbl11 VALUES (4, 'tbl11_4'); INSERT INTO tbl12 VALUES (4, 'tbl12_4'); INSERT INTO tbl13 VALUES (4, 'tbl13_4'); INSERT INTO tbl14 VALUES (4, 'tbl14_4'); INSERT INTO tbl15 VALUES (4, 'tbl15_4'); INSERT INTO tbl16 VALUES (4, 'tbl16_4'); INSERT INTO tbl17 VALUES (4, 'tbl17_4'); INSERT INTO tbl18 VALUES (4, 'tbl18_4'); INSERT INTO tbl19 VALUES (4, 'tbl19_4'); INSERT INTO tbl20 VALUES (4, 'tbl20_4'); INSERT INTO tbl21 VALUES (4, 'tbl21_4'); INSERT INTO tbl22 VALUES (4, 'tbl22_4'); INSERT INTO tbl23 VALUES (4, 'tbl23_4'); INSERT INTO tbl24 VALUES (4, 'tbl24_4'); INSERT INTO tbl25 VALUES (4, 'tbl25_4'); INSERT INTO tbl26 VALUES (4, 'tbl26_4'); INSERT INTO tbl27 VALUES (4, 'tbl27_4'); INSERT INTO tbl28 VALUES (4, 'tbl28_4'); INSERT INTO tbl29 VALUES (4, 'tbl29_4'); INSERT INTO tbl30 VALUES (4, 'tbl30_4'); INSERT INTO tbl31 VALUES (4, 'tbl31_4'); INSERT INTO tbl32 VALUES (4, 'tbl32_4'); SELECT tbl00.fld ,tbl01.fld ,tbl02.fld ,tbl03.fld ,tbl04.fld ,tbl05.fld ,tbl06.fld ,tbl07.fld ,tbl08.fld ,tbl09.fld ,tbl10.fld ,tbl11.fld ,tbl12.fld ,tbl13.fld ,tbl14.fld ,tbl15.fld ,tbl16.fld ,tbl17.fld ,tbl18.fld ,tbl19.fld ,tbl20.fld ,tbl21.fld ,tbl22.fld ,tbl23.fld ,tbl24.fld ,tbl25.fld ,tbl26.fld ,tbl27.fld ,tbl28.fld ,tbl29.fld ,tbl30.fld ,tbl31.fld -- ,tbl32.fld FROM tbl00 LEFT OUTER JOIN tbl01 ON tbl00.id = tbl01.id LEFT OUTER JOIN tbl02 ON tbl00.id = tbl02.id LEFT OUTER JOIN tbl03 ON tbl00.id = tbl03.id LEFT OUTER JOIN tbl04 ON tbl00.id = tbl04.id LEFT OUTER JOIN tbl05 ON tbl00.id = tbl05.id LEFT OUTER JOIN tbl06 ON tbl00.id = tbl06.id LEFT OUTER JOIN tbl07 ON tbl00.id = tbl07.id LEFT OUTER JOIN tbl08 ON tbl00.id = tbl08.id LEFT OUTER JOIN tbl09 ON tbl00.id = tbl09.id LEFT OUTER JOIN tbl10 ON tbl00.id = tbl10.id LEFT OUTER JOIN tbl11 ON tbl00.id = tbl11.id LEFT OUTER JOIN tbl12 ON tbl00.id = tbl12.id LEFT OUTER JOIN tbl13 ON tbl00.id = tbl13.id LEFT OUTER JOIN tbl14 ON tbl00.id = tbl14.id LEFT OUTER JOIN tbl15 ON tbl00.id = tbl15.id LEFT OUTER JOIN tbl16 ON tbl00.id = tbl16.id LEFT OUTER JOIN tbl17 ON tbl00.id = tbl17.id LEFT OUTER JOIN tbl18 ON tbl00.id = tbl18.id LEFT OUTER JOIN tbl19 ON tbl00.id = tbl19.id LEFT OUTER JOIN tbl20 ON tbl00.id = tbl20.id LEFT OUTER JOIN tbl21 ON tbl00.id = tbl21.id LEFT OUTER JOIN tbl22 ON tbl00.id = tbl22.id LEFT OUTER JOIN tbl23 ON tbl00.id = tbl23.id LEFT OUTER JOIN tbl24 ON tbl00.id = tbl24.id LEFT OUTER JOIN tbl25 ON tbl00.id = tbl25.id LEFT OUTER JOIN tbl26 ON tbl00.id = tbl26.id LEFT OUTER JOIN tbl27 ON tbl00.id = tbl27.id LEFT OUTER JOIN tbl28 ON tbl00.id = tbl28.id LEFT OUTER JOIN tbl29 ON tbl00.id = tbl29.id LEFT OUTER JOIN tbl30 ON tbl00.id = tbl30.id LEFT OUTER JOIN tbl31 ON tbl00.id = tbl31.id -- LEFT OUTER JOIN tbl32 ON tbl00.id = tbl32.id WHERE tbl00.id = 4 ; #cfe8bd 805 code fixed 2004 Jul anonymous 2004 Jul 3 2 coalesce in the where clause doesn't work consider the query: select 1 where "234" <= "" return nothing as expected, however, select 1 where "234" <= coalesce("","0") return 1 (pls don't ask why I'm writing these queries, this is not the point) _2004-Jul-19 00:12:45 by drh:_ {linebreak} This has nothing to do with coalesce. The following statement also returns 1: SELECT 1 WHERE '234'<''; The reason is that the comparison operator is using numeric affinity. So the '234' string gets converted into an integer 234. But the '' string stays a string. And numbers are always less than strings. The question is: should the < operator in this context use numeric affinity, or should it be changed to use no affinity. ---- _2004-Jul-19 00:38:18 by drh:_ {linebreak} Decision is to change the comparison operators to use no affinity when the operands are both expressions. #cfe8bd 804 code fixed 2004 Jul anonymous 2004 Jul 1 1 sqliteStrNICmp() and sqliteStrICmp() return wrong value. sqliteStrNICmp() and sqliteStrICmp() return wrong value. For example sqliteStrNICmp("Family", "birthday") == -1 the statement: return *a - *b; should probably be: return UpperToLower[*a] - UpperToLower[*b]; see code below for details: util.c 502 int sqliteStrICmp(const char *zLeft, const char *zRight){ 503 register unsigned char *a, *b; 504 a = (unsigned char *)zLeft; 505 b = (unsigned char *)zRight; 506 while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; } 507 return *a - *b; 508 } 509 int sqliteStrNICmp(const char *zLeft, const char *zRight, int N){ 510 register unsigned char *a, *b; 511 a = (unsigned char *)zLeft; 512 b = (unsigned char *)zRight; 513 while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; } 514 return N<0 ? 0 : *a - *b; 515 } _2004-Jul-12 02:38:08 by anonymous:_ {linebreak} this might be better: return ((int)UpperToLower[*a]) - ((int)UpperToLower[*b]); ---- _2004-Jul-12 02:49:32 by anonymous:_ {linebreak} first line of bug report should read: sqliteStrNICmp() and sqliteStrICmp() return wrong value. For example sqliteStrICmp("Family", "birthday") < 0 ---- _2004-Jul-15 13:23:23 by drh:_ {linebreak} Thank you for reporting this. The problem is now fixed. Note that this is not a "real" problem in the sense that it does not make SQLite malfunction. SQLite uses these routines for equality testing only, and for that purpose they work fine as they are. #c8c8c8 803 new closed 2004 Jul anonymous Unknown 2004 Jul drh 1 1 sqlite3_create_function needs a userdata parameter In 2.x, create_function had a userdata parameter. In 3.x it hasn't. I absolutely need one for writing a 3.x compatible Python library. _2004-Jul-12 11:15:01 by drh:_ {linebreak} 5th parameter to sqlite3_create_function specifies user data. Function implementations can access the user data using the sqlite3_user_data() function. #f2dcdc 802 warn active 2004 Jul anonymous 2004 Jul anonymous 1 1 Unable to compile the sqlite - 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). #cfe8bd 800 todo fixed 2004 Jul anonymous VDBE 2004 Jul 3 3 Handling of NULLs by set function MIN has been changed to non-standard As a result of bug ticket #777, check-in [1679] changed the behavior of aggregate function MIN to be "consistent with" ORDER BY. MIN(C) now returns NULL if column (or expression) C is NULL for any row of the table -- the rationale being that SQLite sorts NULLs before all meaningful (not null) values. Trying to make MIN "consistent with" ORDER BY is a bad idea: *: it's contrary to the SQL-92 standard *: it's contrary to what all the major SQL DBMSs currently do *: it's contrary to what SQL engines have always done (even before the '92 std) MIN is intended to produce the smallest known value of a column or expression. NULL is not a known value; it's a place holder for a missing value. A return value of NULL from MIN is significant; it's supposed to indicate that the value requested cannot be calculated because the set being scanned (after removal of NULLs) is empty. In other words, it means that a column contains no data. In SQLite, after check-in [1679], a return of NULL could mean that, or it could just mean that there's missing data in one row. Consider another incompatibility this NULL return would introduce if other implementors adopted it. The standard says that MIN and MAX should be calculated, after removing NULLs, using the same comparison predicate that's used by ORDER BY, but that the position of NULLs after an ORDER BY is implementation dependent. Suppose another SQL implementor agreed that MIN and MAX should include NULLs and should be consistent with ORDER BY, but he chose to have NULLs collate after all meaningful values. Then his MAX would have to return NULL for the same data set where SQLite's MIN returns NULL. If a programmer has to have the non-standard behavior, the work-around is simple: select case when (select count(*) from t where c is null) = 0 then min(c) else null end AltMinC from t MIN should be changed back so that it eliminates NULLs before it tries to calculate the requested value; this is the standard behavior of all aggregate functions except COUNT(*). #c8c8c8 799 build closed 2004 Jul anonymous Unknown 2004 Jul 5 4 Missing exports in 3.0.2 Win32 DLL It would be nice to have a typedef for utf-16 support. For compilers that support the wchar_t type it could be defind as wchar_t* rather than the current void*. _2004-Jul-15 12:50:29 by drh:_ {linebreak} Some systems define wchar_t to be 32-bits, not 16-bits. We did an extensive search for what datatype to use for UTF-16 strings and found no solution that worked consistently across all compilers. That's why we ended up going with void*. #f2dcdc 798 code active 2004 Jul anonymous Unknown 2004 Jul 1 1 Unable to run tests on Tru64 bit Linux platform 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. #f2dcdc 797 new active 2004 Jul anonymous Parser 2004 Jul 4 3 require basic named subquery / WITH sql support 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 "" (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. #cfe8bd 794 new fixed 2004 Jul anonymous Unknown 2004 Jul 4 3 add API to report number of wildcards in sqlite3_prepare* Although sqlite3_prepare() et.al. support wildcard literals (parameter markers in ODBC speak) there's no API to programmatically determine the number of wildcards in the current SQL statement text. Proposal: /* ** Return the number of wildcard literals in the current ** SQL string given to sqlite3_prepare() and sqlite3_prepare16(). */ int sqlite3_bind_count(sqlite3_stmt *); Experimental API: sqlite3_bind_parameter_count(). #cfe8bd 791 code fixed 2004 Jul anonymous 2004 Jul 1 1 3.0.2 fails to build under Mingw
     dcorbit@DANNFAST /e/sqlite $ ./configure checking build system type... i686-pc-mingw32 checking host system type... i686-pc-mingw32 checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for a sed that does not truncate output... /bin/sed checking for egrep... grep -E checking for ld used by gcc... u:/mingw/mingw32/bin/ld.exe checking if the linker (u:/mingw/mingw32/bin/ld.exe) is GNU ld... yes checking for u:/mingw/mingw32/bin/ld.exe option to reload object files... -r checking for BSD-compatible nm... /mingw/bin/nm checking whether ln -s works... yes checking how to recognise dependent libraries... file_magic file format pei*-i386(.*architecture: i386)? checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... no checking dlfcn.h presence... no checking for dlfcn.h... no checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking for g77... g77 checking whether we are using the GNU Fortran 77 compiler... yes checking whether g77 accepts -g... yes checking the maximum length of command line arguments... 8192 checking command to parse /mingw/bin/nm output from gcc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking if gcc static flag  works... yes checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -DDLL_EXPORT checking if gcc PIC flag -DDLL_EXPORT works... yes checking if gcc supports -c -o file.o... yes checking whether the gcc linker (u:/mingw/mingw32/bin/ld.exe) supports shared libraries... yes checking whether -lc should be explicitly linked in... yes checking dynamic linker characteristics... Win32 ld.exe checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes configure: creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... u:/mingw/mingw32/bin/ld.exe checking if the linker (u:/mingw/mingw32/bin/ld.exe) is GNU ld... yes checking whether the g++ linker (u:/mingw/mingw32/bin/ld.exe) supports shared libraries... yes checking for g++ option to produce PIC... -DDLL_EXPORT checking if g++ PIC flag -DDLL_EXPORT works... yes checking if g++ supports -c -o file.o... yes checking whether the g++ linker (u:/mingw/mingw32/bin/ld.exe) supports shared libraries... yes checking dynamic linker characteristics... Win32 ld.exe checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes appending configuration tag "F77" to libtool checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for g77 option to produce PIC... -DDLL_EXPORT checking if g77 PIC flag -DDLL_EXPORT works... yes checking if g77 supports -c -o file.o... yes checking whether the g77 linker (u:/mingw/mingw32/bin/ld.exe) supports shared libraries... yes checking dynamic linker characteristics... Win32 ld.exe checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking for a BSD-compatible install... /bin/install -c Version set to 3.0.2 checking for gcc... (cached) gcc checking whether we are using the GNU C compiler... (cached) yes checking whether gcc accepts -g... (cached) yes checking for gcc option to accept ANSI C... (cached) none needed checking switches for the host compiler... -g -O2 checking target compiler... gcc checking switches on the target compiler... -g -O2 checking target linker... gcc checking switches on the target compiler... checking for ranlib... (cached) ranlib -g -O2 checking if host and target compilers are the same... yes checking whether to support threadsafe operation... no checking whether to support shared library linked as release mode or not... no checking whether to use an in-ram database for temporary tables... yes checking if executables have the .exe suffix... unknown checking for sin... yes checking for dlopen in -ldl... no checking for library containing Tcl_Init... -ltcl84 checking TCL header files... not specified: still searching... checking tcl.h usability... yes checking tcl.h presence... yes checking for tcl.h... yes checking for library containing tgetent... -ltermcap checking for readline in -lreadline... yes checking readline header files... not specified: still searching... checking readline.h usability... no checking readline.h presence... no checking for readline.h... no checking for /usr/include/readline.h... no checking for /usr/include/readline/readline.h... no checking for /usr/local/include/readline.h... no checking for /usr/local/include/readline/readline.h... no checking for /usr/local/readline/include/readline.h... no checking for /usr/local/readline/include/readline/readline.h... no checking for /usr/contrib/include/readline.h... no checking for /usr/contrib/include/readline/readline.h... no checking for /mingw/include/readline.h... no checking for /mingw/include/readline/readline.h... yes checking for usleep... no configure: creating ./config.status config.status: creating Makefile config.status: creating sqlite.pc  dcorbit@DANNFAST /e/sqlite $ make clean rm -f *.lo *.la *.o sqlite3.exe libsqlite3.la rm -f sqlite3.h opcodes.* rm -rf .libs .deps  rm -f lemon.exe lempar.c parse.* sqlite*.tar.gz rm -f  rm -f *.da *.bb *.bbg gmon.out rm -f testfixture.exe test.db rm -rf doc rm -f common.tcl rm -f sqlite3.dll sqlite3.lib  dcorbit@DANNFAST /e/sqlite $ make sed -e s/--VERS--/`cat ./VERSION`/ \                  ./src/sqlite.h.in >sqlite3.h echo '/* Automatically generated file.  Do not edit */' >opcodes.h grep '^case OP_' ./src/vdbe.c | \   sed -e 's/://' | \   awk '{printf "#define %-30s %3d\n", $2, ++cnt}' >>opcodes.h gcc -g -O2 -o lemon ./tool/lemon.c cp ./tool/lempar.c . cp ./src/parse.y . ./lemon parse.y ./libtool --mode=compile gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/attach.c mkdir .libs  gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/attach.c  -DDLL_EXPORT -DPIC -o .libs/attach.o  gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/attach.c -o attach.o >/dev/null 2>&1 ./libtool --mode=compile gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/auth.c  gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/auth.c  -DDLL_EXPORT -DPIC -o .libs/auth.o  gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/auth.c -o auth.o >/dev/null 2>&1 ./libtool --mode=compile gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/btree.c  gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/btree.c  -DDLL_EXPORT -DPIC -o .libs/btree.o  gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/btree.c -o btree.o >/dev/null 2>&1 ./libtool --mode=compile gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/build.c  gcc -g -O2 -DOS_WIN=1 -I. -I./src -DNDEBUG -c ./src/build.c  -DDLL_EXPORT -DPIC -o .libs/build.o ./src/build.c: In function `sqlite3OpenMasterTable': ./src/build.c:440: error: `OP_SetNumColumns' undeclared (first use in this function) ./src/build.c:440: error: (Each undeclared identifier is reported only once ./src/build.c:440: error: for each function it appears in.) ./src/build.c: In function `sqlite3StartTable': ./src/build.c:694: error: `OP_String8' undeclared (first use in this function) ./src/build.c: In function `sqlite3EndTable': ./src/build.c:1356: error: `OP_String8' undeclared (first use in this function) ./src/build.c:1377: error: `OP_Concat8' undeclared (first use in this function) ./src/build.c: In function `sqlite3DropTable': ./src/build.c:1667: error: `OP_String8' undeclared (first use in this function) ./src/build.c:1667: error: initializer element is not constant ./src/build.c:1667: error: (near initialization for `dropTable[1].opcode') ./src/build.c:1667: error: initializer element is not constant ./src/build.c:1667: error: (near initialization for `dropTable[1]') ./src/build.c:1668: error: initializer element is not constant ./src/build.c:1668: error: (near initialization for `dropTable[2]') ./src/build.c:1669: error: initializer element is not constant ./src/build.c:1669: error: (near initialization for `dropTable[3]') ./src/build.c:1670: error: initializer element is not constant ./src/build.c:1670: error: (near initialization for `dropTable[4]') ./src/build.c:1671: error: initializer element is not constant ./src/build.c:1671: error: (near initialization for `dropTable[5]') ./src/build.c:1672: error: initializer element is not constant ./src/build.c:1672: error: (near initialization for `dropTable[6].opcode') ./src/build.c:1672: error: initializer element is not constant ./src/build.c:1672: error: (near initialization for `dropTable[6]') ./src/build.c:1673: error: initializer element is not constant ./src/build.c:1673: error: (near initialization for `dropTable[7]') ./src/build.c:1674: error: initializer element is not constant ./src/build.c:1674: error: (near initialization for `dropTable[8]') ./src/build.c:1675: error: initializer element is not constant ./src/build.c:1675: error: (near initialization for `dropTable[9]') ./src/build.c:1676: error: initializer element is not constant ./src/build.c:1676: error: (near initialization for `dropTable[10]') ./src/build.c:1677: error: initializer element is not constant ./src/build.c:1677: error: (near initialization for `dropTable[11]') ./src/build.c:1678: error: initializer element is not constant ./src/build.c:1678: error: (near initialization for `dropTable[12]') ./src/build.c: In function `sqlite3CreateIndex': ./src/build.c:2159: error: `OP_String8' undeclared (first use in this function) ./src/build.c:2180: error: `OP_Concat8' undeclared (first use in this function) ./src/build.c:2188: error: `OP_SetNumColumns' undeclared (first use in this function) ./src/build.c: In function `sqlite3DropIndex': ./src/build.c:2288: error: `OP_String8' undeclared (first use in this function) ./src/build.c:2288: error: initializer element is not constant ./src/build.c:2288: error: (near initialization for `dropIndex[1].opcode') ./src/build.c:2288: error: initializer element is not constant ./src/build.c:2288: error: (near initialization for `dropIndex[1]') ./src/build.c:2289: error: initializer element is not constant ./src/build.c:2289: error: (near initialization for `dropIndex[2]') ./src/build.c:2290: error: initializer element is not constant ./src/build.c:2290: error: (near initialization for `dropIndex[3]') ./src/build.c:2291: error: initializer element is not constant ./src/build.c:2291: error: (near initialization for `dropIndex[4]') ./src/build.c:2292: error: initializer element is not constant ./src/build.c:2292: error: (near initialization for `dropIndex[5]') ./src/build.c:2293: error: initializer element is not constant ./src/build.c:2293: error: (near initialization for `dropIndex[6]') ./src/build.c:2294: error: initializer element is not constant ./src/build.c:2294: error: (near initialization for `dropIndex[7]') ./src/build.c:2295: error: initializer element is not constant ./src/build.c:2295: error: (near initialization for `dropIndex[8]') ./src/build.c: In function `sqlite3BeginTransaction': ./src/build.c:2490: error: `OP_AutoCommit' undeclared (first use in this function) ./src/build.c: In function `sqlite3CommitTransaction': ./src/build.c:2506: error: `OP_AutoCommit' undeclared (first use in this function) ./src/build.c: In function `sqlite3RollbackTransaction': ./src/build.c:2523: error: `OP_AutoCommit' undeclared (first use in this function) ./src/build.c: In function `sqlite3BeginWriteOperation': ./src/build.c:2590: error: `OP_Statement' undeclared (first use in this function) make: *** [build.lo] Error 1  dcorbit@DANNFAST /e/sqlite $ 
    _2004-Jul-02 04:46:28 by anonymous:_ {linebreak} I think there is no errors. you just did "make clean" after configure that deletes sqlite3.h. just do "make" after "configure". #c8c8c8 790 code closed 2004 Jul anonymous 2004 Jul 1 1 Missing include file for the SQLITE distribution 3.0.x The include file sqliteint.h references sqlite3.h The file sqlite3.h is not included anywhere in the distribution. _2004-Jul-02 01:15:24 by drh:_ {linebreak} The file sqlite3.h is automatically generated by the makefile. The template is sqlite.h.in. #cfe8bd 784 code fixed 2004 Jun anonymous 2004 Jul 2 2 SQLITE_OMIT_DATETIME_FUNCS code error with Microsoft compilers When SQLITE_OMIT_DATETIME_FUNCS is defined, a compiler error is generated because Microsoft compilers don't like zero sized array definitions. The affected file is "date.c", in the sqliteRegisterDateTimeFunctions function:
     --- date.c --------------------------------------------------------   void sqliteRegisterDateTimeFunctions(sqlite *db){     static struct {        char *zName;        int nArg;        int dataType;        void (*xFunc)(sqlite_func*,int,const char**);     } aFuncs[] = { * #ifndef SQLITE_OMIT_DATETIME_FUNCS *     { "julianday", -1, SQLITE_NUMERIC, juliandayFunc   }, *     { "date",      -1, SQLITE_TEXT,    dateFunc        }, *     { "time",      -1, SQLITE_TEXT,    timeFunc        }, *     { "datetime",  -1, SQLITE_TEXT,    datetimeFunc    }, *     { "strftime",  -1, SQLITE_TEXT,    strftimeFunc    }, * #endif     };     int i; --- date.c -------------------------------------------------------- 
    A quick fix is to extend #ifndef to englobe the function body, instead of just the array values, like this:
     --- date.c -------------------------------------------------------- void sqliteRegisterDateTimeFunctions(sqlite *db){ #ifndef SQLITE_OMIT_DATETIME_FUNCS   static struct {      char *zName;      int nArg;      int dataType;      void (*xFunc)(sqlite_func*,int,const char**);   } aFuncs[] = {     { "julianday", -1, SQLITE_NUMERIC, juliandayFunc   },     { "date",      -1, SQLITE_TEXT,    dateFunc        },     { "time",      -1, SQLITE_TEXT,    timeFunc        },     { "datetime",  -1, SQLITE_TEXT,    datetimeFunc    },     { "strftime",  -1, SQLITE_TEXT,    strftimeFunc    },   };   int i;    for(i=0; i  I believe this affects all Microsoft compilers, but only checked Microsoft Visual C++ .NET 2003 and embebed Visual C++ 3.0 (based on the VC++ 6.0 compiler).	
    #cfe8bd	768	code	fixed	2004 Jun	anonymous		2004 Jul	anonymous	1	2	3.0.0 alpha WHERE-AND evaluation	Hi SQLITE!  Had a test with 3.0.0 (alpha). Ran follwing SQL:    SELECT      *   FROM      Road      LEFT JOIN District ON District.ID = Road.DistrictID      LEFT JOIN City ON City.ID = Road.CityID      LEFT JOIN State ON State.ID = Road.StateID      LEFT JOIN Country ON Country.ID = Road.CountryID   WHERE      Road.Name LIKE 'elster%'      AND City.Name LIKE 'berlin%'   ORDER BY Road.Name, City.Name, District.Name  Result is all roads starting with "elster" but in all cities. The "AND City.Name LIKE 'berlin%'" was ignored.  Swap the both WHERE-parts and you will get all streets in cities starting with "berlin", but the "AND Road.Name LIKE 'elster%'" will be ignored.  Seems that evaluation of WHERE-AND-clause is wrong.  Need more? Let know! Good Luck!	This appears to be the same situation as ticket #813, which has now been fixed.
    #cfe8bd	758	code	fixed	2004 Jun	anonymous	Shell	2004 Jul		1	1	Incorrect return value form strftime %W	SELECT strftime('%W', '2004-06-02');{linebreak} Prints 22{linebreak} (2004-06-02 was Wednesday){linebreak} {linebreak} SELECT strftime('%W', '2004-06-03');{linebreak} Prints 23{linebreak} (2004-06-03 was Thursday){linebreak} {linebreak} This is because 1.1.2004 was Thursday.{linebreak} The problem is that week of year are counted from 1st day of year instead of 1st monday of year.	
    #cfe8bd	756	code	fixed	2004 Jun	anonymous		2004 Jul		2	3	Core Dump - Select From View	The following causes an assertion fault:    CREATE TABLE t1('9' text);   CREATE VIEW v1 AS SELECT a."9" FROM t1 a;   SELECT * FROM v1;	_2004-Jun-09 10:48:44 by drh:_ {linebreak} This is a real bug.  But it is easy to work around - choose sensible column names that do not require quoting.
    #c8c8c8	750	code	closed	2004 May	anonymous	Unknown	2004 Jul		2	3	copy command does not work with existing table	Create a table with a "create table" command. Use pg_dump -a command to create a dump of the data, and edit out all but the actual data (no other SQL commands). This will be a tab-delimited one-per-line set of records. SQLite docs say that the copy command works on an existing table, and is designed specifically to understand pg_dump output. When you issue the copy command as: "copy mytable from mydump" or "copy mytable from mydump using delimiters tab" via the C function sqlite_exec(), SQLite issues the error message that "table mytable already exists" and will not copy the data. The workaround is to use "insert" commands, which is probably a lot slower.	_2004-May-30 20:51:35 by anonymous:_ {linebreak} THIS BUG REPORT IS BOGUS. MY APOLOGIES. It was a coding mistake on my part. Again, apologies.
    #cfe8bd	749	code	fixed	2004 May	anonymous	CodeGen	2004 Jul		2	1	SELECT DISTINCT with LIMIT	  CREATE TABLE search (Word varchar(50),Page varchar(250);   INSERT INTO search VALUES ('word1','page_1');   INSERT INTO search VALUES ('word2','page_1');   INSERT INTO search VALUES ('word3','page_2');   INSERT INTO search VALUES ('word4','page_2');   SELECT DISTINCT Page FROM search LIMIT 0,2  The result is "page_1" but I think that results must be page_1,page_2 because of LIMIT 0,2  This means that SELECT makes LIMIT before DISTINCT	
    #c8c8c8	722	code	closed	2004 May	anonymous	VDBE	2004 Jul	drh	2	1	long long format specifier in sqlite_exec_printf missing	sqlite_exec_printf and friends not not handle 64 bit longs - i.e. lack the "llu" or "I64u" format specifier.  This makes it quite harder and uglier to put 'long long's into the database on 32 bit platforms. At the moment the hack is:     --- static char ts1[64]; memset(ts1, 0, 64); snprintf(ts1, 64, "%llu", l); // llu does not work below char* foo = sqlite_mprintf("select * from foo where bar=%q;", ts1); printf("%s\n", foo); ---  which does the trick. Note the above is testing code, not production, which uses %Q,%q,%d and sqlite_exec_printf().  This could probably be fixed by adding the printf implementation up to date.	_2004-May-05 19:23:05 by anonymous:_ {linebreak} Me again, quick note: while in 64bit mode (linux fedora core 1 x86_64 gcc 3.3.2), using "%ld" or "%lu" works fine of course, since sizeof(long)=sizeof(long long)=8.  In 32 bit mode however, "%ld" truncates to 32 bit.  Should it matter in any way, I'm using long long to store timestamps (milliseconds since 1/1/1970 - like System.currentTimeMillis(), but in C++).  Thanks & regards, great job.  ---- _2004-Jul-19 02:27:24 by drh:_ {linebreak} I consider this a new feature request.  It has been implemented in version 3.0.
    #cfe8bd	713	code	fixed	2004 Apr	anonymous	Unknown	2004 Jul	drh	3	3	Compiling with SQLITE_OMIT_DATETIME_FUNCS causes error	Compiling with the SQLITE_OMIT_DATETIME_FUNCS define causes the following error in date.c:  _:date.c(863) : error C2059: syntax error : '}'  Essentially the } bracket should be before the #endif.	_2004-Apr-28 00:40:44 by anonymous:_ {linebreak} On second thought, the #ifdef is all messed up, I just made it wrap the entire contents of the sqliteRegisterDateTimeFunctions function, as none of the code is needed. In any case, it's better just to remove the data.c file if one is not going to use the functions.
    #cfe8bd	708	code	fixed	2004 Apr	anonymous	Unknown	2004 Jul	rdc	4	1	nonASCII Upper & Lower	Please, change "char *z;" in upperFunc and lowerFunc to "unsigned char *z;".  I use setlocale("russian") and some symbols not converted (lower or upper). After adding "unsigned " all works fine.	
    #cfe8bd	705	code	fixed	2004 Apr	anonymous	Parser	2004 Jul		3	3	can't handle special char in column name	  $ sqlite :memory:   SQLite version 2.8.13   Enter ".help" for instructions   sqlite> create table mytab (#col_a);   sqlite: ./src/main.c:635: sqlite_exec: Assertion `pVm==0 || sqlite_malloc_failed' failed.   Aborted   $	_2004-Jul-20 00:29:17 by drh:_ {linebreak} Unable to reproduce.  Perhaps the problem has already been fixed.
    #cfe8bd	703	code	fixed	2004 Apr	anonymous		2004 Jul		3	3	Aggregate functions (min/max) fail over sub-queries	Computing min,max of (negative) numeric values from a "union all" subquery generates incorrect results.  I have included a shell script which reproduces the problem.	_2004-Apr-23 22:02:48 by anonymous:_      create table t (x int);     insert into t values (-1);     insert into t values (-2);     insert into t values (-3);     insert into t values (-4);     insert into t values (-5);      create table t2 (x int);     insert into t2 values (-1);     insert into t2 values (-2);     insert into t2 values (-3);     insert into t2 values (-4);     insert into t2 values (-5);      select min(x),max(x) from t;     select min(x),max(x) from t2;     select min(x), max(x) from      (         select x from t     );     select min(x), max(x) from      (         select x from t2     );     select min(x), max(x) from      (         select x from t         union all         select x from t2     );  Results in:      -5|-1     -5|-1     -5|-1     -5|-1     -1|-5  ---- _2004-Apr-23 23:17:59 by drh:_ {linebreak} The problem here is that the result of the UNION ALL is being interpreted as type TEXT instead of as type NUMERIC.  And for TEXT, '-1' really is the minimum and '-5' really is the maximum.  Believe it or not, this is the same bug as #521 - "create as select" does not preserve datatypes.  The work around is like this:    select min(x+0), max(x+0) from   (     select x from t     union all     select x from t2   );  The "+0" after the "x" in causes the types to become NUMERIC which makes min() and max() behave as you expect.  ---- _2004-Apr-23 23:37:53 by anonymous:_ {linebreak} Thanks for the workaround!
    #c8c8c8	702	code	closed	2004 Apr	anonymous		2004 Jul		3	3	Bug in sorting: some strings sort in the middle of numerical values	This shows a bug in SQLite The doc says strings sort before numbers. I entered some values into a simple table with just one column, named int.  Generally the values with leading spaces, or leading dashes, as treated as a string.  But they sort in the middle of the numbers.  The fact that they land in the middle of the two values of 13 is also a problem.  (I think that oen of them was inserted with trailing space.)    sqlite> select * from t order by int;   1   1   9   11   13      13      13.0001   --11   13   13.0   13.00001   a11   a9   sqlite>	_2004-Apr-23 23:10:01 by drh:_ {linebreak} Unable to reproduce.  When I enter the values shown above into a simple table and do a SELECT with an ORDER BY, they come out in the correct order.  Note, however, that if there are trailing spaces on the second '13' and on the '13.0' and "13.000001' then the order is as shown.  Are you sure that there are not trailing spaces on your numbers?  ---- _2004-Jun-02 23:22:16 by anonymous:_ {linebreak} "order by int" might be your problem cause "int" is a data type?? maybe: order by `int` ?
    #cfe8bd	687	code	fixed	2004 Apr	anonymous		2004 Jul		4	2	Sqlite incorrectly handles invalid filenames.	When opening an invalid filename, which is resolved to a directory or a directory directly, sqlite_open() fails to return error instead pretends to have opened the directory for read. The patch below adds a check on open failure that prevents this from happening.  {link: http://ilia.ws/stuff/sq.txt}	
    #cfe8bd	686	code	fixed	2004 Apr	anonymous		2004 Jul		2	3	select + indexes + left join + "in (set)" causes core dump	The following SQL code causes a core dump on SqLite 2.8.13 on FreeBSD 4.9.  With the older SqLite 2.8.11, it caused a run time error message, but not a core dump.  I do not know whom to assign this to.  This may a VDBE subsystem error, as an assertion is failed in vdbe.c, resulting in a core dump.  I do not know what the VDBE subsystem does.  Thanks for supporting SqLite!  Please contact me if you have any questions.  -Matthew    -------- begin test.sql --------      -- drop, then recreate the tables      drop table TableA;   drop table TableB;      create table TableA (id integer, ta0 text);   create unique index TableA_index on TableA (ta0);      create table TableB (tb0 integer, id integer);   create unique index TableB_index on TableB (tb0, id);      -- insert some data      insert into TableA values (1,9);   insert into TableA values (2,2);   insert into TableA values (3,3);   insert into TableA values (4,4);   insert into TableA values (5,5);   insert into TableA values (6,6);      insert into TableB values (7,1);      -- this select does not generate an error.   select distinct TableA.id, TableB.tb0 from TableA left join TableB on (TableA.id = TableB.id) where (tb0 = 7) order by ta0;      -- this semantically identical select will core dump with sqlite 2.8.13 on FreeBSD   select distinct TableA.id, TableB.tb0 from TableA left join TableB on (TableA.id = TableB.id) where (tb0 in (7)) order by ta0;      -------- end test.sql --------  Here is what it looks like when I run it:    [user@host dir]$ sqlite test.db   SQLite version 2.8.13   Enter ".help" for instructions   sqlite> .read test.sql   2|   3|   4|   5|   6|   1|7   2|   assertion "pSet->prev" failed: file "./src/vdbe.c", line 4698   Abort trap (core dumped)	Same as #813.
    #cfe8bd	683	code	fixed	2004 Apr	anonymous	Unknown	2004 Jul		1	1	Impossible to drop index with single quotes in the name	After creating an index with the command     CREATE INDEX 'myIndex' ON 'myTable' (myColumn);  the index can't be dropped with either    DROP INDEX myIndex;  or    DROP INDEX 'myIndex';  An index created in SQLite 2.7.5 with single quotes in its name will appear in SQLITE_MASTER without the quotes, but SQLite 2.8.13 still can't DROP it.	_2004-Apr-01 14:11:24 by drh:_ {linebreak} Work-around:     DROP INDEX ['myIndex']  ---- _2004-Jul-20 00:32:31 by drh:_ {linebreak} Fixed in 3.0
    #cfe8bd	680	code	fixed	2004 Mar	anonymous	Parser	2004 Jul		3	3	Parser fails on quoted table/alias DOT STAR	
     sqlite> create table product (id integer); sqlite> insert into product values(1); sqlite> select "product"."id" from "product"; 1 sqlite> select product.* from product; 1 sqlite> select "product".* from "product"; SQL error: no such table: "product" 
    The last statement should produce the same result as the last but one. I suspect somewhere in the "*" expansion code is a call to dequote the table name missing. _2004-Apr-18 09:09:03 by anonymous:_ {linebreak} Following patch against 2.8.13 seems to work: diff -ur sqlite.orig/src/select.c sqlite/src/select.c --- sqlite.orig/src/select.c 2004-03-02 19:37:41.000000000 +0100 +++ sqlite/src/select.c 2004-04-17 20:21:25.000000000 +0200 @@ -952,14 +952,25 @@ for(i=0; inSrc; i++){ Table *pTab = pTabList->a[i].pTab; char *zTabName = pTabList->a[i].zAlias; + char *zTabName2 = 0; + int zTabName2Len; if( zTabName==0 || zTabName[0]==0 ){ zTabName = pTab->zName; } - if( pName && (zTabName==0 || zTabName[0]==0 || - sqliteStrNICmp(pName->z, zTabName, pName->n)!=0 || - zTabName[pName->n]!=0) ){ + if( pName ){ + zTabName2 = sqliteTableNameFromToken(pName); + if( zTabName2 ){ + zTabName2Len = strlen(zTabName2); + } + } + if( zTabName2 && (zTabName==0 || zTabName[0]==0 || + sqliteStrNICmp(zTabName2, zTabName, zTabName2Len)!=0 || + zTabName[zTabName2Len]!=0) ){ continue; } + if( zTabName2 ){ + sqliteFree(zTabName2); + } tableSeen = 1; for(j=0; jnCol; j++){ Expr *pExpr, *pLeft, *pRight; #c8c8c8 678 code closed 2004 Mar anonymous Unknown 2004 Jul anonymous 1 1 Group by only returning one row when source table is sub-query or view Try this query select tbl_name from sqlite_master group by tbl_name Now try this query select tbl_name from (select * from sqlite_master) group by tbl_name The same results should be displayed but only one row is displayed. This also affects group by when using a view _2004-Jul-20 00:31:22 by drh:_ {linebreak} GROUP BY only works when you have aggregate functions. #cfe8bd 655 code fixed 2004 Mar anonymous VDBE 2004 Jul 1 3 Numeric/string confusion with "in" "_number_ in (_number-list_)" uses string comparisons, which can lead to invalid results. Example: select 1 where 1 in (1); (outputs 1) select 1 where 1 in (01); (no output; should output 1!) select 1 where 01 in (1); (no output, wrong) select 1 where 01+0 in (1); (outputs 1) #cfe8bd 521 code fixed 2003 Dec anonymous Unknown 2004 Jul 2 1 "create as select ..." does not preserve datatypes Subject says it all. This problem effectively rendres "create as select" useless, because every "create as select" needs to be examined by hand for datatypes involved and replaced by "create table ..." and 'insert into ... select ...". Is it possible to preserve datatype information for selects that does not involve expressions in "select" and only select whole columns? Here is transcript from sqlite session that shows problem: SQLite version 2.8.6 Enter ".help" for instructions sqlite> create table zzz (col1 text, col2 text); sqlite> create table ttt as select * from zzz; sqlite> .schema CREATE TABLE ttt(col1,col2); create table zzz (col1 text, col2 text); Notice datatypes for "ttt" Fixed in version 3.0 #f2dcdc 239 new active 2003 Feb anonymous Unknown 2004 Jul 4 2 ANSI/Unicode(Wide) version file-handling functions for Win32 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,{linebreak}{linebreak} int sqliteOsDelete(const char *zFilename){{linebreak} #if OS_UNIX{linebreak} unlink(zFilename);{linebreak} #endif{linebreak} #if OS_WIN{linebreak} DeleteFile(zFilename);{linebreak} #endif{linebreak} #if OS_MAC{linebreak} unlink(zFilename);{linebreak} #endif{linebreak} return SQLITE_OK;{linebreak} }{linebreak}{linebreak} DeleteFile in this function is replaced with DeleteFileW, the unicode version of DeleteFile, which takes Unicode string(wide characters) as an argument.{linebreak} 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:{linebreak}{linebreak} DeleteFile -> DeleteFileA{linebreak} GetFileAttributes -> GetFileAttributesA{linebreak} CreateFile -> CreateFileA{linebreak} GetFullPathName -> GetFullPathNameA{linebreak} GetTempPath -> GetTempPathA{linebreak}{linebreak} 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{linebreak} #define DeleteFile DeleteFileW{linebreak} #else{linebreak} #define DeleteFile DeleteFileA{linebreak} #endif // !UNICODE{linebreak} 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:_ {linebreak} 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. #cfe8bd 789 code fixed 2004 Jun anonymous 2004 Jun 1 1 the 'LL' qualifier is not supported by MSVC hello, in vdbe.c the new 'LL' qualifier are not recognised by MSVC in contrast (for example source util.c) gcc understands the qualifierer 'ULL' (if( v & 0xff00000000000000ULL ) #c8c8c8 788 build closed 2004 Jun anonymous TclLib 2004 Jun 1 1 3.0.1 make test failure/death on Mac OS X 10.2.8 Okay, I'm sending a copy of my mailing list message here too. I tried downloading and compiling "sqlite-3.0.1.tar.gz" today on my Mac OS X 10.2.8 machine, for the first time. (Sorry I didn't get to trying this earlier, but it is before the end of June.) If it helps, I'm using GCC version 3.1, from a December 2002 developer package. I did the usual procedure: - configure - make - make test The first two were verbose but I didn't detect any errors. However, part way through its tests, "make test" died with the following errors: ld: Undefined symbols: _Tcl_GetWideIntFromObj _Tcl_NewWideIntObj make: *** [testfixture] Error 1 Prior to this, it printed out around 70 instances of warnings, all of which said the following or something similar: warning: passing arg 2 of `Tcl_GetInt' discards qualifiers from pointer target type Note that simply invoking ./sqlite3 after this point does run the program, though I didn't do anything there other than .help and .quit. I'm afraid that I'm not at the moment experienced enough in C programming to search for the cause of this problem. Note that just before this I tested my environment with "sqlite-2.8.14.tar.gz" using the same procedure, and "make test" ran through to completion, though it reported exactly 1 error. That binary likewise ran for the quick .help and .quit. 1 errors out of 28969 tests Failures on these tests: format3-11.3 make: *** [test] Error 1 Let me know if you need more information, or whether I should use the bug reporting interface on the web site instead of telling you about this on the sqlite mailing list. One more thing: your README file, for both 2.8.14 and 3.0.1, says this: The linux binaries on the website are created using the generic makefile, not the configure script. The configure script is unmaintained. (You can volunteer to take over maintenance of the configure script, if you want!) However, the file stamp for "configure" is 2004.06.22 in the latter version, and a corresponding earlier date in the earlier version. So it looks like it in fact is being maintained. So is that readme file out of date on this matter? _2004-Jun-30 15:05:34 by drh:_ {linebreak} The TCL interface requires TCL version 8.4. The core SQLite library does not require TCL, but TCL 8.4 is required to run the tests. #cfe8bd 785 code fixed 2004 Jun anonymous 2004 Jun 1 1 local variable 'db' used without having been initialized function: sqlite3VdbeFinalize() vdbeaux.c(1325) : warning C4700: local variable 'db' used without having been initialized #f2dcdc 783 code active 2004 Jun anonymous Unknown 2004 Jun 3 3 Build on MAC with -DSQLITE_DEBUG=1 compile error 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 #c8c8c8 781 code closed 2004 Jun anonymous Unknown 2004 Jun 4 4 unable to run malloc test even with -DMEMORY_DEBUG MacOS 10.3.4 gcc 3.3 Cannot run malloc test. -DMEMORY_DEBUG does not cause any new code to be generated for malloc test to be run. _2004-Jun-26 00:47:24 by anonymous:_ {linebreak} For sqlite v3, define SQLITE_DEBUG=1 to run the malloc tests. #f2dcdc 780 warn active 2004 Jun anonymous Unknown 2004 Jun 3 2 Builkd gice src code errors on MacOS 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 [ #c8c8c8 779 code closed 2004 Jun anonymous 2004 Jun 4 1 duplicated declaration of sqlite3_changes() in sqlite.h.in the file sqlite.h.in contains a duplicated declaration of the function int sqlite3_changes(sqlite3*); (includind documentation) before and after the declaration of the function int sqlite3_total_changes(sqlite3*); True. Oops. #cfe8bd 778 code fixed 2004 Jun anonymous Unknown 2004 Jun 1 1 output of sqlite3_mprintf isn't correct After some testing of sqlite 3.0.1 I found problems with sqlite3_mprintf. I testet the function with g++ 3.2.2 under linux and GCC 3.3.1 (cygming special) Output from the function testva(see below) is
     --- using %lu ul1: 7fffffff, 2147483647, 2147483647 ul2: ffffffff, 4294967295, 18446744073709551615 ul3: 80000000, 2147483648, 18446744071562067968 --- using %u l1: 7fffffff, 2147483647, 2147483647 l2: ffffffff, 4294967295, 18446744073709551615 l3: 80000000, 2147483648, 18446744071562067968 --- using %d l1: 7fffffff, 2147483647, 2147483647 l2: ffffffff, -1, -1 l3: 80000000, -2147483648, -18446744071562067968  The function running with sqlite 2.8.x is  --- using %lu ul1: 7fffffff, 2147483647, 2147483647 ul2: ffffffff, 4294967295, 4294967295 ul3: 80000000, 2147483648, 2147483648 --- using %u l1: 7fffffff, 2147483647, 2147483647 l2: ffffffff, 4294967295, 4294967295 l3: 80000000, 2147483648, 2147483648 --- using %d l1: 7fffffff, 2147483647, 2147483647 l2: ffffffff, -1, -1 l3: 80000000, -2147483648, -2147483648  I think these are the correct values  ---------------------------------------------- void testva(void) {     char *s;      unsigned long ul1 = 0x7FFFFFFF;     unsigned long ul2 = 0xFFFFFFFF;     unsigned long ul3 = 0x80000000;      printf ( "--- using %%lu\n");      s = sqlite3_mprintf("%lu", ul1);     printf("ul1: %lx, %lu, %s\n", ul1, ul1 ,s);      s = sqlite3_mprintf("%lu", ul2);     printf("ul2: %lx, %lu, %s\n", ul2, ul2 ,s);      s = sqlite3_mprintf("%lu", ul3);     printf("ul3: %lx, %lu, %s\n", ul3, ul3 ,s);      unsigned l1 = 0x7FFFFFFF;     unsigned l2 = 0xFFFFFFFF;     unsigned l3 = 0x80000000;      printf ( "--- using %%u\n");      s = sqlite3_mprintf("%u", l1);     printf("l1: %x, %u, %s\n", l1, l1, s);      s = sqlite3_mprintf("%u", l2);     printf("l2: %x, %u, %s\n", l2, l2, s);      s = sqlite3_mprintf("%u", l3);     printf("l3: %x, %u, %s\n", l3, l3, s);       printf ( "--- using %%d\n");      s = sqlite3_mprintf("%d", l1);     printf("l1: %x, %d, %s\n", l1, l1, s);      s = sqlite3_mprintf("%d", l2);     printf("l2: %x, %d, %s\n", l2, l2, s);      s = sqlite3_mprintf("%d", l3);     printf("l3: %x, %d, %s\n", l3, l3, s); } 
    _2004-Jun-24 22:24:08 by anonymous:_ {linebreak}
     well, I have traced the function vxprintf()  the reason for the error is in the line:          else if( flag_long )  longvalue = va_arg(ap,long int);          if for an unsigned long int value this line is changed to:                  else if( flag_long )  longvalue = va_arg(ap,long unsigned int);  the conversion is correct. I think by calling va_arg() the %u qualifier must be taken in account.  
    #cfe8bd 777 code fixed 2004 Jun anonymous 2004 Jun 1 1 MIN() does not return NULL if there is a NULL in the list select X from tableX ORDER BY 1 will put NULL values first (NULL is considered the smallest value) but SELECT min(X), max(X) FROM TableX will not return NULL unless all values of X are NULL (if non-null values exist in the subset queried, the min()/max() functions will not report it (I would assume that min() would return NULL in that case) Here is some sample sql demonstrating the issue: -- this query returns min = 0, max = 1 (the NULL is ignored) select min(t), max(t) from (select 1 union select NULL union select 0 AS t); -- this query implies that the 'min' value is NULL select t from (select 1 union select NULL union select 0 AS t) order by 1; I see check-in #597 changed to this current behaviour, but as the above sample demonstrates, this is misleading (in my opinion). I think all the functions can ignore NULL's except for min(). I have a query that needs min to include NULL values, but I don't see any easy workaround the current behavour (ignoring them). I suppose there are people that desire the current behaviour, but wouldn't it be easier for people to have it work as I desire and just exclude records that have NULL values if you don't want them included (in a where clause)? _2004-Jul-10 00:27:49 by anonymous:_ {linebreak} Having MIN return NULL when there are non-null data in the set being scanned is contrary to the SQL-92 std, incompatible with all other major SQL engines, and an all-around bad idea. See ticket #800. #c8c8c8 773 code closed 2004 Jun anonymous Unknown 2004 Jun 3 4 user-defined sql function called unexpected number of times Thank you for making sqlite such an excellent tool! I am using the pysqlite (0.5.0) Python interface to the sqlite (2.8.14) API. My query is of the form: select foo(x,y) as b, sum(z) from ( select * from main.table ) group by b it can probably be simplified and still produce the error, but I'm not sure. The table has 207869 rows. I expected then that foo(x,y) would be called 207869 times. However, it was actually called 252194 times (44325 extra calls). I was surprised to see this and thought it might be a bug. _2004-Jun-22 10:36:16 by anonymous:_ {linebreak} Does the query return 44300 or so rows? SQLite makes no hard guarentees about when or how often user functions will be invoked, so it's not a bug on that basis. ---- _2004-Jun-22 23:13:00 by anonymous:_ {linebreak} Although I haven't verified it, yes, the result does return a number of rows of that order. I have not observed any incorrect results. This was interesting to me because in my case foo(x,y) is an expensive function, and the 20% extra calls impacts my applications performance. I thought it might give insight into possible sqlite speed improvements. #cfe8bd 772 build fixed 2004 Jun anonymous 2004 Jun 2 2 configure with cygwin broken with the last CVS download configure stops with: checking for readline.h... no{linebreak} checking for /usr/include/readline.h... no{linebreak} checking for /usr/include/readline/readline.h... yes{linebreak} checking for usleep... yes{linebreak} configure: creating ./config.status{linebreak} config.status: creating{linebreak} .infig.status: error: cannot find input file:{linebreak} _2004-Jun-21 21:40:23 by dougcurrie:_ {linebreak} Oh, the joy of discovering yet another wonderful feature of autoconf! It seems that when DOS line endings are used in the ac file, autoconf proceeds to put control characters in the emitted filenames. A new version will be uploaded to cvs shortly. -- e #cfe8bd 771 doc fixed 2004 Jun anonymous 2004 Jun 5 4 Typo on SQLite 3 Overview page On the web page http://www.hwaci.com/sw/sqlite/version3.html The sentence shown below: SQLite is not particular about the text it receives and is more than happen to process text strings that are not normalized or even well-formed UTF-8 or UTF-16. should read: SQLite is not particular about the text it receives and is more than happy to process text strings that are not normalized or even well-formed UTF-8 or UTF-16. #cfe8bd 770 doc fixed 2004 Jun anonymous 2004 Jun 5 4 Typo in SQLite 3 Overview doc On the web page http://www.hwaci.com/sw/sqlite/version3.html The sentence shown below: In most other SQL database engines the datatype is associated with the table column the holds the data - with the data container. should read: In most other SQL database engines the datatype is associated with the table column that holds the data - with the data container. #c8c8c8 769 code closed 2004 Jun anonymous 2004 Jun 2 2 macro SQLITE_OMIT_AUTHORIZATION is not honored whether the macro SQLITE_OMIT_AUTHORIZATION is set or not the functions sqlite3Auth* are always called _2004-Jun-20 22:57:12 by drh:_ {linebreak} I don't think so. The sqlite3Auth* functions are disabled by the following code is in {link: getfile/sqlite/src/sqliteInt.h sqliteInt.h}:
     #ifndef SQLITE_OMIT_AUTHORIZATION   void sqlite3AuthRead(Parse*,Expr*,SrcList*);   int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);   void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);   void sqlite3AuthContextPop(AuthContext*); #else # define sqlite3AuthRead(a,b,c) # define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK # define sqlite3AuthContextPush(a,b,c) # define sqlite3AuthContextPop(a)  ((void)(a)) #endif 
    #c8c8c8 767 new closed 2004 Jun anonymous 2004 Jun 1 1 Metadata of query I'm developer of {link: http://sourceforge.net/projects/adodotnetsqlite/ ADO.NET Data Provider for SQLite}. Everything works fine except one thing - I can not correctly implement {link: http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdataidatareaderclassgetschematabletopic.asp IDataReader.GetSchemaTable} method. Basically, this method must return the metadata of the query: tables and column names involved in the query, does the given column have UNIQUE constraint, is the column autoincremented and etc. The correct implementation of this method is vital for the creation of the class similar to {link: http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlcommandbuilderclasstopic.asp SqlCommandBuilder}. I was considering use EXPLAIN command and parsing the commands of the virtual machine, but VM commands do not contain the whole information. For ex., they do not contain constraints definitions. What other options do I have? Thank you, Alexander Gavrilov _2004-Jun-19 18:07:53 by drh:_ {linebreak} Please ask your question on the SQLite mailing list. #cfe8bd 765 build fixed 2004 Jun anonymous 2004 Jun dougcurrie 3 2 MinGW/MSYS build fails with vrsion 3.0.0 There is a problem in Makefile generated with MinGW/MSYS. Configure runs OK, but when I run mingw32-make I get error in parse.c target (please see attached file for details) so I changed that line from parse.c: $(TOP)/src/parse.y lemon to parse.c: $(TOP)/src/parse.y lemon.exe (added extesion to match the lemon target already in Makefile) Then there is also the problem in dll target because sqlite.def file is from 2.8.14 release And there is some problem in doc target, but I still didn't figure out why is that so since common.tcl is in place?!? System is Win2000 with SP2 $ sh --version GNU bash, version 2.04.0(1)-release (i686-pc-msys) $ mingw32-make --version GNU Make version 3.79.1, by Richard Stallman and Roland McGrath. Built for i686-pc-msys $ mingw32-gcc --version mingw32-gcc.exe (GCC) 3.2.3 (mingw special 20030504-1) _2004-Jun-18 21:45:29 by dougcurrie:_ {linebreak} The doc target can be fixed by adding common.tcl as a dependency doc: common.tcl $(DOC) and removing the line cd doc from www/download.tcl ---- _2004-Jun-18 22:05:34 by anonymous:_ {linebreak} I looked into the doc target problem and, to my surprise, it seems like source TCL command (on win/MinGW at least) is interpreting path relative to cwd of tclsh and not relative to script being called. I made some quick fixes to Makefile.in (diff attached) to fix all above mentioned problems. #c8c8c8 764 code closed 2004 Jun drh 2004 Jun drh 1 1 ROLLBACK disables TEMP triggers. When a ROLLBACK occurs, temporary triggers stop working. The following code illustrates: CREATE TABLE t1(x,y); CREATE TABLE t2(z); CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 FOR EACH ROW BEGIN INSERT INTO t2 VALUES(new.x+new.y); END; BEGIN; INSERT INTO t1 VALUES(1,2); SELECT 333, * FROM t2; -- Output "333|3" ROLLBACK; BEGIN; INSERT INTO t1 VALUES(2,3); SELECT 555, * FROM t2; -- Should be "555|5" but comes out blank ROLLBACK; _2004-Jun-19 02:24:14 by anonymous:_ {linebreak} Checkin [1628] fixes this for version 3. It still needs to be applied to 2.8.14. ---- _2004-Jun-19 06:07:36 by anonymous:_ {linebreak} [1631] is the same fix in version 2. #f2dcdc 763 code active 2004 Jun anonymous Unknown 2004 Jun 5 4 tclsqlite.dll not showing the correct version 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! #f2dcdc 762 todo active 2004 Jun anonymous Unknown 2004 Jun anonymous 4 3 Windows pre-compiled binaries are 2.8.13, not 2.8.14 Windows pre-compiled binaries are 2.8.13, not 2.8.14 #c8c8c8 761 todo closed 2004 Jun anonymous Unknown 2004 Jun 5 5 the current sqlite_source.zip is 2.8.13, not 2.8.14 the "cleaned-up" source code file is not current, and does not include the binary encoding/decoding, despite the change log (which, since it isn't the right version, makes sense :) ). This is more of an FYI, I can get the complete 14 source and extract the encoding/decoding files myself. --Keith Fixed. Future releases will include a version number in the filename to prevent this from happening again. #c8c8c8 759 event closed 2004 Jun anonymous Unknown 2004 Jun a.rottmann 2 1 record can't be inserted Run the following code, the record can't be inserted sqlite *lite; char **results; char *szError = 0; int rows; CString s,sCode,sDesc; lite = sqlite_open("c:\\data.db", 0, &szError); sqlite_exec(lite,"create table data(code0 int, desc char(500))",NULL,NULL,NULL); sCode = "001"; sDesc = "UPDATE tableno SET tablestate='0' WHERE tablestate='3' and settletime<='%s';"; sqlite_exec_printf(lite,"insert into data(code0,desc) values(%s,'%s');",0,0,0,sCode,sDesc); sqlite_close(lite); _2004-Jun-14 08:28:46 by danielk1977:_ {linebreak} In the sqlite3_exec_printf() line, I think you need to replace the second instance of %s with %q. #cfe8bd 757 code fixed 2004 Jun anonymous VDBE 2004 Jun 3 3 Indexes on temporary tables leave cursors open We developed a test case that uses several tables, temporary tables, and indexes (both on the normal tables and temporary tables). For some reason, when we drop the temporary tables, the indexes are not cleaned up properly and commits to a normal table fail with SQLITE_LOCKED. When we drop the index explicitly before the temporary table, we don't run into this problem. Interestingly, if :memory: is used instead of a database file, we don't see the problem either. _2004-Jun-09 21:08:14 by anonymous:_ {linebreak} Using the attached test case: $ rm /tmp/testcase; sqlite /tmp/testcase < testcase.sql INSERT INTO Table3 SELECT NULL, TempTable.col5, TempTable.col6, TempTable.col7, TempTable.col8 FROM TempTable LEFT OUTER JOIN Table3 ON TempTable.col5 = Table3.col5 AND TempTable.col6 = Table3.col6 WHERE Table3.col3 is NULL; SQL error: database table is locked If you add "DROP INDEX TempTableIdx;" on line 61, the test succeeds. ---- _2004-Jun-09 23:17:27 by drh:_ {linebreak} The problem does not appear in the latest (2.8 series) version of SQLite in CVS. And since I'm up to my eyeballs in version 3.0 I'm disinclined to figure out why. I'm just going to release version 2.8.14 since that seems to fix the problem. ---- _2004-Jun-10 00:11:07 by anonymous:_ {linebreak} I installed the binary RPMs for 2.8.14 and still see the problem. I rebuilt 2.8.14 from source and it still fails. I know you're busy with sqlite 3 -- and we have the workaround (drop the index explicitly). I will keep looking at this to see if I can figure out what's going on. #f2dcdc 755 new active 2004 Jun anonymous TclLib 2004 Jun drh 5 2 Adding aggregate function to the tcl binding The diff against tclsqlite.c to solve the problem can be also submitted by email #f2dcdc 754 code active 2004 Jun anonymous Shell 2004 Jun drh 2 3 problem opening a dbfile in the upper directory (../dbname) 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 #f2dcdc 752 doc active 2004 Jun anonymous 2004 Jun 4 4 FAQ-Entry: How to escape quotes 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). #c8c8c8 677 code closed 2004 Mar anonymous 2004 Mar 2 3 Failure to convert to FP on division involving a constant sqlite> select * from idiv; I J ---------- ---------- 1 3 2 3 3 3 4 3 sqlite> select I/J from idiv; I/J ----------------- 0.333333333333333 0.666666666666667 1 1.33333333333333 sqlite> select I/3 from idiv; I/3 ---------- 0 0 1 1 sqlite> select J/I from idiv; J/I ---------- 3 1.5 1 0.75 sqlite> select 3/I from idiv; 3/I ---------- 3 1 1 0 _2004-Mar-31 01:12:00 by drh:_ {linebreak} Works fine when I try it. How did you define the IDIV table? What are the column types? Did you compile SQLite yourself or use the precompiled copies on the website? What OS? ---- _2004-Mar-31 02:21:45 by drh:_ {linebreak} The phenomenon appears when column I is an INTEGER PRIMARY KEY. An INTEGER PRIMARY KEY column has an integer datatype. All other columns in SQLite (whether numeric or text) have a floating point datatype. If you take this rule into account, the behavior above is correct. Works as designed, no changes to code. #c8c8c8 675 code closed 2004 Mar anonymous 2004 Mar 2 1 Malformed error at GET BLOB DATA from database file Generally, It is no problem that we input a BLOB DATA into database file, but it is failed that we search a BLOB DATA from database file. The fail message is followed by "The database disk image is malformed.". Why this problem ocurrs? SQLite will not work if you put binary data into an indexed column. An incompatible file format change will be necessary to fix this. The fix will not occur prior to version 3.0. Use sqlite_encode_binary() as an alternative. #c8c8c8 674 code closed 2004 Mar anonymous 2004 Mar 3 4 insert record fails mpatrol tests mpatrol reports this: ERROR: [NULOPN]: memcpy: attempt to perform operation on a NULL pointer ALLOC: malloc (100206, 0 bytes, 4 bytes) [-|-|-] 0x4007D022 sqliteMallocRaw+34 0x40090F17 memRbtreeInsert+71 0x400846C8 sqliteVdbeExec+19080 0x4005A59F sqliteExec+319 0x4006F655 yy_reduce+277 0x4007280D sqliteParser+605 0x4007B911 sqliteRunParser+353 0x4006A517 sqliteMain+327 0x4006A739 sqlite_exec+57 0x0804B391 parse_for_key_words+213 0x0804C781 parse_is_wanted_page+3846 0x0804B11B display_dump_and_free_links+1949 0x0804B20C display_google_page+101 0x0804A7EF main+141 0x401CFC5F __libc_start_main+207 0x0804A651 _start+33 WARNING: [ALLZER]: malloc: attempt to create an allocation of size 0 MEMCOPY: memcpy (0x00000000, 0x0810E078, 0 bytes, 0x00) [-|-|-] 0x40090F43 memRbtreeInsert+115 0x400846C8 sqliteVdbeExec+19080 0x4005A59F sqliteExec+319 0x4006F655 yy_reduce+277 0x4007280D sqliteParser+605 0x4007B911 sqliteRunParser+353 0x4006A517 sqliteMain+327 0x4006A739 sqlite_exec+57 0x0804B391 parse_for_key_words+213 0x0804C781 parse_is_wanted_page+3846 0x0804B11B display_dump_and_free_links+1949 0x0804B20C display_google_page+101 0x0804A7EF main+141 0x401CFC5F __libc_start_main+207 0x0804A651 _start+33 i believe the fix is .. at least it stops the mpatrol error .. in btree_rb.c in memRbtreeInsert() replace: pData = sqliteMallocRaw(nData); if( sqlite_malloc_failed ) return SQLITE_NOMEM; memcpy(pData, pDataInput, nData); with: if(nData==0) { pData=NULL; } else { pData = sqliteMallocRaw(nData); if( sqlite_malloc_failed ) return SQLITE_NOMEM; memcpy(pData, pDataInput, nData); }
    In this block of code: pData = sqliteMallocRaw(nData); if( sqlite_malloc_failed ) return SQLITE_NOMEM; memcpy(pData, pDataInput, nData); sqliteMallocRaw() will return 0 (or NULL - same thing) if the system is out of memory or if nData==0. In the first case (out of memory) the global variable sqlite_malloc_failed will have been set, the jump will be taken and the memcpy will never be reached. The only other way for pData to be 0 if for nData to be zero. But the statement: memcpy(0, pDataInput, 0); Should be benign. The NULL passed in as the first argument should not matter since the 0 in the third argument makes the memcpy() a no-op. Until somebody reports a machine where an memcpy() of zero bytes actually dereferences the destination pointer, I will consider this a non-issue. #c8c8c8 672 warn closed 2004 Mar anonymous Unknown 2004 Mar 1 1 THE DLL FILE FOR WINDOWS IS CURRUPTED THE DLL FILE IS GET CURRUPTED PLEASE UPLOAD THE NEW VERSION MD5 checksums are correct. Must be a user problem. #c8c8c8 671 build closed 2004 Mar anonymous TclLib 2004 Mar 4 4 Missing tcl.h from /src I downloaded and gunzipped the 2.8.13.tar.gz file. Then ./configure and make. No problems. The output of make test showed the following lines at the very end:{linebreak} ./src/test1.c:19: tcl.h: No such file or directory{linebreak} ./src/test2.c:21: tcl.h: No such file or directory{linebreak} ./src/test3.c:21: tcl.h: No such file or directory{linebreak} ./src/test4.c:17: tcl.h: No such file or directory{linebreak} ./src/md5.c:31: tcl.h: No such file or directory{linebreak} make: *** [testfixture] Error 1{linebreak} bash-2.04${linebreak} I don't know if the absence of tcl.h from the /src directory is important, or whether some tests couldn't be performed. Thank you,{linebreak} Peter F. Clark cpf101@stu.wccnet.org You have to have TCL installed in order to run the tests. Get a copy from http://www.tcl.tk/ #cfe8bd 670 code fixed 2004 Mar anonymous 2004 Mar 3 3 The '.database' trunc file name When using 'attached' database, the .database command show omit the first 8 characters of the attached file name. This is not usefull, since in most cases, the actual files name is longer. The problem seems to be in the formatting of output, since the Pragma command provides the full name. sqlite> attach database 'demo.db' as demo ...> ; sqlite> .da 0 main 1 temp 2 demo /tmp_mnt/h sqlite> PRAGMA database_list; 0|main| 1|temp| 2|demo|/tmp_mnt/home4/yair/cvstrac/demo.db sqlite> Note: This ticket was entered (by mistake) as ticket 297 against cvstrac. #c8c8c8 669 new closed 2004 Mar anonymous 2004 Mar 5 5 named-field? right now we still need to use number-based index to acces fields, but how about named-fields such as "name","desciption" etc. rather than 0,1... ? _2004-Mar-18 13:53:03 by drh:_ {linebreak} I have no idea what this ticket is talking about. #cfe8bd 668 code fixed 2004 Mar anonymous VDBE 2004 Mar 2 2 sqlite crash on combinng case and not in The 'Tickets Counts' SQL statement is causing the following error on sqlite 2.8.3. I'm running this again 'out of the box' cvstrac database. The problem occurs on SunOS 5.8. The query seems to work OK on on www.cvstrac.org Assertion failed: pTos<=&p->aStack[pc], file ../sqlite/src/vdbe.c, line 516 SQL: SELECT status, count(case when type='code' then 'x' end), count(case when type='doc' then 'x' end), count(case when type='new' then 'x' end), count(case when type NOT IN ('code','doc','new') then 'x' end), count(*) FROM ticket GROUP BY status UNION SELECT 'TOTAL' AS 'Status', count(case when type='code' then 'x' end) as 'Code Bugs', count(case when type='doc' then 'x' end) as 'Doc Bugs', count(case when type='new' then 'x' end) as 'Enhancements', count(case when type NOT IN ('code','doc','new') then 'x' end) as 'Other', count(*) AS 'All Types' FROM ticket ORDER BY [All Types] _2004-Mar-17 23:04:59 by drh:_ {linebreak} Reproducible test case: CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 SELECT x+2 FROM t1; INSERT INTO t1 SELECT x+4 FROM t1; INSERT INTO t1 SELECT x+8 FROM t1; INSERT INTO t1 SELECT x+16 FROM t1; INSERT INTO t1 SELECT NULL FROM t1; SELECT case when x NOT IN (1,2,3) then 'x' end FROM t1; #cfe8bd 667 build fixed 2004 Mar dougcurrie Unknown 2004 Mar dougcurrie 2 1 Makefile.in needs updates for encode, .defs, Makefile target Now that encode.c is included in the build, the changes need to be propagated to Makefile.in and sqlite.def Recent updates to Makefile.in have assumed that configure is run in $(TOP) whereas the build instructions specify running configure in a bld directory, e.g., see at the bottom of http://www.sqlite.org/ So, $(TOP)/ should be added before references to Makefile.in and sqlite.def #f2dcdc 666 code active 2004 Mar anonymous Unknown 2004 Mar anonymous 5 4 Error message indicates wrong error 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 #c8c8c8 664 new closed 2004 Mar anonymous 2004 Mar 5 5 In-Memory convert to disk database file? If I connect an in-memory database, do som operations, then I wish to persist the data to the disk, how ? Usage questions are handled on the SQLite mailing list, not using trouble tickets. #c8c8c8 663 new closed 2004 Mar anonymous 2004 Mar drh 5 5 SELECT TOP n? how about supporting the "SELECT TOP n" clause? refer to:http://archives.postgresql.org/pgsql-sql/1999-04/msg00102.php Use the LIMIT clause. #f2dcdc 662 new active 2004 Mar anonymous 2004 Mar drh 5 5 Stored Procedures? I know that sqlite demands not to support Stored Procedures, but why? it is quite good. _2005-Aug-30 20:23:58 by anonymous:_ {linebreak} 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:_ {linebreak} This is really something that deserves to be discussed on the mailing list. #c8c8c8 661 new closed 2004 Mar anonymous 2004 Mar 5 5 In-Memory feature? Will sqlite add the in-memory feature? that is, like the hsqldb in sourceforge.net, it has physical disk/in-memory modes, some times, we do not want to generate disk files. In-memory mode, allow user to opereate sql without disk files, that is any way out. Already exists. Read the documentation. #f2dcdc 660 new active 2004 Mar anonymous 2004 Mar 5 5 compression/encoding feature? 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:_ {linebreak} 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? #cfe8bd 659 code fixed 2004 Mar anonymous 2004 Mar 4 4 +1 month issue (dead or defective code) in date.c On line 617 of date.c, the statement "if( y!=r ){" is never true due to the assignment "y = r" just above it. _: _r is a double and y is an int, so the comparison is only true if the fraction part of r is 0. The code is correct as it stands._ Plus I think the "Compute the last day of the current month" wiki example is either flawed or very magical in how it would handle a date like 2004-01-31. It should read "SELECT date('now','start of month','+1 month','-1 day')" if only for sanity sake. _: _Anybody can edit the wiki. You need not submit a bug report._ #cfe8bd 658 code fixed 2004 Mar anonymous 2004 Mar 3 3 select max(rowid) from union crashes sqlite command-line sqlite> select max(rowid) from files; 615 sqlite> select max(rowid) from messages; 6933 sqlite> select max(rowid) from (select rowid from messages union select rowid from files); 999 so that's wrong, but then: sqlite> select max(rowid) from (select max(rowid) from messages union select max(rowid) from files); src/vdbe.c:2399: failed assertion `pTos>=p->aStack' Abort trap I can reproduce the crashing (though not the weird 999 result) with simple tables: sqlite> create table a (a); sqlite> create table b (a); sqlite> insert into a values (1); sqlite> insert into b values (2); sqlite> insert into b values (3); sqlite> insert into b values (4); sqlite> insert into b values (5); sqlite> select max(rowid) from a; 1 sqlite> select max(rowid) from b; 4 sqlite> select max(rowid) from (select rowid from a union select rowid from b); 4 sqlite> select max(rowid) from (select max(rowid) from a union select max(rowid) from b); src/vdbe.c:2399: failed assertion `pTos>=p->aStack' Abort trap #c8c8c8 657 code closed 2004 Mar anonymous Unknown 2004 Mar 1 1 Wrong reported columncount in CallBack routine The Callback routine (called after select) reports 0 as the columncount when the first record (containing the field definitions metadata) is retrieved. The second record (first real data record) reports the correct number of columns. This is a real showstopper for the Delphi components we develop, since the datastructure of the select must be known before datarecords can be processed. The components do work with version 12 and older where the problem does not exists. Albert Drent This doesn't make any sense. The query callback in SQLite has never returned meta data in a separate row prior to returning the result set. In the callback API, meta data is always passed in with every row as the 4th parameter to the callback function. The sqlite_get_table() API returns meta data in a prior row, but it does not use callbacks. The columncount field there appears to be correct, at least in the test cases that are run as part of the regression test suite. This ticket is closed pending more data and/or a better description of the problem. ---- _2004-Mar-13 12:42:07 by anonymous:_ {linebreak} It' appearantly difficult to explain the problem, but you're right, the column info is added to every record. Problem still exists: on the first time the callback is called the columncount is 0, all other times the columncount contains the correct value. The metadata added to every record in the callback is only parsed at the first time the callback is called, explaining the confusion. albert ---- _2004-Mar-13 20:39:02 by anonymous:_ {linebreak} Well the problem was a little more complex since v12 workded and v13 did not. But I have found a way-out. Thanks for your time, and sorry for the trouble. Albert #cfe8bd 654 code fixed 2004 Mar anonymous Unknown 2004 Mar 3 2 Can't compile with CodeWarrior Studio v9.1 I am trying to compile sqlite_source using CW Pro 9.1 and got a compile error: the line: randomName(&zTemp[nFilename+1]); in vacuum.c does not compile 'cos a char * is passing into a function that expects a unsigned char *. Apparently this is no longer valid in ISO C? More likely, this is a bug in CW Pro 9.1. Nevertheless, I put in a typecast to work around the problem. ---- _2004-Mar-10 21:17:21 by anonymous:_ {linebreak} just talked to someone at Metrowerks. In the C/C++ language panel in the project settings, there was an option called "Relaxed Pointer Type Rules" until CW Pro 9. That option is now removed ('cos of the standard?). Typecasting should do the job. Another way they suggested is to use a pragma called "mpwc_relax". #pragma mpwc_relax on ... #pragma mpwc_relax off to allow this kind of compatibility. #c8c8c8 653 code closed 2004 Mar anonymous Unknown 2004 Mar 1 1 sqlite db 'create table t(f)' dumps core sqlite db 'create table t(f)' coredumps : sqliteSafetyOn (db=0x0) at ./src/util.c:1200 on /dmsp/reference/build/sqlite-2.8.12 > uname -srm Linux 2.4.21-9.0.1.ELsmp i686 and /dmsp/reference/build/sqlite-2.8.12 > uname -srm Linux 2.4.20-28.7smp i686 built with NO configure options. _2004-Mar-10 02:53:26 by anonymous:_ {linebreak}
      i did this to src/shell.c and it seems to work.  the problem seems to be that some of code is using data->db while some uses the global db ptr.  to fix this i simply made open_db also initialize the db ptr.  here is a patch:   --- shell.c     2004-03-09 19:50:44.000000000 -0700 +++ shell.c.patched     2004-03-09 19:50:54.000000000 -0700 @@ -528,6 +528,7 @@        exit(1);      }    } +  db = p->db;  }    /*    
    ---- Previously reported by tickets #649, #642, and #620. Fixed by check-in [1238] and in version 2.8.13. #f2dcdc 652 doc active 2004 Mar anonymous Unknown 2004 Mar anonymous 5 5 small addition needed in pragma table_info 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 #f2dcdc 651 new active 2004 Mar anonymous 2004 Mar 5 4 Update optimisation 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. #c8c8c8 650 new closed 2004 Mar anonymous Parser 2004 Mar 4 4 DISTINCT aggregates Attempting DISTINCT within aggregates generates syntax errors. SELECT count(*), count(DISTINCT state) FROM ... See http://www.sqlite.org/omitted.html #c8c8c8 649 code closed 2004 Mar anonymous Shell 2004 Mar 1 1 sqlite-2.8.12 segmentation fault in shell command-line usage sqlite segfault if i use it in command-line, for example sqlite db "select * from table" my system is: Acer Travelmate 313T Slackware Linux 9.1 kernel 2.4.24 sqlite compiled from source with gcc and libs default included in slackware 9.1. I also tried sqlite.bin.gz and segfault too. 2.2.5 version compiled in same pc works fine. I will happy to provide you more info if needed. Thanks for your work. Previously reported as ticket #642 and #620. Fixed by check-in [1238]. #cfe8bd 648 code fixed 2004 Mar rdc Unknown 2004 Mar 3 3 duplicate tracing with revised sqlite_exec implementation The new non-callback based implementation of the sqlite_exec() API causes duplicate tracing of SQL statments when multiple statements are passed in a single SQL string. Previous versions traced the argument SQL statments once then executed the entire sequence. The current version compiles and executes the sequence one statment at a time, and traces from the current statment to the end of the sequence for each compiled statment. For a sequence of 4 statements, it traces the staments as shown below; Executed Traced --------------------------- statement 1 statement 1 statement 2 statement 3 statement 4 statement 2 statement 2 statement 3 statement 4 statement 3 statement 3 statement 4 statement 4 statement 4 _2004-Mar-04 19:11:45 by rdc:_ {linebreak} Checkin [1284] corrects this bug by changing sqlite_compile() so it only traces the statement it compiled. #f2dcdc 647 warn active 2004 Mar anonymous Shell 2004 Mar 5 4 Shell.c compilation warnings 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 #f2dcdc 646 warn active 2004 Mar anonymous Pager 2004 Mar 5 4 Pager.c compilation warnings 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 #f2dcdc 645 new active 2004 Mar anonymous 2004 Mar 5 5 OpenWatcom makefile 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 %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 #f2dcdc 644 todo active 2004 Mar anonymous Unknown 2004 Mar 1 3 How do you fix "SQL error: database disk image is malformed" 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? #c8c8c8 643 code closed 2004 Mar anonymous Unknown 2004 Mar 3 2 local variable 'db' used without having been initialized While compiling the .c files from sqlite_source.zip under Visual Studio .NET 2003, I noticed this error: expr.c(456) : warning C4700: local variable 'db' used without having been initialized And upon further investigation, I noticed that this was more than just an annoying warning message. The pointer variable 'db' is actually being derefenced without initialization: if( zDb!=0 && sqliteStrICmp(db->aDb[pTab->iDb].zName, zDb)!=0 ){ continue; This is from line 457 in expr.c. Regards, -Karthi. Already reported in #604, #612, #616, #629, and #630. Fixed by check-in [1225]. #c8c8c8 642 code closed 2004 Mar anonymous Shell 2004 Mar 1 1 Problem when adding a SQL string on the command line - THIS IS REAL!! When using the command-line version of "sqlite", if I add the SQL string to the command line like this: sqlite ex1 "select * from tblCandy" I get a "Send Error Report" on Windows XP and a "Segmentation Fault" under UNIX. I looked into the problem and solved it myself by changing the code in the "shell.c" file on UNIX. The 1st parameter to the "sqlite_exec" call is "db". But when I changed it to "(&data)->db", it worked on UNIX. Trouble is, I can't compile under Windows XP and that's where I need it the most! It looks like this error was already reported (#631), but got closed out when it was assumed that the user needed double quotes around the SQL string parameter. I assure you ... there is a problem here!!! It's not just the quotes and it happens only when a SQL string is passed on the command line!!! Already fixed. See ticket #620 and check-in [1238]. ---- _2004-Mar-08 08:20:04 by anonymous:_ {linebreak} you can compile shell.c in VC, but first delete the file"tclsqlite.c" #cfe8bd 641 code fixed 2004 Mar anonymous Unknown 2004 Mar 1 1 select query doen't work with binary equations select query doen't work with binary equations as shown below. Last version this worked on that I tried was 2.8.9 SQLite version 2.8.12 Enter ".help" for instructions sqlite> select 4 & 5; sqlite: src/vdbe.c:1216: sqliteVdbeExec: Assertion 'pTos->flags==0x0004' failed. Aborted _2004-Mar-03 18:48:26 by anonymous:_ {linebreak} Brought to you by GNU/Peter. #cfe8bd 640 code fixed 2004 Mar drh CodeGen 2004 Mar 1 1 Trigger causes assertion failure The following code leads to an assertion failure: CREATE TABLE t1(a); CREATE TABLE t2(b); CREATE TABLE t3(c); CREATE TRIGGER r1 AFTER DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t3(c) SELECT b FROM t2 ORDER BY b LIMIT 1; END; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 SELECT a+2 FROM t1; INSERT INTO t1 SELECT a+4 FROM t1; INSERT INTO t1 SELECT a+8 FROM t1; INSERT INTO t2 SELECT a FROM t1; DELETE FROM t1; The failure is as follows: ../sqlite/src/vdbe.c:516: sqliteVdbeExec: Assertion `pTos<=&p->aStack[pc]' failed. #c8c8c8 639 event closed 2004 Mar anonymous 2004 Mar 1 1 Why fixed tickets are not closed ? Why fixed tickets are not closed ? Bartosz Frivolous tickets like this one get closed.... ---- _2004-Mar-01 14:57:30 by anonymous:_ {linebreak} To ask or not to ask ?? Bartosz. #f2dcdc 638 new active 2004 Mar anonymous 2004 Mar 5 5 Lemon.c could not be compiled - source dated 27.02.2004 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 637 code active 2004 Mar anonymous Parser 2004 Mar 5 4 union uses non-standard column names 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. #c8c8c8 636 new closed 2004 Mar anonymous Unknown 2004 Mar 1 1 Retaining autoincrement (Primary key) generated values I need to 1: re-create a table to add a column or remove a column (as there is no alter table) 2: retain the data 3: table has a primary key auto-increment column Then I cannot keep the values. A function to allow: 1: turning off of auto-incremement 2: then I do my insert of old table rows into new table 3: and then turning back on auto-increment with a seed value (starting point) would be the way to go. As it stands I will lose these values otherwise. Any assistance you can give with this problem would be appreciated. SQLite already provides everything the complainant needs. He just needs to read the documentation a little closer or perhaps consult the mailing list for help. #c8c8c8 635 new closed 2004 Feb anonymous 2004 Mar 5 5 ROWID as ref. number The ROWID is unusable as reference number. 1: I create a list. 2: I want to change the last item referenced with ROWID, and I start editing the record. 3: Meanwhile somebody deletes the last record and makes a new one, BUT it's ROWID will be same as my record's. 4: I finish editing, and post the changes, so I will overwrite somebody's fresh new record. _2004-Mar-01 01:34:35 by anonymous:_ {linebreak}
     sqlite> create table tbl2 (    ...> p text not null primary key,    ...> i integer); sqlite> insert into tbl2 values('a',1); sqlite> insert into tbl2 values('b',2); sqlite> insert into tbl2 values('c',3); sqlite> insert into tbl2 values('d',4); sqlite> select * from tbl2; p           i ----------  ---------- a           1 b           2 c           3 d           4 sqlite> select rowid from tbl2; rowid ---------- 1 2 3 4 sqlite> delete from tbl2 where p='d'; sqlite> insert into tbl2 values ('e',5); sqlite> update tbl2 set i=10 where rowid=4; sqlite> select * from tbl2; p           i ----------  ---------- a           1 b           2 c           3 e           10 sqlite> 
    ---- _2004-Mar-01 14:44:25 by drh:_ {linebreak} The ROWID is not a Universally Unique ID (UUID). If you need a UUID, generate one on your own and use that for your record key. Use either uuid_generate() or UuidCreate() depending on your operating system. #f2dcdc 575 code active 2004 Jan anonymous VDBE 2004 Mar drh 3 3 pragma (default_)temp_store implementations seems incomplete 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... #cfe8bd 514 code fixed 2003 Dec anonymous Unknown 2004 Mar 2 3 attaching a locked database causes strange errors and a crash I run SQLite on Windows 2000 using the precompiled sqlite.dll. The following problems occur at least in SQLite versions 2.8.6 and 2.8.7: Suppose you have a database in file 'A' which is locked, e.g. because another process currently running a transaction. Now open a database file 'B' and execute the SQL query: ATTACH DATABASE 'A' AS DB1; The result is a (correct) "database is locked" error message. Unfortunately any subsequent SQL query also produces this error message, regardless whether the query is perfectly in order or even syntactically wrong. Moreover, if you have executed a certain number of statements(at least 3, it seems) after the failed ATTACH, closing database 'B' with "sqlite_close" produces a segmentation fault. The only workaround I see is closing and re-opening the database immediately after an ATTACH command returned "database locked". #f2dcdc 48 doc active 2002 May anonymous 2004 Mar drh 1 1 use sqlite from a tclsh.exe 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:_ {linebreak} This might help Tom: http://www.sqlite.org/cvstrac/wiki?p=SqliteTclPackageWrapper #f2dcdc 748 new active 2004 May anonymous 2004 May 3 3 option to allow ignoring trailing whitespace in selects 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. #f2dcdc 746 warn active 2004 May anonymous CodeGen 2004 May anonymous 5 5 How can I make sqlite support serial term? 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 " serial primary key" is OK, but " 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:_ {linebreak} 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:_ {linebreak} 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>
    #f2dcdc 744 code active 2004 May anonymous BTree 2004 May anonymous 2 2 make test seg faults on x86_64 Linux I'm running the 64 bit version of Gentoo Linux on an AMD Opteron system. Ordinarily I'd install software with "emerge " 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:_ {linebreak} 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. #f2dcdc 742 new active 2004 May anonymous VDBE 2004 May anonymous 5 5 database is locked 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:_ {linebreak} 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. #f2dcdc 741 new active 2004 May anonymous CodeGen 2004 May anonymous 5 5 command tool does not support history 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:_ {linebreak} 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 #c8c8c8 740 code closed 2004 May anonymous BTree 2004 May 1 1 Unable to compile on Fedora core 1 On a fully patched Fedora core 1, I have been unable to build sqlite for weeks now. I have my build directory as a subdirectory of sqlite. In this directory ../configure seems to work. Make fails to compile, the first few lines of the compile error listing are: gcc -g -O2 -DOS_UNIX=1 -DOS_WIN=0 -DHAVE_USLEEP=1 -I. -I../src -c ../src/btree_rb.c -fPIC -DPIC -o .libs/btree_rb.o In file included from ../src/btree_rb.c:19: ../src/btree.h:64: error: syntax error before "u32" ../src/btree.h:65: error: syntax error before "u32" ../src/btree.h:83: error: syntax error before "i64" ../src/btree.h:85: error: syntax error before "i64" ../src/btree.h:93: error: syntax error before "i64" ../src/btree.h:94: error: syntax error before "u32" ../src/btree.h:97: error: syntax error before "u32" ../src/btree.h:98: error: syntax error before "u32" ../src/btree_rb.c:38: error: syntax error before "sqliteRbtreeOps" _2004-May-18 16:25:51 by drh:_ {linebreak} CVS HEAD is undergoing an extensive change to move it to version 3.0.0. It is currently unstable and will not compile using ./configure. Either use the prepackaged source code for 2.8.13 on the website or use the "version_2" branch of CVS. #f2dcdc 739 new active 2004 May anonymous Unknown 2004 May danielk1977 3 1 Suggestion speed query 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 #f2dcdc 738 new active 2004 May anonymous 2004 May danielk1977 4 1 Sort order array in memory 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 #f2dcdc 737 new active 2004 May anonymous Shell 2004 May anonymous 3 3 xml export Export a sql statement to an oracle-style export xml. 30.0 30 ... 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. #f2dcdc 736 new active 2004 May anonymous 2004 May 4 4 Would like to be able to list the LAST 10 lines of a query This falls outside the scope of pretty much everything, but still...{linebreak} 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:{linebreak} LIMIT -n should return the last n rows of a query.{linebreak} LIMIT k, -n should return the n rows just before the kth row{linebreak} LIMIT -k, n should return the n rows starting k rows before the end{linebreak} 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,{linebreak} Csaba Gabor _2004-May-13 16:53:56 by drh:_ {linebreak} "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:_ {linebreak} 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 #f2dcdc 735 code active 2004 May anonymous Shell 2004 May 4 3 .sqliterc not processed if running on a driver other than C: 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:_ {linebreak} That should read "drive" in the title, not "driver" #f2dcdc 734 build active 2004 May anonymous TclLib 2004 May 4 4 libtclsqlite.xxx not built by default make all target 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. #f2dcdc 732 doc active 2004 May anonymous 2004 May 5 5 Odd columns lead to odder selections 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);{linebreak} sqlite> insert into test5 values (1,2);{linebreak} sqlite> insert into test5 values (3,4);{linebreak} sqlite> select "One""Two" from test5;{linebreak} 1{linebreak} 3{linebreak} sqlite> select 'One"Two' from test5;{linebreak} One"Two{linebreak} One"Two{linebreak} sqlite> select "Two'One" from test5;{linebreak} 2{linebreak} 4{linebreak} sqlite> select 'Two''One' from test5;{linebreak} Two'One{linebreak} Two'One{linebreak} Csaba Gabor _2004-May-21 22:10:06 by anonymous:_ {linebreak} 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 #c8c8c8 731 code closed 2004 May anonymous 2004 May 2 3 UNIQUE constraint not working when one of the fields is null The UNIQUE constraint is supposed to prevent the specified columns from being duplicated. To me, that means that if I do a query selecting for those columns (WHERE colA=something1 AND colB=something2 AND ... AND colN=somethingN) then I should get back at most one row. However, here is a situation where I can add the same index twice: create table test (foo integer primary key, bar text,{linebreak} baz text, frob text, unique(bar, baz));{linebreak} pragma index_info('(test autoindex 1)');{linebreak} insert into test values (null, "fred", null, "bill");{linebreak} insert into test values (null, "fred", null, "");{linebreak} select * from test; Notice that bar and baz have values "fred" and null, respectively in both rows. This does not seem correct - certainly not what I'm expecting. Csaba Gabor _2004-May-10 23:41:52 by anonymous:_ {linebreak} Quite interesting... I've tested a little different. create table test2 ( foo integer primary key, bar text unique, baz text unique, frob text); sqlite> insert into test2 values(null,'fred',null,'bill'); sqlite> insert into test2 values(null,'fred',null,''); SQL error: column bar is not unique with this code it works fine. but the former code has bad result. if we do it again like below, sqlite accepts it. sqlite> insert into test values(null,'fred',null,'bill'); sqlite> insert into test values(null,'fred',null,''); so the result is : sqlite> select * from test; foo|bar|baz|frob 1|fred||bill 2|fred|| 3|fred||bill 4|fred|| ---- _2004-May-10 23:42:38 by drh:_ {linebreak} See http://www.sqlite.org/nulls.html. The behavior you desire is what Informix and MS-SQL give. Most other RDBMSes (PostgreSQL, Oracle, DB2, MySQL) work like SQLite. I'm going to leave the behavior as it is. The SQL spec is ambiguous about what should be done. #c8c8c8 730 new closed 2004 May anonymous 2004 May 4 3 Differentiate context-sensetive user actions and navigation in UI It would be very helpful if the links at the top could be differentiated into two classes: fixed links which are always there for navigation, and page-specific actions / functions. I slapped myself when I couldn't figure out how to attach a file to a ticket, and realized it was because I hadn't even thought to look in the navigation bar. It's a bit confusing, and even now that I know where to look I find it awkward. This could be solved in an abstract way by putting the two classes of links into two different
    s, and 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
    test_field+1test
    test
    2
    test_field+1
    2
    lacks "summary" attribute line 6 column 22 - Warning: lacks "alt" attribute line 38 column 1 - Warning:
    lacks "summary" attribute line 46 column 1 - Warning:
    lacks "summary" attribute line 61 column 1 - Warning:
    lacks "summary" attribute line 159 column 1 - Warning:
    lacks "summary" attribute line 338 column 13 - Warning: anchor "sqlite3" already defined line 354 column 13 - Warning: anchor "sqlite3_blob" already defined line 370 column 13 - Warning: anchor "sqlite3_context" already defined line 382 column 13 - Warning: anchor "sqlite3_stmt" already defined line 404 column 13 - Warning: anchor "sqlite3_value" already defined line 417 column 13 - Warning: anchor "sqlite3_aggregate_context" already defined line 436 column 13 - Warning: anchor "sqlite3_auto_extension" already defined line 456 column 13 - Warning: anchor "sqlite3_bind_parameter_count" already defined line 475 column 13 - Warning: anchor "sqlite3_bind_parameter_index" already defined line 487 column 13 - Warning: anchor "sqlite3_bind_parameter_name" already defined line 506 column 13 - Warning: anchor "sqlite3_blob_bytes" already defined line 517 column 13 - Warning: anchor "sqlite3_blob_close" already defined line 527 column 13 - Warning: anchor "sqlite3_blob_open" already defined line 556 column 13 - Warning: anchor "sqlite3_blob_read" already defined line 571 column 13 - Warning: anchor "sqlite3_blob_write" already defined line 591 column 13 - Warning: anchor "sqlite3_busy_handler" already defined line 650 column 13 - Warning: anchor "sqlite3_busy_timeout" already defined line 668 column 13 - Warning: anchor "sqlite3_changes" already defined line 696 column 13 - Warning: anchor "sqlite3_clear_bindings" already defined line 709 column 13 - Warning: anchor "sqlite3_close" already defined line 724 column 13 - Warning: anchor "sqlite3_column_count" already defined line 737 column 13 - Warning: anchor "sqlite3_db_handle" already defined line 751 column 13 - Warning: anchor "sqlite3_enable_load_extension" already defined line 766 column 13 - Warning: anchor "sqlite3_enable_shared_cache" already defined line 798 column 13 - Warning: anchor "sqlite3_exec" already defined line 839 column 13 - Warning: anchor "sqlite3_extended_result_codes" already defined line 857 column 13 - Warning: anchor "sqlite3_finalize" already defined line 878 column 13 - Warning: anchor "sqlite3_get_autocommit" already defined line 891 column 13 - Warning: anchor "sqlite3_interrupt" already defined line 909 column 13 - Warning: anchor "sqlite3_last_insert_rowid" already defined line 930 column 13 - Warning: anchor "sqlite3_load_extension" already defined line 950 column 13 - Warning: anchor "sqlite3_progress_handler" already defined line 978 column 13 - Warning: anchor "sqlite3_release_memory" already defined line 991 column 13 - Warning: anchor "sqlite3_reset" already defined line 1006 column 13 - Warning: anchor "sqlite3_reset_auto_extension" already defined line 1019 column 13 - Warning: anchor "sqlite3_set_authorizer" already defined line 1071 column 13 - Warning: anchor "sqlite3_sleep" already defined line 1085 column 13 - Warning: anchor "sqlite3_soft_heap_limit" already defined line 1109 column 13 - Warning: anchor "sqlite3_step" already defined line 1168 column 13 - Warning: anchor "sqlite3_table_column_metadata" already defined line 1224 column 13 - Warning: anchor "sqlite3_thread_cleanup" already defined line 1240 column 13 - Warning: anchor "sqlite3_total_changes" already defined line 1261 column 13 - Warning: anchor "sqlite3_update_hook" already defined line 1288 column 13 - Warning: anchor "sqlite3_user_data" already defined line 1328 column 5 - Warning: anchor "SQLITE_ABORT" already defined line 1329 column 13 - Warning: anchor "SQLITE_ABORT" already defined line 1402 column 5 - Warning: anchor "SQLITE_ALTER_TABLE" already defined line 1403 column 13 - Warning: anchor "SQLITE_ALTER_TABLE" already defined line 1461 column 5 - Warning: anchor "SQLITE_ANY" already defined line 1462 column 13 - Warning: anchor "SQLITE_ANY" already defined line 1480 column 5 - Warning: anchor "SQLITE_BLOB" already defined line 1481 column 13 - Warning: anchor "SQLITE_BLOB" already defined line 1509 column 5 - Warning: anchor "SQLITE_DENY" already defined line 1510 column 13 - Warning: anchor "SQLITE_DENY" already defined line 1534 column 5 - Warning: anchor "SQLITE_IOERR_BLOCKED" already defined line 1535 column 13 - Warning: anchor "SQLITE_IOERR_BLOCKED" already defined line 1571 column 5 - Warning: anchor "SQLITE_STATIC" already defined line 1572 column 13 - Warning: anchor "SQLITE_STATIC" already defined line 1591 column 5 - Warning: anchor "SQLITE_VERSION" already defined line 1592 column 13 - Warning: anchor "SQLITE_VERSION" already defined line 1619 column 5 - Warning: anchor "sqlite3_aggregate_count" already defined line 1620 column 13 - Warning: anchor "sqlite3_aggregate_count" already defined line 1644 column 5 - Warning: anchor "sqlite3_bind_blob" already defined line 1645 column 13 - Warning: anchor "sqlite3_bind_blob" already defined line 1713 column 5 - Warning: anchor "sqlite3_collation_needed" already defined line 1714 column 13 - Warning: anchor "sqlite3_collation_needed" already defined line 1756 column 5 - Warning: anchor "sqlite3_column_blob" already defined line 1757 column 13 - Warning: anchor "sqlite3_column_blob" already defined line 1803 column 1 - Warning:
    lacks "summary" attribute line 1861 column 5 - Warning: anchor "sqlite3_column_database_name" already defined line 1862 column 13 - Warning: anchor "sqlite3_column_database_name" already defined line 1892 column 5 - Warning: anchor "sqlite3_column_decltype" already defined line 1893 column 13 - Warning: anchor "sqlite3_column_decltype" already defined line 1918 column 5 - Warning: anchor "sqlite3_column_name" already defined line 1919 column 13 - Warning: anchor "sqlite3_column_name" already defined line 1939 column 5 - Warning: anchor "sqlite3_commit_hook" already defined line 1940 column 13 - Warning: anchor "sqlite3_commit_hook" already defined line 1960 column 5 - Warning: anchor "sqlite3_complete" already defined line 1961 column 13 - Warning: anchor "sqlite3_complete" already defined line 1984 column 5 - Warning: anchor "sqlite3_create_collation" already defined line 1985 column 13 - Warning: anchor "sqlite3_create_collation" already defined line 2041 column 5 - Warning: anchor "sqlite3_create_function" already defined line 2042 column 13 - Warning: anchor "sqlite3_create_function" already defined line 2111 column 5 - Warning: anchor "sqlite3_errcode" already defined line 2112 column 13 - Warning: anchor "sqlite3_errcode" already defined line 2142 column 5 - Warning: anchor "sqlite3_free" already defined line 2143 column 13 - Warning: anchor "sqlite3_free" already defined line 2159 column 5 - Warning: anchor "sqlite3_free_table" already defined line 2160 column 13 - Warning: anchor "sqlite3_free_table" already defined line 2206 column 5 - Warning: anchor "sqlite3_get_auxdata" already defined line 2207 column 13 - Warning: anchor "sqlite3_get_auxdata" already defined line 2237 column 5 - Warning: anchor "sqlite3_libversion" already defined line 2238 column 13 - Warning: anchor "sqlite3_libversion" already defined line 2260 column 5 - Warning: anchor "sqlite3_mprintf" already defined line 2261 column 13 - Warning: anchor "sqlite3_mprintf" already defined line 2323 column 5 - Warning: anchor "sqlite3_open" already defined line 2324 column 13 - Warning: anchor "sqlite3_open" already defined line 2356 column 5 - Warning: anchor "sqlite3_prepare" already defined line 2357 column 13 - Warning: anchor "sqlite3_prepare" already defined line 2439 column 5 - Warning: anchor "sqlite3_profile" already defined line 2440 column 13 - Warning: anchor "sqlite3_profile" already defined line 2471 column 5 - Warning: anchor "sqlite3_result_blob" already defined line 2472 column 13 - Warning: anchor "sqlite3_result_blob" already defined line 2518 column 5 - Warning: anchor "sqlite3_value_blob" already defined line 2519 column 13 - Warning: anchor "sqlite3_value_blob" already defined line 389 column 120 - Warning: trimming empty

    line 398 column 6 - Warning: trimming empty

    line 542 column 20 - Warning: trimming empty

    line 544 column 7 - Warning: trimming empty

    line 835 column 62 - Warning: trimming empty

    line 1196 column 29 - Warning: trimming empty

    line 1203 column 7 - Warning: trimming empty

    line 1209 column 13 - Warning: trimming empty

    line 1215 column 7 - Warning: trimming empty

    line 1368 column 89 - Warning: trimming empty

    line 1495 column 65 - Warning: trimming empty

    line 1501 column 6 - Warning: trimming empty

    line 1660 column 11 - Warning: trimming empty

    line 1666 column 6 - Warning: trimming empty

    line 1802 column 17 - Warning: trimming empty

    line 1805 column 49 - Warning: trimming empty

    line 1805 column 53 - Warning: trimming empty

    line 1822 column 14 - Warning: trimming empty

    line 1830 column 28 - Warning: trimming empty

    line 1833 column 45 - Warning: trimming empty

    line 1833 column 45 - Warning: trimming empty

  • line 1835 column 24 - Warning: trimming empty

    line 1835 column 24 - Warning: trimming empty

  • line 1838 column 6 - Warning: trimming empty

    line 1843 column 34 - Warning: trimming empty

    line 1847 column 6 - Warning: trimming empty

    line 2177 column 88 - Warning: trimming empty

    line 2183 column 7 - Warning: trimming empty

    line 2184 column 46 - Warning: trimming empty

    line 2193 column 7 - Warning: trimming empty

    line 2296 column 85 - Warning: trimming empty

    line 2298 column 20 - Warning: trimming empty

    line 2298 column 84 - Warning: trimming empty

    line 2302 column 20 - Warning: trimming empty

    line 2303 column 52 - Warning: trimming empty

    line 2305 column 20 - Warning: trimming empty

    line 2306 column 33 - Warning: trimming empty

    line 2308 column 20 - Warning: trimming empty

    line 2313 column 72 - Warning: trimming empty

    line 2317 column 20 - Warning: trimming empty

    line 2413 column 38 - Warning: trimming empty

    line 2423 column 10 - Warning: trimming empty

    line 2423 column 10 - Warning: trimming empty

  • line 2435 column 1 - Warning: trimming empty

    #cfe8bd 2426 code fixed 2007 Jun anonymous 2007 Jun 4 4 Access violation calling sqlite3_column_text after sqlite3_reset A bug on my side provoked a seg-fault in sqlite3 3.4.0: - prepare 2 select statements (among many others).{linebreak} - execute the first statement, read the 5th column (index 4).{linebreak} - reset first statement.{linebreak} - execute the second statement.{linebreak} - read the 1st column (index 0) of the first statement. -> access violation, stack trace: memcpy{linebreak} sqlite3VdbeMemExpandBlob (pMem->z is 0x018){linebreak} sqlite3ValueText{linebreak} sqlite3_value_text{linebreak} sqlite3_column_text{linebreak} #cfe8bd 2425 code fixed 2007 Jun anonymous 2007 Jun 3 3 ftruncate on platform where off_t is not 64 bit Please apply this one liner to avoid a corrupted database on a platform where the ftruncate() function declaration is missing and off_t is not a 64 bit value: Index: src/os_unix.c =================================================================== RCS file: /sqlite/sqlite/src/os_unix.c,v retrieving revision 1.133 diff -u -3 -p -r1.133 os_unix.c --- src/os_unix.c 8 Jun 2007 18:27:03 -0000 1.133 +++ src/os_unix.c 19 Jun 2007 05:04:49 -0000 @@ -1271,7 +1271,7 @@ int sqlite3UnixSyncDirectory(const char static int unixTruncate(OsFile *id, i64 nByte){ int rc; assert( id ); - rc = ftruncate(((unixFile*)id)->h, nByte); + rc = ftruncate(((unixFile*)id)->h, (off_t)nByte); SimulateIOError( rc=1 ); if( rc ){ return SQLITE_IOERR_TRUNCATE; Yes, I (now) know that -Wall would have caught the fact that there was no declaration of ftruncate which resulted in pushing a 64 bit length value instead of the 32 bit value required by the target platform. But even so, I think this patch is at worst harmless, and could save a lot of debugging pain for somebody else in a similar situation. http://groups.google.com/group/sqlitejdbc/browse_thread/thread/a1535f3419c07796 #cfe8bd 2424 doc fixed 2007 Jun anonymous 2007 Jun 3 4 Documentation for Tcl-level access to incremental blob I/O is missing. > > Version 3.4.0 also includes support for new features such as: > > * Incremental BLOB I/O > Is the incremental blob I/O available at the level of the Tcl binding ? > >From the online information this seems to be currently available only at the > C level. > Yes. There is a new (undocumented!) "incrblob" method on the database object that opens a channel to BLOB. The syntax is like this: db incrblob ?-readonly? ?DBNAME? TABLENAME COLUMN ROWID I neglected to update the documentation to describe how this works. Please open a ticket for me so that I do not forget again... _2007-Jun-18 17:40:41 by anonymous:_ {linebreak} Will/does this work with fts1/2/... etc as well ? #cfe8bd 2423 code fixed 2007 Jun anonymous 2007 Jun 4 4 Check-in [4086] mkdll.sh no longer creates sqlite3.dll and overwrites the previsouly created tclsqlite3.dll in the same script. #cfe8bd 2422 code fixed 2007 Jun anonymous 2007 Jun 1 1 pager.c, line 662: #define pager_datahash(X) 0 pager.c, line 662: #define pager_datahash(X) 0 is no longer in sync with line 596 of the same file: static u32 pager_datahash(int nByte, unsigned char *pData){ This can cause problems with the reference in line 1191. Propsed fix: #define pager_datahash(X,Y) 0 #c8c8c8 2421 code closed 2007 Jun anonymous 2007 Jun 1 1 unresolved external unresolved external for the _sqlite_open,exec,close etc. referenced from the OBJ file created.. The ticket system is for SQLite bugs. General questions on how to use the library and how to compile and link a program should be sent to the mailing list. #c8c8c8 2420 code closed 2007 Jun anonymous 2007 Jun 5 5 sqlite3_prepare() don't work in php pdo implementation i've to open this bug again, 'cause it was closed as outside of sqlite even if it's not so (infact the bugged behaviour doesn't occour in the pdo extension with a "correct" libsqlite - ie: 3.3.4) I'm using SQLITE drivers for PHP's PDO extension. This extension binds abastract layered prepared statement functions to the specific driver's ones. Specifically, PHP code calls sqlite3_prepare() function (see: http://cvs.php.net/viewvc.cgi/pecl/pdo_sqlite/sqlite_driver.c?revision=1.33&view=markup) Somewhere between libsqlite 3.3.5 and 3.3.12 (i've tested these two version only) the result from calling sqlite3_prepare() went corrupted (the binding between value and placeholder in the prepared statement doesn't work). _2007-Jun-17 21:02:49 by anonymous:_ {linebreak} Someone who uses PHP would have to run it through valgrind to find the problem in the PHP wrapper. If you post the output of valgrind someone will take a look. ---- _2007-Jun-17 21:39:24 by anonymous:_ > Somewhere between libsqlite 3.3.5 and 3.3.12 ... the result > from calling sqlite3_prepare() went corrupted Or maybe PHP had a bug in its sqlite3_prepare() usage which was triggered by a change in libsqlite. If it really is an SQLite3 bug, someone (you, maybe?) will be able to come up with a piece of example code using the C API which demonstrates the "bug". If such an example isn't available, it seems entirely reasonable to assume that the "bug" isn't in SQLite. Even if someone doesn't just close the ticket, you're probably not going to get a fix for a problem which can only be reproduced if the SQLite maintainers install PHP. ---- _2007-Jun-18 01:56:09 by anonymous:_ {linebreak} This is an sqlite ticket system. Please post your question to the sqlite mailing list with a short complete PHP example that exhibits the unstated problem. If you can demonstrate the problem using the sqlite3 commandline shell, or via Tcl or via C code using the sqlite API then please re-open this ticket. ---- _2007-Jun-18 07:45:42 by anonymous:_ {linebreak} > Or maybe PHP had a bug in its sqlite3_prepare() usage > which was triggered by a change in libsqlite. ok, it could be, but as far as it is demostrated neither my hypothesis nor this one, i think more research is needed befor closing the bug, isn't it? > If it really is an SQLite3 bug, someone (you, maybe?) will be > able to come up with a piece of example code using the > C API which demonstrates the "bug". i put a link to pdo source code which uses the c api, isn't it enough as example code? ---- _2007-Jun-18 10:49:33 by anonymous:_ > i think more research is needed befor closing the bug, isn't it? I think more research was needed before _opening_ the bug. For example, SQLite has a really nice ticket system. Did you search it for similar bugs? 3.3.12 has been out for quite a while, so if this was a core problem there may already a report of the same problem affecting more systems/bindings/whatever. If there is no such report, it's probably a PDO problem. If you didn't bother searching, that's just another reason to just close this ticket. Anyhow, if you don't want the ticket closed, just re-open it. > i put a link to pdo source code which uses the c api, isn't > it enough as example code? If, by itself, it demonstrates the bug. If you actually want someone to fix this, you're going to have to overcome the initial "is this my problem?" question a SQLite maintainer is going to ask when they see this ticket. If the answer to that question is anything but a clear "yes", the best case is that the ticket will be closed with a "not reproducible" or "not in sqlite" or whatever (this is slightly better than just having the ticket get ignored, which is the other likely situation). ---- _2007-Jun-21 07:36:53 by anonymous:_ {linebreak} > If there is no such report, it's probably a PDO problem. this is quite the same i was told on php bug center: if there's no such report, it's probably an sqlite problem. no one, both here and there, seems to be interested in finding if the bug affected the software he's working on. free to do so, but i'm used differently on my own code. > If you didn't bother searching, that's just another > reason to just close this ticket. that's a speech! it's surely most important being intransigent with awful user than caring about bugs. it's a pity that fine sofwtare often has nasty developing community, the only thing an user could do about this kind of matters is to search his resources elsewhere, that's what i'll do: no more sqlite for me, i hope you'd appreciate the loss of a real pain user. ---- _2007-Jun-21 07:48:14 by anonymous:_ {linebreak} > If you actually want someone to fix this, you're going to have to > overcome the initial "is this my problem?" question a SQLite > maintainer is going to ask when they see this ticket. first of all no one ask anything like so, the first ticket i opened on the subject was even closed with no comment at all from people who closed it. as for the sqlite maintainer's problem: which ones would be? if a code maintener is not interested in bugged behaviour what should he be interested in? i'm happy when people warns me about potential bugs in my code, 'cause this improve its quality, and i use to made my survey about what could be the causes: that's because good software is something to be proud of and that deserves my attention, most of all if it's mine. if you haven't this basic attutidue how could you dedicate yourself to code's maintenance? > If the answer to that question is anything but a clear "yes", > the best case is that the ticket will be closed so it's more important etiquette for you than have good code? that's a strange way to care about software improvement. ---- _2007-Jun-21 12:44:48 by drh:_ {linebreak} Two points: 1: The official maintainers of SQLite all have logins. When we close tickets, our logins appear by the close message. And when we add comments, our names appear at the top of the comment. The SQLite ticketing system, however, allows any anonymous user to modify a ticket - even close a ticket - anytime they want. And a few of the 10000 or so daily anonymous visitors to this site do take the time to go in an clean up a ticket here or there. I am very grateful for the help and hope it continues. But on the other hand, you should not confuse the actions of anonymous users with the actions of maintainers. Up until this comment, no maintainer has taken any action on this ticket - everything up until now has been done by anonymous passers-by. 2: On the other hand, the assessment of the anonymous passers-by seems to have been quite reasonable. The original problem statement in this ticket has very low credibility. SQLite is very, very externsively tested, so a serious problem in sqlite3_prepare() is unlikely to go unnoticed for long. It is true that we do not test against PHP here, but there are thousands of PHP+SQLite users, many of whom write very precise and well-crafted bug reports when things go wrong. Version 3.3.12 has been out for almost half a year and I have not heard a peep from any of these people which suggests to me that they are not having any problems. In addition, the original bug report gives us only a vague description of the problem: there is no PHP script or C code or SQL statement or anything else that might help us isolate the problem. This suggests that the original bug reporter is unclear about what is going on and perhaps what they are doing. All of these factors conspire to give this bug report very low credibility. So we, the official maintainers, did not object when anonymous users closed the ticket. We are appreciative of any and all bug reports and we read every one. We do not want to do anything to discourage people from entering new bug reports. On the other hand, if you want us to act energetically on your bug report, the best way to make that happen is to state precisely and consisely what the problem is and provide a means for us to reproduce it. Bug reports with vague problem statements about "doesn't work with PHP" tend to languish since it is unclear what, if anything, we can do about them. ---- _2007-Jun-22 08:56:20 by anonymous:_ {linebreak} > On the other hand, if you want us to act energetically on your bug > report, the best way to make that happen is to state precisely and > consisely what the problem is and provide a means for us to > reproduce it. Bug reports with vague problem statements about > "doesn't work withPHP" tend to languish since it is unclear > what, if anything, we can do about them. The matter is that my ticket was closed before I could produce any accurate code examples or requested test. I was asked to send a valgrind output, for example, but at the time I read that message the ticket was already closed. I don't pretend "energically acting", it could be sufficient that the ticket were payed attention to. I repeat myself: when I receive a bug report I use to spend at least a few moments in order to ask the reporter the info I need to understand if it were really a bug or not. None of this was done here: it was preferred to ignore the ticket before any further details could be given, relying on the fact that "if no one had reported it before then it shouldn't exist". Last thing: dropping responsibilty for bad managed ticket to anonymous user doesn't free the mainteiner from it, if they endorse anonymous' behaviour. ---- _2007-Jun-22 11:13:32 by anonymous:_ {linebreak} I think you might be misunderstanding the meaning of a "closed" ticket here. While it's true that in many ticket systems, a "closed" state is the end-of-the-line for a ticket, with CVSTrac it's not permanent. If you don't think the ticket should be closed, add remarks with additional information about the bug and just _change the status_ back to what you think is appropriate. There are no "workflow" controls that will stop this. Basically, in the context of SQLite's ticket system, all that "closed" means is "the maintainers can't do anything more with this ticket". You seem to be reading it more as "screw you, go away", which is entirely understandable if you've dealt with more "sophisticated" ticket systems. #f2dcdc 2419 build active 2007 Jun anonymous 2007 Jun 1 2 'CP_UTF8' : undeclared identifier when trying to build the dll 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! #cfe8bd 2418 code fixed 2007 Jun drh 2007 Jun drh 1 1 Database corruption following malloc failure in auto-vacuum mode This bug has already been fixed by check-ins [4079] and [4080]. The purpose of this ticket is to document the problem. A long-standing logic error in the auto-vacuum system can result in database corruption. The bug appears under the following conditions: *: Auto-vacuum (or incremental-vacuuum) mode is enabled *: An explicit transaction is started *: There are many updates within the transaction - so many that they will not all fit in cache and some of the cache pages must be spilled back to the database file and reused for different pages. *: After the cache spill on the previous step but still within the transaction, either a CREATE TABLE or a CREATE INDEX statement is executed. The root page of the new table or index must land on one of the pages that was spilled in the previous step. *: In another update that comes after the CREATE TABLE or CREATE INDEX but still within the same transaction, a malloc() fails forcing the entire transaction to rollback. The logic error that causes this bug has been around since auto-vacuum was first introduced in version 3.1.0. But we are unsure if it was actually possible to hit the bug until recently. This bug came to light while doing "soak" testing of the changes that fixed ticket #2409. While running the soak tests on a build that had auto-vacuum turned on by default and has a small default cache size (thus increasing the chance of a cache spill) a single test fault was observed out of tens of thousands of tests. Further investigation led to the discovery of the logic error described by this ticket. This error has never been observed "in the wild". It has only been seen in test cases that deliberately stress the system, and then only when SQLite is configured with an unusually small cache and with auto-vacuuum enabled by default (a configuration typical of embedded devices, but atypical for workstation applications.) The bug seems to only apply if one uses a CREATE TABLE or CREATE INDEX statement late in a multi-statement transaction and then later rolls back that same transaction due to a malloc() failure. This seems to be a very unlikely sequence of events in practice and so even though the consequences of this bug are severe, we do not believe this is an important bug because it is so difficult to hit. But regardless of whether or not it is important, it has now been fixed. fixed typo. --andy #cfe8bd 2416 doc fixed 2007 Jun anonymous 2007 Jun drh 5 5 Spelling error In the documentation for upcoming 3.4.0 release there is an error: Internationalization of the TRIM() functin. Ticket #2323 should be Internationalization of the TRIM() function. Ticket #2323 _2007-Jun-15 18:38:37 by anonymous:_ {linebreak} A few more: _changes.tcl_ which is when the current release is 3.4.0 instead of 3.3.18. ^^^^ _lang.tcl_ Zeroblobs can be use to reserve space for a BLOB ^^^^ #cfe8bd 2415 code fixed 2007 Jun anonymous 2007 Jun drh 1 1 [4061] propagates SQLITE_ABORT outside nested loops Check-in [4061] causes problems with progress handlers and nested loops. SQLITE_ARBOT is propagated to outer loops which do not have any progress handler. See example code below to reproduce. Before [4061], only the inner loop aborted but allowed the outer loop to continue. #include #include "sqlite3.h" int progress (void *u) { return 1; } sqlite3 *db; int check ( int rc ){ if( rc != SQLITE_OK && rc != SQLITE_ROW && rc != SQLITE_DONE ){ printf ("%d - %s\n", rc, sqlite3_errmsg(db) ); } return rc; } #pragma argsused int main(int argc, char* argv[]) { sqlite3_stmt *pStmtOuter, *pStmtInner; check( sqlite3_open( "test.db3", &db) ); check( sqlite3_exec( db, "CREATE TABLE IF NOT EXISTS t (a);" "INSERT INTO t VALUES (1);" "INSERT INTO t VALUES (2);", NULL, NULL, NULL)); /* Outer loop - does not have progress handler set. However, it is nevertheless interrupted at 2nd run. */ check( sqlite3_prepare( db, "SELECT * FROM t;", -1, &pStmtOuter, NULL)); while (check( sqlite3_step( pStmtOuter)) == SQLITE_ROW) { /* Inner loop - runs with progress handler. */ sqlite3_progress_handler( db, 1, progress, NULL); check( sqlite3_prepare( db, "SELECT * FROM t;", -1, &pStmtInner, NULL)); while (check( sqlite3_step( pStmtInner)) == SQLITE_ROW) { }; check( sqlite3_finalize( pStmtInner )); /* Remove progress handler after inner loop finished. */ sqlite3_progress_handler( db, 0, NULL, NULL); }; check( sqlite3_finalize( pStmtOuter )); check( sqlite3_close( db )); printf ("Done"); scanf ("*%s"); return 0; } #f2dcdc 2414 code active 2007 Jun anonymous 2007 Jun 1 1 Unable t 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:_ {linebreak} 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. #f2dcdc 2413 code active 2007 Jun anonymous 2007 Jun drh 1 1 1 bug and 2 suggestions in lemon Hello, ... {linebreak} Sorry for my english :-) and if i post this with Severity/Priority error. {linebreak} I found some not serious bug and have some suggetions. {linebreak} ============================================================================={linebreak} BUG FIX: {linebreak} lemon.c for Win32. It not found lempar.c - backslash-bug. {linebreak} function: {linebreak} PRIVATE char *pathsearch(argv0,name,modemask); {linebreak} PATCH: {linebreak} ---- CUT --------------------------------------------------------------------{linebreak} --- C:/lemon.c Wed Jun 13 15:02:37 2007 {linebreak} +++ D:/Den/Lemon/lemon.c Wed Jun 13 16:25:22 2007 {linebreak} @@ -2911,7 +2911,11 @@ {linebreak} c = *cp; {linebreak} *cp = 0; {linebreak} path = (char *)malloc( strlen(argv0) + strlen(name) + 2 ); {linebreak} - if( path ) sprintf(path,"%s/%s",argv0,name); {linebreak} + #ifdef __WIN32__ {linebreak} + if( path ) sprintf(path,"%s\\%s",argv0,name); {linebreak} + #else {linebreak} + if( path ) sprintf(path,"%s/%s",argv0,name); {linebreak} + #endif {linebreak} *cp = c; {linebreak} }else{ {linebreak} extern char *getenv(); {linebreak} @@ -2920,11 +2924,19 @@ {linebreak} path = (char *)malloc( strlen(pathlist)+strlen(name)+2 ); {linebreak} if( path!=0 ){ {linebreak} while( *pathlist ){ {linebreak} - cp = strchr(pathlist,':'); {linebreak} + #ifdef __WIN32__ {linebreak} + cp = strchr(pathlist,';'); {linebreak} + #else {linebreak} + cp = strchr(pathlist,':'); {linebreak} + #endif {linebreak} if( cp==0 ) cp = &pathlist[strlen(pathlist)]; {linebreak} c = *cp; {linebreak} *cp = 0; {linebreak} - sprintf(path,"%s/%s",pathlist,name); {linebreak} + #ifdef __WIN32__ {linebreak} + sprintf(path,"%s\\%s",pathlist,name); {linebreak} + #else {linebreak} + sprintf(path,"%s/%s",pathlist,name); {linebreak} + #endif {linebreak} *cp = c; {linebreak} if( c==0 ) pathlist = ""; {linebreak} else pathlist = &cp[1]; {linebreak} ---- CUT --------------------------------------------------------------------{linebreak} ============================================================================= {linebreak} SUGGESTION 1: {linebreak} Why we allocate parser with mallocProc parameter of ParseAlloc function {linebreak} and free with freeProc of ParseFree function? {linebreak} We do this because we want what parser is user-allocatable {linebreak} with USER-DEFINED-MEMORY-ALOCATION-WAY but not with "malloc"/"free" from stdlib... am i right? {linebreak} If so... why we still allocate memory for parser stack with "realloc" function? {linebreak} It's bad for solutions where is no stdlib. {linebreak} My suggestion is {linebreak} FIRST WAY: {linebreak} To add to yyParser struct 3 variables like {linebreak} void *mem_alloc_fn; {linebreak} void *mem_realloc_fn; {linebreak} void *mem_free_fn; {linebreak} and add 3 directives like {linebreak} %memory_alloc {linebreak} %memory_realloc {linebreak} %memory_free {linebreak} and if it declared - use it for allocating/free/reallocating memory in parser. {linebreak} and {linebreak} - void *ParseAlloc(void *(*mallocProc)(size_t)); {linebreak} will now as void *ParseAlloc(); {linebreak} - void ParseFree(void *pParser, void (*freeProc)(void*)); {linebreak} will now as void ParseFree(void *pParser); {linebreak} OR SECOND WAY (very simple): {linebreak} To add to yyParser struct 1 variable like {linebreak} void *mem_realloc_fn; {linebreak} - void *ParseAlloc(void *(*mallocProc)(size_t)); {linebreak} will now as void *ParseAlloc(void *(*mallocProc)(size_t), void *(*reallocProc)(void *, size_t)); {linebreak} store reallocProc in mem_realloc_fn in yyParser {linebreak} and in yyGrowStack something like this: {linebreak} ... yyGrowStack (...) {linebreak} { {linebreak} .... {linebreak} if(pParser->mem_realloc_fn != NULL) {linebreak} { {linebreak} pNew = pParser->mem_realloc_fn(p->yystack, newSize*sizeof(pNew[0])); {linebreak} } {linebreak} else {linebreak} { {linebreak} pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); {linebreak} } {linebreak} .... {linebreak} } {linebreak} and use it for reallocating memory in parser. {linebreak} In this ways - memory allocating in parser is under FULL user control. {linebreak} ============================================================================= {linebreak} SUGGESTION 2: {linebreak} I build lemon with VC 8.0 with option /Wp64 (Detect 64-Bit Portability Issues) {linebreak} and have warnings. Type int, size_t, pointer and unsigned long have diferent size on x32 and x64 platforms. {linebreak} Can you fix type difference, please? {linebreak} Only you can choice better way for this - type conversion OR change type of 'warning' variables. {linebreak} WARNINGS: {linebreak} d:\den\lemon\lemon.c(1331) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(1337) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(1455) : warning C4113: 'int (__cdecl *)()' differs in parameter lists from 'int (__cdecl *)(const void *,const void *)' {linebreak} d:\den\lemon\lemon.c(1578) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1578) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1581) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1581) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1586) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1586) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1588) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1588) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1590) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1590) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1592) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1592) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1595) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1595) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1596) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1596) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1624) : warning C4311: 'type cast' : pointer truncation from 'char **' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1624) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1628) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1628) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1629) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1629) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'char **' of greater size {linebreak} d:\den\lemon\lemon.c(1658) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(1661) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(1774) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1774) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1785) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1785) : warning C4311: 'type cast' : pointer truncation from 'char *' to 'unsigned long' {linebreak} d:\den\lemon\lemon.c(1883) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(2722) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(3171) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(3173) : warning C4018: '>=' : signed/unsigned mismatch {linebreak} d:\den\lemon\lemon.c(3184) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(3340) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(3346) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} d:\den\lemon\lemon.c(3542) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data {linebreak} Ups ... drh, sorry - title change. #c8c8c8 2412 build closed 2007 Jun anonymous 2007 Jun a.rottmann 1 1 Can't make Sqlite 3.3.17 on Solaris 10 X86 Can't build Sqlite3.3.17 on Solaris 10 X86, make failed to make, the last two commands are as following: ./libtool --mode=link gcc -g -O2 -I. -I../sqlite-3.3.17/src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -o libsqlite3.la alter.lo analyze.lo attach.lo auth.lo btree.lo build.lo callback.lo complete.lo date.lo delete.lo expr.lo func.lo hash.lo insert.lo loadext.lo main.lo opcodes.lo os.lo os_unix.lo os_win.lo os_os2.lo pager.lo parse.lo pragma.lo prepare.lo printf.lo random.lo select.lo table.lo tokenize.lo trigger.lo update.lo util.lo vacuum.lo vdbe.lo vdbeapi.lo vdbeaux.lo vdbefifo.lo vdbemem.lo where.lo utf.lo legacy.lo vtab.lo \ -rpath /usr/local/lib -version-info "8:6:8" gcc -shared -Wl,-h -Wl,libsqlite3.so.0 -o .libs/libsqlite3.so.0.8.6 .libs/alter.o .libs/analyze.o .libs/attach.o .libs/auth.o .libs/btree.o .libs/build.o .libs/callback.o .libs/complete.o .libs/date.o .libs/delete.o .libs/expr.o .libs/func.o .libs/hash.o .libs/insert.o .libs/loadext.o .libs/main.o .libs/opcodes.o .libs/os.o .libs/os_unix.o .libs/os_win.o .libs/os_os2.o .libs/pager.o .libs/parse.o .libs/pragma.o .libs/prepare.o .libs/printf.o .libs/random.o .libs/select.o .libs/table.o .libs/tokenize.o .libs/trigger.o .libs/update.o .libs/util.o .libs/vacuum.o .libs/vdbe.o .libs/vdbeapi.o .libs/vdbeaux.o .libs/vdbefifo.o .libs/vdbemem.o .libs/where.o .libs/utf.o .libs/legacy.o .libs/vtab.o -lc (cd .libs && rm -f libsqlite3.so.0 && ln -s libsqlite3.so.0.8.6 libsqlite3.so.0) (cd .libs && rm -f libsqlite3.so && ln -s libsqlite3.so.0.8.6 libsqlite3.so) false cru .libs/libsqlite3.a alter.o analyze.o attach.o auth.o btree.o build.o callback.o complete.o date.o delete.o expr.o func.o hash.o insert.o loadext.o main.o opcodes.o os.o os_unix.o os_win.o os_os2.o pager.o parse.o pragma.o prepare.o printf.o random.o select.o table.o tokenize.o trigger.o update.o util.o vacuum.o vdbe.o vdbeapi.o vdbeaux.o vdbefifo.o vdbemem.o where.o utf.o legacy.o vtab.o make: *** [libsqlite3.la] Error 1 _2007-Jun-13 07:36:18 by anonymous:_ {linebreak} I am Amber, my email address is :guxiaobo1982 at hotmail dot com ---- _2007-Jun-13 13:37:02 by anonymous:_ {linebreak} configure is not finding 'ar' and is using 'false' instead. Change 'false' to 'ar' in the generated Makefile and see what happens. If that still fails, install the appropriate version of GNU ar. ---- _2007-Jun-15 00:59:11 by anonymous:_ {linebreak} ThanksCit is due to arB #f2dcdc 2411 new active 2007 Jun anonymous 2007 Jun 5 3 fts2 RFE - Separate index and storage 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). 1: 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. 1: 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:_ {linebreak} 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:

    #cfe8bd 2410 doc fixed 2007 Jun rdc 2007 Jun 5 3 typo in checkin 4053 In the checkin 4053 the following line: + are people who will argument that a well-normalized database design should be: + are people who will argue that a well-normalized database design #f2dcdc 2409 code active 2007 Jun anonymous 2007 Jun drh 1 1 Database malformed with SQLite3.3.17 on WindowsXP 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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}] 
    #f2dcdc 2408 code active 2007 Jun anonymous 2007 Jun 2 1 BLOBs not output correctly in .mode insert (shell.c - isnumber) The method {linebreak} static int isNumber(const char *z, int *realnum) {linebreak} {linebreak} from shell.c is wrong. {linebreak} Steps to reproduce: {linebreak} 1. Get the file www.smatei.3x.ro/project1.zip {linebreak} 2. extract project1.db from the zip file {linebreak} 3. execute {linebreak} sqlite3 project1.db {linebreak} sqlite>.mode insert {linebreak} sqlite> select ID, Name, Color, Active, Priority, PrioritySource, IndexOrder, Language, 0 from Keywords; {linebreak} INSERT INTO Keywords VALUES(42,#####,0,1,0,0,42,'',0); {linebreak} INSERT INTO Keywords VALUES(41,'######',0,1,0,0,43,'',0);{linebreak} If you look at the 42 item, the string next to 42 is not enclosed by the string delimiter '. {linebreak} 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). {linebreak} A fix for this might be to set the first parameter unsigned char {linebreak} static int isNumber(unsigned const char *z, int *realnum) {linebreak} but I am not sure, because I haven't written C code for a long time. {linebreak} If you have any more questions, please ask. {linebreak} Best Regards, {linebreak} Stefan _2007-Jun-11 14:46:03 by drh:_ {linebreak} 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:_ {linebreak} The output is 41|X'D791D7A8D799D799D7A7D793D790D7A0D7A1'{linebreak} 42|X'D7A1D798D7A4D7A1' ---- _2007-Jun-11 16:29:46 by drh:_ {linebreak} 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(' «Í'); sqlite> ---- _2007-Jun-11 20:07:09 by anonymous:_ {linebreak} 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:_ {linebreak} .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:_ {linebreak} 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"{linebreak} .mode insert whatever{linebreak} select f1, f2, f3 from t1;{linebreak} 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,{linebreak} Stefan{linebreak} #cfe8bd 2407 code fixed 2007 Jun anonymous 2007 Jun 1 4 Problem with ` (0x60) character in LIKE statement
    I have a table and run a query where LIKE statement contains ` (0x60) character:  select * from TABLE where FIELD like '`%';  In response SQLite correctly returns  me a rowset where FIELD starts with `, e.g.  ... `Ayn ad Darah `Ayn ad Darahim `Ayn ad Dayr `Ayn ad Dib `Ayn ad Dilbah ...  Then I modify my query like this:  select * from TABLE where FIELD like '`A%';  SQLite incorrectly returns me records where FIELD does not start with `, but instead it starts from A or B, e.g.  ... Abasa Abasabad ... Abuwangala Abuxarda ... Bazwala Bazwaya Bazwayah Bazy Bazy-Gazyz ...  Can you explain this behaviour and suggest a workaround?
    _2007-Jun-08 18:35:16 by drh:_ {linebreak} Unable to reproduce. I used the following script: CREATE TABLE t1(x); INSERT INTO t1 VALUES('`Ayn ad Darah'); INSERT INTO t1 VALUES('`Ayn ad Darahim'); INSERT INTO t1 VALUES('Abasa'); INSERT INTO t1 VALUES('Bazwala'); SELECT 111, rowid, * FROM t1; SELECT 222, rowid, * FROM t1 WHERE x LIKE '`%'; SELECT 333, rowid, * FROM t1 WHERE x LIKE '`A%'; And I get this output, which appears to be correct: 111|1|`Ayn ad Darah 111|2|`Ayn ad Darahim 111|3|Abasa 111|4|Bazwala 222|1|`Ayn ad Darah 222|2|`Ayn ad Darahim 333|1|`Ayn ad Darah 333|2|`Ayn ad Darahim ---- _2007-Jun-10 12:58:18 by anonymous:_ {linebreak} Can you please unpack and check the following 3.3.17 SQLite database (the archive is less than 100KB).
     1) select * from tgeo where locality like '`%'; 2) select * from tgeo where locality like '`A%'; 
    Just run both queries and check the returned result sets. This should show you the problem.

    In my environment (Windows XP Professional English, codepage Russian) the result set produced by the second SELECT is unexplainable to me, while the result set from the first SELECT seems to be OK. The behavior is equal either I run these queries from SQLite command line tool or from my C++ client application. So it doesn't seem to be the problem of a particular client, it's kind of general.

    #cfe8bd 2406 code fixed 2007 Jun anonymous 2007 Jun 1 3 C++ style comments unacceptable in C code. A number of vendor-specific C compilers are strict C compilers, with no notion of C++. This means especially that they do not recognize C++ style comments (=// ...=) and thus fail to compile the sqlite C sources as the =//= sequences therein are not removed by their preprocessor and cause syntax errors. It is asked to replace all C++ comments with equivalent C comments, i.e. // ... to /* ... */ An example of such a compiler is AIX's =xlc=. #c8c8c8 2405 code closed 2007 Jun anonymous 2007 Jun 1 1 sqlite3_prepare() don't work in php pdo implementation I'm using SQLITE drivers for PHP's PDO extension. This extension binds abastract layered prepared statement functions to the specific driver's ones. Specifically, PHP code calls sqlite3_prepare() function (see: http://cvs.php.net/viewvc.cgi/pecl/pdo_sqlite/sqlite_driver.c?revision=1.33&view=markup) Somewhere between libsqlite 3.3.5 and 3.3.12 (i've tested these two version only) the result from calling sqlite3_prepare() went corrupted (the binding between value and placeholder in the prepared statement doesn't work). _2007-Jun-08 12:17:16 by anonymous:_ {linebreak} 3.3.7 works for me with PHP 5.2.1 (so the range is a bit smaller) ---- _2007-Jun-17 17:03:16 by anonymous:_ {linebreak} the bug it's not outside of sqlite, the demonstration is that the bugged behaviour depends on libsqlite version (excluding the pdo lib for sqlite) #cfe8bd 2404 code fixed 2007 Jun anonymous 2007 Jun 2 2 Values in INTEGER PRIMARY KEY always less than NULL Expression ='v < ?'= is always true if the column =v= has INTEGER PRIMARY KEY constraint and ? is null. $ sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> create table x (v); sqlite> create table y (v integer); sqlite> create table z (v integer primary key); sqlite> insert into x values (-1); sqlite> insert into x values (0); sqlite> insert into x values (1); sqlite> insert into y select v from x; sqlite> insert into z select v from x; sqlite> select v from x where v < null; sqlite> select v from y where v < null; sqlite> select v from z where v < null; -1 0 1 sqlite> select v from x where v + 0 < null; sqlite> select v from y where v + 0 < null; sqlite> select v from z where v + 0 < null; sqlite> _2007-Jun-08 04:55:13 by anonymous:_ {linebreak} These WHERE clauses also always evaluate to true for any table: WHERE rowid < NULL; WHERE rowid <= NULL; ---- _2007-Jun-08 05:37:33 by anonymous:_ {linebreak} It's interesting how these two SELECTs generate very different opcodes: explain select rowid from sqlite_master where rowid > NULL; -- ok 0|Goto|0|12| 1|Integer|0|0| 2|OpenRead|0|1| 3|SetNumColumns|0|0| 4|Null|0|0| 5|ForceInt|1|10| 6|MoveGe|0|10| 7|Rowid|0|0| 8|Callback|1|0| 9|Next|0|7| 10|Close|0|0| 11|Halt|0|0| 12|Transaction|0|0| 13|VerifyCookie|0|0| 14|Goto|0|1| 15|Noop|0|0| explain select rowid from sqlite_master where rowid < NULL; -- bug 0|Goto|0|15| 1|Integer|0|0| 2|OpenRead|0|1| 3|SetNumColumns|0|0| 4|Rewind|0|13| 5|Null|0|0| 6|MemStore|0|1| 7|Rowid|0|0| 8|MemLoad|0|0| 9|Ge|99|13| 10|Rowid|0|0| 11|Callback|1|0| 12|Next|0|7| 13|Close|0|0| 14|Halt|0|0| 15|Transaction|0|0| 16|VerifyCookie|0|0| 17|Goto|0|1| 18|Noop|0|0| ---- _2007-Jun-08 06:54:24 by anonymous:_ {linebreak} This line seems wrong: 9|Ge|99|13| as the branch should be taken if either argument to Ge is NULL. Untested patch: Index: src/where.c =================================================================== RCS file: /sqlite/sqlite/src/where.c,v retrieving revision 1.248 diff -u -3 -p -r1.248 where.c --- src/where.c 4 May 2007 13:15:57 -0000 1.248 +++ src/where.c 8 Jun 2007 06:51:33 -0000 @@ -2346,7 +2346,7 @@ WhereInfo *sqlite3WhereBegin( if( testOp!=OP_Noop ){ sqlite3VdbeAddOp(v, OP_Rowid, iCur, 0); sqlite3VdbeAddOp(v, OP_MemLoad, pLevel->iMem, 0); - sqlite3VdbeAddOp(v, testOp, SQLITE_AFF_NUMERIC, brk); + sqlite3VdbeAddOp(v, testOp, 0x100|SQLITE_AFF_NUMERIC, brk); } }else if( pLevel->flags & WHERE_COLUMN_RANGE ){ /* Case 3: The WHERE clause term that refers to the right-most ---- _2007-Jun-08 07:28:36 by anonymous:_ {linebreak} Patch ran "make test" without regressions. #cfe8bd 2403 code fixed 2007 Jun anonymous 2007 Jun 3 3 LEFT JOIN inconsistancy with NULL expression in ON clause Is this correct SQL behavior? CREATE TABLE ab(a,b); INSERT INTO "ab" VALUES(1,2); INSERT INTO "ab" VALUES(3,NULL); CREATE TABLE xy(x,y); INSERT INTO "xy" VALUES(2,3); INSERT INTO "xy" VALUES(NULL,1); -- ok select * from xy left join ab; x y a b ---------- ---------- ---------- ---------- 2 3 1 2 2 3 3 1 1 2 1 3 -- Why 3 rows returned? -- Would have expected 2 rows. select * from xy left join ab on x*0=0; x y a b ---------- ---------- ---------- ---------- 2 3 1 2 2 3 3 1 -- Why 2 rows returned? select * from xy left join ab on x*0=123; x y a b ---------- ---------- ---------- ---------- 2 3 1 -- Not sure what should be returned here select * from xy left join ab on 0=1; _2007-Jun-07 19:21:21 by drh:_ {linebreak} This is correct LEFT JOIN behavior as I understand what LEFT JOINs are suppose to do. ---- _2007-Jun-07 19:23:26 by anonymous:_ {linebreak} I would have expected 4 rows here - but why 3 rows? I thought that the row is included if the ON clause produces NULL. select * from xy left join ab on x*0=0; x y a b ---------- ---------- ---------- ---------- 2 3 1 2 2 3 3 1 ---- _2007-Jun-07 19:43:36 by drh:_ {linebreak} Tickets are for reporting bugs. For questions about SQL or about SQLite, please post messages on the SQLite mailing list. Instructions at http://www.sqlite.org/support.html ---- _2007-Jun-07 20:03:50 by anonymous:_ {linebreak} I think there is a bug. MySQL 5.0.24a returns a different result for "select * from xy left join ab on 0=1" than SQLite: mysql> select * from ab; +------+------+ | a | b | +------+------+ | 1 | 2 | | 3 | NULL | +------+------+ 2 rows in set (0.00 sec) mysql> select * from xy; +------+------+ | x | y | +------+------+ | 2 | 3 | | NULL | 1 | +------+------+ 2 rows in set (0.00 sec) mysql> select * from xy left join ab on 0=1; +------+------+------+------+ | x | y | a | b | +------+------+------+------+ | 2 | 3 | NULL | NULL | | NULL | 1 | NULL | NULL | +------+------+------+------+ 2 rows in set (0.00 sec) ---- _2007-Jun-07 20:28:04 by anonymous:_ {linebreak} Also compare: sqlite> select * from xy left join ab on null; sqlite> to: mysql> select * from xy left join ab on null; +------+------+------+------+ | x | y | a | b | +------+------+------+------+ | 2 | 3 | NULL | NULL | | NULL | 1 | NULL | NULL | +------+------+------+------+ 2 rows in set (0.00 sec) #c8c8c8 2402 code closed 2007 Jun anonymous 2007 Jun 3 3 Left Outer Join and Where clause Is this a bug or is it how WHERE is supposed to work with LEFT OUTER JOIN? CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2); INSERT INTO t1 VALUES(NULL,2); INSERT INTO t1 VALUES(3,NULL); CREATE TABLE t2(x,y); INSERT INTO t2 VALUES(2,3); INSERT INTO t2 VALUES(NULL,1); select * from t1 left join t2 where x=b; a b x y ---------- ---------- ---------- ---------- 1 2 2 3 2 2 3 select * from t1 left join t2 on x=b; a b x y ---------- ---------- ---------- ---------- 1 2 2 3 2 2 3 3 _2007-Jun-07 19:14:51 by drh:_ {linebreak} This is correct behavior. Result rows are excluded if the WHERE clause is NULL, but can be included if the ON clause is NULL. #f2dcdc 2401 warn active 2007 Jun anonymous 2007 Jun 1 1 I can't send anything to the contrib page 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 #c8c8c8 2400 code closed 2007 Jun anonymous 2007 Jun 4 4 SELECT COUNT (*); returns 1 rather than 0. In a command shell under linux the following commands were used, with my annotations prefixed by '--'
     justin@buttercup:~$ sqlite t.db SQLite version 2.8.17 Enter ".help" for instructions sqlite> SELECT COUNT (*); 1 -- I'd expect a 0 result here.  sqlite> CREATE TABLE test (a,b); sqlite> INSERT INTO test VALUES ("hello","there"); sqlite> SELECT COUNT (*) FROM test; 1 -- Seems fine; it's not an off-by-one error.  sqlite> CREATE TABLE test2 (a,b); sqlite> SELECT COUNT (*) FROM test2; 0 -- Seems to be that an empty table always returns 0. 
    It seems that when SELECT COUNT (*); is used on its own, with no table to select from, the answer 1 is given despite there being no rows returned. Is that right ? There is a single implicit row returned by a SELECT with no FROM clause. The same reason statements like "SELECT 1+1" return a single row. #cfe8bd 2399 code fixed 2007 Jun danielk1977 2007 Jun 1 1 Compiling with msvc fails due to use of "isnan()" Suggested fix is to add the following block somewhere: #if OS_WIN #include #define isnan(X) _isnan(X) #endif But it's not yet clear if this fix is required for all win32 compilers, or just MSVC. Probably the latter. _2007-Jun-06 08:15:43 by anonymous:_ {linebreak} How about is this? #ifndef HAVE_ISNAN # define isnan(X) ((X) != (X)) #endif #f2dcdc 2398 code active 2007 Jun anonymous 2007 Jun 2 3 systemcalls should be restarted when they return EINTR 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} As long as #ifdef SQLITE3_RETRY_EINTR_SYSCALLS is not enabled by default, knock yourselves out. ---- _2007-Jun-06 06:38:51 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 2397 build active 2007 Jun anonymous 2007 Jun 2 4 make install failed on Cygwin 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. #f2dcdc 2396 code active 2007 Jun anonymous 2007 Jun 1 3 -column output truncates characters from varchar field. 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:_ {linebreak} 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:_ {linebreak} .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:_ {linebreak} 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. #c8c8c8 2395 todo closed 2007 Jun anonymous 2007 Jun mani 4 1 SQLite3 cmd prompt interface problem I am unable to run sqlite3 command. When I enter sqlite3 Test.db from command line on windows XP nothing happens. When I try to create a table its throws a syntax error for the first line. Below is the snapshot of the problem. SQLite version 3.3.17 Enter ".help" for instructions sqlite> sqlite3 test.db ...> create table TB1(one varchar(10); SQL error: near "sqlite3": syntax error sqlite> #c8c8c8 2394 todo closed 2007 Jun anonymous 2007 Jun mani 4 1 SQLite3 cmd prompt interface problem I am unable to run sqlite3 command. When I enter sqlite3 Test.db from command line on windows XP nothing happens. When I try to create a table its throws a syntax error for the first line. Below is the snapshot of the problem. SQLite version 3.3.17 Enter ".help" for instructions sqlite> sqlite3 test.db ...> create table TB1(one varchar(10); SQL error: near "sqlite3": syntax error sqlite> This is not a bug. Please use the mailing list for these sorts of questions. #c8c8c8 2389 code closed 2007 May anonymous 2007 Jun 1 1 database placed in the non ASCII named folder could not be opened Just try to open database placed in the folder whose name consists of non ASCII characters. Versions of SQLite about year ago could and new version could not open such a database. It is a great problem for us in Poland. We use XP or Vista (Polish versions). Database can't be stored in any folder named with Cp1250 characters, example: C:\gęś\qwe.sdb Error message: "unable to open database file", when we change name to C:\ges\qwe.sdb it works We connect to the database through Delphi 2007 or through sqlite3.exe shell This works under some circumstances (see the attached Tcl script for the test I tried on Linux) so we need more information: What OS/OS Version are you using? What is the full database path? What error is returned? Thanks, Dan. ---- _2007-May-29 09:29:31 by anonymous:_ {linebreak} Let me assume that the original poster uses Windows (maybe even 9x). The thing is that sqlite3_open function accepts the file name parameter as *UTF8* string and not a string in the ANSI character set used in Windows, so you have to explicitly use UTF8 file names in the application. ---- _2007-May-29 15:41:27 by anonymous:_ {linebreak} _Delphi_ uses ANSI encoded strings by default. You have to convert path and file name to UTF8 encoding before passing it to =sqlite3_open()=: sqlite3_open(PAnsiChar(AnsiToUtf8(FileName))); ---- _2007-Jun-11 11:21:59 by danielk1977:_ {linebreak} Assuming the above comment fixes this problem. #c8c8c8 2357 code closed 2007 May anonymous 2007 Jun anonymous 2 2 Crash in sqlite3PagerClose when SQLITE_ENABLE_MEMORY_MANAGEMENT is def

    I have used the latest amalgamated SQLite code to build a dll, with SQLITE_ENABLE_MEMORY_MANAGEMENT defined and set the soft upper limit to 2^25 (32MB).

    My app runs multi-threaded (is an ISAPI dll called from IIS on Windows) - I create a pool of database connections at startup and whenever a thread needs to access the database, it asks the pool for an idle connection, calls sqlite3_soft_heap_limit((1<<25)/pool_size), does its stuff, calls sqlite3_soft_heap_limit(0) and releases the database connection.

    All works fine, except that when the dll is unloaded, there is a crash in sqlite3PagerClose() - pTmp becomes NULL in the for loop in the code below. Debugger tells me that pTsd->pager is NULL (all field of pTsd are 0, except for nAlloc which is -16754).

     #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT   /* Remove the pager from the linked list of pagers starting at   ** ThreadData.pPager if memory-management is enabled.   */   if( pPager==pTsd->pPager ){     pTsd->pPager = pPager->pNext;   }else{     Pager *pTmp;     for(pTmp = pTsd->pPager; pTmp->pNext!=pPager; pTmp=pTmp->pNext){}     pTmp->pNext = pPager->pNext;   } #endif 

    I guess it is not too serious because it happens only during shut-down and probably after all database ops have been committed to the disk, but still, it is a crash.

    I am building the amalgamated code with Intel 9.1 on WindowsXP, crash seen in debug mode. _2007-May-14 03:04:26 by anonymous:_ {linebreak} Can you post a small self-contained test program that reliably demonstrates this crash? ---- _2007-May-14 10:28:22 by drh:_ {linebreak} One wonders if this is somehow related to #2277. ---- _2007-Jun-27 00:13:01 by drh:_ {linebreak} See {link: /faq.html#q6 the FAQ} for information about using SQLITE_ENABLE_MEMORY_MANAGEMENT and threads. #cfe8bd 2344 code fixed 2007 May anonymous 2007 Jun 2 3 Range of INTEGER not ANSI compliant We are using the SQLite DB to store some scientific data and need to store the full ANSI compliant range of 64 bit integers. As it stands, the SQLite DB will only store the following range: -9223372036854775807..9223372036854775807 Basically this is 1 bit shy of a true 64 bit range. -9223372036854775808..9223372036854775807 It is very inconvenient to not have this full range. It forces one to use some other datatype and do a mapping or use a BLOB. Both of these solutions significantly reduce or overly complicate searching and filtering data which would normally be simple. _2007-May-08 01:37:16 by anonymous:_ {linebreak} I thought we had a nice and friendly card game going here - and now you drag ANSI in. Seriously, is there an ANSI SQL spec that mandates a 64 bit integer range? ---- _2007-May-17 22:40:27 by anonymous:_ {linebreak} Whether it is ANSI or not isn't really relevant. SQLite claims and is documented to support 8 byte INTEGER. Generally 8 bytes suggest 64 bits of data, not 63 as it stands now ;) There is a workaround but it inconvenient. Insert two 32 bit values and then reconstruct the 64 bit value after reading. yuck. ---- _2007-May-17 22:56:42 by anonymous:_ {linebreak} ANSI doesn't mention it, and I don't see a reference in the SQLite docs either. Where does it state that the full range of 64 bit unsigned integers can be represented? 8 bytes does not necessarily mean that 100% of the bits are used to represent the value: http://www.sqlite.org/datatype3.html *INTEGER*. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. ---- _2007-May-25 00:49:54 by anonymous:_ {linebreak} In CS the general and most accepted method of getting the range of an integer is -2^(N-1)...(2^(N-1))-1 where N is the number of bits in the value. Most text books will back this up. http://en.wikipedia.org/wiki/Integer_(computer_science) If SQLite wants to spec out its own range that is fine but it is not what most people would generally assume. Is there some reason why this would be a big deal to support? ---- _2007-May-25 01:12:48 by anonymous:_ {linebreak} sqlite3 can not use literal integer -9223372036854775808, but can store integer -9223372036854775808. $ sqlite3 new.db SQLite version 3.3.6 Enter ".help" for instructions sqlite> create table x(v); sqlite> insert into x values (-9223372036854775807-1); sqlite> select v, typeof(v) from x; -9223372036854775808|integer Is this not enough? ---- _2007-May-25 01:53:19 by anonymous:_ {linebreak} LOL Yeah I guess that would work. Not sure how someone would know to do that. Thanks, we will give this a try. #cfe8bd 2129 doc fixed 2006 Dec anonymous 2007 Jun 4 1 Typo in documentation for sqlite3_create_collation() There are some constants defined for _sqlite3_create_collation()_:

  • #define SQLITE_UTF81
    #define SQLITE_UTF16BE2
    #define SQLITE_UTF16LE3
    #define SQLITE_UTF164
    This differs from constants defined for _sqlite_create_function()_:
    #define SQLITE_UTF81
    #define SQLITE_UTF162
    #define SQLITE_UTF16BE3
    #define SQLITE_UTF16LE4
    #define SQLITE_ANY5
    I know SQLITE_ANY couldn't be used in _sqlite_create_collation()_, but the first four constants should be (I think) the same. I'm not very familiar with the SQLite source code, but I found definition of theese constants in _sqlite3.h_. _2007-Jun-28 10:02:36 by anonymous:_ {linebreak} According to current sources you should close this ticket: #define SQLITE_UTF8 1
    #define SQLITE_UTF16LE 2
    #define SQLITE_UTF16BE 3
    #define SQLITE_UTF16 4 /* Use native byte order */
    #define SQLITE_ANY 5 /* sqlite3_create_function only */
    #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
    #f2dcdc 154 code active 2002 Sep drh Pager 2007 Jun drh 3 3 Prohibit links on database files. 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 2280 new active 2007 Mar anonymous 2007 Mar 4 3 Check constraint failure message should include field name 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:_ {linebreak} Duplicate of ticket #2258 #c8c8c8 2279 code closed 2007 Mar anonymous 2007 Mar 3 4 sqlite3_exec NULL pointer crash When calling into sqlite3_exec if the first parameter is NULL (meaning the database handle) then the system will crash. _2007-Mar-29 21:11:18 by drh:_ {linebreak} If it really makes your system crash, that is an OS bug that you should report to your OS maker. Perhaps you mean that passing an illegal (eg. NULL) pointer to sqlite3_exec() makes your _program_ crash? OK. What were you expecting it to do? ---- _2007-Mar-30 18:58:33 by rdc:_ {linebreak} I think it is a bug that sqlite3_exec() can't accept a NULL sqlite3* pointer. SQLite should validate its API function arguments to a reasonable degree. This particular case seems like something that might be common enough to warrant the extra check. sqlite3_exec should probably return SQLITE_MISUSE in this case. Simply add a test before (or after) the existing zSql pointer test. if( db==0 ) return SQLITE_MISUSE; If you want to get fancier you could (and probably should) also set error message string if that pointer is not null. if( db==0 ){ rc = SQLITE_MISUSE; if( pzErrMsg ){ *pzErrMsg = sqlite3_malloc(1+strlen(sqlite3ErrStr(rc))); if( *pzErrMsg ){ strcpy(*pzErrMsg, sqlite3ErrStr(rc)); } } return rc; } #cfe8bd 2276 code fixed 2007 Mar anonymous 2007 Mar 4 3 strftime %f zero padding problem select strftime('%f','now') does not pad seconds properly, eg. it returns 1.234 instead of 01.234 It seems the problem was introduced by check-in [3443]. Problem is in line:{linebreak} sqlite3_snprintf(7, &z[j],"%02.3f", s);{linebreak} where the width specifier 2 does not cover only integer part but the whole output. I think it should be 6 instead of 2. #c8c8c8 2275 code closed 2007 Mar anonymous 2007 Mar 2 4 Can't get where clause to recognize equality with generated value I can't get a where clause to recognize an equality between a column value and a calculated value:
     # Preparatory: load ../lib/tclsqlite3.dll sqlite3 db mydb proc atan  {x} {expr {atan($x)}} db function atan atan  # Fill a table with values: db eval {create table t2(a integer, b real, c real, d real)} db eval {insert into t2 values(3, 0.463646484842, 0.999992077664, 0.785398163397)} db eval {insert into t2 values(5, 0.51122921115, 0.14786560362, 0.540417767899)} db eval {insert into t2 values(6, 0.495893111807, 0.0928603152509, 0.51122921115)}  # Initialize variables with values from first row: db eval {select b, c from t2 where a = 3} {set valueb $b ; set valuec $c}  # Verify function is being calculated properly: db eval {select a, ($valueb + $valuec*(atan(a - 1) - atan(a - 2))), d from t2} values {   foreach {w x y z} [array names values] {     puts "$values($y) $values($w) $values($x)"'   } }  # Output looks like: # 3 0.785398163397 0.785394490223 # 5 0.540417767899 0.540417767899 # 6 0.51122921115 0.51122921115 # # Middle float value is calculated, end float value is # taken from last column of table row. # Note that middle and end values are equal in second and third rows. # This is as expected. # # Now try to select just integer values based on equality: # (function is identical, just moved to where clause) db eval {select a from t2 where ($valueb + $valuec*(atan(a - 1) - atan(a - 2))) = d}  # I expect to get back 5 and 6, but the result is nothing  
    This looks like a bug to me. If I am making an obvious newcomer's mistake, I'd appreciate a gentle hint. Thanks. _2007-Mar-29 14:28:56 by anonymous:_ {linebreak} You're making a common mistake: trying to compare two floating-point values for exact equality. This isn't SQLite-specific; it's simply in the nature of floating-point numbers that rounding errors can cause the results of two calculations that are mathematically the same to differ in one "binary place." ---- _2007-Mar-29 15:52:04 by anonymous:_ {linebreak} Thanks for the tip. I now remember reading that sqlite stores numbers as double-precision values, so clearly I need to update my procedures to account for that. #f2dcdc 2274 todo active 2007 Mar anonymous 2007 Mar drh 5 3 Sqlite segfaults consistently in FTS2 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 , 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) #cfe8bd 2273 code fixed 2007 Mar anonymous 2007 Mar 1 2 Under latest release 3.3.13 query results in crash (used to run fine) To create tables/data, run this: CREATE TABLE inmk( cls TEXT, sec INTEGER, inst INTEGER ); INSERT INTO inmk VALUES ('ORD', 2751, 2750); CREATE TABLE clss( hrar TEXT, cls TEXT, PRIMARY KEY (hrar, cls) ); CREATE TABLE rels( prnt_inst INTEGER, chld_inst INTEGER ); Then run this query: SELECT I.sec FROM inmk I LEFT JOIN rels R ON R.prnt_inst = I.inst LEFT JOIN inmk UI ON UI.inst = R.chld_inst LEFT JOIN clss C1U ON C1U.cls = UI.cls AND C1U.hrar = 'STH' LEFT JOIN clss C10U ON C10U.hrar = c1u.hrar AND C10U.cls IN (C1U.cls) WHERE I.sec = 2751; --------------------------------------------------------------------- The crash only happens in the latest 3.3.13 build. Observations If "C10U.cls IN (C1U.cls)" is replaced with "C10U.cls = C1U.cls", the query does not result in a crash but obviously this is not how the original query look like. In the original one, be it ...AND C10U.cls IN (C1U.cls, C2U.cls...) or AND (C10U.cls = C1U.cls OR C10U.cls = C2U.cls...) is immaterial and the crash still results. The presence of the primary key in 'clss' table also seems to be important for the crash to occur. _2007-Mar-28 03:37:49 by drh:_ {linebreak} Simplified script: CREATE TABLE a(x); INSERT INTO a VALUES(1); CREATE TABLE b(y,z,PRIMARY KEY(y,z)); SELECT * FROM a LEFT JOIN b AS b1 LEFT JOIN b AS b2 ON b2.y = b1.y AND b2.z IN (b1.z); ---- _2007-Mar-28 09:36:23 by danielk1977:_ {linebreak} Same bug causes crash in: CREATE TABLE b(y,z,PRIMARY KEY(y, z)); SELECT * FROM b WHERE y = NULL AND z IN ('hello'); #cfe8bd 2272 code fixed 2007 Mar anonymous 2007 Mar 5 5 btree.c doc typo If there are N database entries per page and the indexes for Ptr and Key are zero-based, then the docs should be changed as follows: --- src/btree.c 19 Mar 2007 17:44:27 -0000 1.341 +++ src/btree.c 26 Mar 2007 20:33:29 -0000 @@ -21,14 +21,14 @@ ** The basic idea is that each page of the file contains N database ** entries and N+1 pointers to subpages. ** -** ---------------------------------------------------------------- -** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N) | Ptr(N+1) | +** ---------------------------------------------------------------- +** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | ** ---------------------------------------------------------------- ** ** All of the keys on the page that Ptr(0) points to have values less ** than Key(0). All of the keys on page Ptr(1) and its subpages have ** values greater than Key(0) and less than Key(1). All of the keys -** on Ptr(N+1) and its subpages have values greater than Key(N). And +** on Ptr(N) and its subpages have values greater than Key(N-1). And ** so forth. ** ** Finding a particular key requires reading O(log(M)) pages from the @@ -41,7 +41,7 @@ ** page. If the payload is larger than the preset amount then surplus ** bytes are stored on overflow pages. The payload for an entry ** and the preceding pointer are combined to form a "Cell". Each -** page has a small header which contains the Ptr(N+1) pointer and other +** page has a small header which contains the Ptr(N) pointer and other ** information such as the size of key and data. ** ** FORMAT DETAILS @@ -123,7 +123,7 @@ ** 3 2 number of cells on this page ** 5 2 first byte of the cell content area ** 7 1 number of fragmented free bytes -** 8 4 Right child (the Ptr(N+1) value). Omitted on leaves. +** 8 4 Right child (the Ptr(N) value). Omitted on leaves. ** ** The flags define the format of this btree page. The leaf flag means that ** this page has no children. The zerodata flag means that this page carries If there are N database entries per page and the indexes for Ptr and Key are one-based, then the docs should be changed as follows: --- src/btree.c 19 Mar 2007 17:44:27 -0000 1.341 +++ src/btree.c 26 Mar 2007 20:40:50 -0000 @@ -21,13 +21,13 @@ ** The basic idea is that each page of the file contains N database ** entries and N+1 pointers to subpages. ** -** ---------------------------------------------------------------- -** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N) | Ptr(N+1) | +** ---------------------------------------------------------------- +** | Ptr(1) | Key(1) | Ptr(2) | Key(2) | ... | Key(N) | Ptr(N+1) | ** ---------------------------------------------------------------- ** -** All of the keys on the page that Ptr(0) points to have values less -** than Key(0). All of the keys on page Ptr(1) and its subpages have -** values greater than Key(0) and less than Key(1). All of the keys +** All of the keys on the page that Ptr(1) points to have values less +** than Key(1). All of the keys on page Ptr(2) and its subpages have +** values greater than Key(1) and less than Key(2). All of the keys ** on Ptr(N+1) and its subpages have values greater than Key(N). And ** so forth. ** #c8c8c8 2271 doc closed 2007 Mar anonymous 2007 Mar 3 4 Can't use "limit" as column name On WinXP: % load tclsqlite3.dll % sqlite3 db mydb % db eval {create table t1(limit real)} near "limit": syntax error % db eval {create table t1(limitx real)} % Note column named "limit" causes error, same statement with column name "limitx" works OK. _2007-Mar-26 07:19:26 by anonymous:_ {linebreak} Surround limit by quotation marks: create table t1("limit" real) ---- Above is correct. See: http://www.sqlite.org/lang_keywords.html #f2dcdc 2270 build active 2007 Mar anonymous 2007 Mar 3 4 Build on Solaris 8 does not include other libs in .so build 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:_ {linebreak} #1802, #2041 and #2270 are the same basic issue: librt should get linked into libsqlite3.so #c8c8c8 2269 code closed 2007 Mar anonymous 2007 Mar anonymous 2 1 SQLite3_Column_decltype treat [char] (32) as 'char',but not 'char(32)' Create a table use following statement: CREATE TABLE XTollData ( DutyID char (32) NOT NULL , CarNumber char (10) NULL ); SQLite3_Column_decltype treat DutyID as 'char(32)' But if you create a table using following statement: CREATE TABLE [XTollData] ( [DutyID] [char] (32) NOT NULL , [CarNumber] [char] (10) NULL ); SQLite3_Column_decltype will treat DutyID as 'char', not 'char(32)' _2007-Mar-22 19:00:48 by rdc:_ {linebreak} As pointed out at http://www.mail-archive.com/sqlite-users@sqlite.org/msg23237.html quoting the column data type is not valid SQL syntax. Using [char] or even "char" should generate a syntax error. The data type is not an identifier. ---- _2007-Mar-27 14:13:54 by drh:_ {linebreak} You can also say: CREATE TABLE x(a [char(32)]); In other words, put the entire type inside of quotes. ---- _2007-Mar-29 16:34:56 by rdc:_ {linebreak} This *should* generate a syntax error. CREATE TABLE x(a "char(32)"); ^ The data type in a column definition is *not* an identifier and the parser should not accept quotes around a data type. Leaving this as an "extension" just allows people to create code that won't compile on a standard compliant database. #cfe8bd 2268 code fixed 2007 Mar shess 2007 Mar drh 1 4 SQLITE_OMIT_ATTACH doesn't disable sqlite_attach() function. SQLITE_OMIT_ATTACH only changes whether the keywords ATTACH, DETACH, and DATABASE are usable. You can still use sqlite_attach() to attach a database. Verified for 3.3.13, but it seems likely that it's been present for awhile. #cfe8bd 2267 doc fixed 2007 Mar anonymous 2007 Mar drh 2 1 copyright.html grammer needs fix After the last check-in, the "contributed code" section contains 2 grammatical errors. Here's the fixed version. "In order to keep SQLite complete[ly] free and unencumbered by copyright, all new contributors to the SQLite code base are asked [to] dedicate their contributions to the public domain." #f2dcdc 2266 new active 2007 Mar anonymous 2007 Mar anonymous 3 3 Add support for Row_Number() Over 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:_ {linebreak} 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. #c8c8c8 2265 doc closed 2007 Mar anonymous 2007 Mar 1 1 windows + xampp (php) + sqlite3 ... how? Please can you provide a receipe how to use ... - sqlite3 - on ms windows - with xampp (with php) Can this done without compilation? On several places I read that just the php.ini has to be adapted ... however it does not work. btw: sqlite2 works, even via PDO ... but sqlite has its limits. Thanks. This is not an SQLite bug. Ask your question on the mailing list. #cfe8bd 2264 code fixed 2007 Mar anonymous 2007 Mar 3 1 User defined functions naming problem I'm trying to create a user-defined function having the name LEFT but that does not seem to work (I get an sql parsing error). All is fine if I rename it to STRLEFT, but I'd stick to the first one since I'd like to add some compatibility with other db engines. I understand there are a number of keywords which sqlite uses, but according to http://www.sqlite.org/lang_keywords.html, these keywords cannot be used as 'names of tables, indices, columns, or databases'. Function names are not included here. So, is there a way to do it, not possible or is it a bug somewhere in the parser? #c8c8c8 2263 code closed 2007 Mar anonymous 2007 Mar 1 1 Apparent potential leak or concurrency problem when using codec In the pager when about to write to the file, the codec encrypts the page and returns a pointer to the encrypted page. If the encrypted page is written to a static space, then there might be concurrency problems when multiple threads execute the same patch of code. If the encrypted page is allocated by the codec, there is no place to tell the codec to free it or lock it. I am not asking for coding to be done, just advice. Is there a working version available for license that has the encryption fully fleshed out? Thanks - Tim _2007-Mar-07 05:36:32 by anonymous:_ {linebreak} Thanks for the fine work. I have exercised the library on large (to me) data sets, up to 55 million records. It is quick and clean. ---- _2007-Mar-07 12:27:51 by drh:_ {linebreak} A working implementation of the codec exists as {link: http://www.hwaci.com/sw/sqlite/prosupport.html#crypto proprietary code}. I can assure you that it does not have a concurrency problem and it does not leak memory. ---- _2007-Mar-08 19:26:55 by anonymous:_ {linebreak} Thanks for the quick response #cfe8bd 2262 code fixed 2007 Mar anonymous 2007 Mar drh 2 1 Dynamic allocation of tempory storage for pages The SQLITE_MAX_PAGE_SIZE #define is used to define local byte buffers in two places in pager.c. This causes problems on embedded devices with limited stack space. Changing these declarations to dynamic allocations would solve the problem, allowing for larger pages (> 4K in our case) without the stack smashing problems. Original email thread follows: John Boyd wrote: > Richard - > > What are the implications of changing SQLITE_MAX_PAGE_SIZE in pager.h? > > It's just come to my attention that we've left it at it's default of > 32768, which causes some problems on certain devices we run on. I'd > like to change this to 1024 or so, but it's unclear what sort of > performance impact it will cause, if any. > There are no performance implications. If you set SQLITE_MAX_PAGE_SIZE to 1024, that just means that you will not be able to read or write a database with a page size larger than 1024 (the default). I'm guessing this is not an issue for you. I'm guessing the "problems" you are having are stack overflow in a couple of functions in pager.c. There are a couple of places that declare automatic arrays of size SQLITE_MAX_PAGE_SIZE. I'm planning to change this - to dynamically allocate the necessary memory when the database is opened. So eventually, this problem will go away. But for now, you are safe in compiling with SQLITE_MAX_PAGE_SIZE=1024. -- D. Richard Hipp #c8c8c8 2261 build closed 2007 Mar anonymous 2007 Mar 1 1 Problem under Windows 95 SQLITE3 bombs on WINDOWS 95. If I try running SQLITE3 with an existing data base (e.g. SQLITE3 existing.dat) it bombs immediately. If I try running SQLITE3 with a new data base (e.g. SQLITE3 NEW.DAT) it displays its prompt but bombs upon invoking the first CREATE TABLE Command. Not just SQLITE3 bombs but also an application that I recompiled upgrading from version 3.2.2 to 3.3.13 bombs under WINDOWS 95 but runs well under 98, 2000 and XP. _2007-Mar-06 12:59:00 by drh:_ {linebreak} Link against UNICOWS and the problem will go away, I am told. #c8c8c8 2260 code closed 2007 Feb anonymous 2007 Mar 1 1 virtual table/vdbe does not call xFilter() making xColumn segv I have the following schema: create virtual table foo using wrsv (a INTEGER); create virtual table bar using wrsv (a INTEGER); and insert the following data: insert into foo values (100); insert into foo values (200); insert into foo values (300); insert into bar values (100); insert into bar values (200); rowid a ---------- ---------- 1 100 2 200 3 300 rowid a ---------- ---------- 1 100 2 200 The following queries work: select * from foo, bar where foo.a = bar.a and bar.a >1; select * from foo, bar where foo.a = bar.a and bar.a =1; select * from foo, bar where foo.a = bar.a and bar.a <1; select * from foo, bar where foo.a = bar.a and bar.a >=1; select * from foo, bar where foo.a = bar.a and bar.a <=1; However, none of the following work; they all cause xColumn to SEGV (indirectly) because xFilter() does not get called. select * from foo, bar where foo.a = bar.a and foo.a >1; select * from foo, bar where foo.a = bar.a and foo.a =1; select * from foo, bar where foo.a = bar.a and foo.a <1; select * from foo, bar where foo.a = bar.a and foo.a <=1; select * from foo, bar where foo.a = bar.a and foo.a >=1; select * from foo, bar where foo.a = bar.a and foo.rowid>1; select * from foo, bar where foo.a = bar.a and foo.rowid=1; select * from foo, bar where foo.a = bar.a and foo.rowid<1; select * from foo, bar where foo.a = bar.a and foo.rowid<=1; select * from foo, bar where foo.a = bar.a and foo.rowid>=1; I see that the xColumn() virtual table method is called without a preceeding call to xFilter(). Here's the vdbe trace from the last SQL query above: VDBE Execution Trace: SQL: [select * from foo, bar where foo.a = bar.a and foo.rowid>=1;] 0 Goto 0 25 25 Transaction 0 0 26 VerifyCookie 0 2 27 Goto 0 1 1 VOpen 0 0 vtab:8384E30:80C8CC0 2 VOpen 1 0 vtab:8383238:80C8CC0 3 VColumn 1 0 # bar.a sqlite3: ext/eb/eb.c:3578: wrsv_column: Assertion `c->row_data' failed. Whereas here's the trace from the first query listed which shows the call to xFilter() being made. Incomplete SQL: VDBE Execution Trace: SQL: [select * from foo, bar where foo.a = bar.a and bar.a >1;] 0 Goto 0 25 25 Transaction 0 0 26 VerifyCookie 0 2 27 Goto 0 1 1 VOpen 0 0 vtab:8D82E30:80C8CC0 2 VOpen 1 0 vtab:8D81238:80C8CC0 3 Integer 0 0 Stack: i:0 4 Integer 0 0 Stack: i:0 i:0 5 VFilter 0 22 6 Integer 1 0 Stack: i:1 7 VColumn 0 0 # foo.a Stack: i:100 i:1 8 Integer 2 0 Stack: i:2 i:100 i:1 9 Integer 0 0 Stack: i:0 i:2 i:100 i:1 10 VFilter 1 21 21 VNext 0 6 6 Integer 1 0 Stack: i:1 7 VColumn 0 0 # foo.a Stack: i:200 i:1 8 Integer 2 0 Stack: i:2 i:200 i:1 9 Integer 0 0 Stack: i:0 i:2 i:200 i:1 10 VFilter 1 21 21 VNext 0 6 6 Integer 1 0 Stack: i:1 7 VColumn 0 0 # foo.a Stack: i:300 i:1 21 VNext 0 6 6 Integer 1 0 Stack: i:1 7 VColumn 0 0 # foo.a Stack: i:200 i:1 8 Integer 2 0 Stack: i:2 i:200 i:1 9 Integer 0 0 Stack: i:0 i:2 i:200 i:1 10 VFilter 1 21 21 VNext 0 6 6 Integer 1 0 Stack: i:1 7 VColumn 0 0 # foo.a Stack: i:300 i:1 8 Integer 2 0 Stack: i:2 i:300 i:1 9 Integer 0 0 Stack: i:0 i:2 i:300 i:1 10 VFilter 1 21 21 VNext 0 6 22 Close 0 0 23 Close 1 0 24 Halt 0 0 I've tried a bit and cannot reproduce so far. What were the inputs and outputs of the xBestIndex() call prior to the crash? Thanks. ---- _2007-Mar-05 10:47:02 by anonymous:_ {linebreak} This is an error in my code. I was setting aConstraint[].argvIndex to the wrong argvIndex value. Apologies for the waste of bandwidth, but many thanks for fixing the other vtable issues. #f2dcdc 2258 new active 2007 Feb anonymous 2007 Mar 4 3 Include field name in check constraint failure message 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 #cfe8bd 2257 doc fixed 2007 Feb adixon 2007 Mar 4 4 Auto-vacuum documentation misleading The last sentence regarding auto-vacuum is misleading on http://www.sqlite.org/lang_vacuum.html This should mention that auto-vacuum is more likely to lead to disk fragmantation. #c8c8c8 2255 code closed 2007 Feb scouten 2007 Mar 3 3 Temporary DB files are deleted twice in pager_unwritelock, once implic Summary: pager_unwritelock in pager.c does this sequence: sqlite3OsClose(&pPager->jfd); pPager->journalOpen = 0; sqlite3OsDelete(pPager->zJournal); That code will result in two requests to delete the same file. That's because temporary DB journal files are opened with the "delete on close" flag, and thus the file will no longer exist by the time sqlite3OsDelete is called. Redundant delete requests doesn't cause an issue with the above code with synchronous writes because the return code is ignored. However, it does cause an issue on our test_async.c Windows port. Specifically, test_async.c has this code in the writer thread: case ASYNC_DELETE: TRACE(("DELETE %s\n", p->zBuf)); rc = xOrigDelete(p->zBuf); break; The windows implementation of sqlite3OsDelete will return an error code when attempting to delete a non-existent file. (The Unix version of sqlite3OsDelete always returns SQLITE_OK). So, our test_async port doesn't work on Windows because we receive a sticky I/O error due to the double delete. We're going to fix our test_async port like this: case ASYNC_DELETE: TRACE(("DELETE %s\n", p->zBuf)); rc = xOrigDelete(p->zBuf); if( rc != SQLITE_OK && !xOrigFileExists( p->zBuf ) ) rc = SQLITE_OK; break; However, we believe that the sqlite code should probably either: *: never attempt to delete files that have been opened with the "delete on close" flag set. *or* *: change the Windows implementation of sqlite3OsDelete to return SQLITE_OK if the DeleteFileW call fails due to attempting to delete a non-existent file Took the former option. SQLite now avoids deleting a file that has already been deleted via the 'delete on close' flag. #c8c8c8 2253 code closed 2007 Feb anonymous 2007 Mar danielk1977 1 1 src/vdbe.c:3639: sqlite3VdbeExec: Assertion `pC!=0' failed. In my virtual table I'm setting the estimatedCost of the query in a manner similar to what I see in where.c: /* If the table scan does not satisfy the ORDER BY clause, increase the cost by NlogN to cover the expense of sorting.*/ cost += cost*estLog(cost); However, I get an assertion failure in vdbe.c:3639. This problem appears to be generic as I can get fts1 to fail in the same way. I changed the last few lines in fts1.c:fulltextBestIndex to the following. Note: I copied the estLog function from where.c to fts1.c. pInfo->estimatedCost *= pInfo->estimatedCost * estLog(pInfo->estimatedCost); printf ("estimatedCost: %g\n", pInfo->estimatedCost); pInfo->idxNum = QUERY_GENERIC; return SQLITE_OK; The following statements raise the assertion: : ./sqlite3 Loading resources from /home/aim/.sqliterc SQLite version 3.3.13 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 where name like 'a'; estimatedCost: 2.475e+199 sqlite3: ./src/vdbe.c:3639: sqlite3VdbeExec: Assertion `pC!=0' failed. Aborted I get a similar assertion in vdbe.c:3587 : ./sqlite3 Loading resources from /home/aim/.sqliterc SQLite version 3.3.13 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 max (rowid) from foo; sqlite3: ./src/vdbe.c:3587: sqlite3VdbeExec: Assertion `pC!=0' failed. Aborted which is ticket #2250. _2007-Feb-26 13:07:23 by anonymous:_ {linebreak} There is a slight difference to the estimated cost calulation as it appears in where.c. In my case the estimated cost is *=, but in the where.c case it is +=. ---- _2007-Feb-26 13:11:21 by anonymous:_ {linebreak} I replaced the *= with += and the assertion is still raised. : ./sqlite3 Loading resources from /home/aim/.sqliterc SQLite version 3.3.13 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 where name like 'a'; estimatedCost: 5e+100 sqlite3: ./src/vdbe.c:3639: sqlite3VdbeExec: Assertion `pC!=0' failed. Aborted #c8c8c8 2250 code closed 2007 Feb anonymous 2007 Mar danielk1977 1 1 segmentation violation when using "select max(rowid)" in fts1 Using the following statements I find that: "select max(rowid) from foo" gives a segementation violation. create virtual table foo using fts1(name, address); insert into foo (name, address) values ('amanda', '43 elm avenue'); select * from foo; select rowid, * from foo; select max(rowid) from foo; Running the above in gdb: (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y `/home/aim/src/sqlite-cvs/sqlite3' has changed; re-reading symbols. Starting program: /home/aim/src/sqlite-cvs/sqlite3 Loading resources from /home/aim/.sqliterc SQLite version 3.3.13 Enter ".help" for instructions sqlite> .read testcase name address foo ---------- ------------- ---------- amanda 43 elm avenue @ rowid name address foo ---------- ---------- ------------- ---------- 1 amanda 43 elm avenue @ Program received signal SIGSEGV, Segmentation fault. 0x0806083a in sqlite3VdbeExec (p=0x9073098) at ./src/vdbe.c:3588 3588 if( (pCrsr = pC->pCursor)!=0 ){ (gdb) where #0 0x0806083a in sqlite3VdbeExec (p=0x9073098) at ./src/vdbe.c:3588 #1 0x08062d90 in sqlite3Step (p=0x9073098) at ./src/vdbeapi.c:236 #2 0x08062f32 in sqlite3_step (pStmt=0x9073098) at ./src/vdbeapi.c:289 #3 0x0806e551 in sqlite3_exec (db=0x9064330, zSql=0x9073fd0 "select max(rowid) from foo;", xCallback=0x8049e10 , pArg=0xbf86e0cc, pzErrMsg=0xbf86c6ac) at ./src/legacy.c:78 #4 0x0804df8b in process_input (p=0xbf86e0cc, in=0x9063be8) at ./src/shell.c:1606 #5 0x0804d051 in do_meta_command (zLine=0x9063b80 ".read", p=0xbf86e0cc) at ./src/shell.c:1314 #6 0x0804dd43 in process_input (p=0xbf86e0cc, in=0x0) at ./src/shell.c:1566 #7 0x0804ee5e in main (argc=1, argv=0xbf86f6a4) at ./src/shell.c:1936 (gdb) I ran it again this time touching 'vdbe_trace' and 'vdbe_explain' but this time compiled with SQLITE_DEBUG=1 and I get an assertion (see below). Note, I also see this with my own virtual table so I don't believe it's confined to fts1 and in my own virtual table I also see this assertion raised after calls to xBestIndex - for which I'll raise a separate ticket. sqlite> select max(rowid) from foo; VDBE Program Listing: SQL: [select max(rowid) from foo;] 0 Goto 0 6 1 Last 0 0 2 VRowid 0 0 3 Callback 1 0 4 Close 0 0 5 Halt 0 0 6 Transaction 0 0 7 VerifyCookie 0 3 8 Goto 0 1 9 Noop 0 0 VDBE Execution Trace: SQL: [select max(rowid) from foo;] 0 Goto 0 6 6 Transaction 0 0 7 VerifyCookie 0 3 8 Goto 0 1 1 Last 0 0 sqlite3: ./src/vdbe.c:3587: sqlite3VdbeExec: Assertion `pC!=0' failed. Program received signal SIGABRT, Aborted. [Switching to Thread -1208944960 (LWP 18456)] 0x00557402 in __kernel_vsyscall () (gdb) where #0 0x00557402 in __kernel_vsyscall () #1 0x0087fd40 in raise () from /lib/libc.so.6 #2 0x00881591 in abort () from /lib/libc.so.6 #3 0x0087938b in __assert_fail () from /lib/libc.so.6 #4 0x080647a6 in sqlite3VdbeExec (p=0x8dc6c78) at ./src/vdbe.c:3587 #5 0x080682a5 in sqlite3Step (p=0x8dc6c78) at ./src/vdbeapi.c:236 #6 0x0806857e in sqlite3_step (pStmt=0x8dc6c78) at ./src/vdbeapi.c:289 #7 0x0807674e in sqlite3_exec (db=0x8db9c90, zSql=0x8dc7668 "select max(rowid) from foo;", xCallback=0x8049e10 , pArg=0xbfa1026c, pzErrMsg=0xbfa1011c) at ./src/legacy.c:78 #8 0x0804df8b in process_input (p=0xbfa1026c, in=0x0) at ./src/shell.c:1606 #9 0x0804ee5e in main (argc=1, argv=0xbfa11844) at ./src/shell.c:1936 (gdb) Thanks for the report. #f2dcdc 2241 code active 2007 Feb scouten 2007 Mar 3 3 pragma integrity_check no longer affects command-line tool's exit code 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:_ {linebreak} 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? #f2dcdc 2233 new active 2007 Feb anonymous 2007 Mar 4 3 extend xBestIndex in vtables to carry the values for each contraint 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. #f2dcdc 2231 new active 2007 Feb anonymous 2007 Mar 4 4 shell should ignore leading whitespace for meta commands 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] && nArgechoOn ) 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:_ {linebreak} 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. #cfe8bd 2175 code fixed 2007 Jan anonymous 2007 Mar 3 3 lemon calling destructors more than once After [3593] destructors for unused tokens might be called more than once. _2007-Feb-07 16:15:44 by anonymous:_ {linebreak} Fixed this and the line number issue in: http://anonsvn.wireshark.org/viewvc/viewvc.py/trunk/tools/lemon/lemon.c?r1=20447&r2=20737 the diff is against lemon.c 1.43 in your repo #cfe8bd 2173 code fixed 2007 Jan anonymous 2007 Mar 4 4 Incorrect return value test for calls to fcntl() In the file os_unix.c calls are made to the POSIX function fcntl(). It is mistakenly assumed that an error condition is signaled by a non-zero return value. In fact, the POSIX spec. indicates that only -1 indicates an error and any other value (0, 1, -2, 50, etc...) can indicate success as well. It is suggested that an explicit check be made against "-1" in order to test for an error condition. On some platforms (notably QNX) a return value of zero (0) is not the only status code indicating success. See the POSIX spec: http://www.opengroup.org/onlinepubs/009695399/functions/fcntl.html QNX definition: http://www.qnx.com/developers/docs/momentics_nc_docs/neutrino/lib_ref/f/fcntl.html This function (fcntl) is called in several locations in os_unix.c and needs to be corrected in all places. If you have any questions, please let me know. Thanks, Glenn _2007-Mar-30 06:31:26 by anonymous:_ Comparision with POSIX_FCTL_SUCCESS (which should be defined somwhere will be more readable than with (-1) #c8c8c8 2170 code closed 2007 Jan anonymous 2007 Mar anonymous 3 3 -init does not execute .exit/.quit sqlite3 terminates with a prompt when called with -init commandfile and the last (or prevous line) of commandfile contains .exit/.quit .exit/.quit will never be executed. With this "feature" it can't be used in a WIN-batch file. _2007-Jan-24 14:40:36 by anonymous:_ {linebreak} There's a workaround for this bug: Create a text file with ".quit" in it (e.g., _quit.txt_). Run _sqlite3.exe_ redirecting standard input from this file. Ex: sqlite3.exe -init some_init_file.sql targetdatabase.db < quit.txt ---- _2007-Mar-29 20:08:51 by drh:_ {linebreak} Or just redirect input from the original script. I do not understand the problem here.... #c8c8c8 2169 code closed 2007 Jan anonymous 2007 Mar adamd 2 1 cast function A select statement does not support CAST when the table is empty select cast(a_float_field as float) from fields; the type of a_float_field is float( REAL ) but it returns intgere... _2007-Mar-29 20:06:40 by drh:_ {linebreak} SQLite is dynamically typed, not statically typed. Type is associated with values, not with containers. So it makes no sense to cast a value that does not exist. #f2dcdc 2136 new active 2007 Jan anonymous 2007 Mar 1 3 sqlite locking does not handle afs; patch included Please see http://www.mail-archive.com/sqlite-users%40sqlite.org/msg20672.html _2007-Jan-02 03:37:59 by anonymous:_ {linebreak} 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:_ {linebreak} Nope, that's something different. ---- _2007-Mar-30 00:39:05 by anonymous:_ {linebreak} You're right. I should have looked at the link more closely. #cfe8bd 2135 code fixed 2007 Jan anonymous 2007 Mar anonymous 4 3 missing entry sqlite3_clear_bindings in sqlite3_apis In loadext.c, line 110/111: The table sqlite3_apis lacks an entry for sqlite3_clear_bindings #f2dcdc 2133 build active 2006 Dec anonymous 2007 Mar 4 4 meta ticket for outstanding autoconf issues 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 #f2dcdc 2041 code active 2006 Oct anonymous 2007 Mar 4 4 sqlite3.pc on Solaris needs -lrt in "Libs:" entry 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:_ {linebreak} I was having similar problems, but my build failures didn't occur until 'make test'. Unfortunately, @TARGET_LIBS@ did not work for me... Thankfully, adding $(TLIBS) 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:_ {linebreak} #1802, #2041 and #2270 are the same basic issue: librt should get linked into libsqlite3.so #f2dcdc 1802 build active 2006 May anonymous Unknown 2007 Mar 4 4 sqlite.pc needs -lrt on Solaris for fdatasync() 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:_ {linebreak} #1802, #2041 and #2270 are the same basic issue: librt should get linked into libsqlite3.so #f2dcdc 1778 new active 2006 Apr anonymous Parser 2007 Mar 1 3 stdev does not work, workaround not possible due to missing sqrt 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.{linebreak} 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?{linebreak} {linebreak} Example:{linebreak} select count(*), avg(Num), stdev(Num) from Population;{linebreak} {linebreak} My workaround proposal is to use variance due to missing sqrt function:{linebreak} select count(*), avg(Num) as mean,{linebreak} (sum(Num*Num)/(count(*)-1)-sum(Num)*sum(Num)/count(*)/(count(*)-1)) as stdevsquared from Population;{linebreak} 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:_ {linebreak} 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 -/* #include */ +#include #include #include #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:_ {linebreak} 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 -/* #include */ +#include #include #include #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:_ {linebreak} 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. #cfe8bd 1036 code fixed 2004 Dec anonymous Unknown 2007 Mar 3 1 Wrong handling of column names from VIEWs create table t1 (a,b); create table t2 (a,c); insert into t1 values (1,2); insert into t2 values (1,3); create view myview as select t1.a a from t1 inner join t2 on t1.a=t2.a; create table problem as select * from myview; Now table "problem" contains the column "t1.a" instead of "a". Thus I must write "t1.a a" in every SQL which uses the view. _2007-Mar-18 17:26:33 by anonymous:_ {linebreak} I'm using SQLite 3.3.8, on Debian Etch. sqlite> CREATE TABLE table foo (x INTEGER); sqlite> CREATE VIEW foo_view AS SELECT foo.x FROM foo; sqlite> SELECT x FROM foo_view; SQL error: no such column: x sqlite> SELECT 'foo.x' FROM foo_view; So the bug is still here. #f2dcdc 930 new active 2004 Sep anonymous Unknown 2007 Mar drh 2 2 djgpp port for sqlite3 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 #f2dcdc 151 new active 2002 Sep anonymous 2007 Mar 5 5 Add 'configure' options for locating readline headers and library 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:_ {linebreak} 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 
    #f2dcdc 2393 code active 2007 May anonymous 2007 May 4 4 pragma cache_size not accurate when set to less than 10 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) #c8c8c8 2391 todo closed 2007 May danielk1977 2007 May danielk1977 1 1 Inconsistent behaviour from explicit collate clauses. Usually, explicit collation sequences take precedence over implicit ones. For example, in the following: CREATE TABLE t1(x COLLATE c1); SELECT * FROM t1 WHERE x = 'value' COLLATE c2; the collation sequence "c2" would be used. However, if an index is created on table t1 and then the query rerun, collation sequence c1 is used. CREATE INDEX i1 ON t1(x); SELECT * FROM t1 WHERE x = 'value' COLLATE c2; #c8c8c8 2390 code closed 2007 May anonymous 2007 May drh 1 1 defect in select with max(id) Hi, Defect related to select statement on scalars. OS: SuSE9.0 >create table test(id integer,col text); >echo "this table has no records" >select max(id) from test where col='aaa'; | >echo "select statement return a row and when accessed application crash" regards ragha _2007-May-29 04:19:10 by anonymous:_ {linebreak} I can't reproduce the crash. Select max(id) on an empty table will return NULL. Are you running these commands within the commandline sqlite3 or via the C API? ---- _2007-May-29 15:07:31 by anonymous:_ {linebreak} Am using C API. Code is as below [search for ERROR key] CppSQLite3Query CppSQLite3DB::execQuery(const char* szSQL) { checkDB(); sqlite3_stmt* pVM = compile(szSQL); int nRet = sqlite3_step(pVM);//ERROR:On completion of this statement nRet= SQLITE_ROW for the above sql query [select max(id),xx from tbl; if (nRet == SQLITE_DONE) { // no rows return CppSQLite3Query(mpDB, pVM, true/*eof*/); } else if (nRet == SQLITE_ROW) //ERROR { // at least 1 row return CppSQLite3Query(mpDB, pVM, false/*eof*/); } else { nRet = sqlite3_finalize(pVM); const char* szError= sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } ---- _2007-May-29 15:49:38 by anonymous:_ {linebreak} I don't think there is a problem here. Please consult the API documentation. ---- _2007-May-30 08:08:22 by anonymous:_ {linebreak} It's perfectly correct result, it returns one row with a one column containing NULL. #f2dcdc 2388 code active 2007 May anonymous 2007 May 1 3 ORDER BY fails on compound select 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:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 2387 code closed 2007 May anonymous 2007 May 1 1 query: problem with update anagrafica SET nome='nome' where id = '4'; when execute a query update into table (ex.anagrafica) there's no update (i try with 3.3.6 to 3.3.17 api and a command line tools like sqlite3.exe) for example: my database have this table CREATE TABLE anagrafica( id int(8), nome varchar(32) ); my command step: insert into anagrafica VALUES ('4','test'); update anagrafica SET nome="nome" where id = "4"; and there's no update (the column 'name' remain with value 'test') (select * from anagrafica; --> result: 4|test) but if i change with: update anagrafica SET nome="nome1" where id = "4"; all work's fine if i try: select * from anagrafica; ---> result: 4|nome1 Use single quotes around 'nome' to treat it as a string literal. Otherwise SQL treats it like set nome = nome (i.e., set it to the same thing). #c8c8c8 2386 doc closed 2007 May anonymous 2007 May 5 4 Suggestion for wiki speed comparisson: order by, group by, subselect It would be very nice to have on the speed comparisson wiki page tests for order by, group by, and subselects. It should be trivial to add and be very meaningful. Just a suggestion. Thanks! The Wiki is open to everyone. Feel free to add any new speed comparison you like. #c8c8c8 2385 code closed 2007 May anonymous 2007 May 5 4 Comment for SQLITE_VERSION_NUMBER has a typo (missing zero). ** 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. To detect if they are using ** version 3.1.1 or greater at compile time, programs may use the test ** (SQLITE_VERSION_NUMBER>=3001001). */ #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif #define SQLITE_VERSION_NUMBER 3003017 In the second line above, X*100000 should be X*1000000. Duplicate of #2384. See [4038]. #c8c8c8 2384 doc closed 2007 May anonymous 2007 May 1 5 an error in comments Please review the lines 65-69 of the sqlite3.c. Yes, it's true, it's just comments: ** 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. To detect if they are using ** version 3.1.1 or greater at compile time, programs may use the test ** (SQLITE_VERSION_NUMBER>=3001001). So let do some mathematics: X.Y.Z ==> 3.1.1 THEN X is 3, Y is 1 and Z is 1. SQLITE_VERSION_NUMBER = X*100000 + Y*1000 + Z = 3*100000 + 1*1000 + 1 = 300000 + 1000 + 1 = 301001 (???!!! A N D N O T 3001001) Thanks. #f2dcdc 2383 code active 2007 May anonymous 2007 May 3 3 Inconsistent conversion of BLOB revisited 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' #f2dcdc 2381 doc active 2007 May anonymous 2007 May 3 3 'VACUUM' aborts an active transaction. *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 #c8c8c8 2380 code closed 2007 May anonymous 2007 May 1 1 Order By Collum1, Collum2, Collum3 for Pocket PC incorrect in device Order By Collum1, Collum2, Collum3 for Pocket PC WM5.0 and Pocket PC 2003 correct in Emulator but not correct on Pocket PC device. nmtdhbk@yahoo.com thangnm@vega.com.vn Cannot reproduce. Please provide a test case with complete schema, data and the actual query and then re-open this ticket. #cfe8bd 2379 code fixed 2007 May anonymous 2007 May 3 3 Concatenation with zeroblob Concatenation operator ignores contents of zeroblob. $ ./sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> select hex(X'00' || X'61'); -- expected 0061 sqlite> select hex(zeroblob(1) || X'61'); 61 =pTerm->u.i= is ignored in "case OP_Concat:" of sqlite3VdbeExec(). #f2dcdc 2378 code active 2007 May anonymous 2007 May 2 2 Quoted fields come back corrupted, using GROUP BY *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* string(1) "1" } *Actual result* array(1) { [""id""]=> string(1) "1" } _2007-May-21 18:14:27 by anonymous:_ {linebreak} 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 #f2dcdc 2376 code active 2007 May anonymous 2007 May 3 3 -batch doesn't work soon enough 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. #c8c8c8 2375 doc closed 2007 May anonymous 2007 May 4 4 sqlite3_exec docs mentions sqlite3_reset The documentation for sqlite3_exec (capi3.html) says that it invokes sqlite3_reset (and suggests it gets invoked after sqlite3_finalize). The actual (amalgamated) source code does not call sqlite3_reset, unless I missed some trickery. The documenation may say a bit more about relation between sqlite3_reset and sqlite3_finalize: whether it is OK to call sqlite3_reset after sqlite3_finalize or whether this is a no-go. Those passages are not about sqlite3_exec(), they are supposed to be an overview of how to execute SQL queries. The details are in capi3ref.html. It's not OK to call sqlite3_reset() after sqlite3_finalize(). sqlite3_finalize() invalidates the statement handle and passing it to another function will likely cause a crash. #f2dcdc 2374 code active 2007 May anonymous 2007 May 5 5 "ALTER TABLE foo RENAME TO bar" will quote bar (ie. 'bar') 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 ) #f2dcdc 2373 new active 2007 May anonymous 2007 May 4 4 "create table as explain " doesn't work 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. #f2dcdc 2372 code active 2007 May anonymous 2007 May 4 4 sqlite3TestLockingStyle not used if SQLITE_FIXED_LOCKING_STYLE defined static function sqlite3TestLockingStyle() is not used if SQLITE_FIXED_LOCKING_STYLE is defined. It should probably be wrapped in: #ifndef SQLITE_FIXED_LOCKING_STYLE #f2dcdc 2371 code active 2007 May anonymous 2007 May 2 2 sqlite3_errcode() and sqlite3_errmsg() return unexpected results 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 #include #include #include #include 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); } #c8c8c8 2370 code closed 2007 May anonymous 2007 May 3 2 Data is converted without me telling it to do so I've created a table that looks like this:{linebreak} =CREATE TABLE Database (Name NVARCHAR(100) PRIMARY KEY, Value NONE)= I chose NONE, because "A column with affinity NONE does not prefer one storage class over another. *It makes no attempt to coerce data before it is inserted*.", as per the documentation. So I'll happily insert some data:{linebreak} =INSERT INTO Database (Name,Value) VALUES ('Version','1.0')= But to surprise, a SELECT reveals that not '1.0' has been inserted, but '1', even tough it was explicitly inserted as a string, as proven by the single quotes. _2007-May-17 22:16:55 by drh:_ {linebreak} In the same {link: /datatype3.html document} which you quote, just below the sentence you quote, in section 2.1 is an explanation of how the column affinity is determined. The 3rd case is the one you are interested in. Perhaps it would be clearer if a declared datatype of "NONE" would result in a column affinity of "NONE", but to change that now would break backwards compatibility which is something we are unwilling to do. ---- _2007-May-17 22:19:14 by anonymous:_ {linebreak} I think that a column with affinity NONE means to not specify anything for the column type, as follows: CREATE TABLE Database (Name NVARCHAR(100) PRIMARY KEY, Value); INSERT INTO Database (Name,Value) VALUES ('Version1.0','1.0'); INSERT INTO Database (Name,Value) VALUES ('Version2.0',2.0); INSERT INTO Database (Name,Value) VALUES ('Version2',2); select * from Database; Version1.0|1.0 Version2.0|2.0 Version2|2 #c8c8c8 2369 code closed 2007 May anonymous 2007 May 3 3 if you do a configure --prefix=/home/someotherdir tcl installs wrong install tcl to a "private" directory install sqlite3 to the same "private" directory ./configure --prefix=/home/whatever make (works now) make install yields tclsh ./tclinstaller.tcl 3.3 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 if you go to makefile and change the line HAVE_TCL = 1 to HAVE_TCL = then it installs correctly. Note also that I wanted to 'just' install sqlite3, not it and its tcl bindings, which thing appears either hard or impossible from the current source distros. It would have been nice to have a configure option to 'don't attempt to compile tcl bindings', but that was overcomeable. Thank you! Try the --disable-tcl option: ./configure --prefix=/home/whatever --disable-tcl It works for me. #c8c8c8 2368 code closed 2007 May anonymous 2007 May 1 1 vdbeblob.c missing from Makefile.in This is also the cause of the testfixture default build+link problem. Thanks again. #c8c8c8 2367 code closed 2007 May anonymous 2007 May 2 2 SQLITE_OMIT_INCRBLOB breaks default "make test" Running "./configure && make test" on a new tree pulled from CVS yields a failed link for testfixture and many unresolved externals dealing with SQLITE_OMIT_INCRBLOB symbols. (Note: I am not #defining SQLITE_OMIT_INCRBLOB in the build). I think that vdbemem.c and vdbeblob.c should be added to TESTSRC in Makefile.in. It might be more maintainable if every sqlite3 library .c file were listed in TESTSRC. Or perhaps testfixture should be built using the amalgomation. There are also these warnings, which might be harmless, but seem wrong: ./src/tclsqlite.c:297: warning: excess elements in struct initializer ./src/tclsqlite.c:297: warning: (near initialization for `IncrblobChannelType') ./src/tclsqlite.c:297: warning: excess elements in struct initializer ./src/tclsqlite.c:297: warning: (near initialization for `IncrblobChannelType') Compiled with Tcl 8.4. #c8c8c8 2366 code closed 2007 May anonymous 2007 May 4 4 "make test" failures: pragma-1.15, pragma-1.16 Fresh CVS checkout followed by "./configure && make test" pragma-1.15... Expected: [1] Got: [] pragma-1.16... Expected: [0] Got: [] These tests deal with PRAGMA vdbe_listing. Perhaps the default compile flags for testfixture do not enable vdbe_listing support. #c8c8c8 2365 code closed 2007 May anonymous 2007 May 1 1 incrvacuum2, zeroblob regressions from check-ins on 2007-May-16 Windows, Tcl 8.4, -DSQLITE_OMIT_INCRBLOB=1, make test incrvacuum2-1.1... Expected: [32768] Got: [3072] incrvacuum2-1.2... Expected: [31744] Got: [3072] incrvacuum2-1.3... Expected: [26624] Got: [3072] incrvacuum2-1.4... Ok incrvacuum2-2.1... Expected: [32768 32768] Got: [3072 3072] incrvacuum2-2.2... Expected: [32768 31744] Got: [3072 3072] incrvacuum2-2.3... Expected: [32768 26624] Got: [3072 3072] incrvacuum2-2.4... Expected: [27648 26624] Got: [3072 3072] incrvacuum2-2.5... Expected: [27648 3072] Got: [3072 3072] incrvacuum2-2.6... Expected: [26624 3072] Got: [3072 3072] zeroblob-1.1... Expected: [10] Got: [0] zeroblob-1.2... Expected: [10000] Got: [0] zeroblob-1.3... Expected: [10010] Got: [0] zeroblob-1.4... Expected: [1 10000 10000 1] Got: [1 0 0 1] zeroblob-1.5... Expected: [11] Got: [0] zeroblob-1.6... Expected: [1 10000 10000 1 10000 10000] Got: [1 0 0 1 0 0] zeroblob-1.7... Expected: [10] Got: [0] zeroblob-1.8... Expected: [10000 10000] Got: [0 0] zeroblob-2.1... Ok zeroblob-2.2... Ok zeroblob-3.1... Expected: [1] Got: [2] Thanks. #cfe8bd 2364 code fixed 2007 May anonymous 2007 May 2 2 cast(as numeric) truncates small number of large integer =cast(n as numeric)= may return an invalid result when =n= is a large integer. $ sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> select cast(9223372036854774800 as integer); -- OK 9223372036854774800 sqlite> select cast(9223372036854774800 as numeric); -- truncated 9223372036854774784 sqlite> select typeof(cast(9223372036854774800 as numeric)); integer The fraction of =n= is rounded down because =sqlite3VdbeMemNumerify()= converts the argument into REAL once before fits it to INTEGER. #f2dcdc 2363 code active 2007 May anonymous 2007 May 3 3 Couldn't build 3.3.17 on Cygwin/Vista 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:_ {linebreak} Another vote for this #c8c8c8 2362 code closed 2007 May anonymous 2007 May 4 4 Can't add a column with ALTER TABLE I have a table named "students" with only one column: sqlite> .schema students{linebreak} CREATE TABLE students ("id" INTEGER PRIMARY KEY NOT NULL); I'm trying to add a new column, but I get a syntax error: sqlite> alter table students add column photo blob;{linebreak} SQL error: near "add": syntax error I tried doing the same thing with a Rails migration file and got the same error: def self.up add_column :students, :photo, :binary end % rake db:migrate{linebreak} -- add_column(:students, :photo, :binary){linebreak} rake aborted!{linebreak} SQLite3::SQLException: near "ADD": syntax error: ALTER TABLE students ADD "photo" blob The same problem occurs with other data types, e.g. changing "blob" to "integer" gives the same message. _2007-May-16 05:21:21 by danielk1977:_ {linebreak} ALTER TABLE ADD COLUMN was not added until version 3.2.0 You should upgrade if possible. 3.1.3 is over 2 years old now. #c8c8c8 2361 new closed 2007 May anonymous 2007 May 3 3 Why is no LIMIT suported in UPDATE-queries? This is a question and a feature-request: if I have a query like UPDATE people SET capo='new' WHERE capo='old'; the execution would be faster (the table people has many entries) if I could tell how much times capo has the old value (i know it). This could be done using a LIMIT: UPDATE people SET capo='new' WHERE capo='old' LIMIT 3; Thanks _2007-May-15 22:37:47 by drh:_ {linebreak} UPDATE people SET capo='new' WHERE rowid IN (SELECT rowid FROM people WHERE capo='old' LIMIT 3); #cfe8bd 2360 code fixed 2007 May anonymous 2007 May 2 2 Possible buffer overrun in some text functions Some text functions calling _text after _bytes may causes buffer overrun on UTF-16. $ sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> pragma encoding = 'UTF-16be'; sqlite> select upper(a) from (select X'30423042304230423042304230423042' a); Aborted (core dumped) UTF-16be X'3042' is converted to UTF-8 X'E38182' which is longer than UTF-16. _2007-May-15 04:26:27 by drh:_ {linebreak} In think all of these problems have already been fixed in prior check-ins. See, for example, [3880] and [3874]. If you find any places that we have missed, please specify which functions are involved and reopen the ticket. ---- _2007-May-15 09:31:36 by danielk1977:_ {linebreak} In the implementation of upper(), we have: n = sqlite3_value_bytes(argv[0]); z2 = (char*)sqlite3_value_text(argv[0]); If argv[0] is a blob and the database encoding is UTF-16, then n is set to the number of bytes in the the blob. If value_text() is called, the blob is treated as UTF-16 and converted to UTF-8. Subsequent calls to sqlite3_value_bytes() return the length of the converted blob. But, because of the way SQLite converts encodings, the return value of sqlite3_value_text() at this point will always point to a buffer *larger* than n. So there is no overread in the subsequent memcpy(). Therefore this is not exploitable. But it is strange that value_text() can return a pointer to a string shorter than value_bytes(). ---- _2007-May-15 11:29:55 by anonymous:_ {linebreak} The current implementation of UPPER is here. n = sqlite3_value_bytes(argv[0]); z2 = (char*)sqlite3_value_text(argv[0]); if( z2 ){ z1 = sqlite3_malloc(n+1); if( z1 ){ memcpy(z1, z2, n+1); for(i=0; z1[i]; i++){ z1[i] = toupper(z1[i]); } sqlite3_result_text(context, z1, -1, sqlite3_free); } } =z2[n]= is not ='\0'= in the case of "=argv[0]= is BLOB and the encoding is UTF-16", so sqlite3_result_text may overreads after =z1[n]=. There is only overead (no overwrite) in the current CVS, so the risk is smaller but it may exploitable. ---- _2007-May-15 13:48:20 by anonymous:_ {linebreak} Would you rate the new policy _text() before _bytes() as clarified in [4005] stable or should we consider this still experimental? I am asking because the new way of doing things is the _exact opposite_ of the previous recommendation checked in quite recently. I also noticed that the SQLite sources have been updated according to the previous recommendation (they would have to reverted), and I did so likewise with my code (and would have to do so also). (PS: I am asking this here instead of the mailing list to record it along with this ticket). ---- _2007-May-15 13:52:48 by drh:_ {linebreak} The new policy is our best guess of how to deal with this problem as of right now. As new issues appear, we may come up with better guesses. But for right now, the current policy is the best we have. ---- _2007-May-15 14:22:04 by anonymous:_ {linebreak} Thanks! #cfe8bd 2359 code fixed 2007 May anonymous 2007 May 1 5 typo error sqlite3.h, line 357, comments for sqlite3_busy_handler "It is not clear why anyone would every want to do this" ----- ever #c8c8c8 2358 code closed 2007 May anonymous 2007 May 3 4 Incorrect index chosen for query I have a table with following columns: *:type_id (int) *:some_value (varchar) Indexes: *:idx_type (type_id) *:idx_some_value (some_value) *:idx_type_value (type_id,some_value) A query is invoked: {linebreak} _:select * from table where type_id = 10 and some_value = 'txt' The behavior is correct: idx_type_value is used for this query. {linebreak} However, when the query looks like this: _:select * from table where type_id = 10 and some_value IN ('txt') the index used is idx_type. {linebreak} {linebreak} I looked at the file where.c. I discovered that the additional column for an index (some_value IN (...)) adds some estimated cost for an index (row 1546 in where.c), and that's why the index with single column is chosen.{linebreak} Correct me if I'm wrong, but shouldn't the number of matched columns have priority over estimated cost? The solution is to change row 1617 in where.c from: _:if( cost < lowestCost ){ to _:if( nEq >= bestNEq && cost < lowestCost){ {linebreak} Best regards,{linebreak} Jacek _2007-May-14 13:03:40 by anonymous:_ {linebreak} The changed line should be: _:if( nEq > bestNEq || (nEq == bestNEq && cost < lowestCost)) { Jacek ---- _2007-May-14 13:13:10 by anonymous:_ {linebreak} It would be helpful if you posted some SQL create table/index statements with EXPLAIN QUERY PLAN showing the wrong index being selected. ---- _2007-May-14 13:31:50 by drh:_ {linebreak} The best solution is for your to drop the TYPE_ID index since it is redundant. The IDX_TYPE_VALUE index is a superset of TYPE_ID. Dropping TYPE_ID will make your database smaller and faster. #cfe8bd 2356 code fixed 2007 May anonymous 2007 May 1 1 INDEX not used if column in WHERE clause refers to an alias create table t1(a); create index t1_idx on t1(a); explain query plan select a from t1 where a = 1; 0|0|TABLE t1 WITH INDEX t1_idx explain query plan select a as aaa from t1 where aaa = 1; 0|0|TABLE t1 #c8c8c8 2355 code closed 2007 May anonymous 2007 May 3 4 Segfault with looooong sql string Good day. I am using sqlite (amalgama) in my apache module. Following sequience work OK for me: const char *create_table = " \ CREATE TABLE IF NOT EXISTS log \ ( \ peer_ip TEXT, \ date INTEGER, \ gmt_diff INTEGER, \ category TEXT, \ policy TEXT, \ client_ip TEXT, \ client_port TEXT, \ host_name TEXT, \ dest_url TEXT, \ request_method TEXT, \ site_profile TEXT, \ matched_pattern TEXT, \ error_string TEXT, \ http_headers TEXT, \ text BLOB \ ) \ "; return sqlite3_exec( db_handler, create_table, NULL, NULL, NULL ); But when I change format to const char *create_table = " \ CREATE TABLE IF NOT EXISTS log \ ( \ peer_ip TEXT, \ date INTEGER, \ gmt_diff INTEGER, \ category TEXT, \ policy TEXT, \ client_ip TEXT, \ client_port TEXT, \ host_name TEXT, \ dest_url TEXT, \ request_method TEXT, \ site_profile TEXT, \ matched_pattern TEXT, \ error_string TEXT, \ http_headers TEXT, \ text BLOB \ ) \ "; I.e make string a bit longer, my module (with whole apache) is segfault. It's looks like there is a buffer overflow somewhere in the sqlite code. I was trying to find it by myself, but soon gave up :( Valery _2007-May-14 04:09:15 by danielk1977:_ {linebreak} I tried to reproduce this, but could not. Does the attached C program crash for you? Can we have a stack trace from the apache crash? Thanks. ---- _2007-May-14 11:40:14 by drh:_ {linebreak} The automated test suite for SQLite uses CREATE TABLE statements that are much, much bigger than the example above. So we seriously doubt the problem is a buffer overflow in SQLite. Since we are unable to reproduce the problem, pending evidence to the contrary, we will assume this is a problem in either apache or in the application and not in SQLite. ---- _2007-May-14 15:37:11 by anonymous:_ {linebreak} Long ago I've seen the visual studio 1.xx (can't remember) make a mess of a multi line define after editing the define. When retyping the lines all was well. Maybe its an editor issue. #cfe8bd 2354 code fixed 2007 May anonymous 2007 May 2 1 Win32 locking problems The Win32 winLock() function does not re-acquire a shared lock when acquisition of an exclusive lock has failed. See patch in attachment for a possible solution. _2007-May-14 11:59:53 by anonymous:_ {linebreak} The first attachment was not readable, use second attachment win32locking.patch instead #c8c8c8 2353 code closed 2007 May anonymous 2007 May 1 1 Issue with selecting values of indexed column I have a database with ~500000 records in the table TAB. The table has several columns. One column is INTEGER and other columns are TEXT type. Also there is an index for column of INTEGER type. Let say the column of INTEGER type has name XXX. Now the problem: 1) select * from TAB where XXX >= 10000 order by rowid; Works very fast (as expected for indexed column). 2) select * from TAB where XXX >= 10000 and XXX <=20000 order by rowid; Works VERY slowly (as slow as there is no index for XXX). I have tried to rewrite previous request: 3) select * from TAB where not (XXX < 10000 or XXX > 20000) order by rowid; This request returns the same records as previous one, but it works as FAST as request from the first example. What wrong with request in second example? Also I have noted, after removing "order by rowid" the second example also works fast but the order of records is incorrect. _2007-May-11 16:15:39 by drh:_ {linebreak} This appears to be a request for technical support, not a bug report. Please use the mailing list for technical support and reserve tickets for report real bugs. See http://www.sqlite.org/support.html for information on how to access the mailing list. #f2dcdc 2352 code active 2007 May anonymous 2007 May 5 3 timeout just 500 msec to soon 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. #f2dcdc 2351 secure active 2007 May anonymous 2007 May 2 2 UTF-16 convertor accepts malformed UTF-8 sequence 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 '' a, '<31>' b); pragma encoding = 'UTF-16'; select hex(a), hex(b), a == b from (select '' a, '<31>' b); $ ./sqlite3 < test.sql CEB1|D031|0 CEB1|CEB1|1 It's necessary to validate subsequent bytes. #f2dcdc 2350 code active 2007 May anonymous 2007 May 1 1 Temp files not deleted on WinCE 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 2349 code fixed 2007 May anonymous 2007 May 3 3 Inconsistent conversion of BLOB to TEXT on UTF-16 When the encoding is UTF-16, BLOB is generally converted as UTF-16. But the literal BLOB is converted as UTF-8. $ ./sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> pragma encoding = 'UTF-16be'; sqlite> -- general case sqlite> select quote(cast('ab' as blob)); X'00610062' sqlite> select quote(cast(cast('ab' as blob) as text)); 'ab' sqlite> select quote(cast(a as text)) from (select X'00610062' a); 'ab' sqlite> -- literal BLOB is converted as UTF-8 sqlite> select quote(cast(X'00610062' as text)); '' sqlite> select quote(cast(X'6162' as text)); 'ab' sqlite> -- conversion in UPPER function sqlite> select quote(upper(cast('ab' as blob))); 'AB' sqlite> select quote(upper(X'00610062')); '' sqlite> select quote(upper(X'6162')); 'AB' #cfe8bd 2348 doc fixed 2007 May anonymous 2007 May 5 3 deteched -> detected There's a typo in line 2803 of src/pager.c. Please fix from 'deteched' to 'detected'. #cfe8bd 2347 code fixed 2007 May anonymous 2007 May 3 3 sqlite 3.3.17 crashes when doing "IN (select union select)" Couldn't find an open ticket on this. Short story: sqlite3: ../sqlite-cvs/src/select.c:552: selectInnerLoop: Assertion `nColumn==1' failed. Long story. This is reproducible on two different Windows 2000 both running sqlite-3.3.17 release, FreeBSD-5.1 using sqlite-3.3.17 release and Linux Fedora Core 6 x86 using latest cvs. This query causes the crash. select count(*) from foo where id in (select * from foo where id != 0 union select * from foo where id == 0); But this one doesn't. select count(*) from foo where id in (select id from foo where id != 0 union select id from foo where id == 0); The crash only occurs once the table has (at least in my scenario) 24 entries. I've attached a script which sets up the table, fills it with data and demonstrates the crash. Other attachments includes the DrWatson32 log and the gdb traceback. _2007-May-09 18:59:55 by anonymous:_ {linebreak} Can you post the schema of the table(s) involved? ---- _2007-May-09 19:01:07 by anonymous:_ {linebreak} You're to fast dammit! I'm attaching as fast as I can :) ---- _2007-May-09 19:04:27 by anonymous:_ {linebreak} :-) Repeated inline for ease of viewing... -- DROP TABLE "foo"; BEGIN TRANSACTION; CREATE TABLE foo (id int, extra int); INSERT INTO "foo" VALUES(0,NULL); INSERT INTO "foo" VALUES(1,NULL); INSERT INTO "foo" VALUES(2,NULL); INSERT INTO "foo" VALUES(3,NULL); INSERT INTO "foo" VALUES(4,NULL); INSERT INTO "foo" VALUES(5,NULL); INSERT INTO "foo" VALUES(6,NULL); INSERT INTO "foo" VALUES(7,NULL); INSERT INTO "foo" VALUES(8,NULL); INSERT INTO "foo" VALUES(9,NULL); INSERT INTO "foo" VALUES(10,NULL); INSERT INTO "foo" VALUES(11,NULL); INSERT INTO "foo" VALUES(12,NULL); INSERT INTO "foo" VALUES(13,NULL); INSERT INTO "foo" VALUES(14,NULL); INSERT INTO "foo" VALUES(15,NULL); INSERT INTO "foo" VALUES(16,NULL); INSERT INTO "foo" VALUES(17,NULL); INSERT INTO "foo" VALUES(18,NULL); INSERT INTO "foo" VALUES(19,NULL); INSERT INTO "foo" VALUES(20,NULL); INSERT INTO "foo" VALUES(21,NULL); INSERT INTO "foo" VALUES(22,NULL); -- If I comment the following line, the crash now longer occurs! INSERT INTO "foo" VALUES(23,NULL); COMMIT; -- this query crashes select count(*) from foo where id in (select * from foo where id != 0 union select * from foo where id == 0); -- this doesn't -- select count(*) from foo where id in (select id from foo where id != 0 union select id from foo where id == 0); ---- _2007-May-09 19:34:32 by drh:_ {linebreak} If you compile with -DSQLITE_DEBUG=1 (to enable assert() macros) then you get an assertion fault early, without the need for stuffing large amounts of data into the table. ---- _2007-May-09 19:37:32 by drh:_ {linebreak} Test case: CREATE TABLE t1(a,b); SELECT 0 IN (SELECT * FROM t1 UNION SELECT * FROM t1); ---- _2007-May-09 19:47:44 by anonymous:_ {linebreak} That's a nice and small sample. I actually did compile (on Linux at least) with --enable-debugging (which apparently sets -DSQLITE_DEBUG=1). However my sql-fu wasn't strong enough to come up with a smaller sample :-) #c8c8c8 2346 code closed 2007 May anonymous 2007 May 1 1 Inserting a certain integer Seems to be an issue storing large numbers. Recreate: > CREATE TABLE f (i INTEGER); > INSERT INTO f (i) VALUES (243484607108059); > SELECT i FROM f; -37990369602597 (expected 243484607108059) It is interesting if you look at the HEX for these two numbers. -37990369602597 => 0xFFFFDD72AD83D3DB 243484607108059 => 0xDD72AD83D3DB _2007-May-09 17:53:36 by anonymous:_ {linebreak} SQLite version 3.3.13 {linebreak} Enter ".help" for instructions {linebreak} sqlite> CREATE TABLE f (i INTEGER); {linebreak} sqlite> INSERT INTO f (i) VALUES (243484607108059); {linebreak} sqlite> select i from f; {linebreak} 243484607108059 {linebreak} ---- _2007-May-09 19:30:23 by drh:_ {linebreak} This is a duplicate of ticket #1212. #cfe8bd 2345 code fixed 2007 May anonymous 2007 May 3 3 NaN is printed as '0.0' Infinity of type REAL (including Inf and -Inf) is printed as 'NaN', but true NaN is printed as '0.0'. $ ./sqlite3 SQLite version 3.3.17 Enter ".help" for instructions sqlite> select 1e300 * 1e300; -- +Inf NaN sqlite> select typeof(1e300 * 1e300); real sqlite> select 1e300 * -1e300; -- -Inf NaN sqlite> select 1e300 * 1e300 * 0.0; -- NaN 0.0 sqlite> select typeof(1e300 * 1e300 * 0.0); real sqlite> select 1e300 * 1e300 * 0.0 + 1.0; -- also NaN 0.0 sqlite> select max(-1.0, 1e300 * 1e300 * 0.0); -- the value is not 0.0 -1.0 _2007-May-09 02:56:01 by anonymous:_ {linebreak} And NaN is always equals to any number. sqlite> select 1e300 * 1e300 * 0.0 == 1.1; 1 sqlite> select 1e300 * 1e300 * 0.0 == 1.2; 1 sqlite> select 1e300 * 1e300 * 0.0 == 100; 1 #cfe8bd 2343 code fixed 2007 May anonymous 2007 May drh 2 3 mallo.c typo in v 1.168/check in 3925 of Makefile.in diff Makefile.in new.Makefile.in 155c155 < $(TOP)/src/mallo.c \ --- > $(TOP)/src/malloc.c \ #f2dcdc 2342 doc active 2007 May anonymous 2007 May 1 1 Document that prepared incremental vacuum needs multiple sqlite3_step 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? #cfe8bd 2341 code fixed 2007 May anonymous 2007 May 1 1 Potential buffer overflow in sqlite3_snprintf(). The following code should reproduce and explain the problem: /* sqlite3_snprintf() writes terminating zero beyond specified buffer length: */ c[0] = 'a'; c[1] = 0; c[2] = 0; printf ("%s\n", c); sqlite3_snprintf (0, c, "Some String"); printf ("sqlite3_snprintf: '%s'\n", c); c[0] = 'a'; c[1] = 0; c[2] = 0; printf ("%s\n", c); snprintf (c, 0, "Some String"); printf ("snprintf : '%s'\n", c); printf("----\n"); /* Output differs from snprintf: */ c[0] = 'a'; c[1] = 'b'; c[2] = 0; printf ("%s\n", c); sqlite3_snprintf (1, c, "cd"); printf ("sqlite3_snprintf: '%s'\n", c); c[0] = 'a'; c[1] = 'b'; c[2] = 0; printf ("%s\n", c); snprintf (c, 1, "cd"); printf ("snprintf : '%s'\n", c); Here is the output I receive from the above: a sqlite3_snprintf: '' a snprintf : 'a' ---- ab sqlite3_snprintf: '' ab snprintf : 'cb' _2007-May-07 11:24:35 by drh:_ {linebreak} It would appear that sqlite3_snprintf() is safer than snprintf() since sqlite3_snprintf() always guarantees a NUL-terminated string whereas (according to the test case above) snprintf() does not. I was not aware that snprintf() misbehaved in this way and I did not see any mention of the fact in the snprintf() man page. This is good to know. #f2dcdc 2340 code active 2007 May anonymous 2007 May 3 3 "./configure && make testfixture" link problem 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:_ {linebreak} 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 #cfe8bd 2339 code fixed 2007 May anonymous 2007 May 1 1 strange behavior for UNION I've discovered strange behavior for UNION.
     create table t1(num int); insert into t1 values (1); insert into t1 values (2); insert into t1 values (3); insert into t1 values (4);  create table t2(num int); insert into t2 values (11); insert into t2 values (12); insert into t2 values (13); insert into t2 values (14); 
    1.
     select * from t1 order by num desc limit 2; 4 3  select * from t2 order by num desc limit 2; 14 13 
    Ok. 2.
     select * from (select * from t1 order by num desc limit 2); 4 3 select * from (select * from t2 order by num desc limit 2); 14 13 
    Ok.
     3.   select * from (select * from t1 order by num desc limit 2) UNION   select * from (select * from t2 order by num desc limit 2); 1 2 11 12 
    Bad! Looks like UNION cancel "order by date" for subqueries. Why? 4.
       select * from (select * from t1 order by num desc limit 2) UNION   select * from (select * from t2 order by num desc limit 2) ORDER BY num DESC; 14 13 2 1 
    Very strange! "ORDER BY" for 1st subquery do not work, but work very well for 2st :/ _2007-May-06 07:38:45 by anonymous:_ {linebreak} The same discovered at SQLite version 3.3.12 ---- _2007-May-06 15:01:53 by anonymous:_ {linebreak} Another data point... select * from (select * from t1 order by num desc limit 2) UNION select * from (select * from t2 order by num desc limit 2); 1 2 11 12 select * from (select * from t1 order by num desc limit 2) UNION ALL select * from (select * from t2 order by num desc limit 2); 4 3 14 13 Ignoring the order of the final results, you can see that just by changing UNION to UNION ALL changes the individual _values_ in the results. ---- _2007-May-06 15:13:29 by anonymous:_ {linebreak} This hack avoids the problem by not flattening the subqueries. This hack will degrade SELECT performance in the general case, so be warned. Index: src/select.c =================================================================== RCS file: /sqlite/sqlite/src/select.c,v retrieving revision 1.338 diff -u -3 -p -r1.338 select.c --- src/select.c 16 Apr 2007 17:07:55 -0000 1.338 +++ src/select.c 6 May 2007 15:12:08 -0000 @@ -2922,12 +2922,14 @@ int sqlite3Select( ** If flattening is a possiblity, do so and return immediately. */ #ifndef SQLITE_OMIT_VIEW +#if 0 if( pParent && pParentAgg && flattenSubquery(pParent, parentTab, *pParentAgg, isAgg) ){ if( isAgg ) *pParentAgg = 1; goto select_end; } #endif +#endif /* If there is an ORDER BY clause, then this sorting ** index might end up being unused if the data can be ---- _2007-May-06 16:12:38 by anonymous:_ {linebreak} Here's the issue... This compound SELECT: select * from (select * from t1 order by num desc limit 2) UNION select * from (select * from t2 order by num desc limit 2); Is _logically_ flattened to this form: -- note: not actual SQL select num from t1 order by num desc limit 2 UNION select num from t2 order by num desc limit 2; And sqlite3Select()'s use of IgnorableOrderby() _logically_ transforms it into this form: -- note: not actual SQL select num from t1 limit 2 UNION select num from t2 limit 2; ---- _2007-May-06 16:44:04 by anonymous:_ {linebreak} This is an old problem going back to early in the SQLite 3.x series, to at least to 2005. ---- _2007-May-06 18:03:48 by anonymous:_ {linebreak} Better fix: Index: src/select.c =================================================================== RCS file: /sqlite/sqlite/src/select.c,v retrieving revision 1.340 diff -u -3 -p -r1.340 select.c --- src/select.c 4 May 2007 13:15:56 -0000 1.340 +++ src/select.c 6 May 2007 18:01:55 -0000 @@ -2128,6 +2128,9 @@ static void substSelect(Select *p, int i ** ** (14) The subquery does not use OFFSET ** +** (15) The outer query is not part of a compound SELECT +** when the subquery has ORDER BY clause and a LIMIT clause. +** ** In this routine, the "p" parameter is a pointer to the outer query. ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. @@ -2172,6 +2175,9 @@ static int flattenSubquery( ** and (14). */ if( pSub->pLimit && p->pLimit ) return 0; /* Restriction (13) */ if( pSub->pOffset ) return 0; /* Restriction (14) */ + if( p->pRightmost && pSub->pLimit && pSub->pOrderBy ) { + return 0; /* Restriction (15) */ + } if( pSubSrc->nSrc==0 ) return 0; /* Restriction (7) */ if( (pSub->isDistinct || pSub->pLimit) && (pSrc->nSrc>1 || isAgg) ){ /* Restrictions (4)(5)(8)(9) */ ---- _2007-May-06 20:27:29 by anonymous:_ {linebreak} related Check-in [3932] #c8c8c8 2338 todo closed 2007 May anonymous 2007 May 4 3 3.3.17 windows dll download gives 3.2.7 I downloaded the pre-built windows 3.3.17 dll and did a "SELECT sqlite_version()" (via a variant of the ctypes Python code at ) and got the response "3.2.7". You either have a path problem or python is using a specific version of sqlite. #cfe8bd 2337 code fixed 2007 May anonymous 2007 May 1 1 Unusual break of functionality (vtab-related?) after check-in 3918 The code below returns an unusual error as of CVS check-in [3918]. See comments in source for details. #include #include "sqlite3.h" #include "fts2.h" sqlite3 *db; int check ( int rc ){ if( rc != SQLITE_OK && rc != SQLITE_ROW && rc != SQLITE_DONE ){ printf ("%d - %s\n", rc, sqlite3_errmsg(db) ); } return rc; } #pragma argsused int main(int argc, char* argv[]) { check( sqlite3_open( "test_fts2.db3", &db) ); check( sqlite3_exec( db, "CREATE VIRTUAL TABLE FTS USING FTS2 (c);", 0, 0, 0)); check( sqlite3_exec( db, "INSERT INTO FTS (Content) VALUES ('" "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas " "iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam " "sed turpis posuere placerat. Curabitur et lorem in lorem porttitor " "aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit " "ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra " "at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus, " "ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at " "luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu " "lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse " "potenti. Cum sociis natoque penatibus et magnis dis parturient " "montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu, " "suscipit nec, consequat quis, risus." "');", 0,0,0)); /* Problem here: This takes a long time and finally returns Eror 1, "SQL logic error or missing database". */ check( sqlite3_exec( db, "SELECT RowID from FTS WHERE c MATCH 'lorem';", 0, 0, 0)); check( sqlite3_close( db )); printf ("Done"); scanf ("*%s"); return 0; } _2007-May-05 07:26:41 by anonymous:_ {linebreak} The error is triggered by check-in [3916] in os_win.c, line 949: Old, working version: sprintf(zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath); New, non-working version: sqlite3_snprintf(sizeof(zBuf), zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath); The problem is caused by the sizeof(zBuf) argument to sqlite3_snprintf. Not the size of the pointer to the buffer but the size of the actual buffer allocated should be passed, which is at least SQLITE_TEMPNAME_SIZE, according to the function's comments. A tested fix is sqlite3_snprintf(SQLITE_TEMPNAME_SIZE, zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath); *Notes on the general sprintf -> sqlite3_snprintf replacement in check-in [3916]:* A quick glance through the changes of check-in [3916] indicated further possible wrong uses of sizeof() with sqlite3_snprintf. A more experienced developer might want to double-check. An important difference between sprinft and sqlite3_snprintf is that sprintf will never relocate the buffer, whereas sqlite3_snprintf might do so, if I am not mistaken. At least the case above relies on the fact that this does not happen. May I instead propose another, more compatible sprintf replacement: int sqlite3_sprintf (char *Buffer, const char *zFormat, ...){ va_list ap; struct sgMprintf sM; int result; va_start(ap,zFormat); sM.zBase = sM.zText = Buffer; sM.nChar = sM.nTotal = 0; sM.nAlloc = 0x7fffffff; sM.xRealloc = NULL; result = vxprintf(mout, &sM, 0, zFormat, ap); va_end(ap); return result; } I have used this successfully as a sprintf replacement in sqlite until now and it has always worked without problems. As an additional benefit, it is more compact, never reallocates memory and should therefore perform even slightly faster than sqlite3_snprintf. ---- _2007-May-05 12:05:31 by drh:_ {linebreak} sqlite3_snprintf() does not do any buffer reallocation, as far as I can see. ---- _2007-May-07 08:01:14 by anonymous:_ {linebreak} You are correct that sqlite3_snprintf() does not reallocate memory. I have confused it with sqlite3_mprintf(). My apologies for causing trouble. Thanks for the fix, all uses of sqlite3_snprintf() now appear to use the correct buffer size. However, I believe that there is a rare buffer overflow problem with sqlite3_snprintf. I reported this as a separate ticket #2341. #cfe8bd 2335 code fixed 2007 May anonymous 2007 May 1 2 real value corruption on different platforms this problem exists when transferring a db-file betwenn an arm and x86 platform. when storing a real value into the file, it gets utterly corrupted when reading on the other platform. example: the stored value 1.23 will turn into 8.02989250985743e+283, the direction of the platform change does not matter. error is reproductible and shows in versions 3.3.13 and 3.3.17, other versions not tested. integer and datetime values work fine, so its not an endianness problem. i can provide neccessary test data and information if needed, usually within some days, please feel free to contact me. i assigned severity 1 because its a real showstopper if you want to use floating point numbers. _2007-May-04 11:17:16 by drh:_ {linebreak} This is because the ARM7, in defiance of all reason, uses a mixed-endian representation for 64-bit floating point values. See ticket #2278. #cfe8bd 2334 code fixed 2007 May anonymous 2007 May 3 3 valgrind complains about memcpy in select.c (overlapping memory) i have seen valgrind complaining about the line {linebreak} memcpy(aCopy, pKeyInfo->aColl, nCol*sizeof(CollSeq*));{linebreak} in select.c - warning was something about overlapping memory etc also seen some crashes in select.c but havent got any stack yet.{linebreak} sure what the memory areas there dont overlap never and replacing it with a memmove is pointless? #f2dcdc 2333 new active 2007 May anonymous 2007 May 5 4 support memory mapped files 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:_ {linebreak} 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. #c8c8c8 2332 code closed 2007 May anonymous 2007 May danielk1977 1 1 incrblob: Data error writing large blobs The new incremental blob interface chokes on large blobs. Data is not stored correctly if it exceeds a certain size (roughly more than 2 MB). See this code to reproduce: #include #include #include #include "sqlite3.h" sqlite3 *db; int check ( int rc ){ if( rc != SQLITE_OK && rc != SQLITE_ROW && rc != SQLITE_DONE ){ printf ("%d - %s\n", rc, sqlite3_errmsg(db) ); } return rc; } const char *fn = "test_blob.db3"; const buf_size = 0x4000 * 2 * 16 * 4; #pragma argsused int main(int argc, char* argv[]) { unsigned char * buf; int i; sqlite3_stmt *pStmt; sqlite3_blob *pBlob; sqlite_int64 RowId; remove( fn ); check( sqlite3_open( fn, &db) ); check( sqlite3_exec( db, "CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB);", 0, 0, 0)); check( sqlite3_prepare( db, "INSERT INTO blobs (k, v) VALUES (?,?);", -1, &pStmt, NULL)); check( sqlite3_bind_int ( pStmt, 1, 1) ); check( sqlite3_bind_zeroblob ( pStmt, 2, buf_size ) ); check( sqlite3_step( pStmt) ); check( sqlite3_finalize( pStmt )); RowId = sqlite3_last_insert_rowid ( db ); check( sqlite3_blob_open ( db, "main", "blobs", "v", RowId, 1, &pBlob )); buf = sqlite3_malloc( buf_size ); for (i = 0; i < buf_size; i++) { buf[i] = i % 0xff; } check( sqlite3_blob_write( pBlob, buf, buf_size, 0) ); for (i = 0; i < buf_size; i++) { buf[i] = 0xFF; } check( sqlite3_blob_read( pBlob, buf, buf_size, 0) ); for (i = 0; i < buf_size; i++) { if (buf[i] != i % 0xff ) { /* Flag error */ printf ("Expected: %d - Found: %d\n", i, buf[i]); }; } sqlite3_free( buf ); check( sqlite3_blob_close( pBlob )); check( sqlite3_close ( db )); printf ("Done"); scanf ("*%s"); return 0; } Thanks! #c8c8c8 2331 code closed 2007 May anonymous 2007 May 1 1 Performance problem with complex where clause I'm running a query against attached database and it runs very slow - about 5 seconds(on larger database it can ran for a whole minute). Select [Node_Entity].* From [Node] AS [Node_Node] JOIN [Entity] AS [Node_Entity] ON [Node_Node].LOCAL_ID = [Node_Entity].LOCAL_ID , [Link] AS [Link_Link] JOIN [Entity] AS [Link_Entity] ON [Link_Link].LOCAL_ID = [Link_Entity].LOCAL_ID Where (( (([Link_Link].[Target.Id]='06d15df5-4253-4a65-b91f-cca52da960fe') AND ([Link_Link].[Source.Id]=[Node_Entity].[Id])) OR (([Link_Link].[Target.Id]=[Node_Entity].[Id]) AND ([Link_Link].[Source.Id]='06d15df5-4253-4a65-b91f-cca52da960fe')) )) If I remove a part of where clause " OR (([Link_Link].[Target.Id]=[Node_Entity].[Id]) AND ([Link_Link].[Source.Id]='06d15df5-4253-4a65-b91f-cca52da960fe'))" It runs in 16 ms. All .Id fields are indexed This would be better answered on the mailing list. #c8c8c8 2330 code closed 2007 May anonymous 2007 May drh 2 2 Usage of fieldname Session is impossible for where clause I found a problem when using the word "Session" as a field name. In such case it is impossible to filter out using a where clause. Using same data and structure but with another field name works find. Is this a bug or what meaning has Session ? There is no warning or error message but only wrong or unexpected behaviour. Here is the code to demonstrate this from the command line (but also from within applications). D:\Boat>sqlite3.exe Crew.sqb{linebreak} SQLite version 3.3.17{linebreak} Enter ".help" for instructions{linebreak} sqlite> .headers on{linebreak} sqlite> .schema{linebreak} CREATE TABLE 'Boat1' ({linebreak} Session varchar(20),{linebreak} Pos int,{linebreak} Name varchar(20),{linebreak} kg int,{linebreak} Primary key(Session,Pos) );{linebreak} CREATE TABLE 'Boat2' ({linebreak} ID varchar(20),{linebreak} Pos int,{linebreak} Name varchar(20),{linebreak} kg int,{linebreak} Primary key(ID,Pos) );{linebreak} sqlite> select * from Boat1 where Session="Session";{linebreak} Session|Pos|Name|kg{linebreak} 2007-04-30|21|Andreas T|60{linebreak} 2007-04-30|31|Udo|61{linebreak} 2007-04-30|41|Manfred|62{linebreak} 2007-04-30|51|Andreas R|63{linebreak} 2007-04-30|61|Alex|64{linebreak} 2007-04-30|71|Simone|55{linebreak} 2007-04-30|81|Cesar|75{linebreak} 2007-04-30|91|Wolfgang|76{linebreak} 2007-04-30|101|Lisa|56{linebreak} 2007-04-30|22|Adalbert|65{linebreak} 2007-04-30|32|Andrea|57{linebreak} 2007-04-30|52|Tim T|52{linebreak} 2007-04-30|62|Andreas S|66{linebreak} 2007-04-30|72|Ralf|67{linebreak} 2007-04-30|82|Joerg K|68{linebreak} 2007-04-30|92|Heike|54{linebreak} 2007-04-30|102|Uwe|72{linebreak} 2007-04-30|42|Karsten|73{linebreak} 2007-04-30|1|Joerg E|55{linebreak} Session|10|Zusatzgewicht 5kg|5{linebreak} Session|20|Zusatzgewicht 10kg|10{linebreak} Session|30|Zusatzgewicht 15kg|15{linebreak} Session|40|Zusatzgewicht 20kg|20{linebreak} sqlite> select * from Boat2 where ID="Session";{linebreak} ID|Pos|Name|kg{linebreak} Session|10|Zusatzgewicht 5kg|5{linebreak} Session|20|Zusatzgewicht 10kg|10{linebreak} Session|30|Zusatzgewicht 15kg|15{linebreak} Session|40|Zusatzgewicht 20kg|20{linebreak} sqlite>{linebreak} One Structure, one Query, two different results. Only difference is the renaming of field Session into eg ID (or something else). _2007-May-01 10:08:58 by anonymous:_ {linebreak} Learn to use correct quotes in SQL or use binding parameters (from code). The first query should be written as select * from Boat1 where Session='Session'; (note the single quotes) Otherwise the "Session" string is treated as name of the column and interpreted as such. Of course Session=Session is always true. #cfe8bd 2278 code fixed 2007 Mar anonymous 2007 May 1 1 sqlite does not support mixed endian between pxa27x and i386 platforms working on an embedded project using arm pxa27x processor. This processor is "mixed-endian" (see: http://en.wikipedia.org/wiki/Endianness). The arm books say little-endian but thats only half the truth. The little endian part is true for 32 bit data types but not for 64 bit doubles. This is a probem I have encountered with OGR and GDAL as well. I have submitted fixes for those tools but unfortunately I will not have time to find a fix for sqlite. The problem really rears its head when creating the data on an arm machine and then reading it on an i386 machine. both sides think the data is little endian but the words are swapped for doubles. the fix for ogr and gdal was pretty simple which involved a runtime check to determine one of the many types of 64 bit endianess. Then, knowing this information, it could standardize how they wrote the data so that the data was correct across different platforms. email me at dorian.araneda@blackbirdtech.com if you have any questions. _2007-Mar-29 16:31:59 by drh:_ {linebreak} There is an assert() statement designed to detect this problem in the vdbeaux.c source file. Grep for 0x3ff00000 to find it. Suggestions for code to work around the mixed-endian floating point problem are welcomed. ---- _2007-Apr-02 19:08:37 by anonymous:_ {linebreak} solutions to gdal's libtiff tif_dirread.c and tif_dirwrite.c (where the doubles for locations were written) if the situation is mix-endian...this function, implemented in the code where a double would be written or read, would be called. #ifdef HAVE_IEEEFP void TIFFCvtIEEEFloatToNative(TIFF* a, uint32 b, float* c) { } void TIFFCvtIEEEDoubleToNative(TIFF* a, uint32 b, double* c) { unsigned int x; unsigned int* y; int i = 0; y = (unsigned int*)c; for(i = 0; i < b; i++) { x = *(y); *(y) = *(y+1); *(y+1) = x; y = y+2; } } #else extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32,double*); #endif in ogr's shpopen.c for shapefiles. I submitted this code that slightly modified thier original swapbytes function. the constructor I call "Endian = getEndian();" typedef enum { unknown = 0, littleLittle = 1, littleBig = 2, bigLittle = -1, bigBig = -2 } SwapStyle; //note: notice the signs on the enumeration. //This is so i can say -endian. Why you may ask would I want the //opposite endian? Well because the shapefile uses both endian //and opposite endian. why? I dont know but thats the way it is. //inspect the shpopen.c code to see where I had to say "-endian" static SwapStyle Endian; /************************************************************************/ /* SwapWord() */ /* */ /* Swap a 2, 4 or 8 byte word. */ /************************************************************************/ static SwapStyle getEndian() { SwapStyle x = littleLittle; double d = 0x00000000FFFFFFFF; if( *((uchar *) &d) == 0xFF ) x++; //doubles are big endian int i = 0x0000FFFF; if( *((uchar *) &i) == 0) x = -x; //words big endian //printf("endian format = %d\n", x); return x; } static void SwapWord( SwapStyle swapStyle, int length, void * wordP ) { int i; if(length < 8) { if(swapStyle == bigBig || swapStyle == bigLittle) { uchar temp; for( i=0; i < length/2; i++ ) { temp = ((uchar *) wordP)[i]; ((uchar *)wordP)[i] = ((uchar *) wordP)[length-i-1]; ((uchar *) wordP)[length-i-1] = temp; } }; }; if(length == 8) { if(swapStyle == bigBig || swapStyle == littleBig) { unsigned int temp; unsigned int* intWordP= (unsigned int*)wordP;; //for(i = 0; i < 2; i++) //{ temp = *(intWordP); *(intWordP) = *(intWordP+1); *(intWordP+1) = temp; // intWordP = intWordP+2; //} } } } I hope this helps. I am pressed for time at the moment with my project and have already implemented a work around (being, i change the data that i need to store so that it can be stored as longs). If i have time after the project is released..I may take a look at sqlite to see where it needs changed. ---- _2007-Apr-02 19:09:39 by anonymous:_ {linebreak} crap...the formatting got all screwed up. #f2dcdc 2207 new active 2007 Jan anonymous 2007 May 3 4 "CREATE TABLE foo AS SELECT * FROM bar" doesn't copy constraints (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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} How about a new feature: CREATE TABLE foo *WITH CONSTRAINTS* AS SELECT * FROM bar #f2dcdc 1924 new active 2006 Aug anonymous Parser 2007 May 2 3 optimize queries on unions, constant folding 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} You're not assuming that "right" could be a i64 value in this last patch... ---- _2006-Aug-19 13:41:14 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 #f2dcdc 1597 new active 2006 Jan anonymous Unknown 2007 May 1 3 wish: support DROP COLUMN 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:_ {linebreak} http://www.sqlite.org/faq.html#q13 ---- _2006-Oct-24 21:37:43 by anonymous:_ {linebreak} Hope to see this feature too... ---- _2006-Oct-24 21:44:53 by anonymous:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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? #f2dcdc 2813 build active 2007 Nov anonymous 2007 Nov 1 1 compile error on Windows CE 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! #cfe8bd 2811 code fixed 2007 Nov anonymous 2007 Nov 5 4 "appropriate" misspelled "approriate" on SQLite Documentation page In the description of the "Appropriate Uses For SQLite" document on the SQLite Documentation page at http://www.sqlite.org/docs.html, "appropriate" is misspelled "approriate". #f2dcdc 2810 code active 2007 Nov anonymous 2007 Nov 1 1 Unregistered collation problems with simple subselects 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| #f2dcdc 2809 code active 2007 Nov anonymous 2007 Nov 1 1 PRAGMA collation_list shows unregistered collations 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:_ {linebreak} 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. #f2dcdc 2808 doc active 2007 Nov anonymous 2007 Nov 4 2 Documentation GIF images take up too much space 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 ... #cfe8bd 2807 doc fixed 2007 Nov anonymous 2007 Nov 4 3 Link errors in Documentation There are link errors in these documentation files: *atomiccommit.html:*

    SQLite allows a single database connection to talk to two or more database files simultaneously through the use of the ATTACH DATABASE command. --- and step 3.10. --- During recovery at step 4.2 SQLite locates *lang_insert.html:* --- single keyword REPLACE as an #cfe8bd 2806 code fixed 2007 Nov anonymous 2007 Nov 3 4 Low memory assert in insertCell() The call to allocateSpace() at line 4511 of btree.c can fail, returning zero if the nested call to defragmentPage() fails to allocate its temp buffer. This then triggers the following assert. idx = allocateSpace(pPage, sz); assert( idx>0 ); For the older versions (ours is derived from 3.3.8) the solution is quite simple: idx = allocateSpace(pPage, sz); /* Check for memory allocation errors - pre v 3.5.0 */ if (sqlite3MallocFailed()) return SQLITE_NOMEM; assert( idx>0 ); For later versions you probably need something more like: if (idx == 0) return SQLITE_NOMEM; replacing the assert. This was found running test join-4.4 (from 3.3.8). _2007-Nov-28 15:47:39 by anonymous:_ {linebreak} Out of curiosity, which sqlite memory allocator are you using to find these low memory problems? The default malloc one, or the heap-in-an-array one? ---- _2007-Nov-28 17:03:19 by anonymous:_ {linebreak} Sorry, it's a proprietary allocator. But we do try to share the 'benefits'! #cfe8bd 2805 code fixed 2007 Nov anonymous 2007 Nov 1 1 Checkin [4573] Home grown recursive mutexes Checkin [4573] would only work on uniprocessors, not SMP hardware. You cannot implement recursive mutexes without some sort of memory barrier or atomic "test and set" instruction. The reason being the each SMP CPU has its own memory image that is not synchronized with main memory until there is a memory barrier or lock/spinlock. Take a look at NPTL or the previous incarnation, LinuxThreads, to see how difficult it is to implement a reliable and efficient recursive mutex on different CPU architectures. It simply can't be done without dropping into architecture-specific assembler. _2007-Nov-28 17:46:31 by anonymous:_ {linebreak} Solaris 2.6 was mentioned in the original homegrown recursive mutex implementation. Be aware that some Sparc machines offer cache coherency, while others do not. So it's a run-time hardware-specific thing, not an OS thing or a compile-time thing. Here is a fairly comprehensive list of cache coherency info (circa 2003) for various CPUs: http://linux.derkeiler.com/Mailing-Lists/Kernel/2003-09/3187.html #cfe8bd 2803 code fixed 2007 Nov anonymous 2007 Nov 4 3 test: io-4.2.2 fails on 64-bit --- signed extension io-4.2.2 expects *0xfffffff* but gets *0xffffffffffffffff* format 0x%X $res is this a 64-bit sign-extension quirk wrt to tcl? _2007-Nov-27 20:48:24 by anonymous:_ {linebreak} Suggested fix: --- a/test/io.test +++ b/test/io.test @@ -449,6 +449,7 @@ if {$::tcl_platform(platform)=="unix"} { set blob [read $fd 4] close $fd binary scan $blob i res + set res [expr $res & 0xFFFFFFFF] format 0x%X $res } {0xFFFFFFFF} } #cfe8bd 2801 code fixed 2007 Nov anonymous 2007 Nov 5 5 superfluous -lpthread for CLI in publish_osx.sh -lpthread not needed in publish_osx.sh: + CFLAGS="-Os -DSQLITE_ENABLE_FTS3=1 -DSQLITE_THREADSAFE=0" + NAME=sqlite3-$VERS-osx-x86.bin + echo '***** '"COMPILING $NAME..." + gcc $CFLAGS -Itsrc sqlite3.c tsrc/shell.c -o $NAME -ldl -lpthread #cfe8bd 2800 build fixed 2007 Nov anonymous 2007 Nov 5 5 -lpthread not needed for publish.sh for CLI binary -lpthread not needed by publish.sh for CLI binary since not threadsafe build. +CFLAGS="-Os -DSQLITE_ENABLE_FTS3=1 -DSQLITE_THREADSAFE=0" +echo '***** '"COMPILING sqlite3-$VERS.bin..." +gcc $CFLAGS -Itsrc sqlite3.c tsrc/shell.c -o sqlite3 -ldl -lpthread ldd ./sqlite3-3.5.3.bin linux-gate.so.1 => (0xb7f1d000) libdl.so.2 => /lib/libdl.so.2 (0xb7f05000) libpthread.so.0 => /lib/i686/libpthread.so.0 (0xb7ef2000) libc.so.6 => /lib/i686/libc.so.6 (0xb7dc5000) /lib/ld-linux.so.2 (0xb7f1e000) Unrelated - why are the shared libs and binary chmod'ed to be not executable? chmod 644 sqlite3-$VERS.bin.gz chmod 644 tclsqlite3.so chmod 644 sqlite3.so The webserver used by www.sqlite.org treats any file with execute permission as a CGI program and tries to run it. So we have to remove the execution permission bit from files which are intended to be served intact. ---- _2007-Nov-27 19:00:03 by anonymous:_ {linebreak} Instead of gzipping the files directly, can you wrap the individual files in a tar.gz instead? This way they could retain the executable permission. UNIX novices may not know about chmod. #cfe8bd 2799 build fixed 2007 Nov anonymous 2007 Nov 3 3 'configure ' cannot locate VERSION file 'configure' diff: 18437c18437 < ALLOWRELEASE="-release `cat VERSION`" --- > ALLOWRELEASE="-release `cat $srcdir/VERSION`" #c8c8c8 2798 build closed 2007 Nov anonymous 2007 Nov 3 4 Wrong nm used when cross-compiling When cross-compiling, the build platforms nm is used, instead of the one for the target platform. I included a patch for Makefile.in and configure.ac to start using the detected nm instead of the hardcoded 'nm'. _2007-Nov-27 14:53:06 by drh:_ {linebreak} The configure script is a mess and I am disinclined to make it a bigger mess by trying to fix cross-compilation. A better approch to cross-compiling is to use the amalgamation. Build the amalgamation using: make sqlite3.c Then compile sqlite3.c for your target system using whatever cross-compiler you want. #cfe8bd 2797 code fixed 2007 Nov anonymous 2007 Nov 3 3 Low memory SEGV in whereClauseClear() The function whereClauseClear() in where.c dereferences 'a' which may be null following an allocation error in whereClauseInsert(). It looks as if this allocation error will also result in leaking the old WhereTerm array addressed through pWC->a (if this was not static). The correction is probably to re-instate the old value on error before returning from whereClauseInsert(), ie to add the line: pWC->a = pOld; before the return 0. #cfe8bd 2796 code fixed 2007 Nov anonymous 2007 Nov 3 3 Another low memory SEGV in exprAnalyze() The first statement after declaring local variables in function exprAnalyze() in where.c is: if( db->mallocFailed ) return; Unfortunately initialising some of the local variables can already reference null pointers: WhereTerm *pTerm = &pWC->a[idxTerm]; ExprMaskSet *pMaskSet = pWC->pMaskSet; Expr *pExpr = pTerm->pExpr; If pWC->a is NULL the third of these initialisations causes problems. This happened here in the two calls: whereSplit(&sOr, pExpr, TK_OR); exprAnalyzeAll(pSrc, &sOr); from exprAnalyze(), early in the section beginning: /* Attempt to convert OR-connected terms into an IN operator so that ** they can make use of indices. Example: where the allocation in whereClauseInsert() (called by 5 depths of whereSplit()) failed while processing "SELECT y FROM t9\nWHERE x=(SELECT x FROM t9 WHERE y=1)\n OR x=(SELECT x FROM t9 WHERE y=2)\n OR x=(SELECT x FROM t9 WHERE y=3)\n OR x=(SELECT x FROM t9 WHERE y=4)\n OR x=(SELECT x FROM t9 WHERE y=5". The fix is to delay initialising the variables until after the check for mallocFailed. #cfe8bd 2795 code fixed 2007 Nov anonymous 2007 Nov 3 3 Low memory SEGV in exprAnalyze() Function exprAnalyze() in where.c includes the following code: /* Add constraints to reduce the search space on a LIKE or GLOB ** operator. ... pStr2 = sqlite3ExprDup(db, pStr1); if( pStr2 ){ assert( pStr2->token.dyn ); ++*(u8*)&pStr2->token.z[nPattern-1]; } A memory allocation error (in sqlite3StrNDup() called from sqlite3ExprDup()) can leave pStr2->token.z as NULL. Dereferencing this to increment an element brings a segment violation. sqlite3ExprDup() currently has no way of returning an error. #cfe8bd 2794 code fixed 2007 Nov anonymous 2007 Nov 3 3 Low memory SEGV in isLikeOrGlob() Function isLikeOrGlob() in where.c includes (towards the end of the function) the lines: sqlite3DequoteExpr(db, pRight); z = (char *)pRight->token.z; for(cnt=0; (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2]; cnt++){} A memory allocation error (in sqlite3StrNDup(0 called from sqlite3TokenCopy() called from sqlite3DequoteExpr()) can leave pRight->token.z as NULL. Dereferencing z in the for statement brings a segment violation. #f2dcdc 2793 code active 2007 Nov anonymous 2007 Nov 3 3 fts3 lacks scoping 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 #cfe8bd 2792 code fixed 2007 Nov anonymous 2007 Nov 3 3 invalidateCursorsOnModifiedBtrees has no scoping The function invalidateCursorsOnModifiedBtrees is not scoped ala #2554. It should presumably be SQLITE_PRIVATE. May I suggest this as part of the release/test process: gcc --pthread -DNDEBUG -DSQLITE_THREADSAFE -DEXPERIMENTAL -DSQLITE_API=static -DSQLITE_PRIVATE=static -DSQLITE_EXTERN=static -c sqlite3.c nm sqlite3.o | grep -v ' [trUbd] ' If there is any output from the nm/grep then those symbols have not been scoped. _2007-Nov-24 05:54:27 by anonymous:_ {linebreak} I agree it should be part of the release check. But I don't see EXPERIMENTAL #defined in the code anywhere. Also, --pthread does not work for gcc on Linux. $ gcc -DSQLITE_THREADSAFE -DSQLITE_API=static -DSQLITE_PRIVATE=static -DSQLITE_EXTERN=static -c sqlite3.c $ nm sqlite3.o | grep -v ' [trUbd] ' 0001d964 T invalidateCursorsOnModifiedBtrees ---- _2007-Nov-24 07:55:20 by anonymous:_ {linebreak} It should have been -pthread (one dash not two). And yes experimental should also be defined. ---- _2007-Nov-24 18:38:47 by anonymous:_ {linebreak} The macro EXPERIMENTAL is used by what exactly? ---- _2007-Nov-24 19:55:44 by anonymous:_ {linebreak} Several of the SQLite C APIs are marked as EXPERIMENTAL meaning that they could change between releases. This is noted on the documentation pages as appropriate. For example see http://sqlite.org/c3ref/commit_hook.html ---- _2007-Nov-24 22:27:15 by anonymous:_ {linebreak} These are just comments, not #ifdefs:

     $ grep EXPERIMENTAL sqlite3.[ch] sqlite3.c:****** EXPERIMENTAL - subject to change without notice ************** sqlite3.c:****** EXPERIMENTAL - subject to change without notice ************** sqlite3.c:****** EXPERIMENTAL - subject to change without notice ************** sqlite3.c:** This is an EXPERIMENTAL api and is subject to change or removal. sqlite3.c:** EXPERIMENTAL - This is not an official function.  The interface may sqlite3.c:/*** EXPERIMENTAL *** sqlite3.c:******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** sqlite3.c:****** EXPERIMENTAL - subject to change without notice ************** sqlite3.c:****** EXPERIMENTAL - subject to change without notice ************** 
    #f2dcdc 2791 code active 2007 Nov anonymous 2007 Nov 1 1 Allow building FTS[123] as part of sqlite library with configure See attached patch. #c8c8c8 2790 code closed 2007 Nov anonymous 2007 Nov danielk1977 2 2 sqlite3_compile returns NULL for empty statements There was apparently a backwards-incompatible behaviour change in 3.5 and later versions. sqlite3_compile() for an empty statement, like "" now returns a NULL pointer for the statement, but the function returns SQLITE_OK. In my applications I always assumed that if sqlite3_compile() returns SQLITE_OK, then there will be a valid statement. Now if you sqlite3_step() on the NULL pointer, you get a segfault. This has been fixed so that passing a NULL pointer to sqlite3_step() returns SQLITE_MISUSE, as it did for earlier versions. Strictly speaking, applications are not supposed to pass NULL to sqlite3_step(). See also #2773. #cfe8bd 2789 code fixed 2007 Nov anonymous 2007 Nov 3 3 Low memory double free from addWhereTerm The end of the function addWhereTerm() in select.c contains the following: pE = sqlite3ExprAnd(pParse->db,*ppExpr, pE); if( pE ){ *ppExpr = pE; } The function sqlite3Expr() called by sqlite3ExprAnd() deletes both Expr parameters if it fails to create its result Expr. Here the caller still has a pointer to the now freed Expr structure. In our system it currently gets deleted again later, in a call from clearSelect() called from sqlite3SelectDelete() resulting in double free errors. However, it is possible that this does not occur on current systems as ours is still based on version 3.3.8 (which still includes the bad (and no longer required) sqlite3ExprOrFree()). The problem looks as if it slipped in when sqlite3Expr() was changed to delete its parameters on error. The solution is to clear *ppExpr in this case, and this is most easily done by simply copying pE into it in all cases, even when NULL, ie make the line "*ppExpr = pE;" unconditional. #cfe8bd 2788 build fixed 2007 Nov anonymous 2007 Nov drh 3 3 FormatMessageA not defined for Windows Mobile Compiling SQLite 3.5.2 with embedded Visual C++ 4 produces the following link error: os_win.obj : error LNK2019: unresolved external symbol FormatMessageA referenced in function winDlError The only occurence of FormatMessageA is in os_win.c. Windows Mobile doesn't support ASCII, only wide characters. Since LoadLibrary isn't supported in winDlOpen on Windows Mobile, I suggest the following patch for winDlError: #if OS_WINCE if (nBuf > 0) zBufOut[0] = '\0'; #else FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, zBufOut, nBuf-1, 0 ); #endif Already fixed by check-in [4541]. #f2dcdc 2787 build active 2007 Nov anonymous 2007 Nov 4 5 sqlite3.pc is not remade 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} Could somebody who understands what the sqlite3.pc file is used for suggest a makefile rule for rebuilding it? #cfe8bd 2786 code fixed 2007 Nov anonymous 2007 Nov 4 4 sqlite3.pc does not mention -lpthread when used with --static flag I'm trying to statically link sqlite3 on Linux. I'm using pkg-config to get the settings. However, when I use "pkg-config sqlite3 --libs --static", it does not specify "-lpthreads", which is necesary. The fix I use is to add the following line to sqlite3.pc.in: Libs.private: -lpthread #cfe8bd 2785 doc fixed 2007 Nov anonymous 2007 Nov 3 3 Broken Anchors in C API Reference All of the links at the top of the page are linked to #link rather than the correct section within the documentation. http://www.sqlite.org/capi3ref.html Fixed by http://www.sqlite.org/docsrc/vinfo/32573eb907ac4faea29a91677a69cd667d198239 #cfe8bd 2784 code fixed 2007 Nov anonymous 2007 Nov 1 3 Low memory double free and SEGV from flattenSubquery() Low memory double free and SEGV from flattenSubquery() sqlite3SrcListAppend() in build.c can call sqlite3DbRealloc() which can fail under low-memory conditions. In this case it returns zero. It is called by flattenSubquery() in select.c in the section following: /* Move all of the FROM elements of the subquery into the ** the FROM clause of the outer query. Immediately (3 lines) after this call (after the loop) the return value is dereferenced in the start of the next loop: pSrc = sqlite3SrcListAppend(db, pSrc, 0, 0); } p->pSrc = pSrc; for(i=pSrc->nSrc-1; i-extra>=iFrom; i--){ I am also getting a 'double free' error during the cleanup in sqlite3SrcListAppend(), where the old (unextended) structure is freed by sqlite3SrcListDelete(). Apparently one of the pItem->zName strings has already been freed by the lines: sqlite3DeleteTable(pSubitem->pTab); sqlite3_free(pSubitem->zDatabase); sqlite3_free(pSubitem->zName); sqlite3_free(pSubitem->zAlias); immediately before the call in this section of flattenSubquery(). Clearing these pointers after freeing gets rid of the double free error. I can't offer a simple solution to the SEGV The SQL statement is "SELECT * FROM v10_11 LEFT JOIN t9 ON( a=x );" from the join-8.3 runtest. #cfe8bd 2783 doc fixed 2007 Nov anonymous 2007 Nov 5 4 Broken links into the website Hi, there are some broken links in the new website: Documentation -> SQL Syntax -> PRAGMA and http://www.sqlite.org/lang_droptable.html try to click on "CREATE TABLE" and "VACUUM". Fixed by http://www.sqlite.org/docsrc/vinfo/4f5adc7af26df28e61a1a5bacde935573394e7e2 #c8c8c8 2782 code closed 2007 Nov anonymous 2007 Nov 1 1 bind_text(...) into transaction In Transaction i insert some values, using sqlite3_bind_text(...) The first row has undef value(some times it's empty), but other rows have normal values. _2007-Nov-21 13:50:25 by drh:_ {linebreak} If you can describe some kind of problem with SQLite, we will be happy to look into the matter. Your description above sounds like a bug in your own code though. What about this problem makes you think it is a bug in SQLite? #cfe8bd 2781 doc fixed 2007 Nov anonymous 2007 Nov 5 4 Make documentation available offline (i.e. pdf, chm, etc) It would be nice if all of the documentation under "Documentation" was available offline in conjunction with the online format. The resulting pdf, chm, etc. could have the documentation segments merged or keep each segment separate. For example: SQL Syntax segment could be its own pdf or could be merged into a pdf with the c++ API Reference. Added a link to the {link: /download.html download page} containing the complete static text of this website. #cfe8bd 2780 build fixed 2007 Nov anonymous 2007 Nov 3 3 sqliteint.h: test to disable _XOPEN_SOURCE uses wrong macro for OSX sqliteint.h tests for __MACOS__ for whether to define _XOPEN_SOURCE on OSX. But this is not the correct macro (I think it's an old OS9 macro). __APPLE__would be a better choice. #c8c8c8 2779 code closed 2007 Nov anonymous 2007 Nov 2 2 Performance optimizations Performance optimizations )) PRAGMA: Does anyone have experience and good results optimizing sqlite performance using PRAGMA's? )) Other techniques: Any success stories on sqlite optimization methods of any type would be appreciated. Here is a list of the PRAGMA's and example use from the sqlite documentation: PRAGMA auto_vacuum; PRAGMA auto_vacuum = 0 | none | 1 | full | 2 | incremental; PRAGMA cache_size; PRAGMA cache_size = Number-of-pages; PRAGMA case_sensitive_like; PRAGMA case_sensitive_like = 0 | 1; PRAGMA count_changes; PRAGMA count_changes = 0 | 1; PRAGMA default_cache_size; PRAGMA default_cache_size = Number-of-pages; PRAGMA default_synchronous; PRAGMA empty_result_callbacks; PRAGMA empty_result_callbacks = 0 | 1; PRAGMA encoding; PRAGMA encoding = "UTF-8"; PRAGMA encoding = "UTF-16"; PRAGMA encoding = "UTF-16le"; PRAGMA encoding = "UTF-16be"; PRAGMA full_column_names; PRAGMA full_column_names = 0 | 1; PRAGMA fullfsync PRAGMA fullfsync = 0 | 1; PRAGMA incremental_vacuum(N); PRAGMA legacy_file_format; PRAGMA legacy_file_format = ON | OFF PRAGMA locking_mode; PRAGMA locking_mode = NORMAL | EXCLUSIVE PRAGMA main.locking_mode=EXCLUSIVE; PRAGMA page_size; PRAGMA page_size = bytes; PRAGMA max_page_count; PRAGMA max_page_count = N; PRAGMA read_uncommitted; PRAGMA read_uncommitted = 0 | 1; PRAGMA short_column_names; PRAGMA short_column_names = 0 | 1; PRAGMA synchronous; PRAGMA synchronous = FULL; (2) PRAGMA synchronous = NORMAL; (1) PRAGMA synchronous = OFF; (0) PRAGMA temp_store; PRAGMA temp_store = DEFAULT; (0) PRAGMA temp_store = FILE; (1) PRAGMA temp_store = MEMORY; (2) PRAGMA temp_store_directory; PRAGMA temp_store_directory = 'directory-name'; This is not a bug report. Ask any questions on the mailing list. #c8c8c8 2778 code closed 2007 Nov anonymous 2007 Nov adixon 1 1 Error 0 CREATE PROCEDURE Driver_Daily_Activity { @comp_code varchar(8), @begin_date datetime, @end_date datetime, @emp_short_name varchar(8), @emp_id int, @driver_time_in output, @driver_time_out output, @driver_beaktime_in output, @driver_beaktime_out output, @driver_lunchtime_in output, @driver_lunchtime_out output, @total_break_time output } AS select @driver_time_in =driver_datetime_in,@driver_time_out =driver_datetime_out from driver_daily_log with (nolock) where company_code=@comp_code and emp_id=@emp_id and driver_datetime_in >=@begin_date and driver_datetime_out<@end_date and driver_datetime_out is not null select @driver_breaktime_in=substring((CAST(break_time_in AS varchar(20))),12,8) ,@driver_breaktime_out=substring((CAST(break_time_out AS varchar(20))),12,8) from driver_daily_break_log with (nolock) where company_code=@comp_code and emp_id=@emp_id and driver_status='OB'. select @driver_lunchtime_in=substring((CAST(break_time_in AS varchar(20))),12,8) ,@driver_lunchtime_out=substring((CAST(break_time_out AS varchar(20))),12,8) from driver_daily_break_log with (nolock) where company_code=@comp_code and emp_id=@emp_id and driver_status='OL'. select @total_break_time =sum(total_break_time) from driver_daily_break_log with (nolock) where company_code=@comp_code and emp_id=@emp_id. This procedure is giving me the following error : SQL State 42000: Error 0 : Syntax error or access violation SQL identifiers may not contain the "@" character. #c8c8c8 2777 code closed 2007 Nov anonymous 2007 Nov shess 1 1 FTS[23] compile bug You need to #include "sqlite3.h" to pick up the sqlite3_malloc() declaration: ./ext/fts3/fts3_hash.c: In function "fts3HashMalloc": ./ext/fts3/fts3_hash.c:38: warning: initialization makes pointer from integer without a cast Also, can you move the following: #ifndef SQLITE_ENABLE_BROKEN_FTS2 #error fts2 has a design flaw and has been deprecated. #endif to be after this line: #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) in fts2.c? That way you can build fts3 while having fts2 objects in the Makefile without defining -DSQLITE_ENABLE_BROKEN_FTS2 for an fts3-only build. _2007-Nov-23 18:21:04 by anonymous:_ {linebreak} This error still exists in FTS2 and FTS3: ./ext/fts3/fts3_hash.c: In function "fts3HashMalloc": ./ext/fts3/fts3_hash.c:38: warning: initialization makes pointer from integer without a cast On some 64-bit systems this will cause FTS to crash because an int is smaller than a pointer. Nevermind - it was fixed. #f2dcdc 2776 warn active 2007 Nov anonymous 2007 Nov 5 1 mailing list sqlite-users-digest doesn't work. It remembers registered addresses but doesn't send any emails. #c8c8c8 2775 code closed 2007 Nov anonymous 2007 Nov danielk1977 3 4 Low-memory SEGV from sqlite3CodeRowTrigger() I have hit a low memory segment violation in sqlite3CodeRowTrigger() after /* code the WHEN clause */. sqlite3CodeRowTrigger() calls sqlite3ExprDup() which fails to deep copy the string p->pRight->token.z (and therefore everything thereafter). sqlite3CodeRowTrigger() continues to call sqlite3ExprResolveNames() sqlite3ExprResolveNames() calls walkExprTree() for the expression, which recursively calls walkExprTree() for pExpr->pRight which in turn calls nameResolverStep() which then tries to dereference pExpr->token.z[0] (for case TK_STRING) generating the SEGV. The solution appears to be checking for allocation failures before calling nameResolverStep(), using the same early exit as when this fails. ie replacing: if( sqlite3ExprResolveNames(&sNC, whenExpr) ){ with: if( pParse->db->mallocFailed || sqlite3ExprResolveNames(&sNC, whenExpr) ){ _2007-Nov-16 14:36:10 by anonymous:_ {linebreak} This change will also prevent an assertion if the previous allocation is the first to fail, or a SEGV if the following one is the first. --------- Thanks. #cfe8bd 2774 code fixed 2007 Nov shess 2007 Nov shess 1 1 Crash merging empty OR queries in fts3. create virtual table test using fts2(a); insert into test (a) values ('alpha'); insert into test (a) values ('beta'); select a from test where test match ('a:gamma* OR a:delta*'); sqlite3: ../sqlite/ext/fts3/fts3.c:478: dataBufferAppend: Assertion `nSource>0 && pSource!=((void *)0)' failed. "Workaround" is to compile with -DNDEBUG=1, but the person who reported this to me was using the fts2 dll from sqlite.org. Fix on the way. #c8c8c8 2773 code closed 2007 Nov danielk1977 2007 Nov 2 1 sqlite crashes in sqlite3_step when compiled with SQLITE_THREADS=1 When running the self-test of pysqlite2 [1], it crashes. This only happens when sqlite3 is compiled with the --enable-threads option, but not with --disable-threads. #0 0xbb987124 in sqlite3_step () from /usr/pkg/lib/libsqlite3.so.0 #1 0xbb9a7307 in _sqlite_step_with_busyhandler () from /usr/pkg/lib/python2.4/site-packages/pysqlite2/_sqlite.so #2 0xbb9a437b in pysqlite_cursor_executescript () from /usr/pkg/lib/python2.4/site-packages/pysqlite2/_sqlite.so #3 0xbbb45baa in PyCFunction_Call () from /usr/pkg/lib/libpython2.4.so.1.0 The reason for the crash is that v->db is NULL. In the non-threaded case, it all works. [1] Python is incorrectly passing NULL to sqlite3_step(). SQLite tests for this and returns SQLITE_MISUSE, but strictly speaking the behaviour in this case is unspecified. Have changed things so that SQLITE_MISUSE is returned whether the build is threadsafe or not. But this should also be fixed in Python. ---- _2007-Nov-23 13:24:36 by anonymous:_ {linebreak} This is now also fixed in pysqlite. #c8c8c8 2772 code closed 2007 Nov anonymous 2007 Nov danielk1977 3 3 Low memory assert in analyze Function sqlite3Analyze() in analyze.c includes the following two lines: ... z = sqlite3NameFromToken(db, pName1); pTab = sqlite3LocateTable(pParse, z, 0); ... In a low memory situation z can be returned as NULL.{linebreak} sqlite3LocateTable() calls sqlite3FindTable() which promptly asserts on: assert( zName!=0 ); I expect the solution is to conditionalise some of the code in sqlite3Analyze(): ... z = sqlite3NameFromToken(db, pName1); if (z){ pTab = sqlite3LocateTable(pParse, z, 0); sqlite3_free(z); if( pTab ){ analyzeTable(pParse, pTab); } } ... Thanks for the report. #f2dcdc 2771 code active 2007 Nov anonymous 2007 Nov 4 4 Lemon: Generated parser needs stdlib.h (not in default template) 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:_ {linebreak} Sorry, the needed header is =string.h=, not =stdlib.h= :-) #f2dcdc 2770 code active 2007 Nov anonymous 2007 Nov 1 1 Problem with BLOB in 3.5.x ? 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 .... #c8c8c8 2769 new closed 2007 Nov anonymous 2007 Nov danielk1977 3 3 Enable access to the sql string used to prepare a statement If would be nice if it was possible to get access to the sql string used to prepare a sqlite3_stmt*, if it was prepared using sqlite3_prepare_v2. In code terms this would probably mean a public wrapper around sqlite3VdbeGetSql. Possible uses are error messages and statement cache. #c8c8c8 2768 code closed 2007 Nov anonymous 2007 Nov danielk1977 3 3 asserts in wrong order If pC is not set, produce a nice assert error message instead of a segfault:
     diff -u -3 -p -r1.653 vdbe.c --- src/vdbe.c  23 Oct 2007 15:39:45 -0000      1.653 +++ src/vdbe.c  11 Nov 2007 19:38:11 -0000 @@ -2005,10 +2005,10 @@ case OP_Column: {    ** which is the number of records.    */    pC = p->apCsr[p1]; +  assert( pC!=0 );  #ifndef SQLITE_OMIT_VIRTUALTABLE    assert( pC->pVtabCursor==0 );  #endif -  assert( pC!=0 );    if( pC->pCursor!=0 ){      /* The record is stored in a B-Tree */      rc = sqlite3VdbeCursorMoveto(pC); 
    Ok. Thanks. #cfe8bd 2767 code fixed 2007 Nov anonymous 2007 Nov 2 1 UPDATE causes ./src/vdbe.c:503: sqlite3VdbeExec: Assertion `pTos<=&p-> This might be hard to pin down, but since I don't know the code base all that well I would put this out there in case someone else might understand this better or would be willing to help me track this bug down. With that said, here is what is going on: I get the following assertion error: ./src/vdbe.c:503: sqlite3VdbeExec: Assertion `pTos<=&p->aStack[pc]' failed. with the attached "script". _2007-Nov-11 07:41:40 by anonymous:_ {linebreak} Version 3.5.2 does not cause this to fail and runs as expected. ---- _2007-Nov-11 09:30:49 by drh:_ {linebreak} I beg to differ. I'm seeing the problem in 3.5.2 and in CVS head. I am able to reproduce the problem with the following test script: CREATE TABLE t1(x); CREATE TRIGGER r1 BEFORE UPDATE ON t1 BEGIN SELECT raise(ignore); END; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 SELECT x+2 FROM t1; INSERT INTO t1 SELECT x+4 FROM t1; UPDATE t1 SET x=x+1; The problem is that the code generator is generating VDBE code that fails to clear values from the VDBE stack. After a few iterations of the trigger, the VDBE stack overflows, triggering the assertion fault. It may be that the person posting the previous comment did not compile their version 3.5.2 with -DSQLITE_DEBUG. Hence assert() statements were disabled. The assert() statement is correct, however. This is a real problem. ---- _2007-Nov-11 13:01:54 by drh:_ {linebreak} It appears that operations such as UPDATE push a few values onto the stack prior to calling BEFORE triggers. Those values are normally consumed after the triggers run. But if a trigger runs RAISE(IGNORE) the later part of the processing is skipped and those values pushed on the stack are never consumed. Should be a relatively easy fix. Either defer pushing the extra values until after the BEFORE triggers run. Or else pass an extra parameter into sqlite3CodeRowTrigger() to tell it how many values to pop from the stack when a RAISE(IGNORE) is encountered. Preferably the first. I have long wanted to switch the VDBE from being a stack-based VM to being a register based VM. Notice that were the VDBE register based, this bug would have never come up.... ---- _2007-Nov-11 20:24:35 by anonymous:_ {linebreak} Thank you for the amazingly fast turn around. (Yes, I forgot to compile 3.5.2 with -DSQLITE_DEBUG.) #f2dcdc 2766 code active 2007 Nov drh 2007 Nov 1 1 TCL transaction started from within a query does not commit 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.... #c8c8c8 2765 code closed 2007 Nov anonymous 2007 Nov 1 3 bad rollback if temporary table created during transaction Hi, trying to resolve a test failure in an application using pysqlite2 (2.3.5) / sqlite 3.42 for its test suite, I've been able to produce a minimal script which shows that the problem is actually in sqlite... I don't think it comes from the python wrapper (if you think it is tell me and I'll redirect it to the appropriate tracker). Anyway here is the script : import pysqlite2.dbapi2 as sqlite cnx = sqlite.connect('testdb') cursor = cnx.cursor() cursor.execute('SELECT eid from Trinfo') nb = len(cursor.fetchall()) cursor.execute("INSERT INTO Trinfo ( from_state, to_state, wf_info_for, eid, creation_date, modification_date ) VALUES ( 734, 735, 5, 758, 1, 1)") # comment this line and the final assertion is ok cursor.execute("CREATE TEMPORARY TABLE T58d712f777a7170cb8ce7d94cef119ce (C0 integer,C1 timestamp);") # get the same result with or without dropping the temp table #cursor.execute('DROP TABLE T58d712f777a7170cb8ce7d94cef119ce') cnx.rollback() cursor.execute('SELECT eid from Trinfo') nb3 = len(cursor.fetchall()) assert nb3 == nb # FAIL Notice that if you don't create the temporary table, everything run fine, else the insertion is not actually rollbacked. _2007-Nov-09 00:23:38 by drh:_ {linebreak} I tested using the following TCL script: file delete -force test.db test.db-journal sqlite3 db test.db db eval { CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3); INSERT INTO t1 VALUES(4,5,6); INSERT INTO t1 SELECT a*2, b*2, c*2 FROM t1; INSERT INTO t1 SELECT a*4, b*4, c*4 FROM t1; INSERT INTO t1 SELECT a*8, b*8, c*8 FROM t1; } puts "begin=[md5 [db eval {SELECT * FROM t1}]]" db eval {BEGIN} db eval {INSERT INTO t1 VALUES('hello','out','there');} db eval {CREATE TEMPORARY TABLE T58d712f777(C0 integer,C1 timestamp)} puts " mid=[md5 [db eval {SELECT * FROM t1}]]" db eval {ROLLBACK} puts " end=[md5 [db eval {SELECT * FROM t1}]]" The results are: begin=c17bc52be49269f8f2cd3a4df3caee6e mid=f86cc8ad5b925962323edc041bfaa09d end=c17bc52be49269f8f2cd3a4df3caee6e Begin and end are equal so it appears to work using the TCL interface. I also observe that there are countless tests in the SQLite test suite that verify that this sort of thing works correctly. Perhaps this is something to do with python after all. ---- _2007-Nov-11 20:48:52 by anonymous:_ {linebreak} See: http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html#controlling-transactions #c8c8c8 2764 todo closed 2007 Nov anonymous 2007 Nov 2 2 Since I installed Leopard I keep getting sqlite3 data bases in trash Every night I seem to have a bunch of database folders in my trash with sqlite doc inside. I can't seem to delete them all even after quitting my applications. (I realize this is a developer's page, but this is a real annoyance and I have no idea what to do about it!) Thanks, Liz _2007-Nov-08 02:50:51 by drh:_ {linebreak} I am told by engineers at Apple that this is an issue with Leopard and that it has nothing to do with SQLite. Apple is working on the problem and will fix it. #f2dcdc 2763 build active 2007 Nov anonymous 2007 Nov 4 4 AIX build failure due to explicit _XOPEN_SOURCE definition 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. #cfe8bd 2762 code fixed 2007 Nov anonymous 2007 Nov 3 3 fts3 is cavalier about malloc vs sqlite3_malloc The fts3 code (and, from a brief look, the fts2 and fts1 also) are inconsistent with the memory upcalls they use; in some cases they use malloc/realloc/free/calloc(..., 1), and in some they use the sqlite3_ equivalents. I have a patch that makes them use only the sqlite3_ equivalents, but was there a specific reason they were written without originally? And another problem: trying to build fts3_hash.c gives warnings about unknown parameters for sqlite3_malloc (used from fts3HashMalloc) because it never finds sqlite3.h from anywhere. On at least one 64-bit Solaris platform this has caused a segfault on execution, because the compiler guess for return type (int) was 32 bits, whereas the pointer it was trying to return was 64 bits. _2007-Nov-20 03:41:52 by anonymous:_ {linebreak} Indeed, I also have segfaults with FTS3 memory allocation with a 64bit build on OSX 10.5. It works fine on a 32bit build on OS X 10.5. This is the thread trace: Thread 0 Crashed: 0 libSystem.B.dylib 0x00007fffffe00637 __bzero + 55 1 org.sqlite.sqlite3 0x0000000100051fc3 fts3HashMalloc + 46 2 org.sqlite.sqlite3 0x0000000100052465 sqlite3Fts3HashInsert + 316 3 org.sqlite.sqlite3 0x000000010004bb0e sqlite3Fts3Init + 126 4 org.sqlite.sqlite3 0x000000010002537c openDatabase + 808 5 sqlite3 0x000000010000115c open_db + 37 6 sqlite3 0x0000000100003af9 process_input + 938 7 sqlite3 0x00000001000043a8 main + 1696 8 sqlite3 0x000000010000099c start + 52 I didn't try the idea of changing malloc & friends to sqlite equivalents. ---- _2007-Nov-20 03:56:07 by anonymous:_ {linebreak} All calls should use the new sqlite3_ alloc/free calls instead of malloc/free. Because fts is not a part of the sqlite core, this code receives less attention. Also, Makefile.in should be updated so that fts2 and fts3 can build out of the box on all architectures without requiring them loaded as external modules. ---- _2007-Nov-23 18:00:39 by anonymous:_ {linebreak} Those patches seem to work on OSX 10.5 64bit. No compile errors. No run errors in a simple test. I don't build with TclTk (no 64bit tcl on OSX anyways), so I can't run the full tests. #f2dcdc 2760 new active 2007 Nov anonymous 2007 Nov 5 4 request: sqlite3_unlink() to delete db files. 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. :) #c8c8c8 2759 code closed 2007 Nov anonymous 2007 Nov danielk1977 1 2 crash due to 'select * from virtualTable where x is null' For virtual table T1: select * from t1 where y is NULL; causes: 1301 assert( pTerm->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_MATCH) ); (gdb) bt #0 0x005e17a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #1 0x006217d5 in raise () from /lib/tls/libc.so.6 #2 0x00623149 in abort () from /lib/tls/libc.so.6 #3 0x0061adb1 in __assert_fail () from /lib/tls/libc.so.6 #4 0x00849534 in bestVirtualIndex (pParse=0xbfe2d750, pWC=0xbfe2d1d0, pSrc=0x9a23d2c, notReady=18446744073709551615, pOrderBy=0x0, orderByUsable=1, ppIdxInfo=0x9a372bc) at ../../../../Source/sqlite-3.5.1-hp/src/where.c:1301 #5 0x0084a989 in sqlite3WhereBegin (pParse=0xbfe2d750, pTabList=0x9a23d28, pWhere=0x9a28ed8, ppOrderBy=0xbfe2d59c) at ../../../../Source/sqlite-3.5.1-hp/src/where.c:2074 #6 0x0082c6c6 in sqlite3Select (pParse=0xbfe2d750, p=0x9a28f28, eDest=4, iParm=0, pParent=0x0, parentTab=0, pParentAgg=0x0, aff=0x0) at ../../../../Source/sqlite-3.5.1-hp/src/select.c:3118 #7 0x0081f16c in yy_reduce (yypParser=0x9a33aa8, yyruleno=104) at parse.y:368 #8 0x00820f65 in sqlite3Parser (yyp=0x9a33aa8, yymajor=1, yyminor= {z = 0x9a2e120 ";", dyn = 0, n = 1}, pParse=0xbfe2d750) at parse.c:3419 #9 0x0082e877 in sqlite3RunParser (pParse=0xbfe2d750, zSql=0x9a2e100 "select * from t1 where y is NULL;", pzErrMsg=0xbfe2d74c) at ../../../../Source/sqlite-3.5.1-hp/src/tokenize.c:449 #10 0x008246a0 in sqlite3Prepare (db=0x9920010, zSql=0x9a2e100 "select * from t1 where y is NULL;", nBytes=-1, saveSqlFlag=0, ppStmt=0xbfe2d8e0, pzTail=0xbfe2d8e4) at ../../../../Source/sqlite-3.5.1-hp/src/prepare.c:525 #11 0x00824a2c in sqlite3LockAndPrepare (db=0x9920010, zSql=0x9a2e100 "select * from t1 where y is NULL;", nBytes=-1, saveSqlFlag=0, ppStmt=0xbfe2d8e0, pzTail=0xbfe2d8e4) at ../../../../Source/sqlite-3.5.1-hp/src/prepare.c:604 #12 0x00824bf9 in sqlite3_prepare (db=0x9920010, zSql=0x9a2e100 "select * from t1 where y is NULL;", nBytes=-1, ppStmt=0xbfe2d8e0, pzTail=0xbfe2d8e4) at ../../../../Source/sqlite-3.5.1-hp/src/prepare.c:658 #13 0x0084d862 in sqlite3_exec (db=0x9920010, zSql=0x9a2e100 "select * from t1 where y is NULL;", xCallback=0x8049b23 , pArg=0xbfe2da20, pzErrMsg=0xbfe2d9ac) at ../../../../Source/sqlite-3.5.1-hp/src/legacy.c:56 #14 0x0804d2e9 in process_input (p=0xbfe2da20, in=0x0) at ../../../../Source/sqlite-3.5.1-hp/src/shell.c:1663 #15 0x0804de80 in main (argc=5, argv=0xbfe2efd4) at ../../../../Source/sqlite-3.5.1-hp/src/shell.c:2001 Fails to accommodate WO_ISNULL flag. _2007-Nov-05 05:13:22 by danielk1977:_ {linebreak} Thanks for the report. #c8c8c8 2757 doc closed 2007 Nov anonymous 2007 Nov 1 1 Special characters handling in SQLite Like Query If I have data as follows, they wont show up when I try to search for them. [[[ ]]] `~!@#$%^&* ()_+|{}:<>? -=\[];',./ @@@ %%% ### ^^^ ___--- Ho_mer `~!@#$%^&*()_+|`{}:<>?-=\[];,./ _Storage-Room @ # $ _ - + % ^ & asdf_qwerty As all the data contains special charcters ,I am replacing them with SearchS = Trim(SearchS) SearchS = Replace(SearchS, "'", "''") SearchS = Replace(SearchS, "[", "[[]") SearchS = Replace(SearchS, "%", "[%]") SearchS = Replace(SearchS, "^", "[^]") SearchS = Replace(SearchS, "#", "[#]") SearchS = Replace(SearchS, "_", "[_]") My SQL Query looks like this select * from table_name where name LIKE '%" & SearchS & "%' eg . If I am trying to search for '%%%' my query will be select * from table_name where name LIKE '% [%][%][%]%' Which is returning zero results. so how should I replace special characters for SQlite. Thanks _2007-Nov-03 00:11:35 by drh:_ {linebreak} The description appears to be a question on the proper way to use SQL, not a bug report. Please use tickets for reporting bugs only. For help with using SQLite, send a message the the SQLite mailing list. #f2dcdc 2756 new active 2007 Nov anonymous 2007 Nov 1 1 allow vacuum to change pragma setting instead of using existing ones 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) #f2dcdc 2755 code active 2007 Nov anonymous 2007 Nov 3 3 trace interfere with transaction Tcl interface 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 #f2dcdc 2753 code active 2007 Nov anonymous 2007 Nov drh 3 3 Master journal files sometimes not deleted 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 && inDb; 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:_ {linebreak} 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... #c8c8c8 2752 code closed 2007 Nov anonymous 2007 Nov 5 5 redundant assignment? In unixLock() struct lockInfo *pLock = pFile->pLock; and later in the function pLock = pFile->pLock; _2007-Nov-01 05:56:16 by danielk1977:_ {linebreak} The second assignment is required as the value of pFile->pLock might be changed within the call to transferOwnership() above the second assignment. In non-threadsafe builds (where transferOwnership is a no-op) it is redundant, but it's not hurting anybody. #c8c8c8 2751 build closed 2007 Oct anonymous 2007 Nov 2 3 Regression - Solaris/sparc throws BUS ERROR on count()/sum()/etc. A regression has crept into sqlite 3.5 (both 3.5.0 and 3.5.1) running on Solaris/sparc when built with GCC (both 3.4.2 and 4.2.2 tested) which leads to a BUS ERROR when simple count()/sum() queries are run. A workaround is to build with Solaris CC. Example session: # ./sqlite3 SQLite version 3.5.1 Enter ".help" for instructions sqlite> create table foo(a); sqlite> insert into foo values(1); sqlite> select count(a) from foo; Bus error (core dumped) _2007-Oct-31 18:19:12 by danielk1977:_ {linebreak} Can you check that applying this clears the problem? Thanks. diff -u -r1.110 vdbeapi.c --- src/vdbeapi.c 17 Oct 2007 01:44:21 -0000 1.110 +++ src/vdbeapi.c 31 Oct 2007 18:15:44 -0000 @@ -446,7 +446,7 @@ pMem->flags = MEM_Agg; pMem->xDel = sqlite3_free; pMem->u.pDef = p->pFunc; - if( nByte<=NBFS ){ + if( nByte<=NBFS && 0 ){ pMem->z = pMem->zShort; memset(pMem->z, 0, nByte); }else{ ---- _2007-Nov-02 09:06:57 by anonymous:_ {linebreak} I can confirm that your patch prevents the crash. Thank you. ---- _2007-Nov-05 05:51:35 by anonymous:_ {linebreak} Do you attribute this error to be a compiler bug or a problem in SQLite? ---- _2007-Nov-05 06:20:42 by danielk1977:_ {linebreak} Sorry, I missed your post on November 2. I think it's an alignment problem. Without the patch, sqlite3_aggregate_context() is returning a pointer to a pre-allocated buffer. The problem is (I suspect) that the start of this buffer is not aligned to an 8-byte boundary as required by your architecture. So I figure an SQLite bug, not a compiler problem. Will fix shortly. ---- _2007-Nov-05 14:41:25 by anonymous:_ {linebreak} Perhaps zShort should be moved after a double in the struct for alignment?
     diff -u -3 -p -r1.130 vdbeInt.h --- src/vdbeInt.h       28 Aug 2007 23:28:08 -0000      1.130 +++ src/vdbeInt.h       5 Nov 2007 14:39:04 -0000 @@ -123,6 +123,7 @@ struct Mem {      FuncDef *pDef;      /* Used only when flags==MEM_Agg */    } u;    double r;           /* Real value */ +  char zShort[NBFS];  /* Space for short strings */    sqlite3 *db;        /* The associated database connection */    char *z;            /* String or BLOB value */    int n;              /* Number of characters in string value, including '\0' */ @@ -130,7 +131,6 @@ struct Mem {    u8  type;           /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */    u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */    void (*xDel)(void *);  /* If not null, call this function to delete Mem.z */ -  char zShort[NBFS];  /* Space for short strings */  };  typedef struct Mem Mem;  
    #c8c8c8 2747 code closed 2007 Oct anonymous 2007 Nov maria.khomenko 1 1 How to use Composite Key in Sqlite How to use Composite Key in Sqlite Tickets are for reporting bugs. Please ask general questions such as this on the SQLite mailing list. ---- _2007-Nov-01 11:34:53 by anonymous:_ {linebreak} but kindly Maria Give me the Way how can i use ---- _2007-Nov-02 07:15:59 by anonymous:_ {linebreak} How and where Can i do that ---- _2007-Nov-02 07:18:06 by anonymous:_ {linebreak} If you have some Articles regarding that mail me at rizwan_aman007@yahoo.co.in ---- _2007-Nov-05 05:39:22 by anonymous:_ {linebreak} I did't get any resolution. plz help me ---- _2007-Nov-08 12:07:18 by anonymous:_ {linebreak} ` #c8c8c8 2744 code closed 2007 Oct drh 2007 Nov danielk1977 1 1 Cannot quote collating sequence name The following statement gives an error: CREATE TABLE demo(x TEXT COLLATE "binary"); It is using the quote characters as part of the name. The quotes ought to be removed before searching for the collating sequence. #cfe8bd 2687 code fixed 2007 Oct anonymous 2007 Nov 3 2 Building with _UNICODE fails in Win32 (3.5.1) The function winDlError uses the unadorned function FormatMessage() which gets turned into FormatMessageW() in a Unicode build. Because the output buffer is a char*, it needs to be specified as FormatMessageA() to avoid the compile time error.
     static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){   FormatMessageA(     FORMAT_MESSAGE_FROM_SYSTEM,     NULL,     GetLastError(),     0,     zBufOut,     nBuf-1,     0   ); } 
    Note that if the output message is supposed to be in UTF-8 then extra processing needs to be added to this function to convert the message into that character encoding. _2007-Oct-04 03:59:59 by anonymous:_ {linebreak} In summary:
     -    FormatMessage( +    FormatMessageA( 
    ---- _2007-Nov-12 18:37:43 by anonymous:_ {linebreak} Please reopen this ticket: Windows Mobile / CE does not necessarily provide the ANSI version FormatMessageA(). This was observed with the arm-wince-mingw32ce GCC cross compiler. Maybe the following replacement could be added to os_win.c #ifdef UNDER_CE int FormatMessageA(int dwFlags, void *lpSource, int dwMessageId, int dwLangId, char *lpBuffer, int nSize, va_list *args){ if( dwFlags & 256 ){ char *buf = (char *)LocalAlloc(64, 126); *(char **)lpBuffer = buf; if( dwMessageId > 0x7FFFFFF ){ sprintf(buf, "OsError 0x%x", dwMessageId, dwMessageId); }else{ sprintf(buf, "OsError %d", dwMessageId); } return strlen(buf); } if( dwMessageId > 0x7FFFFFF ){ sprintf((char *)lpBuffer, "OsError 0x%x", dwMessageId); }else{ sprintf((char *)lpBuffer, "OsError %d", dwMessageId); } return strlen((char *)lpBuffer); } #endif #f2dcdc 2417 new active 2007 Jun anonymous 2007 Nov drh 3 3 Idea for read write concurrency. 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:_ {linebreak} 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. #f2dcdc 2223 code active 2007 Feb scouten 2007 Nov 3 3 pragma auto_vacuum doesn't survive .dump & reconstitute 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:_ {linebreak} We wonder if other pragmas are also not being propogated. ---- _2007-Feb-08 18:53:42 by anonymous:_ {linebreak} No pragmas are output from .dump. SQLite should have a .dump_with_pragmas command or equivalent. ---- _2007-Nov-27 02:11:05 by anonymous:_ {linebreak} 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. #c8c8c8 1813 new closed 2006 May anonymous 2007 Nov 2 3 select distinct doesn't take advantage of existing indexes Simple testcase, execute to reproduce the problem: create table test(archive integer, host text, priority integer); create index test_idxA on test(archive, host, priority); -- This uses test_idxA explain query plan select distinct archive, host from test order by archive, host; -- But This doesn't explain query plan select distinct archive, host from test; -- Nor does this explain query plan select distinct archive, host, priority from test; -- Let's try and change things a bit... drop index test_idxA; create index test_idxB on test(archive, host); -- This still doesn't use test_idxB explain query plan select distinct archive, host from test; _2007-Nov-12 07:52:50 by anonymous:_ {linebreak} Fixed by this patch to sqlite 3.5.2: http://marc.info/?l=sqlite-users&m=119483059920564&w=2 ---- _2007-Nov-12 16:21:36 by anonymous:_ {linebreak} Fixed in Check-in [4538] #c8c8c8 1779 new closed 2006 Apr anonymous 2007 Nov 5 4 enhancement request (+ pointer) -- group_concat() aggregate function Any thoughts as to incorporating the group_concat() function patch as at http://pugs.blogs.com/pugs/2006/01/more_random_rec.html ? :) Thanks... _2006-Apr-22 00:12:21 by anonymous:_ {linebreak} http://perlcabal.org/~autrijus/tmp/sqlite3-src-func.c.diff Why would anyone favor this function over using GROUP BY? This function does not even support numeric ordering correctly. It treats all numeric sub-keys as strings. ---- _2006-Jun-16 22:36:16 by anonymous:_ {linebreak} Err, wait, GROUP_CONCAT is meant to be used with GROUP BY, not as a replacement. See http://db4free.blogspot.com/2006/01/hail-to-groupconcat.html and http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html Audrey ---- _2007-Nov-01 20:51:53 by anonymous:_ {linebreak} Fixed by Check-in [4519] for future 3.5.2 version. Not enabled by default. #f2dcdc 285 build active 2003 Apr anonymous Unknown 2007 Nov 2 2 Configure doesn't honour LDFLAGS during build 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 #c8c8c8 2750 code closed 2007 Oct anonymous 2007 Oct 2 1 for the new.somefield value returns the old value of it For the update trigger on a table containing n columns when retrieving the new value of filed the value of which was not changed at update (so the new value is null)it returns its old value. _2007-Oct-31 18:21:32 by danielk1977:_ {linebreak} That's how it's documented to work. #f2dcdc 2749 warn active 2007 Oct anonymous 2007 Oct 3 4 SQLITE_OMIT_FLOATING_POINT, int constants too large 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. #f2dcdc 2748 warn active 2007 Oct anonymous 2007 Oct 4 4 amalgamation: SQLITE_OMIT_ALTERTABLE warnings 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. #c8c8c8 2746 code closed 2007 Oct anonymous 2007 Oct 1 1 PRIMARY KEY does not treat NULL as unique The below inserts 2 records. One record would be expected. CREATE TABLE test(Colour VARCHAR COLLATE NOCASE,SubType VARCHAR COLLATE NOCASE,weight DOUBLE, PRIMARY KEY (Colour,SubType)); BEGIN TRANSACTION; INSERT OR REPLACE INTO test VALUES('red', NULL, 100); INSERT OR REPLACE INTO test VALUES('red', NULL, 100); COMMIT I understand that the NULL behaviour is hazy but this seems to not agree with the doc where it says: "nulls are distinct in a UNIQUE column". _2007-Oct-28 23:35:17 by drh:_ {linebreak} "nulls are distinct" means that every NULL is considered to be different from every other NULL. Hence, if two rows contain only NULL values, they are considered UNIQUE because they are not equal to one another. #c8c8c8 2745 code closed 2007 Oct anonymous 2007 Oct shazow 1 1 Sharing File between two processes Sharing File between two processes #c8c8c8 2743 doc closed 2007 Oct anonymous 2007 Oct 1 1 Comparison of SQLite against McObject Fusion Can you please provide a comparison of SQLite against McObhect Fusion. Thanks. _2007-Oct-24 11:07:16 by drh:_ {linebreak} I've never heard of McObject Fusion before. #c8c8c8 2742 code closed 2007 Oct anonymous 2007 Oct 1 1 codeInteger and codeReal In the latest CVS I noticed that codeInteger and codeReal ignores the argument `n'. static void codeReal(Vdbe *v, const char *z, int n, int negateFlag){ assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed ); if( z ){ double value; char *zV; sqlite3AtoF(z, &value); //***** can this accidentally go beyond n bytes? if( negateFlag ) value = -value; zV = dup8bytes(v, (char*)&value); sqlite3VdbeOp3(v, OP_Real, 0, 0, zV, P3_REAL); } } I was under the impression that both sqlite3AtoF and sqlite3Atoi64 required null terminated strings. Is `z' guaranteed to be null terminated in all cases? Could a random byte follow the number string buffer that happens to be a digit and cause the parsed number to be incorrect? So at best you could drop the 'n' arg from codeReal and codeInteger, at worst, you'd have to take n bytes into consideration for the sqlite3Ato* functions or less desirable - allocate a buffer and copy the string to it and nil terminate it prior to calling the sqlite3Ato* functions. _2007-Oct-23 19:23:24 by anonymous:_ {linebreak} You forgot to assert z[n] is not '.', 'e', and 'E' for codeReal. I'm not comfortable with this not-a-valid-number-character assumption, but am too lazy to look for a counter example that might break it. If you're confident that the z[n] byte always exists and reading that byte in sqlite3Ato* will not segfault or cause valgrind to complain, why not do this instead: char zn = z[n]; z[n] = 0; ... do sqlite3Ato* stuff z[n] = zn; It's fast, guaranteed to be safe and is more resiliant in the face of future possibly incompatible code changes in the parser. ---- _2007-Oct-23 19:26:05 by anonymous:_ {linebreak} As you well know, the assert only works in debug mode, not in production. The debug runs pad memory allocations at the end with a byte or two, do they not? ---- _2007-Oct-23 19:52:10 by anonymous:_ {linebreak} The saving/restoring z[n] hack above won't work if the original parse string on which the tokens are based is stored in read-only memory or if the original string is being parsed simultaneously in 2 or more threads. But if the original parse string is guaranteed to be copied before parsing begins, then sure, it could work. ---- _2007-Oct-23 21:15:15 by drh:_ {linebreak} The code is correct as written. If you think otherwise, show me a counter-example. Could the code benefit from be refactored to be cleaner. Probably so. But that would require hundreds of lines of carefully optimized code to be redesigned and rewritten. I have more important fish to fry right now and so I am not going to waste several days modifying code that works. It is what it is. Either show me a case where it fails or else learn to live with it. #cfe8bd 2741 code fixed 2007 Oct anonymous 2007 Oct 3 3 _XOPEN_SOURCE may be necessary for pread/pwrite as well as threads In 3.5.1, _XOPEN_SOURCE is only defined if sqlite is configured to be thread-safe. However, this definition may also be necessary to make prototypes visible for pread, pwrite, fdatasync, and usleep, all of which are conditionally used by os_unix.c. This is only a major problem for pread and pwrite, both of which take arguments that may be 64 bits wide and require a special calling convention on systems with 32-bit "long". _2007-Oct-23 01:09:32 by anonymous:_ {linebreak} But what value should it be set to in order to be portable across all POSIX machines? ---- _2007-Oct-23 14:52:57 by anonymous:_ {linebreak} _XOPEN_SOURCE is so ill defined and poorly implemented, the user should add -D_XOPEN_SOURCE=whatever to their own makefile's compile flags if they need 64 bit pread/pwrite support. ---- _2007-Oct-23 16:01:32 by drh:_ {linebreak} I have added comments to the code to warn about this situtation. But in accordance with the suggestions on ticket #2681, we do not want to define _OPEN_SOURCE by default. #cfe8bd 2740 code fixed 2007 Oct anonymous 2007 Oct 4 4 incorrect assertions in vdbe.c /sqlite/src/vdbe.c contains two assertions of the form assert( SQLITE_MAX_SQL_LENGTH < SQLITE_MAX_LENGTH ); as part of the implementations of the =OP_String8= and =OP_HexBlob= opcodes. This assertion is wrong, because the default definition of =SQLITE_MAX_SQL_LENGTH= is equal to =SQLITE_MAX_LENGTH=. It should be assert( SQLITE_MAX_SQL_LENGTH <= SQLITE_MAX_LENGTH ); #cfe8bd 2739 code fixed 2007 Oct anonymous 2007 Oct 2 3 large-file enable macros should be defined before first #include Currently (3.4.2 and it appears 3.5.1 as well) /sqlite/src/os_unix.c tries to enable support for large files by defining =_LARGEFILE_SOURCE= and/or =_FILE_OFFSET_BITS=64=. Unfortunately, it does this after including sqliteInt.h and os.h, which include several system headers, which means that on some platforms the macros have no effect. Contrast the behavior of these two test files: =testA.c= #define _FILE_OFFSET_BITS 64 #include #include =testB.c= #include #define _FILE_OFFSET_BITS 64 #include When preprocessed, =testA.c= defines a 64-bit =off_t=, =testB.c= doesn't: $ gcc -E testA.c | grep -E 'typedef .* (__)?off(64)?_t;' __extension__ typedef long int __off_t; __extension__ typedef __quad_t __off64_t; typedef __off64_t off_t; $ gcc -E testB.c | grep -E 'typedef .* (__)?off(64)?_t;' __extension__ typedef long int __off_t; __extension__ typedef __quad_t __off64_t; typedef __off_t off_t; this on powerpc-linux (GNU libc 2.6.1). In general the standards (POSIX, SUS) specify that "feature test" macros are only effective if defined before the very first C-library header is included. #cfe8bd 2738 code fixed 2007 Oct anonymous 2007 Oct 2 2 vfsUnlink breaks when building with OS_OTHER=1 I'm building with OS_OTHER=1 defined. That means there is no default vfs implemented. When I register my first vfs, sqlite3_vfs_register() calls vfsUnlink(). As a result of the OS_OTHER=1 define, vfsList is NULL. This causes a NULL pointer to be dereferenced. Note that I believe the same problem would happen if I were to unregister all my vfs nodes for some reason, then register a new one. From vfsUnlink(): if( vfsList==pVfs ){ vfsList = pVfs->pNext; }else{ sqlite3_vfs *p = vfsList; while( p->pNext && p->pNext!=pVfs ){ p = p->pNext; } if( p->pNext==pVfs ){ p->pNext = pVfs->pNext; } } I believe "}else{" should be "}else if ( vfsList != NULL ){" _2007-Oct-22 20:53:13 by anonymous:_ {linebreak} On a related note, sqlite3_vfs_unregister() asserts that vfsList is non-NULL before exiting. If built with OS_OTHER=1, it may be possible that a client such as myself unregisters all the vfs objects at some point, before registering a new one. (This should not be a problem if no new databases are opened while no vfs objects are registered.) It seems that the assert should only be used if OS_OTHER is not defined. #cfe8bd 2737 code fixed 2007 Oct anonymous 2007 Oct 4 4 save 35 bytes in VACUUM with new 2 argument substr()
     Index: src/vacuum.c =================================================================== RCS file: /sqlite/sqlite/src/vacuum.c,v retrieving revision 1.73 diff -u -3 -p -r1.73 vacuum.c --- src/vacuum.c        29 Aug 2007 12:31:28 -0000      1.73 +++ src/vacuum.c        20 Oct 2007 17:32:10 -0000 @@ -136,18 +136,18 @@ int sqlite3RunVacuum(char **pzErrMsg, sq    ** in the temporary database.    */    rc = execExecSql(db, -      "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14,100000000) " -      "  FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" -      "   AND rootpage>0" +      "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) " +      "FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence' " +      "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 %' "); +      "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14) " +      "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 %'"); +      "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) " +      "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 
    #f2dcdc 2736 build active 2007 Oct anonymous 2007 Oct 2 2 build problems on freebsd 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:_ {linebreak} I forgot to mention this is with the TEA version #c8c8c8 2735 code closed 2007 Oct anonymous 2007 Oct nmadhav 3 1 Error : Unrecognized Token Hi, I am trying to Create a table in the sqlite DB. The table name is 9I0_STATIC_101607 and I get an error Unrecognized token : 9I0_STATIC_101607 But if I create a table with name STATIC_9I0_101607, my code works fine. It is something to do with the table name starting with number. Is there any kind of restriction with table name starting with a digit?? Thanks for your help. Regards, Mayura. _2007-Oct-17 17:07:43 by drh:_ {linebreak} This is not a bug report. This is a support request. Please see http://www.sqlite.org/support.html for information on how to receive support for SQLite. Please use these ticketing system to report bugs only. Thanks. #c8c8c8 2734 code closed 2007 Oct anonymous 2007 Oct 3 1 2 bug under the wince
     the test version is 3.5.1  thank you! 1. in os_win.c line:1165     /*     samsting_xie change the last line: zFilename to zName.     the zFilename is not declared, so i change it to zName,     maybe it's write error? the old last line is:    && !winceCreateLock(zFilename, pFile)     */ 2. in os_win.c line:1341   return SQLITE_OK;   /*   samsting_xie add the last line: return SQLITE_OK;   if OS_WINCE defined 1, then this function is not return value.   it's maybe return a unknown value.   */ 
    Duplicate. See, for example, #2718, #2711, #2710, #2702, #2700, #2683. #cfe8bd 2733 code fixed 2007 Oct anonymous 2007 Oct 1 1 OP_Real and OP_Int64 inefficient for constants Let's say I have a table with 50 million rows: CREATE TABLE t1(a real); If I perform a query like: select -3.14159265 * a from t1; then the string "-3.14159265" will be converted to a double 50 million times via OP_Real -> sqlite3VdbeRealValue -> sqlite3AtoF. explain select -3.14 * a from t1; ... 5|Real|0|0|-3.14 -- converts string to double each loop pass! 6|Column|0|0|# t1.a 7|RealAffinity|0|0| 8|Multiply|0|0| 9|Callback|1|0| 10|Next|0|5| ... This is actually quite computationally expensive and unnecessary. If OP_Real and OP_Int64 would store the double/int64 values into P1/P2 at expression parse time then they would not have to be reparsed to a double/int64 each pass in the loop at vdbe runtime. _2007-Oct-18 03:37:47 by anonymous:_ {linebreak} Proof of concept patch: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg28390.html http://marc.info/?l=sqlite-users&m=119266402408308&q=p3 #cfe8bd 2732 code fixed 2007 Oct anonymous 2007 Oct 2 2 sqlite3Step crashes if called with a null argument (easy fix) With the reorganisation of the code in 3.5 to use a memory manager accessed via the db structure, sqlite3Step in vdbeapi.c can now cause an access violation if called with a null Vdbe structure. Unfortunately pysqlite quite often calls this routine with a null statement and so can crash if you execute an empty query. The obvious fix is to move the two marked lines below the null check. static int sqlite3Step(Vdbe *p){ sqlite3 *db; int rc; /* Assert that malloc() has not failed */ -> db = p->db; -> assert( !db->mallocFailed ); if( p==0 || p->magic!=VDBE_MAGIC_RUN ){ return SQLITE_MISUSE; } _2007-Oct-17 01:38:03 by drh:_ {linebreak} This is really a bug in pysqlite. Have you filed a bug report there? ---- _2007-Oct-17 22:47:06 by anonymous:_ {linebreak} Just filed a bug there. I had to verify a few things first. In hindsight, the check for a null statement should perhaps be made in sqlite3_step rather than sqlite3Step. That would be more useful, as it appears to be the case that the mutex check causes an exception (I built the version I first observed this in without mutexes, and then fixed the bug in my copy of pysqlite) #c8c8c8 2731 code closed 2007 Oct anonymous 2007 Oct 1 1 sqlite3ExprCode TK_UMINUS inefficient with large negative floats The follow change in expr.c makes my program (which deals with large negative floating point numbers) run 14 times faster. 14 seconds originally to just 1 second after this patch. Assuming the fix is correct, can you please apply it? make test runs with 0 errors with this. Thanks.
     Index: src/expr.c =================================================================== RCS file: /sqlite/sqlite/src/expr.c,v retrieving revision 1.313 diff -u -3 -p -r1.313 expr.c --- src/expr.c  18 Sep 2007 15:55:07 -0000      1.313 +++ src/expr.c  16 Oct 2007 23:54:17 -0000 @@ -1879,7 +1879,10 @@ void sqlite3ExprCode(Parse *pParse, Expr        assert( pLeft );        if( pLeft->op==TK_FLOAT || pLeft->op==TK_INTEGER ){          Token *p = &pLeft->token; -        char *z = sqlite3MPrintf(pParse->db, "-%.*s", p->n, p->z); +        char *z = sqlite3_malloc(p->n+2); +        z[0] = '-'; +        memcpy(z+1, p->z, p->n); +        z[p->n+1] = 0;          if( pLeft->op==TK_FLOAT ){            sqlite3VdbeOp3(v, OP_Real, 0, 0, z, p->n+1);          }else{ 
    _2007-Oct-17 01:34:39 by drh:_ {linebreak} FWIW, the patch is not correct. It does not work if sqlite3_malloc fails and returns a NULL pointer. But it isn't too hard to fix. I'm curious, though, what kind of program you are running where this makes a 14x speed improvement. One wonders if you couldn't do 100x faster using sqlite3_bind_double() instead. We could go through and make patches like this one all over the place, in order to make this or that special case run a little faster. But that would make the library footprint larger. The sqlite3MPrintf() call in this context is there for reasons of space efficiency, not CPU time. Some years ago, we when through this huge effort to reduce the footprint of the library by replacing the expanded string construction code like you are inserting with instances of sqlite3MPrintf(). I am reluctant to undo that effort for a single special case that could probably be handled more efficiently using sqlite3_bind_double(). ---- _2007-Oct-17 02:21:17 by anonymous:_ {linebreak} I have a script to generate ASCII SQL statements which I use in conjunction with the sqlite3 shell and MySQL to populate huge tables. I use the multi-insert patch on the mailing list for tables that hold millions of rows of negative numbers, with anywhere from 3 to 20 columns. http://www.mail-archive.com/sqlite-users%40sqlite.org/msg28337.html INSERT INTO BIGTABLE VALUES (-334712687065.09, -334712687065.12, -334712687065.13), (-334712687065.09, -334712687065.12, -334712687065.13), ... 10 thousand rows ... (-334712687065.09, -334712687065.12, -334712687065.13), (-334712687065.09, -334712687065.12, -334712687065.13); With the mulit-insert patch and the patch in this ticket, it is 25% faster for inserting than using the equivalent INSERT commands within a transaction: BEGIN INSERT INTO BIGTABLE VALUES(-334712687065.09, -334712687065.12, -334712687065.13); ... 10 thousand rows ... INSERT INTO BIGTABLE VALUES(-334712687065.09, -334712687065.12, -334712687065.13); COMMIT; I have to have no more than 10,000 rows per insert because it blows the stack due to sqlite3Select -> multiSelect recursion. I had to bump a few other sqliteLimits as well to get more than a few thousand rows at a time. I suppose the replacement of the sqlite3MPrintf could be useful in other scenarios as well. ---- _2007-Oct-17 02:27:30 by anonymous:_ {linebreak} The bind double approach is not 100X faster, by the way. It's only around 1.3X faster than the individual ASCII inserts in my tests. But it doesn't matter for my purposes, because it's not MySQL compatible anyway. ---- _2007-Oct-17 03:04:11 by anonymous:_ {linebreak} If the string were not pre-prepended with a '-' char, but instead parsed into a double, and the double simply negated it would be much faster and avoid a needless memory allocation/deallocation. To facilitate this, OP_Real would have to be changed or a new OP code created to accommodate an 8 byte double argument - possibly via straddling P1 and P2. ---- _2007-Oct-23 16:00:39 by anonymous:_ {linebreak} Fixed by Check-in [4507] #c8c8c8 2730 code closed 2007 Oct anonymous 2007 Oct anonymous 3 2 Can't compile for WindowsCE There is a compilation bug in os_win.c line 1165 (then compile for WindowsCE) "sqlite3.5_\os_win.c(1165) : error C2065: 'zFilename' : undeclared identifier" the code #if OS_WINCE if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) == (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB) && !winceCreateLock(zFilename, pFile) seems to be #if OS_WINCE if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) == (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB) && !winceCreateLock(zName, pFile) Best regards, Yuri Noyanov Duplicate of #2648, #2700, #2702, and #2718. #f2dcdc 2729 doc active 2007 Oct anonymous 2007 Oct 1 1 Lemon: %fallback, %wildcard, and @X uncodumented 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? #f2dcdc 2728 code active 2007 Oct anonymous 2007 Oct 4 4 Some indexes could contain pointers not the data 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:_ {linebreak} 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:_ {linebreak} 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´s the best that you could do to solve your problem. ---- _2007-Oct-18 06:07:58 by anonymous:_ {linebreak} 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). #f2dcdc 2727 build active 2007 Oct anonymous 2007 Oct 4 4 building with -malign-double causes strange behavior 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:{linebreak} 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:{linebreak} ==15323== Use of uninitialised value of size 4{linebreak} ==15323== at 0x80585B7: insertElement (sqlite3.c:13072){linebreak} ==15323== by 0x807366E: sqlite3HashInsert (sqlite3.c:13290){linebreak} ==15323== by 0x809FE72: unixOpen (sqlite3.c:15403){linebreak} ==15323== by 0x80579A7: sqlite3OsOpen (sqlite3.c:8210){linebreak} ==15323== by 0x806B12F: sqlite3BtreeFactory (sqlite3.c:21317){linebreak} ==15323== by 0x80767BA: openDatabase (sqlite3.c:71237){linebreak} ==15323== by 0x8076BD1: sqlite3_open (sqlite3.c:71337){linebreak} ==15323== by 0x804BEAE: db_init (dbmgr.c:81){linebreak} ==15323== by 0x804CE64: main (main.c:59){linebreak} 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:_ {linebreak} This is a compiler issue. -malign-double creates problems for most programs. What are you trying to accomplish? #c8c8c8 2726 code closed 2007 Oct anonymous 2007 Oct 4 3 solaris 10 compilation B_FALSE, B_TRUE clash from sys/types.h % make{linebreak} 386-pc-solaris2.10-gcc -O3 -pipe -o lemon ./tool/lemon.c{linebreak} ./tool/lemon.c:111: error: redeclaration of enumerator ‘B_FALSE’{linebreak} /usr/include/sys/types.h:176: error: previous definition of ‘B_FALSE’ was here{linebreak} ./tool/lemon.c:111: error: redeclaration of enumerator ‘B_TRUE’{linebreak} /usr/include/sys/types.h:176: error: previous definition of ‘B_TRUE’ was here{linebreak} make: *** [lemon] Error 1{linebreak} % sed -e 176\!d /usr/include/sys/types.h{linebreak} typedef enum { B_FALSE, B_TRUE } boolean_t;{linebreak} % sed -e 111\!d tool/lemon.c{linebreak} typedef enum {B_FALSE=0, B_TRUE} Boolean;{linebreak} even when the enum is only set when it is not yet defined, I guess this results in conflicts in the code because Boolean may not equal boolean_t. I suggest to rename B_FALSE and B_TRUE to something which makes it unique for the sqlite case. Duplicate of #2583 #f2dcdc 2725 code active 2007 Oct anonymous 2007 Oct 1 1 memory leak in sqlite3_open_v2() when it fails 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:_ {linebreak} 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. #c8c8c8 2723 new closed 2007 Oct anonymous 2007 Oct anonymous 5 4 After execution of SQL, the Data Returned should display the col.name Hi! After executing a SQL command, the program shows the results as a table with columns. The first row ist allways grey but empty. Couldn't the program display the selected entities (or their declared AS-alias) as column headers in the result table? Yours sincerely M. Heinrich, München _2007-Oct-12 18:19:38 by drh:_ {linebreak} Do you mean in the CLI? Just type .header on And the headers will appear. #cfe8bd 2722 code fixed 2007 Oct anonymous 2007 Oct 1 1 data mis-alignment in UTF16 collation callback arguments We're using a Unicode build of SQLite, and found that internally, the 'NOCASE' collation was not Unicode aware -- it would convert any wide strings to UTF-8 when needed, and compare those. For performance, we would like to implement a WNOCASE for wide strings. However, upon implementing this, we found that the pointers passed to our collation function are not wide character (short-) aligned. On our platform we receive data mis-alignment errors when comparing the strings. We have already implemented similiar sqlite wide string functions (WLIKE, WCONTAINS), and we never receive mis-aligned strings there (are those guaranteed to be aligned); it would be helpful if this restriction could be applied to collation callbacks. #c8c8c8 2720 code closed 2007 Oct anonymous 2007 Oct 1 1 WinCE - Can't write Application which was working correctly with one of the last sqlite 3.3.16 fails on 3.5.1 to write anything to the database - no create tables and no inserts if the db existed beforehand. It seems to happen always, with either UTF-8 or UTF-16 encoding. _2007-Oct-11 07:26:49 by anonymous:_ {linebreak} I meant, "...one of the last 3.3.x (I think 3.3.16)..." ---- _2007-Oct-11 12:20:13 by drh:_ {linebreak} The developers have no ability to compile or run on winCE, much less any ability to debug on winCE. All winCE support is community provided. There have been many patches to the winCE code since 3.5.1 was released. The writer of this ticket previously reported two other problems that have already been fixed. Several other problems have also been fixed since 3.5.1. We are guessing that this "Can't write" problem will probably go away if the writer will simply get the latest code out of CVS. If not, then there is nothing really we can do about it unless we have patches to fix the problem. #c8c8c8 2719 code closed 2007 Oct anonymous 2007 Oct 3 1 WinCE winFullPathName doesn't return a value #if OS_WINCE /* WinCE has no concept of a relative pathname, or so I am told. */ sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative);
    #endif Duplicate of #2702 #c8c8c8 2718 build closed 2007 Oct anonymous 2007 Oct 2 1 WinCE compile error On function winOpen
     #if OS_WINCE   if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) ==                (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)        && !winceCreateLock(zFilename, pFile)   ){     CloseHandle(h);     free(zConverted);     return SQLITE_CANTOPEN;   }   if( dwFlagsAndAttributes & FILE_FLAG_DELETE_ON_CLOSE ){     pFile->zDeleteOnClose = zConverted;   }else #endif 
    That zFilename of the winceCreateLock call doesn't exist. I guess it should be zName instead Duplicate of #2700 #f2dcdc 2716 new active 2007 Oct anonymous 2007 Oct 5 1 Create Clear Command 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:_ {linebreak} How about a cookie instead? ---- _2007-Oct-30 08:02:04 by anonymous:_ {linebreak} 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). #f2dcdc 2715 code active 2007 Oct anonymous 2007 Oct 1 1 no authorization needed to remove authorizer 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:_ {linebreak} I'm assuming that this feature request comes from {quote: 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:_ {linebreak} 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. #f2dcdc 2714 code active 2007 Oct anonymous 2007 Oct drh 3 4 Shell cannot import large files greater than 2 GB [patch] 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 2713 build fixed 2007 Oct anonymous 2007 Oct 1 5 build fails for 3.5.1 on win32/cygwin - duplicate opcode labels Problem: build fails on compiling vdbe.c => src/vdbe.c: In function `sqlite3VdbeExec': src/vdbe.c:1136: error: duplicate case value src/vdbe.c:921: error: previously used here src/vdbe.c:1655: error: duplicate case value src/vdbe.c:900: error: previously used here ... Seems like my generated opcodes.h has lots of duplicates: #define OP_Multiply 80 /* same as TK_STAR */ #define OP_Pull 80 #define OP_Dup 71 #define OP_Lt 71 /* same as TK_LT */ I'm running on XP with a c:\cygwin library available. NB. i'm not a regular SQLLite user and was just trying the library out of curiosity so if no one else reports this then don't sweat it... it may be down to my environment screwing up the build process. _2007-Oct-09 17:15:24 by drh:_ {linebreak} Why don't you try compiling the {link: /cvstrac/wiki?p=TheAmalgamation amalgamation} instead? ---- _2007-Oct-09 18:06:22 by anonymous:_ {linebreak} Original poster - just run "make clean" and try again. ---- (OP) OK. tracked it down to the initialisation of the tk array in mkopcodeh.awk which is getting strings like "22 " (not sure if this is a space or a CR). the following patch fixes it for me: --- mkopcodeh.awk-orig 2007-03-29 19:39:30.000000000 +0100 +++ mkopcodeh.awk 2007-10-12 15:14:46.980260800 +0100 @@ -41,7 +41,9 @@ # Remember the TK_ values from the parse.h file /^#define TK_/ { - tk[$2] = $3 + num = $3 + num += 0 # convert "22 " -> 22 + tk[$2] = num } # Scan for "case OP_aaaa:" lines in the vdbe.c file ie. ensure that the keys are numeric. With this patch, the build completes ok. Thanks. ---- _2007-Oct-12 20:08:41 by anonymous:_ {linebreak} It's not an AWK bug in Cygwin. The only way to convert strings to numbers in AWK is to add zero. Cygwin uses the same version of GNU gawk as Linux. It's the exact same code. ---- _2007-Oct-12 20:43:55 by drh:_ {linebreak} Seems like if it were exactly the same code it would work exactly the same. But clearly it does not. I don't know what is going on. Probably some strange DOS \r line ending problems. Presumably the change has fixed the problem. #c8c8c8 2712 code closed 2007 Oct anonymous 2007 Oct 5 4 Expose a function to change the journal filename location Being able to change the pager journal filename using a nice function ie: sqlite3PagerSetJournal it maybe the following prototype: int sqlite3PagerSetJournal(sqlite3* db, const char *zJournal); It is intended to maximize disk IOs by splitting IO concerning the journal and the IO concerning the main DB storage. Typically we dedicate a specific disk channel for the journal, which may be a RAM disk like iRAM from Gigabyte, or a SATA2 disk with 16MB cache dedicated, or using a RAID controller with 256MB RAM with Backup Unit. The main DB storage resides on a different channel on SAS disks configured as RAID10. Separating journal and main data file is typically a feature available in common SQL servers : MySQL, MSSQL, ... _2007-Oct-09 15:38:50 by drh:_ {linebreak} Changing the name of the rollback journal and especially moving it to a different volume can lead to database corruption following a power failure. See http://www.sqlite.org/ac/atomiccommit.html for additional information. #cfe8bd 2711 code fixed 2007 Oct anonymous 2007 Oct 1 1 WinCE: flags incorrectly checked One last fix for WinCE: checkin 4479 is correct in the omission of certain flags for WinCE, but the flags are still being checked for later on in winOpen:
     if( dwFlagsAndAttributes & FILE_FLAG_DELETE_ON_CLOSE ){   pFile->zDeleteOnClose = zConverted; }else ... 
    Since that flag is no longer set, it needs to read:
     if( flags & (SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL) ){   pFile->zDeleteOnClose = zConverted; }else ... 
    Finally, on WinCE, since FILE_FLAG_RANDOM_ACCESS is always set, it doesn't make sense to set FILE_FLAG_SEQUENTIAL_SCAN (for journals). At least on CE, it hampered performance in our tests. #cfe8bd 2710 code fixed 2007 Oct anonymous 2007 Oct 1 1 Typo in code specific to WinCE (checkin 4479) Checkin [4479] introduces a typo in code specific to WiNCE, returning SQLTIE_OK instead of SQLITE_OK _2007-Oct-09 15:21:50 by anonymous:_ {linebreak} Also, checkin 4479 is correct in the omission of certain flags for WinCE, but the flags are still being checked for later on in winOpen: if( dwFlagsAndAttributes & FILE_FLAG_DELETE_ON_CLOSE ){ pFile->zDeleteOnClose = zConverted; }else ... Since that flag is no longer set, it needs to read: if( flags & (SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL) ){ pFile->zDeleteOnClose = zConverted; }else ... #c8c8c8 2709 code closed 2007 Oct anonymous 2007 Oct 2 3 Some SQLITE_OMIT_* keys break the sqlite3.c amalgamation compilation I found that SQLITE_OMIT_TRIGGER, SQLITE_OMIT_REINDEX and SQLITE_OMIT_ALTERTABLE keys break the compilation, when defined.{linebreak} Following patch solved this problem for me.{linebreak} {linebreak} sqlite-amalgamation-3_5_1.define.patch{linebreak} ----------------------------------
     --- ./sqlite3.c.orig Wed Oct  3 18:08:44 2007 +++ ./sqlite3.c Tue Oct  9 14:52:09 2007 @@ -53246,6 +53266,7 @@    /* Run the BEFORE and INSTEAD OF triggers, if there are any    */    endOfLoop = sqlite3VdbeMakeLabel(v); +#ifndef SQLITE_OMIT_TRIGGER    if( triggers_exist & TRIGGER_BEFORE ){       /* build the NEW.* reference row.  Note that if there is an INTEGER @@ -53309,6 +53330,7 @@        goto insert_cleanup;      }    } +#endif     /* If any triggers exists, the opening of tables and indices is deferred    ** until now. @@ -62064,6 +62086,7 @@      sqlite3VdbeAddOp(v, OP_MemInt, 0, memCnt);    }  +#ifndef SQLITE_OMIT_TRIGGER    if( triggers_exist ){      /* Create pseudo-tables for NEW and OLD      */ @@ -62129,6 +62152,7 @@        goto update_cleanup;      }    } +#endif     if( !isView && !IsVirtual(pTab) ){      /* @@ -67517,10 +67541,12 @@      case 214:  {sqlite3IdListDelete((yypminor->yy432));}        break; +#ifndef SQLITE_OMIT_TRIGGER      case 231:      case 236:  {sqlite3DeleteTriggerStep((yypminor->yy243));}        break; +#endif      case 233:  {sqlite3IdListDelete((yypminor->yy370).b);}        break; @@ -68378,11 +68404,13 @@    sqlite3DropTable(pParse, yymsp[0].minor.yy373, 0, yymsp[-1].minor.yy46);  }          break; +#ifndef SQLITE_OMIT_VIEW        case 102:  {    sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy410, &yymsp[-2].minor.yy410, yymsp[0].minor.yy219, yymsp[-6].minor.yy46, yymsp[-4].minor.yy46);  }          break; +#endif        case 103:  {    sqlite3DropTable(pParse, yymsp[0].minor.yy373, 1, yymsp[-1].minor.yy46); @@ -68921,6 +68949,7 @@        case 250:  {sqlite3Pragma(pParse,&yymsp[-1].minor.yy410,&yymsp[0].minor.yy410,0,0);}          break; +#ifndef SQLITE_OMIT_TRIGGER        case 258:  {    Token all; @@ -68935,6 +68964,7 @@    yygotominor.yy410 = (yymsp[-6].minor.yy410.n==0?yymsp[-7].minor.yy410:yymsp[-6].minor.yy410);  }          break; +#endif        case 260:        case 263:  { yygotominor.yy46 = TK_BEFORE; } @@ -68972,6 +69002,7 @@        case 272:  { yygotominor.yy243 = 0; }          break; +#ifndef SQLITE_OMIT_TRIGGER        case 273:  { yygotominor.yy243 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-3].minor.yy410, yymsp[-1].minor.yy174, yymsp[0].minor.yy172, yymsp[-4].minor.yy46); }          break; @@ -68987,6 +69018,7 @@        case 277:  {yygotominor.yy243 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy219); }          break; +#endif        case 278:  {    yygotominor.yy172 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); @@ -69011,11 +69043,13 @@        case 282:  {yygotominor.yy46 = OE_Fail;}          break; +#ifndef SQLITE_OMIT_TRIGGER        case 283:  {    sqlite3DropTrigger(pParse,yymsp[0].minor.yy373,yymsp[-1].minor.yy46);  }          break; +#endif        case 284:  {    sqlite3Attach(pParse, yymsp[-3].minor.yy172, yymsp[-1].minor.yy172, yymsp[0].minor.yy386); @@ -69032,19 +69066,22 @@        case 287:  { yygotominor.yy386 = yymsp[0].minor.yy172; }          break; +#ifndef SQLITE_OMIT_REINDEX        case 290:  {sqlite3Reindex(pParse, 0, 0);}          break;        case 291:  {sqlite3Reindex(pParse, &yymsp[-1].minor.yy410, &yymsp[0].minor.yy410);}          break; +#endif        case 292:  {sqlite3Analyze(pParse, 0, 0);}          break;        case 293:  {sqlite3Analyze(pParse, &yymsp[-1].minor.yy410, &yymsp[0].minor.yy410);}          break; -      case 294: +#ifndef SQLITE_OMIT_ALTERTABLE +   case 294:  {    sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy373,&yymsp[0].minor.yy410);  } @@ -69059,6 +69096,7 @@    sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy373);  }          break; +#endif        case 299:  {sqlite3VtabFinishParse(pParse,0);}          break; 
    ---------------------------------- Thank you! _2007-Oct-09 13:22:03 by anonymous:_ {linebreak} This is because parse.c has to be regenerated from parse.y. Then, with an altered Makefile with the appropriate options, you have to run "make clean && make sqlite3.c". Could Lemon be altered to emit the %if/%ifndef/%else/%endif's as their C preprocessor equivalents instead of just not generating the if'd out parse code? This way the amalgamation could work with all OMITs. ---- _2007-Oct-09 15:13:49 by drh:_ {linebreak} Changing Lemon to generate "universal" code that works with any combination of OMIT macros is not practical. Any change to the grammer rules typically results in massiver reorganization of the parser tables. If you want to use OMIT macros, then you need to compile from the canonical source code - not the amalgamation. ---- _2007-Oct-10 15:30:31 by anonymous:_ {linebreak} I had a issue like that in previous sqlite 3.1x versions, which I want to omit alter table statement but need to generate a parser from lemon, but makefile did not supported it. there´s a way to configure --d(omit something) to omit some features of sqlite ? I know there are few on it, but not all are supported on sqlite configure script #f2dcdc 2708 code active 2007 Oct anonymous 2007 Oct 4 2 SQL error:disk I/O error 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:_ {linebreak} 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? #c8c8c8 2707 code closed 2007 Oct anonymous 2007 Oct appledev 1 3 SQLite on Mac OS X seems to have a 4GB database limit This is on Mac OX 10.4 using Apple's Core Data: I run into a strange error, always when I try to save a managed- object-context and the file-size is already at the 4GB limit: An error saving the context: NSError "An error occurred while saving." Domain=NSCocoaError Domain Code=134030 UserInfo={NSUnderlyingException = disk I/O error; } _2007-Oct-09 05:12:47 by anonymous:_ Why do you think it is SQLite error ?? ---- _2007-Oct-09 06:52:50 by danielk1977:_ {linebreak} What kind of file system are you using for the database? I used the attached script to create a 5.5 GB database on HFS+, then checked it using the integrity check and everything seemed Ok. If it's not a simple file-system limitation, is is possible for you to post some code that demonstrates the issue? Thanks. ---- _2007-Oct-12 18:46:31 by drh:_ {linebreak} Unable to reproduce. Submitter does not respond. #c8c8c8 2706 warn closed 2007 Oct anonymous 2007 Oct danielk1977 4 4 make test aborts when built with SQLITE_OMIT_ATTACH testfixture aborts during make test when it is compiled with -DSQLITE_OMIT_ATTACH=1
     attach-4.5... Error: no such table: db2.t3 ./testfixture: near "DETACH": syntax error     while executing "db eval {   DETACH db2; }"     ("uplevel" body line 1)     invoked from within "uplevel [list $db eval $sql]"     (procedure "execsql" line 3)     invoked from within "execsql {   DETACH db2; }"     (file "./test/attach.test" line 505)     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 
    #f2dcdc 2705 code active 2007 Oct anonymous 2007 Oct 4 4 testfixture unresolved externals with SQLITE_OMIT_GET_TABLE 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 
    #f2dcdc 2704 code active 2007 Oct anonymous 2007 Oct 4 4 "make test" aborts before completion with SQLITE_OMIT_BLOB_LITERAL 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 
    #f2dcdc 2703 code active 2007 Oct anonymous 2007 Oct 3 4 make test does not work with SQLITE_OMIT_FLOATING_POINT 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) 
    #cfe8bd 2702 code fixed 2007 Oct anonymous 2007 Oct 1 1 Errors in CreateFileW function use on WinCE CreateFileW function in WindowsCE uses only subspace of flags of desktop windows' version and reports errors, when passed flag that can't be dispatched. For 3.5.1 this means that any attempt to open/create temporary file on WCE fails.{linebreak} Also there is bad argument name passed in winOpen to winceCreateLock.{linebreak} Also, there is 'return' missing in winFullPathname when building for WCE, so any attempt to open file fails. Here is the patch solving all(for me) filesystem errors on WindowsCE.
     sqlite-amalgamation-3_5_1.ce.patch ---------------------------------- --- ./sqlite3.c.orig Wed Oct  3 18:08:44 2007 +++ ./sqlite3.c Mon Oct  8 17:04:16 2007 @@ -18730,17 +18730,24 @@    }    if( flags & (SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_TEMP_JOURNAL                      | SQLITE_OPEN_SUBJOURNAL) ){ +#if OS_WINCE +    dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN; +#else      dwFlagsAndAttributes = FILE_ATTRIBUTE_TEMPORARY                                 | FILE_ATTRIBUTE_HIDDEN                                 | FILE_FLAG_DELETE_ON_CLOSE; +#endif    }else{      dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;    }    if( flags & (SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_TEMP_DB)){      dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS; -  }else{ +  } +#if !OS_WINCE +  else{      dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;    } +#endif    if( isNT() ){      h = CreateFileW((WCHAR*)zConverted,         dwDesiredAccess, @@ -18786,7 +18793,7 @@  #if OS_WINCE    if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) ==                 (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB) -       && !winceCreateLock(zFilename, pFile) +       && !winceCreateLock(zName, pFile)    ){      CloseHandle(h);      free(zConverted); @@ -18957,6 +18964,7 @@  #if OS_WINCE    /* WinCE has no concept of a relative pathname, or so I am told. */    sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative); +  return SQLITE_OK;  #endif   #if !OS_WINCE && !defined(__CYGWIN__) 
    ---------------------------------- Thank you! #f2dcdc 2701 new active 2007 Oct anonymous 2007 Oct 5 5 Make INSERT-ing multiple rows MySQL-compatible 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:_ {linebreak} 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:_ {linebreak} Patch implementing multi-row INSERT statements against 3.5.1 source tree: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg28337.html #cfe8bd 2700 code fixed 2007 Oct anonymous 2007 Oct 1 1 invalid name in winOpen when compiling under WinCE in os_win.c:1165, WinCE specific code to create lock still refers to former zFilename variable whereas argument is now named zName. --- os_win.c-orig 2007-10-07 22:04:02.000000000 +0200 +++ os_win.c 2007-10-07 23:32:51.000000000 +0200 @@ -1162,7 +1162,7 @@ #if OS_WINCE if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) == (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB) - && !winceCreateLock(zFilename, pFile) + && !winceCreateLock(zName, pFile) ){ CloseHandle(h); free(zConverted); #cfe8bd 2699 code fixed 2007 Oct anonymous 2007 Oct 2 2 Performance issues in 3.5.1 (Windows) As reported on mailing list: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg28164.html "Forcibly adding FILE_FLAG_RANDOM_ACCESS to the flags in os_win.c's winOpen fixed it. It looks like in 3.4.2, that flag was set on all files (journals and db's), while in 3.5, it (was) only being set on db's. Adding it to journals too improves performance almost tenfold. This may also help performance on desktop Windows." #cfe8bd 2698 code fixed 2007 Oct anonymous 2007 Oct 3 4 memory leak in WIN CE because tempfilename is not freed at WinClose in a build for Windows CE ( OS_WIN is defined ) temporary files have to be deleted after winclose because the operating systems does not delete themself. At the first sqlite3_get_table() somewhere in the code in function sqlite3WinOpenExclusive() the call to convertUtf8Filename() returns a newly allocated name for the tempfile. This is afterwards assigned to f.DeleteOnClose but is never deleted or freed in WinClose, when hMutex is not used. _2007-Oct-08 04:49:56 by anonymous:_ {linebreak} This was introduced in checkin [3836] and subsequently reported in bugs #2533 and #2598. #cfe8bd 2697 code fixed 2007 Oct anonymous 2007 Oct 1 3 sqlite3_open_v2 fails then filename includes non-english chars Can't create database with new sqlite3_open_v2 function if filename is international (non English) char filename[MAX_PATH]; memset(filename, 0, sizeof(filename)); ::WideCharToMultiByte(CP_ACP, 0, jobfilename.c_str(), -1, filename, sizeof(filename)-1, 0, 0); int dbcreateres = sqlite3_open_v2(filename, &m_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); dbcreateres == 14 By the way, why we just don't have sqlite3_open16_v2 function !!! It would be best solution for me ! changing the code to ::WideCharToMultiByte(CP_UTF8, ... fixes the issue... sorry for your time... #cfe8bd 2696 code fixed 2007 Oct anonymous 2007 Oct 3 3 sqlite3.c with SQLITE_OMIT_FLOATING_POINT cannot compile on Linux Unmodified compile of sqlite3.c with SQLITE_OMIT_FLOATING_POINT will generate these errors:
     In file included from /usr/include/math.h:141,                  from sqlite3.c:10227: /usr/include/bits/mathcalls.h:55: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘acosl’ /usr/include/bits/mathcalls.h:55: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__acosl’ /usr/include/bits/mathcalls.h:57: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘asinl’ /usr/include/bits/mathcalls.h:57: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__asinl’ /usr/include/bits/mathcalls.h:59: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘atanl’ /usr/include/bits/mathcalls.h:59: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__atanl’ /usr/include/bits/mathcalls.h:61: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘atan2l’ etc... 
    #include must be moved to just after the line #define _SQLITE3_H_ in the sqlite3.c amalgamation for it to compile with gcc. It probably has to do with the place where double is redefined. #c8c8c8 2695 new closed 2007 Oct anonymous 2007 Oct drh 3 3 sqlite3 CLI unresolved externals with SQLITE_OMIT_GET_TABLE sqlite3_free_table and sqlite3_get_table are unresolved if sqlite3 is compiled with -DSQLITE_OMIT_GET_TABLE=1 Required fix below.
     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 5 Oct 2007 06:19:58 -0000 @@ -1458,6 +1458,7 @@ static int do_meta_command(char *zLine,      fprintf(p->out,"\n");    }else  +#ifndef SQLITE_OMIT_GET_TABLE    if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 ){      char **azResult;      int nRow, rc; @@ -1514,6 +1515,7 @@ static int do_meta_command(char *zLine,      }      sqlite3_free_table(azResult);    }else +#endif     if( c=='t' && n>1 && strncmp(azArg[0], "timeout", n)==0 && nArg>=2 ){      open_db(p); 
    _2007-Oct-05 14:34:39 by drh:_ {linebreak} I would imagine that there are many SQLITE_OMIT_... macros that will break the CLI. The CLI is a separate program which is distinct from the SQLite library and is not expected to work with every possible configuration of the SQLite library. So this really should be a feature request and not a bug report. My dilemma now is whether to accept or reject this feature request. The changes are relatively minor. But on the other hand, the requested feature is very obscure. Why is it that you want to have a CLI that omits the sqlite3_get_table() API? As I sit here pondering, I cannot think of a single reason why anybody would want to do such a thing, and so for that reason I am rejecting this feature request. If somebody (the original poster or anybody else) can give me a legitimate reason for wanting to build the CLI without the sqlite3_get_table() interface, I will reconsider the rejection. ---- _2007-Oct-05 15:49:01 by anonymous:_ {linebreak} Why? To test all the OMIT macros on a representative program already in the source tree. I found other OMIT compile problems outside of shell.c when performing this exercise. I'll file a seperate ticket SQLITE_OMIT_FLOATING_POINT. No one is saying anyone would #define this particular OMIT. It is just there for completeness. It gives programmers confidence in using the sqlite library without investing too much time in it. For that matter, it would be nice to test an OMIT-filled sqlite3 library against the exactly same configured corresponding sqlite3 shell. Also, you define it if you wanted to build a minimalistic shell for a severely memory-constrained embedded device. Truth be told, the .table command is a nice but rarely used command whose info can be gleaned with a simple query on sqlite_master anyway. ---- _2007-Oct-05 16:08:23 by anonymous:_ {linebreak} By the way, only a couple of other OMITs broke shell.c: SQLITE_OMIT_COMPLETE SQLITE_OMIT_DISKIO You did a better job than you realized. ;-) ---- _2007-Oct-05 16:26:04 by anonymous:_ {linebreak} Was able to successfully compile/link/run shell.c with: THREADSAFE=0 SQLITE_OMIT_ALTERTABLE SQLITE_OMIT_ANALYZE SQLITE_OMIT_ATTACH SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_AUTOINCREMENT SQLITE_OMIT_AUTOVACUUM SQLITE_OMIT_BETWEEN_OPTIMIZATION SQLITE_OMIT_BLOB_LITERAL SQLITE_OMIT_CAST SQLITE_OMIT_CHECK SQLITE_OMIT_COMPOUND_SELECT SQLITE_OMIT_CONFLICT_CLAUSE SQLITE_OMIT_DATETIME_FUNCS SQLITE_OMIT_EXPLAIN SQLITE_OMIT_FLAG_PRAGMAS SQLITE_OMIT_FLOATING_POINT (see Ticket #2696) SQLITE_OMIT_FOREIGN_KEY SQLITE_OMIT_GET_TABLE (with above patch) SQLITE_OMIT_GLOBALRECOVER SQLITE_OMIT_INCRBLOB SQLITE_OMIT_INTEGRITY_CHECK SQLITE_OMIT_LIKE_OPTIMIZATION SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_MEMORYDB SQLITE_OMIT_OR_OPTIMIZATION SQLITE_OMIT_PAGER_PRAGMAS SQLITE_OMIT_PROGRESS_CALLBACK SQLITE_OMIT_QUICKBALANCE SQLITE_OMIT_REINDEX SQLITE_OMIT_SCHEMA_PRAGMAS SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_SUBQUERY SQLITE_OMIT_TCL_VARIABLE SQLITE_OMIT_TEMPDB SQLITE_OMIT_TRACE SQLITE_OMIT_TRIGGER SQLITE_OMIT_UTF16 SQLITE_OMIT_VACUUM SQLITE_OMIT_VIEW SQLITE_OMIT_VIRTUALTABLE SQLITE_OMIT_XFER_OPT ---- _2007-Oct-05 16:28:11 by drh:_ {linebreak} If you are building a minimalist shell, you should start from scratch and not try to use shell.c. There is a lot of cruft in shell.c (above and beyond ".table") that a minimalist shell does not want. So this is not a valid reason for wanting shell.c to support SQLITE_OMIT_GET_TABLE. Likewise, there a lot of ways to test to make sure SQLite work with SQLITE_OMIT_GET_TABLE without compiling shell.c. I remain unconvinced. Feature request still rejected. ---- _2007-Oct-05 16:33:33 by anonymous:_ {linebreak} Wow, you won't check in an trivially obvious perfectly harmless 2 line patch despite a half dozen reasons why it's useful. A lot of people use shell.c for testing and in production - probably more people use the CLI than do the Tcl API. #cfe8bd 2694 code fixed 2007 Oct anonymous 2007 Oct drh 2 2 Makefile.in is missing invokation of mksqlite3internalh.tcl for a10n The amalgamation should produce both sqlite3.c and sqlite3internal.h which is correct in the master main.mk but missing in Makefile.in; the following patch corrects Makefile.in: --- sqlite3.orig/Makefile.in 2007-09-04 00:11:33.000000000 +0200 +++ sqlite3/Makefile.in 2007-10-04 22:24:00.000000000 +0200 @@ -333,6 +333,7 @@ sqlite3.c: target_source $(TOP)/tool/mksqlite3c.tcl tclsh $(TOP)/tool/mksqlite3c.tcl + tclsh $(TOP)/tool/mksqlite3internalh.tcl # Rules to build the LEMON compiler generator # _2007-Oct-05 14:24:38 by drh:_ {linebreak} See my comment on ticket #2693. #cfe8bd 2693 code fixed 2007 Oct anonymous 2007 Oct drh 2 2 mutex.h missing in a10n of sqlite3internal.h mutex.h is still included in amalgamatized sqlite3internal.h; maybe that patch fixes it. --- tool/mksqlite3internalh.tcl.orig 2007-08-14 15:21:27.000000000 +0200 +++ tool/mksqlite3internalh.tcl 2007-10-04 22:52:46.000000000 +0200 @@ -57,6 +57,7 @@ btreeInt.h hash.h keywordhash.h + mutex.h opcodes.h os_common.h os.h _2007-Oct-05 14:23:58 by drh:_ {linebreak} Our intent is to eliminate sqlite3internal.h. As of 3.5.0 there should never be a need to access the internal definitions of SQLite. Everything that you need to use SQLite properly is contained in sqlite3.h. If you need definitions found in the internal include files, that indicates that you are using SQLite in a way that is unsupported and likely to break from one release to the next. #c8c8c8 2692 build closed 2007 Oct anonymous 2007 Oct 1 1 COmpilation of Sqlite amalgamation v3.4.2. failed Version 3.4.2 (amalgamation) could not be compiled under MS DevStudio 6 the compilation errors are: sqlite3.c(6187) : error C2133: 'sqlite3UpperToLower' : unknown size sqlite3.c(9310) : error C2133: 'sqlite3OpcodeNames' : unknown size sqlite3.c(47159) : error C2133: 'sqlite3IsIdChar' : unknown size _2007-Oct-04 18:19:44 by drh:_ {linebreak} Duplicate of #2574. #c8c8c8 2691 code closed 2007 Oct anonymous 2007 Oct 1 1 SQLITE_OMIT_AUTHORIZATION compilation error sqlite3.Int.h does not compile with SQLITE_OMIT_AUTHORIZATION. Rationale: sqlite3Int.h, line 1768: # define sqlite3AuthRead(a,b,c) is missing a 4th parameter like this: # define sqlite3AuthRead(a,b,c,d) thanks. #c8c8c8 2690 code closed 2007 Oct anonymous 2007 Oct 3 4 "PRAGMA synchronous = OFF;" is more dangerous than documented The "PRAGMA synchronous = OFF;" is much more dangerous than implied in the documentation (at http://www.sqlite.org/pragma.html). On our embedded system written data may remain in a middleware buffer (without being passed to the OS) until a subsequent read, write, seek or close call occurs. In particular, the last write to the database file may remain buffered semi-locally for quite a while after the lock is released. This will inevitably cause problems if the database is read through a different handle meanwhile - even by the same thread! I have seen this occur (fairly regularly), when a subsequent SELECT returns SQLITE_CORRUPT. Four pages are read through another handle before the error is raised. The write didn't complete until the file was closed as part of the application shutdown more than 10 seconds later. It might reasonably be argued that our middleware is broken in this case, but I'm sure that there are other systems with similar problems. The problem is still present in version 3.4.1 where the sqlite3OsSync call at pager.c:3954 should not be conditional on !pPager->noSync. Another solution may be to change the documentation to highlight this risk. _2007-Oct-04 14:26:18 by drh:_ {linebreak} From the description, this seems definitely to be a bug in your alternative OS interface, not in the delivered SQLite code. Perhaps you should modify your middleware so that it flushes pending writes prior to unlocking. #c8c8c8 2689 build closed 2007 Oct anonymous 2007 Oct 3 4 make test fails in 3.5.1 - unresolved externals in testfixture tar zxvf sqlite...... cd sqlite-3.5.1 mkdir bld cd bld ../configure make make test ./libtool --mode=link gcc -g -O2 -I. -I../src -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers -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 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_schema.c ../src/test_server.c ../src/test_tclvar.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 \ libsqlite3.la -framework Tcl -lpthread -framework CoreFoundation gcc -g -O2 -I. -I../src -DNDEBUG -I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers -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_schema.c ../src/test_server.c ../src/test_tclvar.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 -framework Tcl -framework CoreFoundation ./.libs/libsqlite3.dylib -lpthread /usr/bin/ld: Undefined symbols: _Sqlitetest7_Init _SqlitetestOnefile_Init _SqlitetestThread_Init collect2: ld returned 1 exit status make: *** [testfixture] Error 1 _2007-Oct-04 11:21:47 by anonymous:_ {linebreak} This is mac os x ---- _2007-Oct-04 15:40:13 by anonymous:_ {linebreak} Same unresolved externals for testfixture on Linux. Fix below. Do a "make distclean" and re-run configure/make test.
     Index: Makefile.in =================================================================== RCS file: /sqlite/sqlite/Makefile.in,v retrieving revision 1.183 diff -u -3 -p -r1.183 Makefile.in --- Makefile.in 3 Sep 2007 22:15:45 -0000       1.183 +++ Makefile.in 4 Oct 2007 15:37:57 -0000 @@ -212,6 +212,8 @@ SRC += \  # Source code to the test files.  #  TESTSRC = \ +  $(TOP)/src/test_onefile.c \ +  $(TOP)/src/test_thread.c \    $(TOP)/src/attach.c \    $(TOP)/src/btree.c \    $(TOP)/src/build.c \ Index: src/test7.c =================================================================== RCS file: /sqlite/sqlite/src/test7.c,v retrieving revision 1.9 diff -u -3 -p -r1.9 test7.c --- src/test7.c 12 Sep 2007 17:01:45 -0000      1.9 +++ src/test7.c 4 Oct 2007 15:37:57 -0000 @@ -21,8 +21,8 @@  ** This test only works on UNIX with a SQLITE_THREADSAFE build that includes  ** the SQLITE_SERVER option.  */ -#if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) -#if defined(OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE +#if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) && \ +    defined(OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE   #include   #include  @@ -720,5 +720,4 @@ int Sqlitetest7_Init(Tcl_Interp *interp)  }  #else  int Sqlitetest7_Init(Tcl_Interp *interp){ return TCL_OK; } -#endif /* OS_UNIX */  #endif 
    ---- _2007-Oct-04 15:43:15 by anonymous:_ {linebreak} Output of make test after patch: 0 errors out of 31801 tests All memory allocations freed - no leaks Maximum memory usage: 14160983 bytes ---- _2007-Oct-04 19:09:05 by anonymous:_ {linebreak} I am the original reporter - that fix worked for me, thanks. My results (OS X) 0 errors out of 31207 tests All memory allocations freed - no leaks Maximum memory usage: 14161431 bytes #c8c8c8 2688 build closed 2007 Oct anonymous 2007 Oct 3 1 SQLITE_OMIT_AUTHORIZATION build failure Version 3.5.1 does not compile when specifying -DSQLITE_OMIT_AUTHORIZATION. The problem lies on line 6872 (of the amalgamation): =# define sqlite3AuthRead(a,b,c)= should be: =# define sqlite3AuthRead(a,b,c,d)= thanks. #cfe8bd 2686 code fixed 2007 Oct anonymous 2007 Oct 3 3 Integrity check fails if you hit max_page_count and dont rollback If you set PRAGMA max_page_count to reachable value, fill database until SQLITE_FULL is returned, and don't do a rollback immediately (say, because your program quits or crashes before rollback), the database will be left in damaged state (PRAGMA integrity_check will detect errors). This happens for me for both 3.4.2 and 3.5.0. This is serious defect which breaks A.C.I.D. ideology, although it is not a show stopper and will not happen often to users. Furthermore, one time this ended in "database is malformed" error, although I could not reproduce this again. Try modifying the test below to not stop after integrity check failure, let it cycle hundreds times, and you will get malformed database error sooner or later. This should not happen, database integrity must stay o.k. whenever program crashes before doing rollback, or simply never does a rollback. The following code reproduces the problem. Notice the commented out conn.rollback() line, if you uncomment it, bug will disappear. You may consider adding this test to other SQLite unit-tests.
     #!/usr/bin/python import sqlite3, random, os, os.path, sys dbfile = '''db.tmp''' if os.path.exists(dbfile): os.unlink(dbfile) conn = sqlite3.connect(dbfile) cur = conn.cursor() cur.execute('''PRAGMA page_size=1024''') # just to make sure cur.execute('''PRAGMA max_page_count=5120''') # 5 megabytes cur.execute('''PRAGMA auto_vacuum=0''') cur.execute('''CREATE TABLE filler (fill)''')  while 1:     try:         cur.execute('''INSERT INTO filler (fill) VALUES (randomblob(%d))''' % int(random.uniform(10240, 102400)))         conn.commit()         sys.stdout.write('.')     except sqlite3.OperationalError, e:         if e.message != "database or disk is full":             break         sys.stdout.write('*')         #conn.rollback() #uncomment this and error will disappear         cur.execute('''DELETE FROM filler WHERE rowid <= (SELECT MAX(rowid) FROM filler LIMIT 20)''')         cur.execute('''PRAGMA integrity_check''')         r = cur.fetchall()         s = str(r[0][0])         if s != 'ok':             print "Something is wrong! Integrity check returned", s             print r             break 
    #cfe8bd 2685 code fixed 2007 Oct anonymous 2007 Oct anonymous 2 1 Compilation under MSVC gives warning on TryEnterCriticalSection If SQLite is compiled under MSVC 8.0 for instance it gives following warning while compiling mutex_w32.c: src\mutex_w32.c(147) : warning C4013: 'TryEnterCriticalSection' undefined; assuming extern returning int This warning shall be treated as error, if correct behavior of try mutex is exected. Solution: to declare #define _WIN32_WINNT 0x0400 before # include in os.h. Also it worth adding WIN32_LEAN_AND_MEAN to exclude unneeded stuff. Workaround: I propose adding 2 lines of macros starting from line 72 in os.h as: #define _WIN32_WINNT 0x0400 #define WIN32_LEAN_AND_MEAN Code view: #if OS_WIN #define _WIN32_WINNT 0x0400 #define WIN32_LEAN_AND_MEAN # include # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) Sincerely yours, Dmitry Kostjuchenko. _2007-Oct-02 21:40:15 by anonymous:_ {linebreak} This assumes SQLite will not run under non-NT systems. Should backward compatibility still existing ? I'm not sure... ---- _2007-Oct-30 20:33:20 by anonymous:_ {linebreak} Why not enable the code when =_WIN32_WINNT= is actually defined to a proper value (i.e. >= 0x0400): #if _WIN32_WINNT >= 0x0400 // code that uses TryEnterCriticalSection in here #endif That way, if people want this improvement, they can define =_WIN32_WINNT= in their make process. #f2dcdc 2684 code active 2007 Oct anonymous 2007 Oct 1 1 Accessing sqlite from an NT service will lock the complete databse. 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 2683 code fixed 2007 Oct anonymous 2007 Oct 1 1 Windows CE won't compile, also a problem with sqlite3OsFullPath on CE With some modifications the program will compile, but opening a database returns (sometimes) unknown error, and (sometimes) attempt to write a read-only database. This strange behaviour is due to a missing return statement that should be "return SQLITE_OK;". See the patch. _2007-Oct-16 19:02:55 by anonymous:_ {linebreak} I built version for WindowsCE and tested. Now it could open and create databases ! The only difference is in
     @@ -1162,13 +1168,13 @@  #if OS_WINCE    if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) ==                 (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB) -       && !winceCreateLock(zFilename, &f) +       && !winceCreateLock(zName, pFile) 
    #c8c8c8 2682 code closed 2007 Oct anonymous 2007 Oct 1 1 SQLite Text Problem I am using SQLite 3 as backend database in my asp application. I am using SQLite3 ODBC driver (latest version). Table Design ------------ CREATE TABLE log ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, from_value TEXT NULL, to_value TEXT NULL ); INSERT 10 RECORDS IN TO DATABASE -------------------------------- Const adOpenStatic = 3 Const adLockOptimistic = 3 Dim SQLString ,objConnection Dim fromVal,toval Set objConnection = CreateObject("ADODB.Connection") for a = 1 to 10 objConnection.Open "DSN=Test;uid=;pwd=;" fromVal = "FROM Value : "& a toVal = "To Value : "& a SQLString = "INSERT INTO log(from_value, to_value) VALUES ('"& fromVal & "' ,'"&toVal& "')" objConnection.Execute SQLString objConnection.Close next Access records in the log table ------------------------------- Dim LogRs,SQLStmt SQLStmt = "SELECT * FROM log " LogRs.ActiveConnection = "DSN=Test;uid=;pwd=;" LogRs.Source= SQLStmt LogRs.CursorType = 3'ADOPENSTATIC LogRs.CursorLocation = 2 'ADUSESERVER LogRs.LockType = 3 'ADLOCKOPTIMISTIC LogRs.Open() RecordCount = LogRs.RecordCount If I use datatype of from_value/to_value as TEXT ,I get RecordCount as zero which is wrong. If I use datatype of from_value/to_value as Varchar(1600) ,I get RecordCount as 10 which is correct. If I use datatype of from_value/to_value as Varchar(1600) and tried to put more than 1600 charcters in it ,SQLite stores data in DB. While retrieving the data I get the error Arguments are of the wrong type,are out of acceptable range,or are in conflict with one another. I enabled ODBC trace log ,but its empty after running my application.So I am not sure where it is ODBC problem or SQLite ODBC driver error? If I open table (database) in SQLite Studio I could see data without any error. If I use MS Access with same table design and same code, I dont get any error . The code works fine as expected . _2007-Oct-01 22:04:18 by drh:_ {linebreak} There are multiple ODBC drivers for SQLite, none of which are support by this site. Your problem appears to be in the ODBC driver. If you find evidence to the contrary, please reopen this ticket. #cfe8bd 2681 code fixed 2007 Oct anonymous 2007 Oct 3 3 #ifndef _XOPEN_SOURCE needed around #define _XOPEN_SOURCE 500 _XOPEN_SOURCE is really poorly defined/implemented in general. Some platforms need _XOPEN_SOURCE to be set to 600, or a value other than 500. Could you please put an #ifdef wrapper around this, as follows? #ifndef _XOPEN_SOURCE # ifndef __MACOS__ # define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ # endif #endif _2007-Oct-01 16:47:50 by anonymous:_ {linebreak} Furthermore, can you avoid defining _XOPEN_SOURCE if it is not a threadsafe build? (i.e., define _XOPEN_SOURCE only if threadsafe build requested). #cfe8bd 2680 code fixed 2007 Sep anonymous 2007 Oct 2 2 sqlite_int64 vs sqlite3_int64 type confusion in headers and docs Header file sqlite3.h (3.4.2) defines sqlite_int64 but not sqlite3_int64. 3.5.0 defines both. I discovered this used the 3.5.0 documentation (on the site) but building against a local installation of 3.4.2. The documentation and examples used BOTH types in a somewhat ad-hoc manner. Could someone please clarify which is the preferred type? If sqlite3_int64 is preferred, then should the header files for 3.4.x be updated to reflect this? _2007-Oct-03 20:21:49 by anonymous:_ {linebreak} sqlite 3.4.2 doesn't define sqlite3_int though, only sqlite_int this means i can't use common code for both sqlite3.4.2 and sqlite3.5.0 ---- _2007-Oct-03 20:29:51 by anonymous:_ {linebreak} Just use sqlite_int then. They are typedef'd to the same thing in 3.5. #c8c8c8 2679 code closed 2007 Sep anonymous 2007 Oct 2 3 locking errors lead to disk i/o failure with bulk operations on winxp First got lost cursor and disk i/o errors with bulk imports to sqlite database using sqliteodbc driver with =OpenOffice= under win xp sp 2. Then used sqlite3.exe to reproduce and found: if sqlite database is on an ext2 volume accessed through ext2ifs driver, and I .read a sql command file with 348 times INSERT INTO ... VALUES('...','...'); to a table with two text columns, after some (hundred or more) rows without error I receive the following error: SQL error near line xxx: disk I/O error for all following lines; likewise, when I replace the INSERT by DELETE FROM ... WHERE col='...', I will receive the same error after some ten lines. The database cannot be accessed any more as long as the sqlite3 executable is running; closing and restarting it restores access (same with odbc driver - no access unless connection closed and reopened). I can omit these errors by surrounding the statements with a BEGIN TRANSACTION / COMMIT clause (not available with OOo and the odbc driver, unfortunately). Likewise, when the sqlite database is on a ntfs volume, the error is gone. I first thought there might be an error with the ext2 ifs driver, but I use it heavily for all kinds of data without problems so far. Then I took a closer look at the sqlite3 executable by monitoring its activity using sysinternals' procmon. And this revealed that there were no failing reads or writes as the error message would suggest, but I noticed RANGE NOT LOCKED results with =UnlockFileSingle= operations (corresponding to =UnlockFileEx= calls in the source) when the error surfaces. Examing the sequence of =LockFile= and =UnlockFileSingle= on locations 1gb (1), 1gb+1 (1) and 1gb+2 (510) I found that sqlite3 indeed tried to unlock locations already unlocked previously - the reported errors (and the file locking implementation in the ext2 driver) were correct. It seems that sqlite looses track with its locks after multiple lock/unlock sequences. I append the procmon log of locking activities of the sqlite3 executable during 'mass' inserts in csv format. _2007-Sep-28 23:22:07 by anonymous:_ {linebreak} Could you clarify a few things? How many SQLite processes are there in your scenario? What is the actual schema and SQL statements issued by each process? ---- _2007-Sep-29 18:25:50 by anonymous:_ {linebreak} could be a ext2fs ifs driver issue. did you tested id in NTFS / FAT32 filesystems ? ---- _2007-Sep-29 23:32:09 by anonymous:_ {linebreak} ok, first to clarify: there is a *single* sqlite3 process, absolutly no concurrency; and a simple table used, like {quote: CREATE TABLE "WhoIsWho" ("Nummer" varchar(50) NOT NULL, "Teilnehmer" varchar(50), PRIMARY KEY ("Nummer"));} then I feed a text file with 348 statements like {quote: INSERT INTO WhoIsWho VALUES('01805312111','conrad electronic hotline');} with different values to a sqlite3-executable, either by issuing a .read statement at the sqlite3 prompt or using input redirection on the commandline. likewise, with full table to delete the entries I use a file with statements like {quote: DELETE FROM WhoIsWho WHERE Nummer=='01805220111';} this should make the setup clear - but what do you mean with schema? and about ext2ifs issue and testing on ntfs: see above ;-) and read on but now: I digged a lot deeper in this issue: first of all, there is a big difference in the sequence of operations as seen by procmon between ext2 and ntfs. on ntfs, there are 2 (!) {quote: "CloseFile C:\"} between all other operations, and a lot of additional {quote: "CloseFile "}; this way each INSERT operation takes much longer, 142 +/- 23 ms on ntfs vs. 43 +/- 12 ms on ext2 on my system. every INSERT line is handled similar: first a check for a left over journal file, then writes to the journal, then writes to the database, then mark the journal for deletion and close it on the first failing INSERT the check for a left over journal finds it still there - although marked for deletion. the first time this happens the time between the last =Close= and the new =CreateFile= is very short, 4 ms in my case, so the journal is not yet deleted. now sqlite issues 2 identical successive =QueryStandardInformationFile= calls on the journal file, the result is {quote: AllocationSize: 49'152, EndOfFile: 6'184, NumberOfLinks: 1, DeletePending: True, Directory: False} ignoring the {quote: DeletePending: True} result sqlite takes it for a valid journal file and does a rollback assuming the last operation had failed - this I consider a bug: a file marked for deletion has to be looked at as not valid any more. after rollback it marks the file again for deletion, and then creates it new with =OverwriteIf= flag set without checking if deletion actually occured in this case. then it restarts the current INSERT again, this time succeeding - but the next INSERT cycle will rollback this line also. prior to restarting file locks are released, but this time sqlite has lost record of which locks have been set: it releases 2 locks that are not locked, resulting in the errors reported above. this I consider the second bug. Besides, I feel the locking during rollback is not what it should be: it is done with locks at 1gb and at 1gb+1 released, and the lock on 1gb+2 is released and set to exclusive state without any of the 1gb and 1gb+1 locks protecting it. I think there is a =UnlockFileSingle= to 1gb+1 where a =LockFile= at 1gb should have been. why it works with ntfs and not with ext2: i think this is a question of timing and those massive {quote: "CloseFile C:\"} inserted in case of ntfs. they appear like a q&d workaround for similar issues on ntfs. ---- _2007-Sep-30 00:13:23 by anonymous:_ {linebreak} Interesting. You seem to have uncovered a race condition in the Windows version of SQLite. Just for the heck of it, what happens if you change the os_win.c code to Sleep(1000) after every single CloseFile() call? ---- _2007-Sep-30 00:22:31 by anonymous:_ {linebreak} Also, can you increase MX_DELETION_ATTEMPTS from 3 to 30, and Sleep(100) to Sleep(1000) and see what happens?
     #define MX_DELETION_ATTEMPTS 3 static int winDelete(   sqlite3_vfs *pVfs,          /* Not used on win32 */   const char *zFilename,      /* Name of file to delete */   int syncDir                 /* Not used on win32 */ ){   int cnt = 0;   int rc;   void *zConverted = convertUtf8Filename(zFilename);   if( zConverted==0 ){     return SQLITE_NOMEM;   }   SimulateIOError(return SQLITE_IOERR_DELETE);   if( isNT() ){     do{       rc = DeleteFileW(zConverted);     }while( rc==0 && GetFileAttributesW(zConverted)!=0xffffffff             && cnt++ < MX_DELETION_ATTEMPTS && (Sleep(100), 1) );   }else{ #if OS_WINCE     return SQLITE_NOMEM; #else     do{       rc = DeleteFileA(zConverted);     }while( rc==0 && GetFileAttributesA(zConverted)!=0xffffffff             && cnt++ < MX_DELETION_ATTEMPTS && (Sleep(100), 1) ); #endif   }   free(zConverted);   OSTRACE2("DELETE \"%s\"\n", zFilename);   return rc!=0 ? SQLITE_OK : SQLITE_IOERR; } 
    ---- _2007-Sep-30 12:35:32 by anonymous:_ {linebreak} Hmm, I think your suggestions point to the *wrong place*. If there were multiple attempts to delete the file, I would have seen them in the =ProcMon= log. But this is not the case. The =DeleteFileW= succeeds immediately (rc!=0), so the rest of the while clause is never executed. But, as the documentation says, a successful =DeleteFile= call does not mean the file *is deleted*, it only means the file has been *marked for deletion*, and the OS is free to schedule the actual deletion *anytime* after the =CloseFile= call. We should look at the code that checks for a left over journal file. This code already reads the file attributes, so it should be easy to check for the =DeletePending= flag: if it is set it should treat the journal file as if it were already deleted. Nevertheless, there is a fault in the fs driver or the OS: the MS documentation says that a =CreateFile= call on a file marked for deletion fails with ERROR_ACCESS_DENIED - but in this case it succeeds! The second error - loosing track of locks during rollback - still has to be addressed. ---- _2007-Sep-30 15:59:26 by anonymous:_ {linebreak} What happens when you insert the Sleep calls after CloseFile? ---- _2007-Oct-01 12:47:25 by anonymous:_ {linebreak} If I would place a Sleep(1000) after every =CloseFile= (I didn't) then the errror would shurely vanish - and my 348 inserts would last 6 minutes! That's not the way to go. I suggested to look for the code to check for the journal file still there, but I see this has already been accounted for in the code to exclusively open a file on windows, here:
     /* ... ** Sometimes if we have just deleted a prior journal file, windows ** will fail to open a new one because there is a "pending delete". ** To work around this bug, we pause for 100 milliseconds and attempt ** a second open after the first one fails.  The whole operation only ** fails if both open attempts are unsuccessful. */ int sqlite3WinOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){ ...     do{       h = CreateFileW((WCHAR*)zConverted,          GENERIC_READ | GENERIC_WRITE,          0,          NULL,          CREATE_ALWAYS,          fileflags,          NULL       );     }while( h==INVALID_HANDLE_VALUE && cnt++ < 2 && (Sleep(100), 1) ); ... } 
    This requires the =CreateFileW= call to fail and return an invalid handle - which is what Microsoft specifies for a file marked for deletion but what the file system driver does not acknowledge: it allows the file marked for deletion to be successfully opened. So it's again the ext2ifs driver developer's turn: I have already contacted him ... ---- _2007-Oct-01 14:46:18 by anonymous:_ {linebreak} Adding the Sleep would simply confirm your theory. No one is suggesting it be added permanently. ---- _2007-Oct-07 23:21:26 by anonymous:_ {linebreak} I finally tracked down also the unlock errors: they are there by design. When a hot journal is found, the immediate rollback is purposely only with an EXCLUSIVE lock, but without a RESERVED or PENDING lock. Nevertheless, the unlock code assumes that whenever there is an EXCLUSIVE lock, then there might also be a RESERVED and a PENDING lock, and both are unlocked too. That's nothing to bother with, as it only provokes error returns from the OS, the handling itself is correct. See:
     static int winUnlock(OsFile *id, int locktype){ ...   if( type>=RESERVED_LOCK ){     UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);   } ...   if( type>=PENDING_LOCK ){     UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0);   } ... }  
    ---- _2007-Oct-12 18:50:28 by drh:_ {linebreak} **Summary:** This turns out to be a bug in the ext2 driver for winNT, not in SQLite. The locking problem is not a real issue. ---- _2007-Oct-14 16:27:15 by anonymous:_ {linebreak} Just to approve: the ext2ifs driver developer sent me a patched driver that returns a "DELETE PENDING" error when a journal file already marked for deletion tried to be opened, and with it the errors are gone. I suppose the corrected driver will soon be general available. #cfe8bd 2678 code fixed 2007 Sep anonymous 2007 Oct 1 1 amalgamation zip file should include sqlite3ext.h It is not possible to build portable external loadable modules using just sqlite-amalgamation-3_5_0.zip - instead you need the entire sqlite3 source tree. If sqlite3ext.h were bundled with the amalgamation, this would not be necessary. _2007-Sep-28 19:44:00 by anonymous:_ {linebreak} Actually, a better solution would be to get rid of sqlite3ext.h altogether, fold its functionality into sqlite3.h and when people go to compile a module they #define whether they wish to compile an external library or not. #cfe8bd 2673 build fixed 2007 Sep anonymous 2007 Oct 4 4 3.5.0 amalgamation on OS X, "#define _XOPEN_SOURCE 500" fails build In the first amalgamation release for 3.5.0, the following #define causes a build problem on Mac OS X 10.4. #define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ This is not needed on OS X and, instead, causes _POSIX_C_SOURCE to be #defined around line 280 in which in turn causes the fsync() and localtime_r() functions to *not* be declared in and , respectively. This causes a compile warning or an error if you have -Werror-implicit-function-declaration enabled. More importantly, it causes the compiler to create an implicit declaration for those two functions which is somewhat dangerous. Thanks! #cfe8bd 2672 doc fixed 2007 Sep anonymous 2007 Oct 1 3 icu ext init failure: sqlite3_create_function returns SQLITE_BUSY icu extenstion init fails b/c sqlite3_create_function returns 5 (SQLITE_BUSY) in the init code for icu i print the function name and the result code from sqlite3_create_function, i see: sqlite> select load_extension('./icu.so'); create function for regexp gave 0 create function for lower gave 0 create function for lower gave 0 create function for upper gave 0 create function for upper gave 0 create function for lower gave 5 i,e. the first lower with SQLITE_UTF8 fails (i didn't check why yet, i'm wondering was there some API change here though wrt to having both _UST16 and _UTF8?) also, i notice the code on failure doesn't cleanup, so it will leave functions registered even though init failed (recompile & retry probably will crash sooner or later) This is a bug. SQLite does not allow you to change or delete a user function while there are SQL statements running (could cause a seg-fault if the running statement users the function being deleted/modified). Adding new functions is Ok though. The reason this is failing is that SQLite is counting "SELECT load_extension(...)" as a running statement. The first couple of create function calls succeeded because these did not override existing user functions. The easiest workaround would be to use the sqlite3_load_extension() API directly, not via "SELECT load_extension()". In the shell, try this: sqlite> .load icu.so Alternatively, you could try linking the extension staticly with SQLite. To do this, add ext/icu/icu.c to the list of C files to be compiled and add -DSQLITE_ENABLE_ICU to the compiler command line (for all C files, not just icu.c). ---- _2007-Sep-28 17:34:36 by anonymous:_ {linebreak} Ah right! Testing using ".load ./icu.so" does indeed work correctly. However, there still remains the bug that when it does fail to initialize some functions are left registered and accessing those will usually seg-fault. Given that sqlite3_create_function cannot be undone, perhaps there should be some way to detect (inside the extension) if it's being loaded from inside a statement and bail out early? ---- _2007-Sep-28 17:40:14 by anonymous:_ {linebreak} To fix this bug, sqlite need only defer the loading of the extension module until after any pending SQL call is complete. #c8c8c8 2670 doc closed 2007 Sep anonymous 2007 Oct 5 4 Document for EXPLAIN doesn't mention using EXPLAIN QUERY PLAN I was looking for documentation for determining what indicies a select statement uses. I found "EXPLAIN" in the documentation, but couldn't figure anything out from the output. Eventually I found "EXPLAIN QUERY PLAN" on the idxchk wiki page. _2007-Oct-01 13:37:02 by drh:_ {linebreak} EXPLAIN QUERY PLAN is unsupported. If we document it we will have to support it forever. That is something we do not want to do. #c8c8c8 2668 code closed 2007 Sep anonymous 2007 Oct 3 4 Build failure due to syntax error under Cygwin Missing semi-colon at end of line. The patch below fixes it. --- os_win.c.orig 2007-09-25 16:55:35.053064600 -0400 +++ os_win.c 2007-09-25 16:52:46.146226100 -0400 @@ -1326,7 +1326,7 @@ #if defined(__CYGWIN__) cygwin_conv_to_full_win32_path(zRelative, zFull); - return SQLITE_OK + return SQLITE_OK; #endif #if OS_WINCE _2007-Sep-25 21:22:40 by anonymous:_ {linebreak} 4th time this was reported. Cygwin appears to be a popular platform. ------- Duplicate of #2642 #c8c8c8 2667 code closed 2007 Sep anonymous 2007 Oct 1 1 no such function: hex no such function: regexp I am using SQLite 3 with pysqlite. I have few triggers that uses regexp and hex functions. on linux it worked fine. Once I switch to Windows I am getting no such functions errors. _2007-Oct-01 13:35:49 by drh:_ {linebreak} The regexp function is not supported by SQLite. hex() is supported but we are unable to find anything wrong with it. #cfe8bd 2666 doc fixed 2007 Sep anonymous 2007 Oct 4 4 Typos/spelling errors in sqlite3.h I don't want to be a pain in the backside, but here are some spelling errors I've spotted in sqlite3. They're all from sqlite3.h, and are all present as of the 3.5 alpha. ** The sqlite3_errmsg() and sqlite3_errmsg16() return English-langauge

    int *pAutoinc /* OUTPUT: True if colums is auto-increment */
    Note: The intention here was probably column, not columns.

    ** When the virtual-table mechanism stablizes, we will declare the
    Note: This error occurs twice.

    ** The optimizer automatically inverts terms of the form "expr OP column"
    ** and makes other simplificatinos to the WHERE clause in an attempt to


    ** be taylored to the specific needs of the module implementation. The

    #c8c8c8 2663 code closed 2007 Sep anonymous 2007 Oct 3 3 Adding a column with default value not reflected in view When adding a column to a table using alter table any default value for the column is not returned by a select using a view even if the view is recreated. Adding a single integer column to a table with a default value of 0. Any existing record correctly appears to have a value of 0 for the new column. However, if this table is used in a view, then the column appears to be NULL (the view has a select a.*, b.x from a, b where a.i = b.i; definition and we add a column to a). So, I then dropped the view and re-created it again because the schema of a has changed. However, the new column still appears to be NULL in the view whereas 0 is correctly displayed when a select from the table is done. This error occurs using sqlite3 and no code of ours. _2007-Sep-24 14:40:49 by anonymous:_ {linebreak} # sqlite3 f.db sqlite> create table a (a int); sqlite> create table b (b int); sqlite> create view ab as select a.*, b.* from a,b where a.a = b.b; sqlite> insert into a values (1); sqlite> insert into a values (2); sqlite> insert into a values (3); sqlite> insert into b values (2); sqlite> select * from ab; 2|2 sqlite> alter table a add column c int default 0; sqlite> select * from a; 1|0 2|0 3|0 sqlite> select * from ab; 2| sqlite> drop view ab; sqlite> create view ab as select a.*, b.* from a,b where a.a = b.b; sqlite> select * from ab; 2||2 sqlite> ---- _2007-Sep-24 14:43:26 by anonymous:_ {linebreak} Sorry, that should have read (and I also see that this is 3.3.5) $ sqlite3 f.db SQLite version 3.3.5 Enter ".help" for instructions sqlite> create table a (a int); sqlite> create table b (b int); sqlite> create view ab as select a.*, b.* from a,b where a.a = b.b; sqlite> insert into a values (1); sqlite> insert into a values (2); sqlite> insert into a values (3); sqlite> insert into b values (2); sqlite> select * from ab; 2|2 sqlite> alter table a add column c int default 0; sqlite> select * from a; 1|0 2|0 3|0 sqlite> select * from ab; 2| sqlite> drop view ab; sqlite> create view ab as select a.*, b.* from a,b where a.a = b.b; sqlite> select * from ab; 2||2 sqlite> ---- _2007-Oct-01 13:14:13 by drh:_ {linebreak} Unable to reproduce in 3.5.0. This problem appears to have been fixed already. ---- _2007-Oct-22 09:58:35 by anonymous:_ {linebreak} FYI: This problem was not present in 3.4.1 either #c8c8c8 2657 build closed 2007 Sep anonymous 2007 Oct anonymous 1 1 fail to compile I fail to compile. It is a "win32 static library" project. I simply create an empty project with "not using MFC" option and then add all files included in "sqlite-source-3_5_0.zip" into the project. Debug configuration is fine, but I cannot compile release. Information: ...sqlite-source-3_5_0\btree.c(3111) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'F:\9782\vc98\p2\src\P2\regasg.c', line 646) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information Error executing cl.exe. _2007-Sep-21 00:05:42 by anonymous:_ {linebreak} I have the same problem. I am using the preprocessed source code in sqlite-source-3_5_0.zip with Visual Studio 6.0 SP6. Compiler version: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 The offending line of btree.c is line 3111, which looks fairly innocent to me: pCur->aOverflow[iIdx] = nextPage; After investigating, it looks like this error is only emitted when global optimizations (/Og) are enabled, which is one of the switches set by optimizing for maximum speed. As a workaround, you can insert the line #pragma optimize("g", off) before line 3026 and the line #pragma optimize( "", on) after line 3156, which are the beginning and ending of the function static int accessPayload(BtCursor,int,int,unsigned char,int,int) This will disable global optimizations for the function, but leave them enabled for the rest of the file. {link: http://msdn2.microsoft.com/en-us/library/y19zxzb2(vs.71).aspx MSDN} has more information about error C1001, but it is not quite the same as what the VS6 docs say: {quote: This error is most often generated [due to] ... Failure of the code generator to find a way to generate correct code for a construct. This is most often caused by the interaction of an expression and an optimization option. The optimization has generated a tree which the compiler does not know how to handle. Such a problem can often be fixed by removing one or more optimization options when compiling the particular function containing the line indicated in the error message. } ---- _2007-Oct-12 18:53:47 by drh:_ {linebreak} In other words, there is a bug in MSVC++ that prevents it from correctly compiling SQLite. Shouldn't this be a problem reported to Microsoft? What exactly can we (the SQLite developers) do about this? Is there some simple code change that we can make to work around the bug in MSVC++? #c8c8c8 2656 doc closed 2007 Sep anonymous 2007 Oct 2 1 missing documentation: END TRANSACTION The documentation lists END [TRANSACTION] as a legal command, but does not describe it. It should be documented that is is the same as COMMIT [TRANSACTION]. Reference: http://www.mail-archive.com/sqlite-users@sqlite.org/msg03000.html _2007-Oct-01 13:32:34 by drh:_ {linebreak} The END TRANSACTION syntax works but it is unsupported. If I document it that means I will have to begin supporting it, which is something I do not want to do. ---- _2007-Oct-01 17:41:52 by anonymous:_ {linebreak} The END DOCUMENTATION *syntax* is documented - but it is not described what it does. While this might be intentional, I know about a novice user who was confused if he had to call END DOCUMENTATION after either COMMIT or ROLLBACK. If you decide not to document END DOCUMENTATION, you might want to think about not documenting it at all, in other words, remove the syntax declaration. ---- _2007-Oct-01 17:46:07 by drh:_ {linebreak} OK. We have added documentation for END TRANSACTION. ---- _2007-Oct-02 06:30:17 by anonymous:_ {linebreak} Thanks! #c8c8c8 2654 code closed 2007 Sep anonymous 2007 Oct jadams 1 1 sqlite3_prepare return 1(fail) result = sqlite3_exec( db, "create table MyTable_1sadsd ( ID integer primary key autoincrement, name nvarchar(32),comp nvarchar(32), file_content blob )",NULL, NULL, errmsg );//ok result=sqlite3_prepare(db,"insert into MyTable_1sadsd ( name,comp,file_content ) values ( 'aaaa','aaaaaa1',? )",-1,&stat,&zLeftover );//fail //the result==1 so fail; //but result = sqlite3_exec( db, "create table MyTable( ID integer primary key autoincrement, name nvarchar(32),comp nvarchar(32), file_content blob )",NULL, NULL, errmsg );//ok result=sqlite3_prepare(db,"insert into MyTable ( name,comp,file_content ) values ( 'aaaa','aaaaaa1',? )",-1,&stat,&zLeftover );//ok //is ok ,because MyTable is shorter than MyTable_1sadsd ; //why ? tks It's not clear from the report. There's nothing wrong with the SQL or th e C code shown. Maybe some other process is changing the schema or locking the dataabase or something. If you can post a complete program that demonstrates the problem, we will be able to help you. #c8c8c8 2639 code closed 2007 Sep anonymous 2007 Oct 1 2 Russian charset At implementation of query, Russian charset is inserted like a "􏻂􏻮􏻫" _2007-Sep-12 02:29:24 by drh:_ {linebreak} I do not understand the complaint. But a good guess is that you are trying to use a codepage of some kind in a TEXT entry. SQLite understands only Unicode - either UTF8 or UTF16. Translate all of your strings into one of these encodings first, before inserting them into the database, if you want them to be compared correctly. If you do not want to use unicode, insert your data as BLOBs instead of a strings. #c8c8c8 2630 code closed 2007 Sep anonymous 2007 Oct a.rottmann 2 2 sqlite3PagerOpen set a wrong temp file name in pPager->zFilename in pager.c line 1783{linebreak} 1783 rc = sqlite3PagerOpentemp(&fd);{linebreak} 1784 sqlite3OsTempFileName(zTemp);{linebreak} 1785 zFilename = zTemp;{linebreak} 1786 zFullPathname = sqlite3OsFullPathname(zFilename);{linebreak} 1787 if( rc==SQLITE_OK ){{linebreak} 1788 tempFile = 1;{linebreak} .{linebreak} .{linebreak} .{linebreak} 1823 memcpy(pPager->zFilename, zFullPathname, nameLen+1);{linebreak} function sqlite3PagerOpentemp on line 1783 open the fd using e new temp file name{linebreak} but the the function on 1784 get another temp file name and {linebreak}assign it to pPager->zFilename on line 1823 I compile sqlite on POCKETPC and temp file were not delete automatically by the OS{linebreak} so I have uncommented the code that delete temp file in function sqlite3PagerClose{linebreak} /* Temp files are automatically deleted by the OS*/{linebreak} if( pPager->tempFile ){{linebreak} sqlite3OsDelete(pPager->zFilename);{linebreak} }{linebreak} but the sqlite3OsDelete(pPager->zFilename); use the wrong temp file name. I have change the previous code with this one. 1783 // rc = sqlite3PagerOpentemp(&fd);{linebreak} 1784 sqlite3OsTempFileName(zTemp);{linebreak} 1785 zFilename = zTemp;{linebreak} 1786 zFullPathname = sqlite3OsFullPathname(zFilename);{linebreak} {linebreak} 1787 do{{linebreak} 1788 cnt--;{linebreak} 1789 rc = sqlite3OsOpenExclusive(zFullPathname, &fd, 1);{linebreak} 1790 assert( rc!=SQLITE_OK || fd );{linebreak} 1791 }while( cnt>0 && rc!=SQLITE_OK && rc!=SQLITE_NOMEM );{linebreak} 1792{linebreak} 1793 if( rc==SQLITE_OK ){{linebreak} 1794 tempFile = 1;{linebreak} 1795 }{linebreak} and all is fine.{linebreak} I hope this is useful.{linebreak} thanks.{linebreak} by.{linebreak} _2007-Sep-06 23:25:20 by drh:_ {linebreak} The code in question was restructured and rewritten for SQLite version 3.5.0. But looking into this did bring to my attention a bug in the implementation of 3.5.0, for which I am grateful. #c8c8c8 2603 new closed 2007 Aug anonymous 2007 Oct 1 3 B-tree and B+tree allow bidirectional cursor but VDBE does not. B-tree and B+tree allow bidirectional cursor but VDBE does not. We would very much like to have this capability and our fallback is to work with the btree api directly. the closest opcodes are: rewind p1 p2 p3 p1 is p2 is line number if rowcount=p1 and step What we would like to see is something like rstep p1 p1= signed integer for direction of relative motion repos p1 p2 p1=unsigned integer representing low-order 32 bits of 64 bit integer p2=unsigned integer representing hi-order 32 bits of 64 bit integer If this is doable in your opinion then we would be willing to look at implementing it and contributing it to the project. _2007-Oct-12 18:58:46 by drh:_ {linebreak} I'm not really sure what the description above is saying, but my best guess is that it is a request for logic to do a ScrollingCursor. Please see the wiki page for how to accomplish ScrollingCursor in SQLite. #c8c8c8 2601 code closed 2007 Aug anonymous 2007 Oct 1 1 Problem with opening database with Unicode filename Problem with opening database with Unicode filename - it doesn't open the database with Unicode filename or path. The description contains insufficient information for us to act on the problem. #cfe8bd 2598 code fixed 2007 Aug anonymous 2007 Oct 3 3 Failure to delete temporary files on WINCE platforms Problem lies in the sqlite3WinOpenExclusive function. Under WINCE platform, winFile.hMutex is set to NULL (line 822 of os_win.c) even though winFile.zDeleteOnClose is set. So when winceDestroyLock (called from winClose) is eventually called, because hMutex is NULL, the file is never deleted. #cfe8bd 2597 code fixed 2007 Aug anonymous 2007 Oct 1 1 tclsqlite "db eval" with array-name doesn't have "*" entry. (tcl8.5a7) This problem was caused on tcl cvs head(tcl8.5a7) only. Tcl8.4 and 8.5a6 doesn't have the problem. package require sqlite3 sqlite db :memory: db eval "create table t (c1, c2, c3)" db eval "PRAGMA empty_result_callbacks = on" db eval "select * from t" val "" puts [array get val] I expected a value "* {c1 c2 c3}", but the val(*) entry didn't exist. It seems to me that "Tcl_DecrRefCount(pStar);" cause the problem... _2007-Aug-30 03:18:14 by anonymous:_ {linebreak} I'm sorry for the bad format. package require sqlite3{linebreak} sqlite db :memory:{linebreak} db eval "create table t (c1, c2, c3)"{linebreak} db eval "PRAGMA empty_result_callbacks = on"{linebreak} db eval "select * from t" val ""{linebreak} puts [array get val]{linebreak} #c8c8c8 2585 code closed 2007 Aug anonymous 2007 Oct anonymous 1 1 Error Function GetAtomNameA The Procedure entry point GetAtomNameA could not be located in the dynamic link library sqlite3.dll Using CodeBlock _2007-Oct-05 15:11:29 by drh:_ {linebreak} Nothing in SQLite invokes GetAtomNameA(). This must be a problem with some other library. #cfe8bd 2579 code fixed 2007 Aug anonymous 2007 Oct 4 3 the third parameter of substr should be optional Please make the 3rd Parameter of SUBSTR optional as in most other programming languages. It is better and simpler for migrations to SQLite #cfe8bd 2550 code fixed 2007 Aug anonymous 2007 Oct drh 3 3 Lemon parser may accept input before EOF is seen A lemon parser with table compression may accept input before EOF is seen. This can happen even without any syntax errors being reported. Consider this little lemon grammar: %parse_accept{printf("parse accept\n");} %syntax_error{printf("syntax error\n");} %parse_failure{printf("parse failure\n");} start ::= foobar. foobar ::= FOO. foobar ::= foobar BAR. This grammer describes input that matches the regular language FOO BAR*, i.e. one FOO followed by zero or more BARs. This grammar shows how lemon breaks: When this grammar is fed the input FOO BAR FOO FOO BAR, it will accept twice: the second FOO acts as the EOF terminal after the initial FOO BAR and gets eaten by the parser without error. The parser then accepts and resets itself for new input. The remainder of the input is again a valid FOO BAR, giving rise to the second accept. More precisely, lemon has the following logic error: The accept action is triggered at the end of a reduce action of a start rule (that has the start symbol at the left hand side), when that start symbol is about to be pushed onto the stack. This (normally) works because the start symbol may not be used on the right hand side of a rule, so EOF can be the only follower terminal of a start rule. Unfortunately, in the presence of default rules, a start rule can be used as the default rule, and it can be reduced even when the lookahead symbol is not EOF. I see two ways of fixing this: 1:Before accepting, make sure the lookahead symbol is really EOF. 1:Refuse to reduce a start rule without the lookahead symbol actually being EOF. Option 1 seems nice, but is not really user friendly with lemon as it has been set up now: the accept action is not really usable as the final indication that all is well, because it has no access to the parse tree in the minor value of the start symbol for returning to the calling program (through the extra parameter). With option 2, reduction of a start rule is really the last action of the parser (alright, except for the parse_accept action). Normally, I'd say a user uses the start rules for returning the parse tree to the lemon caller, and this is the more naturaly way to do it. Option 2 has an additional advantage that, in combination with judicious placement of error symbols in the start rule, it remains possible to parse remaining input. This would not be possible if a start rule were reduced prematurely as under option 1, because then the parser would have to go to a state where it discards all remaining input (or it would have to call parse_failure) without actually parsing the remaining input. Ciao. Vincent. _2007-Sep-27 08:42:25 by anonymous:_ {linebreak} YES!!! I have this error too :-(( Please ... fix it. Thanks, Alexander. #cfe8bd 2548 code fixed 2007 Aug anonymous 2007 Oct anonymous 4 4 Pelles C compiler for Windows ANSI prototype / K&R declaration errors Compiling for Windows using the PellesC compiler suite. Mismatches between ANSI style prototypes and K&R style function declarations are reported as errors. All the error reports are of the form: ...\main.c(1235): error #2120: Redeclaration of 'sqlite3_global_recover' previously declared at ...\sqlite3.h(1693): found 'void _cdecl function' expected 'void _stdcall function(void)'. 1. In main.c at line 1235 need to change int sqlite3_global_recover(){ to int sqlite3_global_recover(void){ 2. In malloc.c at line 809 need to change int sqlite3FailedMalloc(){ to int sqlite3FailedMalloc(void){ 3. In os_win.c at line 1613 need to change int sqlite3WinEnterMutex(){ to int sqlite3WinEnterMutex(void){ 4. In os_win.c at line 1630 need to change int sqlite3WinLeaveMutex(){ to int sqlite3WinLeaveMutex(void){ 5. In util.c at line 706 need to change int sqlite3ThreadData(){ to int sqlite3ThreadData(void){ 6. In util.c at line 719 need to change int sqlite3ThreadDataReadOnly(){ to int sqlite3ThreadDataReadOnly(void){ 7. In util.c at line 730 need to change int sqlite3ReleaseThreadData(){ to int sqlite3ReleaseThreadData(void){ ----end of report---- #cfe8bd 2546 code fixed 2007 Jul anonymous 2007 Oct 4 1 Comments are not parsed correctly When I try to insert a new record in a table with the .read command , I cannot load data whose line terminate with a comment. I always get an "Incomplete SQL" error. file content: INSERT INTO _users_parameters VALUES (1,1); -- temperature sqlite> .read smartdas.sql Incomplete SQL: INSERT INTO _users_parameters VALUES (1,3); -- temperature file content: INSERT INTO _users_parameters VALUES (1,1); /* temperature*/ sqlite> .read smartdas.sql Incomplete SQL: INSERT INTO _users_parameters VALUES (1,3); /* temperature */ If I remove the comment, then the row is inserted as expected: file content: INSERT INTO _users_parameters VALUES (1,1); sqlite> .read smartdas.sql sqlite> select * from _users_parameters; 1|1 Thanks, Paolo Saudin #cfe8bd 2533 code fixed 2007 Jul anonymous 2007 Oct 1 2 temporary files are not deleted on WinCe temporary files are not deleted on WinCe if they are not locked. hMutex is false in struct pFile. function: static void winceDestroyLock(winFile *pFile) line: 16490 in sqlite3.c from sqlite-amalgamation-3_4_1.zip problem: delete temporary files only if pFile->hMutex is true if (pFile->hMutex){ ... if( pFile->zDeleteOnClose ){ DeleteFileW(pFile->zDeleteOnClose); sqliteFree(pFile->zDeleteOnClose); pFile->zDeleteOnClose = 0; } ... } solution: delete temporary files not dependend if pFile->Mutex is true or not if (pFile->hMutex){ ... ... } if( pFile->zDeleteOnClose ){ DeleteFileW(pFile->zDeleteOnClose); sqliteFree(pFile->zDeleteOnClose); pFile->zDeleteOnClose = 0; } regards Juergen Wolters Temporary files never create a lock object, so the hMutex member is always null. Since there is no mutex to cleanup, winceDestroyLock() is never called and temporary files are never deleted. Checkin [3836] needs to be reverted and the original ticket which triggered it re-opened. #c8c8c8 2519 new closed 2007 Jul anonymous 2007 Oct 1 1 Page cache and schema should be shared between all connections/threads The current shared cache scheme is too restrictive to use easily in a multi-threaded application. The page cache should be shared between all connections/threads, as the database file itself is a global resource. If the schema is changed in one thread connection, all other thread connections should pick up the change automatically. Mutexes should be used for coordination as appropriate. Advantages of thread-agnostic shared cache/schema approach: *: reduced memory use due to cache sharing in a multi-threaded/multi-connection program *: simpler usage model for multiple connections so that the programmer need not be concerned with what thread created the connection, or using starting a dummy transaction with an insert into a dummy table in order to {link: http://developer.mozilla.org/en/docs/Storage:Performance#Keeping_the_cache_between_transactions keep the cache between transactions} *: eliminate the schema/thread/connection mismatch problem #2486 *: fewer system resources - use just a single file descriptor for multiple connections to the same database file, since it is a global resource. This would avoid file descriptor problems related to the Linux 2.4 kernel. *: improved concurrency for connections in multiple threads _2007-Jul-26 18:39:20 by anonymous:_ {linebreak} the database file is a global resource, the sqlite handle is not. imagine if you start a transaction in a thread then another thread start another transaction... if you use two sqlite handles, this is ok, because you can lock a file handle for the transactions. since sqlite doesn't provide nested transactions, you should avoid thinking a sqlite handle object is a global resource. this is explicit well documented. ---- _2007-Jul-26 19:49:57 by anonymous:_ {linebreak} That's the problem with the current implementation. There is no need for multiple file descriptors to the same database file, since it is a global resource. There should be only a single file handle shared between all threads and connections. Access to this common file handle should be coordinated via proper mutexes between threads. ---- _2007-Jul-26 20:11:09 by anonymous:_ {linebreak} right again, neither ADO / SQL Server provider in ADO / Microsoft world suport a shared handle (connection object) properly. nobody implements this just because tx control should be done by program, not by database layer driver. ---- _2007-Jul-26 20:19:24 by anonymous:_ {linebreak} Whether there is 1 connection or 50 connections to the same database, the *database file page cache*, a global resource, must be the same in all cases. Don't confuse the page cache with a journal file. ---- _2007-Jul-26 20:45:01 by anonymous:_ {linebreak} suppose you have a main program and a shared library. the two linked static against a sqlite amalgamation, with different versions (e.g. 3.3.14 main program and 3.4.1 shared library). if the pager cache internal structures changed against versions (which could happen), sqlite is going to be crazy and doing worst. also, not all os platforms works like other in memory management. they could have different memory virtual address (in windows, dll memory is protected from program memory if it uses the malloc allocator, with globalalloc things performs differently). since sqlite is multi-platform, it's not cool to put a per-platform feature. a 'possible' (?) workaround is to use a per-process shared memory to implement this, but not all os'es sqlite compile and run may support it to implement this design. ---- _2007-Jul-26 20:53:27 by anonymous:_ {linebreak} The proposed in-process shared database page cache has nothing to do with virtual shared memory or shared libraries. If the in-memory database change counter matches that of the locked database file, we can assume that the in-memory database page cache is current - regardless of whatever sqlite3 connection or thread we're on. ---- _2007-Aug-10 20:33:49 by anonymous:_ {linebreak} using the same file descriptor should not work. locking engine in sqlite is file-locked base. testing in a process within various threads if you could lock a region of the file will not work if sqlite is changed this way. again, not usual and you should realize you can use various sqlite versions inside the same program using amalgamations. ---- _2007-Aug-10 21:25:12 by anonymous:_ {linebreak} Of course using a single file descriptor would work. There is only 1 underlying database file - why on earth do you need more than 1 descriptor to access it? That's what mutexes are for. Regarding putting multiple sqlite3 engines in the same binary, no one has ever done this before, as it was not even possible until 2 days ago (Ticket #2554). But if you wanted to support the old style multi-descriptor file locking, it could be done with an appropriate compile flag -DOMIT_SINGLE_FILE_DESCRIPTOR like every other feature in sqlite. ---- _2007-Aug-10 23:36:34 by anonymous:_ {linebreak} you didn't get the issue. suppose (in my case), I have two DLL´s (shared libraries) that are linked statically against sqlite. if I build a updated DLL with different versions of SQLite, e.g., 3.2.5 (on old dll´s) and 3.4.1 (on the updated dll), sqlite in-memory structures would not be the same layout (new fields, features, etc). this is very dangerous in my point of view. I preffer paying the penalty reading from disk and keep things going smoothly. ---- _2007-Aug-11 00:46:16 by anonymous:_ {linebreak} Okay, keep it running smoothly. ---- _2007-Oct-04 01:02:32 by anonymous:_ {linebreak} Must manually enable shared cache via: http://www.sqlite.org/capi3ref.html#sqlite3_enable_shared_cache #c8c8c8 2490 code closed 2007 Jul anonymous 2007 Oct 1 1 Latest cvs 3.4.0 seg fault This problem is the same with 3.3.1.13, Fedora's 3.4.0 and the debug version I just built. Using latest Fedora and perl modules: net1#r mx mxaddrs ... perl : 5.8.8 DBI : 1.58 DBD::SQLite : 1.13 SQLite::DBMS: 3.4.0.1 Code is simple db create and inserts. Problem only occurs when a DBI sth->prepare() is used with multiple execute inserts of duplicate data. Instead of returning an error seg fault occurs. If required I can try and put together a small code sample. _2007-Jul-07 06:25:54 by anonymous:_ Why do you think its pure SQLite problem ? ---- _2007-Jul-07 11:46:55 by drh:_ {linebreak} To amplify the remark by anonymous above: what makes you think this is a problem with SQLite and not a problem with perl or the DBD::SQLite module? We have run literally millions of test cases through the core SQLite without hitting any segfaults, yet you say that a simple test case is sufficient to cause the problem. That would seem to implicate DBD::SQLite rather than the SQLite core, would it not? Please tell us why you think this is an SQLite problem. And please also provide us with a reproducible test case, keeping in mind that the core SQLite developers do not normally have DBD::SQLite installed. ---- _2007-Aug-10 15:18:32 by anonymous:_ {linebreak} This is a DBD::SQLite bug. See http://rt.cpan.org/Public/Bug/Display.html?id=28757 for a test case and a patch. Mike #f2dcdc 2392 code active 2007 May anonymous 2007 Oct 4 4 Reduce MemPage and PgHdr struct sizes. Better page memory utilization. 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 */ #c8c8c8 2277 code closed 2007 Mar anonymous 2007 Oct 1 1 Incorrect usage of CRITICAL_SECTION and TLS on Windows We found this problem during our product certification for MS Vista. SQLITE.DLL breaks into WinDbg when been (a) used (b) unloaded. The reasons are (1) Initialized CRITICAL_SECTION, which was created, but not deleted, (2) Allocated index in TLS, which was not deleted as well. We fixed both of then in our local copy of source code. Plese, contact me slava@raxco.com if you need the changes. _2007-May-22 22:14:39 by anonymous:_ {linebreak} Can you post the changes here? ---- _2007-Jun-27 20:58:25 by anonymous:_ {linebreak} What CRITICAL_SECTION is causing this bug ? Can you post your patches (or the fixes) here ? will help us a lot ---- _2007-Jul-28 21:16:33 by anonymous:_ {linebreak} The CRITICAL_SECTION being referenced is: static CRITICAL_SECTION cs declared in os_win.c The thread local storage in reference is acquired in sqlite3WinThreadSpecificData(). The critical section is never destroyed via DeleteCriticalSection and will therefore appear as a leaked resource. The TlsAlloc is never matched to a TlsFree and again will appear as a leaked resource. As a side note, the double checked locking used in sqlite3WinThreadSpecificData() to guard against multiple TLS allocations may or may not survive compiler optimization. The same is true of the spin/sleep in sqlite3WinEnterMutex(). Worst case the compiler generates code that loops indefinately. Possibly the best solution to these problems is to introduce an API for initializing the critical section and TLS index. Along with an API to perform the inverse. It would the responsiblity of the programmer to ensure that these APIs are called in a thread safe manner prior to the use of any other sqlite APIs. This would be easily achieved by inclusion in the main() of an executable or the initialization and finalization exports for a DLL. ---- _2007-Jul-31 05:27:48 by anonymous:_ {linebreak} IMO this is a non-issue. the Tls index is allocated the first time it's needed, and never needs to be deallocated until the program terminates. Same with the critical section. You can't "leak" something that only gets allocated one time, and is automatically freed by the operating system when the calling program terminates. ---- _2007-Oct-12 19:33:55 by drh:_ {linebreak} As of version 3.5.0, SQLite no longer uses TLS. #f2dcdc 55 new active 2002 Jun anonymous 2007 Oct drh 5 3 instead of triggers for inserts (updates) on regular tablesxx 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:_ {linebreak} {link: http://www.sqlite.org/lang_createtrigger.html create trigger syntax} :{linebreak} 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 ) #f2dcdc 2677 new active 2007 Sep anonymous 2007 Sep danielk1977 5 3 CREATE TRIGGER .. {databaseevent ON ... }+ for multiple events 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? {linebreak} 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. #c8c8c8 2676 code closed 2007 Sep anonymous 2007 Sep 1 1 TEMP_STORE does not appear to be set by the compile time switch The compile time switch -DTEMP_STORE=2 does not appear to change TEMP_STORE. When a database is created after compiling the library I tried to view temp_store by using PRAGMA temp_store which returns the value 0. If this is true that would force all temp storage to a file. I want temp storage to be in memory. It's more complex than that. See the table at: http://www.sqlite.org/pragma.html#pragma_temp_store #c8c8c8 2675 new closed 2007 Sep anonymous 2007 Sep 1 1 TEMP_STORE does not appear to be set by the compile time switch The compile time switch -DTEMP_STORE=2 does not appear to change TEMP_STORE. When a database is created after compiling the library I tried to view temp_store by using PRAGMA temp_store which returns the value 0. If this is true that would force all temp storage to a file. I want temp storage to be in memory. See #2676 #f2dcdc 2674 code active 2007 Sep anonymous 2007 Sep 3 4 NFS fails without lock manager *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 ~ # [__db_init .c:384] Statement: CREATE TABLE versions ( id INTEGER PRIMARY KEY AUTOINCREMENT, version INTEGER, tbl CHAR(256) ); Failed with error: database is locked [main .c:1096] Unable to init output DB: /mnt/nfs/o dev-srs08 ~ # /etc/init.d/nfslock start Starting NFS statd: [ OK ] dev-srs08 ~ # dev-srs08 ~ # _2007-Sep-28 04:35:00 by anonymous:_ {linebreak} Yet another reason to avoid using SQLite on remote shares. ---- _2007-Sep-29 18:04:19 by anonymous:_ {linebreak} _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- #f2dcdc 2671 code active 2007 Sep shess 2007 Sep shess 2 4 Fts field-based queries are not correctly case-insensitive. 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. #c8c8c8 2669 code closed 2007 Sep anonymous 2007 Sep anonymous 2 3 INSERT of Large REAL value fails with Floating Point Exception When inserting a large number as a REAL value, a Floating Point Invalid Operation exception is thrown. This occurs in the "sqlite3VdbeIntegerAffinity" function in the "vdbemem.c" source, on the line "pMem->i = pMem->r". This exception is only thrown when the value in pMem->r is outside the range of a signed I64 value. The following is a work-around that seems to suppress the exception and produce no adverse affects on the content of the database: /* ** @date Added 9/26/07 - ESK -- Include needed for the _I64_MIN and _I64_MAX defines */ #include /* ** The MEM structure is already a MEM_Real. Try to also make it a ** MEM_Int if we can. */ void sqlite3VdbeIntegerAffinity(Mem *pMem){ assert( pMem->flags & MEM_Real ); /* ** @date 9/26/07 - ESK -- Added conditional to check for a double value that is ** outside the range of the __int64 value (when the value is out of the range it ** throws a invalid floating point operation exception). */ if (( pMem->r > _I64_MAX ) || ( pMem->r < _I64_MIN )){ pMem->i = 0; }else{ pMem->i = pMem->r; } if( ((double)pMem->i)==pMem->r ){ pMem->flags |= MEM_Int; } } At the time of the exception, pMem->r is equal to 3.8E+49. The library was compiled under Borland C++ Builder 5 on the Windows Platform (2k and XP). This issue has only occurred for us when pulling data out of a database (that originally accepted the real value that was inserted) and inserting the data into another database. The problem occurs when calling sqlite3_step with a sqlite3_stmt struct, after binding the REAL value to the structure. I'm not sure if this floating point exception will present in any other location, since this is the only location we've seen it in so far. This issue may or may not be related to Ticket #2586. _2007-Sep-26 15:10:55 by anonymous:_ {linebreak} Please provide a few line standalone SQL example with schema that reproduces what you're seeing. ---- _2007-Sep-26 15:26:59 by anonymous:_ {linebreak} To be more specific, please provide a few line standalone SQL example with schema that reproduces what you're seeing using the sqlite3 commandline shell program. http://www.sqlite.org/sqlite-3_5_0.zip ---- _2007-Sep-26 23:34:56 by anonymous:_ {linebreak} We cannot replicate the issue using the sqlite3.exe utility. However the following code sample does demonstrate how to reproduce the exception (the exception occurs within the call to sqlite3_step): #include "sqlite3.h" int main(int argc, char* argv[]) { sqlite3 *pDB; int ret; char *errmsg = NULL; sqlite3_stmt *pStmt; ret = sqlite3_open ("database.db", &pDB); ret = sqlite3_exec (pDB, "CREATE TABLE POS_NUMERIC (MAIN_ID INTEGER, NUMERIC_VALUE REAL )", 0, 0, &errmsg); if ( errmsg ){ free (errmsg); } ret = sqlite3_prepare (pDB, "INSERT INTO POS_NUMERIC (MAIN_ID, NUMERIC_VALUE) VALUES (?, ?)", -1, &pStmt, 0); sqlite3_bind_text (pStmt, 1, "1234", strlen ("1234"), SQLITE_TRANSIENT); sqlite3_bind_text (pStmt, 2, "3.8E49", strlen ("3.8E49"), SQLITE_TRANSIENT); ret = sqlite3_step (pStmt); sqlite3_finalize (pStmt); pStmt = NULL; ret = sqlite3_close (pDB); return 0; } ---- _2007-Sep-27 01:07:15 by anonymous:_ {linebreak} Your program works fine here with gcc, and the database has the correct values. What compile flags did you use for Borland C++? Can you run this program? #include #include #include "sqlite3.h" void p(char* z) { puts(z); sqlite3_free(z); } int main() { sqlite_int64 i; double r = atof("3.8E49"); printf("sizeof(sqlite_int64) = %d\n", sizeof(sqlite_int64)); p(sqlite3_mprintf("r = %f", r)); i = r; if ((double)i == r) puts("can fit into sqlite_int64"); else puts("can not fit into sqlite_int64"); return 0; } It should produce: sizeof(sqlite_int64) = 8 r = 38000000000000000000000000000000000000000000000000.000000 can not fit into sqlite_int64 ---- _2007-Sep-27 01:14:21 by anonymous:_ {linebreak} It's a Borland bug. You have to set the FPU control word as follows to avoid these floating point exceptions. _control87(MCW_EM, MCW_EM); See: http://www.virtualdub.org/blog/pivot/entry.php?id=53 http://homepages.borland.com/ccalvert/TechPapers/FloatingPoint.html #c8c8c8 2665 code closed 2007 Sep anonymous 2007 Sep 3 1 Dissapearing exclusive lock when DB is copied... In our application, we occasionally need to make copies of a running database. To insure consistancy, the program does something like this (in python): # we're about to lock the db{linebreak} dbcursor.execute('begin exclusive'){linebreak} # the db is now locked{linebreak} shutil.copy('database.db','other-name.db'){linebreak} # WHOAH, what happened to our lock on database.db??????{linebreak} the comments indicate the locking status at each time. I've got a workaround, which amounts to: # we're about to lock the db{linebreak} dbcursor.execute('begin exclusive'){linebreak} # the db is now locked{linebreak} os.system('cp database.db other-name.db'){linebreak} # database.db is still locked, but other-name.db is not locked{linebreak} which is more or less what I'd expect. Is this copying of databases totally evil? Why does a copy made by a process that has an exclusive lock on the origin of the copy destroy the exclusive lock? Why doesn't a copy by a different process destroy it? _2007-Sep-25 18:30:59 by anonymous:_ {linebreak} The problem is shutil.copy('database.db','other-name.db') must be unlocking the file or doing something altogether wrong. Run strace/truss to confirm. ---- _2007-Sep-25 18:32:06 by drh:_ {linebreak} On unix, when you close a file, all locks on that file held by the same process are cleared - even locks that were created by separate file descriptors. You are probably closing the file at the conclusion of your copy, which is clearing the locks. This "feature" of unix is brought to you by The Open Group. After a while, you learn to clearly see the differences between those parts of unix that were designed by Thompson and Richie and those parts developed by committee. Would that there was more of the former and less of the latter... ---- _2007-Sep-25 18:52:38 by anonymous:_ {linebreak} How can we get the UNIX file descriptor for the sqlite3* connection from the sqlite3 API so that we do not have to reopen and ultimately close the file, thus clearing the locks? ---- _2007-Sep-25 19:12:05 by anonymous:_ {linebreak} I've run strace, and the results are exactly what you'd expect; the shutil.copy() command opens the FD for creating. opens the destination FD, and writes out a copy. Also; the bug dissapears if you replace the shutil.copy() with something like: os.system('python -e "shutil.copy(...."') so it's not the mechanics of shutil.copy, but instead is because of the same processness of doing the copy. Sorry for not including that earlier! ---- _2007-Sep-26 12:09:00 by anonymous:_ {linebreak} Maybe you could consider introducing new API - sqlite3_backup(sqlite3*, const char*), or new SQL command BACKUP(FileName) which would backup main database to specified file using (exclusive?) lock. I don't see far to SQLite internals, but I hope this change could also provide functionality for saving in-memory databases to disk. #f2dcdc 2664 code active 2007 Sep danielk1977 2007 Sep 1 1 attaching the same db twice in shared-cache mode fails 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 #c8c8c8 2662 code closed 2007 Sep anonymous 2007 Sep 1 1 Serious Performance Degradation from 3.3.4 to 3.3.5 & latest versions Starting from 3.3.5, SQLite suffers a serious performance degradation for the following schema and query. 3.3.4 returnes results *immedialtely*, all later versions take considerable time (multiple seconds) to execute the query. The database is about 6 MB in size. Schema: CREATE TABLE MTV20030105AdLink (AdvertisementID Numeric, AdRelationShipID Numeric, AgencyID Numeric, AdvertiserID Numeric, ProductID Numeric); CREATE TABLE MTV20030105AdType (ADTypeID Numeric, AdTypeName char(50)); CREATE TABLE MTV20030105Adjacency (AdInstID Numeric, ProductID Numeric); CREATE TABLE MTV20030105Advertiser (AdvertiserID Numeric, AdvertiserName char(50)); CREATE TABLE MTV20030105Agency (AgencyID Numeric, AgencyName char(50)); CREATE TABLE MTV20030105Products (ProductID Numeric, ProductName char(50)); CREATE TABLE MTV20030105Programs (ProgramID Numeric, ProgramName char(50)); CREATE TABLE MTV20030105Spots (AdInstID Numeric, AdvertisementID Numeric, KeyNumber char(15), StationID Numeric, SpotDateTime DateTime, Duration Numeric, BreakNumber Numeric, NumAdsInBreak Numeric, PositionInBreak Numeric, PromoBefore Numeric, PromoAfter Numeric, AdTypeID Numeric, CommentID Numeric, ProgramID Numeric, MarketInd Numeric); CREATE TABLE MTV20030105Stations (StationID Numeric, NetworkID Numeric, NetworkName char(50), CallSign char(50), LeadMarketInd Numeric); CREATE INDEX MTV20030105AdLink_i1 ON MTV20030105AdLink(ProductID); CREATE INDEX MTV20030105Spots_i1 ON MTV20030105Spots (AdvertisementID); Query: select SpotDateTime,NetworkName,CallSign,KeyNumber,Duration,ProgramName from MTV20030105Spots,MTV20030105Stations,MTV20030105Programs where MTV20030105Spots.AdvertisementID in (select AdvertisementID from MTV20030105AdLink where productid=90887) and MTV20030105Stations.StationID=MTV20030105Spots.StationID and MTV20030105Programs.ProgramID=MTV20030105Spots.ProgramID; "ANALYZE;" was not executed with any version of SQLite, and running it does not speed up the query with recent versions. I can provide the test database if required, just let me know. _2007-Sep-24 14:49:29 by anonymous:_ {linebreak} This is not a bug. This question belongs on the mailing list. If you run "EXPLAIN QUERY PLAN" on your SELECT you can see that your schema is not optimal, and results in full table scans for stations and programs: 0|1|TABLE MTV20030105Stations 1|2|TABLE MTV20030105Programs 2|0|TABLE MTV20030105Spots WITH INDEX MTV20030105Spots_i1 0|0|TABLE MTV20030105AdLink WITH INDEX MTV20030105AdLink_i1 If you change your schema as follows, it will use the indexes effectively: CREATE TABLE MTV20030105AdLink (AdvertisementID Numeric, AdRelationShipID Numeric, AgencyID Numeric, AdvertiserID Numeric, ProductID Numeric); CREATE TABLE MTV20030105AdType (ADTypeID INTEGER PRIMARY KEY, AdTypeName char(50)); CREATE TABLE MTV20030105Adjacency (AdInstID INTEGER PRIMARY KEY, ProductID Numeric); CREATE TABLE MTV20030105Advertiser (AdvertiserID INTEGER PRIMARY KEY, AdvertiserName char(50)); CREATE TABLE MTV20030105Agency (AgencyID INTEGER PRIMARY KEY, AgencyName char(50)); CREATE TABLE MTV20030105Products (ProductID INTEGER PRIMARY KEY, ProductName char(50)); CREATE TABLE MTV20030105Programs (ProgramID INTEGER PRIMARY KEY, ProgramName char(50)); CREATE TABLE MTV20030105Spots (AdInstID Numeric, AdvertisementID Numeric, KeyNumber char(15), StationID Numeric, SpotDateTime DateTime, Duration Numeric, BreakNumber Numeric, NumAdsInBreak Numeric, PositionInBreak Numeric, PromoBefore Numeric, PromoAfter Numeric, AdTypeID Numeric, CommentID Numeric, ProgramID Numeric, MarketInd Numeric); -- assumes that StationID is a unique identifier CREATE TABLE MTV20030105Stations (StationID INTEGER PRIMARY KEY, NetworkID Numeric, NetworkName char(50), CallSign char(50), LeadMarketInd Numeric); CREATE INDEX MTV20030105AdLink_i1 ON MTV20030105AdLink(ProductID); CREATE INDEX MTV20030105Spots_i1 ON MTV20030105Spots (AdvertisementID); explain query plan select SpotDateTime,NetworkName,CallSign,KeyNumber,Duration,ProgramName from MTV20030105Spots,MTV20030105Stations,MTV20030105Programs where MTV20030105Spots.AdvertisementID in (select AdvertisementID from MTV20030105AdLink where productid=90887) and MTV20030105Stations.StationID=MTV20030105Spots.StationID and MTV20030105Programs.ProgramID=MTV20030105Spots.ProgramID; 0|0|TABLE MTV20030105Spots WITH INDEX MTV20030105Spots_i1 1|1|TABLE MTV20030105Stations USING PRIMARY KEY 2|2|TABLE MTV20030105Programs USING PRIMARY KEY 0|0|TABLE MTV20030105AdLink WITH INDEX MTV20030105AdLink_i1 ---- _2007-Sep-24 15:12:03 by anonymous:_ {linebreak} This query is faster: explain query plan select SpotDateTime,NetworkName,CallSign,KeyNumber,Duration,ProgramName from (select AdvertisementID from MTV20030105AdLink where productid=90887) ads, MTV20030105Spots, MTV20030105Stations, MTV20030105Programs where MTV20030105Spots.AdvertisementID = ads.AdvertisementID and MTV20030105Stations.StationID=MTV20030105Spots.StationID and MTV20030105Programs.ProgramID=MTV20030105Spots.ProgramID; 0|0|TABLE MTV20030105AdLink WITH INDEX MTV20030105AdLink_i1 1|1|TABLE MTV20030105Spots WITH INDEX MTV20030105Spots_i1 2|2|TABLE MTV20030105Stations USING PRIMARY KEY 3|3|TABLE MTV20030105Programs USING PRIMARY KEY ---- _2007-Sep-24 15:45:58 by anonymous:_ {linebreak} Point well taken ;-) For completeness, here is the query plan produced by SQLite 3.3.4: 0|0|TABLE MTV20030105Spots WITH INDEX MTV20030105Spots_i1 1|1|TABLE MTV20030105Stations 2|2|TABLE MTV20030105Programs 0|0|TABLE MTV20030105AdLink WITH INDEX MTV20030105AdLink_i1 The table scan order is different which results in much faster execution times. If anyone knows if this change was intentional in later versions, I'd be glad to read about it on the mailing list. Also, out of plain curiosity: While I realize that the presented DB schema is not defined adequately, would anyone still consider that the new scan order behavior breaks backwards compatibility? For very large tables, the query becomes unusable after 3.3.4. Meet you at the mailing list ... ---- _2007-Sep-24 18:18:28 by anonymous:_ {linebreak} The table/index scan order has changed many times from release to release, and has never been guaranteed. When the query optimizer was first introduced many queries relying on the join order specified in the FROM clause were slower and had to be reworked. Your previous defined schema was just lucky in this regard. If you have proper indexing you would not have had this performance degradation. For that matter, it would not hurt if you used ANALYZE as well. #c8c8c8 2661 code closed 2007 Sep anonymous 2007 Sep 2 3 Single line, multi inserts Using a wrapper for the DLL in Delphi, when doing single SQL statements, each row being inserted is successfully inserted as it should be. When doing multiple inserts in one call though, only the first insert seems to be processed. When using SQLITE3.EXE and I do the multi insert on one line, the transaction adds two rows to the DB. In detail; insert into tblfiles ([Name], fkid) values ('.bash_history',1); insert into tblfiles ([Name], fkid) values ('.rnd',1); When I run this via SqlDB.ExecSQL in Delphi, only .bash_history shows up in tblfiles. When I run that statement in SQLITE3.EXE, both show up. The wrapper directly calls the DLL. I'm pounding the DB pretty hard with a bulk inserts (45,000 inserts easy). One at a time takes a VERY long time. Apparantly it was the wrapper that was causing the issue. Found another one and multi-inserts work just fine. #c8c8c8 2660 code closed 2007 Sep anonymous 2007 Sep 4 4 Spelling error in comment for SQLITE_CONSTRAINT "constraint" is mispelled as "contraint" once in sqlite3.h and once in sqliteInt.h.

    In sqlite3.h

    #define SQLITE_CONSTRAINT 19 /* Abort due to contraint violation */

    In sqliteInt.h

    /*
    ** SQLite supports many different ways to resolve a contraint
    ** error. ROLLBACK processing means that a constraint violation
    Thanks. #cfe8bd 2659 code fixed 2007 Sep rse 2007 Sep danielk1977 2 2 openDirectory function broken IMHO the recently changed/introduced function src/os_unix.c:openDirectory() is broken in case the "zFilename" is just a filename without any path information in it (e.g. "foo.db"). In this case "ii" is 0 and as a result an uninitialized value "fd" is passed back and because of "fd" is uninitialized even the return code could be arbitrarily "SQLITE_OK" or "SQLITE_CANOPEN". The fix IMHO is to open "." in case no path information is present in "zFilename" and pass back an "fd" only if open(2) really was successful. Same for the return code. I append a patch which fixes this. But as I don't know what the original intentions were when this function was adjusted recently the patch should be reviewed by someone and then rejected or applied accordingly. #cfe8bd 2658 code fixed 2007 Sep anonymous 2007 Sep 2 3 sqlite3VtabOverloadFunction broken Triggered by a compiler warning ("rc" not initialized) I reviewed the function src/vtab.c:sqlite3VtabOverloadFunction() and came to the conclusion that it is broken at all: 1. The compiler is right that "rc" is not initialized before it is used for comparison. 2. If sqlite3DbStrDup fails a the uninitialized "xFunc" function pointer is passed back in the result structure. I do not understand this piece of code in detail, so I can only guess what it should do. IMHO the function has to be fixed this way: if sqlite3DbStrDup fails one has to short-circuit the processing and immediately return/pass-through "pDef" as is. Then use xFindFunction and this way correctly initialize "rc" and then return "pDef" again if "rc" is _now_ zero. I append a patch for fixing the code this way. I'm rather sure this is the way the function was intended to work, but as I'm not 100% sure please review it and apply or reject accordingly. #c8c8c8 2655 code closed 2007 Sep anonymous 2007 Sep 2 3 Reuse prepared statement after locked(5) gives called out of seq(21) Reusing a prepared statement after locked(5) error gives library routine called out of sequence(21) Create a test db: sqlite3 test.db CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, val INTEGER); go Lock db by running a statement in a transaction: begin transaction go delete from test where id = 99 go Try to run a prepared statement on the table via Perl DBI will give database is locked(5) at the first try. On following tries library routine called out of sequence(21) will be returned. Only works if statement handle is undef:ed and prepared again. If this is a problem in the SQLite DBD or in the SQLite library I don't know. Environment: FreeBSD 6.1 Perl 5.8.8 DBI 1.50 SQLite DBD 1.13 SQLite 3.4.2 Test script: #!/usr/local/bin/perl use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=test.db","","",{RaiseError => 0}) or die "Couldn't open dbfile."; $dbh->func(1000, 'busy_timeout'); my $sql = "DELETE FROM test WHERE id = ?"; my $sth = $dbh->prepare($sql); die "Couldn't prepare" unless defined $sth; my $ret; while(! defined $ret){ sleep 1; print "Execute sth\n"; $ret = $sth->execute(452); print "ERROR: " . $sth->err . $sth->errstr . "\n" if $ret; $sth->finish; } if($ret){ print "Failure\n"; } else{ print "Success\n"; } DBI->trace(5) is attached. _2007-Sep-19 11:47:29 by drh:_ {linebreak} You appear to be calling sqlite3_finalize() (I'm guessing that is what the "finish" method does) on the statement after the error. sqlite3_finalize() is the destructor for a statement. Then you try to use the object after it has been destroyed. Most systems would segfault under those circumstances. SQLite is nice and gives you an SQLITE_MISUSE error. ---- _2007-Sep-19 14:33:56 by anonymous:_ {linebreak} How is the library supposed to be used in order to reuse the already prepared statement? (According to perldoc DBI->finish is supposed to finish collection of data from an execution. It is not supposed to be destructive on the statement handle. So I guess that is a misuse of the library from SQLite DBD.) If I leave out DBI->finish I get the same error. I added the trace when not running finish. #f2dcdc 2653 code active 2007 Sep anonymous 2007 Sep 3 4 Exclusive Transactions do not work with a Database File attached twice 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. #f2dcdc 2652 code active 2007 Sep drh 2007 Sep 1 1 Aggregate function cannot be used from within a subquery 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:_ {linebreak} Your syntax appears to be incorrect.{linebreak} 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() #f2dcdc 2651 new active 2007 Sep anonymous 2007 Sep 5 4 Add support for overriding home directory location 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=. #c8c8c8 2650 build closed 2007 Sep anonymous 2007 Sep 1 1 lack ; in os_win.c:1329 Hi, I want just to inform you that it misses one; in the file os_win.c (line 1329). in winFullPathname, #if defined(__CYGWIN__) cygwin_conv_to_full_win32_path(zRelative, zFull); return SQLITE_OK <--- lack ';' #endif Regards YoCarBo Duplicate of #2642 and #2647 #f2dcdc 2649 new active 2007 Sep anonymous 2007 Sep 4 4 Add an "--enable-extensions" (default=no) to the configure script The attached patch adds "--enable-extensions" to the configure script, but is disabled by default (because of the security considerations of having it enabled). #cfe8bd 2648 build fixed 2007 Sep anonymous 2007 Sep 1 1 compilation error for PocketPC/WindowsCE function winOpen has some type errors under OS_WINCE preprocessor

     #if OS_WINCE   if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) ==                (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)        && !winceCreateLock(zFileName, &f)   ){     CloseHandle(h);     free(zConverted);     return SQLITE_CANTOPEN;   }   if( dwFlagsAndAttributes & FILE_FLAG_DELETE_ON_CLOSE ){     pFile->zDeleteOnClose = zConverted;   }else #endif 
    The line 18511 should be: && !winceCreateLock(zName, pFile) Also it's have mistake in typing FILE_FLAG_DELETE_ON_CLOSE (with last underlines - FILE_FLAG_DELETEONCLOSE in line 18517). Please change the sources to be compiled for WindowsCE. BR. Yuri Noyanov #c8c8c8 2647 code closed 2007 Sep anonymous 2007 Sep 1 1 sqlite-3.5.0 Cygwin: Compilation fails on src/os_win.c - ';' missing There is a ';' symbol missing on line 1329 in file os_win.c (winFullPathname function) after return statement:
     #if defined(__CYGWIN__)   cygwin_conv_to_full_win32_path(zRelative, zFull);   return SQLITE_OK #endif 
    Duplicate of Ticket #2642 #c8c8c8 2646 code closed 2007 Sep anonymous 2007 Sep a.rottmann 4 1 sqlite3_get_table loses one table row sqlite3_get_table seems to loose one row. this patch fixes the problem for me. If it is wrong, please fix the bug in a right way. --- sqlite-3.4.2/src/table.c 2007-06-12 15:18:01.000000000 +0300 +++ sqlite-3.4.2-x/src/table.c 2007-09-14 13:55:32.000000000 +0300 @@ -77,6 +77,7 @@ static int sqlite3_get_table_cb(void *pA } p->azResult[p->nData++] = z; } + p->nRow++; }else if( p->nColumn!=nCol ){ sqlite3SetString(&p->zErrMsg, "sqlite3_get_table() called with two or more incompatible queries", Can you take a look at the documentation here and confirm that you are interpreting it correctly? http://www.sqlite.org/capi3ref.html#sqlite3_free_table In particular, this bit: "Notice that there is an extra row of data containing the column headers. But the *nrow return value is still 3. *ncolumn is set to 2. In general, the number of values inserted into azResult will be ((*nrow) + 1)*(*ncolumn)." The code looks like it matches this description to me. If you find that it does not, please re-open this ticket. Thanks. #f2dcdc 2645 build active 2007 Sep anonymous 2007 Sep 5 4 Conflict between tclConfig.sh and tclinstaller.tcl 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. #c8c8c8 2644 code closed 2007 Sep anonymous 2007 Sep 1 1 sqlite Will you tell me why sqlite program is running on my laptop computer? Is it part of another program. Your answer and time is really appreciated. Thank you. _2007-Sep-13 18:00:08 by drh:_ {linebreak} SQLite is used by Mcaffee Anti-virus, AOL Mail, Skype, Adobe Lightroom, and countless other programs, most of which we are completely unaware of. This website is for reporting bugs against SQLite, not for getting help with figuring out what it is or why it is running on your computer. Please use the SQLite mailing list for such help. #cfe8bd 2643 code fixed 2007 Sep anonymous 2007 Sep 1 1 bestIndex: Assertion `flags!=0' failed after index creation I get an assertion crash on a database using sqlite 3.3.12 and also 3.4.2:
     sqlite> create index idx_media_items_p1 on media_items (p1); sqlite> select count(1) from media_items where p1 is not null; lt-sqlite3: ./src/where.c:1486: bestIndex: Assertion `flags!=0' failed. Aborted (core dumped)  Program received signal SIGABRT, Aborted. [Switching to Thread 47454430964672 (LWP 24045)] 0x00002b28d839247b in raise () from /lib/libc.so.6 (gdb) bt #0  0x00002b28d839247b in raise () from /lib/libc.so.6 #1  0x00002b28d8393da0 in abort () from /lib/libc.so.6 #2  0x00002b28d838bbf6 in __assert_fail () from /lib/libc.so.6 #3  0x00002b28d7fd3360 in bestIndex () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #4  0x00002b28d7fd3f7c in sqlite3WhereBegin () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #5  0x00002b28d7fb3bdc in sqlite3Select () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #6  0x00002b28d7fa2568 in yy_reduce () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #7  0x00002b28d7fa4e52 in sqlite3Parser () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #8  0x00002b28d7fb5719 in sqlite3RunParser () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #9  0x00002b28d7fa8e1d in sqlite3Prepare () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #10 0x00002b28d7fa92f6 in sqlite3_prepare () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #11 0x00002b28d7fd70df in sqlite3_exec () from /home/steve/dev/sqlite-3.4.2/.libs/libsqlite3-3.4.2.so.0 #12 0x0000000000406a74 in process_input () #13 0x0000000000407bc2 in main () 
    core: http://skrul.com/core.gz I can send the db file upon request. _2007-Sep-13 17:09:29 by anonymous:_ {linebreak} Two additional notes: This does not crash on 3.3.4, plus this particular database was created using the "attach database" command from another database. ---- _2007-Sep-13 17:18:42 by drh:_ {linebreak} I need to know the schema for the media_items table. ---- _2007-Sep-13 17:22:13 by anonymous:_ {linebreak}
     steve@steve-linux:~/dev/sqlite-3.4.2/.libs$ ./sqlite3 /home/steve/dev/songbird/db/flat2.db SQLite version 3.4.2 Enter ".help" for instructions sqlite> .schema CREATE TABLE media_items (   media_item_id integer primary key autoincrement,   guid text unique not null,   created integer not null,   updated integer not null,   content_url text not null,   content_mime_type text,   content_length integer,   hidden integer not null check(hidden in (0, 1)),   media_list_type_id integer,   p1 text,   p1_sort text,   p2 text,   p2_sort text,   p3 text,   p3_sort text,   p4 text,   p4_sort text,   p5 text,   p5_sort text,   p6 text,   p6_sort text,   p7 text,   p7_sort text,   p8 text,   p8_sort text,   p9 text,   p9_sort text,   p10 text,   p10_sort text , p11 text); CREATE INDEX idx_media_items_p1 on media_items (p1); CREATE INDEX idx_media_items_p11 on media_items (p11); CREATE INDEX idx_media_items_p2 on media_items (p2); sqlite> 
    ---- _2007-Sep-13 17:24:37 by drh:_ {linebreak} I also want to see a ".dump" of the sqlite_stat1 table. ---- _2007-Sep-13 17:25:52 by anonymous:_ {linebreak}
     sqlite> .dump sqlite_stat1 BEGIN TRANSACTION; ANALYZE sqlite_master; INSERT INTO "sqlite_stat1" VALUES('media_items','idx_media_items_p11','61799 1'); INSERT INTO "sqlite_stat1" VALUES('media_items','sqlite_autoindex_media_items_1','61799 1'); COMMIT; sqlite> 
    ---- _2007-Sep-13 18:03:19 by anonymous:_ {linebreak} Great! I applied those changes to my sqlite 3.4.2 where.c and it fixed the problem. Thanks for the unbelievably fast fix! #c8c8c8 2642 code closed 2007 Sep anonymous 2007 Sep 5 5 CYGWIN compile error due to missing semicolon Missing semi-colon near line 1329 of os_win.c after SQLITE_OK. #if defined(__CYGWIN__) cygwin_conv_to_full_win32_path(zRelative, zFull); return SQLITE_OK #endif Thanks. #c8c8c8 2641 code closed 2007 Sep anonymous 2007 Sep 2 3 sqlite - Ticket #2638 continued as it was arbitrarily closed unsolved to continue the thread from 2638. I tried as a blob and it was identical behaviour, this was not a workaround. behaviour is different in different versions for test or blobs. used to work, is now broken Indeed, the behaviour has changed. SQLite is now less tolerant of non utf-8 encoded strings being handled as text. It is very likely that that is the reason your shiftjis data is being mangled. It should not of happened if the data was being treated as a blob. Suggest going to the mailing-list for clarification. There are many clever people there who understand this kind of issue. If it does turn out to be a bug, we can reopen this ticket. #cfe8bd 2640 code fixed 2007 Sep anonymous 2007 Sep 1 1 sqlite doesn't treat global identifiers correctly in a subquery Apparently, sqlite doesn't treat global identifiers correctly in a subquery; in particular, with my database filling, the following query gives a wrong result (3 rows) whereas changing the innermost p.person_id into d.person_id (which are equal by the preceding condition) gives the correct result (56 rows). select distinct p.name from persons p, directors d where d.person_id=p.person_id and not exists ( select * from directors d1 where d1.person_id=p.person_id except select * from writers w ) _2007-Sep-12 11:36:42 by danielk1977:_ {linebreak} Can you provide a sample populated database? This would be a lot quicker to look into that way... If it's too large to attach to this ticket, you can mail it to me: dan@sqlite.org ---- _2007-Sep-12 14:30:33 by anonymous:_ {linebreak}
     CREATE TABLE persons(person_id, name); INSERT INTO "persons" VALUES(1,'fred'); INSERT INTO "persons" VALUES(2,'barney'); INSERT INTO "persons" VALUES(3,'wilma'); INSERT INTO "persons" VALUES(4,'pebbles'); INSERT INTO "persons" VALUES(5,'bambam'); CREATE TABLE directors(person_id); INSERT INTO "directors" VALUES(5); INSERT INTO "directors" VALUES(3); CREATE TABLE writers(person_id); INSERT INTO "writers" VALUES(2); INSERT INTO "writers" VALUES(3); INSERT INTO "writers" VALUES(4);   select distinct p.name   from persons p, directors d   where d.person_id=p.person_id and       not exists       ( select * from directors d1 where d1.person_id=p.person_id        except         select * from writers w       ); wilma    select distinct p.name   from persons p, directors d   where d.person_id=p.person_id and       not exists       ( select * from directors d1 where d1.person_id=d.person_id        except         select * from writers w       ); wilma bambam 
    #c8c8c8 2638 code closed 2007 Sep anonymous 2007 Sep 2 3 selects on japanese text okay in 3.3.5 bad in later versions I have a database that was created in version 3.3.5 that contains japanese shift-jis text fields (a kanji lookup db). It works fine with the 3.3.5 dll. When I put the 3.4.2 or alpha 3.5 dll in a select of a japanese character does not match characters in the DB correctly, instead of returning 300 or so matching entries it returns 2000 non matching ones. I have a workaround in the sense that I can keep the current 3.3.5 dll in the app and it works but I'd like to move forward to new versions soon. It's a database of japanese characters with japanese pronounciation and english meanings. format is code page 932. User puts a character in and it matches to a character in the system. replacing the dll and putting the same character in exactly (ie, paste current clipboard in both cases to be sure input codex is the same) and results are completely different. _2007-Sep-12 01:09:08 by drh:_ {linebreak} SQLite uses Unicode, either UTF8 or UTF16. You can put in string that are not well-formed UTF8 or UTF16 and sometimes it might work. But later versions have become noticably less tolerate of illformed UTF8. This is due to security concerns. See, for example, ticket #2029. If you want to store strings of codepage 932, I suggest you store them as BLOBs and not as text strings. #c8c8c8 2637 code closed 2007 Sep anonymous 2007 Sep 1 1 Segfault in pthread_getspecific () Hi, I am trying to run Trac 0.11-dev with Apache 2.2.3-3.2ubuntu0.1/mod_python and libsqlite3 3.4.2. Accessing Trac over Apache causes segfault in libsqlite3. This has something to do with threading (models), I assume. I am not sure if this is an configuration issue, but I couldn't find any help after hard googling. I tried also libqlite 3.3.x with the same result. I marked the bug with severity 1, since there is no known workaround AFAIK. I compiled libsqlite3 to get the symbolic traceback:
     #0  0xb7c521fa in pthread_getspecific () from /lib/tls/i686/cmov/libpthread.so.0 #1  0xb7d07f01 in sqlite3Insert (pParse=0x0, pTabList=0xb7d39bc8, pList=0xbfe16c98, pSelect=0xb7cebe8c,     pColumn=0xb7cdf298, onError=1) at ./src/insert.c:1564 #2  0xb7d1e40e in sqlite3_get_table_cb (pArg=0xb7cdf298, nCol=1, argv=0xa582000, colv=0xb7d39bc8)     at ./src/table.c:107 #3  0xb7cebe8c in sqlite3AuthRead (pParse=0xb7cebe8c, pExpr=0xbfe16c98, pTabList=0xb7d39bc8)     at ./src/auth.c:118 #4  0xb7cebf18 in sqlite3AuthRead (pParse=0xb7d39bc8, pExpr=0xa582000, pTabList=0x1) at ./src/auth.c:140 #5  0xb7d118b6 in sqlite3Parser (yyp=0xa6ff558, yymajor=, yyminor=       {z = 0xffffffff 
    , dyn = 0, n = 0}, pParse=0xbfe16e34) at parse.y:468 #6 0xb7d11fc1 in sqlite3Parser (yyp=0xa6ff558, yymajor=, yyminor= {z = 0xffffffff
    , dyn = 0, n = 1609611034}, pParse=0xbfe16e38) at parse.y:651 #7 0xb7d2f625 in getMask (pMaskSet=0x1, iCursor=1) at ./src/where.c:289 #8 0xb7d12243 in sqlite3Parser (yyp=0xbfe16ef8, yymajor=, yyminor= {z = 0xbfe16f08 "\222\023ӷ\232cӷ\200dӷ", dyn = 0, n = 0}, pParse=0x0) at parse.y:706 #9 0xb7d12347 in sqlite3Parser (yyp=0xb7cdffdc, yymajor=, yyminor= {z = 0xbfe1734c "X�o\n", dyn = 0, n = 0}, pParse=0xbfe16f78) at parse.y:735 #10 0xb7d1279c in sqlite3Parser (yyp=0xa6ff558, yymajor=, yyminor= {z = 0xa43a300 "system", dyn = 0, n = 86104312}, pParse=0xb7d39bc8) at parse.y:768 #11 0xb7d1288f in sqlite3Parser (yyp=0xbfe1734c, yymajor=, yyminor= {z = 0xa760dc8 "�>u\no", dyn = 0, n = 86104336}, pParse=0xbfe17048) at parse.y:812 #12 0xb7cf46da in sqlite3BtreeClose (p=0x0) at ./src/btree.c:1236 #13 0xb7d16c56 in base_vprintf (xRealloc=0, useInternal=-1210868792, zInitBuf=0x1
    , nInitBuf=-1211228996, zFormat=0xa760dc8 "�>u\no", ap=0xb7d36480 "CREATE TABLE sqlite_master(\n type text,\n name text,\n tbl_name text,\n rootpage integer,\n sql text\n)") at ./src/printf.c:785 #14 0xb7d173ce in base_vprintf (xRealloc=0xbfe16f28, useInternal=-1210882944, zInitBuf=, nInitBuf=-1075743924, zFormat=, ---Type to continue, or q to quit--- ap=0xe9e1744a
    ) at ./src/printf.c:589 #15 0xb7d179d6 in base_vprintf (xRealloc=0xbfe17038, useInternal=0, zInitBuf=, nInitBuf=-1075743924, zFormat=, ap=0xbfe17090 "\030r��") at ./src/printf.c:548 #16 0xb7d0d75d in pager_playback (pPager=0x68, isHot=16777221) at ./src/pager.c:1474 #17 0xb7d1b000 in prepSelectStmt (pParse=0x5cc2c, p=0xb7cdd000) at ./src/select.c:1368 #18 0xb7d1191f in sqlite3Parser (yyp=0xa6ff558, yymajor=, yyminor= {z = 0xffffffff
    , dyn = 0, n = 0}, pParse=0xa73708c) at parse.y:480 #19 0xb7d11fc1 in sqlite3Parser (yyp=0xa6ff558, yymajor=, yyminor= {z = 0xffffffff
    , dyn = 0, n = 87668806}, pParse=0xbfe17488) at parse.y:651 #20 0xb6810cef in statement_create () from /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so #21 0xb680c7ad in connection_call () from /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so #22 0xb7547987 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0 #23 0xb7547c03 in ?? () from /usr/lib/libpython2.5.so.1.0 #24 0x0a681a70 in ?? () #25 0x0a4154ec in ?? () #26 0x00000000 in ?? ()
    _2007-Sep-11 14:47:34 by anonymous:_ {linebreak} Also, Trac works fine if started using tracd standalone daemon tool ---- _2007-Sep-11 14:47:34 by anonymous:_ {linebreak} Could you try sqlite 3.5? The threading code has been completely redone. ---- _2007-Sep-11 14:57:17 by anonymous:_ {linebreak} No dice. libsqlite 3.5.0:
     #0  0xb7c521fa in pthread_getspecific () from /lib/tls/i686/cmov/libpthread.so.0 #1  0xb7d07f01 in sqlite3Insert (pParse=0x0, pTabList=0xb7d39bc8, pList=0xbfe16c98, pSelect=0xb7cebe8c,     pColumn=0xb7cdf298, onError=1) at ./src/insert.c:1465 #2  0xb7d1e40e in sqlite3Select (pParse=0xb7cdf298, p=0x1, eDest=171204008, iParm=-1210868792,     pParent=0x0, parentTab=0, pParentAgg=0xbfe16ca8, aff=0xb7cebf18 "�\205�\017\225�\017���\215�&")     at ./src/select.c:2915 #3  0xb7cebe8c in attachFunc (context=0x0, argc=0, argv=0x0) at ./src/attach.c:82 #4  0xb7cebf18 in attachFunc (context=0x0, argc=-1211232372, argv=0x1) at ./src/attach.c:114 #5  0xb7d118b6 in sqlite3PagerWrite (pDbPage=0xa8fa470) at ./src/pager.c:4156 #6  0xb7d11fc1 in sqlite3PagerOpen (pVfs=0xa8fa470, ppPager=0xb7d36480,     zFilename=0xffffffff 
    , nExtra=-1075745228, flags=-1075745224, vfsFlags=1) at ./src/pager.c:2110 #7 0xb7d2f625 in sqlite3VdbeHalt (p=0xa8fa470) at ./src/vdbeaux.c:1142 #8 0xb7d12243 in yy_find_shift_action (pParser=0x0, iLookAhead=1 '\001') at parse.c:1442 #9 0xb7d12347 in yy_destructor (yymajor=, yypminor=0x1) at parse.c:1337 #10 0xb7d1279c in sqlite3Parser (yyp=0xa8fa470, yymajor=, yyminor= {z = 0xa8fec48 "system", dyn = 0, n = 86973048}, pParse=0xb7d39bc8) at parse.c:3268 #11 0xb7d1288f in sqlite3Parser (yyp=0xbfe1734c, yymajor=-1075744936, yyminor= {z = 0xa906428 "�l\212\no", dyn = 0, n = 86973072}, pParse=0xbfe17048) at parse.c:3477 #12 0xb7cf46da in ?? () at ./src/btree.c:2498 from /usr/lib/libsqlite3.so.0 #13 0xbfe1734c in ?? () #14 0xb7d39bc8 in ?? () from /usr/lib/libsqlite3.so.0 #15 0x0a906428 in ?? () #16 0x0a5e3520 in ?? () #17 0xbfe17048 in ?? () #18 0xb7f18300 in ?? () from /lib/ld-linux.so.2 #19 0xb7d16c56 in sqlite3Pragma (pParse=0xbfe1734c, pId1=0xa8fec48, pId2=0x0, pValue=0xb757a700, minusFlag=173792084) at ./src/pragma.c:601
    ---- _2007-Sep-11 14:58:54 by anonymous:_ {linebreak} Just a shot in the dark - do you have the correct system header files for your version of GLIBC? ---- _2007-Sep-11 15:02:42 by anonymous:_ {linebreak} sqlite 3.5 does not call pthread_getspecific ---- _2007-Sep-11 15:59:51 by anonymous:_ {linebreak} After a little fight, I rollbacked everything on my system to older versions. I'll see whether this problem reappears when Trac 0.11 is released. Meanwhile you can close the ticket, since I cannot provide anymore further info. It must be some sort of configuration issue. Glibc headers might be a good guess. Maybe the latest 3.5.0 was not installed correctly. ---- _2007-Sep-11 16:17:03 by drh:_ {linebreak} Anonymous users can close tickets in CVSTrac. You could have closed this ticket yourself. #c8c8c8 2636 code closed 2007 Sep anonymous 2007 Sep 1 1 Bug in sqlite3_prepare_v2 If we prepare two statements using sqlite3_prepare_v2, lets say DELETE FROM table WHERE ID = ?;{linebreak} and{linebreak} UPDATE table SET ID = ID - ? WHERE ID > ?; at the same time, bind values to it Then execute each of the statements, they get executed, but the changes to the database from the second (UPDATE) statement does not show up in the database. _2007-Sep-11 07:21:12 by danielk1977:_ {linebreak} Can you post a short program to demonstrate the problem? From the report, I'm not sure exactly how to reproduce it. _2007-Sep-12: by drh:_ {linebreak} Unable to reproduce and original submitter is not responding. #c8c8c8 2635 code closed 2007 Sep anonymous 2007 Sep 3 2 problem with calculation of juliand date in the calculation of the function computeYMD (in date.c) the date corresponding of the julian day 77528 is 29 february 300 (which should not exist) instead of 1 march 300, as matter of fact the next day is 2 march 300. This problem is present every 400 years backward. Thanks. _2007-Sep-08 21:46:10 by drh:_ {linebreak} The date and time functions in SQLite render all dates according to the gregorian calendar. This is by design. #f2dcdc 2634 code active 2007 Sep anonymous 2007 Sep 3 3 .schema uses incorrect ORDER BY giving wrong dependency order 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:_ {linebreak} 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 
    #cfe8bd 2633 build fixed 2007 Sep anonymous 2007 Sep 1 1 building with gcc3.3.4 - undefined reference to `sqlite3KeywordCode' I'm using gcc 3.3.4 with glibc 2.3.2 trying to cross compile for arm. My configure command line: ../sqlite-3.4.2/configure --disable-readline --disable-tcl --host=arm-linux --prefix=/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/ During the build I have to compile lemon and mkkeywordhash for my native system and restart the build. Otherwise the build goes smoothly until I get here: ... ranlib .libs/libsqlite3.a creating libsqlite3.la (cd .libs && rm -f libsqlite3.la && ln -s ../libsqlite3.la libsqlite3.la) ./libtool --mode=link gcc -I/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/include -I. -I../sqlite-3.4.2/src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -L/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/lib -DHAVE_READLINE=0 \ -o sqlite3 ../sqlite-3.4.2/src/shell.c libsqlite3.la \ gcc -I/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/include -I. -I../sqlite-3.4.2/src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DHAVE_READLINE=0 -o .libs/sqlite3 ../sqlite-3.4.2/src/shell.c -L/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/lib ./.libs/libsqlite3.so -Wl,--rpath -Wl,/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux//lib ./.libs/libsqlite3.so: undefined reference to `sqlite3KeywordCode' ./.libs/libsqlite3.so: undefined reference to `keywordCode' collect2: ld returned 1 exit status make: *** [sqlite3] Error 1 I'm trying to build the shared libraries for use on an arm system. I'd just build the sqlite3.c amalgamation into my apps, but I had a grocery list of build errors in gcc 4.1.2 on my native system and I didn't think my gcc3.3.4 cross-compiler would fair much better. So I'd like to at least get the shared libs working. Any help would be appreciated. I figured out that the build does not warn you if keywordhash.h is not created. Perhaps it should or the build will fail. So after compiling the mkkeywordhash tool for the native machine: gcc -g -o mkkeywordhash ../sqlite-3.4.2/tool/mkkeywordhash.c I then had run: ./mkkeywordhash >keywordhash.h ... manually before restarting the build. Build completes without errors now, but build tools/code generators are inherently non-cross-compiler friendly when they are part of the main build process and have to be compiled into machine executable form before being run. Any possibility of moving these to an interpreter-based language that doesn't require compiling? #cfe8bd 2631 code fixed 2007 Sep anonymous 2007 Sep 3 3 Comments at end of "CREATE TABLE" cause SQL error. Comments after the semi colon of a "CREATE TABLE" statement that use the double-dash format cause an Incomplete SQL error in the Windows command line program when read in with the ".read" command. The following SQL statement read in from a file through the ".read" command will generate the error: CREATE TABLE test (abc, def); -- this comment causes error With the comment removed the read works correctly. The error doesn't happen if the statement is typed into the console. #f2dcdc 2629 doc active 2007 Sep anonymous 2007 Sep 4 4 typo in os_unix.c for nolock
     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 */ 
    #cfe8bd 2628 code fixed 2007 Sep anonymous 2007 Sep 3 4 Bad error handling for invalid page-size When opening a database which has an invalid page-size, sqlite3BtreeOpen() decides to use default values. This prevents the assert in sqlite3PagerSetPagesize() (which would at least show the cause of the problem) and subsequently brings obscure errors. It would be preferable to return a database error when this is detected. I had foolishly reduced the value of SQLITE_MAX_PAGE_SIZE for use in embedded devices, and noticed this when trying to open a database created with a larger page size. #f2dcdc 2627 code active 2007 Sep anonymous 2007 Sep 3 2 Improper parsing of nested JOIN 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} I guess he had no luck filing a JET bug. ---- _2007-Sep-11 17:22:28 by anonymous:_ {linebreak} 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 #c8c8c8 2626 code closed 2007 Sep anonymous 2007 Sep 1 1 The Amalgamation compile error when i compile The Amalgamation 3.4.2 with visual studio 2003 in window, i encounted 3 errors : 'sqlite3IsIdChar':unknown size 'sqlite3OpcodeNames':unkown size 'sqlite3UpperToLower':unkown size i think it is caused by following source code in sqlite3.c: #ifndef SQLITE_PRIVATE # define SQLITE_PRIVATE static #endif it should be: #ifndef SQLITE_PRIVATE # define SQLITE_PRIVATE #endif is that right? It looks like vs2003 doesn't like this kind of forward decl: static int aArray[]; ... static int aArray[] = {1, 2, 3}; But is fine with this: int aArray[]; ... int aArray[] = {1, 2, 3}; By defining SQLITE_PRIVATE as an empty string, you are avoiding constructs like the first block above. It's not ideal, but not harmful either. ---- _2007-Sep-06 13:11:51 by anonymous:_ {linebreak} This is fixed in 3.5. #c8c8c8 2625 build closed 2007 Sep anonymous 2007 Sep 2 2 http://www.sqlite.org/cvstrac/wiki?p=HowToCompileWithVsNet has problem when i compile 3.4.2 with visual studio 2003 in windows, i do as http://www.sqlite.org/cvstrac/wiki?p=HowToCompileWithVsNet told me to. but step 8 "Add all the .c and .h files that you unzipped, except for: tclsqlite.c and shell.c.Note: You may add tclsqlite.c and shell.c, but then you have to define the preprocessor-symbol NO_TCL:" won't work. i suggest to modify it to be "Add all the .c and .h files that you unzipped, except for: tclsqlite.c shell.c and icu.c. Note: You may add tclsqlite.c and shell.c, but then you have to define the preprocessor-symbol NO_TCL, you may add icu.c, but then you have to define the preprocessor-symbol SQLITE_CORE". why not supply a .sln file? this will save many people's time. thank you. _2007-Sep-06 07:04:34 by danielk1977:_ {linebreak} What you suggest sounds like an improvement. I'd add the text in myself, but I don't have visual studio, so I can't test it. But the wiki pages are all user editable, so feel free to modify it yourself by clicking the "Edit" link found at the top right-hand side of the page. If you have a *.sln file that you can attach to the page, even better. #cfe8bd 2624 code fixed 2007 Sep anonymous 2007 Sep 1 1 Invalid documentation references in sqlite.h.in Documentation in sqlite.h.in contains invalid references to the following functions and #defines: *: SQLITE_LOCK_READ -> _SHARED *: sqlite3_register_vfs -> vfs_register *: sqlite3_unregister_vfs -> vfs_unregister *: sqlite3_find_vfs -> vfs_find *: sqltie3_blob_size -> sqltie3_blob_bytes *: sqlite3_finalise -> sqlite3_finalize ( s vs. z) *: sqlite_column_text -> missing 3 *: sqltie3_blob_size -> ti mixed up #cfe8bd 2623 code fixed 2007 Sep anonymous 2007 Sep 1 1 zeroblob(-1) returns non-NULL from sqlite3_column_blob() Please consider this psydo-code: sqlite3_prepare ("select zeroblob(-1)", DB, &Stmt); sqlite3_step(Stmt); sqlite3_column_blob(Stmt, 0) == NULL; // Error here! sqlite3_column_blob() used to return NULL for "zeroblob(-1)" as well as any other negative length value for SQLite 3.4.2. After the 3.5.0 changes it returns an arbitrary non-NULL value. sqlite3_column_bytes() returns 0 both before and after the changes. I suppose that the pre 3.5.0 NULL result is correct and meaningful. Or is it in fact undefined? #cfe8bd 2622 doc fixed 2007 Sep anonymous 2007 Sep 3 3 SQLITE_OMIT_MEMORY_ALLOCATION undocumented unresolved functions When SQLITE_OMIT_MEMORY_ALLOCATION is defined, in addition to the functions sqlite3_malloc(), sqlite3_realloc(), and sqlite3_free(), two other functions are also unresolved: sqlite3_memory_alarm() and sqlite3_memory_used(). $ make sqlite3 2>&1 | grep 'undefined reference to' | sed 's/^.*://g' | sort | uniq undefined reference to `sqlite3_free' undefined reference to `sqlite3_malloc' undefined reference to `sqlite3_memory_alarm' undefined reference to `sqlite3_memory_used' undefined reference to `sqlite3_realloc' They are used in sqlite3_soft_heap_limit() in malloc.c. So this issue could either be resolved with a doc fix to the statement "If SQLite is compiled with SQLITE_OMIT_MEMORY_ALLOCATION then no implementation for the sqlite3_malloc(), sqlite3_realloc(), and sqlite3_free() functions is provided." or by using an appropriate #ifdef around sqlite3_memory_used and sqlite3_memory_alarm in sqlite3_soft_heap_limit(). i.e.:
     Index: src/malloc.c =================================================================== RCS file: /sqlite/sqlite/src/malloc.c,v retrieving revision 1.13 diff -u -3 -p -r1.13 malloc.c --- src/malloc.c        29 Aug 2007 14:06:23 -0000      1.13 +++ src/malloc.c        4 Sep 2007 04:40:03 -0000 @@ -36,6 +36,7 @@ static void softHeapLimitEnforcer(  ** zero or negative value indicates no limit.  */  void sqlite3_soft_heap_limit(int n){ +#ifndef SQLITE_OMIT_MEMORY_ALLOCATION    sqlite3_uint64 iLimit;    int overage;    if( n<0 ){ @@ -52,6 +53,7 @@ void sqlite3_soft_heap_limit(int n){    if( overage>0 ){      sqlite3_release_memory(overage);    } +#endif  }   /* 
    I prefer the #ifdef over the doc change, but either is fine. _2007-Sep-04 04:55:41 by anonymous:_ {linebreak} It appears that the next paragraph mentions that sqlite3_memory_alarm must also be provided by the user if SQLITE_OMIT_MEMORY_ALLOCATION is defined. So sqlite3_memory_used is the only one not documented as being required to be supplied by the user. ---- _2007-Sep-04 05:35:13 by anonymous:_ {linebreak} loadext.c also has references to sqlite3_memory_highwater and sqlite3_memory_used when SQLITE_OMIT_MEMORY_ALLOCATION is defined. #cfe8bd 2621 code fixed 2007 Sep anonymous 2007 Sep 1 5 another typo -Application that implement their own OS interface will require modification. +Any application implementing their own OS interface will require modification. #c8c8c8 2620 doc closed 2007 Sep anonymous 2007 Sep 5 5 doc note needed for sqlite3_memory_alarm() In the docs for sqlite3_memory_alarm() it is probably worth noting that the registered callback xCallback may be invoked from any thread where sqlite3_malloc may be invoked and the user must take appropriate measures in writing their callback. _2007-Sep-04 03:32:19 by drh:_ {linebreak} The docs already say:
    "Application programs should not attempt to use sqlite3_memory_alarm().... This interface is exposed only so that applications can provide their own alternative implementation...."
    Isn't that enough? ---- _2007-Sep-04 04:03:54 by anonymous:_ {linebreak} Connection locks may be held. Things could potentially deadlock if you don't know what you're doing. I thought an explicit mention would make this clear, but perhaps you're right. Feel free to close this ticket. #cfe8bd 2619 doc fixed 2007 Sep anonymous 2007 Sep 5 5 typo -This is a large change approximately 1 line of count of out 10 was modified. +This is a large change. Approximately 10 percent of the lines of code was modified. #c8c8c8 2618 code closed 2007 Sep anonymous 2007 Sep linus 4 1 Dabase is Locked I have copied my executables and binaries to my target with Sqlite Database. But When i try to access the Database I get, Error:Database is Locked and memory fault occurs. _2007-Sep-04 03:13:48 by drh:_ {linebreak} SQLite version 2.8.0 dates back to February of 2003. We might consider doing a patch on a branch of version 2.8.17 if someone happens to find a very serious bug and explains the bug clearly. This ticket does neither. Please take further discussion to the mailing list. Tnx. #c8c8c8 2617 code closed 2007 Sep anonymous 2007 Sep drh 2 3 Check in #4357 may lead to bugs in SMP aware systems in windows vfs Hi The method for generating temporary file names in windows vfs driver may cause problems when running on SMP systems, because they could 'collide' on sqliteRandomness() call. A safer and proper fix for this is to use GetTempFileName () windows API (http://msdn2.microsoft.com/en-us/library/aa364991.aspx) and set flags to generate a unique file name. It ensures no-other call could get the same file name. _2007-Sep-03 21:28:15 by drh:_ {linebreak} The chances of a name collision are vanishingly small, so small that the problem can be ignored. ---- _2007-Sep-05 14:49:46 by anonymous:_ {linebreak} Yes. You are correct on this, could never happen, but still exists. Also, after examined the Randomness code for Win32 VFS driver, I found this:
     static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){   int n = 0;   if( sizeof(LPSYSTEMTIME)<=nBuf-n ){     SYSTEMTIME x;     GetSystemTime(&x);     memcpy(&zBuf[n], &x, sizeof(x));     n += sizeof(x);   }   if( sizeof(DWORD)<=nBuf-n ){     DWORD pid = GetCurrentProcessId();     memcpy(&zBuf[n], &pid, sizeof(pid));     n += sizeof(pid);   }   if( sizeof(DWORD)<=nBuf-n ){     DWORD cnt = GetTickCount();     memcpy(&zBuf[n], &cnt, sizeof(cnt));     n += sizeof(cnt);   }   if( sizeof(LARGE_INTEGER)<=nBuf-n ){     LARGE_INTEGER i;     QueryPerformanceCounter(&i);     memcpy(&zBuf[n], &i, sizeof(i));     n += sizeof(i);   }   return n; } 
    The code could run into a buffer underrun because you check for sizeof(LPSYSTEMTIME) (which is equal to sizeof(void *), because LPSYSTEMTIME is typedef'ed as SYSTEMTIME *, so a underrun could happen here. Also, LPSYSTEMTIME suffer from timer granularity of the kernel, which could be, in some systems, up to 130ms. A better implementation for this routine could be:
     static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){   int n = 0;   if( sizeof(DWORD)<=nBuf-n ){     DWORD cnt = GetTickCount(); // Ticks from system startup     memcpy(&zBuf[n], &cnt, sizeof(cnt));     n += sizeof(cnt);   }   if( sizeof(LARGE_INTEGER)<=nBuf-n ){     LARGE_INTEGER i;     QueryPerformanceCounter(&i); // High-resolution TSC counter     memcpy(&zBuf[n], &i, sizeof(i));     n += sizeof(i);   }   if( sizeof(DWORD)<=nBuf-n ){     DWORD pid = GetCurrentThreadId(); // Current thread id     memcpy(&zBuf[n], &pid, sizeof(pid));     n += sizeof(pid);   }   if( sizeof(DWORD)<=nBuf-n ){     DWORD pid = GetCurrentProcessId(); // Current process id     memcpy(&zBuf[n], &pid, sizeof(pid));     n += sizeof(pid);   }   if( sizeof(SYSTEMTIME)<=nBuf-n ){     SYSTEMTIME x;     GetSystemTime(&x); // System date/time     memcpy(&zBuf[n], &x, sizeof(x));     n += sizeof(x);   }   return n; } 
    This code will fill, with less chance of collision, the 20 byte randomness key used to generate the temporary file name, and also will generate more efficiently random numbers, because it includes the thread id on it, which will help in SMP systems, because they cannot get to be the same at same time. There is a chance this could be fixed (SYSTEMTIME issue) and include in pre-3.5.0 code ? #cfe8bd 2616 code fixed 2007 Sep anonymous 2007 Sep 1 1 Flags parameter not honoured in openDatabase() The flags parameter of openDatabase() is not honored. At least I did not find any further reference to it in the function body. As a result, calling sqlite3_open_v2 with the SQLITE_OPEN_READWRITE flag creates a new database file even though, as advertised in the documentation, it should not. #cfe8bd 2615 code fixed 2007 Sep anonymous 2007 Sep 1 1 winRandomness without effect due to < vs. > mixup os_win.c line 1424 checks that if( sizeof(LPSYSTEMTIME)>=nBuf ), supposedly to make sure that the supplied buffer is never overwritten. However, the comparison should be <= instead. The current implementation prevents that the buffer is filled at all because the check always fails. #c8c8c8 2614 code closed 2007 Sep anonymous 2007 Sep 1 1 Custom VFS still calls default xRandomness If a default VFS is registered, any custom VFS's xRandomness callback is never invoked. The only reference to the xRandomness call is hard coded in random.c, line 65: sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k); This makes it impossible to implement custom random seeds for any VFS other than the default. Correct. This fact has now been made explicit in the documentation. #cfe8bd 2612 code fixed 2007 Sep anonymous 2007 Sep 1 1 enterMutex() misnamer enterMutex() in mem1.c is wrongly named as enterMem(). This results in linker errors due to missing enterMutex() function. #cfe8bd 2611 code fixed 2007 Sep anonymous 2007 Sep 2 1 AV calling sqlite3_vfs_register() Calling sqlite3_vfs_register() as the first thing in an application raises an AV. Rationale: vfsList in os.c is not initialized until the first call of sqlite3_vfs_find(). Thus calling sqlite3_vfs_find() before sqlite3_vfs_register() functions as a workaround, but can be easily forgotten. #cfe8bd 2610 code fixed 2007 Sep anonymous 2007 Sep drh 4 3 SQLITE_API sqlite3_sleep function header missing in sqlite3ext.h struct sqlite3_api_routines { does not contain sqlite3_sleep }
    I am using the amalgamation for Windows to write loadable extension functions and was going to use sqlite3_sleep in cases where trials to access with sqlite3_step do not succeed.
    There may be many more SQLITE_API declared functions, which are not yet part of the interface. How can I use SQLITE_API declared functions also in my extension dll's ? Why aren't they in the struct?
    Is there another and better way to retry sqlite3_step on SQLITE_BUSY error for a maximum of time (like .timeout in sqlite3.exe)? My example:
     #include  SQLITE_EXTENSION_INIT1  static void execSQL(sqlite3_context *context, int argc, sqlite3_value **argv) { ...   len = strlen(sql);   errno = sqlite3_prepare(db, sql, len, &stmt, &t);   while( stmt )   {     while( (s=sqlite3_step(stmt))==SQLITE_BUSY )       sqlite3_sleep( 100 );     if( s==SQLITE_ROW )     {       switch( sqlite3_column_type(stmt, 0 ) ) ...     }     else     {       sqlite3_finalize(stmt);       stmt=NULL;     }   } ... int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ) {   SQLITE_EXTENSION_INIT2(pApi)   sqlite3_create_function(db, "execSQL", 1, SQLITE_UTF8, 0, execSQL,  0, 0); 
    For those who want to know: The execSQL function is foreseen to process a list of SQL statements out of a table which keeps the stored SQL statements; Table and Trigger creations and deletions, loading of further extensions, etc. This issue has already been addressed by check-in [4343]. #c8c8c8 2609 code closed 2007 Sep anonymous 2007 Sep 1 1 Is non-thread safe binaries dangerous for multi-threaded app design ? Can accessing two threads ( one is the main app one ) to one connection silently corrupt in-memory data so that next commit to write the wrong ones to the disk, for the non-threadsafe binaries ? _2007-Sep-01 20:45:04 by anonymous:_ {linebreak} Forgot to mention: only the main app thread writes ( calls COMMIT), the other thread only scrolls & reads the data. ---- _2007-Sep-01 20:57:07 by anonymous:_ {linebreak} You have to compile sqlite with -DTHREADSAFE=1 if you are to use it in multiple threads in the same program. This question really belongs on the mailing list, not the bug ticket system. ---- _2007-Sep-01 22:13:40 by anonymous:_ {linebreak} Then this issue should be noted on the top of official site, and there should also be thread-safe binaries in the download area. #cfe8bd 2608 code fixed 2007 Aug anonymous 2007 Sep 3 3 failed allocation leads to unexpected infinite loop I tried to build 3.4.2 on Windows with something else than mingw and I stumbled upon this. The malloc.test hangs in malloc-1.733 so I attached to testfixture.exe with the VC8 debugger and found the following: The function sqlite3WinTempFileName contains an infinite loop where random file names are generated and the loop breaks when one is found which does not exist. That is where it hangs. sqlite3WinTempFileName calls in the infinite loop ( sqlite3WinFileExists, which calls ( convertUtf8Filename, which calls ( utf8ToUnicode, which calls ( sqlite3MallocRaw, which fails, and returns 0 ) and utf8ToUnicode returns 0 ) and convertUtf8Filename returns 0 ) and sqlite3WinFileExists returns SQLITE_NOMEM=7 ) and the test in the loop thinks it has received TRUE and goes on. Essentially this means an existence test seems to return a TRUE answer when the test actually has not happened at all for an obscure technical reason. This can stand improvement. This was probably missed because that allocation should never fail. It is probably failing for reasons to do with my build, which is another matter. _2007-Sep-01 02:16:48 by drh:_ {linebreak} This fix is simply to not check to see if the randomly generated filename already exists. I extended the random section of the filename to be 20 characters long. with 62 possible values at each position, this gives 119 bits of randomness. The chance of such an name colliding is many orders of magnitude smaller than the chance of a random malfunction causing the win32 APIs to return the wrong answer when we ask whether or not the file exists. The flaw in the above argument is that the PRNG in SQLite is poorly seeded on windows. We need to do a better job seeding the PRNG on that platform. It's the winRandomness() function in the os_win.c source file that seeds the PRNG, if any windows hackers would like to suggest a way to improve the seeding. #f2dcdc 2607 event active 2007 Aug anonymous 2007 Sep 2 1 Data loss, continuation to Re: [sqlite] how to flush database to disk? 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:{linebreak} {quote: 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:{linebreak}{link: http://www.sqlite.org/lang_createvtab.html CreateVirtualTable}{linebreak} {wiki: VirtualTables VirtualTables} ---- _2007-Sep-04 04:51:15 by anonymous:_ {linebreak} 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:_ {linebreak} were't => were not, above. #cfe8bd 2606 code fixed 2007 Aug anonymous 2007 Sep 3 3 PATCH - default configure option enable_threadsafe=yes Obvious patch below to enable thread-safe sqlite3 builds by default to match the default thread-safe build of the sqlite3.c amalgamation. Patch included for both configure.ac and configure so you don't have to regenerate the script. I tested it with no options, enable and disable and it works.
     Index: configure =================================================================== RCS file: /sqlite/sqlite/configure,v retrieving revision 1.42 diff -u -3 -p -r1.42 configure --- configure   17 Feb 2007 14:59:18 -0000      1.42 +++ configure   31 Aug 2007 15:43:23 -0000 @@ -18883,7 +18883,7 @@ fi  if test "${enable_threadsafe+set}" = set; then    enableval=$enable_threadsafe;  else -  enable_threadsafe=no +  enable_threadsafe=yes  fi   { echo "$as_me:$LINENO: checking whether to support threadsafe operation" >&5 Index: configure.ac =================================================================== RCS file: /sqlite/sqlite/configure.ac,v retrieving revision 1.29 diff -u -3 -p -r1.29 configure.ac --- configure.ac        17 Feb 2007 14:59:18 -0000      1.29 +++ configure.ac        31 Aug 2007 15:43:23 -0000 @@ -178,7 +178,7 @@ AC_SUBST(BUILD_CFLAGS)  # Do we want to support multithreaded use of sqlite  #  AC_ARG_ENABLE(threadsafe, -AC_HELP_STRING([--enable-threadsafe],[Support threadsafe operation]),,enable_threadsafe=no) +AC_HELP_STRING([--enable-threadsafe],[Support threadsafe operation]),,enable_threadsafe=yes)  AC_MSG_CHECKING([whether to support threadsafe operation])  if test "$enable_threadsafe" = "no"; then    THREADSAFE=0 
    _2007-Aug-31 16:23:18 by drh:_ {linebreak} Thanks for the patch. Here's the thing: Threadsafe builds are currently running about 8% slower than single-threaded builds. (All those calls to pthread_mutex_lock() do not come for free.) So we are going to have to make a decision about whether or not we really want the default build to be threadsafe. ---- _2007-Aug-31 16:29:45 by anonymous:_ {linebreak} The trend these days is multi-core chips and multi-threaded software. Embedded programmers know their way around a compiler and can easily disable thread-safety if they should so choose to get extra speed. Beginners (and apparently one old timer) may forget to configure a threadsafe build which may produce programs that seem to work initially, but fail unexpectedly in the field. Better safe than sorry, I figure. #f2dcdc 2539 code active 2007 Jul anonymous 2007 Sep 2 2 WinCE: Temporary etilqs_ files are not removed from temporary folder 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:_ {linebreak} 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:_ {linebreak} This is actually a duplicate of #2533 ---- _2007-Sep-21 14:20:05 by anonymous:_ {linebreak} 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 #c8c8c8 2486 code closed 2007 Jul anonymous 2007 Sep 2 3 pragma index_list does not detect index created on 2nd connection Open two connections to the same database. On the first connection, create a table "test" and an index on that table. On the second, run "pragma index_list( test )". Expected result: pragma detects the previously-created index. Actual result: no index is detected. Test case to follow. _2007-Jul-05 20:02:25 by anonymous:_ {linebreak}

     #include "sqlite3.h"  #include   extern "C" int IsIndexCreatedCallback( void* p, int, char**, char** ) {  *(bool*)p = true;  return 0; }  BOOST_AUTO_TEST_CASE( SQLiteTest ) {  sqlite3* sqlite1;  int result = sqlite3_open( "test", &sqlite1 );   sqlite3* sqlite2;  result = sqlite3_open( "test", &sqlite2 );   result = sqlite3_exec( sqlite1, "create table test ( id integer )", 0, 0, 0 );   bool exists = false;  result = sqlite3_exec( sqlite2, "pragma index_list( test )", IsIndexCreatedCallback, &exists, 0 );  BOOST_CHECK( !exists );   result = sqlite3_exec( sqlite1, "create index ix on test ( id )", 0, 0, 0 );   exists = false;  result = sqlite3_exec( sqlite2, "pragma index_list( test )", IsIndexCreatedCallback, &exists, 0 );  BOOST_CHECK( exists ); } 
    ---- _2007-Jul-05 20:18:10 by anonymous:_ {linebreak} Can reproduce with 3.4.0 using two sqlite3 processes. I found that if you execute "select * from sqlite_master" from the second sqlite3 commandline shell, then pragma index_list on the 2nd connection will correctly show the indexes for some reason. ---- _2007-Jul-05 21:12:32 by drh:_ {linebreak} The first connection does not know that an index has been created on the second connection until it attempts to access the database. ---- _2007-Jul-05 21:17:36 by anonymous:_ {linebreak} Same problem with connection 1 executing ALTER TABLE ADD COLUMN and connection 2 executing PRAGMA table_info(table-name). I suspect the following PRAGMAs must always read() the database's file change counter and if it changed then reset the cached schema before proceeding: PRAGMA foreign_key_list(table-name); PRAGMA index_info(index-name); PRAGMA index_list(table-name); PRAGMA table_info(table-name); ---- _2007-Jul-05 21:37:12 by anonymous:_ {linebreak} Does the comment on 2007-Jul-05 21:12:32 imply this behavior is by design? ---- _2007-Jul-06 11:31:55 by drh:_ {linebreak} Yes. ---- _2007-Jul-06 15:38:07 by anonymous:_ {linebreak} That's understandable. This ticket can be fixed with documentation. Can you recommend the most efficient/quickest way to force SQLite to reload the schema in memory from a library user's point of view? SELECT 0 from _dummy_table_ SELECT 0 from sqlite_master where 1=0 ? ---- _2007-Jul-06 15:41:37 by anonymous:_ {linebreak} Would a new pragma for this purpose be out of the question? PRAGMA force_schema_reload; ---- _2007-Jul-06 16:57:56 by anonymous:_ {linebreak} I can appreciate seperate processes' in-memory schema not being automatically updated when another process changes the schema or adds a new index. But it does not make sense that another connection in the *same process* is not flagged to automatically update their in-memory schema prior to executing one of these PRAGMAs being issued. It's just a matter of checking an integer change counter in memory for each connection on the same database. ---- _2007-Jul-06 18:22:18 by anonymous:_ {linebreak} =SELECT 0 from sqlite_master where 1=0= doesn't work. =SELECT 0 from sqlite_master= does. Can you elaborate on the reason for this design decision? ---- _2007-Jul-06 18:55:04 by anonymous:_ {linebreak} I was just looking for the fastest executing SELECT statement I could find that would force a reload of all schema from the file. Perhaps something like this? select null from sqlite_master limit 1 I'm pretty sure trying to query a non-existant table also has the side-effect of reloading the entire schema. -- force a re-load, and ignore the error SELECT a from _non_existant_table_ I just don't know which one's faster. It would be better to have a standard way of doing this. ---- _2007-Jul-11 21:08:14 by anonymous:_ {linebreak} Doing a select against a non-existent table will fail without reloading the schema. At least in my independent discovery of this problem that didn't resolve things... ---- _2007-Jul-20 06:25:14 by anonymous:_ {linebreak} Would a schema change (add index) in one connection affect the other connection as it goes to insert into the table without knowing that the index has been added? And result in incomplete index contents? ---- _2007-Jul-26 18:42:06 by anonymous:_ {linebreak} the greatest way to solve this is reloading the db metadata when you issue a pragma command, like pragma index_list or other. i thought this will be great. also, database header has a version to detect SQLITE_SCHEMA changes. why pragma commands doesn't honor this ? ---- _2007-Aug-22 19:09:28 by anonymous:_ {linebreak} related ticket: #2519 ---- _2007-Sep-04 20:10:24 by anonymous:_ {linebreak} Fixed in 3.5.0 (*) #include "sqlite3.h" #include #include #include int mycb(void* p, int nCol, char** azVals, char** azCols) { int i; *(int*)p = 1; printf("mycb: "); for (i = 0; i < nCol; i++) { printf("%s = %s, ", azCols[i], azVals[i]); } printf("\n"); return 0; } int main() { const char* dbname = "schemachange.db"; sqlite3* sqlite1; sqlite3* sqlite2; int exists; int result; sqlite3_enable_shared_cache(1); /***** line necessary for it to work ****/ unlink(dbname); result = sqlite3_open(dbname, &sqlite1); assert(result == SQLITE_OK); result = sqlite3_open(dbname, &sqlite2); assert(result == SQLITE_OK); result = sqlite3_exec(sqlite1, "create table t(id integer)", 0, 0, 0); assert(result == SQLITE_OK); exists = 0; result = sqlite3_exec(sqlite2, "pragma index_list(t)", mycb, &exists, 0); assert(result == SQLITE_OK); result = sqlite3_exec(sqlite1, "create index ix on t(id)", 0, 0, 0); assert(result == SQLITE_OK); exists = 0; result = sqlite3_exec(sqlite2, "pragma index_list(t)", mycb, &exists, 0); assert(result == SQLITE_OK); assert(exists); return 0; } (*) It seems that sqlite3_enable_shared_cache(1) is required. What's the downside in making this the default behavior? It seems like a win/win from a memory usage and schema change detection point of view. #f2dcdc 2294 code active 2007 Apr anonymous 2007 Sep 2 1 segfault when destroying lock on WinCE with threads 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:_ {linebreak} 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:_ {linebreak} 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. #c8c8c8 1929 warn closed 2006 Aug anonymous 2007 Sep 4 3 3.3.7 sqlite3_index_info incompatible with C++ The definition of sqlite3_index_info in sqlite3.h release 3.3.7 causes problems when compiling as C++ because "const" structure members can only be initialised by a user-defined constructor. I think the "const" should probably be removed. I get the following warnings with MSVC 6.0: sqlite3.h(1644) : warning C4510: 'sqlite3_index_info' : default constructor could not be generated sqlite3.h(1619) : see declaration of 'sqlite3_index_info' sqlite3.h(1644) : warning C4610: struct 'sqlite3_index_info' can never be instantiated - user defined constructor required _2007-Feb-08 15:13:58 by anonymous:_ {linebreak} I also meet this problem. Why this issue is Pending? I need this fixed to use the 3.3.x series. ---- _2007-Sep-07 22:23:51 by anonymous:_ {linebreak} I ran into this today. I spent some time working on it. It would be nice if this were fixed up or if a workaround were published. ---- _2007-Sep-08 15:54:55 by anonymous:_ {linebreak} Just hack the sources to remove the const or upgrade your compiler. ---- _2007-Sep-21 14:31:29 by anonymous:_ {linebreak} Fixed by Check-in [4445] #f2dcdc 2917 code active 2008 Feb anonymous 2008 Feb 4 4 Tcl interface - busy callback confusion script/procedure 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:_ {linebreak} 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"" #f2dcdc 2916 code active 2008 Feb anonymous 2008 Feb 1 1 sqlitedll-3_5_5.zip is older 3.5.4 binary sqlitedll-3_5_5.zip in download section is same with old 3.5.4 binary. _2008-Feb-01 12:13:04 by anonymous:_ {linebreak} Yes , I can confirm it #f2dcdc 2915 build active 2008 Feb pweilbacher 2008 Feb 4 3 fix Makefile for platforms that need .exe extension 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. #cfe8bd 2904 code fixed 2008 Jan anonymous 2008 Feb pweilbacher 3 3 os_os2.c - 2 dysfunctional functions The attached patch fixes os2Truncate() and os2FullPathname(). Currently, os2Truncate() does nothing useful. It moves the pointer associated with a file handle but has no effect on the file's size. The patch provides code that will change the actual size of a file on the disk. os2FullPathname() is overly complex and fails in marginal cases. E.g. for file "c:\programs\myapp\mydata.db", it fails to return a fully-qualified path when given "c:mydata.db". The patch replaces existing code with a single API call that always returns a valid result. Submitted by Rich Walsh (richATe-vertise.com) #f2dcdc 2228 new active 2007 Feb anonymous 2008 Feb 3 4 horizontal partitioning 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:_ {linebreak} 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. #f2dcdc 2914 code active 2008 Jan anonymous 2008 Jan 3 3 ATTACH returns SQLITE_ERROR when it means SQLITE_BUSY 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. #cfe8bd 2913 code fixed 2008 Jan anonymous 2008 Jan 3 3 vtab regression failures FYI: vtab6-2.2... Expected: [1 2 3 {} 2 3 4 1 3 4 5 2] Got: [1 2 3 {} 2 3 4 {} 3 4 5 {}] vtab6-2.3... Ok vtab6-2.4... Expected: [1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3] Got: [1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 {} {} {}] vtab6-2.5... Expected: [2 3 4 {} {} {} 3 4 5 1 2 3] Got: [2 3 4 {} {} {} 3 4 5 {} {} {}] vtab6-2.6... Expected: [1 2 3 {} {} {} 2 3 4 {} {} {}] Got: [1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 {} {} {}] vtab6-3.1... Ok vtab6-3.2... Ok vtab6-3.3... Ok vtab6-3.4... Ok vtab6-3.5... Ok vtab6-3.6... Ok vtab6-3.7... Ok vtab6-3.7... Ok vtab6-4.1... Ok vtab6-4.2... Ok vtab6-4.3... Ok vtab6-4.4... Ok vtab6-4.6... Ok vtab6-4.7... Ok vtab6-4.8... Ok vtab6-4.9... Ok vtab6-4.10... Ok vtab6-7.1... Expected: [1 999 999 2 131 130 999] Got: [1 999 999 999 999 999 999] vtab6-8.1... Ok vtab6-8.2... Ok vtab6-8.3... Ok vtab6-9.1... Ok vtab6-9.1.1... Expected: [] Got: [2 22 {}] vtab6-9.2... Expected: [] Got: [2 22 {}] vtab6-10.1... Ok #f2dcdc 2912 new active 2008 Jan anonymous 2008 Jan 5 4 merge join Would it be possible to implement merge joins? #f2dcdc 2911 code active 2008 Jan anonymous 2008 Jan 2 2 Adding parentheses to a FROM clause 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 #c8c8c8 2910 new closed 2008 Jan anonymous 2008 Jan 1 2 Number of rows in result set - new API Performance problem to retrieve number of records in result set after executed any query using prepare/step is evident. On DB around 200MB using one table with 15.000 records having around 10 fieds, among it's one blob field with data less than 10KB in each record, executed query with 'where' clausule using prepare/step (have no blob field listed) last around 30s to only count records in result set. SQLIte3_Get_Table need only 3s to returning all data as well. I I'm aware that many asserts may slow down the whole process dramatically, however not 10 times. Since there is no an API to retrieve number of records in result set and as prepare/step is far to slow, suggestion is to create one API, with maximum optimization for the purpose. _2008-Jan-31 02:00:07 by anonymous:_ {linebreak} To discover the number of rows, the VDBE engine should iterate over every record of the result. This is the same as calling sqlite_step() until EOF. But you can't do that, because after each sqlite_step(), you lost in memory data fields fetched for each row, so the way is counting rows after iteration. Also, tickets should be used for reporting bugs only. ---- _2008-Jan-31 04:24:29 by danielk1977:_ {linebreak} Internally, sqlite3_get_table() uses sqlite3_exec() which uses sqlite3_prepare()/step()/finalize(). So you should look for another reason why get_table() is 10 times faster than prepare()/step()/finalize(). You could also try a "SELECT count(*) ..." query to determine the expected size of a result set. As the above poster points out, there is no way to efficiently add this capability to SQLite (at least, no more efficiently than evaluating a count(*) query before the "real" query). Dan. ---- _2008-Jan-31 08:19:05 by anonymous:_ {linebreak} Anonymous: As allowed during ticket adding, I propose new feature. Dan: Since this feature should speed-up performance of a SQLite wrapper, "SELECT count(*) ..." is a real problem (require careful parsing to redesine gived query). "SELECT count(*) ..." itself is reasonably fast. ---- _2008-Jan-31 08:54:56 by anonymous:_ {linebreak} In addition to upper. "SELECT count(*)..." exactly last around 3s, Get_Table last as well around 3s, prepare/step/finalyze to only count numbers of records last 30s. This clearly indicate radically performance lost in prepare/step/finalyze. #f2dcdc 2909 build active 2008 Jan aswift 2008 Jan aswift 4 4 Omit the _XOPEN_SOURCE 500 define on Mac OS-X (check for __APPLE__) 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. #f2dcdc 2908 code active 2008 Jan anonymous 2008 Jan 3 3 Add support to examine whether statements modify the database 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. #f2dcdc 2907 code active 2008 Jan anonymous 2008 Jan 1 1 Issues of sqlite3 with Windows Mobile 5/6 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:_ {linebreak} 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) #c8c8c8 2906 code closed 2008 Jan anonymous 2008 Jan anonymous 2 2 Error in MSVC v.6.0 (optimization: Maximize Speed mode) Hello, I am Vyacheslav Pindura (Kiev, Ukraine). I will detect error in MSVC v.6.0 (optimization: Maximize Speed mode). Look accessPayload() function in amalgamation project (the same in btree.c in separeted project). This is fragment from sqlite.cod (listing generated by MSVC compiler). Look my comment "//SLA: ..."
     <<<<<< BEGIN LISTING ; COMDAT _accessPayload _TEXT SEGMENT _pCur$ = 8 _offset$ = 12 _amt$ = 16 _pBuf$ = 20 _skipKey$ = 24 _eOp$ = 28 _nKey$ = -12 _iIdx$ = -8 _pPage$ = -4 _pBt$ = -4 _ovflSize$62039 = 24 _nextPage$62040 = 12 _pDbPage$62056 = -12 _accessPayload PROC NEAR    ; COMDAT  ; 29385: ){    00000 83 ec 0c  sub  esp, 12   ; 0000000cH   00003 53   push  ebx   00004 55   push  ebp   00005 56   push  esi  ; 29386:   unsigned char *aPayload; ; 29387:   int rc = SQLITE_OK; ; 29388:   u32 nKey; ; 29389:   int iIdx = 0; ; 29390:   MemPage *pPage = pCur->pPage;     /* Btree page of current cursor entry */    00006 8b 74 24 1c  mov  esi, DWORD PTR _pCur$[esp+20]   0000a 57   push  edi   0000b 33 db   xor  ebx, ebx   0000d 8b 7e 1c  mov  edi, DWORD PTR [esi+28]  ; 29391:   BtShared *pBt;                   /* Btree this cursor belongs to */ ; 29392: ; 29393:   assert( pPage ); ; 29394:   assert( pCur->eState==CURSOR_VALID ); ; 29395:   assert( pCur->idx>=0 && pCur->idxnCell ); ; 29396:   assert( offset>=0 ); ; 29397:   assert( cursorHoldsMutex(pCur) ); ; 29398: ; 29399:   getCellInfo(pCur);    00010 56   push  esi   00011 89 5c 24 18  mov  DWORD PTR _iIdx$[esp+32], ebx   00015 89 7c 24 1c  mov  DWORD PTR _pPage$[esp+32], edi   00019 e8 00 00 00 00  call  _getCellInfo  ; 29400:   aPayload = pCur->info.pCell + pCur->info.nHeader;    0001e 8b 4e 24  mov  ecx, DWORD PTR [esi+36]  ; 29401:   nKey = (pPage->intKey ? 0 : pCur->info.nKey);    00021 8a 47 03  mov  al, BYTE PTR [edi+3]   00024 33 ed   xor  ebp, ebp   00026 83 c4 04  add  esp, 4   00029 66 8b 6e 38  mov  bp, WORD PTR [esi+56]   0002d 03 e9   add  ebp, ecx   0002f 84 c0   test  al, al   00031 74 08   je  SHORT $L80642   00033 33 c0   xor  eax, eax   00035 89 44 24 10  mov  DWORD PTR _nKey$[esp+28], eax   00039 eb 0a   jmp  SHORT $L80643 $L80642:   0003b 8b 4e 2c  mov  ecx, DWORD PTR [esi+44]   0003e 8b 4e 28  mov  ecx, DWORD PTR [esi+40]   00041 89 4c 24 10  mov  DWORD PTR _nKey$[esp+28], ecx $L80643:  ; 29402: ; 29403:   if( skipKey ){    00045 8b 4c 24 30  mov  ecx, DWORD PTR _skipKey$[esp+24] //SLA:  ecx:=skipKey  ; 29404:     offset += nKey;    00049 8b 7c 24 24  mov  edi, DWORD PTR _offset$[esp+24] //SLA:  edi:=offset   0004d 3b cb   cmp  ecx, ebx   0004f 74 02   je  SHORT $L62032   00051 03 f9   add  edi, ecx    //SLA:  offset += skipKey   !!! $L62032:  ; 29405:   } ; 29406:   if( offset+amt > nKey+pCur->info.nData ){    00053 8b 54 24 28  mov  edx, DWORD PTR _amt$[esp+24]   00057 8b 46 30  mov  eax, DWORD PTR [esi+48]   0005a 03 44 24 10  add  eax, DWORD PTR _nKey$[esp+28]   0005e 8d 0c 17  lea  ecx, DWORD PTR [edi+edx]  //SLA:  edi have (offset+skipKey) !!!   00061 3b c8   cmp  ecx, eax   00063 76 0d   jbe  SHORT $L62033   00065 5f   pop  edi   00066 5e   pop  esi   00067 5d   pop  ebp  ; 29407:     /* Trying to read or write past the end of the data is an error */ ; 29408:     return SQLITE_ERROR;    00068 b8 01 00 00 00  mov  eax, 1   0006d 5b   pop  ebx  ; 29510: } <<<<<<< END LISTING 
    So, optimization imposible !!! We need disable optimization in MSVC project :( Best regards, Vyacheslav. _2008-Jan-27 12:51:32 by drh:_ {linebreak} See also ticket #2657. There have been other reports of problems with MSCV 6.0 and SQLite, some of which result in an "Internal Compiler Error" and others which just cause incorrect code to be generated. At this point we recommend that you *not* use MSVC 6.0 to build SQLite or any other project for that matter. If you must use MSVC 6.0, at least disable optimization. To be fair to MSVC, other compilers also have bugs. Ticket #2469 is an example of an optimizer bug in GCC which has since been fixed. Thank you for reporting this problem. But this really is a bug in MSVC, not in SQLite, so there is nothing that we can do about it. #f2dcdc 2905 code active 2008 Jan anonymous 2008 Jan pweilbacher 2 2 mutex_os2.c - incorrect mutex implementation 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) #f2dcdc 2903 code active 2008 Jan anonymous 2008 Jan 2 2 tclinstaller.tcl fails on path and permissions issue 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:_ {linebreak} 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. #f2dcdc 2902 code active 2008 Jan anonymous 2008 Jan drh 3 3 Add watch support to SQLite 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:_ {linebreak} Great idea and nice job. This functionality is very useful. ---- _2008-Jan-31 18:27:16 by anonymous:_ {linebreak} Any chance to get this committed for the next release (i.e. 3.5.6)? ---- _2008-Jan-31 19:38:35 by drh:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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. #f2dcdc 2901 code active 2008 Jan anonymous 2008 Jan 3 3 ROLLBACK and COMMIT statements should not expire 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). #c8c8c8 2900 code closed 2008 Jan anonymous 2008 Jan 3 4 Can't ESCAPE in GLOB If you apply an ESCAPE clause to the GLOB operator, you get the message: SQL error: wrong number of arguments to function glob() You can reproduce this on Mac OS X 10.5 with the following:
     $ sqlite3 test.db SQLite version 3.4.0 Enter ".help" for instructions sqlite> create table Identifiers ( ident text ); sqlite> insert into Identifiers values ( "foo?" ); sqlite> insert into Identifiers values ( "foo" ); sqlite> insert into Identifiers values ( "foo_" ); sqlite> select * from Identifiers where ident like "foo\_" escape "\"; foo_ sqlite> select * from Identifiers where ident glob "foo\?" escape "?"; SQL error: wrong number of arguments to function glob() 
    I believe that this is because sqlite3RegisterLikeFunctions (in "func.c") registers the "like" function with either 2 or 3 arguments, but only registers the "glob" function with 2 arguments. _2008-Jan-22 13:04:28 by drh:_ {linebreak} Escape characters in a GLOB as you would in a shell glob, which is to put them inside of a [...]. Example: select * from identifiers where ident glob 'foo[?]'; Note also the use of single-quotes instead of double-quotes around the string literal. SQL requires single-quotes. #f2dcdc 2899 code active 2008 Jan anonymous 2008 Jan 4 4 sqlite3_reset() after exec() takes > 100 ms to complete 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,{linebreak} "SELECT [file_id],[file_name],[file_mime],[file_type],"{linebreak} "[file_size],[date_created],[date_accessed],[data] "{linebreak} "FROM file_cache WHERE [file_id] = ? LIMIT 1;",{linebreak} -1, &sqQueryStatement, &unused ); // query function -- called repeatedly (usually second or third run starts to cause big delays) /* begin function */ sqlite3_reset( sqQueryStatement );{linebreak} sqlite3_bind_int( sqQuerystatement, 1, 292 );{linebreak} sqlite3_step( sqQueryStatement );{linebreak} 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 #f2dcdc 2898 code active 2008 Jan anonymous 2008 Jan 1 1 Latest CVS for 3.5.4 fails to build test1.c 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} Still fails the same based on today's cvs update. ---- _2008-Jan-23 03:14:49 by anonymous:_ {linebreak} This bug fixed as of latest cvs pull #f2dcdc 2897 code active 2008 Jan anonymous 2008 Jan 1 1 String or BLOB exceed size limit 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} This issue is probably resolved by check-in [4636], then. ---- _2008-Jan-18 14:28:13 by anonymous:_ {linebreak} 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. #c8c8c8 2896 code closed 2008 Jan anonymous 2008 Jan 1 1 FTS3 misses document, but finds non-matching ones instead The following script presents a severe bug in FTS3 where it does not find a document even though it is in the index. Instead it finds other documents which do not match the search criteria. The log below was generated by the original SQLite3.exe 3.5.4 downloaded from the web-site. It shows that the entry 'A-123' is present in the table but is not matched by the query. It also demonstrates that non-matching entries are found instead. DROP TABLE IF EXISTS fts3; CREATE VIRTUAL TABLE fts3 using fts3 (a); INSERT INTO fts3 VALUES ('A-123'); SELECT * FROM fts3; A-123 SELECT * FROM fts3 WHERE fts3 MATCH 'A-123'; INSERT INTO fts3 VALUES ('A-12'); SELECT * FROM fts3 WHERE fts3 MATCH 'A-123'; A-12 INSERT INTO fts3 VALUES ('A-1'); SELECT * FROM fts3 WHERE fts3 MATCH 'A-123'; A-12 A-1 Here is the SQL only (without output, for easy reproduction): DROP TABLE IF EXISTS fts3; CREATE VIRTUAL TABLE fts3 using fts3 (a); INSERT INTO fts3 VALUES ('A-123'); SELECT * FROM fts3; SELECT * FROM fts3 WHERE fts3 MATCH 'A-123'; INSERT INTO fts3 VALUES ('A-12'); SELECT * FROM fts3 WHERE fts3 MATCH 'A-123'; INSERT INTO fts3 VALUES ('A-1'); SELECT * FROM fts3 WHERE fts3 MATCH 'A-123'; _2008-Jan-17 19:36:18 by anonymous:_ {linebreak} Sorry, I must have been dreaming: This is of course *not a bug* but the expected behavior. The '-' character is supposed to exclude the word following it. My sincere apologies if this has caused doubt or uncertainties to anyone! #c8c8c8 2895 build closed 2008 Jan anonymous 2008 Jan 3 1 Please describe how to run an indvidual test out of the test suite Please describe how to run an individual test out of the test suite? Thanks. For example, how to run the test incrvacuum-ioerr-1.31.4 _2008-Jan-17 17:14:12 by drh:_ {linebreak} Tickets are for reporting bugs, not asking questions about how to compile or operate SQLite. For questions of that nature, please post comments on the SQLite mailing list. See http://www.sqlite.org/support.html. PS: You cannot run individual tests. You have to run an entire script. #cfe8bd 2894 code fixed 2008 Jan anonymous 2008 Jan 1 1 virtual table calls Next() and Column() after Eof() returns true I saw this problem in my virtual table implementation. When I had a query that used a left outer join on a column that could be NULL, Next() and Column() were called after Eof() had returned true. I tried to reproduce the problem using test_schema from the source distribution which resulted in a segmentation fault, and I assume it's the same defect. Here is a sample script: .load test_schema.so create virtual table x using schema; -- this produces results select * from x where dflt_value is null; -- this produces a segmentation fault select * from x lhs left outer join x rhs on lhs.dflt_value = rhs.dflt_value; #f2dcdc 2893 code active 2008 Jan anonymous 2008 Jan 1 1 incorrect integer range tests 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:_ {linebreak} See the remarks on ticket #2280. The code duplicates the behavior of the FPU on x86. ---- _2008-Jan-16 18:21:28 by anonymous:_ {linebreak} 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:_ {linebreak} Just because the double to int overflow behavior happens to be that way with GCC on x86, is it desirable? #f2dcdc 2892 new active 2008 Jan anonymous 2008 Jan 5 5 There should be a way in the api to read more precise error message. 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} What error message do you get from the CLI? #c8c8c8 2891 code closed 2008 Jan anonymous 2008 Jan 2 3 col with "NOT NULL", no default: works on table create, not col add 1: WORKS: CREATE TABLE my_table ("my_column" integer NOT NULL); 2: GIVES ERROR: ALTER TABLE my_table ADD "my_other_column" integer NOT NULL; (2) gives the error: "SQL error: Cannot add a NOT NULL column with default value NULL" This is inconsistent, either both cases should work, or both should give an error. _2008-Jan-15 19:59:03 by anonymous:_ {linebreak} This is default in all SQL database managers. If a column can't have a default NULL value, how it will be added to a table with existing rows ? How that columns will have the default column value is there´s no default and has the NOT NULL constraint ? ---- _2008-Jan-16 00:15:50 by drh:_ {linebreak} Anonymous poster above is correct. This is not a bug. #c8c8c8 2890 build closed 2008 Jan anonymous 2008 Jan 1 1 Assistance request fixing six 3.5.4 i/o test failures Failures include 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 Please let me know how to run individual tests, so I can debug these and submit fix suggestions. Thanks. _2008-Jan-15 21:50:52 by drh:_ {linebreak} These errors do not appear when the tests are run individually. They are only reproducible when you run the complete test suite. ---- _2008-Jan-16 03:15:50 by anonymous:_ {linebreak} Please give an example of how to run one individual test. Thanks. #c8c8c8 2889 build closed 2008 Jan anonymous 2008 Jan 3 2 Cannot disable TCL Slackware 12 TCL/TK is not installed, as I don't need it, and don't really want to install it Sequence of commands to reproduce : tar -xzvf sqlite-3.5.4.tar.gz cd sqlite-3.5.4 mkdir bld cd bld ../configure --disable-tcl --without-tcl make The last command dies with --------------------------------------------------- rm tsrc/sqlite.h.in tsrc/parse.y cp parse.c opcodes.c keywordhash.h tsrc tclsh ../tool/mksqlite3c.tcl make: tclsh: Command not found make: *** [sqlite3.c] Error 127 root@slack12:~/install/sqlite-3.5.4/bld# ls .. --------------------------------------------------- Thanks in advance Roman Same as #2845, #2346, #2871. #c8c8c8 2888 code closed 2008 Jan anonymous 2008 Jan 3 4 statement not commited code: #include #include "sqlite3.h" int main() { sqlite3 *db; sqlite3_stmt *stmt; sqlite3_open("test.db", &db); sqlite3_prepare(db, "SELECT 1", -1, &stmt, NULL); sqlite3_step(stmt); sqlite3_exec(db, "CREATE TABLE t(a INT)", NULL, NULL, NULL); printf("%s\n", sqlite3_errmsg(db)); return -1; } CREATE TABLE isn't commited. There is no BEGIN, CREATE TABLE doesn't return an error, so I think table should be created. _2008-Jan-15 12:28:21 by drh:_ {linebreak} The pending SELECT statement must complete before a COMMIT will occur. See the documentation. #c8c8c8 2887 code closed 2008 Jan anonymous 2008 Jan anonymous 5 5 || not outputing correctly with empty fields While using || to concatenate fields for output, the rows with a NULL field are not printed. Example: -all rows: sqlite> select vend_city,vend_state,vend_zip from vendors; vend_city vend_state vend_zip ---------- ---------- ---------- Bear Town MI 44444 Anytown OH 44333 Dollsville CA 99999 New York NY 11111 London N16 6PS Paris 45678 {linebreak} -Using ||, the 2 last rows with NULL states do not show on the output: {linebreak} sqlite> select vend_city ||','|| vend_state ||','|| vend_zip from vendors; vend_city ||','|| vend_state ||','|| vend_zip --------------------------------------------- Bear Town,MI,44444 Anytown,OH,44333 Dollsville,CA,99999 New York,NY,11111 _2008-Jan-15 12:30:30 by drh:_ {linebreak} The expression NULL || evaluates to NULL, regardless of the value of . This is in accordance with the SQL standard. Use the coalesce() or ifnull() functions to work around this. #f2dcdc 2886 code active 2008 Jan anonymous 2008 Jan 3 3 testfixture: -fPIC needed when building extension(s) (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 #f2dcdc 2885 code active 2008 Jan anonymous 2008 Jan 4 4 (minor) fulltest failures 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:_ {linebreak} A test from 20 minutes ago passes cleanly. This could be closed. #f2dcdc 2884 new active 2008 Jan anonymous 2008 Jan 4 4 Way to find out limits 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. #cfe8bd 2883 code fixed 2008 Jan anonymous 2008 Jan 1 1 compile error - missing data I have original sqlite 3.2.8 source code in external SVN and a dashboard has encountered the following compile error win gcc 4.x: "shell.c:364: error: format not a string literal and no format arguments" See http://mail.kde.org/pipermail/kde-dashboard/2008-January/008494.html Any SQLite newer is addected as well. The patch below fixes misused fprintf. Index: shell.c{linebreak} ==================================================================={linebreak} --- shell.c (revision 761314){linebreak} +++ shell.c (working copy){linebreak} @@ -361,7 +361,7 @@{linebreak} output_c_string(p->out, z);{linebreak} }{linebreak} if( bSep ){{linebreak} - fprintf(p->out, p->separator);{linebreak} + fprintf(p->out, "%s", p->separator);{linebreak} }{linebreak} }{linebreak} #f2dcdc 2882 code active 2008 Jan anonymous 2008 Jan 3 3 fulltest failure: ./testfixture: wrong # args: should be "cksum db" 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:_ {linebreak} The latest code seems to have fixed this. I would close this but I don't see how to do that. #f2dcdc 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 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:_ {linebreak} Same tests still fail with CVS of today around 11AM CST. ---- _2008-Jan-11 17:41:55 by drh:_ {linebreak} 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:_ {linebreak} 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. #cfe8bd 2880 code fixed 2008 Jan anonymous 2008 Jan 1 1 problem with reals bigger then 1e18 We've been reported (and confirmed) that there might be an isue using the Windows sqlite3 dll on large numbers. When defining fields as real then inserting data like 1e18 goes well, but 1e19 generates an error about being not a valid float. If you enter the data using sqlite3.exe there's no problem, retrieving the data is also working well. The problem arises when calling sqlite3step, the prepare does not give any error. We've checked and the same error appears using sqlite administrator (which is a Delphi development too, but using ZEOS). Since it goes wrong within sqlite3step this might be a sqlite isue? albert drent aducom software _2008-Jan-09 13:56:01 by drh:_ {linebreak} You write: "If you enter the data using sqlite3.exe there's no problem." But sqlite3.exe uses the sqlite3_prepare() and sqlite3_step() interface the same as anything else. So if sqlite3.exe is working, that suggests the problem is in your program, and not in the SQLite core. If you can provide a specific example of what is not working we can investigate this problem further. But based on the information provide, we are unable to reproduce the problem and suspect the problem is in the application, not in SQLite. ---- _2008-Jan-09 15:48:49 by anonymous:_ {linebreak} Delphi has been known to futz with the FPU registers. It's possible that Delphi is changing the FPU accuracy and causing this problem. ---- _2008-Jan-09 19:49:57 by anonymous:_ {linebreak} I don't know where the problem lies and will investigate further. It's not a fpu isue since it's a ansistring containing the string, being prepared and executed. There hardly any Delphi involved here. I'll create a small app in Delphi showing the problem and report this issue on Delphi forums too. The string is somewhat like 'insert into demo (myval) value (1e19)' Will come back here. Albert ---- _2008-Jan-10 13:47:28 by anonymous:_ {linebreak} Thanks to sasa: he found out the following It appears to be a problem in used C compiler. Following script is tested in sqlite 3-5-4 shell: create table t1 (ID integer primary key, v1 double); insert into t1(v1) values(1e18); insert into t1(v1) values(1e19); This works correctly on linux compiled with GNU compiler 4.1.2. On windows with MinGW 3.2.0 works correctly too, however it fails when shell is compiled with BCC 5.5.1. Without detail check I can only assume there is a problem in representing and using 8 and 6 bytes floats together in SQLite without explicit casting BCC may require. Or this may be a limitation of BCC 5.5.1 or a bug. Without detail check those are most probably causes. ---- _2008-Jan-10 14:01:30 by drh:_ {linebreak} SQLite does not use any "6 byte floats". I'm not sure what a 6 byte float is. The code in SQLite is suppose to be ANSI C and casts that are not required by ANSI C are generally omitted. If you find an exception to this please let us know. If BCC requires casts above and beyond what is required by ANSI C, then that is a bug in BCC. I assume then, that this is a bug in BCC. I do not have access to BCC so there is nothing I can do to fix it. If you can suggest patches that will work around the BCC bug (for example, some unnecessary explicit casts) we will consider adding them to the core. But I am afraid it will be up to you to supply those patches, since we do not have BCC available to experiment with and SQLite works perfectly for every compiler we have access to. ---- _2008-Jan-10 18:34:56 by anonymous:_ {linebreak} Funny thing is that if the dll is created with a gnu compiler it seems to work. Can you tell me with what compiler the dll (w.o. tcl binding) has been build? ---- _2008-Jan-10 20:16:12 by anonymous:_ {linebreak} This is the reply of sasa, it's way ahead of me... Unfortunately, I have no more time to test any DLL since I do not using any I did not compiled myself. As I understand vac, that one from official SQLite site have this bug. In the signature of DLL can be seen which compiler was used for compilation. BCC 5.5.1 is free and can freely be downloaded from official Borland site by anyone. This is I prepared to add to the ticket, but you can add yourself. I have spent all my spare time for now. Since it do not break anything it will be probably included in official version:
     /* ** The MEM structure is already a MEM_Real. Try to also make it a ** MEM_Int if we can. */ SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){   assert( pMem->flags & MEM_Real );   assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );   pMem->u.i = pMem->r; // <- This causing termination for values >= 1e19   if( ((double)pMem->u.i)==pMem->r ){     pMem->flags |= MEM_Int;   } } 
    This conversion line causing BCC 5.5.1 run-time to raise a conversion error if values are >= 1e19. It is necessary a clean way to convert double to integer/int64. If nothing else, this will solve the problem (code is not essential for correct functionality):
     /* ** The MEM structure is already a MEM_Real. Try to also make it a ** MEM_Int if we can. */ SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){   assert( pMem->flags & MEM_Real );   assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );  #ifndef __BORLANDC__   pMem->u.i = pMem->r;   if( ((double)pMem->u.i)==pMem->r ){     pMem->flags |= MEM_Int;   } #endif } 
    [ Bijgewerkt do jan 10 2008, 08:49 ] SZUTILS - link ---- _2008-Jan-11 10:23:37 by anonymous:_ {linebreak} In "sqlite - Check-in [4705]" you have tryed to "attempt to work around this bug in the Borland compiler + ** by moving the value into a temporary variable first so that if + ** the assignment into the integer really does corrupt the right-hand + ** side value, it will corrupt a temporary variable that we do not + ** care about." First of all, thank you for attempt to solve the issue. I will first write several facts: 1. Statically linked SQLite 3.5.4 commandline shell (aka sqlite3.exe) is compiled and SQL script worked fine on Windows with MinGW 3.2.3, however not with BCC 5.5.1 (without any special compiler options). 2. Library (aka sqlite3.dll) compiled with MinGW 2.95 (from official SQLite site), MinGW 3.2.3, BCC 5.5.1 and probably other compilers for Windows does FAIL executing provided SQL script only with large floats >=1e19. With MinGW 3.2.3, library was created from official SQLite 3.5.4 distribution with following script: sh configure make dll 3. Both (integer and double) have 8 byte size in BCC. BCC is ANSI C complient compiler. 4. It is not the fact that BCC corrupt right-hand side value. It fail trying to convert values >=1e19 and assign it to int64 variable. This will raise invalid floating-point operation exception for most C compilers. 5. Since front-end application use only DLL (compiled by several different C compilers, including provided from offical SQLite site) to execute an SQL command by sqlite_exec(), it is nothing which connect the bug and the application itself (made in Delphi or C). Current attempt in 4705 will not work from two reasons: 1. The same conversion logic is used. 2. Variable definition in the middle of the function in not allowed by ANSI C. This will fail not only on BCC, but on any ANSI C compiler. According to upper, conclusion is clear that this is not a bug in BCC, but in all C compiles for Windows - or in conversion double to integer currently used. Thank you for your time. Sasa Zeman ---- _2008-Jan-11 13:22:27 by drh:_ {linebreak} The purpose of the sqlite3VdbeIntegerAffinity() function is to convert a floating point value into a 64-bit integer value if and only if that conversion can be done without loss of precision. Perhaps Sasa Zeman or somebody else can suggest a way to do that successfully on BCC 5.5.1. (The current implementation appears to work on every other compiler.) Or perhaps this is not a compiler issue at all, but an instance of Delphi messing with FPU registers, as was suggested by the anonymous comment on 2008-Jan-09. Please note that I do not own a machine that runs windows, and I am unwilling to purchase one for the purpose of fixing this issue. So I cannot download and install BCC 5.5.1 or Delphi. And thus, I cannot reproduce the problem here. So if you want this problem resolved, you are going to need to suggest code for resolving it. Completely disabling the sqlite3VdbeIntegerAffinity() function is not an acceptable resolution because that breaks quite a few other things. ---- _2008-Jan-11 14:00:05 by anonymous:_ {linebreak} AFAIK it is a general compiler isue on Windows. Reading Sasa's comment this is NOT a Delphi isue since the problem lies in SQLite3.dll. In fact, the tests who are shown here are all done in C++. What I would like to know is how the Windows dll on this website and which DOES have this problem, is created and with what compiler. Appearantly you haven't created this one since you do not own a Windows compiler (?). Then we are in pursuit of an answer and solution. Ignoring the problem is not an option IMHO and would be bad news to all on the Windows community. The Borland C++ compiler with the patch here (SASA does this work?) is completely FREE and doesn't need to be purchased. But if this isue cannot be resolved, and I'm not a C++ guru, then there should be a note here that on Windows the precision is limited to 10e18??? There are now three people busy with this, sure there must be a solution in conjunction with all of us? It's in everyones benefit if this isue can be resolved in stead of ignored. ---- _2008-Jan-11 14:36:11 by drh:_ {linebreak} The windows binaries on the SQLite website are cross-compiled on a Linux box using Mingw-GCC. ---- _2008-Jan-11 17:49:26 by anonymous:_ {linebreak} Which steps do I need to take to reproduce the problem? It seems to work just fine with sqlite3.exe 3.5.0 on Windows XP: sqlite> create table t1 (ID integer primary key, v1 double); sqlite> insert into t1(v1) values(1e18); sqlite> insert into t1(v1) values(1e19); sqlite> select * from t1; 1|1.0e+18 2|1.0e+19 Could someone please post a little C-code which exhibits the problem? Thanks! ---- _2008-Jan-11 18:10:29 by anonymous:_ {linebreak} Thank you for your respond. In order to reproduce the problem, you can create very simple C program using the DLL, which execute upper script by each line, using sqlite3_exec() command. Thank you for your time. Sasa ---- _2008-Jan-11 19:05:51 by anonymous:_ {linebreak} The following: + static const i64 maxInt = (((i64)0x7fffffff)<<32)|0xffffffff; + static const i64 minInt = ((i64)0x80000000)<<32; + + if( r<(double)minInt ){ + return minInt; + }else if( r>(double)maxInt ){ runs faster on my compiler if you do this: + static const double maxInt = (((i64)0x7fffffff)<<32)|0xffffffff; + static const double minInt = ((i64)0x80000000)<<32; + + if( rmaxInt ){ ---- _2008-Jan-12 11:26:41 by anonymous:_ {linebreak} I asked for code to reproduce the problem and would like to report back that I was able to do so on WinXP using Delphi. Here are my findings: *: The sqlite3.exe console provided on the SQLite web-site is not affected by the problem, it executes the SQL above with no errors. *: The precompiled sqlite3.dll from the SQLite web-site does show the problem (version 3.5.4 tested) when executing the SQL through sqlite3_exec(). *: The {link:http://www.yunqa.de/delphi/ DISQLite3} Delphi library does not exhibit the problem (same tests as with sqlite3.dll). DISQLite3 is compiled with Borland's C Compiler, so I conclude that it is not a BCC problem. *Cause* of the problem with sqlite3.dll is a FPU exception, probably generated by converting 1e19 to a 64-bit integer in the line identified above. AFAIK, Windows -- contrary to Linux -- has FPU exceptions turned on by default, which would explain why Linux users do not see it. A *solution* is to disable FPU exceptions for Win applications which use sqlite3.dll. I'd generally recommended to do so, since there are other parts in the SQLite code which depend on the FPU not raising exceptions. SQLite is, by the way, not the odd one out with this recommendation: The Delphi help recommends to do so when using OpenGL as well. In Delphi, this call disables all FPU exceptions. Run it before calling any SQLite functions: Set8087CW($133F); { Disable all FPU exceptions. } BCC has these available: unsigned int _control87(unsigned int newcw, unsigned int mask); unsigned int _controlfp(unsigned int newcw, unsigned int mask); /* For MS compatability. */ With FPU exceptions disabled, the SQL executes correctly using sqlite3.dll 3.5.4. Since I can not recompile sqlite3.dll exactly as the downloaded version, I can not test if changes in [4706] still require to disable FPU exceptions. ---- _2008-Jan-12 19:34:01 by anonymous:_ {linebreak} Thank you for your respond. I suppose it is all clear now. That explains why GNU compiled SQLite shell works correctly on Windows too, but not its DLL - GNU force disabling FPU exceptions at program beginning to preserve multi-platfom compatibility. Changes in [4706] solve the issue in this case. Compiled DLL from latest CVS works correctly. If exist similar coversion in the SQLite code, that should be solved as well. Current souluton in [4706] is suggested to be permanent since SQLite is DB engine, not a math computation library. Thus enabling/disabling FPU exceptions ($133F/$1332) can be a bit of problem if front-end application is math oriented and take explicit care of FPU exceptions. And second reason is connected - not to pressing user of SQLite to set unnecesary FPU settings which is highly depent on his compiler/RAD. And last and most important - preserve multi-platform compatibility. Thank you once again. As well, thanks to author(s) of SQLite for solving the issue. Sasa ---- _2008-Jan-13 12:56:31 by anonymous:_ {linebreak} I'm glad that the isue has resolved finally. Thanks to everybody working on this. Albert Drent aducom software ---- _2008-Jan-13 17:37:46 by anonymous:_ {linebreak} The patch is incorrect: + if( r<(double)minInt ){ + return minInt; + }else if( r>(double)maxInt ){ + return minInt; <============= should return maxInt here also consider making minInt and maxInt const doubles instead of const ints. ---- _2008-Jan-13 18:20:13 by drh:_ {linebreak} Actually, the patch is correct as written. Attempting to convert a out-of-range double into an integer yields 0x8000000000000000 regardless of whether or not the double is positive or negative. At least this is what intel hardware does. I did consider making the minInt and maxInt constants doubles, but that would mean that the conversion from integer to double would occur on the build machine, which might do the conversion differently than the target machine. It seems safer to do the conversion at runtime. We might reconsider this in the future. ---- _2008-Jan-13 19:38:50 by anonymous:_ {linebreak} In C, casting an out of range double to int is undefined, as was SQLite's previous behavior by extension. GCC on x86 happens to yield 0x8000000000000000 for positive overflow, a negative value. This is not guaranteed for other compilers even on x86. I can understand why you'd want to be compatible with x86 GCC, but you have a chance for this database operation to at least preserve the sign of the number even though you lose the magnitude. This has value. #f2dcdc 2879 code active 2008 Jan anonymous 2008 Jan anonymous 4 3 VACUUM enters temporary sequence numbers in sqlite_sequence 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. #f2dcdc 2878 code active 2008 Jan anonymous 2008 Jan 1 1 Memory leaks with latest CVS [4693] 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} A test from 20 minutes ago passes cleanly. This could be closed. #cfe8bd 2877 code fixed 2008 Jan anonymous 2008 Jan 1 1 Unescaped quotation marks in mkopcodeh.awk (CVS [4693]) mkopcodeh.awk line 146 is missing escapes in front of the "case" quotation marks: print "** comments following the "case" for each opcode in the vdbe.c" Works for me with: print "** comments following the \"case\" for each opcode in the vdbe.c" #c8c8c8 2876 build closed 2008 Jan anonymous 2008 Jan 1 1 3.5.4 fails to build on OpenBSD... $ ./configure --prefix=/home/achowe/Projects/org/sqlite --disable-tcl --enable-threadsafe $ make ... rm tsrc/sqlite.h.in tsrc/parse.y cp parse.c opcodes.c keywordhash.h tsrc tclsh ./tool/mksqlite3c.tcl tclsh: not found *** Error code 1 There appears to be a TCL dependency even though I've specified --disable-tcl. Stock OpenBSD does not supply TCL and I have no desire to install it. Duplicate of ticket #2845. #f2dcdc 2875 code active 2008 Jan anonymous 2008 Jan 3 2 LIKE does not work with lowercase swedish characters Swedish letters å,ä,ö is not supported by the LIKE statement. When trying to perform a query like SELECT * FROM table WHERE name LIKE "å%" we will not get a match for names starting on Å (which is uppercase for å). 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 ('Åland'); sqlite> INSERT INTO TestingTable values ('åland'); sqlite> SELECT * FROM TestingTable; Sweden sweden Åland åland sqlite> SELECT * FROM TestingTable WHERE Name LIKE "swe%"; Sweden sweden sqlite> SELECT * FROM TestingTable WHERE Name LIKE åla%"; åland ============================================================ #f2dcdc 2874 code active 2008 Jan anonymous 2008 Jan 1 1 THREADSAFE #define HAVE_LOCALTIME_R, HAVE_GMTIME_R in os_unix.c 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? #f2dcdc 2873 code active 2008 Jan anonymous 2008 Jan 1 1 HAVE_USLEEP, HAVE_FDATASYNC=1 detected but not used by configure; make 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:_ {linebreak} 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." #f2dcdc 2872 code active 2008 Jan anonymous 2008 Jan 4 4 Some table scan operations could use an index for better data density 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). #c8c8c8 2871 build closed 2008 Jan anonymous 2008 Jan 3 3 SQLite 3.5.4 build process does not listen to --disable-tcl I build sqlite without TCL support, with an incantation along the lines of: =../sqlite-3.5.4/configure --disable-tcl; make=. This works fine in 3.5.3 but 3.5.4 fails late in the compilation, looking for =tclsh=: =tclsh ../sqlite-3.5.4/tool/mksqlite3c.tcl= is the command it's trying to run. I'm building on Solaris 10u4 and the full incantation for =configure= is as follows (most of this is for readline): =../sqlite-3.5.4/configure --prefix=/home/tfb/packages/sqlite-3.5.4 --enable-static=no --with-readline-lib="-L/opt/sfw/lib -R/opt/sfw/lib -lreadline -lcurses" --with-readline-inc=-I/opt/sfw/include --disable-tcl=. I use =gmake= (which is GNU make, in =/usr/sfw/bin= on Solaris 10) to compile. This is not urgent for me - I will just stick with 3.5.3 for now - but it would be nice to avoid mandatory dependence on TCL I think. Thanks --tim Duplicate of ticket #2845 #c8c8c8 2870 code closed 2008 Jan anonymous 2008 Jan danielk1977 5 5 Comment error In the #4666 checkin comment is: +** Change the value of the P3 operand for a specific instruction. +*/ +void sqlite3VdbeChangeP5(Vdbe *p, int addr, u8 val){ but should be: .... P5 .... operand Thanks. #f2dcdc 2869 new active 2008 Jan anonymous 2008 Jan 5 5 add "sqlite3_open16_v2" to the C API 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. #c8c8c8 2868 code closed 2008 Jan anonymous 2008 Jan 1 1 Encryption user can't link latest SQLite I have licensed the encryption package and have it working with an earlier version of SQLite. I downloaded the current stable release, copied it over the previous version and compiled it. It compiled fine, but now the pager has unresolved externals, it seems many of the function names have changed. Please advise. Thanks Tim _2008-Jan-03 14:00:20 by drh:_ {linebreak} The license is perpetual with unlimited free updates. You just have to send us private email and we will send you back the latest code. #f2dcdc 2867 code active 2008 Jan anonymous 2008 Jan 2 2 doesn't build on Cygwin - wrong sqlite3 exe suffix The new Makefile used $(EXE), which doesn't seem to be defined (typo?) _2008-Jan-02 11:12:39 by anonymous:_ {linebreak} 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) 
    #f2dcdc 2866 build active 2008 Jan anonymous 2008 Jan 1 3 Problems building Windows native in cygwin/mingw environment 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 $ #c8c8c8 2862 warn closed 2007 Dec anonymous 2008 Jan 4 3 Small warning fix Hi, There is a harmless warning in btree.c about szNext being used uninitialized, with a comment in the code saying that adding an extra initialization to silence it would slow it down. But I've done it another way which will probably make a tiny speed-up instead (only when failing some step though, I think) Diff:{linebreak} http://megasource.no-ip.org/PTstuff/btree.c.morefix {linebreak} http://megasource.no-ip.org/PTstuff/btree.c.fix (the original fix, just to silence the warning) _2008-Jan-01 06:19:11 by danielk1977:_ {linebreak} Thanks. #c8c8c8 2861 doc closed 2007 Dec anonymous 2008 Jan 1 1 How do I connect to Crystal Reports - I am using vs2003 & the Finisar Not sure of the right venue for this question. My apologies if this is not the right place. I am developing a simple accounting application for a non-profit organisation. I am using vs2003 and programming in c#. To date I have used Access (Jet) database files and the Crystal Report Generator built in to VS2003. I thought SQLite would be a better choice than the Access database - simple to change my c# code using the Finisar data provider, but I am at a loss to see how I can use this provider in Crystal. Is there any way to get this provider onto the list of ADO DB providers in Crystal - or any other approach I could use. If I cannot use Crystal is there an alternative for producing reports which can link to SQLite. Any help much appreciated. Roger Lovelock _2007-Dec-29 13:58:55 by anonymous:_ {linebreak} Not a bug. Better ask this on the mailing list. To subscribe to the list, send a message to: For help and a description of available commands, send a message to: ---- _2008-Jan-01 06:07:34 by danielk1977:_ {linebreak} This question would have a good chance of success if put to the mailing list. Suggest trying it there. #c8c8c8 2858 build closed 2007 Dec anonymous 2008 Jan danielk1977 3 3 amalgamated sqlite3.c requires sqlite3ext.h Staring with SQLite 3.5.3, the "amalgamted" source file sqlite3.c requires sqlite3ext.h to compile. This is because sqlite3.c attempts to effectively include sqlite3ext.h instead of simply copying/pasting its contents: $ grep sqlite3ext.h sqlite3.c #define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ /************** Include sqlite3ext.h in the middle of loadext.c **************/ /************** Begin file sqlite3ext.h **************************************/ ** @(#) $Id: sqlite3ext.h,v 1.17 2007/08/31 16:11:36 drh Exp $ /************** End of sqlite3ext.h ******************************************/ #include "sqlite3ext.h" /************** Include sqlite3ext.h in the middle of fts3_tokenizer.c *******/ /************** Begin file sqlite3ext.h **************************************/ ** @(#) $Id: sqlite3ext.h,v 1.17 2007/08/31 16:11:36 drh Exp $ /************** Include sqlite3.h in the middle of sqlite3ext.h **************/ /************** Continuing where we left off in sqlite3ext.h *****************/ /************** End of sqlite3ext.h ******************************************/ Compare to earlier versions such as SQLite 3.5.2: #define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ /************** Include sqlite3ext.h in the middle of loadext.c **************/ /************** Begin file sqlite3ext.h **************************************/ ** @(#) $Id: sqlite3ext.h,v 1.17 2007/08/31 16:11:36 drh Exp $ /************** End of sqlite3ext.h ******************************************/ If you look at it in context you can see that sqlite3ext.h will never be #included since SQLITE_CORE is defined. #ifndef SQLITE_CORE #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #endif ---- _2007-Dec-29 10:16:59 by anonymous:_ {linebreak} And yet SQLite 3.5.2 doesn't build here, maybe because SQLITE_CORE is not defined here. Where and how should SQLITE_CORE be defined? ---- _2007-Dec-29 10:24:58 by anonymous:_ {linebreak} We compile SQLite with SQLITE_OMIT_LOAD_EXTENSION defined. ---- _2007-Dec-30 13:10:01 by anonymous:_ {linebreak} OK, I now understand the problem much better. Below is a short explanation. My apologies for the initial bug report, it was a bit misleading and not detailed enough. You've added _fts3.c_ to the amalgamated source file of SQLite, starting with version 3.5.3. Now _"sqlite3ext.h"_ is needed by two of the amalgamated files: *: _loadext.c_: It includes _"sqlite3ext.h"_ and =SQLITE_CORE= must be defined first. *: _fts3.c_: It includes _"sqlite3ext.h"_ and I think =SQLITE_CORE= must be defined first since the FTS3 module is being built into the core of SQLite and not as an extension. There are actually many issues: 1: I think the amalgamated source file should never include _"sqlite3ext.h"_. Instead its should copy/paste its contents when needed. This is done for _loadext.c_ but not for _fts3.c_, resulting in the following error when building _sqlite3.c_ without _"sqlite3ext.h"_: {linebreak} =sqlite3.c:80297:26: error: sqlite3ext.h: No such file or directory= {linebreak} =sqlite3.c:80335: error: expected ',', ';', 'asm' or '__attribute__' before 'static'= {linebreak} =sqlite3.c:86299: error: expected ';', ',' or ')' before '*' token= {linebreak} I solved this by making sure =SQLITE_CORE= is defined when processing the contents of _fts3.c_, whether =SQLITE_OMIT_LOAD_EXTENSION= is defined or not, by moving: {linebreak} =#ifndef SQLITE_OMIT_LOAD_EXTENSION= {linebreak} after the block starting with: {linebreak} =#define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */= {linebreak} =/************** Include sqlite3ext.h in the middle of loadext.c **************/= 2: The FTS3 module in the amalgamated source file is built into the resulting library when =SQLITE_CORE= is not defined, whether =SQLITE_ENABLE_FTS3= is defined or not: {linebreak} =#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)= {linebreak} {linebreak} =#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)= {linebreak} =# define SQLITE_CORE 1= {linebreak} =#endif= {linebreak} =[...]= {linebreak} I'm not sure that's on purpose. Do you want the FTS3 module always built into the resulting SQLite library? If so, I think it would be more readable not to trigger this by defining =SQLITE_CORE=. Or at the very least it could be triggered by defining =SQLITE_ENABLE_FTS3= if =SQLITE_CORE= is defined in a single place - not all over the FTS3 source files. Is there any chance this ticket is opened again? Should I open a new ticket instead ? ---- _2007-Dec-30 17:17:07 by anonymous:_ {linebreak} SQLITE_CORE is defined previously in sqlite3.c. You can define it yourself on the commandline if you like. What compiler are you using? Will it #include a file even when it is not wanted, as in: #if 0 #include "foo.h" #endif or #ifdef SOME_UNDEFINED_MACRO #include "bar.h" #endif ---- _2007-Dec-30 17:53:42 by anonymous:_ {linebreak} I can recreate your problem. If I use http://sqlite.org/sqlite-amalgamation-3_5_4.zip, unzip it, delete sqlite3ext.h and grab shell.c from CVS:
     $ gcc -I. -DSQLITE_OMIT_LOAD_EXTENSION shell.c sqlite3.c -o shell -lpthread sqlite3.c:81710:26: error: sqlite3ext.h: No such file or directory sqlite3.c:81748: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘static’ sqlite3.c:87815: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token 
    You must use both -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_CORE on the compile line: gcc -I. -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_CORE shell.c sqlite3.c -o shell -lpthread That's a bug. The workaround is simple, though - always compile with -DSQLITE_CORE As you've found out, if you choose to build with FTS3 support you do not have to #define SQLITE_CORE on the compile line, as it defines it for you: gcc -I. -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 shell.c sqlite3.c -o shell -lpthread ---- _2007-Dec-30 17:55:25 by anonymous:_ {linebreak} I'm using GCC, Visual Studio, Intel C++, HP ANSI C/aC++, SGI MIPSpro, Sun Studio, IBM XL C and other compilers. They will certainly not #include a file even when it is not wanted. How is your remark related to the use case exposed above? ---- _2007-Dec-30 18:08:50 by anonymous:_ {linebreak} Ignore the #include thing - it was just an idea. The sqlite bug is explained in detail in the 2007-Dec-30 17:53:42 comment. ---- _2007-Dec-30 18:09:36 by anonymous:_ {linebreak} Indeed, =SQLITE_CORE= is usually defined by the _loadext.c_ source code. Unfortunately this will not happen if =SQLITE_OMIT_LOAD_EXTENSION= is defined. The _fts3.c_ source code in the amalgamated source file needs to be compiled with =SQLITE_CORE= if we want it: *: not to include _"sqlite3ext.h"_, *: and not to build the FTS3 module unless =SQLITE_OMIT_LOAD_EXTENSION= is defined. So yes, the solution is to define =SQLITE_CORE= when building the amalgamated source file: *: either from the command line, in which case this requirement needs to be documented, *: or within the amalgamated source file itself, in which case {linebreak} =#define SQLITE_CORE 1= {linebreak} should be added before any reference to _sqlite3ext.h". ---- _2008-Jan-01 05:51:17 by danielk1977:_ {linebreak} Thanks. #f2dcdc 2853 new active 2007 Dec anonymous 2008 Jan 2 3 optimizer fails to use an index on MAX subquery 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:_ {linebreak} Can you supply the schema of these tables and all related indexes? ---- _2007-Dec-20 10:55:29 by danielk1977:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 sqlite> select min(a) from (select 123 as a) where a=7; sqlite> select min(a) from (select NULL as a) where a=7; 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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 #f2dcdc 2847 new active 2007 Dec anonymous 2008 Jan 5 4 Include major, minor, and patch version numbers in sqlite.h 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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:_ {linebreak} 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" ---- _2007-Dec-27 02:32:44 by anonymous:_ {linebreak} Declaring a copyright and putting it into the public domain is not compatible. ---- _2008-Jan-11 04:55:22 by anonymous:_ {linebreak} 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 bug 408603. 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. #e8e8bd 2632 code review 2007 Sep anonymous 2008 Jan danielk1977 5 2 sqlite3* not available within loadable extension It is not really a bug but it may be the right moment to introduce a valuable improvement for developers of loadable extensions, which are really great (may be for all and in general) with the migration to version 3.5 branch.{linebreak} By standard usage of sqlite3ext.h within loadable extensions source code there is common to all functions the 1st parameter as sqlite3_context* context, as you know. Unfortunately there is no database context direct accessible from this. However, if you take the definitions of Mem and sqlite3_context out of vdbeInt.h and remove type by space holders, then
    sqlite3* db = context->s.db;
    is the required variable for use with sqlite3_prepare, sqlite3_step and sqlite3_finalize etc. (That's my work-around){linebreak} What is needed only for loadable extension developers to stay aligned with new versions is the re-arrangement of existing struct sqlite3_context {Mem s} and struct Mem {sqlite3 *db} to become able to simply *typecast* sqlite3_context* into a sqlite3*; all the other internals of Mem would stay private to vdbe even when version numbers will grow.{linebreak} And now to answer the question "why the hell is he asking for this?" here my explanation by an example of what I made running:{linebreak}
     select execSQL("select 'iniTable' as Title;select * from iniTable", '|', X'0D0A', X'0D0A'||'----'||X'0D0A' );  iniTable ---- Common|Integer|4711 Common|Float|3.1416927 Common|Double|3.1416927 Common|Text|Dies ist Text Common|Blob|X'0D0A' 
    Think about an application which has to create a whole InMemory-Database table structure inclusive triggers and views:
     select execSQL(stmt) from StatementTable where Usage='InMemory'; 
    And all within one and the same transaction. It is really that easy! This could answer also some points in the wishlist of the SQLite3 web site; all to do this is reordering Mem s in sqlite3_context and sqlite3*db in struct Mem to the beginning of the structures.{linebreak}Doing this with the release of version 3.5 is really a good moment, isn't it? _2007-Sep-07 11:54:38 by danielk1977:_ {linebreak} The usual approach is to pass the sqlite3* handle to sqlite3_create_function() as the 5th argument and then retrieve it from within the user function implementation using sqlite3_user_data(). If you depend on the definitions of internal data structures, you're living dangerously. ;) ---- _2007-Sep-07 12:54:56 by anonymous:_ {linebreak} Is then the following correct and will work in the same expected way (same pointer within ld-ex-function)? Even with sqlite_auto_extension called at DLL load time? (Win32 with Amalgamation and BDS2006){linebreak}
     #include  SQLITE_EXTENSION_INIT1  int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ) {   SQLITE_EXTENSION_INIT2(pApi)   sqlite3_create_function(db, "execSQL",  -1, SQLITE_UTF8, db, execSqlFunc, 0, 0); ... }  static void execSqlFunc(   sqlite3_context *context, int argc, sqlite3_value **argv ) {   sqlite3 *db = sqlite3_user_data(context ); /*   instead of using context's internals ( sqlite3 *db = context->s.db );   or waiting for reordering of them and using typecase ( sqlite3 *db = (sqlite3*)context; )   respective ( sqlite3 *db = *(sqlite3**)context; )? */ ... } 
    Thank's for the smilie and your hint. Of cause, I do not want to live dangerous. This was the purpose of my posting to get this fixed officially with the next release. But if you say it is not worth the "small change" of reordering and I'm doing it correct this way, then that's fine. I started similar to your proposal by using a static variable and assigned it from within sqlite3_extension_init but this would not work with more than one db-connection (the last one would win). The other open point for me is the right place and methode to link the same source code as used for the Loadable Extension Functions to become a DLL (for SQlite3.exe .load) as auto-loaded extensions into a specialized made of SQLite3.DLL for my applications. Do you have another trick than modifying the sqlite3_open-functions with compiler switches? This would be great. Even if above statements work, do you think the reordering makes sense for an easier transfer for the sqlite3* into the loadable extension function? The 5th argument would be kept free for other purposes. What is your estimation of likelyhood for that proposed change? What's against it? ---- _2007-Sep-07 14:11:38 by danielk1977:_ {linebreak} The code above is correct as far as I can see. As far as reordering structures to allow tricky casting, there's no particular argument against, other than it makes the code a bit tricky to follow. And limits the ways in which we can change the contents of the currently opaque sqlite3_context structure in the future. Something like: sqlite3 *sqlite3_get_connection(sqlite3_context *p){ return p->s.db; } might be a chance I guess. ---- _2007-Sep-10 18:58:09 by anonymous:_ {linebreak} That is a very good idea. Now I have a case, where I would like to make use of both, the db connection AND the user data:{linebreak} I have two database selections (by a list of keys) and I would like to used one function to compare "equal" and another "unequal". In this case I could use the same function body and use the userdata to distinguish between the cases equal and unequal while using the db connection to query the selection with the given keys.{linebreak} Using 2 functions which are sharing the same body of a 3rd function will be my workaround until this new API function becomes available with the next 3.5.x version. Many thanks. ---- _2007-Sep-10 19:09:51 by anonymous:_ {linebreak} I agree. It is very reasonable to want to use an sqlite3* connection from within a registered function as well. Scenario - perform an SQL query on same connection from within a user-defined function. Setting user data just for this common action is awkward. ---- _2008-Jan-08 14:46:14 by anonymous:_ {linebreak} when will this function become usable? will it come with 3.5.5 ? {linebreak} sqlite3 *sqlite3_get_connection(sqlite3_context *p) #f2dcdc 2613 code active 2007 Sep anonymous 2008 Jan drh 3 3 replace doesn't work with blobs containing \x0, otherwise it does 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:_ {linebreak} Replace was designed to work with strings. However, working with blobs would be an interesting extension. ---- _2007-Oct-18 06:13:10 by anonymous:_ {linebreak} 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:_ {linebreak} Treatment of length operator is - as fas as I know - dependent on type: {linebreak} 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. {linebreak} 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. {linebreak} 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:_ {linebreak} 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. #f2dcdc 2506 new active 2007 Jul anonymous 2008 Jan 3 2 New API to retrieve ROWID from SQLite3_stmt structire 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:_ {linebreak} 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:_ {linebreak} This is far to old active ticket. Is it in consideration to be implemented in the near future? #f2dcdc 2336 warn active 2007 May anonymous 2008 Jan 4 4 Compiler warnings on strcpy(), sprintf(), et al. 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:_ {linebreak} Some are still left in fts1.c and fts2.c. ---- _2008-Jan-07 10:54:43 by anonymous:_ {linebreak} 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() #c8c8c8 1460 code closed 2005 Sep anonymous VDBE 2008 Jan drh 2 2 sqlite3_clear_bindings not implemented in sources after searching inside source files, the routine sqlite3_clear_bindings() was not found. But this is in sqlite3.h and documentation. Is there routine deprecated ?? _2005-Sep-28 15:23:22 by drh:_ {linebreak} This routine is in the source file experimental.c. http://www.sqlite.org/cvstrac/getfile/sqlite/src/experimental.c ---- _2008-Jan-24 02:19:38 by anonymous:_ {linebreak} This routine may be in experimental.c but some distributions (Centos 4.4, Fedora Core 6-64 bit to name 2) seem to provide .so's that do not contain the routine. Is there some compilation flag that eliminates "experimental" code. Regardless, it remains defined in the header file, which results in a linker error and great user confusion, judging by the # of bugs opened on this issue. ---- _2008-Jan-24 02:29:03 by anonymous:_ {linebreak} Example program: #include int main(void) { sqlite3_stmt* stmt; sqlite3_clear_bindings(stmt); return 0; } Compile: gcc test1.c -lsqlite3 /tmp/ccsrGxAt.o(.text+0x23): In function `main': : undefined reference to `sqlite3_clear_bindings' collect2: ld returned 1 exit status However, just to prove that -lsqlite3 is the sqlite3 library: #include int main(void) { printf("SQLITE header version %d, library version %s", SQLITE_VERSION_NUMBER, sqlite3_libversion()); return 0; } # gcc test2.c -lsqlite3 # ./a.out SQLITE header version 3003006, library version 3.3.6 ---- _2008-Jan-24 12:37:33 by drh:_ {linebreak} The sqlite3_clear_bindings() routine is now located in the vdbeapi.c source file and is a part of all builds. #f2dcdc 489 new active 2003 Nov anonymous 2008 Jan 4 4 DLL exports suggestion 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:_ {linebreak} 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:_ {linebreak} The prefix SQLITE_API appears in front of all interfaces in the {link: /cvstrac/wiki?p=TheAmalgamation 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:_ {linebreak} 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:_ {linebreak} See also Ticket #2448 #c8c8c8 1268 build closed 2005 May anonymous 2017 Apr 1 1 /usr/include/sys/context.h:155: parse error before "sigset64_t" Inability to compile without errors _2005-May-27 15:46:15 by drh:_ {linebreak} /usr/include/sys/context.h is a file on your computer. It has nothing to do with SQLite. SQLite does not #include this file. ---- _2005-Aug-30 15:24:21 by anonymous:_ {linebreak} context.h is included from other files that are included. The error message was from someone trying to compile on an AIX box using gcc. Rather than dismissing it as "not a bug", you might want to see if others who use AIX know how to get around this problem. ---- _2017-Apr-14 09:13:22 by anonymous:_ {linebreak} I am getting an error of "/usr/include/sys/context.h:188:2: error: unknown type name 'sigset64_t' sigset64_t sc_mask; /* signal mask to restore */" while trying to compile ntpv4 tests with gcc. I copied sigset64_t declaration to ntp_types.h source file however, then I get conflict error for sigset64_t. Need guidance on resolving "unknown type name" kind of errors.