Small. Fast. Reliable.
Choose any three.
Key: Active Review Fixed Tested Deferred Closed
# Type Status Created By Subsys Changed Assigned Svr Pri Title
Description
Remarks
 
4047 build closed 2009 Dec anonymous ext 2009 Dec danielk1977 1 1 FTS3 Select match crash
When doing certain type of 'select match', our application crashes. This does not happend with version 3.6.20. This happends with the windows sqlite3.dll

How to reproduce the crash.

1. Create a db,

2. Execute this commands:

CREATE VIRTUAL TABLE foobar using FTS3(description, tokenize porter);

INSERT INTO foobar (description) values ('Filed under: Emerging Technologies, EV/Plug-in, Hybrid, Chevrolet, GM, ZENN 2011 Chevy Volt - Click above for high-res image gallery There are 16 days left in the month of December. Besides being time for most Americans to kick their Christmas shopping sessions into high gear and start planning their resolutions for 2010, it also means that there''s precious little time for EEStor to "deliver functional technology" to Zenn Motors as promised. Still, the promises held out by the secretive company are too great for us to forget about entirely. We''d love for EEStor''s claims to be independently verified and proven accurate, as would just about anyone else looking to break free of petroleum in fav');

3. Execute this query:

SELECT docid FROM foobar WHERE description MATCH '"high sp d"';

The dll crashes.

Thank you for this great tool. Keep up the good work! :-)

Jochi Martinez www.bfreenews.com

This tracker and hence ticket are closed. Please follow the instructions from the SQLite home page "Report a bug" at bottom right.
 
4046 code closed 2009 Dec anonymous cli 2009 Dec   4 4 Command-line id displayed incorrectly
In the command-line interface ids over 9999 are displayed incrementing from 1000 in a strange manor. For example:

9998 lauren aboulafia Actor 9999 julianne nicholson Actor 1000 steve stockman Director 1000 mike tyson Actor 1000 james toback Director 1000 abraham benrubi Actor 1000 stew albert Actor 1000 david leaf Director 1000 randy couture Actor 1000 antonio nogueira Actor 1000 bruce buffer Actor 1000 herb dean Actor 1001 vitor belfort Actor

However the ids are internally correct:

select * from people where id = 10010;

id first_name last_name type ---- -------------- ---------- ---------- 1001 vitor belfort Actor

2009-Dec-10 01:53:24 by anonymous:
This tracker and hence ticket at closed. Use the sqlite-users mailing list as documented at http://www.sqlite.org/src/wiki?name=Bug+Reports
 
4045 doc closed 2009 Dec anonymous   2009 Dec   3 2 Missing documentation for "PRAGMA ignore_check_constraints"
There is no mention of PRAGMA ignore_check_constraints on Pragma commands page, however I can see this pragma in source code.
2009-Dec-08 23:23:30 by anonymous:
This tracker and hence ticket are closed. Please continue discussion on the sqlite-users mailing list.
 
4044 code closed 2009 Nov anonymous   2009 Nov   5 3 For Wince Patch Or Dll ?
Hello !How can I use Sqlite Wince ?
2009-Nov-05 05:49:34 by anonymous:
In what way is that a bug report? Use the sqlite-users mailing list for questions and make sure you search the archives and SQLite web site first.
 
4043 code closed 2009 Oct anonymous   2009 Oct   1 1 x NATURAL JOIN x BUG
Problem: x NATURAL JOIN x erroneously yields cartesian product.

1) Run the C++ program below to generate the necessary SQL data. 2) Then run sqlite3.exe and read it in! (.read test.sql) 3) Execute the following queries:

Blistering fast: SELECT COUNT(*) FROM Item; Result: 10000

Slooooow! WRONG result: SELECT COUNT(*) FROM Item NATURAL JOIN Item; Result: 100000000

Clearly, SQLite executes a cartesian product!

Oddly, this works as intented: SELECT COUNT(*) FROM (Item) NATURAL JOIN (Item); Result: 10000

Unfortunately, this is absolutely crucial for my application.

// test.sql generator #include <fstream> int main() { std::ofstream file ("test.sql"); file << "CREATE TABLE IF NOT EXISTS Item (ItemID INTEGER PRIMARY KEY, A INTEGER NOT NULL, B INTEGER NOT NULL, C INTEGER NOT NULL, D INTEGER NOT NULL, E INTEGER NOT NULL, UNIQUE (A, B));\r\n"; file << "BEGIN TRANSACTION;\r\n"; for (int i = 0; i < 10000; ++i) { file << "INSERT INTO Item (A, B, C, D, E) VALUES ("<< i << ", " << i + 1 << ", " << i + 2 << ", "<< i + 3 << ", " << i + 4 << ");\r\n"; } file << "COMMIT TRANSACTION;\r\n"; file.close(); return 0; }

2009-Oct-19 04:50:49 by anonymous:
This bug tracker is closed and all tickets in it are being closed as I am about to do this one.

See http://www.sqlite.org/src/wiki?name=Bug+Reports

 
4042 code closed 2009 Oct anonymous   2009 Oct   3 3 Tests from icu.test fail in SQLite 3.6.19
Tests from icu.test fail in SQLite 3.6.19. These tests pass in SQLite 3.6.18. I use ICU 4.2.1.
Thanks. Fixed here:

  http://www.sqlite.org/src/vinfo/8a21fdaf6a89f74b040ea0c6bb996ac1c6fcd369

The problem was with the test script only, not the code. So you don't need to take a patch unless you specifically want to run the tests.

 
4041 code closed 2009 Oct anonymous   2009 Oct   1 1 sqlite3_create_function and INDEXED column values
When I create my own "stored procedures" using sqlite3_create_function, I get horrible performance (which I expected) even though the column of interest is indexed.

Consider this sample (it's stupid, but it shows my problem): SELECT * FROM MyTable WHERE IS_MY_BIRTHDAY(IndexedDate);

IS_MY_BIRTHDAY returns 1 when the date is my birthday. Now, inside this function, if I encounter a date greater than my birthday, then I want to tell SQLite to stop searching, since the date is indexed.

Is this possible? If so, how?

2009-Oct-02 01:57:36 by anonymous:
This ticket tracker is no longer used (fossil is instead). Please post your query to the users mailing list.
 
4040 code closed 2009 Sep anonymous front 2009 Oct   3 4 sqlite3_bind_text( , , NULL, 0, ) binds null not the empty string
I am using sqlite3_bind_text in production code and a customer found a fault.

H13533 says "In calls to sqlite3_bind_blob(S,N,V,L,D), sqlite3_bind_text(S,N,V,L,D), or sqlite3_bind_text16(S,N,V,L,D) SQLite binds the first L bytes of the BLOB or string pointed to by V, when L is non-negative."

Sometimes, I am calling sqlite3_bind_text with V=NULL and L=0. By H13533, the effect of this should be to read no bytes from V and bind a zero-length string. Instead, it behaves like sqlite3_bind_null(S,N).

For now, the workaround is simple and obvious: wrap sqlite3_bind_text with something that substitues an arbitrary non-NULL pointer for V if called with V==NULL, L==0.

2009-Oct-01 06:48:21 by anonymous:
cvstrac is no longer used for SQLite bug reporting. I have transferred the bug information over to http://www.sqlite.org/src/tktview/19b44e35753baae47ad997559f4dc333441930c6 and am closing this. Thanks for the report.
 
4039 warn fixed 2009 Aug anonymous back 2009 Oct   3 3 Invalid address in unixWrite() and sqlite3MemSize() on MacOSX
The Chromium project has been running its unit and system tests under Valgrind on Linux and Mac OS X for several months now. We occasionally see a pair of valgrind warnings in one particular test on the mac:

  Syscall param write(buf) points to unaddressable byte(s)
    write$UNIX2003
    unixWrite (third_party/sqlite/src/os_unix.c:923)
    sqlite3OsWrite (third_party/sqlite/src/os.c:69)
    pager_write_pagelist (third_party/sqlite/src/pager.c:3095)
    sqlite3PagerCommitPhaseOne (third_party/sqlite/src/pager.c:4805)
    ...
  Address 0x1381b038 is 8 bytes inside a block of size 4,104 alloc'd
    malloc (vg_replace_malloc.c:195)
    sqlite3MemMalloc (third_party/sqlite/src/mem1.c:43)
    mallocWithAlarm (third_party/sqlite/src/malloc.c:228)
    sqlite3PageMalloc (third_party/sqlite/src/malloc.c:414)
    pagerAllocatePage (third_party/sqlite/src/pager.c:3682)
    ...
  Invalid read of size 4
    sqlite3MemSize (third_party/sqlite/src/mem1.c:99)
    sqlite3MallocSize (third_party/sqlite/src/malloc.c:478)
    sqlite3PageFree (third_party/sqlite/src/malloc.c:432)
    pager_truncate_cache (third_party/sqlite/src/pager.c:2673)
    ...
  Address 0x1381b034 is 4 bytes inside a block of size 4,104 alloc'd
    malloc (vg_replace_malloc.c:195)
    sqlite3MemMalloc (third_party/sqlite/src/mem1.c:43)
    mallocWithAlarm (third_party/sqlite/src/malloc.c:228)
    sqlite3PageMalloc (third_party/sqlite/src/malloc.c:414)
    pagerAllocatePage (third_party/sqlite/src/pager.c:3682)

(see http://crbug.com/20653 for more detail.)

How the heck bytes allocated by malloc can be unaddressable is beyond me.

As I said, this only seems to happen on MacOSX. Has anybody else seen anything like this?

2009-Oct-06 17:52:28 by anonymous:
Apparently fixed by http://www.sqlite.org/src/vinfo/5e2f54968

This bug tracker is no longer used - please direct further discussion to the sqlite-users mailing list.

 
4038 doc closed 2009 Aug anonymous   2009 Sep   4 4 Documentation error
From the documentation of function strftime:

%W week of year: 00-53

Shouldn't it be 00-52? I've never heard of years with 54 weeks!

2009-Aug-29 18:51:40 by drh:
See http://opengroup.org/onlinepubs/007908799/xsh/strftime.html

The standard meaning of %W in the strftime() function of the standard library is that 00 means the days before the first Monday of the month. 01 means the first Monday and the 6 days the follow, and so forth. Hence, the last day of a year that begins on a Monday (ex: 2007) will be 53.

 
4037 code closed 2009 Aug anonymous front 2009 Nov   2 3 unsupported syntax: databasename.tablename.*
The following query

select databasename.tablename.* from databasename.tablename

returns:

near "*": syntax error

However, the following query returns no error:

select databasename.tablename.fieldname from databasename.tablename

2009-Nov-08 02:27:14 by anonymous:
Please discuss this on the sqlite-users mailing list, especially including what the SQL standard says and what other databases say.
 
4036 new closed 2009 Aug anonymous back 2009 Oct   4 3 Especial Use of BackSlach characters
The only way to put a special character (control characters) is placing on the character explicit in the query, there is a way to put, as in 'C' language.

SELECT '\t'
UNION ALL
SELECT '\\t'
UNION ALL
SELECT '\n'
UNION ALL
SELECT '\\n'
UNION ALL
SELECT '\65'
UNION ALL
SELECT '\0065'

On Postgres '\t' is interpreted as the char '0x09' vertical tabulation
'\n' is interpreted as the char '0x0A'
'\65' is interpreted as the char '0x35' digit '5'
'\0065' is interpreted as the widechar '0x0035' digit '5'

On MySql '\t' is interpreted as the char '0x09' vertical tabulation
'\n' is interpreted as the char '0x0A'
'\65' is interpreted as the number '65'
'\0065' is interpreted as the string '?065'

2009-Aug-26 20:04:22 by drh:
You mean it works differently in MySQL? The backslash is has no special meaning in the SQL langauge and no SQL database engines that I am aware of, other than MySQL, do anything special with the backslash.

What are you asking for? Do you want us to break compatibility with every other database engine in the world in order to be compatible with MySQL?


2009-Oct-05 08:40:45 by anonymous:
Annoyingly the idiotic(*) mysqldump program uses backslashes instead of quoting properly. For example it dumps "you'd be" as "you\'d be".

(*) A conclusion based on trying to fixup its output to be useful as standard SQL.


2009-Oct-06 17:49:40 by anonymous:
There is no standards compliant way of addressing this. You can preprocess the SQL and text in your code before handing to SQLite where you can use any backslash escaping rules you want. Please direct further discussion to the the sqlite-users mailing list.
 
4035 warn closed 2009 Aug anonymous ext 2009 Oct   4 3 Fix for compiler warning in fts3.c
The patch below fixes a compiler warning generated with GCC4.2.2.

It occurs because the function fts3GetVarint does not set *v when "bad data" is detected (see line 410 in source code) and so in fts3GetVarint32 may indeed be uninitialized for the line *pi = (int) i;


	--- ext/fts3/fts3.c
	+++ ext/fts3/fts3.c
	@@ -418,7 +418,7 @@
	 }

	 static int fts3GetVarint32(const char *p, int *pi){
	- sqlite_int64 i;
	+ sqlite_int64 i=0;
	  int ret = fts3GetVarint(p, &i);
	  *pi = (int) i;
	  assert( *pi==i );
2009-Oct-03 04:06:07 by anonymous:
Now http://www.sqlite.org/src/tktview/8f81455baf1099c16b0da49c1e9c6c735e2e94e3
 
4034 code closed 2009 Aug anonymous front 2009 Sep   4 4 EXPLAIN changes settings
  SQLite version 3.6.17
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> pragma cache_size;
  2000
  sqlite> explain pragma cache_size = 1000;
  0|Expire|1|0|0||00|
  1|Halt|0|0|0||00|
  sqlite> pragma cache_size;
  1000
  sqlite>
2009-Aug-20 11:43:56 by anonymous:
All right. Explain show result execution details. Explain doesn't break query execution.
 
4033 code closed 2009 Aug anonymous   2009 Aug   1 1 Can not INSERT INTO (with WHERE TEST)
For about a week I have been attempting to import the entire unicode.org's unihan.txt file into a basic spreadsheet format, using numerous methods, and all in vain.

Now I am trying SQL, which I have no experience with. I already found a pre-made SQL database that breaks this rather undigestable .txt file up by tables, but I still can't import these tables into a spreadsheet because values would be lined up wrong. I need a way to map all the values in all the tables to an index ".k" column (which represents a unique unicode value), which is present in all of the tables.

My thinking is that I can make a new table within this pre-made database, using SQL to copy all the data in where it needs to be, all neatly mapped to each's corresponding values in each's .k columns.

So, I thought I had finally found a chink in this problem's armor, but I am foiled yet again, this time by something that makes no logical sense to me:

--

INSERT INTO fulldb (kTotalStrokes) SELECT kTotalStrokes.v FROM kTotalStrokes, fulldb WHERE fulldb.k = kTotalStrokes.k;

--

(the k columns for both fulldb and kTotalStrokes have overlapping values.)

I get no errors of any kind when I run this with sqlite3, yet I view the table in Firefox SQLite Manager plugin, and the fulldb.kTotalStrokes column remains NULLed out.

I am trying to get fulldb.kTotalStrokes to be populated only for rows where kTotalStrokes.k and fulldb.k overlap. Maybe there's a better way to do this, or I'm not seeing something that's painfully obvious.

This seems like such a ridiculously easy problem, yet I'm pulling my hair out here, and would appreciate any help. cjparks_public@hotmail.com

Thanks!

Please send questions such as this to the sqlite-users@sqlite.org mailing list. Reserve tickets for reporting bugs. Thanks.
 
4032 new closed 2009 Aug anonymous   2009 Oct   5 3 Create TableObject future
Hello all, How about to add object database. I propouse to add a TableObject it is same as Table but have new column, ID. For example:
CREATE tableObject eployees(name varchar(100), surname varchar(100)); CREATE tableObject payed_salary(employee REFS eployees, amount INTEGER); select employee.name as employee_name , employee.surname as employee_surname , amount from payed_salary;


Column employee is compoud from row_id from employees table object and table object id.

How about to ad this future? With respect, Ion Lupascu ion.lupascu@orange.md

2009-Oct-06 17:54:01 by anonymous:
It isn't clear what you are asking for, why rowid won't suffice and why you can't just add the column yourself. Closing as this bug tracker is no longer used. Please direct further discussion to the sqlite-users mailing list.
 
4031 doc closed 2009 Aug anonymous   2009 Aug   4 4 Document behavoir of SQLITE_OMIT_INCRBLOB compiler flag
Update documentation at http://sqlite.org/compile.html#omit_incrblob to include the comment along the following lines:

As of 3.6.17 when SQLite is compiled with this option, zeroblobs will be stored uncompressed in the database. This means that while in previous versions a zeroblob of 1,000,000 would be stored with no disk space used, it will now take 1,000,000 bytes to store.

Also in sqlite3.h, at the comment starting with:

    ** The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
    ** is filled with zeroes.  A zeroblob uses a fixed amount of memory
    ** (just an integer to hold its size) while it is being processed.

Add: comment along the lines of when compiled with SQLITE_OMIT_INCRBLOB the full amount of space needed is allocated while it is being processed.

2009-Aug-17 18:24:28 by drh:
If the documentation is updated at all it should say:

"Prior to SQLite version 3.6.17, there was a bug such that if SQLite were compiled with the SQLITE_OMIT_ZEROBLOB compile-time option, the zeroblob() function would not work. The zeroblob() function would always create a zero-length BLOB regardless of what parameter was passed in."


2009-Aug-17 18:38:00 by anonymous:
OK, now it makes sense. I thought the compressed zeroblob was a feature, not a bug :()

Therefore, no document changes needed

 
4030 code closed 2009 Aug anonymous back 2009 Aug   3 3 Checkin 6906 has unintended side affect in how zero blobs are stored
Zero blobs are now stored decompressed in the database when SQLite is compiled with SQLITE_OMIT_INCRBLOB.

  CREATE TABLE T1(C1);
  INSERT INTO T1 VALUES(ZEROBLOB(100000));

  Directory of Y:\SQLite3\Projects\3_6_17
  08/17/2009  09:04 AM   102,400 test.sqlite

  Directory of Y:\SQLite3\Projects\3_6_16
  08/17/2009  09:06 AM     2,048 test.sqlite

I believe that this was a direct result of the changes in ticket # 6906

However, if this was an intended side affect, it should be documented and noted in the compiler options page as well

The 3.6.17 behavior is correct. Check-in [6906] was a bug fix. See ticket #3977
 
4029 doc fixed 2009 Aug anonymous   2009 Aug   5 4 typo in result_blob.html
In the page result_blob.html, in the paragraph beginning "The sqlite3_result_text(), ", the phrase "space and does not copy the it or call a destructor" requires editing.
Fossil check-in 1fc73b9146ee
 
4028 doc fixed 2009 Aug anonymous   2009 Aug   5 4 typo in blob_open.html
On the page http://www.sqlite.org/c3ref/blob_open.html in the paragraph beginning "Use the sqlite3_blob_bytes() interface" the word "underface" should be "interface".
See the fossil check-in 1fc73b9146
 
4027 warn fixed 2009 Aug anonymous   2009 Aug   4 4 GCC warning.
mingw gcc (GCC) 4.3.3-dw2-tdm-1

gcc -c -march=pentium4 -mwindows --std=c99 -O2 -Wall *.c

using the amalgamation.

2009-Aug-13 14:20:15 by anonymous:
sqlite3.c:45740: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true


2009-Aug-13 15:00:47 by drh:
I have no idea what this warning message means.


2009-Aug-13 15:07:38 by drh:
After pondering this warning message some more, I think it is saying that GCC is making the (incorrect) assumption that integer overflow never occurs in the expression and that expression

     x-1 < x+1

is always true. Unfortunately, the whole point of that expression is to check for integer overflow, so if my reading of the warning message is correct, GCC is making an invalid assumption and generating incorrect code. We have tests in the TH3 test suite that verify the condition in question works and those tests pass using GCC 4.1.1. This sounds like a bug in GCC 4.3.3 to me....


2009-Aug-14 16:52:11 by anonymous:
LWN covered this about a year ago as it was the basis for a CERT advisory.

http://lwn.net/Articles/278137/ http://lwn.net/Articles/278230/


2009-Aug-14 17:15:49 by drh:
I do not think that the LWN articles or the CERT advisory are directly applicable here. In this warning the comparison is

     (x-1) < (x+1)

Where is a signed integer, not a pointer. This test is designed to be false if the value in x is either the largest or the smallest possible integer and true otherwise. But, apparently, GCC wants to make it always true.


Work-around implemented in fossil-scm check-in 9cbe3654055a78c09ea1ecd5dc599bcd888b57e3


2009-Aug-14 18:34:43 by anonymous:
Although I like the style of this test I'm wondering if it safe to rely on the way a compiler understands it. Beside the warning, what will happend if an overgenerous optimizer silently replace it with a constant TRUE? If such things are critical I would suggest to consider a test call when sqlite starts up and simply exit if the result is not the one the developer had in mind. just a though...


2009-Aug-14 18:56:45 by drh:
The 9cbe3654055a78c09ea1ecd5dc599bcd888b57e3 check-in referenced above replaced the (x-1)<(x+1) test with

   x>SMALLEST_INT && x<LARGEST_INT

This involves two comparisons instead of one, and is thus slower, but the code is not in a speed-critical area and the new style appears to be more robust against over-zealous optimizers.

 
4026 build closed 2009 Aug anonymous build 2009 Aug   2 3 Error when compiling for Windows CE
Hi, we are using sqlite-amalgamation for building the library on Windows CE.

The last version introduce some defines at the begining of sqlite.c which introduced the error.

This change works for us.

  #define HAVE_SYS_TYPES_H 1
  #define HAVE_SYS_STAT_H 1
  #define HAVE_STDLIB_H 1
  #define HAVE_STRING_H 1
  #define HAVE_MEMORY_H 1
  #define HAVE_STRINGS_H 1
  #ifndef _WIN32_WCE
    #define HAVE_INTTYPES_H 1
    #define HAVE_STDINT_H 1
  #endif
  #define HAVE_UNISTD_H 1
  #define HAVE_DLFCN_H 1
  #define HAVE_FDATASYNC 1
  #define HAVE_USLEEP 1
  #ifndef _WIN32_WCE
    #define HAVE_LOCALTIME_R 1
  #endif
  #define HAVE_GMTIME_R 1

Thanks!

2009-Aug-13 13:52:17 by shane:
I checked both the .zip and .tar.gz v3.6.17 amalgamation downloads. The "#defines" you reference aren't set any of the supplied source files.

If you run the configure script, a config.h will be generated for you which attempts to set these #defines appropriately. You then have to define _HAVE_SQLITE_CONFIG_H somewhere (typically as a compiler option) and supply the config.h as part of the build process when compiling sqlite3.c.

I suspect you're using configure and it isn't setting them appropriately in your generated config.h for your build environment. If this is the case, then the correct "fix" for this will be to update the configure script.

Can you confirm this and provide details on your build environment?


2009-Aug-14 07:55:16 by anonymous:
We are using APSW which download the sqlite amalgamation by itself and run configure on it on non windows enviroment, but instead of generating the config.h, it add the defines on top of the sqlite.c file and we did not notice that behaviour.

So your suspect was wight, in one of our last merges with the linux enviroment, the defined get added, and we thought they where in the sqlite downloaded code.

Thanks for taking the time to give it a look and giving us some hints on the problem, it is an issue in our side. ;)


2009-Aug-14 16:46:49 by anonymous:
(I am the apsw author).

The APSW fetching functionality was never intended to provide you with something to check into source control. If you want that then download SQLite yourself.

It is intended to be used when doing a build and saves you from having to download SQLite for a build. The necessary defines have to be somewhere (for non-Windows) and due to the interactions between Python's build tools, modifying the sqlite source was the most effective place.

I will update the APSW documentation to explain this. See http://code.google.com/p/apsw/issues/detail?id=64


2009-Aug-18 07:01:07 by anonymous:
We update our scripts and documentation to reflect that, and avoid this issue in the future.

Thanks for the reply.

 
4025 warn closed 2009 Aug anonymous back 2009 Oct   3 3 Add assertions to createVarMap
If a column is bound twice in the same SQL (because of erroneous SQL) like this

  UPDATE ColA=:1, ColB=:2, ColA=:3 ...

Note: ColA was bound twice The parser doesn't say anything about it, and the VDBE will fail to bind the variable correctly, without any errors or warning, causing a hell of a debugging session.

I'd like to suggest adding a few assertions/contracts to catch this sort of error.

here is what I'm currently doing (vdbeapi.c line:1070):

  static void createVarMap(Vdbe *p){
  if( !p->okVar ){
    int j;
    Op *pOp;
    sqlite3_mutex_enter(p->db->mutex);
        //This is a race condition fix I submitted in a previous ticket
	if( !p->okVar ){
		for(j=0, pOp=p->aOp; j<p->nOp; j++, pOp++){
		  const char* what = pOp->p4.z;
		  if( pOp->opcode==OP_Variable ){
                       //New assert that pOp->p4.z!=NULL
			assert( pOp->p1>0 && pOp->p1<=p->nVar && pOp->p4.z!=NULL);
			p->azVar[pOp->p1-1] = pOp->p4.z;
		  }
		}
               //Assert that all variables are assigned
		for(j=0;j<p->nVar;++j)
		{
			assert( p->azVar[j]!=NULL);
		}
		p->okVar = 1;
	}
    sqlite3_mutex_leave(p->db->mutex);
  }
  }
2009-Oct-02 08:50:54 by anonymous:
This may be an error for your code, but it is not an error for everyone elses code. It is quite possible to have the same binding repeated multiple times. A toy example:

  select a+:1, b+:2, c+:1 from foo;


2009-Oct-03 01:56:37 by anonymous:
Oops misread your code. This behaviour can only be changed if there would be no effect on existing code. Please continue discussion on the sqlite users mailing list.
 
4024 new closed 2009 Aug anonymous back 2009 Oct   4 3 createVarMap race condition fix
When the VDBE does createVarMap (vdbeapi.c line 1070) it can cause a race. I know it's documented and benign, but when working with very large amounts of variable bindings it does affect performance a bit, anyways the race can be easily avoided by an additional check to okVar.

Like this:

  static void createVarMap(Vdbe *p){
    if( !p->okVar ){
    int j;
    Op *pOp;

    sqlite3_mutex_enter(p->db->mutex);
        //double check
	if( !p->okVar ){ // <= this fixes the issue
		for(j=0, pOp=p->aOp; jnOp; j++, pOp++){
		  if( pOp->opcode==OP_Variable ){
			assert( pOp->p1>0 && pOp->p1<=p->nVar);
			p->azVar[pOp->p1-1] = pOp->p4.z;
		  }
		}
		p->okVar = 1;
	}
    sqlite3_mutex_leave(p->db->mutex);
  }
2009-Oct-06 17:59:34 by anonymous:
Are you calling sqlite3_bind_parameter_{name,index} from multiple threads concurrently? That is the only way to get the actual race condition. Even then it would only build the map for as many times as you have concurrent threads doing the bind call. I really don't believe you are encountering measurable performance issues due to this. In any event there is a simple workaround - call the bind method once in one thread and then knock yourself out using as many threads as you want.

Closing as this bug tracker is no longer used. Please continue discussion on sqlite-users mailing list.

 
4023 code closed 2009 Aug anonymous   2009 Aug   3 3 Error when connect to SQLite on Linux platform
I program software on Linux platform. So I can connect to SQLite with connection string: "jdbc:sqlite:/home/james/Desktop/temp/DB_Clinic_08122009"

when I run my program this error appeared : java.lang.ClassNotFoundException: sqlite.JDBC

Please help me find out this error! Thank you alot!

2009-Aug-12 09:48:19 by anonymous:
The issue is with whatever 3rd party Java library you are using. You need to contact them.
 
4022 code fixed 2009 Aug anonymous vfs 2009 Aug   1 3 Large file support is disabled due to placement of definitions
When running on 32 bit x86 Debian Lenny you get errors once a database hits 2GB (I/O error on writing, No LFS on opening). The cause is the position of the large file support macros. There is a comment before them explaining that they must precede any system headers. However the block above includes stdint.h and inttypes.h.

If I move the LFS macros to before those inclusions then large file support works just fine.

Fixed by check-in [b0848925babde5241aefe0a117ebb10299c94a15]
 
4021 website closed 2009 Aug anonymous   2009 Sep   5 4 List of well know users
We are a company that makes an IDE that runs on top of an open source compiler and would like to know if it would be possible to be included in the users list.

In your web you claim: "SQLite is in the public domain and so many people use it in their projects without ever telling us." but there is no info or at least I couldn't fint it about how to be included in the Well-Known Users list. Maybe a note or an email address at the bottom would help anyone willing to do it.

Regards, Jose

PS: Sorry for my poor English.

2009-Sep-29 07:14:46 by anonymous:
A well known user is a product/company in use by many users or from a very large well known world wide company. If you look at the list the vast majority of products have millions of users. The companies have revenues in the billions and offices all over the world.

The purpose of the page is to help show just how widespread SQLite is and that anybody new (including a large company) adopting it is not alone. For example someone reading the page should think "If Google, GE, Adobe and Philips can use it then so can I".

You are smart enough to use SQLite already and join the many other products and projects using it. There used to be a listing of them, but it got far too large and unmanageable.

When you have a large amount of potential influence like the list on the page, let us know :-)

 
4020 code closed 2009 Aug anonymous   2009 Oct   5 4 sqlite3FindFunction() - too long loop
If matchQuality() returns maximum possible value there's no need to check other functions in the list.
2009-Oct-04 21:22:22 by anonymous:
While technically true it really doesn't matter. The loops are iterating over exact function name matches so all they are seeing is the different combinations of nArg and encoding. In the vast majority of cases that is exactly one and in other circumstances will be low single digits. The only performance critical time when this function is called is on preparing a statement (ie it isn't called on every row executing a statement). Consequently the suggested code change wouldn't have any measurable effect, and slightly complicates the code.

Please direct further discussion to the sqlite-users mailing list.

 
4019 build closed 2009 Aug anonymous build 2009 Oct   3 2 Configure clean is not enough
 Makefile: $(TOP)/Makefile.in
@@ -807,6 +843,8 @@
        rm -f common.tcl
        rm -f sqlite3.dll sqlite3.lib sqlite3.def
        rm -f sqlite3.c .target_source
+       rm -f pkgIndex.tcl
+       rm -f sqlite3_analyzer$(TEXE)

 distclean:     clean
        rm -f config.log config.status libtool Makefile sqlite3.pc
2009-Oct-18 07:54:18 by anonymous:
Which Makefile? What you have doesn't resemble what I see. Please continue discussion on the sqlite-users mailing list as this tracker and ticket are now closed.
 
4018 code closed 2009 Aug anonymous vfs 2009 Oct   1 1 File handle leak
Code example:

ThreadProc(){
  outDB.Connect(outPath);
  outDB.ExecuteLite(m_globQuery.GetSql(SQL_PRAGMA_SYNCHRONOUSOFF));
  outDB.ExecuteLite(m_globQuery.GetSql(SQL_CREATE_TEMPMAINTABLE));
  outDB.CreateFunc("fnn",1,m_pfnn,FileNameNormalizer);
  for(int i=0;im_dateItem->m_fileList.size();i++){
    outDB.ExecuteLite(m_globQuery.GetSql(SQL_ATTACH_DATABASE,var->m_dateItem->m_fileList[i].c_str(),"newTempDB"));
    outDB.ExecuteLite(m_globQuery.GetSql(SQL_INSERT_FROMBIN,var->m_dateItem->m_item->m_host,var->m_dateItem->m_date));
    outDB.ExecuteLite(m_globQuery.GetSql(SQL_DETACH_DATABASE,"newTempDB"));
  }
  outDB.DeleteFunc("fnn");
  outDB.Disconect();
}
When many threads attach and deattach sqlitedb in unixLock() pOpen->nLock stay always more then 0 and pOpen->aPending not cleaning
2009-Aug-20 06:39:02 by danielk1977:
Attachment demonstrates the problem. If enough database connections are opened and closed while a lock is held on the database file, eventually the process runs out of file descriptors.

This problem is probably unix only.


2009-Aug-26 21:13:33 by anonymous:
In Windows occurs too. I'm attaching the stacks of the leaks!

The problem is the page cache!


2009-Aug-31 12:27:50 by anonymous:
On WBEL release 4 (Manifestdestiny Respin 1) 2.6.9 x86_64

pOpen->nLock = 2 pOpen->aPending = 2048 and crash (too many opened handles)


2009-Oct-19 05:53:33 by anonymous:
There is a test in the testsuite for this which confirms that it is fixed.
 
4017 code closed 2009 Aug anonymous   2009 Aug   1 1 "SELECT OR IGNORE" causes insert!
From the docs: IGNORE. When a constraint violation occurs, the one row that contains the constraint violation is NOT INSERTED or changed.

Now run the following (SQLite 3.6.16). The result will be TWO rows!


CREATE TABLE Test
(
 TestID INTEGER PRIMARY KEY,
 C01 INTEGER NOT NULL,
 C02 INTEGER NOT NULL,
 C03 INTEGER NOT NULL,
 C04 INTEGER NOT NULL,
 C05 INTEGER NOT NULL,
 C06 VARCHAR(255),
 C07 CHAR(10) NOT NULL,
 C08 INTEGER NOT NULL,
 C09 INTEGER NOT NULL,
 C10 INTEGER NOT NULL,
 C11 INTEGER NOT NULL,
 C12 INTEGER NOT NULL,
 C13 INTEGER NOT NULL,
 C14 CHAR(10) NOT NULL,
 C15 DATE NOT NULL,
 C16 INTEGER NOT NULL,
 C17 INTEGER NOT NULL,
 C18 INTEGER NOT NULL,
 C19 INTEGER NOT NULL,
 C20 INTEGER NOT NULL,

 UNIQUE (C01, C02, C03, C06)
);

INSERT OR IGNORE INTO Test (C01, C02, C03, C04, C05, C07, C08, C09, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20)
 VALUES (1, 2, 3, 4, 5, '', 8, 9, 10, 11, 12, 13, '3.3.16 bug', '2009-08-09 12:34:56', 14, 15, 16, 17, 18);
INSERT OR IGNORE INTO Test (C01, C02, C03, C04, C05, C07, C08, C09, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20)
 VALUES (1, 2, 3, 4, 5, '', 8, 9, 10, 11, 12, 13, '3.3.16 bug', '2009-08-09 12:34:56', 14, 15, 16, 17, 18);
2009-Aug-10 21:47:59 by drh:
The NULL you are inserted into column C06 makes both rows unique.
 
4016 build closed 2009 Aug anonymous build 2009 Aug   3 2 `make install` rebuilds SQLite
`make install` rebuilds all files, which have been already built during running `make`. It's a regression introduced in 3.6.17. Makefile files of older versions don't have this bug.
Thanks.
 
4015 code closed 2009 Aug anonymous test 2009 Aug   4 4 test1.c needs to test for SQLITE_OMIT_DEPRECATED
This routine needs to be surrounded with #ifndef SQLITE_OMIT_DEPRECATED

since it calls the non-existent routine sqlite3_expired when compiled with SQLITE_OMIT_DEPRECATED

2009-Aug-08 16:57:20 by anonymous:
Should add #ifndef around test_create_aggregate as well


2009-Aug-10 04:34:08 by danielk1977:
I don't see where you mean. I thought these issues were fixed almost a year ago by [5808] . Please check that you are using an up to date copy of test1.c and re-open the ticket if there really is still a problem. Thanks.
 
4014 new closed 2009 Aug anonymous front 2009 Aug   4 4 Special Caracter '\' doesn't work!
Using backslash to put special characters doesn't work on SQLite

Best way: SELECT '\n\ttest\t';

Working way: SELECT ' test ';

2009-Aug-08 18:34:34 by drh:
The special nature of '\' is only in MySQL. The SQLite complies with the SQL standard (and all other database engines other than MySQL, as far as I know) in treating '\' like any other character.
 
4013 doc closed 2009 Aug anonymous tcl 2009 Aug   5 4 http://www.sqlite.org/tclsqlite.html#profile is not defined
Documentation error in http://www.sqlite.org/tclsqlite.html The method "profile" is mentioned in the documentation but it is not defined. (Just curious)
2009-Aug-10 05:29:42 by danielk1977:
Thanks. Now fixed here:

  http://www.sqlite.org/docsrc/fdiff?v1=1576&v2=1746

Updated docs will migrate tothe website when 3.6.17 is released.

 
4012 new closed 2009 Aug anonymous back 2009 Oct   3 2 Drop tables/indexes in the presence of active statements
When I have one or more statements openned I can't call DDL queries, like CREATE TABLE, but that can be mapped to work if the statements not mention the tables or fields modified by the DDL queries.
In 3.6.16, it is possible to perform some DDL operations while statements are active. The attached script outputs:

  You can create a table
  You can create a view
  You can create an index
  You can create a trigger
  You can drop a trigger
  You can drop a view
  You cannot drop an index
  You cannot drop a table

You cannot drop a table or index while statements are running. This is to avoid problems if (a) a running statement is using the dropped index or table, or (b) if dropping the table or index requires moving the root page of another b-tree data structure that may be being used by another statement.

So this ticket is presumably requesting that SQLite be changed so that tables and indexes can be dropped while there exist open SQL statements.


2009-Oct-06 18:01:30 by anonymous:
It is SQL Lite! If you have a use case demonstrating the problem and workarounds such as using multiple connections are not applicable then please post details to the sqlite-users mailing list. Closing as this bug tracker is no longer in use.
 
4011 code fixed 2009 Aug anonymous vfs 2009 Aug shane 3 3 mutexes are not freed when using sqlite on windows
When using sqlite functions in DLL on Windows, when FreeLibrary() is called the winMutexEnd() function does not actually destroy mutexes.

In sqlite3_initialize(), function winMutexInit() is indirectly called three times:

  1. in sqlite3MutexInit()
  2. in sqlite3PcacheInitialize()
  3. in sqlite3_os_init() (in func sqlite3_vfs_register())

so variable winMutex_lock == 3.

In sqlite3_shutdown(), functions

  • sqlite3PcacheShutdown()
  • sqlite3_os_end()
  • sqlite3MutexEnd()

are called, but sqlite3PcacheShutdown() and sqlite3_os_end() do not decrement (directly or indirectly) variable winMutex_lock. So when sqlite3MutexEnd() is called the var winMutex is still == 3, and mutexes are not destroyed.

I've used sources 'sqlite-amalgamation-3_6_16.zip'.

I've used the following patch to fix this issue:

--- sqlite3.c	Sat Jun 27 10:10:08 2009
+++ sqlite3.c.fixed	Wed Aug 05 12:59:53 2009
@@ -15035,7 +15035,7 @@

 static int winMutexInit(void){
   /* The first to increment to 1 does actual initialization */
-  if( InterlockedIncrement(&winMutex_lock)==1 ){
+  if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
     int i;
     for(i=0; i<sizeof(winMutex_staticMutexes)/sizeof(winMutex_staticMutexes[0]); i++){
       InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);
@@ -15052,7 +15052,7 @@
 static int winMutexEnd(void){
   /* The first to decrement to 0 does actual shutdown
   ** (which should be the last to shutdown.) */
-  if( InterlockedDecrement(&winMutex_lock)==0 ){
+  if( InterlockedCompareExchange(&winMutex_lock, 0, 1)==1 ){
     if( winMutex_isInit==1 ){
       int i;
       for(i=0; i<sizeof(winMutex_staticMutexes)/sizeof(winMutex_staticMutexes[0]); i++){
Here's an example of resource leak in sqlite (msvc 2008 project) _http://file.qip.ru/file/97033993/2a5ff5f3/sqlite_res_leaks.html
 
4010 code active 2009 Aug anonymous back 2009 Aug   4 4 review design decision on JOURNAL_CHUNKSIZE in memjournal.c
memjournal.c has the comment on JOURNAL_CHUNKSIZE

    /* Space to hold the rollback journal is allocated in increments of
    ** this many bytes.
    **
    ** The size chosen is a little less than a power of two.  That way,
    ** the FileChunk object will have a size that almost exactly fills
    ** a power-of-two allocation.  This mimimizes wasted space in power-of-two
    ** memory allocators.
    */
    #define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*)))

The problem with this design decision, is that the memory journal almost always is written in 1024 (or page size) chunks, Since only 1020 bytes are available, there will almost always be at least 2 chunks needed with every read/write.

Recommend that testing be done for various sizes, and that it be made pagesize dependent. Informal testing shows that a larger chunk size, even up to 4* page size reduces churning in the memjrnlRead & memjrnlWrite routines

 
4009 code active 2009 Aug anonymous   2009 Aug   2 1 group_concat too slow
A call to group_concat takes endless time to complete when the original table contains 100,000+ entries.

I ported the database to mysql running on the same host, and the request takes a couple of seconds after having set the variable group_concat_max_len to a "decent" value (200,000 or so). See attached database for details.

.schema

SELECT * FROM slow_concat;

2009-Aug-04 15:54:11 by anonymous:
Cannot upload database (2MB compressed)


2009-Aug-06 06:59:07 by anonymous:
I let the select run until I got the result.

10 mins for SQLite

2.5 secs for MySQL


2009-Aug-06 12:33:09 by anonymous:
After having quickly looked at the code, it seems that groupConcatStep is called every time a tuple is added. sqlite3StrAccumAppend is then called which does a new memory allocation and copy of the current buffer with the content to add. That's a bit overkill. In the reallocation phase, maybe should you add a chunk of memory big enough to avoid a malloc at each call, but small enough to avoid a not_enough_memory_like message.

Quick hack ==> replacing line 770 of file printf.c with something like this might do the trick:

p->nAlloc = (int)szNew + (int)szNew % 8192;


2009-Aug-06 14:15:08 by anonymous:
tested successfully from 10 mins to 6 secs if changing line 770 with

p->nAlloc = ((int)szNew + 4095) & ~4095;

Not sure small gadgets with lowmem will enjoy this change though...

 
4008 new active 2009 Aug anonymous func 2009 Aug   1 1 2-digit year number in strftime() function by new 'y' switch
The 2-digits year number is needed for compatibility with other RDBMS.

diff -u date.c.orig date.c

--- date.c.orig 2009-06-25 15:24:38.000000000 +0400
+++ date.c      2009-08-03 15:57:21.000000000 +0400
@@ -844,6 +844,7 @@
 **   %w  day of week 0-6  sunday==0
 **   %W  week of year 00-53
 **   %Y  year 0000-9999
+**   %y  year 00-99
 **   %%  %
 */
 static void strftimeFunc(
@@ -883,6 +884,9 @@
         case 'Y':
           n += 8;
           break;
+        case 'y':
+          n += 4;
+          break;
         case 's':
         case 'J':
           n += 50;
@@ -968,6 +972,10 @@
           sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=sqlite3Strlen30(&z[j]);
           break;
         }
+        case 'y': {
+          sqlite3_snprintf(3,&z[j],"%02d",x.Y % 100); j+=sqlite3Strlen30(&z[j]);
+          break;
+        }
         default:   z[j++] = '%'; break;
       }
     }
 
4007 new closed 2009 Aug anonymous func 2009 Aug   1 1 New group_split() function as inverse of group_concat()
Now we can do:
sqlite> create table a(a integer);
sqlite> insert into a values (1);
sqlite> insert into a values (2);
sqlite> insert into a values (3);
sqlite> select group_concat(a) from a;
1,2,3
sqlite> select group_concat(a, ' ') from a;
1 2 3

But very useful will be to add new function group_split():

sqlite> select group_split('1,2,3') from a;
1
2
3
sqlite> select group_split('1 2 3', ' ') from a;
1
2
3

Can any to show example of the group_split() function if this can't be implemented in upstream?

2009-Aug-04 05:15:08 by danielk1977:
Suggest posting to the mailing list. Somebody might have an implementation of something similar. This kind of function probably won't be implemented in the core anytime soon.
 
4006 new closed 2009 Aug anonymous back 2009 Aug   3 3 PRAGMA to define journal location
It is could be useful to have a PRAGMA to define journal location.

For instance, some device have main storage for user data on quite slow interface (MMC/USB) and another file system on embedded storage which is much faster.

It would be great to improve commit performance by placing commit journal on fast storage.

2009-Aug-01 12:21:29 by drh:
The rollback journal must be in the same directory as the database file so that it can be found for recovery after a crash. See http://www.sqlite.org/atomiccommit.html for additional information.
 
4005 code closed 2009 Jul anonymous   2009 Oct   3 4 sqlite3AtoF() returns incorrect value for "7.4576373809917618"
I have an application running under Windows built with Visual Studio that does SQL queries using full precision floats. Occasionally it would fail to query a row that it just inserted. Using a debugger I tracked the failed matches down to the value returned by sqlite3AtoF():

I pulled the sqlite3AtoF() function out into the following simple example program that demonstrates the issue:

sqlite3AtoF() of '7.4576373809917618' = 7.4576373809917635

atof() of '7.4576373809917618' = 7.4576373809917618

-- Mark

#include "stdafx.h"
#include <ctype.h>
#define LONGDOUBLE_TYPE double
#define sqlite3Isspace isspace
#define sqlite2Isdigit isdigit
#define sqlite3Isdigit isdigit


int sqlite3AtoF(const char *z, double *pResult){
#ifndef SQLITE_OMIT_FLOATING_POINT
  int sign = 1;
  const char *zBegin = z;
  LONGDOUBLE_TYPE v1 = 0.0;
  int nSignificant = 0;
  while( sqlite3Isspace(*z) ) z++;
  if( *z=='-' ){
    sign = -1;
    z++;
  }else if( *z=='+' ){
    z++;
  }
  while( z[0]=='0' ){
    z++;
  }
  while( sqlite3Isdigit(*z) ){
    v1 = v1*10.0 + (*z - '0');
    z++;
    nSignificant++;
  }
  if( *z=='.' ){
    LONGDOUBLE_TYPE divisor = 1.0;
    z++;
    if( nSignificant==0 ){
      while( z[0]=='0' ){
        divisor *= 10.0;
        z++;
      }
    }
    while( sqlite3Isdigit(*z) ){
      if( nSignificant<18 ){
        v1 = v1*10.0 + (*z - '0');
        divisor *= 10.0;
        nSignificant++;
      }
      z++;
    }
    v1 /= divisor;
  }
  if( *z=='e' || *z=='E' ){
    int esign = 1;
    int eval = 0;
    LONGDOUBLE_TYPE scale = 1.0;
    z++;
    if( *z=='-' ){
      esign = -1;
      z++;
    }else if( *z=='+' ){
      z++;
    }
    while( sqlite3Isdigit(*z) ){
      eval = eval*10 + *z - '0';
      z++;
    }
    while( eval>=64 ){ scale *= 1.0e+64; eval -= 64; }
    while( eval>=16 ){ scale *= 1.0e+16; eval -= 16; }
    while( eval>=4 ){ scale *= 1.0e+4; eval -= 4; }
    while( eval>=1 ){ scale *= 1.0e+1; eval -= 1; }
    if( esign<0 ){
      v1 /= scale;
    }else{
      v1 *= scale;
    }
  }
  *pResult = (double)(sign<0 ? -v1 : v1);

  return (int)(z - zBegin);
#else
  return sqlite3Atoi64(z, pResult);
#endif /* SQLITE_OMIT_FLOATING_POINT */
}

int _tmain(int argc, _TCHAR* argv[])
{
    char *z = "7.4576373809917618";
    double sqliteResult;
    double systemResult;

    sqlite3AtoF(z, &sqliteResult);
    systemResult = atof(z);
    printf("sqlite3AtoF() of '%s' = %.30g\n", z, sqliteResult);
    printf("atof() of '%s' = %.30g\n", z, systemResult);
    return 0;
}
2009-Jul-31 17:28:12 by anonymous:
See #3868


2009-Oct-03 01:58:18 by anonymous:
Closing - see referenced ticket. If you want to discuss further then please use the sqlite users mailing list.
 
4004 new closed 2009 Jul anonymous   2009 Nov   5 2 Implement a "counter" SQL function
It would be very nice if this SQL function could make it into the next build. It's such a useful function and since the code for it already exists, it seems rather easy to implement! http://www.sqlite.org/cvstrac/chngview?cn=5614
2009-Aug-03 21:14:44 by anonymous:
It's very helpful function! The patch may be like to

$ diff -u func.c.orig func.c

--- func.c.orig 2009-06-25 15:45:57.000000000 +0400
+++ func.c      2009-08-04 00:59:44.000000000 +0400
@@ -1385,6 +1385,35 @@
 }

 /*
+** Implementation of the counter(X) function.  If X is an integer
+** constant, then the first invocation will return X.  The second X+1.
+** and so forth.  Can be used (for example) to provide a sequence number
+** in a result set.
+*/
+static void counterFunc(
+  sqlite3_context *pCtx,   /* Function context */
+  int nArg,                /* Number of function arguments */
+  sqlite3_value **argv     /* Values for all function arguments */
+){
+  int i;
+  int *pCounter;
+
+  pCounter = (int*)sqlite3_get_auxdata(pCtx, 0);
+  if( pCounter==0 ){
+    pCounter = sqlite3_malloc( sizeof(*pCounter) );
+    if( pCounter==0 ){
+      sqlite3_result_error_nomem(pCtx);
+      return;
+    }
+    *pCounter = sqlite3_value_int(argv[0]);
+    sqlite3_set_auxdata(pCtx, 0, pCounter, sqlite3_free);
+  }else{
+    ++*pCounter;
+  }
+  sqlite3_result_int(pCtx, *pCounter);
+}
+
+/*
 ** All all of the FuncDef structures in the aBuiltinFunc[] array above
 ** to the global function hash table.  This occurs at start-time (as
 ** a consequence of calling sqlite3_initialize()).
@@ -1463,6 +1492,7 @@
     LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),
     LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
   #endif
+    FUNCTION(counter,            1, 0, 0, counterFunc      ),
   };

   int i;

2009-Nov-08 02:32:41 by anonymous:
Anything that is added has to be supported in that version of SQLite forever and goes against the Lite philosophy. If this function was part of the SQL standard or would be used by almost every SQLite user then there would be a good case for it.

But that is not the case. There is however nothing stopping you from defining it for your own code and SQLite provides several mechanisms for doing so.

 
4003 code closed 2009 Jul anonymous func 2009 Oct   3 5 wrong rounding
In FAQ ist described, why 9.95 is rounded wrong. This is true and unavoidable. But the same happens, when 42.5, 80.5 or 90.5 ist rounded, but they have an exact representation.

The bug is in function sqlite3VXPrintf, where realvalue receives the exact value 42.5, then by "realvalue += rounder" the exact value 0.5 is added, result exact 43.0, but in the line "while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }" it is multiplied with the unexact 0.1, result unexact 4.3, and this is why the final result is wrong.

I corrected this within my code, I only wanted to inform you about it.

2009-Oct-03 02:04:13 by anonymous:
Tests with the SQLite shell 3.6.18 show this is no longer an issue. To continue discussion please use the sqlite-users mailing list.
 
4002 new closed 2009 Jul anonymous back 2009 Oct   5 4 PRAGMA to force all tables to use AUTOINCREMENT behavior
It would be nice to have a PRAGMA switch that forces the automatic rowid generation for all non-virtual tables in a database (including those that do not have a specific user defined INTEGER PRIMARY KEY alias) to use the AUTOINCREMENT behavior and keep all ROWID values unique for the lifetime of the database.

This might prove useful for generic frameworks that provide sync and replication ability (for example, on mobile devices) to track tables they otherwise don't manage or understand. It would also be nice if this PRAGMA supported the features discussed in ticket 3563. If not the "BY" feature, at least the "FROM" feature.

It is understood there is a small performance hit associated with this feature.

2009-Jul-30 16:11:04 by anonymous:
Also see: http://www.mail-archive.com/sqlite-users%40sqlite.org/msg44888.html


2009-Jul-30 16:35:10 by anonymous:
This is bad because ROWID without explicit field is not persistant and may change after dump/restore. Please see illustration of the problem:

sqlite> create table test(a);
sqlite> insert into test values(1);
sqlite> insert into test values(2);
sqlite> insert into test values(3);
sqlite> select rowid,* from test;
1|1
2|2
3|3
sqlite> delete from test where rowid=2;
sqlite> .dump test
BEGIN TRANSACTION;
CREATE TABLE test(a);
INSERT INTO "test" VALUES(1);
INSERT INTO "test" VALUES(3);
COMMIT;
sqlite> drop table test;
sqlite> BEGIN TRANSACTION;
sqlite> CREATE TABLE test(a);
sqlite> INSERT INTO "test" VALUES(1);
sqlite> INSERT INTO "test" VALUES(3);
sqlite> COMMIT;
sqlite> select rowid,* from test;
1|1
2|3
As you can see now ROWID=2 is correspond to field value 3 and it's wrong.


2009-Oct-18 09:41:45 by anonymous:
If you want to do sync and replication then choose a product without Lite in its name! It is far better to start with such capabilties designed in. Suggest you try Couchdb.
 
4001 code closed 2009 Jul anonymous func 2009 Oct   1 1 "SQL error: database table is locked" for user function
sqlite> select test1();

sqlite> select test2();
SQL error: database table is locked
sqlite> DROP TABLE test;
sqlite>
The functions test1, test2 are implemented as

static void test1(sqlite3_context *context, int argc,
    sqlite3_value **argv)
{
    int rc;
    sqlite3 *db;

    db = sqlite3_context_db_handle(context);

    rc = sqlite3_exec(db, "CREATE TABLE test(a)", NULL, NULL, NULL);

    if (rc != SQLITE_OK) {
        sqlite3_result_error_code(context, rc);
    }

    sqlite3_result_null(context);
}

static void test2(sqlite3_context *context, int argc,
            sqlite3_value **argv)
{
    int rc;
    sqlite3 *db;

    db = sqlite3_context_db_handle(context);

    rc = sqlite3_exec(db, "DROP TABLE test", NULL, NULL, NULL);

    if (rc != SQLITE_OK) {
        sqlite3_result_error_code(context, rc);
        return;
    }
    sqlite3_result_null(context);
}
2009-Jul-29 17:47:13 by anonymous:
sqlite> .load './libsqliteversioning.so
sqlite> create table b(b);
sqlite> CREATE TRIGGER b_i BEFORE INSERT ON b BEGIN
   ...>     SELECT test1();
   ...> END;
sqlite> CREATE TRIGGER b_d BEFORE DELETE ON b BEGIN
   ...>     SELECT test2();
   ...> END;
sqlite> insert into b values ('');
sqlite> delete from b;
SQL error: database table is locked
sqlite>


2009-Jul-29 20:43:01 by anonymous:
1. test1() doesn't return after an error
2. http://www.sqlite.org/cvstrac/wiki?p=DatabaseIsLocked


2009-Jul-29 22:22:38 by anonymous:
1. Yes, it is. But result is equal.

2. It's impossible to call user function without SELECT statement.

Now this call

SELECT user_function();

always lock database for DROP TABLE but no lock for CREATE TABLE.

A lot of extensions may create and using special tables but can't remove these itself. As example trigger-based async replication is needed of special tables for record versions and record actions logging.


2009-Oct-06 18:03:05 by anonymous:
Under the hood this is actually a duplicate of #4012.
 
4000 code closed 2009 Jul anonymous front 2009 Jul   1 1 Bug in column names and returned data with subselect
When referencing column names of a subselect in an outer select, it seems that the quoting or bracketing of the columns is kept ... even worse, as in the case of the t2 example below, the returned DATA is messed up if you quote a column name under certain circumstances

  create table t1 (mycol);
  create table t2 ("[mycol]");
  insert into t1 values('a');
  insert into t2 values('a');

  select * from t1;
  mycol
  a

  select [mycol] from t1;
  mycol
  a

  select [mycol] from (select * from t1);
  [mycol]
  a

  select "mycol" from (select * from t1);
  "mycol"
  a

  select "mycol" from (select * from t2);
  "mycol"
  mycol

  select [mycol] from (select * from t2);
  SQL error: no such column: mycol

  select "[mycol]" from (select * from t2);
  "[mycol]"
  a
2009-Jul-29 05:04:46 by danielk1977:
I think this is all behaving as designed. Suggest posting to the mailing list for an explanation as to the results of the 5th select.


2009-Jul-29 05:49:08 by anonymous:
Ok granted the 5th scenario was my mistake -- I'd forgotten that quotes will fallback to a string literal when it doesn't match an identifier.

However, shouldn't the engine be stripping out the leading and trailing identifiers that DO match a legal identifier name in output column names?

 
3999 code closed 2009 Jul anonymous   2009 Jul danielk1977 3 3 FTS3 : Use other separator than space for matches in offsets function
In order to make easier spitting of matches of words in offsets function of FTS3, it should be nice to distinguish:

  • separators of different matches
  • separators of the 4 integers inside an individual match.

We could keep the space character to separate the 4 integers, but use an other character between matches, eg:

  • TAB character(0x09),
  • colon character,
  • any other character defined as alternative in a new PRAGMA command (for example: offsets_sep = ":";).

So, using this regular pattern: "(\d+) (\d+) (\d+) (\d+)", we could split the offsets into clusters of 4 integers.

Best regards

This is a word for word copy of #3750.

Fts3 is an SQLite extension, not a core module. This makes it tricky to add PRAGMA options to configure it. And I don't think we can change the default separator used by the offsets() function without breaking existing applications.

It should be possible to have the application split the results into sets of 4 integers, no?

 
3998 new active 2009 Jul anonymous func 2009 Aug   3 3 Optimization for UPDATE statement
When I perform an UPDATE command, even if the field value is not being changed, the sqlite does recordings on disc, making the process slow.

Exemple:
UPDATE tb SET field = newFieldValue;
takes 1082 ms and performs many written to disk!

And...
UPDATE tb SET field = newFieldValue WHERE field != newFieldValue;
takes 14 ms and makes little written to disk!

Someone will tell me to use the second form but, the second form will be more slow if 'newFieldValue' is a subselect or something else.

2009-Jul-29 03:31:19 by anonymous:
"the second form will be more slow if 'newFieldValue' is a subselect or something else." You can't assume that. It depends on the efficiency of the SQLite query optimizer. I've worked on other database products where I wouldn't hesitate to use the second form with 'newFieldValue' being a subselect. Do more tests and see what happens! HTH, TC
 
3997 code closed 2009 Jul anonymous front 2009 Jul danielk1977 2 1 sqlite3_create_collation doesn't work or specified collation not used
Either: Calls to sqlite3_create_collation do not register collations or the SQL parser does not mistakenly identifies all COLLATE <collation> statements as using the BINARY collation function "binCollFunc".

All collations registered are directed to the binCollfunc including NOCASE and user-defined collations.

 
3996 new closed 2009 Jul anonymous ext 2009 Jul   5 3 fts3 syntax: case insensitive column names
Whould it be possible in FTS3 that the column name comparison before the ':' character becomes case insensitive?

Example: CREATE VIRTUAL TABLE t USING FTS3 (Name, Address)

These queries would then all be identical: SELECT * FROM t WHERE t MATCH 'name:acme' SELECT * FROM t WHERE t MATCH 'Name:acme' SELECT * FROM t WHERE t MATCH 'NAME:acme'

 
3995 new closed 2009 Jul anonymous ext 2009 Jul   5 3 fts3 legacy syntax: whitespace before '-' prefix
For the '-' prefix in FTS3 it makes no difference whether it is preceded by a whitespace character or not. MATCH 'a-b' returns the same result as MATCH 'a -b'. Would it be possible to change the '-' prefix, so that it is only interpreted as exclusion operator when it is preceded by a whitespace? MATCH 'a-b' should then return the same as MATCH 'a b', while MATCH 'a -b' is still interpreted as 'a NOT b'?
2009-Jul-28 07:53:36 by danielk1977:
I don't think we can make such a change without risking breaking existing applications.
 
3994 code closed 2009 Jul anonymous   2009 Oct   2 2 REPLACE statements fail on FTS3 tables when data already exists
  CREATE VIRTUAL TABLE ftsX USING FTS3(content);
  REPLACE INTO ftsX (docID, content) VALUES (1, 'a');
  REPLACE INTO ftsX (docID, content) VALUES (1, 'a');

Executing the above sql fails with a 'constraint failed' error. Does REPLACE functionality not work with FTS3 and/or VIRTUAL tables?

2009-Oct-20 06:20:05 by anonymous:
Use the sqlite-users mailing list for questions.
 
3993 warn closed 2009 Jul anonymous   2009 Sep   2 2 warnings in 3.6.16
[ 71%] Building C object externals/sqlite3/sqlite3.c.o

cc1: warnings being treated as errors

sqlite3/sqlite3.c: In function 'proxyGetHostID':

sqlite3/sqlite3.c:25431: warning: comparison of unsigned expression < 0 is always false

sqlite3/sqlite3.c:25445: warning: comparison of unsigned expression < 0 is always false

sqlite3/sqlite3.c: In function 'proxyGetLockPath':

sqlite3/sqlite3.c:25495: warning: comparison between signed and unsigned

sqlite3/sqlite3.c: At top level:

sqlite3/sqlite3.c:72969: warning: missing initializer

sqlite3/sqlite3.c:72969: warning: (near initialization for 'sqlite3Apis.aggregate_count')

Grtz, Steven

2009-Jul-27 20:14:47 by shane:
What compiler and compiler options are you using? Also what SQLite options are you using? I suspect these warnings will only appear with certain SQLITE_OMIT options and at specific warning levels (such as -Wextra with gcc).


2009-Sep-30 08:46:37 by anonymous:
No followup from OP and issue is revisited on the mailing list frequently enough.
 
3992 code fixed 2009 Jul anonymous front 2009 Jul   2 1 CHECK constraint one column one effects unrelated second column
Consider these SQL instructions:

  $ cat bug.txt
  CREATE TABLE parameters1(
       mountcnt    INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),
       version     REAL NOT NULL
      );
  INSERT INTO parameters1(mountcnt, version) VALUES(1, 1.0);
  UPDATE parameters1 SET mountcnt = mountcnt + 1;

  CREATE TABLE parameters2(
       mountcnt    INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),
       version     REAL NOT NULL CHECK (typeof(version) == 'real')
      );
  INSERT INTO parameters2(mountcnt, version) VALUES(1, 1.0);
  UPDATE parameters2 SET mountcnt = mountcnt + 1;

  $ tmp/sqlite3-3.6.16.bin < bug.txt
  SQL error near line 14: constraint failed

The only difference between table 1 and 2 is the additional CHECK constraint on the 'version' column. Yet for some reason the increment of 'mountcnt' fails for the second table.

This is reproducible with the prebuilt linux binary.

 
3991 xplatform fixed 2009 Jul anonymous vfs 2009 Aug shane 2 3 Windows CE fix for Microsoft ARM emulator, code simplification
While stress-testing the locking mechanism for Windows CE, a defect in the Microsoft ARM emulator was uncovered which caused a very random locking error to occur when performing a large number of inserts to a database outside of a transaction. Isolating the problem was a bit troublesome because it only appears when code optimizations are turned on, and only under the ARM emulator. The problem seems to not occur on a real device.

In any event, the fix was rather goofy, but a code simplification nonetheless so here goes:

  // os_win.c line 485:

    /* Want a read-only lock? */
  - else if ((dwFileOffsetLow >= SHARED_FIRST &&
  -           dwFileOffsetLow < SHARED_FIRST + SHARED_SIZE) &&
  -          nNumberOfBytesToLockLow == 1){
  + else if (dwFileOffsetLow == SHARED_FIRST && nNumberOfBytesToLockLow == 1){
      if (pFile->shared->bExclusive == 0){
        pFile->local.nReaders ++;
        if (pFile->local.nReaders == 1){
          pFile->shared->nReaders ++;
        }
        bReturn = TRUE;
      }
  }

Since isNT() is always true on CE, LockFileEx() is always called for a read lock, which always passes SHARED_FIRST for the dwFileOffsetLow, and 1 for nNumberOfBytesToLockLow to winceLockFile. So the range check is unnecessary.

Another validation of the fix was to leave the original code intact and disable optimizations for the winceLockFile() function by surrounding the function with #pragma optimize("",off) winceLockFile() function #pragma optimize("", on) Disabling optimizations with the original range check intact also prevent the ARM emulator from randomly failing in here.

The nature of the error was that occasionally, randomly, while trying to acquire a PENDING lock, pFile->local.nReaders was being incremented. Shortly thereafter an unrecoverable "database is locked" error would occur due to the reader lock counts not being decremented to zero.

2009-Jul-26 19:06:50 by anonymous:
For reference, the originating System.Data.SQLite forum thread: http://sqlite.phxsoftware.com/forums/p/1850/7863.aspx


2009-Jul-31 08:03:18 by anonymous:
The fix is very important for us to develope in Windows Mobile platform. Could it be fixed sooner?

So much thanks.


2009-Aug-02 21:32:36 by anonymous:
Confirmed. It can happen on HP 214 randomly. Also on same device when inserting or updating a lot of data may result in database corruption. Don't know if this is the same case, but when doing inserts from hand like above we got database locked error, but when coping 1000000 records between tables nothing happened until application restart, after which database was corrupted. Odd.


2009-Aug-05 04:09:46 by shane:
This was to work around what appears to be a compiler bug in MSVC which exhibited itself when optimizations were enabled and the application was running under the Windows CE Emulator with an ARM system image. I was not able to duplicate the bug with my emulator tests, although I did verify that the code simplification worked correctly.
 
3990 code closed 2009 Jul anonymous vfs 2009 Oct   1 1 bus error on sparc arch
Hi,

I'm the Debian maintainer of SQLite3. Two bus errors reported against it on sparc, both result of a test suite. The first related to apr-util[1] and the second to monotone[2]. Both bugreports have backtrace that I don't include here but may help.

I'm afraid I can't give you more information, but bugreporters may do. Still, contact me if I can help anything.

Regards, Laszlo/GCS

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=538396

[2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524140

2009-Jul-27 07:55:12 by danielk1977:
Added a request for a stack trace on a debugging build to debian bug 538396.


2009-Oct-02 08:55:15 by anonymous:
Original reporters have not responded on Debian bug tracker asking for debug mode traceback. Closing this ticket as this tracker is no longer used.

To continue with the issue then please provide a backtrace with debug symbols. It would also be very nice if valgrind was used to point fingers appropriately (it is exceedingly rare for this kind of issue to be SQLite's fault!) It can be continued on the sqlite-users mailing list.

 
3989 code active 2009 Jul anonymous test 2009 Jul   4 4 lock3 has funky filepath causing problems on windows
lock3.test, version 1.4 has a real funny filepath in test 1.1

  do_test lock3-1.1 {
    file mkdir tempdir/t1/t2/t3
    sqlite3 db2 ./tempdir/t1//t2/./t3//./../..//./../../tempdir/..//test.db//

suggest replacing it with

  do_test lock3-1.1 {
    sqlite3 db2 test.db
2009-Jul-25 13:31:38 by danielk1977:
In what respect is it causing problems on windows?


2009-Jul-25 14:41:45 by anonymous:
It's the final / causing the problems, and this line doesn't test SQLite anyways, its testing the underlying file system

the same problem can be created from the commandline tool running under Vista

  Y:\SQLite3\Tools>dir tempdir\t1\t2\t3
   Volume in drive Y is Personal
   Volume Serial Number is BAC6-795F

  Y:\SQLite3\Tools>sqlite3 ./tempdir/t1//t2/./t3//./../..//./../../tempdir/..//test.db//
  SQLite version 3.6.16
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t1 (c1);
  Unable to open database "./tempdir/t1//t2/./t3//./../..//./../../tempdir/..//test.db//": unable to open database

  Y:\SQLite3\Tools>sqlite3 ./tempdir/t1//t2/./t3//./../..//./../../tempdir/..//test.db
  SQLite version 3.6.16
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t1 (c1);
  sqlite> .quit
 
3988 code fixed 2009 Jul anonymous test 2009 Jul   4 4 vacuum2 test does not handle OMIT_INCRBLOB properly
vacuum2 attempts to account for OMIT_INCRBLOB properly with the following lines

  ifcapable !incrblob {
    proc zeroblob {n} { string repeat 0 $n }
    db function zeroblob zeroblob
  }

However, this string can be stored as an integer which causes the tests in vacuum2 to fail

suggested change

  ifcapable !incrblob {
    proc zeroblob {n} { string repeat a $n }
    db function zeroblob zeroblob
  }
Thanks.
 
3987 code active 2009 Jul anonymous   2009 Jul   4 3 limit + order by speed
Seems like last query sorts entire table instead just one row:

  SQLite version 3.6.16
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t(a);
  sqlite> insert into t values(1);
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> insert into t select * from t;
  sqlite> select * from (select * from t limit 1); -- this is fast
  1
  sqlite> select * from (select * from t limit 1) order by a; -- this is slow
  1
2009-Jul-24 14:43:39 by danielk1977:
SQLite is probably transforming the query to this internally:

  SELECT * FROM t ORDER BY a LIMIT 1

which is a valid transformation, but not a productive one.

 
3986 code closed 2009 Jul anonymous front 2009 Jul   3 3 EXPLAIN causes Segmentation Fault
The following script causes a Segmentation Fault:

Script s1:

.database
.schema
create table barf(a int, b int);
select * from barf;
.database
.schema
insert into barf values (10, 20);
insert into barf values (100, 204);
insert into barf values (1, 203);
insert into barf values (11, 21);
select * from barf;
.explain
explain select * from barf;
.quit
Running of script s1:

$ sqlite3 -init s1
Loading resources from s1
seq  name             file
---  ---------------  ----------------------------------------------------------
0    main
seq  name             file
---  ---------------  ----------------------------------------------------------
0    main
1    temp             /var/tmp/sqlite_TMCqMB6tH91IcGr
CREATE TABLE barf(a int, b int);
10|20
100|204
1|203
11|21
Segmentation fault
2009-Jul-22 16:32:41 by drh:
Unable to replicate the problem in CVS HEAD. Perhaps there is an issue with the way the OP compiled SQLite?
 
3985 code closed 2009 Jul anonymous test 2009 Jul   4 4 capi3c.test does not test for SQLITE_OMIT_UTF16
capi3c fails testing when UTF16 is not available

ANALYSIS:

capi3c.test calls procedures such as "sqlite3_column_text16", which are not available in test_1.c when compiled with SQLITE_OMIT_UTF16

 
3984 doc closed 2009 Jul anonymous   2009 Oct   3 3 Requirement H13015 does not specify value for pzTail
http://sqlite.org/hlr10000.html#H13015 currently ends with "What does *pzTail point to if there is one statement?"

If there is more than one statement in the string passed to the function, *pzTail will point past the end of the first statement, but there is currently no guarantee that it won't do the same if there is only one statement, making it impossible, based on the documentation, to determine if more statements exist.

The value of *pzTail should be well-defined no matter how many statements are passed to the function.

2009-Oct-01 07:23:36 by anonymous:
Now http://www.sqlite.org/src/tktview/43d2aa29b9cc8e8c9e0d67c03c6879112cf75d59
 
3983 code closed 2009 Jul sdwilsh build 2009 Jul   2 2 SQLITE_API not used in sqlite3.h
In the amalgamation, sqlite3.h does not have SQLITE_API before API functions. As a result, consumers on windows who build a dll are required to use a def file. It'd be much nicer to be able to add a compile time define and set SQLITE_API to __dllspec(dllexport) and the consumer code can just define SQLITE_API to __dllspec(dllimport).
2009-Jul-22 19:03:58 by danielk1977:
The script that generates the amalgamation package now adds the SQLITE_API macro before each API function and global variable in sqlite3.h.

This means that the two global variables that are part of the API are defined in sqlite3.h as:

    SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
    SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;

And in sqlite3.c as:

    SQLITE_API const char sqlite3_version[] = "version string";
    SQLITE_API char *sqlite3_temp_directory;

So presumably dll users will have to define SQLITE_EXTERN as an empty string. Its default value is "extern".

 
3982 new closed 2009 Jul anonymous front 2009 Oct   2 1 'INSERT OR REPLACE' changes rowid
I don't think that the rowid should change after a 'INSERT OR REPLACE' execution when a row is replaced and rowid is AUTOINCREMENT.

It's as though the REPLACE is implemented as

"if the row exists, delete the row, then do INSERT ...",

when it should be

"if the row exists, update the row's column values".


create table if not exists mytable (id INTEGER PRIMARY KEY AUTOINCREMENT, name string)
Cheers, Yonas
2009-Jul-20 07:03:10 by danielk1977:
With some table schemas, an "INSERT OR REPLACE" statement may need to delete more than one row before inserting the new record.


2009-Jul-20 14:09:17 by anonymous:
I am pleased that someone else found this a little odd - I got round the problem through some rather complex triggers because I assumed it was correct behaviour for SQL to delete the row and create a new one. However, if it looks like this may be fixed to not do this, then that would be great news indeed...


2009-Jul-22 10:06:11 by danielk1977:
It is correct behavior.

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

From here: http://www.sqlite.org/lang_conflict.html

So this ticket is really a feature request for some kind of REPLACE statement that preserves rowids. The trick being, of course, that a single REPLACE statement may cause more than one row to be deleted. In this case how should SQLite determine which of the deleted rowids to reuse? For example:

  CREATE TABLE t1(a UNIQUE, b UNIQUE);
  INSERT INTO t1 VALUES('one', 'I');     /* rowid=1 */
  INSERT INTO t1 VALUES('two', 'II');    /* rowid=2 */

At the moment, the following deletes both existing rows and adds a new row with rowid=3. What else could/should it do?

  INSERT OR REPLACE INTO t1 VALUES('one', 'II');


2009-Jul-22 15:14:14 by anonymous:
But delete triggers MUST fire on these deletions! The command "insert or replace" doesn't show that some background database modification operations were performed. There are no way to know when some rows are deleted before inserting.

Please see ticket 3964 - database history logging and replication doesn't work correct now. So realization of user-level replication is impossible. As example, "Versioning" extension (http://mobigroup.ru/files/sqlite-ext/) work incorrect for this queries. (P.S. User-level replication Slony/SlonyII for PostgreSQL work correct for all queries!).


2009-Oct-24 00:54:24 by anonymous:
Closing. Please continue discussion on the sqlite-users mailing list. This is two separate issues - one about how to do replication and second about SQLite correctly following SQL standards.
 
3981 doc fixed 2009 Jul anonymous front 2009 Jul paul 1 1 Source file "sqlite3.c":the comment about how many lines for sqlite3.h
the comment about how many lines for "sqlite3.h" is wrong: this can be changed with a preprocessor then will not have this kind of problem again. :)
 
3980 code closed 2009 Jul anonymous   2009 Jul   1 3 Primary key with NULL not enforced
create table if not exists test (pk1 varchar(20), pk2 numeric(3,0), field1 varchar(30), primary key(pk1, pk2));
insert into test values ('123456789', null, 'Test');
insert into test values ('123456789', null, 'Test');
insert into test values ('123456789', null, 'Test');

Expected result:
Second and third insert should fail with error saying: columns pk1, pk2 are not unique.

2009-Jul-18 14:32:51 by anonymous:
Actually all insert should have failed because primary key should not contains NULL value logically.


2009-Jul-18 14:49:43 by drh:
From the documentation: (http://www.sqlite.org/lang_createtable.html)

"According to the SQL standard, PRIMARY KEY should imply NOT NULL. Unfortunately, due to a long-standing coding oversight, this is not the case in SQLite. SQLite allows NULL values in a PRIMARY KEY column. We could change SQLite to conform to the standard (and we might do so in the future), but by the time the oversight was discovered, SQLite was in such wide use that we feared breaking legacy code if we fixed the problem. So for now we have chosen to continue allowing NULLs in PRIMARY KEY columns. Developers should be aware, however, that we may change SQLite to conform to the SQL standard in future and should design new programs accordingly."
So, we are aware of the fact that SQLite allows NULLs in the primary key and we have deliberately allowed that to be the case for now.

The other part of your complaint is a duplicate of ticket #3463. Please see that prior ticket for the rational behind the current behavior of SQLite.

 
3979 code closed 2009 Jul anonymous   2009 Oct   2 3 DISTINCT performance
SQLite speed during SELECT DISTINCT is much slower than it could be. I'v compared it to MySQL with MyISAM engine and below are results (all reported times are simillar after running query at least twice).

All tests were done on WindowsXP. SQlite was compiled using visual C compiler (I'v done one test using gcc -O3 and it was slower)

Tested table : CREATE TABLE t(a REAL, b REAL, c REAL, d REAL, e REAL, f REAL, g REAL)
Actual values are all REAL randomly generated between 0 and 1.
There are 35000000 rows.
SQLite is configured with:
SQLITE_DEFAULT_PAGE_SIZE = 32768
SQLITE_DEFAULT_CACHE_SIZE = 8000
SQLITE_DEFAULT_TEMP_CACHE_SIZE = 8000

Database file with just the one table uses 2.3G (1.8G in MySQL)

The query 'select count(distinct d) from t' takes 1 min 50 sec in MySQL (memory used: 200M) and 9 min 17 sec in SQLite (memory used: 500M). The problem is a different problem than known problem with SQLite sorter - most of the time processor was fully used and there wasn't that much disc writes (by the way the sorter problem on that table causes creation of index take 9 hours compared to 10 minutes in MySQL).

After building debug version with optimizations disabled profiler shows (first few minutes of execution):

  Symbol + Offset            	64-bit 	Timer samples
  insertCell                 	       	28.71
  sqlite3BtreeMovetoUnpacked 	       	11.33
  sqlite3VdbeRecordCompare   	       	5.82
  sqlite3VdbeSerialGet       	       	5.69
  findOverflowCell           	       	5.23
  cellSizePtr                	       	4.75
  sqlite3MemCompare          	       	4.64
  balance_nonroot            	       	4.31
  assemblePage               	       	3.97
  sqlite3IsNaN               	       	3.45
  memcpy                     	       	2.92
  memset                     	       	2.7

  Total: 678628 samples, 83.51% of samples in the module

I see that the for loop in insertCell() wasn't changed for a long time. Maybe it isn't necessary to copy few thousand bytes to put 2 bytes in front of them? And even if it is neccesery maybe that code ca be changed. The only try I did was to replace the for loop with memmove() and profiler shows that it helped:

  Symbol + Offset            	64-bit 	Timer samples
  sqlite3BtreeMovetoUnpacked 	       	14.36
  sqlite3VdbeRecordCompare   	       	8.24
  findOverflowCell           	       	6.48
  sqlite3VdbeSerialGet       	       	6.21
  cellSizePtr                	       	5.87
  TrailUpVec                 	       	5.79
  LeadDownVec                	       	5.76
  sqlite3MemCompare          	       	5.43
  balance_nonroot            	       	5.27
  assemblePage               	       	4.93
  sqlite3IsNaN               	       	4.3
  memcpy                     	       	3.52
  memset                     	       	3.35

  Total: 516985 samples, 79.51% of samples in the module

TrailUpVec() and LeadDownVec() are part of runtime library - probably memmove() uses them.

Unfortunatelly after turning optimization on, tested query runs longer (9 min 33 sek). Looks like original version skips one comparition compared to possible naive implementation of memmove(). Maybe more loop unwinding would make SQLite run faster.

2009-Jul-18 13:45:43 by anonymous:
Interesting remark. Note that you are using a 32k page size which will increase the overhead needed to insert a cell into a page. Have you tried with the default (1k) page size ? I agree that the copy-lines with
.. for(j=end-2, ptr=&data[j]; j>ins; j-=2, ptr-=2){ ...
appear to have room for code optimization but I'm not sure if that is worthwhile to do so. Going backwards in the memory and copy data might prevent the processor to make full use of his cache, imo. might also be useful to copy 4 bytes using 32 bit pointers instead of a single byte loop, etc. ? but that might be the job of the compiler...


2009-Jul-18 14:51:27 by anonymous:
Judging from other benchmarks I'v seen/done large page size makes SQLite run faster, but yes - I'v tried default page size (with 256000 set for both caches) and after few minutes sorter problem was hit - processor stopped working and disc writes started. It would probably take few hours to finish the query.
Also notice that even without insertCell() function SQLite still will be a lot slower than MySQL. I'v seen an open ticket with a patch for speeding up sqlite3VdbeRecordCompare() (it compares bytes without unpacking) - if I remember corectly autor claims that in can increase speed about 20%. I haven't studied sqlite3BtreeMovetoUnpacked() but if this one and other two could be made fater it would be really visible (unfortunatelly still slower than MySQL).


2009-Jul-18 15:13:52 by danielk1977:
Can you attach the code used to test each system? Thanks.


2009-Jul-18 16:11:42 by anonymous:
Any plans to change the sorter to use something other than a b-tree?


2009-Jul-18 16:16:43 by anonymous:
I'v been executing query using MySQL and SQLite console (SQLite version compiled myself using shell.c and sqlite3.c). The only problem is to copy table from one database to another. I don't have code that do this efficiently using publictly available software, but since the data is random, any data should produce the same results. I'v just wrote java code that creates test table:

  import java.util.Random;
  import java.sql.*;

  public class Test {
  	public static void main(String[] arg) throws Exception {
  		String driver = "org.gjt.mm.mysql.Driver";
  		String url = "jdbc:mysql:///test";
  		String user = "root";
  		String password = "";
  		int rows = 35000000;

  		Class.forName(driver);

  		Connection conn = DriverManager.getConnection(url, user, password);

  		try {
  			conn.createStatement().executeUpdate("create table t(a double, b double, c double, d double, e double, f double, g double)");
  			PreparedStatement stmt = conn.prepareStatement("insert into t values(?, ?, ?, ?, ?, ?, ?)");

  			Random rnd = new Random();

  			for (int i = 0; i < rows; i++) {
  				for (int j = 1; j <= 7; j++) {
  					stmt.setDouble(j, rnd.nextDouble());
  				}
  				stmt.executeUpdate();
  			}
  		} finally {
  			conn.close();
  		}
  	}
  }

For MySQL it's important to configure database to use MyISAM (or add engine in CREATE TABLE). Obviously SQLite version should use transactions, but it should be faster to use similar C code for SQLite.

If you want I can send you exact tables I'v used. But it will be a lot of GB.


2009-Jul-20 09:01:58 by danielk1977:
The attached tcl script uses the sqlite tcl interface and mysqltcl to test this. Script uses 350,000 rows instead of 35M. With all default settings, mysql is faster than SQLite for this operation.

  dan@computer2:~$ tclsh8.5 ./3979.tcl
  SQLite: 3078399 microseconds per iteration
  Mysql: 407267 microseconds per iteration

  dan@computer2:~$ tclsh8.5 ./3979.tcl -nosetup
  SQLite: 2995847 microseconds per iteration
  Mysql: 405754 microseconds per iteration


2009-Oct-03 02:02:16 by anonymous:
Now http://www.sqlite.org/src/tktview/2e047cbefa54099ea6866d7b7e68857aa25d1eab
 
3978 code closed 2009 Jul danielk1977 ext 2009 Jul   1 1 Asynchronous IO is incompatible with multi-file transactions
In the following script, the COMMIT statement fails with SQLITE_CANTOPEN.

    ATTACH 'test2.db' AS next;
    CREATE TABLE main.t1(a, b);
    CREATE TABLE next.t2(a, b);
    BEGIN;
      INSERT INTO t1 VALUES(1, 2);
      INSERT INTO t2 VALUES(3, 4);
    COMMIT;
 
3977 todo closed 2009 Jul danielk1977   2009 Jul danielk1977 3 3 Defining SQLITE_OMIT_INCRBLOB breaks sqlite3_result_zeroblob()
When OMIT_INCRBLOB is defined, using sqlite3_result_zeroblob() from within a user function causes the function to return a blob zero bytes in size, regardless of the arguments passed to result_zeroblob().

This causes the r-tree module to crash.

 
3976 code closed 2009 Jul anonymous test 2009 Jul danielk1977 4 4 savepoint does not handle SQLITE_OMIT_INCRBLOB properly
savepoint.test,v 1.12 does not handle section 5 properly when compiled with SQLITE_OMIT_INCRBLOB

savepoint-5.1.1... Error: {incrblob not available in this build}

 
3975 code fixed 2009 Jul anonymous test 2009 Jul shane 4 4 tableapi.test section 3 runs when compiled with SQLITE_OMIT_GET_TABLE
Section 2 tests are blocked with

  ifcapable gettable {
  }

This same blocking needs to be around section 3 as well, since it uses the sqlite3_get_table_printf routine which is not available in test1.c when compiled with SQLITE_OMIT_GET_TABLE

2009-Jul-17 00:13:26 by anonymous:
Better still would be to block out the entire test file, since sections 4 to 7 use the same sqlite3_get_table_printf routine as well
 
3974 new closed 2009 Jul anonymous front 2009 Oct   4 3 support for SQL:2008 <result offset clause> and <fetch first clause>
Add support for SQL:2008 <result offset clause> and <fetch first clause> to limit result set cardinality

SQL 2008 has added new syntax to support a direct way to limit the returned set of rows in a result set.

Syntax (cf. SQL 2008, section 7.13):

  <result offset clause> ::= OFFSET <n> {ROW | ROWS}
  <fetch first clause> ::= FETCH {FIRST | NEXT} [<n>] {ROW | ROWS} ONLY
2009-Oct-04 20:47:19 by anonymous:
Please repost on the sqlite-users mailing list. In particular reference the syntax used by other databases as well as draft or actual SQL standards (latter preferred).
 
3973 warn fixed 2009 Jul anonymous func 2009 Jul danielk1977 5 5 sqlite3ExprListDup assigns to but does not use pNewExpr
  873 ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){
  889     Expr *pNewExpr;
  891     pItem->pExpr = pNewExpr = sqlite3ExprDup(db, pOldExpr, flags);

pNewExpr isn't used anywhere, this bothers Coverity :)

 
3972 code closed 2009 Jul anonymous ext 2009 Jul danielk1977 3 3 zNew is used uninitialized in getNextString if !zTemp
http://mxr-test.konigsberg.mozilla.org/sqlite/source/ext/fts3/fts3_expr.c?mark=235,243,246-248,251-251#233

  233   if( rc==SQLITE_DONE ){
  ...
  235     char *zNew;
  ...
  243     if( zTemp ){
  244       zNew = &(((char *)p)[nByte]);
  ...
  246     }else{
  247       memset(p, 0, nByte+nTemp);
  248     }
  ...
  250     for(jj=0; jj<p->pPhrase->nToken; jj++){
  251       p->pPhrase->aToken[jj].z = &zNew[nNew];
2009-Jul-15 19:55:20 by drh:
It appears that if zTemp==0, then p->pPhrase->nToken==0 and the loop that uses &zNew[nNew] is never run. So I don't think this is a problem. Do you have a test case to prove me wrong?
 
3971 code closed 2009 Jul anonymous back 2009 Oct   4 4 TRACE error in btree.c when page is null
SETUP TRACING IN btree.c at line 30, by changing #if 0 to #if 1

Run the following lines of code

      CREATE TABLE t1(x);
      INSERT INTO t1 VALUES(randomblob(9000));
      INSERT INTO t1 VALUES(randomblob(9000));
      BEGIN;
      INSERT INTO t1 SELECT x||x FROM t1;
      INSERT INTO t1 SELECT x||x FROM t1;
      INSERT INTO t1 SELECT x||x FROM t1;
      INSERT INTO t1 SELECT x||x FROM t1;
      ROLLBACK;
      INSERT INTO t1 SELECT x||x FROM t1;
      INSERT INTO t1 SELECT x||x FROM t1;
      INSERT INTO t1 SELECT x||x FROM t1;
      INSERT INTO t1 SELECT x||x FROM t1;
      BEGIN;
      DELETE FROM t1 WHERE rowid%5!=0;
      SELECT count(*) FROM t1;

The TRACE statement at line 4755

      TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno));

eventually fails after outputting ....

<snip>

  FREE-PAGE: 16 leaf on trunk page 3
  FREE-PAGE: 17 leaf on trunk page 3
  FREE-PAGE: 18 leaf on trunk page 3

because pPage is 0;

Unhandled exception at 0x0046a664 in sqlite3.exe: 0xC0000005: Access violation reading location 0x00000048.

This tracker and hence ticket are now closed. If this is still an issue then please continue discussion on the sqlite-users mailing list where other developers can help find a solution.
 
3970 code closed 2009 Jul anonymous ext 2009 Jul   5 4 Rtree gives poor error message with column named index
If you call the first column of an rtree "index" then the error that comes back is "out of memory" with the corresponding error code. This will demonstrate the problem.

  create virtual table test using rtree(index, x1, x2, y1, y2);

Yes it is a keyword and yes it works when quoted. However the error message could be a lot better!

Thanks. Fixed now.
 
3969 doc closed 2009 Jul anonymous   2009 Jul   3 3 jump is a keyword?
It looks like jump is some sort of keyword in SQLite, but it's not documented. set name="jump" results in name being 0 instead of the string.
2009-Jul-14 22:45:58 by drh:
The SQL language uses single-quotes for string literals.
 
3968 code fixed 2009 Jul anonymous back 2009 Jul   4 3 ignored error
Functions sqlite3BtreeKeySize() and sqlite3BtreeDataSize() may return error code (for example from internally called btreeMoveto()). This error code is ignored in vdbe.
2009-Jul-14 14:43:43 by drh:
Do you have a test case where this causes an application-visible problem of some kind?


2009-Jul-14 16:27:24 by anonymous:
When I'v reported the bug the I only studied the code without running it. Ignoring errors usually is a bad idea and since there is no assert/comment i thought there might be a bug. But since you ask I'v done an experiment. I'v changed:

  rc = restoreCursorPosition(pCur); (in sqlite3BtreeKeySize())

to:

  rc = SQLITE_IOERR;
  printf("entered\n");

And results (code from "SQLite In 5 Minutes Or Less" - with error checking):

  C:\Documents and Settings\vic\Pulpit\sqlite>sqlite3.exe db "select count(*) from t"
  count(*) = 1

  C:\Documents and Settings\vic\Pulpit\sqlite>sqlite3.exe db "insert into t values(1)"
  entered

  C:\Documents and Settings\vic\Pulpit\sqlite>sqlite3.exe db "select count(*) from t"
  count(*) = 1

So insert failed and failure was not reported. Obviously the test isn't quite correct - it skips some code from restoreCursorPosition() that run before error can occure, but still checking error code can't make code less correct, and will definitely make it more readable.

 
3967 code closed 2009 Jul anonymous func 2009 Jul anonymous 3 2 sqlite3_mprintf
__int64 iID = 12; //VC++ 6.0

char *pTxt = "SQLite";

char *pQL = sqlite3_mprintf( "%d %q", iID, pTxt ); //"12 SQLite"

Result:

"12 (NULL)"

Use %lld for 64-bit integers.
 
3966 code closed 2009 Jul anonymous cli 2009 Oct   1 3 sqlite shell does not return fail status from fail during .import
The sqlite3 shell does not return a failure status on many meta commands. e.g. ".import x.txt nonexistent_table" does not have a fail status. In this case the faulty code from shell.c is:

    nByte = strlen30(zSql);
    rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
    sqlite3_free(zSql);
    if( rc ){
      fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
      nCol = 0;
      rc = 1;
    }else{
      nCol = sqlite3_column_count(pStmt);
    }
    sqlite3_finalize(pStmt);
    if( nCol==0 ) return 0;

Most likely that last line should be "return rc;". There are many other return 0 statements in this piece of code that should instead be returning 1.

2009-Oct-03 02:08:35 by anonymous:
Now http://www.sqlite.org/src/tktview/bd770b2c529cbf56cca2302d5a5cae3b6d3b37f0
 
3965 code fixed 2009 Jul drh back 2009 Jul   1 1 IN operator combined with zeroblob() yields wrong answer.
The following statement returns 0 (false):

    SELECT x'0000' IN (x'000000');

But this equivalent statement returns 1 (true):

    SELECT zeroblob(2) IN (zeroblob(3));

The correct answer is false.

 
3964 code closed 2009 Jul anonymous front 2009 Jul   1 1 Delete trigger error
CREATE TABLE _version_sessions(save_date real,key text,value text, _action TEXT, _rowid INTEGER);
CREATE TABLE sessions (
                  save_date real not null default (julianday('now')),
                  key text not null,
                  value text not null,
                  unique(key) on conflict replace
                );
CREATE TRIGGER _version_sessions_d AFTER DELETE ON sessions BEGIN
INSERT INTO _version_sessions (_action, _rowid) values ('D', old.rowid);
END;
CREATE TRIGGER _version_sessions_i AFTER INSERT ON sessions BEGIN
INSERT INTO _version_sessions SELECT *,'I' as _action, new.rowid as _rowid FROM sessions WHERE rowid=new.rowid;
END;

insert into sessions (key,value) values ('test key 1','test value 1');
insert into sessions (key,value) values ('test key 1','test value 1');
delete from sessions;

select * from _version_sessions;
2455026.10635193|test key 1|test value 1|I|1
2455026.10635215|test key 1|test value 1|I|2
|||D|2

Delete trigger for rowid=1 doesn't executed.
Your "unique(key) on conflict replace" clause means there is only one row in the table when the "delete" is run.


2009-Jul-22 15:28:36 by anonymous:
There is logical bug because database is modified by deleting the conflicted row but delete trigger doesn't fire. We can get equal database state by manual delete and insert and trigger will fire. So "insert" operation may produce different databases with same trigger actions. I think it's logical chaos.


2009-Jul-24 12:46:21 by anonymous:
Well this happened because you are using replace for an conflicting state in key, the second insert will make actually a replace. But if a replace is a DELETE after an INSERT this is a bug, but I don't known. It's weird is the rowid was changed!!!

insert into sessions (key,value) values ('test key 1','test value 1');

-- see this at this point SELECT rowid, * FROM sessions;

insert(replace) into sessions (key,value) values ('test key 1','test value 1'); -- see this at this point SELECT rowid, * FROM sessions;

delete from sessions;


2009-Jul-24 14:49:11 by anonymous:
Yes, ROWID is changed and delete trigger doesn't fire.
 
3963 code closed 2009 Jul anonymous ext 2009 Oct danielk1977 1 1 the icu tokenizer of fts3 does not work properly under some situation.
in fucntion icuNext(), line 234, it should be U16_NEXT instead of U8_NEXT. as pCsr->aChar store utf16 code instead of utf8 code. I find this problem when i try do some chinese keyword filting.
2009-Oct-20 06:17:12 by anonymous:
Please post to the mailing list about this including a code sample that shows the problem.
 
3962 code closed 2009 Jul anonymous back 2009 Jul   1 1 Can't ATTACH encrypted database
Using encryption implementation from ADO.NET Provider noticed that attaching encrypted database fails with SQLITE_NOTADB (after comparing header)

Analyzing code I noticed that vars: xCodec, xCodecSizeChng, xCodecFree and pCodec are empty for attached database (as a result header is not decrypted).

This is most likely repeatable with official encryption. I also added this issue to ADO.NET Provider forum just in case.

Here is the stack if this will help (using sqlite-amalgamation-3.6.16 with additional 14~15 lines at begining):

  lockBtree(BtShared * 0x002a12b8) line 38857
  sqlite3BtreeBeginTrans(Btree * 0x00a4bf60, int 0) line 39125 + 18 bytes
  lockBtreeWithRetry(Btree * 0x00a4bf60) line 38962 + 11 bytes
  btreeCursor(Btree * 0x00a4bf60, int 1, int 0, KeyInfo * 0x00000000, BtCursor * 0x002ad568) line 39941 + 9 bytes
  sqlite3BtreeCursor(Btree * 0x00a4bf60, int 1, int 0, KeyInfo * 0x00000000, BtCursor * 0x002ad568) line 39992 + 25 bytes
  sqlite3InitOne(sqlite3 * 0x00a46060, int 2, char * * 0x0012f1bc) + 427 bytes
  sqlite3Init(sqlite3 * 0x00a46060, char * * 0x0012f1bc) + 145 bytes
  attachFunc(sqlite3_context * 0x0012f358, int 3, Mem * * 0x002f71f0) line 63407 + 13 bytes
  sqlite3VdbeExec(Vdbe * 0x002a3b40) line 52154 + 32 bytes
  sqlite3Step(Vdbe * 0x002a3b40) line 49403 + 9 bytes
  sqlite3_step(sqlite3_stmt * 0x002a3b40) line 49464 + 9 bytes
  sqlite3_exec(sqlite3 * 0x00a46060, const char * 0x002d2920, int (void *, int, char * *, char * *)* 0x00403050 callback(void *, int, char * *, char * *), void * 0x0012f71c, char * * 0x0012f67c) + 254 bytes
  process_input(callback_data * 0x0012f71c, _iobuf * 0x00000000) line 2880 + 28 bytes
  main(int 4, char * * 0x00291f08) line 3293 + 14 bytes
Licensees of the official SQLite Encryption Extension do not have this problem.


2009-Jul-13 15:09:06 by anonymous:
Folks using the ADO.NET provider don't have this problem either (when using the ATTACH syntax correctly). To attach an encrypted database you need to provide the password in the KEY argument to the ATTACH statement.

Bear in mind that the ADO.NET provider's encryption is not cross-platform and uses an inferior method (RC4).


2009-Jul-13 17:57:02 by anonymous:
I Use binnary key.... wkich contains 0x00 at few places. Untill now all was working correctly. I'm comparing bechaviour of encryption coe and sqlite code version 3.6.14.2 which was working correctly (aka ATTACH DATABASE x AS y; without key to copy actual key).

As far as i reached with 3.6.16 there is a problem with pager in function attachFunc

      case SQLITE_NULL:
        /* No key specified.  Use the key from the main database */
        sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
        sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
        break;

sqlite3BtreePager(db->aDb[nDb].pBt)->pPager->pCodec is NULL at this point. Same thing on VACUUM, but VACUUM works fine.

As far as I remember this wasn't NULL in 3.6.14.2. I will verify that now.


2009-Jul-13 18:08:08 by anonymous:
in 3.6.14.2 both are filled correctly:

  sqlite3BtreePager(db->aDb[nDb].pBt)->pPager->xCodec
  sqlite3BtreePager(db->aDb[nDb].pBt)->pPager->pCodecArg

in 3.6.16 both are NULL:

  sqlite3BtreePager(db->aDb[nDb].pBt)->pPager->xCodec
  sqlite3BtreePager(db->aDb[nDb].pBt)->pPager->pCodec

Please verify that or at least provide way to attach database with binnary key.


2009-Jul-13 19:15:44 by anonymous:
For tkose interested (and authors of ADO.NET Provider) I found solution

Sorry SQLite guys... it was a mistake in crypto.c

In function sqlite3CodecAttach there is line:

  Pager *p = sqlite3BtreePager(db->aDb[nDb].pBt);

Leave it, but notice the p variable. Go to lines with:

  LPCRYPTBLOCK pBlock = (LPCRYPTBLOCK)sqlite3pager_get_codecarg(p);

  if (!pBlock) return SQLITE_OK;

We need actual p later, but in oryginal codes there was a diffrent value at this line in older codes. Replace first line from above with:

  LPCRYPTBLOCK pBlock = (LPCRYPTBLOCK)sqlite3pager_get_codecarg(sqlite3BtreePager(db->aDb[0].pBt));

and all works fine again :D

Sorry SQLite guys one more time.

 
3961 code closed 2009 Jul anonymous vfs 2009 Jul drh 1 1 database is locked error while using linux kernel above 2.6.28
My problem is get a "database is locked" error using lastest linux kernel (above 2.6.28) , while the code can run smoothly on linux 2.6.26.2 kernel(vmware pc686 host) and on 2.6.26.3 kernel(arm9 embed system).

The problem code is:

static bool OpenAndInitDb(char * pDbFileName)
{
 char * errMsg = NULL;

 sqlite3_enable_shared_cache(1);
 if (sqlite3_open(pDbFileName, &gJcDb) != SQLITE_OK)
 {
  fprintf(stderr, "!!!Open database error: %s\n", sqlite3_errmsg(gJcDb));
  return false;
 }
#if 1
 if (sqlite3_exec(gJcDb, "PRAGMA cache_size = 4000", NULL,  NULL, &errMsg) != SQLITE_OK)
 {
  fprintf(stderr, "!!!cache_size set error, %s\n", errMsg);
  sqlite3_free(errMsg);
 }
#endif
 sqlite3_exec(gJcDb, "PRAGMA cache_size", PragmaSetCallback, "PRAGMA cache_size", &errMsg);



#if 1
 if (SQLITE_OK != sqlite3_exec(gJcDb, "PRAGMA synchronous = FULL", NULL,  NULL, &errMsg)) //OFF FULL NORMAL
 {
  fprintf(stderr, "!!!synchronous set error, %s\n", errMsg);
  sqlite3_free(errMsg);
 }
#endif
 sqlite3_exec(gJcDb, "PRAGMA synchronous", PragmaSetCallback, "PRAGMA synchronous", &errMsg);

 return true;
}


static bool LoadTerminalFromDb(sqlite3 * pDb, Terminal * pTerminal)
{
   sqlite3_stmt * stmt = 0;
   if (sqlite3_prepare_v2(pDb, "select * from Terminal",  -1, &stmt, 0) != SQLITE_OK)
   {
       return false;
   }
   if (sqlite3_step(stmt) != SQLITE_ROW)
   {
        sqlite3_finalize(stmt);
        return false;
   }
   return true;
}
Even if I comment the the #if 0/1 #endif code block, still can't open a table and access the table data. I tried sqlite3.6.7 and sqlite3.6.16, the problem is same.
OP reports that he later discovered that his kernel was misconfigured.
 
3960 code closed 2009 Jul danielk1977 ext 2009 Jul danielk1977 1 1 crash in fts3 with (... MATCH '1-2.3')
This script causes a double-free:

    CREATE VIRTUAL TABLE t2 USING fts3(a, b);
    SELECT * FROM t2 WHERE t2 match '1-2.3';
This bug affects all search strings that use the legacy syntax that contain a regular token, followed by a negated token, followed by another regular token. For example:

  "one -two three"

If either the "one" or "three" terms are removed the search string is handled correctly.

Bug introduced in 3.6.8.

 
3959 code closed 2009 Jul anonymous func 2009 Jul   1 1 The time which is returned by datetime("now", "utc") is earlier.
The result of datetime("now", "utc" on timezone +0900.

sqlite> select datetime("now");
2009-07-10 02:00:11
sqlite> select datetime("now", "localtime");
2009-07-10 11:00:16
sqlite> select datetime("now", "utc");
2009-07-09 17:00:20
sqlite> select datetime("2009-07-10 11:00:16", "utc");
2009-07-10 02:00:16

datetime("2009-07-10 11:00:00", "localtime") is wrong too.

sqlite> select datetime("2009-07-10 11:00:00", "localtime");
2009-07-10 20:00:00

Please reread the documentation on the datetime() function and especially the documentation on the 'localtime' and 'utc' modifiers. Also note that string literals in SQL use a single quote.
 
3958 code closed 2009 Jul anonymous back 2009 Jul   4 3 Quering out the rowid works diferent
Execute: CREATE TABLE mytb (u_pkey INTEGER, s_description TEXT, CONSTRAINT 'mytb_idx_000' PRIMARY KEY (s_description, u_pkey));

SELECT rowid, rowid as rowid FROM mytb;

Now, CREATE TABLE mytb (u_pkey INTEGER, s_description TEXT, CONSTRAINT 'mytb_idx_000' PRIMARY KEY (u_pkey));

SELECT rowid, rowid as rowid FROM mytb;

On tables having an single field as primary key will return as the name of first rowid as you own name in this case 'u_pkey' and in a table with multiple fields as primary key booth fields will have the same name 'rowid'.

2009-Jul-09 22:57:59 by drh:
INTEGER PRIMARY KEY maps to ROWID in SQLite. Please see the documentation or ask for help on the SQLite mailing list. sqlite-users@sqlite.org.
 
3957 code closed 2009 Jul anonymous front 2009 Jul   4 4 CONSTRAINT PRIMARY KEY don't respect the given name
When I execute this:
CREATE TABLE mytb (u_pkey INTEGER, s_description TEXT, CONSTRAINT 'mytb_idx_000' PRIMARY KEY (s_description, u_pkey));
CREATE INDEX 'mytb_idx_001' ON mytb (s_description);

"PRAGMA table_info(mytb);" returns:
cid name type notnull dflt_value pk
0 u_pkey INTEGER 0 <null> 1
1 s_description TEXT 0 <null> 1




The both fields are primary key ('pk')!

And then: "PRAGMA index_list(mytb);" Returns:
seq name unique
0 mytb_idx_001 0
1 sqlite_autoindex_mytb_1 1




Reversed order!?!
And "SELECT * FROM sqlite_master WHERE tbl_name = 'mytb';" Returns:
type name tbl_name rootpage sql
table mytb mytb 16363 CREATE TABLE mytb (u_pkey INTEGER, s_description TEXT, CONSTRAINT 'mytb_idx_000' PRIMARY KEY (s_description, u_pkey))
index sqlite_autoindex_mytb_1 mytb 16364 <null>
index mytb_idx_001 mytb 16365 CREATE INDEX 'mytb_idx_001' ON mytb (s_description)






Note the primary key given name not used instead 'sqlite_autoindex_mytb_1' used !
There is no requirement that indices created by constraints be named after those constraints.
 
3956 code closed 2009 Jul anonymous front 2009 Jul   2 1 PRIMARY KEY index not created
When I execute this:
CREATE TABLE mytb (u_pkey INTEGER, s_description TEXT, CONSTRAINT 'mytb_idx_000' PRIMARY KEY (u_pkey));
CREATE INDEX 'mytb_idx_001' ON mytb (s_description);

After: "PRAGMA table_info(mytb);" returns:
cid name type notnull dflt_value pk
0 u_pkey INTEGER 0 <null> 1
1 s_description TEXT 0 <null> 0




The field 'u_pkey' is an primary key ('pk')!

And then: "PRAGMA index_list(mytb);" Returns:
seq name unique
0 mytb_idx_001 0





And "SELECT * FROM sqlite_master WHERE tbl_name = 'mytb';" Returns:
type name tbl_name rootpage sql
table mytb mytb 16363 CREATE TABLE mytb (u_pkey INTEGER, s_description TEXT, CONSTRAINT 'mytb_idx_000' PRIMARY KEY (u_pkey))
index mytb_idx_001 mytb 16364 CREATE INDEX 'mytb_idx_001' ON mytb (s_description)






Where's the Primary Key Index???
2009-Jul-09 22:55:27 by drh:
INTEGER PRIMARY KEY is a special case in SQLite. Please see the documentation or ask for help on the SQLite mailing list. sqlite-users@sqlite.org.


2009-Jul-10 16:35:19 by anonymous:
Ok, but how I can list all indexes created in a table? I can't use "PRAGMA index_list(...);"! I only can do this if I parser the 'sql' used to create the table by own!


2009-Jul-10 16:48:59 by anonymous:
You'll have to write some code. First get all the indices from pragma index_list(), then call pragma table_info() on the table. When there's only one primary key, and the primary key is of type integer, then that table has a rowid alias and you can create a fake entry in your own code to point to that index.
 
3955 build closed 2009 Jul anonymous   2009 Oct   3 2 Compilation errors on GCC4.4.0 (My case: MinGW32)
Compiling with '-Wall -Werror -Wextra' results in these errors:
sqlite3\sqlite3.c: In function 'winMutexInit':
sqlite3\sqlite3.c:15040: error: comparison between signed and unsigned integer expressions
sqlite3\sqlite3.c: In function 'winMutexEnd':
sqlite3\sqlite3.c:15058: error: comparison between signed and unsigned integer expressions
sqlite3\sqlite3.c: In function 'winRandomness':
sqlite3\sqlite3.c:28125: error: comparison between signed and unsigned integer expressions
sqlite3\sqlite3.c:28131: error: comparison between signed and unsigned integer expressions
sqlite3\sqlite3.c:28136: error: comparison between signed and unsigned integer expressions
sqlite3\sqlite3.c:28141: error: comparison between signed and unsigned integer expressions
sqlite3\sqlite3.c: At top level:
sqlite3\sqlite3.c:72969: error: missing initializer
sqlite3\sqlite3.c:72969: error: (near initialization for 'sqlite3Apis.aggregate_count')
sqlite3\sqlite3.c: In function 'sqliteDefaultBusyCallback':
sqlite3\sqlite3.c:91438: error: comparison between signed and unsigned integer expressions

Grtz, Steven
2009-Oct-01 07:31:47 by anonymous:
Err you told the compiler to treat all warnings as errors so it did. See http://www.sqlite.org/faq.html#q17

If you want to take this issue further then discuss it on the sqlite-users mailing list. However please ensure you read the many existing threads in the archive about compilation warnings first.

 
3954 code closed 2009 Jul anonymous   2009 Jul   1 1 SELECT date('now') returns previous days date after midnight
Open sqlite3 in a terminal. I have tested this in OSX 10.5.6. Set the system date to 23:59:30 or something close to midnight.

Type SELECT date('now'); and press enter. this will display todays date. Type this a few times while keeping an eye on the time - after midnight it still returns the previous date.

I played around with this a while and discovered that it increments the date at exactly 02:00 am to the current date... why 02:00 am and not 00:00:00 ??????

2009-Jul-08 21:53:25 by drh:
The date and time functions display universal coordinatated time (UTC or GMT) not your local time. Use the 'local' modifier to get local time.
 
3953 new closed 2009 Jul anonymous front 2009 Oct a.rottmann 3 5 create view from SQL with noname expressions generates unusable names
Hi,

I'm trying to use views with noname expressions and I have following issue: create view from SQL with noname expressions generates unusable names In case a new query will be applied using that property it will fail It will be nice to generate those names in a unique and known way to become usable.

e.g. "create view test as select (at.FeatId + bt.FeatId) * 22 from Counties as at, Hospitals as bt;" Using the API the name of the property show-up as "(at.FeatId + bt.FeatId) * 22" however I cannot use it in a new query statement. (table->pSelect->pEList->a[idx].zName - name table->pSelect->pEList->a[idx].pExpr->span.n - expression)

Thanks, Romi.

2009-Oct-02 08:40:46 by anonymous:
The same thing applies to regular selects.

  select (at.a+at.b)*3 from dummy as at, dummy as bt;

I don't exactly see how SQLite can guess what you really want that column named. To continue this issue further, please discuss it on the sqlite users mailing list.

 
3952 new closed 2009 Jul anonymous   2009 Jul   5 4 Feature request: sqlite3_create_function_v2()
It would be very convenient to have sqlite3_create_function_v2() - in the same vein as sqlite3_create_collation_v2(), it would take an extra destructor argument that gets called on the 5th argument when the function is deleted due to overloading the function or closing the db connection.

  int sqlite3_create_function_v2(
    sqlite3 *db,
    const char *zFunctionName,
    int nArg,
    int eTextRep,
    void *pApp,
    void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
    void (*xStep)(sqlite3_context*,int,sqlite3_value**),
    void (*xFinal)(sqlite3_context*),
    void (*xDestroy)(void*)
  );
2009-Jul-07 21:55:05 by anonymous:
I agree with you so strongly that I created ticket #3141 over a year ago asking the same thing :-)
 
3951 code closed 2009 Jul anonymous   2009 Oct   3 1 tkt3922.2 and tkt3922.3 tests fail
tkt3922.2 and tkt3922.3 tests fail during running `make test`. I use x86_64 architecture.

The output of `make test` contains:

tkt3922.1... Ok
tkt3922.2...
Expected: [-9.22337203685478e+18 real]
     Got: [-9223372036854775808 integer]
tkt3922.3...
Expected: [-9.22337203685478e+18 real]
     Got: [-9223372036854775808 integer]
tkt3922.4... Ok
tkt3922.5... Ok
tkt3922.6... Ok
2009-Oct-06 19:09:20 by anonymous:
These tests all pass for me with current SQLite code on Ubuntu 9.04 AMD64.
 
3950 code closed 2009 Jul anonymous vfs 2009 Oct   2 3 sqlite3_last_insert_rowid returns the wrong rowid
sqlite3_last_insert_rowid returns the wrong rowid when insert triggers are involved. Actually, it seems to be that sqlite3_last_insert_rowid does not return the rowid of the primarily inserted record but the rowid of the table that is used inside the trigger.

Furthermore, I could only verify this error together with FTS but not with other tables inside the insert trigger.

Here is some C sample code but the same error should occur when using SQL statements only (at the end you find also the output on a Mac OSX using sqlite3 3.6.16 with actual and expected results):

#include <stdio.h>
#include <stdlib.h>

#include "sqlite3.h"

void OnErrorExit(sqlite3* database, int rc, char* errorMessage)
{
  if (rc != SQLITE_OK)
  {
    if (errorMessage != NULL)
    {
      fprintf(stderr,"SQL error: %s\n",errorMessage);
      sqlite3_free(errorMessage);
    } /* if */
    sqlite3_close(database);
    exit(1);
  } /* if */
}

void ShowDatabaseContents(sqlite3* database)
{
  char* errorMessage;
  char** result;
  char* sqlStatement;

  int noOfColumns, noOfRows;
  int rc;

  sqlite3_int64 lastInsertedID;


  lastInsertedID = sqlite3_last_insert_rowid(database);
  printf("Last inserted ID: %d\n",(int) lastInsertedID);
  sqlStatement = "SELECT * FROM Simple;";
  rc = sqlite3_get_table(database,sqlStatement,&result,&noOfRows,&noOfColumns,&errorMessage);
  OnErrorExit(database,rc,errorMessage);

  printf("Number of rows: %d\n",noOfRows);
  printf("Number of columns: %d\n",noOfColumns);
  for (int i=0; i<noOfRows+1; ++i)
  {
    printf("Row: %2d ",i);
    for (int j=0; j<noOfColumns; ++j)
      printf("  Column[%d]: %s",j,result[i*noOfColumns+j]);
    printf("\n");
  } /* for */
}

int main (int argc, const char * argv[])
{
  char* errorMessage;
  char* sqlStatement;

  int rc;

  sqlite3* database;


 // prepare database
  rc = sqlite3_open(NULL,&database);
  if (rc != SQLITE_OK)
  {
    fprintf(stderr,"Can't open database in memory: %s\n",sqlite3_errmsg(database));
    exit(1);
  } /* if */
  sqlStatement = "CREATE TABLE Simple (ID integer primary key, Name text);";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "CREATE VIRTUAL TABLE SimpleFTS USING FTS3 (Name);";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "CREATE TRIGGER DeleteTrigger AFTER DELETE ON Simple FOR EACH ROW BEGIN DELETE FROM SimpleFTS WHERE (rowid=OLD.ID); END;";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "CREATE TRIGGER InsertTrigger AFTER INSERT ON Simple FOR EACH ROW BEGIN INSERT INTO SimpleFTS (rowid,Name) VALUES (NEW.ID,NEW.Name); END;";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
 // insert and delete items
  sqlStatement = "INSERT INTO Simple (Name) VALUES('one');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "INSERT INTO Simple (Name) VALUES('two');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);
  sqlStatement = "DELETE FROM Simple WHERE (ID = 1);";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);
  sqlStatement = "INSERT INTO Simple (Name) VALUES('one');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);
  sqlStatement = "INSERT INTO Simple (Name) VALUES('one');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);

  sqlite3_close(database);

  printf("Done!\n");
  return 0;
}
This is the output after the last insert:

Last inserted ID: 5
Number of rows: 3
Number of columns: 2
Row:  0   Column[0]: ID  Column[1]: Name
Row:  1   Column[0]: 2  Column[1]: two
Row:  2   Column[0]: 3  Column[1]: one
Row:  3   Column[0]: 4  Column[1]: one
Actually, I would expect this:

Last inserted ID: 4
Number of rows: 3
Number of columns: 2
Row:  0   Column[0]: ID  Column[1]: Name
Row:  1   Column[0]: 2  Column[1]: two
Row:  2   Column[0]: 3  Column[1]: one
Row:  3   Column[0]: 4  Column[1]: one
2009-Jul-05 07:29:55 by anonymous:
Sorry, the code has been mixed up a bit:

#include <stdio.h>

#include <stdlib.h>

#include "sqlite3.h"

  void OnErrorExit(sqlite3* database, int rc, char* errorMessage)
  {
    if (rc != SQLITE_OK)
    {
      if (errorMessage != NULL)
      {
        fprintf(stderr,"SQL error: %s\n",errorMessage);
        sqlite3_free(errorMessage);
      }
      sqlite3_close(database);
      exit(1);
    }
  }

  void ShowDatabaseContents(sqlite3* database)
  {
    char* errorMessage;
    char** result;
    char* sqlStatement;

    int noOfColumns, noOfRows;
    int rc;

    sqlite3_int64 lastInsertedID;

    lastInsertedID = sqlite3_last_insert_rowid(database);
    printf("Last inserted ID: %d\n",(int) lastInsertedID);
    sqlStatement = "SELECT * FROM Simple;";
    rc = sqlite3_get_table(database,sqlStatement,&result,&noOfRows,&noOfColumns,&errorMessage);
    OnErrorExit(database,rc,errorMessage);

    printf("Number of rows: %d\n",noOfRows);
    printf("Number of columns: %d\n",noOfColumns);
    for (int i=0; i<noOfRows+1; ++i)
    {
      printf("Row: %2d ",i);
      for (int j=0; j<noOfColumns; ++j)
        printf("  Column[%d]: %s",j,result[i*noOfColumns+j]);
      printf("\n");
    }
  }

int main (int argc, const char * argv[]) { char* errorMessage; char* sqlStatement;

  int rc;

  sqlite3* database;

  rc = sqlite3_open(NULL,&database);
  if (rc != SQLITE_OK)
  {
    fprintf(stderr,"Can't open database in memory: %s\n",sqlite3_errmsg(database));
    exit(1);
  } /* if */
  sqlStatement = "CREATE TABLE Simple (ID integer primary key, Name text);";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "CREATE VIRTUAL TABLE SimpleFTS USING FTS3 (Name);";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "CREATE TRIGGER DeleteTrigger AFTER DELETE ON Simple FOR EACH ROW BEGIN DELETE FROM SimpleFTS WHERE (rowid=OLD.ID); END;";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "CREATE TRIGGER InsertTrigger AFTER INSERT ON Simple FOR EACH ROW BEGIN INSERT INTO SimpleFTS (rowid,Name) VALUES (NEW.ID,NEW.Name); END;";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
 // insert and delete items
  sqlStatement = "INSERT INTO Simple (Name) VALUES('one');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  sqlStatement = "INSERT INTO Simple (Name) VALUES('two');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);
  sqlStatement = "DELETE FROM Simple WHERE (ID = 1);";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);
  sqlStatement = "INSERT INTO Simple (Name) VALUES('one');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);
  sqlStatement = "INSERT INTO Simple (Name) VALUES('one');";
  rc = sqlite3_exec(database,sqlStatement,NULL,NULL,&errorMessage);
  OnErrorExit(database,rc,errorMessage);
  ShowDatabaseContents(database);

  sqlite3_close(database);

  printf("Done!\n");
  return 0;
}

This is the output after the last insert:

Last inserted ID: 5 Number of rows: 3 Number of columns: 2 Row: 0 Column[0]: ID Column[1]: Name Row: 1 Column[0]: 2 Column[1]: two Row: 2 Column[0]: 3 Column[1]: one Row: 3 Column[0]: 4 Column[1]: one

Actually, I would expect this:

Last inserted ID: 4 Number of rows: 3 Number of columns: 2 Row: 0 Column[0]: ID Column[1]: Name Row: 1 Column[0]: 2 Column[1]: two Row: 2 Column[0]: 3 Column[1]: one Row: 3 Column[0]: 4 Column[1]: one


2009-Oct-03 02:21:43 by anonymous:
FTS does other things behind the scenes which is probably confusing the issue. Please can you try this with the latest SQLite which also has some trigger related changes (eg recursive triggers). We need to distinguish between this being a bug in general or only with FTS.

Continue discussion on the sqlite-users mailing list.

 
3949 code closed 2009 Jul anonymous   2009 Jul   1 1 About COMMIT and ROLLBACK
Here is my source code:

SELECT ...;

while (...) {

    FETCH ...;

    r = do_some_other_SQLs();

    if ( r == 0 )

        COMMIT;   // it's OK

    else

        ROLLBACK; // ERROR: cannot rollback transaction - SQL statements in progress

}

I can COMMIT the work but can't ROLLBACK it, why?

2009-Jul-04 15:51:59 by drh:
Please ask support questions on the SQLite mailing list: sqlite-users@sqlite.org. Tickets should be used for reporting bugs.
 
3948 new closed 2009 Jul anonymous func 2009 Jul   5 2 Add contextRealloc function similar to contextMalloc
/*
** Reallocate nByte bytes of space using sqlite3_realloc(). If the
** allocation fails, call sqlite3_result_error_nomem() to notify
** the database handle that malloc() has failed.
*/
void *contextRealloc(sqlite3_context *context, void* pPrior, i64 nByte){
  char *z = sqlite3_realloc(pPrior, (int)nByte);
  if( !z && nByte>0 ){
    sqlite3_result_error_nomem(context);
  }
  return z;
}

2009-Jul-03 17:47:09 by danielk1977:
Why?


2009-Jul-04 10:50:39 by anonymous:
When does exists useful wrapper for sqlite3_malloc why does not exists wrapper for sqlite3_realloc? Now SQLite context* interface is not symmetrical.


2009-Jul-04 15:54:51 by drh:
contextMalloc() is "static" procedure that is used internally only. It is not an interface. If contextRealloc() were useful internally, we would add that too. But it is not useful. If we added it, it would simply be unreachable code. Hence there is no reason to add it.
 
3947 code fixed 2009 Jul anonymous front 2009 Jul   1 1 Bug in triggers
This works:

cn1.Execute "CREATE TEMP TRIGGER IF NOT EXISTS table1s_pack_it BEFORE INSERT ON main.table1 BEGIN DELETE FROM table1 WHERE mytext=NEW.mytext;END;"


This does not:

cn1.Execute "CREATE TEMP TRIGGER IF NOT EXISTS table1s_pack_it BEFORE INSERT ON main.table1 BEGIN DELETE FROM main.table1 WHERE mytext=NEW.mytext;END;"


It gives me an error saying "Cannot compile SQL-Statement: near ".": syntax error"

I am afraid that the trigger may also delete recordsets from the attached database. I don't know how the trigger knows that it should delete from "main.table1" only and not from <attacheddatabase>.table1.

 
3946 code closed 2009 Jul anonymous back 2009 Oct   3 4 Error return from VFS xUnlock ignored
My testing has uncovered a case where SQLite used to report an error that was initially returned by a VFS xUnlock failing, but no longer reports an error. The relevant parts of the stack trace are shown below.

Debugging shows how the issue arises. Frame 5 (my code) returns the error. Frame 8 (pager_unlock) stashes the error code in pPager->rc. Various intermediate frames return void. Frame 15 (sqlite3InitOne) is at the initone_error_out location but rc is zero so this routine as a whole returns SQLITE_OK to all the callers up the rest of the chain which means sqlite3_prepare returns SQLITE_OK instead of the error it used to.

To a certain extent xUnlock failing is not something the code can do much about. It is like free() failing - what exactly would you do next? However code has changed in SQLite to swallow the error when it didn't use to. (The change may have been in the 3.6.14/15 timeframe.)

#5  0x00007fb351261eb1 in apswvfsfile_xUnlock (file=0x1931cf8, flag=0) at src/vfs.c:1851
#6  0x00007fb35110f716 in sqlite3OsUnlock (id=0x1931cf8, lockType=0) at sqlite3/sqlite3.c:11874
#7  0x00007fb35112d95c in osUnlock (pFd=0x1931cf8, eLock=0) at sqlite3/sqlite3.c:30970
#8  0x00007fb35112f5f4 in pager_unlock (pPager=0x1931bc8) at sqlite3/sqlite3.c:31614
#9  0x00007fb35112f98b in pagerUnlockAndRollback (pPager=0x1931bc8) at sqlite3/sqlite3.c:31705
#10 0x00007fb351136f99 in pagerUnlockIfUnused (pPager=0x1931bc8) at sqlite3/sqlite3.c:34248
#11 0x00007fb3511379b6 in sqlite3PagerUnref (pPg=0x1805398) at sqlite3/sqlite3.c:34460
#12 0x00007fb351143b8a in releasePage (pPage=0x18053e0) at sqlite3/sqlite3.c:38247
#13 0x00007fb351147316 in unlockBtreeIfUnused (pBt=0x17b6e58) at sqlite3/sqlite3.c:38975
#14 0x00007fb35114ba39 in sqlite3BtreeCloseCursor (pCur=0x193fe78) at sqlite3/sqlite3.c:40046
#15 0x00007fb3511e0a5f in sqlite3InitOne (db=0x1812a28, iDb=0, pzErrMsg=0x195e0c8) at sqlite3/sqlite3.c:74877
#16 0x00007fb3511e0caa in sqlite3Init (db=0x1812a28, pzErrMsg=0x195e0c8) at sqlite3/sqlite3.c:74907
#17 0x00007fb3511e0fdd in sqlite3ReadSchema (pParse=0x195e0b8) at sqlite3/sqlite3.c:74944
#18 0x00007fb3511b418c in sqlite3LocateTable (pParse=0x195e0b8, isView=0, zName=0x193fcc8 "dummy1", zDbase=0x0) at sqlite3/sqlite3.c:64273
#19 0x00007fb3511f0c01 in selectExpander (pWalker=0x7fff59a531c0, p=0x1829128) at sqlite3/sqlite3.c:78423
#20 0x00007fb351196b08 in sqlite3WalkSelect (pWalker=0x7fff59a531c0, p=0x1829128) at sqlite3/sqlite3.c:57444
#21 0x00007fb3511f1f4c in sqlite3SelectExpand (pParse=0x195e0b8, pSelect=0x1829128) at sqlite3/sqlite3.c:78619
#22 0x00007fb3511f235f in sqlite3SelectPrep (pParse=0x195e0b8, p=0x1829128, pOuterNC=0x0) at sqlite3/sqlite3.c:78702
#23 0x00007fb3511f3203 in sqlite3Select (pParse=0x195e0b8, p=0x1829128, pDest=0x7fff59a534c0) at sqlite3/sqlite3.c:78914
#24 0x00007fb351215a2a in yy_reduce (yypParser=0x194fb08, yyruleno=111) at sqlite3/sqlite3.c:88455
#25 0x00007fb35121b513 in sqlite3Parser (yyp=0x194fb08, yymajor=1, yyminor={z = 0x19c6422 "dummy1", n = 6}, pParse=0x195e0b8) at sqlite3/sqlite3.c:89371
#26 0x00007fb35121d495 in sqlite3RunParser (pParse=0x195e0b8, zSql=0x19c6414 "select * from dummy1", pzErrMsg=0x7fff59a53748) at sqlite3/sqlite3.c:90214
#27 0x00007fb3511e1bfd in sqlite3Prepare (db=0x1812a28, zSql=0x19c6414 "select * from dummy1", nBytes=21, saveSqlFlag=0, ppStmt=0x18b78b0,
    pzTail=0x7fff59a53880) at sqlite3/sqlite3.c:7518
#28 0x00007fb3511e241c in sqlite3LockAndPrepare (db=0x1812a28, zSql=0x19c6414 "select * from dummy1", nBytes=21, saveSqlFlag=0, ppStmt=0x18b78b0,
    pzTail=0x7fff59a53880) at sqlite3/sqlite3.c:75208
#29 0x00007fb3511e2928 in sqlite3_prepare (db=0x1812a28, zSql=0x19c6414 "select * from dummy1", nBytes=21, ppStmt=0x18b78b0, pzTail=0x7fff59a53880)
    at sqlite3/sqlite3.c:75271
2009-Oct-08 06:46:34 by anonymous:
Now http://www.sqlite.org/src/tktview/d8fe6cef65f48e06ac806f92fc54486eee841f06
 
3945 code closed 2009 Jul anonymous   2009 Jul   1 1 select error

修改用户密码 count:9
修改本用户密码 count:25
1\select * from table where info LIKE '%用户密码%' escape '[' ; count:34
2\select * from table where info LIKE '%修改%' escape '[' ;count:19 error
3\select * from table where info LIKE '%修改用户密码%' escape '[' ;count:9
2 result is error!
2009-Jul-03 07:05:44 by anonymous:
You should use the ICU extension if you need locale aware like. This issue is mentioned in the FAQ at http://www.sqlite.org/faq.html#q18
 
3944 code closed 2009 Jul anonymous front 2009 Jul danielk1977 1 3 Access violation in sqlite3AuthRead
I updated from 3.6.13, to 3.6.16 and got an access violation in 'sqlite3AuthRead(...)', specifically in line 63884 of sqlite3.c, here :

  zCol = pTab->aCol[pExpr->iColumn].zName;

When compiled with SQLITE_DEBUG, the assertion in line 63867 fails :

  for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){

I am inserting into a table with BEFORE triggers. The problem appears perfectly repeatable in my program, but if I run the same statements in a test program, it doesn't fail.

The sequence of statements executed is :

"CREATE TABLE IF NOT EXISTS ad_tree ( pre INTEGER NOT NULL, size INTEGER NOT NULL DEFAULT 0, level INTEGER NOT NULL, invisibility INTEGER NOT NULL, closed INTEGER NOT NULL DEFAULT 1, key INTEGER PRIMARY KEY AUTOINCREMENT );"

"CREATE TRIGGER IF NOT EXISTS insert_into_ad_tree BEFORE INSERT ON ad_tree FOR EACH ROW" "BEGIN" "UPDATE ad_tree SET pre = pre + 1 WHERE pre >= NEW.pre ;" "UPDATE ad_tree SET size = size + 1 WHERE pre < NEW.pre AND NEW.pre <= pre+size+1 AND level < NEW.level ;" "END;"

"CREATE TRIGGER IF NOT EXISTS delete_from_ad_tree AFTER DELETE ON ad_tree FOR EACH ROW" "BEGIN" "DELETE FROM ad_tree WHERE pre > OLD.pre AND pre <= OLD.pre + OLD.size ;" "UPDATE ad_tree SET size = size - OLD.size - 1 WHERE pre < OLD.pre AND OLD.pre <= pre+size ;" "UPDATE ad_tree SET pre = pre - OLD.size - 1 WHERE pre > OLD.pre ;" "END;"

"INSERT OR IGNORE INTO ad_tree ( pre, size, level, invisibility, closed, key ) VALUES(0,0,0,0,0,0)"

The access violation occurs when executing the INSERT statement. Looking at the stack backtrace, sqlite appears to be executing the first trigger statement when it fails. There are other queries that are executed before, but they refer to other tables, and even when I duplicate the full SQL statement history that is executed, I cannot get a test program to fail.

Looking at the different versions of sqlite, I found that this code ( 'sqlite3AuthRead(...)' function ) was changed in version 3.6.14, and sure enough, if I use that version my program also crashes. If I revert to 3.6.13, my program works without problems.

2009-Jul-02 17:35:59 by danielk1977:
The following hits an assert() if the database connection has an authorizer registered.

    CREATE TABLE t1 ( x );
    CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
      UPDATE t1 SET x = 1 WHERE NEW.x = 0;
    END;
    INSERT INTO t1 (x) values(0);
    SELECT * FROM t1;
 
3943 build closed 2009 Jul anonymous build 2009 Oct   4 4 Problems when linking a not-threaded program to a shared sqlite
I wonder if [4550] is the full solution to the problem of #2786: AFAIK (and, regarding to threading issues, that's not much knowledge) -lpthreads is needed not only for static linking but also for dynamic linking, since sqlite (when compiled to support threads) is thread-safe but not thread-aware (as discussed for example in this thread); so shouldn't -lpthreads be in the Libs line of the .pc file as opposed of the Libs.private line?
2009-Jul-02 10:13:28 by anonymous:
I think pkg-config should output "-pthread" (not "-lpthread"). This causes (for gcc at least) two things: -D_REENTRANT and -lpthread. And some headers (e.g. boost) might actually check for that define.


2009-Oct-04 20:41:46 by anonymous:
pkgconfig doesn't know what compiler is being used (-pthread is not a generic flag that works with all compilers) so that route can't really be taken.

If you have specific examples (ie "this flag XXX must be used when compiling with SQLite shipped XXX") then please post to the sqlite-users mailing where we can hammer down what changes must be made. (ie real facts not speculation please :-)

Closing as this bug tracker is no longer used.

 
3942 code fixed 2009 Jul danielk1977 back 2009 Jul danielk1977 1 1 Commiting transaction with active selects drops all shared-cache locks
If a transaction is committed while there are active SELECT statements, the database is not unlocked at the file-system level. However, all shared-cache table locks are dropped, including the read-locks used by the active SELECT statements. This is technically incorrect.
 
3941 code closed 2009 Jul anonymous func 2009 Jul drh 4 1 incorrect result on group_concat() function
sorry
 
3940 code closed 2009 Jul anonymous build 2009 Jul   1 1 3.6.16 won't link if SQLITE_OMIT_AUTOVACUUM is defined.
if you have SQLITE_OMIT_AUTOVACUUM defined, you can't link the library because

#ifndef SQLITE_OMIT_AUTOVACUUM
/*
** If the cell pCell, part of page pPage contains a pointer
** to an overflow page, insert an entry into the pointer-map
** for the overflow page.
*/
static int ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell){
  CellInfo info;
  assert( pCell!=0 );
  sqlite3BtreeParseCellPtr(pPage, pCell, &info);
  assert( (info.nData+(pPage->intKey?0:info.nKey))==info.nPayload );
  if( info.iOverflow ){
    Pgno ovfl = get4byte(&pCell[info.iOverflow]);
    return ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno);
  }
  return SQLITE_OK;
}
#endif
Is commented out but, ptrmapPutOvflPtr is still referenced in the code several places where

else if( ISAUTOVACUUM )

Is used.

 
3939 code closed 2009 Jul anonymous   2009 Jul   3 3 Dropping a table with open statements fails
Assume you have 2 tables, and a prepared statement loops over all records of the first one, just printing values. Then, if for some reason I want to drop the other table, a locked error is returned.

This might seem a stupid example, but I have a more complex program where I want to regenerate a table inside a statement-loop, and that is impossible.

There are workarounds to this problem, but it will cost me a lot of time to implement and I just figure this should be possible, as long as no schema changes occur on tables that are part of open statements.

(I will also submit a small sample program illustrating the problem)

2009-Jul-01 08:29:03 by anonymous:
Compile like this:

gcc -I/opt/sqlite-3.6.16/include test.c -o test -L/opt/sqlite-3.6.16/lib -lsqlite3 -lpthread -ldl (or whereever SQLite is installed)

Source:

  #include <sqlite3.h>
#include <assert.h>
#include <stdio.h>

  #define CHECK(X) (assert(X == SQLITE_OK))

  int main (int argc, char ** argv)
{
   sqlite3 * hDB;
   int ret = sqlite3_open(":memory:", &hDB);
   CHECK(ret);

   ret = sqlite3_exec(hDB, "CREATE TABLE t1 (col1 INTEGER);", NULL, NULL, NULL);
   CHECK(ret);
   ret = sqlite3_exec(hDB, "CREATE TABLE t2 (col2 INTEGER);", NULL, NULL, NULL);
   CHECK(ret);
   ret = sqlite3_exec(hDB, "INSERT INTO t1 VALUES (1);", NULL, NULL, NULL);
   CHECK(ret);

   sqlite3_stmt * hSQL_stmt;
   ret = sqlite3_prepare_v2(hDB, "SELECT * FROM t1;", -1, &hSQL_stmt, NULL);
   CHECK(ret);
   ret = sqlite3_step(hSQL_stmt);
   assert(ret == SQLITE_ROW);

   char * err_msg;
   ret = sqlite3_exec(hDB, "DROP TABLE IF EXISTS t2;", NULL, NULL, &err_msg);
   if ( ret != SQLITE_OK )
   {
      printf("SQLite error: %s\n", err_msg);
      return 1;
   }

   ret = sqlite3_finalize(hSQL_stmt);
   CHECK(ret);
   ret = sqlite3_close(hDB);
   CHECK(ret);
   return 0;
}


2009-Jul-01 10:48:24 by danielk1977:
Unfortunately it is this way by design. When using auto-vacuum databases, dropping an existing table can cause another table to be moved to a different location within the database. If there were open cursors traversing that table when it is moved, sqlite would crash. So dropping a table is not allowed while there are any database cursors open on the database. The restriction is applied to non-auto-vacuum databases as well, to prevent application visible incompatibilities between modes.

You can delete the contents of your second table while traversing the first of course. In SQLite, "DELETE FROM tbl" is just as efficient as "DROP TABLE tbl".

Or maybe use a temp table in some way. You can create and drop temp tables while traversing the main database.

 
3938 code closed 2009 Jun anonymous test 2009 Oct   3 3 v 3..6.16 do not pass unit tests: 'make test'
The last 3.6.16 release do not seem passing thru veryquick unit test issued by command 'make test'.
Following tests failed:

  rollback-2.3...
  Expected: [0]
       Got: [1]
  ...
  tkt3457-1.4...
  Expected: [1 {unable to open database file}]
       Got: [0 {1 2 3 4 5 6}]

Both are about journaling file. I have used regular source tar-ball and compiled either using GNU build system or Makefile.linux-gcc (test failed in both cases in the same way). I have repeated tests against 3.6.15 release, and all passed correctly, so I assume that something got broken in last release.

Tests was done on Linux CentOS 5.3 with all available updates.

Best Regards,
Grzegorz W.

2009-Jul-01 00:40:38 by drh:
The SQLite tests need to be run as a normal user, not as root. Are you running these tests as root?


2009-Jul-02 19:23:44 by anonymous:
No, I have run test as normal user. There must be someting in last version because I have run tests with 3.6.15 in exactly the same way and they passed.


2009-Oct-06 18:05:03 by anonymous:
Please post about this on the sqlite-users mailing list. The tests do work otherwise this version would not be released so it is likely something specific to your machine. Closing as this bug tracker is no longer used.
 
3937 code closed 2009 Jun anonymous vfs 2009 Oct   2 3 Cygwin 1.7 compatibility patch
Cygwin 1.7 is due to be released from beta status soon, so I am updating the Cygwin SQLite package to build against it. (I'm the current package maintainer.) This is a major upgrade to Cygwin, one of those rare "breaks everything for the better" sorts of releases. One of those breaks affects the SQLite, causing it to no longer build without warnings on Cygwin 1.7.

While fixing this, I found a number of other minor problems. The resulting patch (http://etr-usa.com/cygwin/sqlite-winfullpathname.patch) is therefore a bit of a mess, so I'll describe what it does and why:

  1. The warning is in winFullPathname(), which contains implementations for several different Win32 flavors. One is Cygwin-specific and uses a private Cygwin API, deprecated in Cygwin 1.7. (This is where the compiler warning comes from.) There's a replacement for this API, but these APIs are only meant for use by Cygwin-specific tools, not things like SQLite. While looking at the code, I saw the nearby Win32 native implementation. I don't use SQLite myself -- I just volunteered to maintain the Cygwin package, since no one else seemed likely to -- so I didn't test it, but it seems to me that the mainline Win32 implementation should work just fine. (Cygwin programs can use both POSIX and Win32 APIs.) My patch removes the Cygwin-specific code, so the compiler takes the main Win32 #ifdef path.

  2. Removed conditional #include <sys/cygwin.h>, now that we're no longer calling private Cygwin APIs.

  3. Most of the isNT() branch duplicates an abstraction already present in the Win32 API that papers over the ANSI vs. wide character differences in the NT vs. 9x APIs. My patch leaves only a single assignment that changes based on the return value of isNT(). (This particular change is the one most responsible for the patch's ugliness, since it changes the indent level of many lines.) In short, this change calls the platform-independent GetFullPathName() rather than GetFullPathNameW() or GetFullPathNameA(), and uses the platform-neutral TCHAR family typedefs rather than the old pre-NT ones.

  4. With the Cygwin-specific path gone and most of the other Win32 differences accounted for in other ways, the several #ifdefs become a simple #ifdef/#else clause pair.

  5. An unrelated change I couldn't help making: the function is passed a buffer (zFull) and its size (nFull), but in calls to sqlite3_snprintf(), the code uses a different size value (pVfs->mxPathname). I don't know that this is a risk of a buffer overrun, but it's certainly messy and confusing.

Instead of applying the patch, you can just:

  1. Remove the conditional sys/cygwin.h.

  2. Replace winFullPathname() with this fully-patched version:

http://etr-usa.com/cygwin/sqlite-winfullpathname.c

2009-Aug-10 13:27:54 by anonymous:
getTempname on os_win.c some times works wrong because of the Cygwin I maked this patch!

static int getTempname(int nBuf, char zBuf){ static char zChars[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; size_t i, j; char zTempPath[MAX_PATH+1]; if( sqlite3_temp_directory ){ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); }else if( isNT() ){ char *zMulti; WCHAR zWidePath[MAX_PATH]; GetTempPathW(MAX_PATH-30, zWidePath); zMulti = unicodeToUtf8(zWidePath); if( zMulti ){ char zCygwindrive = strstr(zMulti, "\\cygdrive\\");

      if (zCygwindrive != NULL) {
          zCygwindrive += 9; //strlen("\\cygdrive");
          zCygwindrive[0] = zCygwindrive[1];
          zCygwindrive[1] = ':';

          sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zCygwindrive);
      } else {
          sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
      }
      free(zMulti);
    }else{
      return SQLITE_NOMEM;
    }
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
** Since the ASCII version of these Windows API do not exist for WINCE,
** it's important to not reference them for WINCE builds.
*/
#if SQLITE_OS_WINCE==0
  }else{
    char *zUtf8;
    char zMbcsPath[MAX_PATH];
    GetTempPathA(MAX_PATH-30, zMbcsPath);
    zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
    if( zUtf8 ){
      char* zCygwindrive = strstr(zUtf8, "\\cygdrive\\");

      if (zCygwindrive != NULL) {
        zCygwindrive += 9; //strlen("\\cygdrive");
        zCygwindrive[0] = zCygwindrive[1];
        zCygwindrive[1] = ':';

        sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zCygwindrive);
      } else {
        sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
      }
      free(zUtf8);
    }else{
      return SQLITE_NOMEM;
    }
#endif
  }


2009-Oct-01 07:27:37 by anonymous:
Now http://www.sqlite.org/src/tktview/2fd50fa6656950e19826089cd1abf19c35c26409
 
3936 warn closed 2009 Jun anonymous build 2009 Oct   4 3 Newer libtool needs LT_INIT
Newer versions of libtoolize give this warning:

libtoolize: `AC_PROG_RANLIB' is rendered obsolete by `LT_INIT'

You don't see this if you use the provided autotools build system, but some packaging systems do things like autoreconf or "autoconf ; automake ; libtool" before building the package, to ensure the package is built using the platform versions.

I see this with libtool 2.2.7, but don't know how far back the change in directives goes.

2009-Oct-04 20:44:18 by anonymous:
The whole configure stuff is a bit of a pain to deal with especially since SQLite has to support a wide variety of ages of systems. If you are prepared to maintain and test it then please introduce yourself on the mailing list where we will coordinate further actions.

Closing as this bug tracker is no longer used.

 
3935 code closed 2009 Jun anonymous front 2009 Jul   2 3 Error in table alias since 3.6.15
The following select used to work with all latest SQLite versions until 3.6.15. I'll try to attach the database.

  SELECT
    CategoryName, ProductName,
    Sum(Round(Ord_OrdDet.UnitPrice * Quantity * (1 - Discount), 2)) AS ProductSales
  FROM
      (Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID) Cat_Prod
    INNER JOIN
      (Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) Ord_OrdDet
    ON Cat_Prod.ProductID = Ord_OrdDet.ProductID
  WHERE Ord_OrdDet.ShippedDate BETWEEN '1995-01-01 00:00:00' AND '1995-12-31 00:00:00'
  GROUP BY Cat_Prod.CategoryName, Cat_Prod.ProductName;
2009-Jun-30 05:16:00 by danielk1977:
Please attach the database schema.


2009-Jul-01 06:04:08 by danielk1977:
Simplification:

  CREATE TABLE t1(a, b);
  CREATE TABLE t2(c, d);

  SELECT b FROM (t1 INNER JOIN t2 ON a=c) AS j1;      -- Succeeds
  SELECT t1.b FROM (t1 INNER JOIN t2 ON a=c) AS j1;   -- Succeeds
  SELECT j1.b FROM (t1 INNER JOIN t2 ON a=c) AS j1;   -- Fails
 
3934 xplatform closed 2009 Jun anonymous   2009 Jul   1 1 shocking difference between filesystem
Article unveiled huge difference in performance among different filesystems:

With the SQLite test profile to measure how long it takes to perform 12,500 insertions using this lightweight SQL database, EXT3 and NILFS2 were the clear winner. It took 20 seconds for this database test to complete under EXT3, 34 seconds under NILFS2, but 870 seconds for EXT4! XFS was at 1312 seconds and Btrfs was at 1472 seconds!

http://www.phoronix.com/scan.php?page=article&item=ext4_btrfs_nilfs2&num=2

2009-Jun-29 16:43:58 by anonymous:
At 20 seconds, it's obvious you weren't inserting inside a transaction, which invalidates the test entirely.


2009-Jun-29 20:07:13 by anonymous:
It doesn't invalidate the test. The test shows the performance of data flush on the file system. Nevertheless, why is this a bug report? This looks like something that belongs to mailing list.


2009-Jun-29 20:10:20 by anonymous:
It invalidates the test because it no longer is about SQLite performance, and instead only tests the filesystem's ability to flush caches and create/delete temp files during transaction setup and teardown.

And I agree this venue is an inappropriate place to discuss the findings.


2009-Jun-29 21:07:24 by anonymous:
Maybe the submiter wanted just to indicate the issue. Not everybody uses the mailing list.


2009-Jun-29 22:37:55 by anonymous:
To a first approximation their testing is crap. I used a test derived from one included in SQLite. I can't attach it here as it is too large. Grab a copy of http://code.google.com/p/apsw/source/browse/apsw/trunk/tools/speedtest.py (choose "raw file" on the right) and then run:

  python speedtest.py --dump-sql=test.sql

Edit the beginning of the test.sql file so that the journal pragma is commented out. Run the resulting test.sql using the SQLite shell where the first parameter points to a nonexistent file on the filesystem under test.

  sqlite /path/to/test.db < test.sql > test.out

I ran using ext3, ext4 and xfs all using the same partition (destroyed and recreated each time using GNU parted). The test.out file was identical each time indicating test ran correctly. Running current Ubuntu Jaunty 64 bit with all updates:

ext3

  real	0m29.121s
  user	0m17.649s
  sys	0m1.552s

ext4

  real	0m23.258s
  user	0m15.577s
  sys	0m1.104s

xfs

  real	0m26.903s
  user	0m16.809s
  sys	0m1.208s

As you can see they are all in the same ballpark. Phoronix need to provide their test SQL that can be run by the SQLite shell to show that this is even an issue with SQLite or the filesystems and not their code.

 
3933 code fixed 2009 Jun anonymous cli 2009 Jul   1 1 pthread_create 's return value is not determine.
in function testThreadLockingBehavior, pthread_create function was not determine the return value, and if it failed, the pthread_join function will make who application crashed.

I have add determine expression, it tests passed.

 
3932 doc closed 2009 Jun anonymous front 2009 Jun   4 3 Accent grave (`) does not appear supported for table and column names
I believe that standard SQL (or perhaps only MySQL) allows the accent grave character (`) to be used for quoting table and column names.

An example of why this is needed is that such names may contain embedded spaces. Without quotation, the SQL parser would not be able to tell where such a name stops and SQL keywords resume.

Yes, I have already found out that the ordinary string quotation mark (apostrophe (')) is used in SQLite for this purpose. But I found out by accident. None of the documentation I could locate easily on this website using Google (including bug reports) mentioned the substitution of apostrophe for accent grave.

I am NOT requesting that SQLite or SQLite3 be changed to accept accent grave for this purpose. I am requesting that the documentation be augmented to explain this substitution.

Thanks.

2009-Jun-29 02:22:38 by anonymous:
Try this: http://www.google.com.au/search?hl=en&q=%22single+quote%22+OR+%22double+quote%22++site%3Asqlite.org TC


2009-Jun-29 02:25:36 by anonymous:
Or indeed this: seems to say that you can use grave accents: http://www.google.com.au/search?hl=en&q=grave++site%3Asqlite.org TC


2009-Jun-29 20:03:46 by drh:
The use of grave (`) for quoting identifiers is not standard SQL. It is a MySQLism. Nevertheless, SQLite supports it for compatibility. SQLite also supports [...] quoting for compatibility with MS-SQL.
 
3931 code closed 2009 Jun anonymous   2009 Jun   1 1 Incorrect query results for SELECT ... WHERE ... IN ((SELECT ...))
For some of our customer databases, one of our queries fails. After examining the issue I found that when I remove an extra pair of brackets, the query works. Oddly, this only happens for some of the databases, but not for all. It may depend on the data in the database...

I could reproduce the problem with a small subset of our database. Enclosed is a dump of that subset that allows to reproduce the problem:

Create a new database from the data.sql SQL instructions Then, execute the following query:

  SELECT * FROM
    data
  WHERE (
    data.record_id IN
      ((SELECT record_id FROM modification_info WHERE (LastDataInfo >= '2009-06-24T10:12:28Z')))
    AND
      data.record_id IN (346)
  );

This should yield the following result set:

  31928|346|3454|5116|0|0
  32268|346|3455|30982|0|0
  32901|346|3456|34902|0|32
  59770|346|3457|0|0|32
  59771|346|3458|0|0|32
  59772|346|3459|0|0|32
  59773|346|3460|0|0|32
  59774|346|3461|37472|0|32
  72474|346|3462|12|0|32

However, it does yield an empty result set.

Removing the extra brackets around the SELECT statement inside the IN test will produce the correct result:

  SELECT * FROM
    data
  WHERE (
    data.record_id IN
      (SELECT record_id FROM modification_info WHERE (LastDataInfo >= '2009-06-24T10:12:28Z'))
    AND
      data.record_id IN (346)
  );
2009-Jun-26 11:38:14 by anonymous:
Could not attach the file, because it's 400k, but the ticket system only accepts 100k. You can find the data file needed to reproduce the problem here


2009-Jun-26 12:31:15 by drh:
Thank you for a very detailed bug report.

The behavior of SQLite is correct in this case. When you say:

    ... x IN (SELECT ...)       /* case 1 */

the result is true if x is equal to any value of the result set of the SELECT statement. When you say

    ... x IN (123)              /* case 2 */

the result is true if x is equal to any of the values in the list - the value 123 in this case. If you use this:

    ... x IN ((SELECT...))

Then the "(SELECT ...)" part is interpreted as a single value, which is the first element of the result set of the SELECT statement. And so the IN operator is as in case 2, not case 1.


2009-Jun-27 08:27:29 by anonymous:
I can't see how IN ((SELECT ...)) is actually allowed by the syntax diagram at http://www.sqlite.org/lang_expr.html. The diagram says that if IN is followed by an opening bracket, then the opening bracket must be followed by (a) a SELECT-STMT, or (b) one or more EXPR's seperated by commas. But (SELECT ...) is neither (a) nor (b). A SELECT-STMT does not allow enclosing brackets (see http://www.sqlite.org/lang_select.html), and an EXPR (which can be enclosed in brackets) can not be a SELECT-STMT (see http://www.sqlite.org/lang_expr.html). TC
 
3930 warn closed 2009 Jun anonymous front 2009 Jun   1 1 SELECT 0.09 + 0.01 - 0.1 <> 0
The command

SELECT 0.09 + 0.01 - 0.1
should return 0 (zero) but returns -1.38777878078145e-17

and the command

SELECT 0.09 + 0.01 - 0.1 +1 -1
correctly returns 0 (zero)

and the command

select (0.09 + 0.01 - 0.1) < 0

should return 0 (zero) but returns 1

ps: my processador is intel core 2 duo 32bits and my OS is windows xp 32 bits

This is a characteristic of floating point numbers. See http://www.sqlite.org/faq.html#q16 for additional information.
 
3929 code closed 2009 Jun danielk1977 back 2009 Jun danielk1977 1 1 Spurious SQLITE_CORRUPT caused by AFTER INSERT trigger.
This bug can cause an SQLITE_CORRUPT error when an AFTER INSERT or AFTER UPDATE trigger writes to the table (directly or via another trigger) that it is attached to. The database is not actually corrupt, but the INSERT or UPDATE statement fails.

Fixed by check-in [6800]

 
3928 code fixed 2009 Jun anonymous front 2009 Jun drh 2 1 integer primary key autoincrement & sqlite_sequence Datum
I get false entries in sqlite in connection with an AFTER INSERT trigger (see attached SQL-Code) and an INTEGER PRIMARY KEY AUTOINCREMENT - column.

Changing to a BEFORE trigger wouldn't be a satisfying solution because on one hand I differ between a record-INSERT and a record-UPDATE and log an identity code in a creator field or editor field (something the "normal" user should see)

on the other hand I log every insert/update/delete in extra tables and splitting the action into 2 Parts (first INSERT, second Trigger) would lead to an extra line in my log.

2009-Jun-23 00:25:04 by drh:
Problem restated: The following SQL causes the sqlite_sequence table to go corrupt:

   CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
   CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
     INSERT INTO t1(b) VALUES(new.b);
     SELECT raise(ignore);
   END;
   INSERT INTO t1 VALUES(123,'xyz');
   SELECT * FROM sqlite_sequence;

As shown by the final SELECT, there are two entries in the sqlite_sequence table for table T1 and the second entry has a NULL seq value.

 
3927 code closed 2009 Jun anonymous   2009 Jun   4 4 incorrect syntax error message on "select * from Group" query
I don't know if it is a bug, keywords problem or something, but when I try to query table "Group" I get "SQL error: near "Group": syntax error" message, whether the table actually exists or not. This was a bit annoying since I have a table named "Group".
2009-Jun-22 17:20:19 by anonymous:
Read this: http://www.sqlite.org/lang_keywords.html
 
3926 code closed 2009 Jun anonymous back 2009 Oct   4 4 invalid error message
  #include <stdio.h>
  #include "sqlite3.h"

  int main() {
    sqlite3 *db;
    sqlite3_stmt *stmt;

    sqlite3_open("test.db3", &db);

    sqlite3_exec(db, "create table t(a)", NULL, 0, 0);
    sqlite3_exec(db, "insert into t values(1)", NULL, 0, 0);
    sqlite3_exec(db, "insert into t values(1)", NULL, 0, 0);
    sqlite3_prepare(db, "select * from t", -1, &stmt, NULL);
    sqlite3_step(stmt);
    sqlite3_interrupt(db);
    sqlite3_step(stmt);
    printf("%s\n", sqlite3_errmsg(db));
    sqlite3_finalize(stmt);
    printf("%s\n", sqlite3_errmsg(db));

    sqlite3_close(db);
  }

First error message printed by this code should be "interrupted" but it prints "SQL logic error or missing database" (in older version it prints "error"). Code after vdbe_error_halt label overrides properly assigned error code after abort_due_to_interrupt label in vdbe.

2009-Oct-01 07:29:24 by anonymous:
Please post to the mailing list about this. Also note that prepare version one is deprecated.
 
3925 doc fixed 2009 Jun anonymous vfs 2009 Jun   4 4 More clarity needed around VFS xOpen & xClose methods.
In the function sqlite3PagerOpen(), even if sqlite3OsOpen() fails, the function will call sqlite3OsClose() which relies on the object pointed to by the sqlite3_file * being properly initialized.

Isn't this bad form? This object is an output parameter of the sqlite3OsOpen() call. In general practice, it is not safe to rely on the state of output parameters when an function does not return a success code.

At the very least, this should be documented with some requirements.

Rough suggestions:

1) The xOpen method of a VFS must leave the sqlite3_file output object in a valid state even if the xOpen method fails. The pMethods member must be NULL or point to a valid sqlite3_io_methods structure.

2) If the pMethods member of a sqlite3_file object is non-null, the xClose method may be called even if the xOpen call for the associated VFS failed.

 
3924 doc fixed 2009 Jun anonymous back 2009 Jun   4 4 Comment in expr.c doesn't make sense
The comment at line 492 is unclear:

  /*
  ** Allocate a Expr node which joins up to two subtrees.
  **
  ** The
  ** Works like sqlite3Expr() except that it takes an extra Parse*
  ** argument and notifies the associated connection object if malloc fails.
  */

perhaps it should be

  ** This routine works like sqlite3Expr() except that it takes an extra Parse*
 
3923 code fixed 2009 Jun anonymous func 2009 Jun   2 4 group_concat includes null if first in the groiup
The group_concat function does normally not include rows where the column or expression to be grouped is null. But it appears as if it does when a null occurs on the first selected row. This was not so in version 3.6.13.

  SQLite version 3.6.15
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t1 (f1);
  sqlite> insert into t1 values (null);
  sqlite> insert into t1 values ('b');
  sqlite> insert into t1 values (null);
  sqlite> insert into t1 values (null);
  sqlite> insert into t1 values ('e');
  sqlite> select group_concat (f1) from t1;
  ,b,e
  sqlite> select group_concat (f1) from t1 where f1 is not null;
  b,e
See also ticket #3806
 
3922 code fixed 2009 Jun drh back 2009 Jun   1 1 Incorrect string to numeric conversion of -9223372036854775809
Consider the following SQL:

  CREATE TABLE t1(x NUMERIC);
  INSERT INTO t1 VALUES('-9223372036854775809');
  SELECT x, typeof(x) FROM t1;

The result is:

  -92233702036854775808 integer

Because the input is too large to be represented as a 64-bit integer value, the conversion should go to floating point and correct result should be:

  -9.22337203685478e+18 real

The error seems to only occur for values in the range of -92233702036854775808 through -92233702036854776832, inclusive. Larger or smaller values convert correctly.

 
3921 xplatform closed 2009 Jun anonymous vfs 2009 Oct   1 4 Sqlite don't work for palm os
The Sqlite don't work on Palm because that OS services (vfs, mem) are so diferent. I was posted the resolution but no one accept then... If one day someone works on it I have the solution, tell me to get that!
2009-Oct-02 08:57:02 by anonymous:
Please post to the sqlite users mailing list. You can distribute your VFS seperately from SQLite. See http://sqlite.org/contrib
 
3920 new closed 2009 Jun anonymous ext 2009 Oct   1 1 Add callback to sqlite3async about actual file closing
I suggest to add to the extension possibility to set callback which will be called when connection is actually closed (as opposed to return from sqlite3_close() function). This possibility could be implemented like this:

  #define SQLITEASYNC_CLOSE_CALLBACK 101

  typedef void (*close_callback_type)(char* zName, int nName);

  struct AsyncFileData {
    ...
    close_callback_type closeCallback;
  };

  static int asyncFileControl(sqlite3_file *id, int op, void *pArg){
    ...
    case SQLITEASYNC_CLOSE_CALLBACK:
    if (((AsyncFile*)id)->pData->zName) {
      ((AsyncFile*)id)->pData->closeCallback = (close_callback_type)pArg;
      return SQLITE_OK;
    }
    break;
    ...
  }

  static int unlinkAsyncFile(AsyncFileData *pData){
    ...
    if( pData->zName ){
      ...
      if (pData->closeCallback != 0) {
        pData->closeCallback(pData->zName, pData->nName);
      }
    }
    ...
  }

I'll try to make exact patch myself later.

2009-Oct-04 20:49:51 by anonymous:
You haven't described why this callback would be useful. (Remember if we add it then it can't ever be removed without breaking code that uses it.)

Please post use cases to the sqlite-users mailing list. Closing as this bug tracker is no longer used.

 
3919 code closed 2009 Jun anonymous ext 2009 Oct   1 1 findLock() in sqlite3async should use filename with full path
I see that findLock() function finds AsyncLock object for intra-process locking by exact equality of the file name. Tracing call to findLock() back I see that file name given to it is the same file name that user gave to sqlite3_open*() functions. So if I open connections to the same database giving not exactly equal names intra-process locking will not work.
2009-Oct-20 06:19:32 by anonymous:
Errr, you are the user. There are also many difficulties in determining if it is the same file. Please continue discussion on the sqlite-users mailing list where other developers can help find a solution.
 
3918 code closed 2009 Jun anonymous back 2009 Jun danielk1977 1 1 Bug causing false corruption report.
In allocateBtreePage(), if the free-list is being searched for a specific page number, and the code encounters a free-list trunk page that is not the last in the trunk-list and has no leaf pages, the 4-byte block starting at byte offset 8 of the page is interpreted as a leaf page number anyway. i.e. even though the trunk has 0 leaves, sqlite tries to read the first leaf anyway.

Usually, this is harmless, except:

  • If the 4 byte block seems to contain a value greater than the total number of pages in the db image, corruption is incorrectly reported, and
  • if the 4 byte block seems to contain the page number of the page being searched for, then actual corruption could follow.

The second of these two outcomes is quite unlikely. It has not actually been demonstrated yet.

2009-Jun-17 11:22:20 by danielk1977:
3.6.15 is the only released version of sqlite that exhibits the reported problem. But that is because 3.6.15 is the first version that includes the check for corruption that causes an error to be reported. The underlying problem - that sqlite may try to read a leaf page number from an empty trunk page - has been present since at least 3.4.0.
 
3917 event closed 2009 Jun anonymous   2009 Oct   1 4 Illegal instruction (core dumped)
Here is the core backtrace :

  (gdb) bt
  #0  0x080a529b in rl_read_key ()
  #1  0x080a51a8 in _rl_insert_typein ()
  #2  0x08096a98 in _rl_dispatch_subseq ()
  #3  0x08096e41 in bind_arrow_keys_internal ()
  #4  0x0804c6f8 in process_input (p=0xbffa9910, in=0x0) at shell.c:2802
  #5  0x0804ee88 in main (argc=2, argv=0xbffaaec4) at shell.c:3152

I just did a return at the sqlite command line in an long-open session of my db (more than 2 days). It is thus possible for the database to have been overwritten

2009-Oct-03 02:12:31 by anonymous:
This is unlikely to be sqlite's fault (if it crashed repeatedly someone else would have noticed by now!) If you have a way of repeating it then please post to sqlite-users mailing list.
 
3916 code closed 2009 Jun anonymous back 2009 Jun   4 4 unneed assignment in build.c
pColl = 0 is not needed at line 1267:

    if( !pColl ){
      sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
      pColl = 0;
    }
Thanks
 
3915 code closed 2009 Jun anonymous back 2009 Jun   4 4 assert statement repeated in btree.c
at line 6290:

  assert( pPage->intKey || nKey>=0 );
  assert( pPage->intKey || nKey>=0 );
Thanks.
 
3914 code fixed 2009 Jun anonymous back 2009 Jun shane 4 4 Linkage error in where.c when compiled with SQLITE_OMIT_VIRTUALTABLE
Where.c generates a linkage error at line 2236 since bestVirtualIndex is not available when compiled with SQLITE_OMIT_VIRTUALTABLE:

RECOMMENDED SOLUTION:

  #ifndef SQLITE_OMIT_VIRTUALTABLE
    if( IsVirtual(pSrc->pTab) ){
      sqlite3_index_info *p = 0;
      bestVirtualIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost,&p);
      if( p->needToFreeIdxStr ){
      sqlite3_free(p->idxStr);
    }
  #endif

Also, I think that a decision should be made either to surround all Virtual table access code with SQLITE_OMIT_VIRTUALTABLE, or eliminate it and only use the IsVirtual MACROS

For example, similar code in alter.c,v 1.61 has the following lines at 594:

  #ifndef SQLITE_OMIT_VIRTUALTABLE
    if( IsVirtual(pTab) ){
      sqlite3ErrorMsg(pParse, "virtual tables may not be altered");
      goto exit_begin_add_column;
    }
  #endif

There are about 24 instances when IsVirtual is used, and could be compiled out of the code with #ifndef SQLITE_OMIT_VIRTUALTABLE blocking.

2009-Jun-15 17:20:45 by anonymous:
BAD COPY/PASTE, RECOMMENDED SOLUTION SHOULD BE:

  #ifndef SQLITE_OMIT_VIRTUALTABLE
  if( IsVirtual(pSrc->pTab) ){
    sqlite3_index_info *p = 0;
    bestVirtualIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost, &p);
    if( p->needToFreeIdxStr ){
      sqlite3_free(p->idxStr);
    }
		sqlite3DbFree(pParse->db, p);
  }else
  #endif


2009-Jun-15 17:39:27 by drh:
Note that this is not a problem with GCC (the compiler we use for development) since with SQLITE_OMIT_VIRTUAL, the IsVirtual() macro is hard-coded to 0 (false) and hence GCC ocmpletely omits the content of the if statement and no linkage error occurs.


2009-Jun-15 17:55:31 by anonymous:
Can the #ifndef SQLITE_OMIT_VIRTUALTABLE be added into where.c so that MSVC does not generate an error?


2009-Jun-16 14:25:24 by shane:
I wrapped the call to bestVirtualIndex() with an #if-def. I left the other calls to IsVirtual() in place, as I think the code is clearest in this form.
 
3913 code active 2009 Jun anonymous tcl 2009 Jun   4 4 Some variables in bubble-generator.tcl are being used before being set
Hi there, I have converted your bubble-generator (found in http://www.sqlite.org/docsrc/artifact/1558) to python and now I'm noticing there are two minor issues on it.

On the draw_loop function, mxx will not be set if it you pass a graph like this: "x {optx {loop a b}}". I'm setting mxx to 0 at the top of this function for now.

The second issue I found lives in the draw_stack function, here, the bypass_x variable is used multiple times before being defined. I don't have any graphs that cause trouble here, but I though it would be nice to point it.

 
3912 code fixed 2009 Jun anonymous   2009 Jun   1 1 tokenize.c: variable declared after beginning of block
This code in tokenize.c throws errors on some compilers because n is not declared at the beginning of the block:

  case '@':  /* For compatibility with MS SQL Server */
  case ':': {
    testcase( z[0]=='$' );  testcase( z[0]=='@' );  testcase( z[0]==':' );
    int n = 0;
    *tokenType = TK_VARIABLE;

Suggested fix: Move the line "int n = 0;" ahead of the testcase line.

 
3911 code fixed 2009 Jun drh front 2009 Jun   3 1 Memory leak on SELECT statements with subquery in FROM clause
The following code leaks memory:

   CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2);
   CREATE TABLE t2(b,c); INSERT INTO t2 VALUES(2,3);

   SELECT * FROM t1 JOIN (t2) USING(b);

No leak occurs if the parentheses are removed from around (t2).

 
3910 build closed 2009 Jun anonymous build 2009 Nov   1 1 DJGPP build errors
Hi All,

SQLite cannot be compiled with DJGPP (latest version).

1) Default build settings are incorrectly determined, so SQLITE_DISABLE_LFN, SQLITE_MUTEX_NOOP, SQLITE_OMIT_LOAD_EXTENSION macros have to be manually enabled to avoid build errors. Using the command line to pass these options isn't working well as the 128 chars DOS cmdline limit is quickly reached. It can be hacked through config.h, but it isn't very ideal. However, since these options are probably needed for all DJGPP builds, they could be enabled by default. The linked patch contains such resolution.

2) DJGPP has three more compilation errors, which are corrected by linked patch.

--- gcc -I. -I../../../../include -O3 -c ../../sqlite3.c -osqlite3.o ../../sqlite3.c: In function 'sqliteErrorFromPosixError': ../../sqlite3.c:21216: error: 'ETIMEDOUT' undeclared (first use in this function) ../../sqlite3.c:21216: error: (Each undeclared identifier is reported only once ../../sqlite3.c:21216: error: for each function it appears in.) ../../sqlite3.c:21252: error: 'ENOTCONN' undeclared (first use in this function) ../../sqlite3.c:21256: error: 'ESTALE' undeclared (first use in this function) ---

Patch fixing above issues: http://www.syenar.hu/harbour/sqlite3-3.6.14.2-djgpp-patch.dif

Brgds, Viktor

2009-Jun-11 22:14:31 by anonymous:
Replaced linked patch with a clean one, which solves the root cause (DJGPP was detected as SQLITE_OS_UNIX), instead if the symptoms.

Link unchanged: http://www.syenar.hu/harbour/sqlite3-3.6.14.2-djgpp-patch.dif

Brgds, Viktor


2009-Jun-11 22:26:52 by anonymous:
After trying to build and actual app using DJGPP + SQLite, these errors appear:

c:\hb20\lib\dos\djgpp/libsqlite3.a(sqlite3.o):sqlite3.c:
(.text+0xa7ba): undefined reference to `_sqlite3_os_init'
c:\hb20\lib\dos\djgpp/libsqlite3.a(sqlite3.o):sqlite3.c:
(.text+0xc464): undefined reference to `_sqlite3_os_end'

We're in SQLITE_OS_OTHER mode, and these functions aren't defined.

Brgds, Viktor


2009-Nov-08 02:35:44 by anonymous:
DJGPP is not a platform supported by the core SQLite team. (ie it is not a platform they develop and do testing on). A suggested approach is to write DJGPP support as a VFS and then have the code be on http://sqlite.org/contrib for DJGPP users to get it.
 
3909 code closed 2009 Jun anonymous   2009 Jun   1 1 Check-in [6746] needs pager.c to follow suit
The following sections from pager.c do not match the changes introduced in [6746] . The new int return value is not honored in the definition of xCodec.

  #ifdef SQLITE_HAS_CODEC
    void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
    void *pCodecArg;            /* First argument to xCodec() */
  #endif

Plus:

  #ifdef SQLITE_HAS_CODEC
  /*
  ** Set the codec for this pager
  */
  void sqlite3PagerSetCodec(
    Pager *pPager,
    void *(*xCodec)(void*,void*,Pgno,int),
    void *pCodecArg
  ){
    pPager->xCodec = xCodec;
    pPager->pCodecArg = pCodecArg;
  }
  #endif
It all looks correct to me. And it compiles (without warnings) and runs. But even if it were wrong, it shouldn't make any difference since it is all commented out within

   #ifdef SQLITE_HAS_CODEC
   ...
   #endif

Thanks for the report, though.

 
3908 code fixed 2009 Jun anonymous back 2009 Jun   4 4 SQLITE_OPEN_READONLY and :memory: database allow write operations on d
When SQLITE_OPEN_READONLY is specified for a memory only database (:memory:) the resulting database allows write operations.

It wouldn't make much sense to have a read only memory database, but the features should work as advertized. Also, in my use case, I was running API tests against memory databases. So, a memory database should behave as close as possible as a persistent database.

 
3907 code closed 2009 Jun anonymous   2009 Jun   1 1 wrong result returned with sql query using no table and EXISTS
Here is some python code describing the problem:

  >>> cnx = db.get_connection('sqlite', database=':memory:')
  >>> cu = cnx.cursor()
  >>> cu.execute('create table t1(x integer, y integer)')
  >>> cnx.commit()
  >>> cu.execute('SELECT DISTINCT %(x)s, %(y)s '
                 'WHERE NOT EXISTS(SELECT 1 FROM t1 '
                 'WHERE t1.x=%(x)s AND t1.y=%(y)s)',
                 {'y': 522, 'x': 529})
  >>> cu.fetchall()
  [(529, 522)]

I would expect an empty result since the exists subquery clearly return no result.

2009-Jun-11 17:09:52 by drh:
It is a NOT EXISTS subquery, not an EXIST subquery.

In the future, please submit raw SQL with your bug reports - not python code that generates SQL. Thanks.

 
3906 code closed 2009 Jun anonymous cli 2009 Oct   4 4 patch for mode insert in CLI to preserve number-like strings
Strings of digits cannot be safely "round-tripped" through output using the ".mode insert" feature of the command line interface.

For a sequence like this:

  CREATE TABLE test_table(city TEXT, zip TEXT);
  INSERT INTO test_table VALUES('Cambridge','02139');
  .mode insert test_table
  SELECT * FROM test_table;

This output is produced:

  INSERT INTO test_table VALUES('Cambridge',02139);

Note the lack of quotes on the zip code, since it is considered numeric. If this insert line is later read back into sqlite, the leading 0 of the zip code is lost.

Here is a patch to the isNumber method in src/shell.c that rejects strings with leading zeros.

RCS file: /sqlite/sqlite/src/shell.c,v
retrieving revision 1.210
diff -u -r1.210 shell.c
--- shell.c	31 May 2009 17:16:10 -0000	1.210
+++ shell.c	11 Jun 2009 02:14:30 -0000
@@ -1054,6 +1054,12 @@
   if( !isdigit(*z) ){
     return 0;
   }
+  if (*z=='0') {
+    const char ch = *(z+1);
+    if (ch!=0 && ch!='.' && ch!='e' && ch!='E') {
+      return 0;
+    }
+  }
   z++;
   if( realnum ) *realnum = 0;
   while( isdigit(*z) ){ z++; }
Perhaps an always-quote flag might be useful in some cases?
2009-Oct-12 21:23:07 by anonymous:
Now http://www.sqlite.org/src/info/7b61b6c6ce
 
3905 build closed 2009 Jun anonymous build 2009 Sep   1 1 Build issue on Solaris with the latest gcc - undefined referenes.
Building sqlite-3.6.14.2 on a Sun T5240 running Solaris 10 update 4 with gcc 4.3.2 works fine. Building it on the same machine with gcc 4.4.0 causes a string of error messages.

kirkby@t2:~/sqlite-3.6.14.2$ make

/bin/bash ./libtool --tag=CC --mode=link gcc -DSQLITE_THREADSAFE=1 -g -O2 -o sqlite3 shell.o ./libsqlite3.la gcc -DSQLITE_THREADSAFE=1 -g -O2 -o .libs/sqlite3 shell.o ./.libs/libsqlite3.so -lc -Wl,--rpath -Wl,/usr/local/lib

./.libs/libsqlite3.so: undefined reference to `dlerror@SUNW_1.22'

./.libs/libsqlite3.so: undefined reference to `dlopen@SUNW_1.22'

./.libs/libsqlite3.so: undefined reference to `dlsym@SUNW_1.22'

./.libs/libsqlite3.so: undefined reference to `dlclose@SUNW_1.22'

collect2: ld returned 1 exit status make: *** [sqlite3] Error 1

A Google search on these 'undefined references' with '@SUNW' appearing on Solaris shows they are not new. They are not unique to sqlite , nor are they unique to gcc-4.4.0.

There are numerous similar reports many connected with building Apache. What is common is that all the software that shows this problem makes use of libtool. Some saying the problem is caused by not linking libc, or including it in the wrong order.

Is there any chance of someone looking at this bug? If you don't have access to a Sun running Solaris, with the latest version of gcc (4.4.0), I could get a developer access on such a machine. It might not be that particular machine, as it's not mine, but I do have another machine where I could replicate the problem.

2009-Jun-11 21:19:23 by anonymous:
Just to add, sqlite is used as part of the Sage project,

http://www.sagemath.org/

which aims to create a free GPL'ed maths program which is a viable alternative to the commercial programs (MATLAB, Mathematica, Maple etc).

The head of the Sage project, Professor Willian Stein, confirmed to me today that if a SQLite developer wanted access to the 128 core Sun on which this problem was first noticed, it can be arranged.

I had previously intended to set up a Sun I own to do this, but it can be done on the universities computer which is faster and has a faster connection than any I own.

Any help with sorting this out would be appreciated.


2009-Sep-30 09:03:51 by anonymous:
You need to add -ldl to the link line.

Please direct further discussion to the mailing list.

 
3904 code fixed 2009 Jun drh front 2009 Jun   2 1 Assertion fault with reverse_unordered_selects pragma
The following code hits an assertion fault:

   CREATE TABLE t1(x UNIQUE);
   INSERT INTO t1 VALUES(1);
   PRAGMA reverse_unordered_selects = ON;
   SELECT * FROM t1;
 
3903 doc closed 2009 Jun anonymous   2009 Jun   3 3 Problem with affinities
All results should be the same:

  SQLite version 3.6.14.2
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> CREATE TABLE t(x INTEGER);
  sqlite> INSERT INTO t VALUES(2);
  sqlite> SELECT * FROM t WHERE x < '1';
  sqlite> SELECT * FROM t WHERE 2 < '1';
  2
  sqlite> SELECT * FROM t WHERE CAST(2 AS INTEGER) < '1';
  sqlite>
In this case it is working as designed:

  • (x < '1') is false because the x has numeric affinity. So '1' is converted to an integer before the comparison.
  • (2 < '1') is true, because a number is less than a string.
  • (CAST(2 AS INTEGER) < '1') is false because the CAST expression has numeric affinity. So '1' is converted to 1 before the comparison.

The fact that CAST expressions have an affinity has been added to the documentation here:

  http://www.sqlite.org/docsrc/ci/0b44acac2087059539713e0f28fa2544ca840ec7
 
3902 code review 2009 Jun anonymous front 2009 Jun   3 2 The PRAGMA full_column_names is not working
(Sorry by my bad english)

When I use the "PRAGMA full_column_names = 1" command, the requested field names does not retturn with the table name if we use a command like this:

SELECT * FROM table

It returns:

field1 field2 field3

when it would to return:

table.field1 table.field2 table.field3

If we use this command:

SELECT rowid,* FROM table

The result comes with the table name only in the rowid field:

table.rowid field1 field2 field3

I noticed in code that on select.c where it has this line:

    if( pEList->a[i].zName ){

it evaluates to false on rowid but evaluates to true on the other fields, then executes the following:

      char *zName = pEList->a[i].zName;
      sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);

that does not add the table name to the fields. The code that does it is after the following line:

    }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) && pTabList ){

WHAT I MADE TO SOLVE THIS:


I discovered that that line was there to use that block of code if there is an alias (AS) in the column, but it doesn't work. Instead I have made a workaround or solved it doing this line of code:

    if( pEList->a[i].zName && (sqlite3StrNICmp(pEList->a[i].zName, (char*)p->span.z, p->span.n) != 0){

I added the code

   (sqlite3StrNICmp(pEList->a[i].zName, (char*)p->span.z, p->span.n) != 0)

to the line, that evaluates wether the expression token string (p->span.z) is equal to the alias name of the expression (pEList->a[i].zName).

I hope that some programmer put this to the sqlite code.

And thank you for your work, I like too much this piece of code.

    The diff file follows bellow:
--- C:/sqlite3/sqlite-source-3_6_14_2/select.c	Mon May 25 08:49:40 2009
+++ C:/sqlite3/sqlite-source-3_6_14_2/select.c	Mon Jun 08 08:01:30 2009
@@ -1045,9 +1045,11 @@
     Expr *p;
     p = pEList->a[i].pExpr;
     if( p==0 ) continue;
-    if( pEList->a[i].zName ){
+    // Check wether there is an alias name for the expression or column.
+    if( pEList->a[i].zName && (sqlite3StrNICmp(pEList->a[i].zName, (char*)p->span.z, p->span.n) != 0)){
       char *zName = pEList->a[i].zName;
       sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);
+    // Check wether this is a table column.
     }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) && pTabList ){
       Table *pTab;
       char *zCol;
@@ -1064,16 +1066,17 @@
       }else{
         zCol = pTab->aCol[iCol].zName;
       }
-      if( !shortNames && !fullNames ){
-        sqlite3VdbeSetColName(v, i, COLNAME_NAME,
-            sqlite3DbStrNDup(db, (char*)p->span.z, p->span.n), SQLITE_DYNAMIC);
-      }else if( fullNames ){
+      if ( shortNames ) {
+        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);
+      }else if( fullNames || pTabList->nSrc>1 ){
         char *zName = 0;
         zName = sqlite3MPrintf(db, "%s.%s", pTab->zName, zCol);
         sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);
-      }else{
-        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);
+      } else {  //( !shortNames && !fullNames )
+        sqlite3VdbeSetColName(v, i, COLNAME_NAME,
+            sqlite3DbStrNDup(db, (char*)p->span.z, p->span.n), SQLITE_DYNAMIC);
       }
+    // If we falls here, it is a expression without an alias. ex.: SELECT 1+1 From table
     }else{
       sqlite3VdbeSetColName(v, i, COLNAME_NAME,
           sqlite3DbStrNDup(db, (char*)p->span.z, p->span.n), SQLITE_DYNAMIC);
@@ -3209,7 +3212,7 @@
               pExpr->span = pExpr->token;
               pExpr->span.dyn = 0;
             }
-            if( longNames ){
+            if( longNames || pTabList->nSrc>1 ){
               pNew = sqlite3ExprListAppend(pParse, pNew, pExpr, &pExpr->span);
             }else{
               pNew = sqlite3ExprListAppend(pParse, pNew, pExpr, &pRight->token);
2009-Jun-08 12:35:00 by drh:
Use:

   PRAGMA short_column_names=OFF;
   PRAGMA full_column_names=ON;


2009-Jun-08 22:00:34 by anonymous:

Related to the documentation, for the queries WITH JOINS, when:

  PRAGMA short_column_names=ON;
  PRAGMA full_column_names=OFF;
  SQLite may return: only column names
  And it really returns: only column names

  PRAGMA short_column_names=ON;
  PRAGMA full_column_names=ON;
  SQLite may return: only column names
  And it really returns: only column names

  PRAGMA short_column_names=OFF;
  PRAGMA full_column_names=ON;
  SQLite may return: table and column names
  And it really returns: table and column names

  PRAGMA short_column_names=OFF;
  PRAGMA full_column_names=OFF;
  SQLite may return: table and column names
  BUT IR RETURNS: only column names      <<<----

The Documentation:

Result columns are named by applying the following rules in order:

1. If there is an AS clause on the result, then the name of the column is the right-hand side of the AS clause.

2. If the result is a general expression, not a just the name of a source table column, then the name of the result is a copy of the expression text.

3. If the short_column_names pragma is ON, then the name of the result is the name of the source table column without the source table name prefix: COLUMN.

-> 4. If both pragmas short_column_names and full_column_names are OFF then case (2) applies for simple queries and case (5) applies for joins.

5. The name of the result column is a combination of the source table and source column name: TABLE.COLUMN

And another thing:

When we have SIMPLE QUERIES, the configuration bellow:

  PRAGMA short_column_names=ON;
  PRAGMA full_column_names=ON;

may return the table name together with the column names. I understand that the short_column_names is used only for joins. It is what we understand reading the docs (above), and it is logical.

The code that I made works like the documentation. Please, take a look at the diff.

I will make new checking to the code changes at this night cause I think that there is code that is not needed there. Bye!


2009-Jun-09 00:57:51 by drh:
The documentation was wrong and has been corrected. See http://www.sqlite.org/draft/pragma.html#pragma_full_column_names


2009-Jun-09 01:42:20 by anonymous:
Then I don't know why the short_column_names does exist, because in the way the new documentation is written, if it is ON or OFF the result will be the same.

In the old way the short_column_names had a reason to exist.

And if someone want that the simple queries return only column names and the join queries return the table name with the columns... what configuration we may use?

 
3901 code fixed 2009 Jun drh front 2009 Jun   2 1 LIKE of indexed non-text column in WHERE clause gives incorrect answer
Consider the following SQL:

  CREATE TABLE t1(x INTEGER UNIQUE COLLATE nocase);
  INSERT INTO t1 VALUES(4);
  INSERT INTO t1 VALUES(45);
  SELECT x FROM t1 WHERE x LIKE '4%';
  SELECT x FROM t1 WHERE +x LIKE '4%';

The correct answer is two rows: 4 and 45. The second SELECT above gives the correct result. The first SELECT returns just one row: 4

The problem is that the LIKE query optimizer incorrectly converts the LIKE expression into:

  SELECT x FROM t1 WHERE x>='4' AND x<'5';

This optimization should only be applied if the affinity of the column on the LHS of the LIKE operator is TEXT.

When "+x" is used on the LHS of the LIKE operator, it defeats the optimization and the correct answer results.

 
3900 code closed 2009 Jun anonymous back 2009 Jun   3 4 Execution of sqlite3_mutex_leave without prior sqlite3_mutex_enter
Consider the following execution trace:

execExecSql()

  • sqlite3_prepare(..., &pStmt, 0)
  • sqlite3_step(pStmt) // locks and unlocks pStmt->db->mutex
  • sqlite3_column_text(pStmt, 0)
    • columnMallocFailure(pStmt)
      • sqlite3_mutex_leave(pStmt->db->mutex)

In execExecSql, sqlite3_prepare creates a new pStmt object, but does not enter the pStmt->db->mutex. Neither does sqlite3_step. Thus, the execution of sqlite3_mutex_leave will receive an unlocked mutex.

It seems to be a defective behavior especially when considering the following comment above noopMutexLeave:

The sqlite3_mutex_leave() routine exits a mutex that was previously entered by the same thread. The behavior is undefined if the mutex is not currently entered or is not currently allocated. SQLite will never do either.

Please, let me know if this is correct or not.

Have a nice day! Jacek

The analysis above is not correct. The mutex is entered within the columnMem() function.

There are assert() statements in the SQLite code that will fail if there is an attempt to leave a mutex that has not been entered, or if there is an attempt to enter a non-recursive mutex multiple times from the same thread, or if there is an attempt to use a shared data structure while the appropriate mutex is not held. So a bug like this would be unlikely to go undetected.

 
3899 code closed 2009 Jun anonymous   2009 Jun   3 5 Random SQLITE_ERROR returned instead of SQLITE_BUSY
It may sound silly but... Under some circumstances when many simultaneous SELECT/INSERT queries are done a random SQLITE_ERROR is raised instead of SQLITE_BUSY after calling sqlite3_exec.

How to reproduce: Windows XP, Digital mars c compiler (or any other I suppose), SQLite amalgamation 3.6.14.2 compiled with -DSQLITE_THREADSAFE=1 -DNDEBUG=1 and statically linked with application that makes a connection to a file database and then spawns 10+ 'reader' and 10+ 'writer' threads that use that same connection.

Reader threads do simple COUNT(*) on a table and sleep for 1ms, and writer threads do simple INSERT into same table and then sleep for 1ms. Both threads handle SQLITE_BUSY with a sqlite3_sleep(1), and do printf in case of SQLITE_ERROR.

And the funny part: Start aplication and then hit ctrl+r in explorer and hold it down to refresh database file size as fast as possible. After couple secs a random SQLITE_ERROR's will be reported, ranging from code 0 (no error) to disc I/O error, database locked, unable to open database file etc. The more threads application spawns the more the problem will be visible. If ctrl+r is not pressed then problem will not occur, no matter how many threads are there.

I tested the same scenario with 3.6.5 version of amalgamation compiled with same options and there is no SQLITE_ERROR raised, only SQLITE_BUSY, as it should.

If I made some horrible and stupid mistake and wasted your time - I apologize sincerely.

Bane

2009-Jun-05 18:58:45 by drh:
What is "explorer" and what does ctrl+r do to it?


2009-Jun-05 22:01:36 by anonymous:
The Explorer is the default file manager on Windows. On pressing CTRL+R the Explorer updates it's current view. While holding CTRL+R down, the Explorer continuously update it's view.

I suspect the Explorer accesses the database file while updating it's view and this interferes in some way with the application accessing this file.


2009-Jun-10 19:17:18 by shane:
Can you post/send the source code for your test?


2009-Jun-19 15:19:08 by bane:
Sorry for not replying sooner. There is no bug, problem was in my test code. Explorer does lock file and SQLITE_ERROR 10 (IO err) and 14 (cant open file) are returned always, but I used sqlite3_errcode() in a non thread safe way, so I got random numbers. My mistake, I owe you guys a beer.
 
3898 todo closed 2009 Jun anonymous front 2009 Jun   3 4 Expressions are not being converted as expected.
I've created a table like so:

  CREATE TABLE desc (number primary key, full_line);

Then I've loaded it with taxonomy numbers from NCBI (where "9606" means "Homo Sapiens", for instance).

  sqlite> select * From desc where number="9606";
  9606|Homo sapiens
  sqlite> select * From desc where number='9606';
  9606|Homo sapiens
  sqlite> select * From desc where number=9606;
  sqlite> select * From desc where number=9606+0;

One workaround is this:

  sqlite> select * From desc where number+0=9606;
  9606|Homo sapiens

If I change the table definition to this:

  CREATE TABLE desc (number integer primary key, full_line);

Then it works as expected:

  sqlite> select * From desc where number=9606;
  9606|Homo sapiens
  sqlite> select * From desc where number='9606';
  9606|Homo sapiens
  sqlite> select * From desc where number="9606";
  9606|Homo sapiens

Why is it doing this? I thought SQLite automatically converted from numbers to text and vice-versa as needed. If it converted the 9606 to a string or the field to a number, then there would be no problem.

2009-Jun-04 21:31:37 by anonymous:
Never mind, Jay A. Kreibich <jay@kreibi.ch> informed me that this is as designed.
 
3897 code closed 2009 Jun anonymous   2009 Oct   1 1 Error inserting trough instead of insert trigger using fts3
I have a problem inserting data through a view.

This is my DB:

CREATE TABLE data (
	id BLOB PRIMARY KEY,
	created REAL NOT NULL
);

CREATE VIRTUAL TABLE text USING FTS3();

CREATE VIEW data_view AS
  SELECT d.id, d.rowid, d.created, t.content
  FROM data d INNER JOIN text t ON d.rowid = t.rowid;

CREATE TRIGGER data_view_insert INSTEAD OF INSERT ON data_view
BEGIN
  INSERT INTO data (id , created) VALUES (new.id, new.created);
  INSERT INTO text (docid, content) VALUES (last_insert_rowid(), new.content);
END;
When I insert rows in the data_view:

PRAGMA count_changes = 1;
INSERT INTO data_view (id, created, content)
VALUES (randomblob(16), datetime('now'), 'data');
I receive strange SQLite Error: “not an error”.
2009-Jun-05 15:14:20 by anonymous:
I tried the scripts with the command line sqlite3 application. The row inserted in the data_view. But I received “SQL error: unknown error.”


2009-Jun-22 09:23:41 by anonymous:
I've experienced big trouble when using PRAGMA count_changes = 1; with FTS3 tables.

Your script runs fine for me with PRAGMA count_changes = 0;


2009-Jul-02 12:39:32 by anonymous:

With PRAGMA count_changes = 0 optimistic concurrency in my application (as well as in any .NET application which uses System.Data.SQLite wrapper and instead of insert trigger on fts3 table) does not work right because the number of affected rows always equals 0. At first, I posted the issue at System.Data.SQLite. But it turned out to be sqlite issue.


2009-Oct-19 06:57:05 by anonymous:
FTS3 has other tables behind the scenes and uses those to do work. It would be virtually impossible to pretend that isn't the case.
 
3896 new closed 2009 Jun anonymous   2009 Oct   3 3 Optional Locking for Virtual Tables
It would be nice to have a way for virtual table modules to indicate that they do not require locking by SQLite in order to function correctly.

My virtual table module allows SQLite access to data stored in a global memory section and synchronizes such access via global mutices on a "table" basis. When a long running SQL based report against some virtual tables is running, it will starve a cache update attempting to update a completely different table.

I have patched two sources to work around this problem:

- build.c will set P2 of the OP_Transaction to 0 if no native tables of the database are affected (thus not RESERVED lock on the database). TEMP database (index 1) is never changed.

- vdbeaux.c will not consider OP_VUpdate as causing a rollback (thus not opening a Statement Journal file)

This has the side effect of also replacing the OP_Statement for the TEMP database with an OP_Noop. Could this cause a problem on some transactions (e.g. those writing large amounts of data to ephemeral tables)?

2009-Jun-05 09:26:48 by anonymous:
A DELETE against a native table without a WHERE clause creates code to count the rows (this requires only a READ table lock) and then an OP_Clear. This requires a WRITE transaction to be open against the database file, which fact is recorded in the Parse structure.

The P2 of the OP_transaction is set to one if - an OP_Clear is generated against the Db - or a native table in the Db is wríte locked


2009-Oct-04 23:15:44 by anonymous:
We can't unilaterally change SQLite since it would break other existing virtual table code. It also isn't clear if your worries are about different SQLite queries blocking each other or SQLite queries blocking other random non-SQLite code.

SQLite already has well defined semantics with respect to locking and we really don't want developers to have to consider differences between virtual tables and "real" tables. You can create multiple connections or multiple cursors on the same connection as appropriate.

This bug tracker is no longer in use and so the issue will be closed. Please continue discussion on the sqlite-users mailing list.

 
3895 code closed 2009 Jun anonymous back 2009 Jun   1 3 Bus Error on DELETE FROM on hpux-ia64 in 32bit mode (ELF-32)
sqlite 3.6.14.2 Compiled for IA64, 32bit!! Sources: TEA tarball of the amalgamation.

Crashes with a Bus Error. Stack at the point:

  #0  0x60000000c2541420:0 in sqlite3RowSetInsert (p=0x40e0ad68, rowid=2062535)
      at ../generic/tclsqlite3.c:30020
  30020     pEntry->v = rowid;
  (gdb) where
  #0  0x60000000c2541420:0 in sqlite3RowSetInsert (p=0x40e0ad68, rowid=2062535)
      at ../generic/tclsqlite3.c:30020

The same sources compiled for 64bit do not crash.

Speculating that there is a 32/64 mismatch somewhere, and (due bus error), an alignment problem.

The crash happens on the assignment of the 64bit rowid to the 64bit 'v' field in the RowSetEntry.

RowSetEntry = 1* 64bit v + 2*32bit pointer to left/right subtree. Note: I counted the pointers as 32bit due to compilation for 32bit. This is 8 + 2*4 = 16 byte.

  (gdb) p pEntry
  $1 = (struct RowSetEntry *) 0x40e0ad84
  (gdb) p p->pFresh
  $2 = (struct RowSetEntry *) 0x40e0ad94
  (gdb) p p->pFresh - pEntry
  $3 = 1
  (gdb) p ((char*)p->pFresh) - ((char*)pEntry)
  $4 = 16
  (gdb)

That matches. For 64bit mode I am guessing that the struct would be 3*64bit = 3*8 = 24 byte, i.e 64bit pointers.

The pEntry pointer is 4-aligned, but not 8-aligned. That is possibly the problem.

  (gdb) p ((unsigned long)(void*)pEntry)%8
  $8 = 4
  (gdb) p ((unsigned long)(void*)pEntry)%4
  $9 = 0
  (gdb)

A possible contra-indication to my theory above ... The p->pChunk field is NULL, but that is where the rowset-entries are allocated from if I understand correctly. Which means that the pFresh points to whereever, i.e. this is possibly not initialized ?!

  (gdb) p* p
  $11 = {pChunk = 0x0, db = 0x40dc69b8, pEntry = 0x0, pLast = 0x0,
    pFresh = 0x40e0ad94, pTree = 0x0, nFresh = 3, isSorted = 1 '\001',
    iBatch = 0 '\000'}
  (gdb)

The SQL statement we are trying to execute is

  (gdb) up 4
  #4  0x60000000c267d490:0 in DbObjCmd (cd=0x40d0b5f8, interp=0x40053448,
      objc=3, objv=0x40057514) at ../generic/tclsqlite3.c:107300
  107300        while( rc==TCL_OK && pStmt &&   SQLITE_ROW==sqlite3_step(pStmt) ){
  (gdb) p zSql
  $17 = 0x40d0cb78 "\n\t\tDELETE FROM meta         WHERE file = $sig;\n\t\tDELETE FROM instances    WHERE file = $sig;\n\t    "
  (gdb)

At this point I am still not sure where the problem exactly comes from, only speculation, and know only that I am deep in the guts of sqlite.

Also thankful for ways to activate introspections and tests which would help tracing the cause.

I can run test scripts/code on my system, should it be necessary. I haven't put up the configure stdout and config.log yet. Not sure if needed.

2009-Jun-02 19:43:27 by drh:
See tickets #3869 and #3882 and check-in [6666] .


2009-Jun-02 20:10:28 by anonymous:
Hm. There is a bit of weirdness still from my point of view.

The checkin [6666] fixing this is listed as committed on May 22.

Version 3.6.14.2 was released May 24/25 and thus should have the fix methinks.

My TEA/amalgamation definitely doesn't have the change (rowset.c, v1.6 and looked at RowSetInit) and the configure.in reports it as 3.6.14.2, and it was generated "May 25 12:34 UTC".

Some problem in the code generating the amalgamation or TEA tarball ?

In the meantime I will apply the referenced patch to fix the problem locally.

Thanks.


2009-Jun-02 20:23:56 by drh:
3.6.14.2 was a branch release. The fix for this problem went into the trunk, not into the 3.6.14.2 branch.


2009-Jun-02 20:28:12 by anonymous:
Ok, that explanation makes sense.

And I can confirm that this patch fixes the issue for me here as well. Crash is gone. Wonderful, happy again.

 
3894 code closed 2009 Jun anonymous front 2009 Jun   3 3 No such column error when using quoted names in subqueries.
The following SQL works fine in 3.6.13, but gives a "no such column: a" in 3.6.14.

  Create Table t (a int);
  Insert Into t Values (0);
  Select a From (Select [a] From t);
  Select [a] From (Select [a] From t);
  Select a From (Select "a" From t);
  Select * From (Select [a] From t) Order By a;

A workaround can be made:

  Select a From (Select [a] As [a] From t);
2009-Jun-02 15:48:13 by drh:
Duplicate of ticket #3893.
 
3893 code fixed 2009 Jun anonymous front 2009 Jun   1 1 Double quotes are not handled properly in subqueries
  SQLite version 3.6.14.2
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> CREATE TABLE "FOO" ("BAR");
  sqlite> SELECT "Q"."BAR" FROM (SELECT "BAR" FROM "FOO") "Q";
  SQL error: no such column: Q.BAR
  sqlite> SELECT "Q"."BAR" FROM (SELECT BAR FROM "FOO") "Q";
  sqlite>

This defect breaks a lot of queries and views in our application. Version 3.6.12 works fine.

Problem introduced by check-in [6597] . Already fixed in CVS by check-in [6681] .
 
3892 website closed 2009 Jun anonymous   2009 Jun   5 5 typo on download page
"The is the recommended source" should be "This is the recommended source"
Thanks. Fixed here:

  http://www.sqlite.org/docsrc/ci/0f6eae0c0dab8eccd526f61c12bb9b625a01c62a
 
3891 code fixed 2009 May anonymous cli 2009 May   3 3 NULL-dereference after failed realloc, and leak
in shell.c's multireplace, I see this:

    if( (nOut+nCopy)>nMalloc ){
      nMalloc = 16 + (nOut+nCopy)*2;
      zOut = (char *)sqlite3_realloc(zOut, nMalloc);
    }
    assert( nMalloc>=(nOut+nCopy) );
    memcpy(&zOut[nOut], zCopy, nCopy);

That appears to have two problems:

    p = realloc (p, ...

leaks whenever realloc fails. I noticed that sqlite3_realloc is documented to be able to return NULL and not to free its first argument when it does that, so it seems to be just as susceptible as realloc is.

However, more importantly, when the above sqlite3_realloc call returns NULL, the subsequent memcpy (deref of zOut) will segfault.

 
3890 code closed 2009 May anonymous   2009 Jun   1 1 synchronous=full hides newly created table from 2nd connection
The following C code demonstrates a curious case where "pragma synchronous=full" hides a newly created table from a 2nd database connection.

This is surprising, since "full" is the default synchronous mode and I would expect that it should have no effect on a newly created database.

The problem was detected by a database wrapper which automatically applies a number of PRAGMA settings to initialize newly opened databases.

Please see comment below for details.

  void check (sqlite3* db, int rc){
    if( rc != SQLITE_OK && rc != SQLITE_DONE ){
      printf ("%d - %s", rc, sqlite3_errmsg(db) );
    }
  }

  int main(int argc, char* argv[])
  {
    const char *fn = "test.db3";
    sqlite3* Db1;
    sqlite3* Db2;
    sqlite3_stmt *pStmt;

    remove( fn );

    check(Db1, sqlite3_open(fn, &Db1) );
    check(Db2, sqlite3_open(fn, &Db2) );

    /* After the next line is executed, the new table t created from connection
    ** Db1 is not visible to connection Db2. select * from t (below) returns
    ** SQLITE_SCHEMA, no such table: t.
    **
    ** Without this line, table t is visible and no error is returned. */
    check(Db2, sqlite3_exec(Db2, "pragma synchronous=full", NULL, NULL, NULL));

    check(Db1, sqlite3_exec( Db1, "create table t(c)", NULL, NULL, NULL));

    check(Db2, sqlite3_prepare( Db2, "select * from t", -1, &pStmt, NULL));
    if (pStmt)
      check(Db2, sqlite3_finalize( pStmt ));

    printf ("\nDone");
    scanf ("*%s");

    return 0;
  }
2009-May-31 17:25:06 by drh:
This is not a bug.

The SQLite parser does not check for changes to the schema before it parses a new SQL statement. So if the new SQL statement makes use of tables or indices or views or anything else that did not exist the last time the schema was examined, the new SQL statement will not compile. Errors from the parser are based on the schema as SQLite last saw it.

In the example given without the PRAGMA statement, Db2 has never looked at the schema in the first place. And if that is so, the schema is examined prior to parsing the SQL statement. So it is not the PRAGMA that is making it fail. Any SQL statement at that some place would have the same effect.

If you make schema changes in one database connection, then want to use those changes in a second connection, the only sure what to do so is to first run some innocuous SQL statement in second connection to force SQLite to reexamine the schema.


2009-May-31 20:52:45 by anonymous:
I would like to add to previous report that some pragma statements prevents in Db2 to see schema changes (auto_vacuum, cache_size) but not all. You write that PRAGMA is making it work but it is other way around. Using pragma making it not work.


2009-May-31 21:23:47 by drh:
Only pragmas that access the database file (and hence cause the schema to be loaded) will cause the problem. You are correct that I inverted the meaning in my sentence. I'll go back and correct that....


2009-Jun-01 06:33:41 by anonymous:
Can you please explain why this can't be reproduced with sqlite3.exe because it is working.


2009-Jun-03 15:20:02 by anonymous:
The above behavior does not show in sqlite3.exe because internally it calls sqlite3_prepare() again after it returned SQLITE_SCHEMA. This makes the error go away and hides it from the CLI. You can see how this works when debugging sqlite3_exec(), which does all the work.

See the documentation for how to handle SQLITE_SCHEMA errors gracefully using sqlite3_prepare_v2().

 
3889 todo closed 2009 May anonymous func 2009 May   1 1 UPDATE TRIGGER works in all records
After an UPDATE in a record I want the update time stored in a column of this record - the problem is that the trigger I use doesn't work only in this record but in all others
SQLite is working correctly here. The error is in your script. Please submit your problem to the sqlite mailing list (sqlite-users@sqlite.org) for additional help.
 
3888 code fixed 2009 May anonymous   2009 May drh 5 5 Typo in [6994]
I have no idea what testcase is, but this seems wrong:

  -        testcase( pTest->op==TK_COLUMN || pTest->op==TK_REGISTER );
  +        testcase( pTest->op==TK_COLUMN );
  +        testcase( pTest->op==TK_COLUMN );

[6694]

2009-May-30 22:53:29 by drh:
The purpose of the testcase() macro is explained under section 7.0 of http://www.sqlite.org/testing.html

Thanks for point out this typo. The extra testcase() is redundant, obviously, but also harmless. I will remove it at the next check-in.

 
3887 code fixed 2009 May drh front 2009 May   4 1 Collating sequence ignore for min()/max() with more than 32 arguments
The min() and max() functions with 2 or more arguments work as scalars, not as aggregates. They return the minimum or maximum of the arguments given, where the min or max is determined using the collating sequence of the left-most argument that has a collating sequence. But if the first argument to have a collating sequence is the 33rd or greater argument, the collating sequence is ignored completely. Example:

   CREATE TABLE t1(x TEXT COLLATE nocase);
   INSERT INTO t1 VALUES('B');
   SELECT max(1,2,3,4,5,6,7,8,9,10,
              11,12,13,14,15,16,17,18,19,20,
              21,22,23,24,25,26,27,28,29,30,
              31,'a',x) FROM t1;

The above will return 'a'. But the following:

   SELECT max(1,2,3,4,5,6,7,8,9,10,
              11,12,13,14,15,16,17,18,19,20,
              21,22,23,24,25,26,27,28,29,30,
              'a',x) FROM t1;

returns 'B'. 'B' is the correct result in both cases.

 
3886 doc closed 2009 May anonymous func 2009 Oct   4 5 Unclear documentation regarding built-in function overriding
Documentation states: The first application-defined function with a given name overrides all built-in functions in the same database connection with the same name. Subsequent application-defined functions of the same name only override prior application-defined functions that are an exact match for the number of parameters and preferred encoding.

I override LIKE with nArg=2, ESCAPED LIKE does not become overridden.

DRH hints in ticket 3345: 2008-Aug-31 12:34:58 by drh: To overload a built-in function, specify the same number of arguments in the sqlite3_create_function() call as the original built-in function has. It is OK to call sqlite3_create_function() mulitple times with the same function name and a different number of parameters each time.

Documentation seems to be incorrect.

I don't challenge the current behavior of SQLite (regarding arguments number), but correcting documentation would be nice.

2009-Oct-04 21:10:58 by anonymous:
Now http://www.sqlite.org/src/tktview/4776dee07aa8026fa2eaeed947bd65e2e5f545ec
 
3885 build closed 2009 May anonymous   2009 May   1 1 tclsqlite for linux64
I got the precompiled binary for Linux tclsqlite-3.6.14.2.so but for my Linux/Fedora 2.6.27.21-170.2.56.fc10.x86_64 I have: > tclsh % load ./tclsqlite-3.6.14.2.so Sqlite3 couldn't load file "./tclsqlite-3.6.14.2.so": ./tclsqlite-3.6.14.2.so: wrong ELF class: ELFCLASS32

How can I resolve it?

regards E. Rossetti

2009-May-29 10:59:13 by drh:
This sounds like a support request, not a bug report. Please use the SQLite mailing list for support and preserve tickets for reporting bugs.
 
3884 code closed 2009 May anonymous back 2009 Jun   1 1 Gettting 'disk image malformed' error
I using sqlite-3.5.9 and observing a 'disk image malformed' error after executing several sql statements. After debugging found that the in sqlite3BtreeInitPage() it returns with SQLITE_CORRUPT_BKPT based on some condition (see below)...
 SQLITE_PRIVATE int sqlite3BtreeInitPage(
  MemPage *pPage,        /* The page to be initialized */
  MemPage *pParent       /* The parent.  Might be NULL */
 ){
      ...
      if( pPage->nCell==0 && pParent!=0 && pParent->pgno!=1 ){
      /* All pages must have at least one cell, except for root pages */
      return SQLITE_CORRUPT_BKPT;
      }
      ...
 }

So I have some doubts, is this condition required? if required what does it checks? Also if you have any workaround, please let me know. Please let me know from which version of sqlite this bug has been resolved. I tested this bug with sqlite-3.6.4. and with that I am no more observing this bug.

Thank you in advance.

2009-May-29 10:58:21 by drh:
SQLite is returning SQLITE_CORRUPT because you have a corrupted database file, not because of any bug in SQLite. Please use the mailing list for help in debugging your problem.


2009-Jun-03 13:53:52 by anonymous:
Hi,

Can you please let me know on which mailing-list should I post further queries for this bug.

Thank you.


2009-Jun-03 14:31:44 by drh:
sqlite-users@sqlite.org


2009-Jun-12 10:54:38 by anonymous:
Hi, I have registed with sqlite-users@sqlite.org mailing list but still my messages are not getting updated. Please help. Thank you.
 
3883 code fixed 2009 May anonymous back 2009 May   1 1 TOCTOU pager bug in 3.6.14.2
We are seeing an intermittent race condition between two or more processes when trying to access the same DB. It appears that one process has a TOCTOU (time of check, time of use bug) where it sees that the journal exists but before it tries to use it another process plays it back an removes it.

The following is a reproducer:

- In pager.c, hasHotJournal, add a sleep line 3386:

   rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS,
&exists);
   if( rc==SQLITE_OK && exists ){
       sleep(10);

- build the sqlite shell

Start 2 sqlite shells on the same DB. In the first shell: create table test(test integer); begin immediate; In the second shell: begin immediate; This should pause because of the "sleep" added above. While still paused, got back to the first shell and: commit; Then go back to the second and wait: You should get this error in the second shell: SQL error: unable to open database file

Another interesting possibility: if you don't do the "create table", then the "commit" will return with "database is locked", which is strange (but doesn't cause a crash, instead it causes a wait)

The patch given solved the problem for us. Thanks!
 
3882 code closed 2009 May anonymous back 2009 May   1 3 On sparc/linux, sqlite-3.6.14.x series can generate a bus error.
With sqlite-3.6.14[.x] series, sqlite can trigger a bus error on sparc/linux, indicating a data misalignment. We discovered this from pysqlite, but using the sqlite test suite from sqlite-3.6.14.1.tar.gz, we have isolated it in sqlite-amalgamation-3.6.14.2.tar.gz to this:

The failing test is aggerror.test, and the sql which triggers the error is:

   update t1 set a=41 where a=40;

gdb points to sqlite3.c @ 30221, and the surrounding code is:


   30216   ** routine may not be called again.
   30217   */
   30218   SQLITE_PRIVATE int sqlite3RowSetNext(RowSet *p, i64 *pRowid){
   30219     rowSetToList(p);
   30220     if( p->pEntry ){
   30221       *pRowid = p->pEntry->v;
   30222       p->pEntry = p->pEntry->pRight;
   30223       if( p->pEntry==0 ){
   30224         sqlite3RowSetClear(p);
   30225       }


For reference, the corresponding Gentoo bug is: https://bugs.gentoo.org/show_bug.cgi?id=270867 (although the original description is incorrect --- I only thought I was using amalgamation source) the error reported here is from that amalgamation source for 3.6.14.2 running the test suite.

As best as we can tell, this is a regression from 3.6.13.

2009-May-28 15:23:13 by drh:
This appears to be a duplicate of ticket #3869. Already fixed by check-in [6666] . The fix will appears in the 3.6.15 release.


2009-May-28 16:25:27 by anonymous:
There is now a patch on the cited gentoo bug which allows the entire test suite to run without error using sqlite-3.6.14.2.
 
3881 code closed 2009 May anonymous back 2009 Sep   3 4 zeroblob function causes memory problems
The incremental BLOB IO API was designed to prevent large amounts of BLOB data from being loaded into main memory.

However - when calling zeroblob function (which is a necessary step before writing a BLOB of any size to the database), the SQLite DLL consumes the same amount of RAM memory as the size of the BLOB we are trying to write.

In order to reproduce this problem, please create a table with the following schema:

CREATE TABLE blobtest ( objId INTEGER PRIMARY KEY, bfield BLOB )

and try to insert a BLOB with the size of 100 MB to the table. You'll see (in the task manager) that the process immediatly grows by 100MB of memory when the zeroblob function is executed (it will happen when calling sqlite3_step() function).

Another related problem is that when doing a SELECT command for a table that has a blob column - like the following:

SELECT (bfield IS NOT NULL) AS bfield FROM blobtest

The SQLite DLL still allocates as much memory as the size of the BLOB column. This happens even though the only thing I wanted to know is whether the BLOB field is NULL or not.

In order to reproduce this problem - just run the sqlite command line utility and do the above select command. You'll immediatly see (in the task manager) that the sqlite utility grows by the amount of the BLOB size that was selected.

BTW - the same thing happens when calling the LENGTH function, like the following:

SELECT LENGTH(bfield) AS bfield FROM blobtest

IMO SQLite should store the size of the BLOB separately and not have to copy the entire BLOB to main memory just so that a function can count its bytes.

This may cause severe memory thrashing when working with databases that have many BLOB fields in them.

2009-Sep-29 07:50:27 by anonymous:
I have just tested all your queries and none of them have memory consumption increases in the range of the size of the blob. Closing.
 
3880 code closed 2009 May anonymous vfs 2009 Oct   1 2 incorrect return value when delete journaling file on WCE.
First sorry about my English. My English is too poor ^^.

Anyway in winDelete() in sqlite3.c. there are some problem at detecting result of delete file and return value. On WCE if file deleted at first DeleteFileW() call. GetLastError() return unknown previous error code. in my case it occurs when I delete journal file and it return ERROR_INVALID_PARAMETER(but file is deleted). And on 'while' will process GetLastError() cause rc is INVALID_FILE_ATTRIBUTES. So this winDelete() fucntion return SQLITE_IOERR_DELETE. because error is not ERROR_FILE_NOT_FOUND. I think if file deleted. GetFileAttributesW() will return INVALID_FILE_ATTRIBUTES. then there are no reason to check error code.

I think my explanation is too bad. but I think that if you see once code you can notice problem easy cause it is simplest mistake.

2009-May-26 04:00:37 by anonymous:
I check more detail and read document about GetFileAttributes(). But I don't understand why GetFileAttributes() isn't set correct error code when file doesn't exist on WCE.


2009-Oct-10 02:58:13 by anonymous:
Please repost this to the sqlite-users mailing list where other CE developers will be able to help understand the issue as well as see why they are not hitting the issue, but you are. Closing as this bug tracker is no longer used.
 
3879 code fixed 2009 May anonymous front 2009 May   1 4 Rows lost in sort
SQLite 3.6.14.1 appears to yield a different result from my application, which admittedly is rather complex. But I managed to isolate an example that looks quite wrong, as rows are lost after sorting:

  $ sqlite3
  SQLite version 3.6.14.1
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> .read cre14.sql
  sqlite> select stelling, sortering from vzet;
  26|153
  27|68
  28|-18
  29|19
  sqlite> select stelling, sortering from vzet order by sortering;
  26|153
  sqlite>

The complexity is hidden in the view. It includes a join of several tables and the sort column is an expression. Still it is a minimal example, any simplification makes the problem disappear. The definition of the view and the setup of the data will be attached or can be viewed at ticket090525.

Anonymously yours, EP.

2009-May-25 11:18:54 by drh:
Simplified test case:

  CREATE TABLE t1 (a PRIMARY KEY, b);
  INSERT INTO t1 VALUES ('w',  1);
  INSERT INTO t1 VALUES ('z', -1);

  CREATE TABLE t2 (m INTEGER PRIMARY KEY, n, a, p);
  INSERT INTO t2 VALUES (25, 13, 'w', 1);
  INSERT INTO t2 VALUES (26, 25, 'z', 153);
  INSERT INTO t2 VALUES (27, 25, 'z', 68);

  CREATE TABLE t3 (m);
  INSERT INTO t3 VALUES (25);

  SELECT 111,
         t1.b*123
    FROM t3, t2 AS j0, t2 AS j1, t1
   WHERE j0.m=t3.m
     AND t1.a=j0.a
     AND j1.n=j0.m;

  SELECT 222,
         t1.b*123
    FROM t3, t2 AS j0, t2 AS j1, t1
   WHERE j0.m=t3.m
     AND t1.a=j0.a
     AND j1.n=j0.m
   ORDER BY t1.b;

Problem introduced by check-in [6538] in version 3.6.14.

 
3878 code closed 2009 May anonymous   2009 May   1 1 lower / lower case problem with UNICODE
select cnt_descr ,lower( cnt_descr ) as lower_cnt_descr ,upper( cnt_descr ) as upper_cnt_descr ,substr( cnt_descr, 1, 2 ) as substr_cnt_descr ,(select src_descr from source where src_code = 'insure') as src_descr , substr( cnt_code, 1, 2 ) cnt_code , count( 1 ) cnt from content where src_code = 'insure' group by substr( cnt_code, 1, 2 ) , substr( cnt_descr, 1, 2 ) order by 1

RESULT:

[cnt_descr] => аварийная гарантия

            [lower_cnt_descr] => пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ

            [upper_cnt_descr] => пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ

            [substr_cnt_descr] => ав

            [src_descr] => Словарь по страхованию

            [cnt_code] => av

            [cnt] => 16

________________

Please see FAQ #18: http://www.sqlite.org/faq.html#q18
 
3877 code closed 2009 May anonymous func 2009 May   1 5 substr problem
SQLite version 3.5.9

Enter ".help" for instructions

sqlite> select substr('abcde',0,2);

ab

________________________

SQLite version 3.6.13

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> select substr('abcde',0,2);

a

i transfer my sites to new server and got this problem.

2009-May-24 10:45:16 by drh:
The 3.5.9 behavior is incorrect. The bug was fixed in release 3.6.11. See ticket #3628.


2009-May-24 16:19:03 by anonymous:
1. The bug was fixed in release 3.6.11.

2. bug was NOT fixed in release 3.6.13.

Look on this -

select sqlite_version();

3.6.13

____

select substr('abcde',0,2);

a


2009-May-24 21:07:02 by anonymous:
The behavior of 3.6.13 is correct - substr('abcedf',0,2) should indeed return 'a'. The fact is that 3.5.9 had a bug and you have code depending on the bug. The proper fix is to adjust your code to use substr('xyzvw',1,2), ie. indexes starting from one and not zero.
 
3876 doc fixed 2009 May anonymous   2009 May   4 3 Documentation for sqlite3_create_function and H16124
http://sqlite.org/c3ref/create_function.html says about nArg:

If this parameter is negative, then the SQL function or aggregate may take any number of arguments.

http://sqlite.org/hlr10000.html#H16124 says:

... interface shall fail with an error code of SQLITE_ERROR if parameter N is less than -1 or greater than 127 ...

The code follows H16124 although the upper bound is SQLITE_MAX_FUNCTION_ARG which could be different than its default of 127.

To correct things the doc page needs to say "If this parameter is minus one ..." and H16124 needs to be clear that 127 is actually the default value of a #define.

 
3875 code fixed 2009 May anonymous   2009 May   4 3 Changes in error reporting for function registration
In current CVS (after the 3.6.14.1 release) error reporting when registering a function has changed, in particular when nArg is too large in the call to sqlite3_create_function().

In 3.6.14.1 and earlier releases, SQLITE_ERROR is returned. Current CVS is now returning SQLITE_MISUSE and also failing to set any error text so you just get "not an error".

In any event http://sqlite.org/hlr10000.html#H16124 states that SQLITE_ERROR is the correct code to return.

The SQLITE_MISUSE return code makes more sense in this context. The documentation has been updated.


2009-May-24 19:47:54 by anonymous:
I wasn't too explicit, but there still remains the issue that the error text is "not an error". Should this error condition ever arise, it certainly won't help the user. (Note that these days the user rarely directly interacts with SQLite but usually has some sort of wrapper and other programming language in the way, so they won't be that familiar with all the constraints on registering functions.)

Also changing to report MISUSE instead of generic ERROR changes the behaviour of SQLite - it may bite people who are using shared libraries.


2009-May-24 22:02:01 by drh:
Our reasoning is that no correct program will ever invoke sqlite3_create_function with a 3rd argument of less than -1 or greater than 127 in the first place. (I have adjusted the documentation to say that if the 3rd parameter is less than -1 or greater than 127 then the behavior is undefined.)

That is the original intent of the design, though poorly expressed. We currently return SQLITE_MISUSE (formerly SQLITE_ERROR) rather than segfault since we felt like that might be more helpful to people as they attempt to debug their code. But it has always been our idea that if you invoke sqlite3_create_function() with a number of arguments less than -1 or greater than 127, you have a bug in your program.

 
3874 xplatform closed 2009 May anonymous   2009 Oct   3 2 Missing proper file locking on Hurd
Hi,
As reported on http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529734 , SQLite doesn't know about Hurd. It tries to handle it as a Linux box, but without proper locking any write access fails.
Please find the suggested patch above. User reports it fixes this issue.
Regards, Laszlo/GCS (Debian maintainer of SQLite)
2009-Oct-12 21:12:59 by anonymous:
Debian tracker says fixed.
 
3873 build closed 2009 May anonymous   2009 Oct   1 1 WinCE and Pelles C x64 build errors/warnings
1.) Build problem with MinGW32CE on Windows (4.1.0):

arm-wince-mingw32ce-gcc -I. -I../../../../include -O2 -fomit-frame-pointer -D_WIN32_WCE -c ../../sqlite3.c -osqlite3.o ../../sqlite3.c: In function 'localtime': ../../sqlite3.c:26524: warning: integer constant is too large for 'long' type ../../sqlite3.c:27835:43: error: macro "GetDiskFreeSpaceW" passed 5 arguments, but takes just 0 ../../sqlite3.c: In function 'getSectorSize': ../../sqlite3.c:27831: warning: assignment makes integer from pointer without a cast

2.) Build problem with Pelles C / ARM:

pocc.exe -I. -Ze -Go -Ot -Tarm-coff -D_M_ARM -D_WINCE -DUNICODE -I../../../../include -D_WIN32_WCE -c ../../sqlite3.c -Fosqlite3.obj ../../sqlite3.c(10963): warning #2027: Missing prototype for 'localtime'. ../../sqlite3.c(10963): error #2168: Operands of = have incompatible types '(incomplete) struct tm *' and 'int'. ../../sqlite3.c(10964): error #2152: Unknown field 'tm_year' of '(incomplete) struct tm'. ../../sqlite3.c(10965): error #2152: Unknown field 'tm_mon' of '(incomplete) struct tm'. ../../sqlite3.c(10966): error #2152: Unknown field 'tm_mday' of '(incomplete) struct tm'. ../../sqlite3.c(10967): error #2152: Unknown field 'tm_hour' of '(incomplete) struct tm'. ../../sqlite3.c(10968): error #2152: Unknown field 'tm_min' of '(incomplete) struct tm'. ../../sqlite3.c(10969): error #2152: Unknown field 'tm_sec' of '(incomplete) struct tm'. ../../sqlite3.c(26518): error #2120: Redeclaration of 'localtime' previously declared at ../../sqlite3.c(10963): found '(incomplete) struct tm * __cdecl function(const unsigned long int *)', expected 'int __cdecl function()'. ../../sqlite3.c(26519): error #2149: Undefined size for 'y' with type '(incomplete) struct tm'. ../../sqlite3.c(26519): error #2149: Undefined size for 'y' with type '(incomplete) struct tm'. ../../sqlite3.c(26529): error #2152: Unknown field 'tm_year' of '(incomplete) struct tm'. ../../sqlite3.c(26530): error #2152: Unknown field 'tm_mon' of '(incomplete) struct tm'. ../../sqlite3.c(26531): error #2152: Unknown field 'tm_wday' of '(incomplete) struct tm'. ../../sqlite3.c(26532): error #2152: Unknown field 'tm_mday' of '(incomplete) struct tm'. ../../sqlite3.c(26533): error #2152: Unknown field 'tm_hour' of '(incomplete) struct tm'. ../../sqlite3.c(26534): error #2152: Unknown field 'tm_min' of '(incomplete) struct tm'. ../../sqlite3.c(26535): error #2152: Unknown field 'tm_sec' of '(incomplete) struct tm'. ../../sqlite3.c(27831): error #1053: Disagreement in number of macro arguments. ../../sqlite3.c(27831): warning #2027: Missing prototype for 'GetDiskFreeSpaceW'. ../../sqlite3.c(90665): warning #2154: Unreachable code. ../../sqlite3.c(26496): warning #2135: Static 'utf8ToMbcs' is not referenced. ../../sqlite3.c(26352): warning #2135: Static 'sqlite3_os_type' is not referenced.

3.) Warnings with Pelles C x64 mode:

pocc.exe -I. -Ze -Go -MT -Ot -I../../../../include /Tamd64-coff -c ../../sqlite3.c -Fosqlite3.obj ../../sqlite3.c(37823): warning #2115: Local 'rc' is initialized but never used. ../../sqlite3.c(45703): warning #2115: Local 'db' is initialized but never used. ../../sqlite3.c(49364): warning #2115: Local 'vals' is initialized but never used. ../../sqlite3.c(56419): warning #2115: Local 'rc' is initialized but never used. ../../sqlite3.c(58559): warning #2115: Local 'pNewExpr' is initialized but never used. ../../sqlite3.c(63264): warning #2115: Local 'pOld' is initialized but never used. ../../sqlite3.c(69525): warning #2115: Local 'regRecord' is initialized but never used. ../../sqlite3.c(69524): warning #2115: Local 'regData' is initialized but never used. ../../sqlite3.c(84292): warning #2115: Local 'pFinal' is initialized but never used. ../../sqlite3.c(90665): warning #2154: Unreachable code.

Brgds, vsz

2009-Oct-12 21:14:36 by anonymous:
See the FAQ, numerous tickets and endless mailing list postings.
 
3872 code fixed 2009 May drh back 2009 May   1 1 Incomplete shutdown of the default pcache implementation
When the default pager cache implementation (pcache1.c) is used, it is initialized correctly by sqlite3_initialize() but it is not shutdown by sqlite_shutdown(). If after the sqlite3_shutdown() an alternative pager cache is installed using sqlite3_config(SQLITE_CONFIG_PCACHE,...) and the system is restarted, calls to sqlite3PageAlloc() attempt to use the original pcache1.c pager cache mechanism. This can result in non-threadsafe behavior and/or crashes, depending on how mutexing is configured.
 
3871 code closed 2009 May danielk1977 front 2009 May   1 1 vtab logic fails to optimize some WHERE ... OR ... clauses.
Even if a virtual table can optimize WHERE expressions of the form "a = ?", it fails to optimize "a = ? OR a = ?". However, assuming the virtual table can also optimize "b = ?", it may optimize "a = ? OR a = ? OR b = ?".

The problem is that "a = ? OR a = ?" is being transformed by SQLite to "a IN (?, ?)", and virtual tables cannot optimize expressions involving the IN() operator. The attached test script demonstrates the problem.

 
3870 doc fixed 2009 May anonymous   2009 May   5 3 total_change_count documentation typo
The description of the total_change_count function at http://www.sqlite.org/c3ref/total_changes.html has an incorrect sentence.

I think the phrase "The count does not rows of views..." should be more like "The count does not include rows of views..." or something similar.

 
3869 code fixed 2009 May anonymous front 2009 May   1 3 Alignment error on HP-UX 11.23/IA, 11.31/IA
While running "gmake -k test" on HP-UX 11.23/IA and HP-UX 11.31/IA, the following error occurs:

  ./testfixture ./test/veryquick.test
  aggerror-1.1... Ok
  aggerror-1.2... Ok
  aggerror-1.3... Ok
  aggerror-1.4...gmake: *** [test] Bus error (core dumped)

gdb gives:

  $ gdb ./testfixture core
HP gdb 5.9 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.9 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `testfixture'.
Program terminated with signal 10, Bus error.
BUS_ADRALN - Invalid address alignment. Please refer to the following link that helps in handling unaligned data: http://docs.hp.com/en/7730/newhelp0610/pragmas.htm#pragma-pack-ex3
#0  0x40e4270:0 in sqlite3RowSetInsert (p=0x400d1cf8, rowid=40)
    at sqlite3.c:30028
30028     pEntry->v = rowid;
(gdb) where
#0  0x40e4270:0 in sqlite3RowSetInsert (p=0x400d1cf8, rowid=40)
    at sqlite3.c:30028
#1  0x412ec40:0 in sqlite3VdbeExec (p=0x400fb918) at sqlite3.c:54636
#2  0x4120390:0 in sqlite3Step (p=0x400fb918) at sqlite3.c:49100
#3  0x40b7640:0 in sqlite3_step (pStmt=0x400fb918) at sqlite3.c:49172
#4  0x40a7940:0 in DbObjCmd (cd=0x40099238, interp=0x400487a8, objc=3,
    objv=0x400ee118) at ./src/tclsqlite.c:1785
#5  0x60000000ca3a55d0:0 in TclEvalObjvInternal ()
...
2009-May-21 22:03:44 by anonymous:
The problem is that *p->pFresh is not aligned to an 8-byte boundary. How do we ensure that *p->pFresh is aligned correctly? If I modify sqlite3RowSetInit() and change:

  p->pFresh = (struct RowSetEntry*)&p[1];

to:

  p->pFresh = (struct RowSetEntry*)&p[ROUND8(1)];

then the testsuite gets farther. But, I imagine we'd need to increase the amount of memory alloc'ed to pMem->zMalloc to compensate for the additional 7 bytes unused.

 
3868 code closed 2009 May anonymous   2009 May   1 3 sqlite3AtoF is wrong
  #include <stdio.h>
  #include <math.h>

  int sqlite3AtoF(const char *z, double *pResult);

  int main() {
    double d;
    sqlite3AtoF("1.1400000000000001", &d);
    printf("%.20f\n", d);
    printf("%.20f\n", atof("1.1400000000000001"));
  }

this code prints:

  1.13999999999999990000
  1.14000000000000010000

obviously sqls also return wrong results

2009-May-21 14:16:03 by drh:
You got 16 digits of precision on a 64-bit IEEE 754 float, which only promises 15.955 digits of precision. So you are already ahead of the curve. This is not a bug.

FWIW, sqlite3AtoF() and atoi() give identical answers on linux x86 using gcc 4.1.0. Test program:

  #include <stdio.h>
  #include <math.h>
  #include <stdlib.h>
  int sqlite3AtoF(const char*, double*);
  int main(int argc, char **argv){
    double r1, r2;
    unsigned long long int x1, x2;
    int i;
    for(i=1; i<argc; i++){
      const char *z = argv[i];
      r1 = atof(z);
      sqlite3AtoF(z, &r2);
      memcpy(&x1, &r1, sizeof(r1));
      memcpy(&x2, &r2, sizeof(r2));
      printf("atof:  0x%16llx  %.30f\n", x1, r1);
      printf("AtoF:  0x%16llx  %.30f\n", x2, r2);
    }
    return 0;
  }

The above program was compiled and run as follows:

  drh@elly:~/sqlite/bld> gcc -DSQLITE_PRIVATE= t1.c sqlite3.c -ldl -lpthread
  drh@elly:~/sqlite/bld> ./a.out 1.1400000000000001
  atof:  0x3ff23d70a3d70a3e  1.140000000000000124344978758018
  AtoF:  0x3ff23d70a3d70a3e  1.140000000000000124344978758018
 
3867 code fixed 2009 May anonymous cli 2009 May   4 4 dump of certain database creates sqlite_sequence insertion too early
I previously reported this bug at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=496895 but it seems it was never forwarded upstream.

I have a database, that I'm not sure how exactly I arrived at it except that it was created by the f-spot photo management application, which if dumped creates sql statements containing this:

DELETE FROM sqlite_sequence;
INSERT INTO "sqlite_sequence" VALUES('photos',3829);
CREATE TABLE photos (
id                 INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
time               INTEGER NOT NULL,
uri                STRING NOT NULL,
description        TEXT NOT NULL,
roll_id            INTEGER NOT NULL,
default_version_id INTEGER NOT NULL,
rating             INTEGER NULL
);
Once I vacuum the database, dumping it correctly creates sql that creates and fills the photos table before touching sqlite_sequence for it.

Since the database contains somewhat private data, and vacuuming it makes the problem go away, I'm not providing the file here. I will, however, provide it to a developer on request to reproduce the problem.

 
3866 code closed 2009 May anonymous ext 2009 May anonymous 4 4 Make ext/async/sqlite3async.h includable to C++
The ext/async/sqlite3async.h header is missing a

  /*
  ** Make sure we can call this stuff from C++.
  */
  #ifdef __cplusplus
  extern "C" {
  #endif
  #ifdef __cplusplus
  }  /* End of the 'extern "C"' block */
  #endif

define to allow it to be included from C++

Thanks.
 
3865 code fixed 2009 May drh back 2009 May   1 1 Database corruption following VACUUM on >4GiB database file
A 32-bit integer overflow introduced at check-in [4896] (SQLite version 3.5.8) causes irreparable corruption of database files that remain larger than 4GiB after VACUUM. This bug was fixed when the relevant code was refactored as part of check-in [6241] (SQLite version 3.6.11).

Curiously, this bug was fixed long before we even knew it existed. The bug has only come to light within the past week but has been fixed for over three months.

This problem was not picked up by static analysis. It was not seen in run-time testing because none of the test cases are run on databases that are 4GiB or larger in size after vacuuming.

The problem has already been fixed. The purpose of this ticket is to document the problem.

 
3864 code closed 2009 May anonymous   2009 May   2 1 Wrong result set
a query on a table return a wrong dataset; I think it's a problem with a index on that table, but however SQLite engine cannot invent data for records; using analyze, vacuum, and other commands, db return to work fine. I attach damned database and a sample doc.

  regards
2009-May-18 23:18:49 by drh:
Looking at the screen dumps sent by the OP by private email, I see that the database file is corrupt.

Probably the REINDEX command will fix it, based on what I saw in the screen dump.

 
3863 code fixed 2009 May drh front 2009 May   4 1 Memory leak following ill-formed SQL
The following SQL leaks memory (in addition to generating an error):

    CREATE TABLE t1(a,b);
    INSERT INTO t1 VALUES(1,2);
    CREATE TABLE t2(n);
    CREATE TRIGGER r21 AFTER INSERT ON t2 BEGIN
      SELECT a FROM t1 WHERE a>new.x UNION ALL
      SELECT b FROM t1 WHERE b>new.x ORDER BY 1 LIMIT 2;
    END;
    INSERT INTO t2 VALUES(6);
 
3862 code fixed 2009 May anonymous   2009 May drh 5 5 debug code checked in [6642]
[6642]

     if( checkForMultiColumnSelectError(pParse, pDest, pEList->nExpr) ){
  +static int cnt = 0;
  +cnt++;
       return;
     }
 
3861 code closed 2009 May anonymous func 2009 May a.rottmann 3 1 I am not able to use variables with INSERT
I am using sqlite3 embedded in C language, and i am decalring a variable for example int x=1; and than when i try to use this variable in INSERT for example INSERT VALUE (x), it is compiling correctly but i am not getting the value of x in the table, but i am getting a NULL value.
2009-May-16 17:21:39 by drh:
This is not a bug in SQLite. Please seek help on the mailing list sqlite-users@sqlite.org.
 
3860 build fixed 2009 May anonymous build 2009 May   1 2 Compilation fails with Apples llvm-gcc-4.2
sqlite3 doesn't compile with Apples llvm-gcc-4.2. It gives me the attached error. I found this by trying to build Mozilla Thunderbird 3 with Apples llvm-gcc-4.2 (Bug 492843 at bugzilla.mozilla). So I need this fix to be able to build Mozilla related code with Apples llvm-gcc-4.2.
2009-May-18 06:02:53 by anonymous:
Small typo. Comment starting: "We we have to ..." should probably be: "So we have to ...". HTH, TC
 
3859 code closed 2009 May anonymous func 2009 Oct   1 1 sqlite3_prepare returns SQLITE_BUSY but problem is on Windows level
Our SQLite DB files reside on NAS. When our application tries to access the DB file over the network, Windows reports a system error, such as "disconnected". However, SQLite APIs (notably sqlite3_prepare()) reports SQLITE_BUSY indefinitely resulting in our application's failure to properly recognize the actual error condition.

Code snippets are available upon request.

2009-Oct-18 07:50:37 by anonymous:
See the FAQ - yet another reason why you should not use SQLite over the network.
 
3858 code closed 2009 May danielk1977 back 2009 May danielk1977 1 1 backup db corrupted if source is updated during backup operation
Usually, if a source database is updated by an external connection while it is being backed up, the backup operation is automatically restarted by the next call to sqlite3_backup_step(). However, if the cache associated with the backup database is completely empty when sqlite3_backup_step() is next called, the backup is not being restarted and a corrupt backup database is produced.

The cache associated with the backup database may become empty mid-backup as a result of a call to sqlite3_release_memory(), or simply because the pcache implementation released or reused the associated cached pages.

 
3857 code active 2009 May anonymous   2009 May   3 3 Lemon parser generator: No configurable location for lempar.c
While working on the Gentoo ebuild for the Lemon parser generator, I found that I had to patch the sources in order to get lemon to look in /usr/share/lemon for its default parser template file, lempar.c. Lemon appears to look in the directory of the grammar file it's working on, and possibly its own directory, for this file. When it is installed in a directory in the $PATH it appears to also look in the $PATH. The $PATH is not a very good place to install this file, as it is only for executables. Lemon should look for this file in a location configurable at compile time or it will be difficult for distributions to package it. There is at least one program, namely the Netsurf web browser, which needs lemon in order to compile and does not provide its own lempar.c. Please fix this. Related bug: #1656
 
3856 warn closed 2009 May anonymous   2009 Oct   4 1 compiler warning on x86 (Visual Studio 2005)
Line 37332 of the amalgamation...

sqlite3.c(37332) : warning C4244: '+=' : conversion from '__w64 int' to 'u32', possible loss of data

2009-Oct-04 23:24:07 by anonymous:
See the FAQ
 
3855 code closed 2009 May anonymous func 2009 May shane 2 2 Problem width compatibility version 3.6.14 width 3.6.13 (<)
My database will be creating: sqlite3_open_v2(Name, &database, SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE) ;

and always success opening sqlite3_open_v2(Name, &database, SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_READWRITE) ;

but width version 3.6.14 - can not opening

2009-May-12 12:27:56 by shane:
Is this on Windows? It may be related to ticket http://www.sqlite.org/cvstrac/tktview?tn=3821 On Windows, SQLITE_OPEN_EXCLUSIVE was not being handled correctly. SQLite uses SQLITE_OPEN_EXCLUSIVE to make sure that a new file is created (ie. doesn't already exist). SQLite doesn't use it to indicate "exclusive access" as it is usually understood.


2009-May-12 13:00:48 by shane:
The documentation is going to be updated to indicate that the SQLITE_OPEN_EXCLUSIVE is for the internal use of SQLite and that it has the same meaning as the O_EXCL flag to open() in Unix.

You should modify your code to not pass the SQLITE_OPEN_EXCLUSIVE flag to sqlite3_open_v2().

 
3854 code closed 2009 May anonymous tcl 2009 May   4 4 Tcl Interface does not recognize dbcmd in "sqlite 3 dbcmd name"
The "new Tcl command" that is suppose to be created to control the database seems not to work. If sqlite3 is entered with one parameter that parameter is treated as the database name. I downloaded the interface and unzipped it but it doesn't seem to make any difference if I downloaded it or not. Works the same if it is not present so something is broke or I didn't install it correctly but since 3.6.14 is new thought I would raise a flag in case something did break.

(sqlite-3_6_14) 1 % sqlite3 db1 test1.db

SQL error: near "test1": syntax error

(sqlite-3_6_14) 2 %

2009-May-11 23:44:22 by drh:
The primary test suite for SQLite (488 files of test data, 1.8 million test case, 7.7 MB of script) is build atop the the "sqlite3" TCL command. And all 1.8 million test cases passed on 5 different platforms (win32, win64, mac, linux, linux x86_64) before we released 3.6.14. If there is any one part of SQLite that is the most heavily tested, it surely must be the "sqlite3" TCL command.

So I'm guessing you have an installation problem. Please bring the matter up on the mailing list and perhaps you can get some help there.

 
3853 secure closed 2009 May anonymous front 2009 Jun   1 1 Crash when inserting
Given this table:

CREATE TABLE calendar (
  id integer default -1,
  uid integer not null,
  name text not null,
  color text default 'navy',
  config text default '',
  constraint calendar_pk primary key (id, uid),
  constraint uid_fk foreign key (uid) references user (id)
     on delete cascade
     on update cascade
     on insert cascade
);
CREATE TRIGGER compute_id after insert on calendar
begin
    update calendar set id = (select max(id) + 1 from calendar)
     where id = -1;
end;
CREATE TRIGGER genfkey2_insert_referencing BEFORE INSERT ON calendar WHEN
    new.uid IS NOT NULL AND NOT EXISTS (
       SELECT 1 FROM user WHERE new.uid == id
    )
BEGIN
  SELECT RAISE(ABORT, 'constraint failed');
END;
CREATE TRIGGER genfkey2_update_referencing BEFORE
    UPDATE OF uid ON calendar WHEN
    new.uid IS NOT NULL AND
    NOT EXISTS (SELECT 1 FROM user WHERE new.uid == id)
BEGIN
  SELECT RAISE(ABORT, 'constraint failed');
END;
and this simple insert - field config is rijndael-256 encrypted:

insert into calendar (uid, name, color, config) values ('test','privat','navy','{�& �z�8��Uo�?���;�,^��ɍ�������9L�Nу&`n�����7��4�;nḺ�K�');
Using the command line interface causes a plain crash. Using the PDO sqlite extension from PHP gives the error message: HY000 1 unrecognized token: "'{�& �z"

Propability: Crash every time

Unable to reproduce.

Your INSERT statement is corrupted. Please consider putting your INSERT statement into a .TXT file and attaching it to the ticket.

 
3852 doc closed 2009 May anonymous   2009 Oct   5 4 H35230 requirement refers itself
This is H35230 text where this requirement refers itself:

H35230: If page 1 data is read as required by H35230, then the value of the page-size field that appears in the database file header that consumes the first 100 bytes of the read block is not the same as the connections current expected page size, then the expected page size is set to this value, the database file is unlocked and the entire procedure to open a read transaction is repeated.

Now http://www.sqlite.org/src/info/5483170346
 
3851 code closed 2009 May anonymous   2009 May   2 4 Table names no longer enclosed in brackets
Until Sqlite 3.6.13, doing "pragma foreign_key_list" returns the table names surrounded by brackets.

  SQLite version 3.6.13
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> pragma foreign_key_list('publication');
  0|0|[Section]|sectionId|id|RESTRICT|RESTRICT|NONE
  0|1|[Section]|language|language|RESTRICT|RESTRICT|NONE

As of 3.6.14, the brackets are lost.

  SQLite version 3.6.14
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> pragma foreign_key_list('publication');
  0|0|Section|sectionId|id|RESTRICT|RESTRICT|NONE
  0|1|Section|language|language|RESTRICT|RESTRICT|NONE

Is this a bug or from now on table names will have no brackets surrounding them?

The change is a bug fix. Version 3.6.13 was wrong. Version 3.6.14 provides correct behavior. See ticket #3800.
 
3850 new closed 2009 May anonymous test 2009 Oct   5 4 additional test
There used to be a memory leak in:

  create table t1(a int)
  create table t2(a int)
  select * from (select * from t1) left join t2 using(a)

The leak was corrected (probably by checkin [3529] ) but I don't see a test for it and it isn't mentioned in checkins comments, so possibly this case isn't tested.

 
3849 doc closed 2009 May anonymous func 2009 Oct   5 4 Mispelling in util.c
Line 862

  /* Walues  between 268435456 and 34359738367 */
2009-Oct-12 21:16:03 by anonymous:
Being fixed.
 
3848 code closed 2009 May anonymous   2009 Oct   1 1 unable to create a database with shell script running via cron/at
Hello,

I try to create a database with a shell script running via cron/at command. The database file is not created, the fs is writable. I run the cron/at under root account. From the console I am able to create the database file manually or with this script (see blow).

My shell script is:

#!/bin/sh

SQLITE=`which`

${SQLITE} /root/my.db "CREATE TABLE toto (idtoto TEXT PRIMARY KEY);"

exit 0

System: FreeBSD pbsd.muhc.mcgill.ca 6.4-RELEASE FreeBSD 6.4-RELEASE #0: Tue Dec 2 09:48:41 EST 2008 root@pbsd.muhc.mcgill.ca:/usr/obj/usr/src/sys/PATRIOTEBSD i386

sqlite3 was installed via the port collection: sqlite3-3.5.6

Thank you in advance for your help

L2F

2009-May-08 19:25:44 by anonymous:
Just a few remarks:

  • There is no sign of a bug (yet). Perhaps you'd better ask for help on the sqlite-users mailing list

  • You should make sure the sqlite executable can be reached via PATH. You may need to set PATH in your script as cron doesn't automatically apply ~/.profile

  • Shouldn't that be:

  SQLITE=`which sqlite3`

  • Perhaps you can catch any error messages by piping the cron output to a logfile? Or read the mail from cron to root?

  0 * * * * /root/myscript.sh >>/tmp/myscript.log 2>&1


2009-May-11 15:33:43 by anonymous:
Dear,

I did some mistake to copy my test drive:

Here the new one: > whoami root > crontab -l */5 * * * * /root/sqlite/sqlite.cron 1> /root/sqlite/test.log 2> /root/sqlite/test.err

> cat /root/sqlite/sqlite.cron #!/bin/sh

SQLITE=`which sqlite3`

${SQLITE} /root/my.db "CREATE TABLE toto (idtoto TEXT PRIMARY KEY);"

exit 0

> tail -f /var/log/cron May 11 08:36:00 pbsd /usr/sbin/cron[1019]: (root) RELOAD (tabs/root)

cat test.err /root/sqlite/sqlite.cron: /root/my.db: not found

==> error the db file must exists ??


2009-Oct-12 21:16:47 by anonymous:
Use the mailing list
 
3847 warn closed 2009 May anonymous vfs 2009 May   4 4 Warning on Mac OSX
sqlite3/sqlite3.c: In function 'proxyGetLockPath': sqlite3/sqlite3.c:25175: warning: unused variable 'err'

My proposal is to move the "int err = errno;" into the SQLITE_DEBUG to remove this warning.

Thanks.
 
3846 code closed 2009 May anonymous front 2009 Jul   4 4 join operators without join
This shouldn't be allowed:

  SQLite version 3.6.14
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t(a);
  sqlite> select * from t using(a);
  sqlite> select * from t on 1;
  sqlite>
 
3845 doc closed 2009 May anonymous   2009 May sdwilsh 1 1 sqlite3_table_column_metadata
how to retieves "default Values"? for example:varchar(10) default "abc"
2009-May-08 06:53:36 by danielk1977:
You will need to use "PRAGMA table_info".

  http://www.sqlite.org/pragma.html#pragma_table_info
 
3844 code closed 2009 May anonymous back 2009 May   1 1 Page cache not re-used after a pager_reset()
Our shop has a SQLite database which is shared between two processes. The first process will occasionally perform a massive update on the database, using multiple large transactions. If the second process updates the database during the massive update, we see the expected locking take place, allowing the second process to make it's update, and the first process resumes updating. Subsequently, memory utilization in the first process drops dramatically and the performance of the first process becomes abysmal.

We found that prior to the second process updating the database, the first process had fully loaded its page cache (pcache1Pagecount returns 1999), and was enjoying a 58% cache hit rate. When the second process updates the database, it results in a pager_reset() in the first process, which should flush the cache and build up a new one. We see the memory utilization drop, implying the pages have been freed. However, pcache1Pagecount starts at 1999, and quickly increases to 2006 or 2007 then remains constant. We see the hit rate go to 0%, and never rises again above 1%.

If another pager_reset() occurs, pcache1Pagecount will increase by another 8 or so pages, but performance remains abysmal.

The implication is that the pages in the page cache are not being re-used after the pager_reset(), and instead the pager allocates a few additional pages, and thereafter only works from that small pool.

FWIW, prior to 3.6.6, the call chain pager_reset() -> sqlite3PcacheClear() -> pcacheClear() appears to wipe out the hash table. With the introduction of the pache1.c source in 3.6.6, this does not occur, suggesting that there's a missing call to pcache1RemoveFromHash().

I'll continue investigating, but I'm hoping this rings some bells with someone, or perhaps they can give some suggestions on where to look.

2009-May-07 17:55:31 by anonymous:
The following one line change seems to address the problem. After the second process completes it's update, we see the page count drop back to zero after the pager_reset(), and the cache builds up again:

  static void pcache1TruncateUnsafe(
  PCache1 *pCache,
  unsigned int iLimit
  ){
    unsigned int h;
    assert( sqlite3_mutex_held(pcache1.mutex) );
    for(h=0; h<pCache->nHash; h++){
      PgHdr1 **pp = &pCache->apHash[h];
      PgHdr1 *pPage;
      while( (pPage = *pp)!=0 ){
        if( pPage->iKey>=iLimit ){
          pcache1PinPage(pPage);
          pcache1RemoveFromHash(pPage);     <--- Added ---->
          *pp = pPage->pNext;
          pcache1FreePage(pPage);
        }else{
          pp = &pPage->pNext;
        }
      }
    }
  }


2009-May-08 06:57:16 by danielk1977:
Thanks for investigating this. See [6619] .


2009-May-08 22:03:12 by anonymous:
Confirmed that Check-in 6619 resolves the problem. Thank you for your prompt attention!
 
3843 warn fixed 2009 May anonymous build 2009 May   4 2 Compiler warning inside sqlite-amalgamation
The sqlite3.c inside the amalgamation is missing #include <ctype.h> which causes warnings due to the use of isalnum() and similar functions. Adding the missing include, fixes 3 warnings to this effect.
2009-May-07 14:06:46 by danielk1977:
The calls to these functions are in the fts3 files.
 
3842 code closed 2009 May anonymous back 2009 May a.rottmann 1 1 Sqlite3_exec is crashing when I am retrieving 1450 plus messages
Hello, I am Tameez from Hyderabad India. I am using sqlit3 to store our some 4000 plus messages. During runtime, I am querying the database to retrieve the message given the "Message Number", I am successully able to retrieve the 1245 messages and after 1245 messages, SQLite is crashing sometimes in sqlit3_exec or sqlite3_close call. When I debugged sqlite3_exec, I found sqlit3_finalize is returning 7. Later on when its giving Access violation error and there by my integrated application crashes. I am opening and closing the database for each message retrieval.

I have written a simple exe to confirm is it application side issue or sqlite issue. In simple exe, Its working fine but in integrated application its not working.

Also, I cannot one time open or close the database , as the message request is asynchronous.

The architecture of our application is 1. sqlite library and its wrapper is present in one lib. 2. another custom library which is unique to each application will call this library or wrappers. 3. The end application calls the point 2 wrappers to call sqlite3.

Also, we have initialized the static structure of db in sqlite library (point 1).

Please give me workaround or immediate fix since the my product release is due in this may.

2009-May-07 11:31:22 by drh:
In your description, you indicate that everything works fine when SQLite is run separately from your application. This suggests that it is your application, not SQLite which harbors the bug.

The return code of 7 indicates that malloc() is failing. You are running out of memory. Probably what is happening is that some other part of your application is corruption the malloc() heap.

This appears to be a bug outside of SQLite that is corrupting the heap and then SQLite is stumbling over the corruption.

[TAMEEZ]. Please note that we are calling this function from FORTRAN. In the callback function we are dynamically allocating the buffer equivalent to length+1 of argv[0] using calloc. This is the one we are doing. Regarding running out of memory, I found using windows task manager memory is available.

 
3841 code fixed 2009 May anonymous   2009 May   1 1 group_concat bug with subselect
As reported on the mailing list:

The following example demonstrates what a bug in group_concat.

  CREATE TABLE table2 (key TEXT, x TEXT);
  CREATE TABLE list (key TEXT, value TEXT);

  INSERT INTO table2 VALUES ("a", "alist");
  INSERT INTO table2 VALUES ("b", "blist");
  INSERT INTO list VALUES ("a", 1);
  INSERT INTO list VALUES ("a", 2);
  INSERT INTO list VALUES ("a", 3);
  INSERT INTO list VALUES ("b", 4);
  INSERT INTO list VALUES ("b", 5);
  INSERT INTO list VALUES ("b", 6);

  SELECT
    table2.x,
    (SELECT group_concat(list.value)
      FROM list
      WHERE list.key = table2.key)
  FROM table2;

Output:

  alist|1,2,3
  blist|,4,5,6

I expected:

  alist|1,2,3
  blist|4,5,6
 
3840 warn active 2009 May anonymous build 2009 May   3 4 Missing header files in amalgamation
I build direct from the complete source code version (the one even "the SQLite developers do not use" according to the download page!), but I think this is a general issue since I've checked the pre-generated download also.

When the amalgamation is generated through mksqlite3c.tcl, trims out repeated #include lines. However, if this #include occurs within a #if... block, then the include file is only included when the conditional compile dictates. The example of this is ctype.h. In version 3.6.13, a #include <ctype.h> exists inside an #if block which only compiles if SQLITE_ASCII is not defined. However, ctype.h is required for the FTS3 functions but the #include line that is part of this source file is trimmed out because the build script thinks it has already been included.

For my build, I have simply patched the way mksqlite3c.tcl works (see patch below) so that it only marks an include file as "seen" if it seen at the top level - i.e. not inside an #if block. Its probably not the best solution, and almost certainly not the best tcl code, but it solves the problem for me.

P.S. I'm afraid I can't get the formatting right on the patch file, so let me know if you want me to email it instead.

Patch:


--- mksqlite3c.tcl (revision 4146)
+++ mksqlite3c.tcl (revision 4147)
@@ -134,8 +134,9 @@
# sqlite3.c output file. If any #include statements are seen,
# process them approprately.
#
+set deflevel 0
proc copy_file {filename} {
- global seen_hdr available_hdr out addstatic
+ global seen_hdr available_hdr out addstatic deflevel
set tail [file tail $filename]
section_comment "Begin file $tail"
set in [open $filename r]
@@ -158,11 +159,20 @@
section_comment "Continuing where we left off in $tail"
}
} elseif {![info exists seen_hdr($hdr)]} {
- set seen_hdr($hdr) 1
+ if {$deflevel == 0} {
+ set seen_hdr($hdr) 1
+ }
puts $out $line
}
} elseif {[regexp {^#ifdef __cplusplus} $line]} {
+ incr deflevel
puts $out "#if 0"
+ } elseif {[regexp {^\s*#\s*if} $line]} {
+ incr deflevel
+ puts $out $line
+ } elseif {[regexp {^\s*#\s*endif} $line]} {
+ incr deflevel -1
+ puts $out $line
} elseif {[regexp {^#line} $line]} {
# Skip #line directives.
} elseif {$addstatic && ![regexp {^(static|typedef)} $line]} {
 
3839 code closed 2009 May anonymous vfs 2009 Sep   5 3 make internal functions and variables static
Consider making some internal functions in os_win.c and shell.c static. MingW(GCC) compilers can automatically create DLL entry points when using gcc -shared instead of dllwrap. But that will put these internal symbols in the exports of the resulting DLL. See attached patch.
2009-Sep-30 08:45:45 by anonymous:
Now http://www.sqlite.org/src/tktview/35c54c8749872e4165328d6f12acbcd0930fd9a1
 
3838 code fixed 2009 May drh front 2009 May   1 1 DEFAULT VALUE incorrect on UTF16 database
In the following script, the output shown for column "c" is incorrect.

  PRAGMA encoding=UTF16;
  CREATE TABLE t1(a);
  INSERT INTO t1 VALUES(1);
  ALTER TABLE t1 ADD COLUMN b;
  ALTER TABLE t1 ADD COLUMN c DEFAULT 'xyzzy';
  UPDATE t1 SET b=2;
  SELECT * FROM t1;

Everything works when the encoding is UTF8. The default value of column C seems to be corrupted by the UPDATE statement.

 
3837 code closed 2009 May anonymous vfs 2009 Jun adamd 1 1 MissingMethod exception cant find Can't find PInvoke DLL 'sqlite3.dll'
I have already download the sqlite3 dll from your site. i have copy paste the same into my application folder and into my windows folder. i am working on compact framework as i wanna develop mobile application. i m using dot net compact framework with C# and SQlite as my database. when i m using this dll to connect to database, i got the error

"missing method exception Can't find PInvoke DLL 'sqlite3.dll'."

can you please help me.. i cant fix whats going wrong here,

2009-May-05 20:17:15 by anonymous:
This is not a bug, but a support question. The place for support questions is mailing list. Anyway, you can't use the precompiled DLL in compact framework, since it's compiled for different system and different processor. See http://sqlite.phxsoftware.com/ for .NET libraries for SQLite that work also on Compact Framework.


2009-May-06 04:28:10 by anonymous:
sorry for posting here. Hmmmmmmm... i dont think so. as u told, i had downloaded the same from the site and use into my application but still got the same error.. i m using WIndows XP...can u explain me whats wrong going here..


2009-May-06 04:33:05 by anonymous:
can u please tell me how can i get the precompiled version of the sqlite for compact framework. its really in urgent base. thnx in advance.


2009-Jun-12 05:36:10 by anonymous:
You should ask in the right place - the mailing list as pointed out earlier.
 
3836 code closed 2009 May anonymous   2009 May   3 3 select * where rowid > 10 fails, but >=10 works
It seems that rowid comparison is partially broken. eg

  select * from t1 where rowid >= 10

works, but using > instead returns empty values.

2009-May-05 03:45:04 by drh:
What does

   SELECT rowid, * FROM t1;

show?


2009-May-05 04:45:19 by anonymous:
It shows all values with all rowids, as expected. Here is the reproducable test from Tcl.

sqlite3 db /tmp/foo.db
db eval {create table t2 (a,b)}
set a 0; set b 0
while {$a<20} {
  incr a; incr b;
  db eval {insert into t2 values($a,$b)}
}
puts [db eval {select rowid from t2 where rowid>=10}]
# 10 11 12 13 14 15 16 17 18 19
puts [db eval {select rowid from t2 where rowid>10}]
# {}

2009-May-05 05:04:45 by anonymous:
If it helps, the bug does not appear to be in version 3.6.2


2009-May-05 11:30:33 by drh:
I ran your script using every historical version of SQLite from 3.1.3 through 3.6.13. It seems to work correctly in every case.


2009-May-05 18:55:46 by anonymous:
Ok. More testing reveals this disappears if compiled without -O2. Also, there is no bug if tried on a different Linux distribution or on Windows.

Could be a compiler bug in an older version of gcc.

 
3835 code closed 2009 May anonymous front 2009 May   2 4 "having max()" causes non-aligned pointers being freed
If you have the file words.sql with the following contents:

BEGIN TRANSACTION;
CREATE TABLE "words" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text_id" integer, "word" varchar(255));
INSERT INTO "words" VALUES(1,1001,'te');
INSERT INTO "words" VALUES(2,1002,'veniente');
INSERT INTO "words" VALUES(3,1003,'die');
INSERT INTO "words" VALUES(4,2001,'te');
INSERT INTO "words" VALUES(5,2001,'veniente');
INSERT INTO "words" VALUES(6,2001,'die');
INSERT INTO "words" VALUES(7,2001,'te');
INSERT INTO "words" VALUES(8,2001,'decedente');
INSERT INTO "words" VALUES(9,3001,'canebat');
CREATE INDEX "index_words_on_text_id" ON "words" ("text_id");
CREATE INDEX "index_words_on_word" ON "words" ("word");
COMMIT;
Run sqlite3 words.db < words.sql and then sqlite3 words.db and then execute the following query:

select text_id, count(distinct word) as histo
  from words where word in ("te", "veniente", "die")
 group by text_id
having max(histo);
On Mac OS X 10.5.6 with SQLite 3.4.0 (installed via the ruby gem), this produces the following output:

sqlite3(19396,0xa0094720) malloc: *** error for object 0x80a720: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
sqlite3(19396,0xa0094720) malloc: *** error for object 0x80a720: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
and a malloc error can't possibly be the correct behavior. (Is the SQL syntax bad?) I looked through the changelog, and didn't see anything about segfaulting, so I'm reporting this without testing if it's problematic in the latest release.

I labeled it severity 2 instead of 1, because there's a simple fix: just do having histo = 3 and it all works. Also, having explored a little more during the reporting of this bug, just doing a select distinct text_id for each word and INTERSECTing them together is an order of magnitude faster in ActiveRecord in Ruby on my laptop. Out of curiosity, is there a set intersection operator, like the set union that IN() provides? Also, I didn't use the FTS, because each word references other data, so it made sense to have one record per word in the text.

Thanks very much. SQLite is perfect for my small Latin website; I have one ruby server process that hits the db, and it just works great. (The line "te veniente die te decedente canebat" is from Vergil's description of Orpheus and Eurydice, a beautiful work of poetry.)

Duplicate of ticket #2526. Fixed by check-in [4179] .
 
3834 code closed 2009 May anonymous func 2009 Oct   1 1 last_row_id() does not give the right answer
The problem: I add 16 rows into a table and the last_insert_rowid() gives me the correct rowid. But the moment I add the 17th row, last_insert_rowid() gives me the value 19 which is wrong. It should be 18. Then it gets weird, I add till rows 33 last_insert_row() gives me the value which is one higher. But the moment I add 34th row the following happens:

  • 34th row is not added to the table

  • I get last_insert_rowid() value of 35.

My table is as follows,

  CREATE TABLE TB1
  (
       ItemID INTEGER NOT NULL,
       AccountID INTEGER NOT NULL,
       CompanyID INTEGER NOT NULL,
       ArchivedOn DATETIME,
       PRIMARY KEY (ItemID)
  )

I have two triggers on this table,

  CREATE TRIGGER UpdateTimeStamp AFTER  INSERT ON TB1
  BEGIN
    UPDATE TB1 SET Date = DATETIME('NOW')
      WHERE rowid = new.rowid;
  END

  CREATE TRIGGER Insert_FTS_TB1
  AFTER INSERT ON TB1
  BEGIN
   INSERT INTO fts_TB1 (rowid,AccountID,CompanyID)
      VALUES (new.ItemID,new.AccountID,new.CompanyID);
  END
2009-Oct-06 18:08:08 by anonymous:
Closing as this bug tracker is no longer used. Please post further discussion to the sqlite-users mailing list.

You need to confirm that the rowid is indeed wrong (ie select the row with id last_insert_rowid()) and show it is the wrong one.

See also #3982, #651.

 
3833 code closed 2009 May anonymous back 2009 Jun   1 3 Concurrent sqlite3OsAccess() and sqlite3OsDelete()
I have a test that spawns 5 threads, each of which opens a connection to the same database file using shared-cache. I am using the Unix VFS. Each thread repeats a loop many times with the following sequence:

- sqlite3_enable_shared_cache(TRUE)

- sqlite3_open_v2(\hdd0\db1)

- PRAGMA cache_size=0

- PRAGMA encoding=UTF8

- PRAGMA page_size=4096

- CREATE TABLE t<thread_id>(a,b,c);

- CREATE TEMP TRIGGER temp_trigger<thread_id> AFTER UPDATE ON t<thread_id> FOR EACH ROW BEGIN INSERT INTO t<thread_id> VALUES (new.rowid); END

- DROP TRIGGER temp_trigger<thread_id>

- DROP TABLE t<thread_id>

- sqlite3_close()

After a short time I see SQLITE_CANTOPEN on the main journal file when executing DROP TABLE. It appears that sqlite3OsAccess() and sqlite3OsDelete() are allowed to be called concurrently on the same journal file from different threads, leading one thread to believe that the journal file exists when it has been deleted. This may be the same issue reported on the mailing list on 04-17-09 by Filip Navara.

2009-May-11 22:28:28 by anonymous:
This issue also exists in 3.6.14.


2009-May-19 17:48:38 by anonymous:
This issue exists in SQLite 3.6.14.1. The CREATE TEMP TRIGGER and DROP TRIGGER are not necessary to reproduce the issue, the following is enough:

- sqlite3_enable_shared_cache(TRUE)

- sqlite3_open_v2(\hdd0\db1)

- PRAGMA cache_size=0

- PRAGMA encoding=UTF8

- PRAGMA page_size=4096

- CREATE TABLE t<thread_id>(a,b,c);

- DROP TABLE t<thread_id>

- sqlite3_close()


2009-Jun-01 18:28:38 by anonymous:
This looks like it could be related to ticket #3883 - perhaps this has been fixed now?


2009-Jun-29 18:56:20 by anonymous:
Appears to be fixed in 3.6.15 (was probably addressed by the fix for #3883) - closing this bug.
 
3832 code fixed 2009 May drh front 2009 May   1 1 assertion fault on an INSERT with a BEFORE trigger
The following SQL causes an assertion fault:

  CREATE TABLE t1(a INT, b INTEGER PRIMARY KEY);
  CREATE TABLE log(x);
  CREATE TRIGGER t1r1 BEFORE INSERT ON t1 BEGIN
    INSERT INTO log VALUES(new.b);
  END;
  INSERT INTO t1 VALUES(NULL,5);
  INSERT INTO t1 SELECT b, a FROM t1 ORDER BY b;

The same fault occurs on all versions going back to 3.1.3, which is the oldest version that comes easily to hand.

 
3831 code closed 2009 Apr anonymous back 2009 Oct   3 3 Database corrupted during proper usage of sqlite
On one of computers, database got corrupt. I believe I worked with sqlite is recommended safe way.

No condition from "how to corrupt your database" in docs is met. This is certain:

  • database is in separate directory
  • no one manually deleted journal
  • filesystem is journalled (WinXP's NTFS 5)
  • no symlinks/hardlinks
  • no access over network share.
  • even no simultaneous access from different processes

On the other hand, there were:

  • process crashes
  • power failures
  • Windows's automatic CHKDSK checks

Platform is Win32. Database size did not go under 200M. All processes used the same 3.6.10 release all the time, build from amalgamation, though some might be compiled with a bit different linker settings.

There are some special notes how I work with database:

  • (!) The following pragma is used: PRAGMA max_page_count=N (I see one of prev versions had bug with SQLITE_FULL - this may be related). So, hitting SQLITE_FULL is normal for my app and happens regularly. When it's hit, I do ROLLBACK and delete some older data (btw previous sqlite version corrupted database if I didn't do it).
  • I'm not sure but I think one of previous versions of my app did PRAGMA temp_store=MEMORY.
  • I INSERT multiple rows using INSERT ... SELECT ... UNION ALL ... UNION ALL ... UNION ALL ... Thus, BEGIN/COMMIT are not used, autocommit is on by default.
  • Autovacuum is off.
  • I preallocate disk space by inserting huge zeroblob row, then deleting it. This is done to avoid db file fragmentation.

I can upload the corrupted file for you somewhere. Integrity check shows errors, VACUUM returns "database is corrupted" error.

This happened second time; first time we considered it was a bad luck.

It would be good to have repair function in API which would do something like "sqlite3 corrupted.db .dump | sqlite3 repaired.db"

2009-Apr-30 21:02:58 by shane:
We need some clarification on this issue. You state that you do a ROLLBACK when you get SQLITE_FULL. You also state that you use INSERT ... SELECT so no BEGIN/COMMIT is used. This is contradictory. You must be in a transaction to do a ROLLBACK. A ROLLBACK if there is no transaction is an error, but also a no-op.


2009-May-01 00:42:00 by anonymous:
Doesn't a transaction start automatically when INSERT is performed?


2009-May-01 01:17:29 by drh:
A transaction starts automatically before the INSERT, but the transaction will also automatically COMMIT upon successful completion, or automatically ROLLBACK if there is any kind of error, such as an SQLITE_FULL error.


2009-May-01 21:29:55 by shane:
We've tried unsuccessfully to duplicate this issue. Any additional details you can provide would be appreciated.


2009-May-04 08:23:05 by anonymous:
ROLLBACK is legacy code. Version 3.4.2 did not make ROLLBACK automatically when SQLITE_FULL was hit, thus database was left corrupted.

Then I upgraded to 3.6.10, so current code does not need it, but I'm mentioning it because it might be relevant.


2009-May-11 14:42:06 by anonymous:
I have never written a ticket, so please dont mind if this is wrong here.

We use QNX 6.3 on a ppc with sqlite as database for our application. As there was a speed problem in older sqlite versions we used the PRAGMA SYNCHRONOUS = OFF command before creating an INSERT and the PRAGMA SYNCHRONOUS = ON afterwards. We used version 3.4.2 for a long time, 2 month ago we changed to version 3.6.11 (now without pragma options).

On our machines there are several programs that access the databases (we use 4 dbs) and also the programs have all several threads. This worked for over a year now on 10 machines. I only saw two times a database that was corrupted. Always messages like this: On page 6928 at right child: 2nd reference to page 7003 Page 3805 is never used. But that never caused a totally corruption of the database. I added a program to run the integrity_check and performing a ".dump |" if a problem was found.

Today I had the first total crash. No program could start at all. All programs (written in c) got database locked (11) and ended. I was lucky to have a telnet connection to the customer, so I run an integrity_check and got a long list with errors. I tried to .dump | but the most important table was so much damaged, that it was empty after the .dump. Also there was the data.s3db-journal file, but no connection to the database was opened.

I dont have an idea how to find the reason for the problem. The customer had problems with the machine, so he switched off/on very often the last days. But I thought sqlite should be save enough to handle power fails. I need to find a solution where quickly, if I have the same problem at a customer without internet connection I will have a big problem.

Best Regards, Stefan Breitholz s.breitholz@staubli.com


2009-May-12 09:29:51 by anonymous:
I think my greatest risk of database corruptions are the inserts. As many programs may access the database, it is often locked. So I wrote a function that handles every insert to the database, it tries several time to access it. Perhaps it is also wrong, that different threads inside a program use the same sqlite3* handle for the database.

int sqlite3_exec_save(sqlite3* database, const char *command, int (*callback)(void *ag1,int arg2,char **arg3,char **arg4), void *arg1 , char **aErrmsg, const char *errString, int printMessage ){

	int counter = 0;
	int returnCode;
	char help_str[500];

	char *errmsg = 0;

	srand (pthread_self());

	//try up to 300 times in up to 9 sec
	do{
		returnCode = sqlite3_exec(database, command, NULL, NULL, &errmsg);
		if((returnCode == SQLITE_BUSY) || (errmsg != NULL && returnCode != SQLITE_ERROR)){
			usleep(20000 + (rand()%10000));//several threads wait different times

			counter++;

		}
	}while ((returnCode == SQLITE_BUSY && counter < 300) || (errmsg != NULL && counter < 300 && returnCode != SQLITE_ERROR)); //only repeat non SQL-Errors
	if (errmsg != NULL ){
		sprintf(help_str,"%s (%i:%s) [attempt %i]:", errString, returnCode, errmsg, counter);
		eprintf("could not insert to database");
		logPoint(help_str);
		logPoint(command);
	}else if( counter > 5){
		eprintf("needed %i attempts to insert to database", counter);
	}

	//if somebody wants to use the error messagae outside the function
	if (aErrmsg != NULL && errmsg != NULL){
		*aErrmsg = malloc(strlen(errmsg)+1);
		strcpy(*aErrmsg,errmsg);
	}

	return returnCode;
}

Please give me some advice. Stefan


2009-May-12 10:31:59 by drh:
Here is your advice: Ask your questions on the sqlite users mailing list: sqlite-users@sqlite.org. Appending comments to an unrelated ticket is not an efficient way to get help with your problem.
 
3830 doc fixed 2009 Apr anonymous test 2009 Apr   4 4 blob.test test numbers out of sequence
The final test in this file follows test # 3.1

  do_test blob-2.3 {
   set blobs [execsql {SELECT * FROM t1}]
   set blobs2 [list]
   foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
   set blobs2
  } {CDEF12 345678}

On my porti this test fails with a response of

  Expected: [CDEF12 345678]
       Got: [123456 7890AB CDEF12 345678]

So I'm trying to determine if this is a real test and misnumbered (should be 3.2), or is an artifact in the file and should be ignored.

 
3829 code closed 2009 Apr anonymous front 2009 Oct   4 4 invalid join types
According to documentation there should be specific order of join keywords, but that isn't true is sqlite, for example:

  SQLite version 3.6.13
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t1(a);
  sqlite> create table t2(a);
  sqlite> select * from t1 outer natural left join t2;
  sqlite>
2009-Oct-04 20:45:31 by anonymous:
Which documentation? Please post your question to the sqlite-users mailing list.
 
3828 code fixed 2009 Apr drh front 2009 Apr   3 1 EXPLAIN QUERY PLAN confuses sqlite3_complete()
The following interface call returns TRUE when it should be returning false:

   sqlite3_complete("EXPLAIN QUERY PLAN CREATE TRIGGER r1"
                    " AFTER INSERT ON t1 BEGIN SELECT null;");
 
3827 doc closed 2009 Apr anonymous cli 2009 Apr   4 5 Type in online help
Typo. See copy from command line output. It took me a moment to figure out what the help was saying.

sqlite> .mode MODE mode should be on of: column html insert line list

Should read (I think)

sqlite> .mode MODE mode should be one of: column html insert line list

This was previously reported in ticket #2111 and fixed for SQLite version 3.3.9.

I do not think this is worth backporting to the obsolete 2.8 branch.

 
3826 code closed 2009 Apr anonymous vfs 2009 Oct   2 2 sqlite3VXPrintf optimization suggestions
*printf for real (f/e/g) format can take 2 simple optimisations:

  1. this loop can be eliminated: for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){} and use a static double array (of e.g. 32 doubles) initialised once

  2. trailing zero removal optimisation if you know that what is left from the number to print, after the decimal point, is going to end up with all-zeros, the current code does a lot of work to place the zeroes and then eventually ends up removing the zeroes. A simple comparison for the magnitude of the number left to print, done just before this point:

        /* "0" digits after the decimal point ....

can be avoided.

2009-Oct-04 20:53:45 by anonymous:
This function isn't in any performance critical code paths. The array would take up 256 bytes which is larger than the code!

Your attention to detail is appreciated. Did you run the test suite after the changes to ensure that there were no unexpected side effects? Please post further discussion to the sqlite-users mailing list. Closing as this bug tracker is no longer used.

 
3825 code closed 2009 Apr anonymous   2009 Oct   2 1 -DTEMP_STORE=3 compile option doesn't work
From to post I put to sqliteusers mailing list (no response) :

Hi, From what I understand : - default behavior is to use files for temporary stuff. - the directory that will be used for these temporary files can be defined via pragma (temp_store_directory). If the pragma is not used, it will default to the first hardcoded directory (linux), in the order that follows: /var/tmp, /usr/tmp, /tmp, or finally current directory.

So, in the environment I am running in, either those directories do not exist, or are not writable to the user under which the process is running. The result being an "error 14: unable to open database file" as soon as temporary files are needed.

After a little digging I discover SQLITE_TEMP_STORE compilation flag. So I export CFLAGS=-DSQLITE_TEMP_STORE=3, run configure and remake, figuring that the temp files will now reside in memory, and need no writing into a directory. However, the problem remains.

When I look through the code, there is no instance of SQLITE_TEMP_STORE, only TEMP_STORE... So I repeat the above with -DTEMP_STORE. Same result.

Then I add a path that I know is accessible to the user under which the process runs, to the azDirs array in the unixGetTempname function. Voila.. working now..

I've retested with default TEMP_STORE and TEMP_STORE compiled in a 3(memory only). And regardless of the setting, it only works if there is a readable/writable directory...

I would think that if TEMP_STORE=3, then no directory is required ? Is this a bug, or am I misunderstanding something ?

2009-Apr-24 13:25:10 by anonymous:
After code reading, I have discovered that the culprit is the statement journal.

Regardless of TEMP_STORE = MEMORY or not, the statement journal, which is treated differently than a regular journal file, is placed in a temporary file.


2009-Oct-18 07:55:18 by anonymous:
Believed fixed.
 
3824 code fixed 2009 Apr anonymous front 2009 Apr   1 3 Select with order by in some conditions
-- Sending this to new database:

create table tab (
  s1  string,
  i1  integer,
  s2  string
  );
create unique index ix2 on tab(s2);

insert into tab(s1,i1)    values('aa',100);
insert into tab(s1,i1)    values('bb',20);
insert into tab(s1,i1)    values('cc',120);

select i1,s1 from tab
 where s2 is null
 order by i1;


--- you will get this:

100|aa
20|bb
120|cc

--- I think it is in invalid order, isn't it?
--- but with dropping the index

drop index ix2;

select i1,s1 from tab
 where s2 is null
 order by i1;

--- you'll get the correct order:

20|bb
100|aa
120|cc

2009-Apr-24 13:57:06 by drh:
This bug comes about because the query optimizer assumes that the output of a unique index is unique, and hence does not need to be sorted. This is normally true. But it is not true if the constraint is "x IS NULL" instead of "x=123". The fix will be to teach the query optimizer that "x IS NULL" does not yield a unique answer even with a UNIQUE index. We are testing the fix now.
 
3823 code closed 2009 Apr anonymous back 2009 Oct   3 3 busy timeout is ignored in shared-cache mode
If one connection locks a database for write, another connection operating on the same shared cache immediately gets an SQLITE_BUSY error on attempt to aquire a write lock. Busy timeout interval that was set in advance on the second connection is not used.
2009-Oct-12 21:24:18 by anonymous:
Dup of #2010
 
3822 website closed 2009 Apr anonymous   2009 Apr drh 5 4 Sitemap says "browse bug beports"
Beporting bugs is nice and assonant, but doesn't contribute to a professional image. Ah, well!
2009-Apr-22 11:06:04 by drh:
It is true that many organizations prefer to conceal the fact that their software contains bugs. (For example, try finding a bug report at oracle.com.) But we consider such practice to be simple deceit. All software of reasonable complexity contains bugs. The difference is that at SQLite.org, we strive to be open and honest about that fact and let our users know exactly what those bugs are, when they appeared, and how they have been fixed.

Our intent is to be open and honest in all matters, including but not limited to bug reporting. If that means projecting an "unprofessional" appearance, well then so be it.

Thank you for the suggestion, though.


2009-Apr-22 11:21:15 by anonymous:
The point is that "beport" is not report


2009-Apr-22 12:11:53 by drh:
Ah, yes. Quite so. I completely missed that. Problem fixed now. Thanks.
 
3821 code fixed 2009 Apr anonymous vfs 2009 Apr shane 1 3 Incorrect handling of hot journals on Windows
When two concurrent threads or processes try to access the same database and a journal file exists (possibly as a consequence of journal_mode=persist) a race condition can occur where the hasHotJournal function is called from both threads.

In revision 1.573 of pager.c the hasHotJournal function was modified to check the first byte of the hot journal. To implement this functionality the journal is opened using sqlite3OsOpen. If the above race condition scenario happens then one of the sqlite3OsOpen (or winOpen specifically) calls will fail with SQLITE_CANTOPEN due to sharing violation.

I believe the bug happens due to incorrect interpretation of the flags in winOpen and that the journal shouldn't actually be opened for exclusive non-sharing access in this case.

The problem was previously reported on mailing list:

http://sqlite.org:8080/cgi-bin/mailman/private/sqlite-users/2009-April/010897.html

Proposed fix (tested for few days now without the problem happening again):

http://sqlite.org:8080/cgi-bin/mailman/private/sqlite-users/2009-April/010904.html

 
3820 code closed 2009 Apr anonymous front 2009 Oct   4 3 multi-line comments don't work when followed by "." directive
This works:

  /* hello */
  .bail ON
  select "hello";

This doesn't:

  /* hello
  */
  .bail ON
  select "hello";

The only difference is the newline within the comment. The error message is:

SQL error near line 1: near ".": syntax error

2009-Oct-12 21:26:28 by anonymous:
multi line comments are a SQL feature. dot commands are a shell feature. You are effectively mixing them. This tracker and ticket are now closed. Please continue discussion on sqlite-users mailing list.
 
3819 code closed 2009 Apr anonymous front 2009 Oct   2 1 Table was updated but my SQL stmt still generated an error message
I tried to execute the following update statement

UPDATE A INNER JOIN B ON A.ID = B.ID SET A.[Image] = '' WHERE B.MyCriteria = 1 AND A.[Image] = 'XXX.jpg'

I understand that the order is wrong in that statement and SQLite allows to update tables with inner join subqueries only in where clause, so naturally I got an "Error Message: SQLite syntax; near INNER".

But the statement has been executed fine. The [image] filed has been updated anyway. Why?

2009-Oct-12 21:39:34 by anonymous:
Sounds like an error in your code. If there is a syntax error then NULL is returned from sqlite3_prepare so there is no way you could have run it. Please continue discussion on the sqlite-users mailing list as this tracker and ticket are now closed.
 
3818 code closed 2009 Apr anonymous   2009 Apr   1 1 sq3lite_close segfaults
trackerd received a SIGSEGV when calling sq3lite_close. I'm attaching a stack trace and can provide the core file.

  mdb core.trackerd.1240262184
Loading modules: [ ld.so.1 ]
* ::status
debugging core file of trackerd (32-bit) from napoleon
file: /usr/bin/trackerd
initial argv: trackerd
threading model: native threads
status: process terminated by SIGSEGV (Segmentation Fault), addr=10
* ::stack
libc_hwcap2.so.1`t_delete+0x14(0, 0, 0, fee8b24e)
libc_hwcap2.so.1`realfree+0x8e(88759d8, 0, fe5ffd3c, fee8b835)
libc_hwcap2.so.1`_free_unlocked+0x6e(88b74f0)
libc_hwcap2.so.1`free+0x37(88b74f0, fef7f000, fe5ffd5c, fedb3200)
libsqlite3.so.0`sqlite3MemFree+0x22(88b74f8)
libsqlite3.so.0`sqlite3_free+0x64(88b74f8, 88b74f8, fe5ffdbc, fedb3f44)
libsqlite3.so.0`sqlite3DbFree+0x4f(8873618, 88b74f8)
libsqlite3.so.0`sqliteResetColumnNames+0x3f(88d1888, 889fd18)
libsqlite3.so.0`sqlite3DeleteTable+0x7d(88d1888, 0, fe5ffe3c, fede5fed)
libsqlite3.so.0`sqlite3SchemaFree+0xc6(8873898, fed896dc, fe5ffe7c, fede0ba6)
libsqlite3.so.0`sqlite3ResetInternalSchema+0x55(8873618)
libsqlite3.so.0`sqlite3_close+0x53(8873618, 806d654, 884dec8, 0)
tracker_db_close+0x54(884dec8)
tracker_db_close_all+0x33(8808f38, 80cca40, fe5fff8c, 8066176)
process_user_request_queue_thread+0x8af(0, 8137638, 200, fed0ae46)
libglib-2.0.so.0.1800.3`g_thread_create_proxy+0x133(8137638, fef7f000, fe5fffec
, feeecd1e)
libc_hwcap2.so.1`_thrp_setup+0x7e(fe790200)
libc_hwcap2.so.1`_lwp_start(fe790200, 0, 0, feeecd1e, 0, 0)
>
2009-Apr-21 15:31:43 by drh:
This kind of thing comes up from time to time and it is almost always traced to heap corruption somewhere else within the larger application. In other words, this is unlikely to be SQLite's fault. If you have additional evidence that the problem is within SQLite we will be happy to look into the matter. But a stack trace showing that free() failed when it was called from SQLite is scant evidence of a problem in SQLite.

valgrind is a great tool for tracking down the true cause of these kinds of problems.

 
3817 new closed 2009 Apr anonymous front 2009 Oct   5 4 Function to duplicate prepared statements
The idea: Add a function to the API which creates a copy of a sqlite3_stmt. For this use, it would be sufficient do be able to do this to statements that are not currently being executed.

The why: A comparison of the Tcl DataBase Connection (TDBC) interfaces with the C-level SQLite3 interfaces seems to indicate that a sqlite3_stmt corresponds both to a TDBC prepared statement object and to a TDBC resultset object. Just after preparation or after being reset, the sqlite3_stmt is like a TDBC statement, but calling sqlite3_step gives it the semantics of a TDBC resultset. Having a function that copies a sqlite3_step would allow the TDBC statement object to own a sqlite3_stmt that is prepared but never executed, as any calls to the TDBC [execute] method could create a sqlite3_stmt copy that is owned and stepped by the TDBC resultset object.

The alternative TDBC implementation of transferring ownership of the sqlite3_stmt between prepared statement object and resultset object is possible, but somewhat awkward. It is more likely that a developer would be content to call sqlite3_prepare anew every time a query is made, thus forcing SQLite to frequently recompile the same piece of code.

Some background: I started using sqlite3 (the Tcl package) for a project, but switched to tdbc::sqlite3 since it had a more convenient syntax for bound values. After a while, I began seing excessive memory use, which turned out to be due to queries with large resultsets; even though I had taken care to use the TDBC resultset interface, the tdbc::sqlite3 driver is just a wrapper around the sqlite3 extension, and the latter does not (AFAICT) provide a way to return results row-by-row, so of course TDBC had to juggle a few hundred MB of intermediate data in RAM! I then examined the possibility of coding a TDBC driver for SQLite in C, but decided I wasn't quite up to it (the above mismatch between the "prepared statement" concepts of the two systems being one issue), and instead changed my queries to only return the rowids, fetching the rest of the columns in a separate call for each row. :-(

2009-Oct-12 21:25:17 by anonymous:
Please discuss on the sqlite users mailing list.
 
3816 build closed 2009 Apr anonymous ext 2009 Oct a.rottmann 1 1 RTREE
when use RTREE in VC++6.0 releas maxSpeed,insert into RTREE 100,000 records will report an error,debug or releas not use MaxSpeed can work very well.
2009-Oct-12 21:27:25 by anonymous:
Your sentence doesn't make any sense. This tracker and ticket are now closed - please continue discussion on the sqlite-users mailing list.
 
3815 doc fixed 2009 Apr anonymous   2009 Apr   1 3 sqlite3_interrupt() can interrupt queries started after its return
Context :

- one long query executing in a thread ( sql thread )
- an event occur in the main thread and call a member that do :
- call sqlite3_interrupt()
- genere a string sql query
- send the string sql to "sql thread" for execution
- Query sent is interrupted
The documentation was unclear. The sqlite3_interrupt() call actually stays in effect until all currently running SQL statements have halted. Only after all current statements have halted are new statements allowed to run without being interrupted.

The documentation has been updated.


2009-Apr-21 10:43:47 by anonymous:
How i can know that all current queries are finished ?
 
3814 code closed 2009 Apr anonymous func 2009 May   1 3 sum function won't work if the "group by" fields heaving unicode data
I keep unicode data inside 2 column (name,name2). when running "select name,name2,sum,sum(sum) from table1 group by name,name2;" i get bad calculation under the sum(sum) column!

it doesn't happened when column name,name2 hold english(string) data !

2009-Apr-19 19:20:30 by anonymous:
my schema is: CREATE TABLE table1(name text(20),name2 text(20),sum double);

my command is : select name,name2,sum,sum(sum) from table1 group by name,name2;

when inserting english strings to name, name2 everything works fine!

when inserting hebrew chars (unicode) the sum(sum) gives me wrong calculation!


2009-Apr-20 07:55:29 by anonymous:
Unable to reproduce.

Example test (in UTF-8 encoding)

#!/bin/sh
DB="test.db"
SQL="sqlite3 $DB"
QUERY="select name,name2,sum,sum(sum) from table1 group by name,name2;"

echo "Testing English"

rm -f $DB
echo "create table table1(name text(20),name2 text(20),sum double);" | $SQL
echo "insert into table1 values ('a', 'b', 1);" | $SQL
echo "insert into table1 values ('a', 'b', 2);" | $SQL
echo "insert into table1 values ('a', 'c', 4);" | $SQL
echo "insert into table1 values ('a', 'd', 3);" | $SQL
echo "$QUERY" | $SQL

######################################
echo "Testing Hebrew"

rm -f $DB
echo "create table table1(name text(20),name2 text(20),sum double);" | $SQL
echo "insert into table1 values ('א', 'ב', 1);" | $SQL
echo "insert into table1 values ('א', 'ב', 2);" | $SQL
echo "insert into table1 values ('א', 'ג', 4);" | $SQL
echo "insert into table1 values ('א', 'ד', 3);" | $SQL
echo "$QUERY" | $SQL
Output:

Testing English
a|b|2.0|3.0
a|c|4.0|4.0
a|d|3.0|3.0
Testing Hebrew
א|ב|2.0|3.0
א|ג|4.0|4.0
א|ד|3.0|3.0
Environment:

  • OS: Linux,Debian 5.0 (Lenny)
  • Sqlite: sqlite3 3.5.9-6 (from distro package)
  • LANG=he_IL.UTF-8 (and not overriden otherwise)

Tzafrir

 
3813 code fixed 2009 Apr anonymous func 2009 Apr   2 2 func.c uses sqlite3_aggregate_count() despite SQLITE_OMIT_DEPRECATED
In func.c, the groupConcatStep() routine uses the deprecated sqlite3_aggregate_count() even if compiled with SQLITE_OMIT_DEPRECATED defined.

Suggestion: Inline the sqlite3_aggregate_count() implementation like this:

  pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
  // if( sqlite3_aggregate_count(context)>1 ){ // Deleted
  if( context->pMem->n>1 ){                    // Added
    if( argc==2 ){

This solves the problem for me and also passes the new group_concat tests.

 
3812 code closed 2009 Apr anonymous cli 2009 Oct   1 4 Quotes appears around data when importing exported csv file
When exporting data to CSV format with sqlite3 tool, it adds quotes around values, which have spaces. Export doing with command:

sqlite3 -csv -separator ';' -noheader -batch 'SELECT * FROM table' > table.csv

And after that doing import to database from newly exported CSV file, quotes around some values appears in table. Import is doing with command:

sqlite3 -csv -separator ';' -batch db.sqlite3 '.import table.csv table'

2009-Oct-06 18:10:48 by anonymous:
Superceded by http://www.sqlite.org/src/tktview/c25aab7e7ea55c861313076cae9257fc8f3fbdc0
 
3811 code fixed 2009 Apr anonymous   2009 Apr   1 2 journal_mode=off and locking_mode inconsistency
According to the documentation, "The OFF journaling mode disables the atomic commit and rollback capabilities of SQLite. The ROLLBACK command no longer works".

Accordingly, this SQL

  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(a PRIMARY KEY, b);

  PRAGMA journal_mode = off;

  BEGIN;
    INSERT INTO t1 VALUES(13, 14);
  ROLLBACK;

  SELECT * FROM t1;

correctly returns

  off
  13|14

However, if run in exclusive mode, the behavior changes:

  PRAGMA locking_mode=exclusive;

  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(a PRIMARY KEY, b);

  PRAGMA journal_mode = off;

  BEGIN;
    INSERT INTO t1 VALUES(13, 14);
  ROLLBACK;

  SELECT * FROM t1;

and the output becomes

  exclusive
  off

In other words: With locking_mode=exclusive, journal_mode = off no longer disables ROLLBACK and, contrary to the documentation, the INSERT rolls back.

Following up on my initial message to the mailing list, I now believe that this is not the intended behavior (at least I could not find this documented) but a problem in the library.

The documentation has been updated to explain that changing the journal_mode is only guaranteed to be effective if the change occurs prior to the first transaction. Test cases have been added to prove that journal_mode=OFF works with locking_mode=EXCLUSIVE as long as the journal_mode change occurs prior to the first transaction.
 
3810 code closed 2009 Apr anonymous back 2009 Oct danielk1977 2 3 SQLITE_ERROR on concurrent CREATE TEMP TRIGGER and sqlite3_close()
I have a test that spawns 5 threads, each of which opens a connection to the same database file using shared-cache. Each thread repeats a loop many times with the following sequence:

- sqlite3_enable_shared_cache(TRUE)

- sqlite3_open_v2(\hdd0\db1)

- PRAGMA cache_size=0

- PRAGMA encoding=UTF8

- PRAGMA page_size=4096

- CREATE TABLE t<thread_id>(a,b,c);

- CREATE TEMP TRIGGER temp_trigger<thread_id> AFTER UPDATE ON t<thread_id> FOR EACH ROW BEGIN INSERT INTO t<thread_id> VALUES (new.rowid); END

- DROP TRIGGER temp_trigger<thread_id>

- DROP TABLE t<thread_id>

- sqlite3_close()

After a short time I see SQLITE_CORRUPT when executing CREATE TEMP TABLE. By using a semaphore to protect execution of each stage of the loop, I have discovered that the error occurs when CREATE TEMP TRIGGER in one thread is allowed to execute at the same time as sqlite3_close() in another thread. I am using a custom VFS - if I use the Unix VFS, I see SQLITE_CANTOPEN on the main journal file instead, when executing DROP TABLE (this may be a separate issue, reported on the mailing list on 04-17-09 by Filip Navara).

2009-Apr-18 00:32:48 by drh:
When the xOpen method of the VFS is called with a NULL filename, it is suppose to open a new unique temporary file. In other words, every time xOpen is called with a NULL filename a different temporary file is opened. Could it be that your custom VFS is in fact opening the same temporary file multiple times?


2009-Apr-22 11:14:53 by drh:
No feedback from the OP. We will assume that the diagnosis in the previous remark is correct and close this ticket.


2009-Apr-30 00:59:06 by anonymous:
My logs confirm that every call to xOpen() with a NULL filename generates a unique filename - this issue is still open.


2009-Apr-30 01:28:28 by drh:
In as much as this works correctly on every VFS we have at hand, it still seems likely this is a problem with the OP's custom VFS and not something in the SQLite core. Perhaps we might document the VFS interface better or provide some additional checks if we knew what was going on. But because we have no way to reproduce the problem (since we do not have access to the OP's VFS) there is nothing we can do here to troubleshoot or fix the problem.

In other words, there is nothing we can do here without additional information.


2009-Jul-01 00:55:40 by anonymous:
I have now successfully demonstrated this bug using the Unix VFS. In my previous tests, I realised I was not calling sqlite3_enable_shared_cache(TRUE) correctly. The bug exists in 3.6.16 as described above, using SQLITE_OS_UNIX and no custom VFS code.


2009-Jul-01 07:15:10 by danielk1977:
Can you post the code that you used to demonstrate the problem using the unix VFS?

Thanks.


2009-Jul-01 17:41:35 by anonymous:
My test code is not currently in a form that can be released (lots of wrappers involved) - I will try to get this to you as soon as I can.


2009-Jul-01 23:08:26 by anonymous:
The attached source reproduces the error, using the amalgamated source version 3.6.16 and the compile options described below.


2009-Aug-11 20:08:18 by anonymous:
The recent fixes in 3.6.17 have changed the behaviour of this bug, but it still exists. The difference is that SQLITE_ERROR is returned instead of SQLITE_CORRUPT, and the error text has changed to "no such trigger: temp_trigger<thread_id>". The scenario to reproduce the bug is unchanged. The comments associated with the fix suggest that the problem is caused by creating a temp trigger on a table from one connection, and then dropping that same table from a different connection, orphaning the temp trigger in the process. However this does not occur in my test scenario, as each connection is operating on its own table - there should not be any possibility of orphaned triggers.

I am suspicious of the following comment in the OP_ParseSchema case of sqlite3VdbeExec():

  ** Although the mutex on the BtShared object that corresponds to
  ** database u.bv.iDb (the database containing the sqlite_master table
  ** read by this instruction) is currently held, it is necessary to
  ** obtain the mutexes on all attached databases before checking if
  ** the schema of u.bv.iDb is loaded. This is because, at the start of
  ** the sqlite3_exec() call below, SQLite will invoke
  ** sqlite3BtreeEnterAll(). If all mutexes are not already held, the
  ** u.bv.iDb mutex may be temporarily released to avoid deadlock. If
  ** this happens, then some other thread may delete the in-memory
  ** schema of database u.bv.iDb before the SQL statement runs. The schema
  ** will not be reloaded becuase the db->init.busy flag is set. This
  ** can result in a "no such table: sqlite_master" or "malformed
  ** database schema" error being returned to the user.

I have seen that sqlite3_close() calls sqlite3ResetInternalSchema(), so I wonder if there could be a race condition when one connection to a DB is closed while another connection is adding a temp trigger.


2009-Oct-15 21:43:39 by anonymous:
Assuming fixed. If not the case the please post to sqlite-users mailing list.


2009-Oct-20 16:49:55 by drh:
When ever a prepared statement runs, it first checks to see if the schema has changed. If the schema has changed, then the statement must be recompiled and retried. This loop of checking for schema changes and recompiling is run 5 times, after which statement execution is abandoned with an error.

What appears to be happening in this ticket is that one thread keeps trying to run a prepared statement, but the schema keeps getting changed out from under it by another thread. Each time the original thread reprepares its statement, another thread changes the schema yet again before the first thread has an opportunity to run the statement.

If the attached test program is modified so that the statement is retried even if it returns SQLITE_ERROR (in addition to SQLITE_SCHEMA and other values) then it works as desired.

So, in other words, this appears to be an application problem.


2009-Oct-22 17:42:16 by anonymous:
Retrying on SQLITE_ERROR does indeed work in my test case. However I was under the impression that SQLITE_ERROR implied a serious error - should my application always retry on SQLITE_ERROR returned from sqlite3_exec() or sqlite3_step()? Wouldn't SQLITE_SCHEMA be the more appropriate error code in this case?
 
3809 code fixed 2009 Apr anonymous   2009 Apr   1 2 Reverse behavior of SQLITE_HAVE_ISNAN
With check-in [6517] , SQLITE_HAVE_ISNAN pulls in the SQLite alternative instead of isnan(). From how I read the comment, I guess that

  #if defined(SQLITE_HAVE_ISNAN)

should be negated to

  #if !defined(SQLITE_HAVE_ISNAN)
 
3808 code fixed 2009 Apr anonymous   2009 Apr   3 1 strftime conversion regression
There is some regression in the strftime conversion (some older 3.6.x versions appear affected as well):

  bogdan@xxxxx ~/sqlite-3.6.13 $ ./sqlite3
  SQLite version 3.6.13
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> select strftime('%Y-%m-%dT%H:%M:%fZ', 1237962480.998, 'unixepoch');
  2009-03-25T06:28:00.997Z

  bogdan@xxxxx ~/sqlite-3.6.13 $ /usr/bin/sqlite3
  SQLite version 3.4.0
  Enter ".help" for instructions
  sqlite> select strftime('%Y-%m-%dT%H:%M:%fZ', 1237962480.998, 'unixepoch');
  2009-03-25T06:28:00.998Z
 
3807 code fixed 2009 Apr drh front 2009 Apr   1 1 Malformed SQL causes crash
It is reported on the mailing list that the following SQL crashes SQLite:

create table crash(a,b); insert into crash select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 union all select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 union
select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
order by 1
2009-Apr-15 23:59:06 by drh:
Simpler test case:

   SELECT 1 UNION ALL SELECT 2, 3 UNION SELECT 4, 5 ORDER BY 1;
 
3806 code fixed 2009 Apr anonymous   2009 Apr   3 3 GROUP_CONCAT treats empty strings as NULL sometimes
To reproduce run this unconventional sql:

  SELECT F1, GROUP_CONCAT(F2), COUNT(F2), GROUP_CONCAT(F3),
         COUNT(F3), GROUP_CONCAT(F4), COUNT(F4), COUNT(*)
  FROM
  (SELECT 1 F1, 'a' F2, '' F3, NULL F4
   UNION
   SELECT 1, 'b', '', NULL
   UNION
   SELECT 1, 'c', '', NULL)
  GROUP BY F1

Note that Group_Concat(f3) returns null while count(f3) returns 3.

The behavior is only applied to initial and subsequent rows containing empty strings. E.g. add an 'x' to the second row, like this:

  SELECT F1, GROUP_CONCAT(F2), COUNT(F2), GROUP_CONCAT(F3),
         COUNT(F3), GROUP_CONCAT(F4), COUNT(F4), COUNT(*)
  FROM
  (SELECT 1 F1, 'a' F2, '' F3, NULL F4
   UNION
   SELECT 1, 'b', 'x', NULL
   UNION
   SELECT 1, 'c', '', NULL)
  GROUP BY F1

Note that Group_Concat(f3) now returns "x," while count(f3) still returns 3.

 
3805 website fixed 2009 Apr anonymous   2009 Apr   1 2 CREATE VIRTUAL TABLE doesn't work anymore
The following statement works in version 3.6.12, but doesn't work in 3.6.13 anymore:

CREATE VIRTUAL TABLE text USING FTS3(spec TEXT);

Error messsage: near "VIRTUAL": syntax error

SQLite amalgamation was used for both versions, build was done on Linux, SunOS/Sparc and SunOS/x86 and all platforms showed the same behaviour. Build parameters were the same for both versions, CFLAGS contained -DSQLITE_ENABLE_FTS3 .

2009-Apr-15 12:53:21 by drh:
The amalgamation build on the website was faulty. It had been prepared with the SQLITE_OMIT_VIRTUAL_TABLE compile-time option enabled. This has been corrected. Please download a fresh copy and try again.
 
3804 code fixed 2009 Apr anonymous vfs 2009 Apr shane 1 1 Access violation on WinCE
getSectorSize on WinCE will make access violation. I thing that there is a problem with winFullPathname. It returns string using snprintf, that is shorter than MAX_PATH as expected.

Around line 1610:

        /* trim path to just drive reference */
        WCHAR *p = zConverted;
        for(i=0;i<MAX_PATH;i++){
          if( p[i] == '\\' ){   <=====HERE
            i++;
            p[i] = '\0';
            break;
          }
        }

Workaround is:

  static int getSectorSize(
    sqlite3_vfs *pVfs,
    const char *zRelative     /* UTF-8 file name */
  ){
  #if SQLITE_OS_WINCE
    return SQLITE_DEFAULT_SECTOR_SIZE;
  #else
  .....
2009-Apr-15 11:06:13 by anonymous:
Sorry I want to say that there is problem with convertUtf8Filename. It makes string shorter than MAX_PATH and if path does not contain \ char, it will do access violation (there is check only on \ char not end of string)


2009-Apr-15 14:38:32 by shane:
If the "fullpath" did not contain a '\' and was less then MAX_PATH in length, then an access violation could occur (on any Windows platform). Modified "trimming" loop to prevent this.
 
3803 code closed 2009 Apr anonymous build 2009 Sep   3 3 size of sqlite3.c overflows stabs fields making some debugging fail
This comes from

https://bugzilla.mozilla.org/show_bug.cgi?id=415316

and

http://www.mail-archive.com/sqlite-users@sqlite.org/msg26012.html

where we noticed that we don't get any debug information about stackframes inside of sqlite on systems using stabs in the wild. Our current speculation is that this could be easily worked around by hacking mksqlite3c.tcl to insert #line directives in between the individual files.

2009-Sep-29 07:57:08 by anonymous:
Original reporters have fixed their issue by using DWARF which doesn't have the same limitations as stabs. It wasn't clear if inserting #line directives would fix the problem or may fix the problem.

Closing as a workaround of building the library from multiple source files is available.

 
3802 code closed 2009 Apr anonymous test 2009 Apr   4 4 bindxfer.test fails compiled with SQLITE_OMIT_DEPRECATED
bindxfer test # 1.10 attempts to transfer binding with an unequal number of paramters, expecting an error

    do_test bindxfer-1.10 {
      set VM1 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]
      set VM2 [sqlite3_prepare $DB {SELECT ?, ?, ?, ?} -1 TAIL]
      sqlite3_transfer_bindings $VM1 $VM2
    } 1  ;# SQLITE_ERROR

in test1.c (ver 1.351) this is passed along in the routine test_transfer_bind to sqlite3TransferBindings in vdbeapi.c which has an assert statement at line 1276 that was added in v 1.159

    assert( pTo->nVar==pFrom->nVar );

RECOMMENDED SOLUTION:

Catch the error in test1.c returning SQLITE_ERROR or restore the lines in vdbeapi.c from v 1.159

    if( pFrom->nVar!=pTo->nVar ){
      return SQLITE_ERROR;
    }
2009-Apr-15 13:19:32 by drh:
Unable to reproduce this problem.

The bindxfer-1.10 test is contained within

  if !deprecated {
     ....
  }

So it should not be running when compiled with -DSQLITE_OMIT_DEPRECATED. Please try a clean rebuild from scratch and see if the problem doesn't clear itself.


2009-Apr-16 16:14:19 by anonymous:
Error in description.

bindxfer.test fails when compiled without SQLITE_OMIT_DEPRECATED

To be clear, works with the SQLITE_OMIT_DEPRECATED, does not work without it.

 
3801 code fixed 2009 Apr anonymous test 2009 Apr   4 4 temptrigger.test is run when compiled with SQLITE_OMIT_SHARED_CACHE
When compiled with SQLITE_OMIT_SHARED_CACHE, the TCL command sqlite3_enable_shared_cache is not available, since it is commented out of test1.c

    #if !SQLITE_OMIT_SHARED_CACHE
       { "sqlite3_enable_shared_cache", test_enable_shared, 0  ),
       { "sqlite3_shared_cache_report", sqlite3BtreeSharedCacheReport, 0),
    #endif

temptrigger.test does not test for this, and fails running the line

    set ::enable_shared_cache [sqlite3_enable_shared_cache]

RECOMMENDED CHANGE:

Add an ifcapable test for the shared cache at line 17:

    ifcapable !trigger || !shared_cache { finish_test ; return }
 
3800 code closed 2009 Apr anonymous cli 2009 Apr   1 1 .genfkey does not work on quoted table names
If a foreign key constraint references a table with a quoted table name, the .genfkey command will fail on that constraint. Example:

  create table "t.3"(c1 primary key);
  create table t13(c1, foreign key(c1) references "t.3"(c1));
  .genfkey

yields:

  Error in table t13: foreign key columns do not exist
 
3799 doc closed 2009 Apr anonymous front 2009 Oct   5 4 Comment is incomplete in where.c
Comment is incomplete at line 2000

    /* For application testing, randomly reverse the output order for
    ** SELECT statements that omit the ORDER BY clause.  This will help
    ** to find cases where
    */
2009-Oct-12 21:36:59 by anonymous:
No longer in code. The comment is referring to using pragma to reverse order.
 
3798 code closed 2009 Apr anonymous   2009 Apr   1 1 segmentation fault on tables with default date column
Hello,

after creating a table with date default column, insert into that table generates segmentation fault:

% ./sqlite3-3.6.12.bin test
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE config (version INTEGER, data BLOB, time_create DATE DEFAULT (DATETIME('NOW', 'LOCALTIME')));
sqlite> INSERT INTO config (version) VALUES (123342);
29017 segmentation fault (core dumped) sqlite3 test

Problem is reproducable on linux and solaris 10.

Duplicate of ticket #3791
 
3797 new closed 2009 Apr anonymous front 2009 Oct   3 3 Not optimal join implementation in some case
Sample queries:

create table t1(p1, p2)

create table t2(p1, p2)

explain select t1.p2 a, t2.p2 b from t1 left join t2 on (t1.p1=t2.p1 and t1.p2 = 1)

Generate execute plan - for each row in t1 loop throught t2 rows and if t1.p1 = t2.p1 then test t1.p2, and if it equal 1, return result row.

But more optimal for each row in t1 first test t1.p2, and if it equal 1 loop throught t2.

In this example indexes are not used, but even to them there is the same. Records at first get out of the inner loop table, and the constraints concerning the first table only are then checked.

2009-Oct-20 06:17:45 by anonymous:
Use the sqlite-users mailing list for questions.
 
3796 new closed 2009 Apr anonymous   2009 Sep   2 3 Async "attach" command
Is usefull to have a set of database files to prevent locking for full dataset. But when we want to attach databases this operation is sync and is paused (if database timeout value more than 0) on locked databases.

It is possible to permit attach databases async (or only for queries to these attached databases)?

2009-Sep-29 07:17:44 by anonymous:
Your query isn't clear enough. SQLite has to read information from databases to verify they are a valid database and to prepare/execute queries. This can't be done asyncronously. If you want that then use a seperate thread.
 
3795 code closed 2009 Apr anonymous func 2009 Apr   4 3 SQLITE returns SQLITE_CONSTRAINT twice on Trigger error.
When I executed SQL Trigger 'raise (faile, "blah...")' using C/C++ interface, I've noticed that sqlite3_finalize() returns not SQLITE_OK but SQLITE_CONTRAINTS.

But I've already got SQLITE_CONTRAINTS in return value of sqlite3_step().

Simplified SQL query: CREATE TRIGGER some_trigger BEFORE INSERT ON some_table BEGIN SELECT CASE WHEN ( some_condition ) THEN RAISE ( FAIL, "blah" ) END; END;

And FAIL on this query causes SQLITE to return SQLITE_CONSTRAINTS for twice.

Duplicate of ticket #3794.
 
3794 code closed 2009 Apr anonymous func 2009 Apr   4 3 FAIL on SQL query causes sliqte3 to return SQLITE_CONSTRAINT twice
When I executed SQL Trigger 'raise (faile, "blah...")' using C/C++ interface, I've noticed that sqlite3_finalize() returns not SQLITE_OK but SQLITE_CONTRAINTS.

But I've already got SQLITE_CONTRAINTS in return value of sqlite3_step().

Simplified SQL query: CREATE TRIGGER some_trigger BEFORE INSERT ON some_table BEGIN SELECT CASE WHEN ( some_condition ) THEN RAISE ( FAIL, "blah" ) END; END;

And FAIL on this query causes SQLITE to return SQLITE_CONSTRAINTS for twice.

2009-Apr-09 00:44:05 by drh:
That is what the documentation for sqlite3_finalize() says it is suppose to do.
 
3793 code fixed 2009 Apr anonymous back 2009 May danielk1977 2 3 SQLite assert indicates BtShared object points to wrong db connection
I am seeing an assert(sqlite3_mutex_held(pBt->db->mutex)) from SQLite in btreeInvokeBusyHandler(). My test spawns 5 threads, each of which modifies and queries its own table in a common database (each thread uses a separate connection from sqlite3_open_v2() to the same filename with shared cache enabled). At the time of the assert(), it seems that the common BtShared object points to a database connection (pBt->db) from the wrong thread.

Normally when a thread takes the BtShared mutex on a Btree operation by calling sqlite3BtreeEnter(), it also updates the database connection in that shared object (pBt->db) - in other words while a thread owns the mutex, the Btree and BtShared objects both point to that thread's database connection. However, I think there is a case where a thread can take this mutex without updating the BtShared database connection - when sqlite3VdbeExec() calls sqlite3BtreeMutexArrayEnter(). If I modify sqlite3BtreeMutexArrayEnter() to explicitly set the BtShared database connection (p->pBt->db = p->db) after every call to sqlite3_mutex_enter(p->pBt->mutex), the assert() goes away. Does this indicate a bug in SQLite, or simply an unnecessary assert()?

Bug demo attached. Fix coming soon.
 
3792 secure closed 2009 Apr anonymous cli 2009 Sep   3 4 HTML mode does not quote special characters in headers
HTML mode does not quote HTML special characters like < & in headers. This allows an attacker who is able to write data into a database which ends up in a column name to hide or modify records in the output, and to inject potentially dangerous code, e. g. Javascript to perform cross-site scripting or cross-site request forgery attacks.

The quoting of special characters in headers should be the same as for data in records, e. g.:

  echo "select '< &';" | sqlite3 -html
  <TR><TH>'< &'</TH></TR>
  <TR><TD>&lt; &</TD>
  </TR>
2009-Sep-29 07:36:06 by anonymous:
http://www.sqlite.org/src/tktview/dc3a6e5b31378eea92795c64ed25385eb07d61ed
 
3791 code fixed 2009 Apr drh front 2009 Apr   1 1 INSERT into table with DEFAULT column value segfaults.
The following SQL causes a segfault:

   CREATE TABLE t1(x, y DEFAULT(datetime('now')));
   INSERT INTO t1(x) VALUES(1);

This is a distillation of the problem reported on the mailing list by Arthur Skowrenek

 
3790 code closed 2009 Apr anonymous build 2009 Apr   3 4 Define SQLITE_OMIT_TRIGGER
When defined SQLITE_OMIT_TRIGGER the function sqlite3DropTable has undefined function call related to triggers (sqlite3TriggerList).
Thanks. This one already fixed by [6464] .
 
3789 todo closed 2009 Apr anonymous   2009 Apr   1 1 Cannot turn INTEGER auto-inc *off*
Am evaluating SQLite, and creating a test program to copy Clarion TPS data into SQLite. A couple of my tables have existing "ID" PK values, so I need to transfer them as-is - but SQLlite won't let me.

Every table with INTEGER (null or not null) with a CONSTRAINT of Primary Key (but not declared as "INTEGER PRIMARY KEY") assumes autoinc.

Example table def. with problem:

CREATE TABLE "CashRegTransHdr"
(
  "TransacNo" INTEGER NOT NULL,
  "StoreSysID" integer NOT NULL,
  "TillNo" smallint,
  "TransacDate" date,
  "TransacTime" time,
  "Operator" smallint,
  "AmountForRoyaltyCalc" real,
  "TransacTot" real,
  "TaxAmount" real,
  "Taxable" real,
  "NonTaxable" real,
  "Discount" real,
  "ByCash" real,
  "ByEftPos" real,
  "ByCheque" real,
  "ByCreditCard" real,
  "Change" real,
  "NumItems" smallint,
  "NoSaleMode" smallint,
  "PreOrderMode" smallint,
  "PreOrderTotalAmount" real,
  "IsPreOrderPickup" boolean default false,
  "DepositAmount" real,
  "ValueAddAmount" real,
  "LinkID" integer,
  "DTstamp" integer,
  CONSTRAINT "PK_CTH" PRIMARY KEY ("TransacNo")
)

I want to import existing TransacNos .. but SQLlite is renumbering, starting from 1....

I attached a log file, where you can see existing TransacNos are being applied, but ignored.

NOTE: I am using with ODBC 0.8

Steve

2009-Apr-08 02:49:54 by drh:
According to your log, when you are inserting into the CashRegTransHdr table, you are not telling it what the TransacNo is. So SQLite is picking one for you automatically. This is what SQLite is designed to do. If you want to copy over the TransacNo, then include it in your INSERT statement.
 
3788 code closed 2009 Apr anonymous   2009 Apr   2 3 Extremely excessive memory usage and slowness when using 32k page_size
Sustained un-indexed inserts using 32k pages use an excessive amount of memory and are slower than inserts on a 1024 page database.

I will attach a C program that illustrates the issue under linux.

This is a very important issue for us as we partition data into multiple files and can be writing to as many as 50-100 files at once so this bug causes the process to OOM.

The work around is to use a 1024 page size. This significantly degrades query performance.

2009-Apr-07 16:10:35 by anonymous:
NOTE: In C program the example trace in the comments shows a growth to only 16M but on our production servers using a table with more columns this same program grows to 65M! This is how having 50-100 open files can cause OOM issues.


2009-Apr-07 16:18:35 by drh:
Well, a cache size of 2000 pages at 32K per page comes to 65MB. So I do not see how this is a bug in SQLite.

Have you considered reducing the size of your cache using the cache_size pragma?


2009-Apr-07 21:48:15 by anonymous:
Checking cache_size now (although I thought I did this before to no effect. I hope I am wrong).

Any idea why it is slower insert with a 32k page size? I would think it would be faster (less writes).


2009-Apr-08 15:35:22 by anonymous:
Follow up for posterity. cache_size pragma works to control memory foot print on inserts.
 
3787 doc closed 2009 Apr anonymous   2009 Apr   5 4 Funny "ah" in http://www.sqlite.org/limits.html
Ah, I wonder how this got into http://www.sqlite.org/limits.html?

;-)

Thanks. Fixed here:

  http://www.sqlite.org/docsrc/ci/d8a646e9898ba20fd7e6937ee4a966db39285dcb
 
3786 code closed 2009 Apr anonymous   2009 Apr   1 1 sqlite3TriggerList still used despite of SQLITE_OMIT_TRIGGER
With SQLITE_OMIT_TRIGGER #defined, the sqlite3TriggerList() implementation is excluded from triggers.c.

However, sqlite3TriggerList() is still called from these source files:

  * alter.c
  * build.c
  * insert.c

I suppose that the relevant sections could be #ifdefed out, but I am unsure if it would be better to re-#define sqlite3TriggerList in sqliteInt.h.

 
3785 code closed 2009 Apr anonymous front 2009 Oct   3 3 cannot join using column oid - column not present in both tables
  SQLite version 3.6.12
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t1(a);
  sqlite> create table t2(a);
  sqlite> select * from t1, t2 using(oid);
  SQL error: cannot join using column oid - column not present in both tables
  sqlite> select t1.oid, t2.oid from t1, t2 using(oid);
  SQL error: cannot join using column oid - column not present in both tables
  sqlite> select t1.oid, t2.oid from t1, t2;
  sqlite> select * from t1, t2 on t1.oid = t2.oid;
  sqlite>
2009-Oct-24 00:46:01 by anonymous:
This tracker and ticket are now closed. Please continue discussion on the sqlite-users mailing list where other developers can help with the issue and explore possible solutions.
 
3784 code closed 2009 Apr anonymous   2009 Apr   3 3 With check-in [6454], "PRAGMA default;" still reports syntax error
With check-in [6454] ,

  PRAGMA default;

still reports a syntax error. On the other hand, these PRAGMAs do not:

  PRAGMA defaul;
  PRAGMA defaultx;
2009-Apr-07 15:43:32 by drh:
The purpose of check-in [6454] is to allow pragmas of the following form:

    PRAGMA temp_store(default);

Check-in [6454] was never intended to allow a pragma named "default". Only to allow the argument to the pragma to be "default".


2009-Apr-07 17:15:11 by anonymous:
Thanks for clearing this up!
 
3783 code closed 2009 Apr anonymous build 2009 Apr   4 3 notify.c: Missing (void) in procedure defs
In notify.c, the procedures enterMutex() and leaveMutex() are missing the void parameter declaration, which leads to unpleasant warnings with certain compilers wherever those procedures are called.

Adding (void), as common practice throughout SQLite, removes those warnings:

  /*
  ** Obtain the STATIC_MASTER mutex.
  */
  static void enterMutex(void){
                         ~~~~ ADD THIS
    sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
    checkListProperties(0);
  }

  /*
  ** Release the STATIC_MASTER mutex.
  */
  static void leaveMutex(void){
                         ~~~~ ADD THIS
    assertMutexHeld();
    checkListProperties(0);
    sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
  }
 
3782 new closed 2009 Apr anonymous front 2009 Oct   5 4 parse ADD CONSTRAINT in ALTER TABLE statements
I would like to see the possibility to add constraints in ALTER TABLE statements.

I know constraints created with CREATE TABLE are not enforced, but at least the parser accepts them. Similarly I would like the parser to accept ADD CONSTRAINT in ALTER TABLE statements.

Jarl

2009-Oct-24 00:52:30 by anonymous:
Constraints are enforced. You need to be clearer about what you are trying to achieve on the sqlite-users mailing list.
 
3781 code fixed 2009 Apr anonymous vfs 2009 Apr   4 4 Wrong assert in unixOpen()
In file /sqlite/src/os_unix.c in function unixOpen() there's assert:

  assert(fd != 0);

It's wrong. fd can be equal to 0 in case if I've closed stdin before calling sqlite3_open_v2().

 
3780 code fixed 2009 Apr drh front 2009 Apr   4 1 The reverse_unordered_sorts pragma does not always work.
On a query of an unindexed table where the query has no WHERE clause, the reverse_unordered_selects pragma does not change the output order.
 
3779 code closed 2009 Apr anonymous cli 2009 Oct   4 4 sqlite3 .dump sqlite_sequence table details out of sequence for .read
A database with auto_increment attributes contains a table called sqlite_sequence.

Command line sqlite3 program .dump command creates sql statements for sqlite_sequence table rows before creating statements for relevant auto_increment attributes in other tables.

Attempt to .read into a new, empty database the output from a .dump command reports errors on the lines:

  DELETE FROM sqlite_sequence;

  INSERT INTO "sqlite_sequence" VALUES('attributename',##);

because the sqlite_sequence table does not yet exist.

2009-Oct-12 21:37:59 by anonymous:
This is fixed.
 
3778 build closed 2009 Apr anonymous   2009 Apr   1 1 SQLITE_OMIT_VIRTUALTABLE - compile error
sqlite-amalgamation-3_6_12.zip; Visual Studio 2005; Compiled with SQLITE_OMIT_VIRTUALTABLE;

I got an error: error C2129: static function 'void sqlite3VtabArgInit(Parse *)' declared but not defined

2009-Apr-05 21:44:22 by drh:
Please see http://www.sqlite.org/faq.html#q23
 
3777 code fixed 2009 Apr anonymous back 2009 Apr   1 1 CREATE TABLE with a UNIQUE column causes bus error (sigbus) on SPARC
On Linux/SPARC (but probably all other OSes on SPARC, too) sqlite crashes with a bus error (sigbus) when creating a table with a unique column.

CREATE TABLE test (a VARCHAR(1)); # works
CREATE TABLE test (a VARCHAR(1) UNIQUE); # crashes
The problem is that sqlite is doing unalined memory access. Mem->u.i is an int64 and needs to be aligned by 8 but it only is aligned by 4. It can be reproduced using the sqlite versions Gentoo and Debian have and also using the trunk from cvs.

It was detected because firefox(3.1) uses it to store bookmarks and therefore crashes on SPARC systems.

I wrote a patch which seems to fix the bug, however with this patch applied firefox still crashes therefore I probably missed something.

--- src/vdbeInt.h
+++ src/vdbeInt.h
@@ -125,6 +125,8 @@
   u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
   void (*xDel)(void *);  /* If not null, call this function to delete Mem.z */
   char *zMalloc;      /* Dynamic buffer allocated by sqlite3_malloc() */
+
+  char __alignment_dummy[4];   /* Dummy to make sizeof(Mem) dividable by 8 */
 };

 /* One or more of the following flags are set to indicate the validOK
And here's the output from gdb, reproducing it using the cvs checkout of 2009-04-04 (a few minutes ago):

GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-unknown-linux-gnu"...
(gdb) set args /tmp/brand_new_database
(gdb) start
Breakpoint 1 at 0x168c0: file ./src/shell.c, line 2987.
Starting program: /tmp/sqlite/bin/sqlite3 /tmp/brand_new_database
main (argc=2, argv=0xff86b514) at ./src/shell.c:2987
2987	  Argv0 = argv[0];
(gdb) continue
Continuing.
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE test (a VARCHAR(1) UNIQUE);

Program received signal SIGBUS, Bus error.
0xf7ecd7f8 in sqlite3VdbeRealValue (pMem=0x4ef5c) at ./src/vdbemem.c:379
379	    return (double)pMem->u.i;
(gdb) backtrace
#0  0xf7ecd7f8 in sqlite3VdbeRealValue (pMem=0x4ef5c) at ./src/vdbemem.c:379
#1  0xf7ec7618 in sqlite3VdbeExec (p=0x4dbf8) at ./src/vdbe.c:1903
#2  0xf7ec9854 in sqlite3_step (pStmt=0x4dbf8) at ./src/vdbeapi.c:484
#3  0xf7ea1354 in sqlite3_exec (db=0x3ef20,
    zSql=0x3eeb0 "CREATE TABLE test (a VARCHAR(1) UNIQUE);",
    xCallback=0x13310 <callback>, pArg=0xff869f0c, pzErrMsg=0xff869e94)
    at ./src/legacy.c:72
#4  0x0001653c in process_input (p=0xff869f0c, in=0x0) at ./src/shell.c:2797
#5  0x00016ea4 in main (argc=2, argv=0xff86b514) at ./src/shell.c:3145
(gdb) print &pMem->u.i
$1 = (i64 *) 0x4ef5c
(gdb) info frame
Stack level 0, frame at 0xff869960:
 pc = 0xf7ecd7f8 in sqlite3VdbeRealValue (./src/vdbemem.c:379);
    saved pc 0xf7ec7618
 called by frame at 0xff869c90
 source language c.
 Arglist at 0xff869960, args: pMem=0x4ef5c
 Locals at 0xff869960, Previous frame's sp in fp
 Saved registers:
  l0 at 0xff869960, l1 at 0xff869964, l2 at 0xff869968, l3 at 0xff86996c,
  l4 at 0xff869970, l5 at 0xff869974, l6 at 0xff869978, l7 at 0xff86997c,
  i0 at 0xff869980, i1 at 0xff869984, i2 at 0xff869988, i3 at 0xff86998c,
  i4 at 0xff869990, i5 at 0xff869994, fp at 0xff869998, i7 at 0xff86999c
(gdb) disass $pc-32 $pc+32
Dump of assembler code from 0xf7ecd7d8 to 0xf7ecd818:
0xf7ecd7d8 <sqlite3VdbeRealValue+44>:	sethi  %hi(0x800), %g1
0xf7ecd7dc <sqlite3VdbeRealValue+48>:	or  %g1, 0x298, %g1	! 0xa98
0xf7ecd7e0 <sqlite3VdbeRealValue+52>:	ld  [ %l7 + %g1 ], %g1
0xf7ecd7e4 <sqlite3VdbeRealValue+56>:	bne  0xf7ecd810 <sqlite3VdbeRealValue+100>
0xf7ecd7e8 <sqlite3VdbeRealValue+60>:	ldd  [ %g1 ], %f0
0xf7ecd7ec <sqlite3VdbeRealValue+64>:	ret
0xf7ecd7f0 <sqlite3VdbeRealValue+68>:	restore
0xf7ecd7f4 <sqlite3VdbeRealValue+72>:	call  0xf7ed5f00 <__floatdidf>
0xf7ecd7f8 <sqlite3VdbeRealValue+76>:	ldd  [ %i0 ], %o0
0xf7ecd7fc <sqlite3VdbeRealValue+80>:	ret
0xf7ecd800 <sqlite3VdbeRealValue+84>:	restore
0xf7ecd804 <sqlite3VdbeRealValue+88>:	ldd  [ %i0 + 8 ], %f0
0xf7ecd808 <sqlite3VdbeRealValue+92>:	ret
0xf7ecd80c <sqlite3VdbeRealValue+96>:	restore
0xf7ecd810 <sqlite3VdbeRealValue+100>:	or  %g2, 2, %g2
0xf7ecd814 <sqlite3VdbeRealValue+104>:	sethi  %hi(0x800), %g1
End of assembler dump.
(gdb) info registers
g0             0x0	0
g1             0x4	4
g2             0x4	4
g3             0xf7ef2098	-135323496
g4             0xf7ef2094	-135323500
g5             0x53514c69	1397836905
g6             0xf7f28d90	-135098992
g7             0xf7c22e00	-138269184
o0             0xf7ecd7ac	-135473236
o1             0x82094	532628
o2             0x1	1
o3             0x0	0
o4             0x0	0
o5             0x0	0
sp             0xff8698e8	0xff8698e8
o7             0xf7ecd7f4	-135473164
l0             0x3f390	258960
l1             0x3f360	258912
l2             0x3f390	258960
l3             0x3f360	258912
l4             0x1	1
l5             0x0	0
l6             0x1	1
l7             0xf7ef0000	-135331840
i0             0x4ef5c	323420
i1             0x2	2
i2             0xff869c70	-7955344
i3             0xff86994c	-7956148
i4             0x4eee4	323300
---Type <return> to continue, or q <return> to quit---
i5             0xf7ec2e64	-135516572
fp             0xff869960	0xff869960
i7             0xf7ec7610	-135498224
y              0x0	0
psr            0xff440087	[ #0 #1 #2 S #18 #22 #24 #25 #26 #27 #28 #29 #30 #31 ]
wim            0x0	0
tbr            0x0	0
pc             0xf7ecd7f8	0xf7ecd7f8 <sqlite3VdbeRealValue+76>
npc            0xf7ed5f00	0xf7ed5f00 <__floatdidf>
fsr            0x0	[ ]
csr            0x0	0
(gdb) quit
The program is running.  Exit anyway? (y or n) y
Let me know if you need further information or testing. Thanks for looking at this.
2009-Apr-04 22:52:25 by drh:
How can an object like Mem that contains an element requiring 8-byte alignment not be a multiple of 8 in size? What compiler are you using? Does the compiler not allow for arrays of structures that have elements requiring 8-byte alignment?

What size is your Mem structure? I'm getting 40 bytes on x86 and 56 bytes on x86_64. (Notice that both are divisible by 8.)


2009-Apr-05 04:16:41 by anonymous:
Hello,

> How can an object like Mem that contains an element requiring 8-byte > alignment not be a multiple of 8 in size?

The comment in the patch isn't really correct, the address of Mem/Mem->u.i needs to be aligned by 8, sorry for that.

sizeof(Mem) is a multiple of 8. (It's 40)

> What compiler are you using?

Tried using gcc 4.3.2 and 4.3.3, output of gcc -v is:

Using built-in specs. Target: sparc-unknown-linux-gnu Configured with: /tmp/portage/sys-devel/gcc-4.3.3-r2/work/gcc-4.3.3/configure --prefix=/usr --bindir=/usr/sparc-unknown-linux-gnu/gcc-bin/4.3.3 --includedir=/usr/lib/gcc/sparc-unknown-linux-gnu/4.3.3/include --datadir=/usr/share/gcc-data/sparc-unknown-linux-gnu/4.3.3 --mandir=/usr/share/gcc-data/sparc-unknown-linux-gnu/4.3.3/man --infodir=/usr/share/gcc-data/sparc-unknown-linux-gnu/4.3.3/info --with-gxx-include-dir=/usr/lib/gcc/sparc-unknown-linux-gnu/4.3.3/include/g++-v4 --host=sparc-unknown-linux-gnu --build=sparc-unknown-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --enable-languages=c,c++,java,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3-r2 p1.1, pie-10.1.5' Thread model: posix gcc version 4.3.3 (Gentoo 4.3.3-r2 p1.1, pie-10.1.5)

> Does the compiler not allow for arrays of structures that have elements > requiring 8-byte alignment?

The compiler does the alignment correctly, unless you do casts that break the alignment, such as accessing an int as char.

> What size is your Mem structure?

40

I did more research and I found the solution :)

In sqlite memory for the Mem structs is allocated using the "allocSpace" function, but this function doesn't care about alignment, it just uses the next available memory in the global buffer.

--- src/vdbeaux.c
+++ src/vdbeaux.c
@@ -1100,6 +1100,10 @@
     do {
       memset(zCsr, 0, zEnd-zCsr);
       nByte = 0;
+      while (((int) zCsr) % 8 > 0) {
+        /* ensure the memory we allocate for Mem structs is aligned by 8 */
+        zCsr++;
+      }
       allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
       allocSpace((char*)&p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
       allocSpace((char*)&p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
But I got another bus error: when starting sqlite without a database file (using the in-memory journal), any create table such as "create table a (b int);" causes a bus error.

GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-unknown-linux-gnu"...
(gdb) start
Breakpoint 1 at 0x168c0: file ./src/shell.c, line 2987.
Starting program: /tmp/sqlite/bin/sqlite3
main (argc=1, argv=0xffd7b534) at ./src/shell.c:2987
2987      Argv0 = argv[0];
(gdb) continue
Continuing.
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE a (B VARCHAR(1));

Program received signal SIGBUS, Bus error.
0xf7e84cac in memjrnlWrite (pJfd=0x3fb1c, zBuf=0x3f5d8, iAmt=512, iOfst=0)
    at ./src/memjournal.c:136
135   while( nWrite>0 ){
(gdb) backtrace
#0  0xf7e84cac in memjrnlWrite (pJfd=0x3fb1c, zBuf=0x3f5d8, iAmt=512, iOfst=0)
    at ./src/memjournal.c:135
#1  0xf7e853f4 in sqlite3OsWrite (id=0x3fb1c, pBuf=0x3f5d8, amt=512, offset=0)
    at ./src/os.c:69
#2  0xf7e88b00 in writeJournalHdr (pPager=0x3f9f0) at ./src/pager.c:816
#3  0xf7e88bd0 in pager_open_journal (pPager=0x3f9f0) at ./src/pager.c:3985
#4  0xf7e88fa4 in pager_write (pPg=0x4d7ac) at ./src/pager.c:4109
#5  0xf7e8b160 in sqlite3PagerWrite (pDbPage=0x4d7ac) at ./src/pager.c:4302
#6  0xf7e66340 in newDatabase (pBt=0x3f578) at ./src/btree.c:2064
#7  0xf7e6c70c in sqlite3BtreeBeginTrans (p=0x3f548, wrflag=1)
    at ./src/btree.c:2185
#8  0xf7ea467c in sqlite3VdbeExec (p=0x4dc90) at ./src/vdbe.c:2651
#9  0xf7ea9854 in sqlite3_step (pStmt=0x4dc90) at ./src/vdbeapi.c:484
#10 0xf7e81354 in sqlite3_exec (db=0x3f108,
    zSql=0x3f0a0 "CREATE TABLE a (B VARCHAR(1));",
    xCallback=0x13310 <callback>, pArg=0xffd79f2c, pzErrMsg=0xffd79eb4)
    at ./src/legacy.c:72
#11 0x0001653c in process_input (p=0xffd79f2c, in=0x0) at ./src/shell.c:2797
#12 0x00016ea4 in main (argc=1, argv=0xffd7b534) at ./src/shell.c:3145
(gdb) quit
The program is running.  Exit anyway? (y or n)
This is because sqlite3_file is aligned by 4 but the subclass MemJournal needs 8-byte alignment.

src/memjournal.c:125 MemJournal *p = (MemJournal *)pJfd;

But I haven't found the place where it gets allocated yet, simply adding an 8-byte dummy didn't do the job.

Cheers, Friedrich


2009-Apr-06 21:42:39 by anonymous:
With Check-in 6450 and 6452 it works much better, however there is one unaligned access left:

In sqlite3VdbeExec aTempRec (sizeof(UnpackedRecord) = 12) is declared. In sqlite3VdbeRecordUnpack aTempRec(called pSpace) may be used for a Mem struct, therefore it also needs to be aligned by 8.

After applying this patch to current trunk it passes the testsuite and firefox also works again:

--- src/vdbe.c
+++ src/vdbe.c
@@ -562,7 +562,10 @@
 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
   int nProgressOps = 0;      /* Opcodes executed since progress callback. */
 #endif
-  UnpackedRecord aTempRec[16]; /* Space to hold a transient UnpackedRecord */
+
+  /* Space to hold a transient UnpackedRecord */
+  UnpackedRecord aTempRec[16] __attribute__((aligned(8)));
+  assert( EIGHT_BYTE_ALIGNMENT(aTempRec) );

   assert( p->magic==VDBE_MAGIC_RUN );  /* sqlite3_step() verifies this */
   assert( db->magic==SQLITE_MAGIC_BUSY );
Thank you very much for your efforts in resolving this.
 
3776 code closed 2009 Apr anonymous cli 2009 Apr anonymous 3 2 when use 'case' in a view, the where subclause is type awared
I create two tables, and insert one row data into each table, just like :
    create table t1(id integer primary key);
    create table t2(id integer primary key);
    insert into t1 valuse(1);
    insert into t2 valuse(1);

then create a view like this:

    create view v1 as
    select t1.id as id,
    case 1 when t2.id is null then 0 else t2.id end as t2id
    from t1, t2 where t1.id=t2.id;

then use the select with a string format integer to select data from view, but no data return :

    select id,t2id from v1 where id='1' and t2id='1';

But if use a integer expression, it work correctly:

    select id,t2id from v1 where id=1 and t2id=1;

and if only id is string format integer, it work happily:

    select id,t2id from v1 where id='1' and t2id=1;

in other words, the 't2id' which is from a case subclause is data type awared, it is not like which sqlite announced.

2009-Apr-03 12:22:36 by anonymous:
version 3.5.4 has same problem.


2009-Apr-03 12:22:47 by drh:
SQLite is working as it was designed here. If you have questions, please ask them on the mailing list.
 
3775 doc fixed 2009 Apr anonymous   2009 Apr   4 4 SQLITE_LOCKED_SHAREDCACHE missing from constlist.html
The extended error code SQLITE_LOCKED_SHAREDCACHE is not listed in the page of constants http://www.sqlite.org/c3ref/constlist.html
 
3774 code fixed 2009 Apr anonymous back 2009 Apr   2 3 select count(*) from sqlite_master fails on new database
After upgrading to 3.6.12, the following statement crashed the application when executed on an empty database.

    SQLite version 3.6.12
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite>select count(*) from sqlite_master;
 
3773 code fixed 2009 Apr anonymous   2009 Apr   1 3 bug which may leads to segmentation fault in sqlite
the bug is shown by the sample sqlite session below:

  sqlite> SELECT T1.C0 FROM (SELECT X.cw_eid AS C0, X.cw_creation_date AS C1
   ...> FROM cw_EmailAddress AS X
   ...> UNION ALL
   ...> SELECT X.cw_eid AS C0, X.cw_creation_date AS C1
   ...> FROM cw_File AS X
   ...> ORDER BY 2 DESC) AS T1
   ...>
   ...> ;
  SQL error: 1st ORDER BY term out of range - should be between 1 and 1
  sqlite>
  sqlite> SELECT T1.C0 FROM (SELECT X.cw_eid AS C0, X.cw_creation_date AS C1
   ...> FROM cw_EmailAddress AS X
   ...> UNION ALL
   ...> SELECT X.cw_eid AS C0, X.cw_creation_date AS C1
   ...> FROM cw_File AS X
   ...> ORDER BY 2 DESC) AS T1
   ...> ;
  Erreur de segmentation

side notes:

* this has been introduced in recent sqlite release, ought to work before

* as you can see in the session, the first time the query is issued, the error "SQL error: 1st ORDER BY term out of range - should be between 1 and 1" is issued while it's not true, sorting on column 2 should be ok

* if I run the same query again, then I get a segfault; ouch...

2009-Apr-02 16:30:11 by drh:
Test case:

  CREATE TABLE t1(a,b);
  CREATE TABLE t2(x,y);
  SELECT a FROM (
    SELECT a, b FROM t1
    UNION ALL
    SELECT x, y FROM t2
    ORDER BY 2
  );


2009-Apr-02 17:00:27 by drh:
This is fixed in CVS as of check-in [6437] . If you do not want to use sources out of CVS, your temporary work-around until the next official release is to add

    LIMIT -1 OFFSET 0

after the ORDER BY clause on the subquery.

 
3772 build closed 2009 Apr anonymous   2009 Apr   1 1 3.6.12 (today's cvs) fails to configure
  Please provide the syntax to run autoconf for sqlite. I've tried
  several ways of autoconf and autoupdate with no success. The
  error reported is:

   configure: error: configure script is out of date:
    configure $PACKAGE_VERSION = 3.6.12
    top level VERSION file     =
   please regen with autoconf
2009-Apr-02 14:26:44 by drh:
We do not support configure for CVS downloads. We barely support configure for official releases. Sorry. If you have questions on how to build SQLite, please ask them on the SQLite mailing list.
 
3771 code closed 2009 Apr danielk1977 front 2009 Apr danielk1977 1 1 Missing OP_VerifyCookie in "<expr> IN (SELECT c FROM t)"
When an expression of the form:

  <expr> IN (SELECT c FROM t)

is evaluated, if there is an index on t(c), then it is used to optimize the query. SQLite does not code the required OP_VerifyCookie and OP_Transaction opcodes in this case. Same bug shows up for:

  <expr> IN (SELECT rowid FROM t)
 
3770 new closed 2009 Apr anonymous front 2009 Oct   3 3 Optimizations
With:

  create table t1(a unique);
  create table t2(a unique);
  create table t3(a unique);

Those queries are optimized (no temporary tables):

  select * from (select * from t1) left join t3 using(a) order by a
  select * from (select * from t1 union all select * from t2)

But this isn't (creates two temporary tables):

  select * from (select * from t1 union all select * from t2) left join t3 using(a) order by a

Query can be changed to this (one temporary table):

  select * from (select * from t1 union all select * from t2 order by a) left join t3 using(a)

This will probably allways return sorted rows, but as long something simillar won't be done by library the query is invalid.

I don't think current implementation allows to create query that creates no temporary tables, which seems to be possible after optimizations.

2009-Oct-03 02:28:41 by anonymous:
It isn't clear what you want to happen. Please discuss further on the sqlite-users mailing list especially including some numbers. For example using a reasonable sized data set show what timings you get with the 'slow' and 'fast' versions of the query. It will also be helpful to see how many other people use similar queries, and would depend on SQLite to optimize them rather than doing what you did.
 
3769 code fixed 2009 Apr drh func 2009 Apr   1 1 The %s format in strftime() fails after 2038-01-19 03:14:07
The %s format in strftime is computed using a 32-bit integer instead of a 64-bit integer and hence fails for dates past 2038-01-19 03:14:07.
Check-in [6430] produces rounding errors and wrong results with Borland / CodeGear compilers.

  datetest 3.8.2 {strftime('%s','2038-01-19 03:14:07')} 2147483647

Fails with the following result:

  2147483646 (off by 1)

The problem happens here:

  sqlite3_snprintf(30,&z[j],"%lld",
    (i64)(x.iJD/1000.0 - 210866760000.0)); // <-- Rounding errors.

When I change the floating point numbers to integers, it fixes the problem for me:

  sqlite3_snprintf(30,&z[j],"%lld",
    (i64)(x.iJD/1000 - 210866760000)); // <-- Integers only.

However, I am not sure if this also works for other compilers.

 
3768 code closed 2009 Apr anonymous front 2009 Apr   5 4 No syntax error when FROM is mistyped
The query:

  select s.id from seen_bys s where 1=1
    and (select count(*) seen_bys where id = s.id and net = 50 and node = 361) = 1
    and (select count(*) seen_bys where id = s.id and net = 400 and node = 333) = 1
    -- 134 expressions skipped
  group by s.id having count(*) = 136;

Do not produce syntax error. Note missing FROM after select count(*).

Kind Regards, Oleg.

2009-Apr-01 19:47:44 by drh:
SQLite does not require a FROM clause. This is useful, for example, in triggers when you want to invoke a application-defined function. Or, to type things like:

   SELECT sqlite_version();

on the command-line prompt.

Your query is syntactically well-formed, though not particularly useful. All of the terms in the WHERE clause resolve to elements in the outer query so no errors occur their either.

 
3767 new closed 2009 Apr anonymous front 2009 Oct   3 4 Significant GROUP BY speed-up
Consider the following dynamically generated query:

  select s.id from seen_bys s where 1=1
    and (select count(*) from seen_bys where id = s.id and net = 50 and node = 361) = 1
    and (select count(*) from seen_bys where id = s.id and net = 400 and node = 333) = 1
  -- skipped 134 similar expressions
  group by s.id having count(*) = 136;

Let's execute this against the database with data. First run:

  time cat query_not_optimal | ./sqlite3 test.db
  1719

  real    0m7.286s
  user    0m6.268s
  sys     0m0.056s

Second run (just for fun):

  time cat query_not_optimal | ./sqlite3 test.db
  1719

  real    0m6.878s
  user    0m6.720s
  sys     0m0.020s

I'm not familiar with SQLite's code generator, but I wonder why SQLite do not GROUP BY before applying WHERE clause. OK. I'll do this manually:

  select s.id from (select id from seen_bys group by id having count(*) = 136) s where 1=1
    and (select count(*) from seen_bys where id = s.id and net = 50 and node = 361) = 1
    and (select count(*) from seen_bys where id = s.id and net = 400 and node = 333) = 1
    -- skipped 134 expr.

First run:

  time cat query_optimal | ./sqlite3 test.db
  1719

  real    0m0.211s
  user    0m0.144s
  sys     0m0.012s

Second:

  time cat query_optimal | ./sqlite3 test.db
  1719

  real    0m0.219s
  user    0m0.148s
  sys     0m0.024s

Kind Regards, Oleg

2009-Apr-19 18:15:20 by anonymous:
By the definition of SQL, the WHERE clause is applied to the data that goes into the aggregation, not to the results of the aggregation. The HAVING clause is applied to the latter.


2009-Oct-20 05:31:42 by anonymous:
This does not appear to be a bug. Please continue discussion on the sqlite-users mailing list if appropriate.
 
3766 code fixed 2009 Apr drh front 2009 Apr   4 1 pzTail pointer set incorrectly on the sqlite3_prepare16_v2() interface
When a UTF-16 SQL statement containing one or more surrogate pairs is passed into the sqlite3_prepare16_v2() or sqlite3_prepare16() interfaces, the pzTail pointer is set incorrectly. It is off by the number of surrogate pairs in the original SQL statement.
Test coverage provided by TH3.
 
3765 build closed 2009 Mar anonymous build 2009 Jun anonymous 3 3 Warning during make of amalgamation version 3.6.12
1. Running under Ubuntu Linux 8.10 fully updated.

2. Downloaded sqlite-amalgamation-3.6.12.tar.gz

3. gcc --version

   gcc (Ubuntu 4.3.2-1ubuntu12) 4.3.2

4. sudo ./configure

5. sudo make

6. Warning reported:

gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.6.12\" "-DPACKAGE_STRING=\"sqlite 3.6.12\"" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.6.12\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_READLINE=1 -I. -I. -DSQLITE_THREADSAFE=1 -g -O2 -MT sqlite3.lo -MD -MP -MF .deps/sqlite3.Tpo -c sqlite3.c -fPIC -DPIC -o .libs/sqlite3.o

In function 'memset', inlined from 'exprDup' at sqlite3.c:57675: /usr/include/bits/string3.h:82: warning: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters

7. sudo make install

8. sqlite3 test.db -- appears to operate correctly

2009-Mar-31 16:18:40 by drh:
The line of code in question is:

   memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);

nSize is a variable. EXPR_FULLSIZE is a macro that resolves to sizeof(Expr). It is a simple matter to set a breakpoint on this line and look for cases where the 3rd is non-zero. In gdb:

   br sqlite3.c:57675
   condition 1 nSize<sizeof(Expr)

Such a breakpoint is hit very quickly when running the test suite, showing that the length parameter is neither constant nor zero.

So I think this is a bug in your compiler, not in SQLite.


2009-Jun-04 00:09:15 by anonymous:
This issue appears to be similar to: https://bugzilla.redhat.com/show_bug.cgi?id=452219

It looks like what happens in this case is that since exprStructSize returns only 3 possible values, and one of them is EXPR_FULLSIZE, there is a branch of the code in which the third parameter supplied to memset is known at compile-time to be zero.

The whole point of building as an amalgamation is to allow compilers to do inlining and other kinds of optimizations, and the warning is an example of what happens when an optimizing compiler separates out some execution paths.

It doesn't seem quite right to call this a bug in gcc. Adding an extra check here to determine whether nSize < EXPR_FULLSIZE has two advantages:

  1. It makes the resulting object file smaller
  2. It eliminates the warning

I suggest such a change is worth considering.

 
3764 code closed 2009 Mar anonymous ext 2009 Oct   3 4 contrib: extension-functions.c
In function _substr():

    do{
      c1 = sqliteCharVal((unsigned char *)zt1);
      c2 = sqliteCharVal((unsigned char *)zt2);
      sqliteNextChar(zt1);
      sqliteNextChar(zt2);
    }while( c1 == c2 && c1 != 0 && c2 != 0 );

should be changed to:

    do{
      c1 = sqliteCharVal((unsigned char *)zt1);
      c2 = sqliteCharVal((unsigned char *)zt2);
      if (c1 == 0 || c2 == 0) break;
      sqliteNextChar(zt1);
      sqliteNextChar(zt2);
    }while( c1 == c2 );
2009-Oct-13 00:01:20 by anonymous:
Contact the author, not us.
 
3763 new closed 2009 Mar anonymous func 2009 Sep dwong 1 1 Database handle for smart pointers
Hello!

While experimenting with SQLite, in C++, I noticed there is no way to open a database and get a pointer returned. This is generally no problem, unless one wants to handle databases with smart pointers.

Other allocation functions offer this, for example one can write:

shared_ptr <char> sql ( sqlite3_mprintf ("INSERT INTO products (id) VALUES (%d);", 777), sqlite3_free ); // ... sqlite3_exec (database, sql.get(), NULL, NULL, NULL);

But, using smart pointers with databases requires at least one dangerous pointer somewhere, example:

sqlite3 *temp; sqlite3_open ("test.sqlite", &temp); shared_ptr <sqlite3> database (temp, sqlite3_close);

A new sqlite3_open function with a form similar to malloc would be very nice.

Regards, Frans Eliasson, Uppsala, Sweden

2009-Aug-15 22:31:20 by anonymous:
If you really want to do this, just create or reset your shared_ptr after the open call. Since sqlite doesn't throw exceptions, this is perfectly safe.


2009-Sep-30 08:37:34 by anonymous:
Your pointer wrapper would also have to be more intelligent such as calling the right routines to dispose of the pointer. (eg you should use sqlite3_free with the return of sqlite3_mprintf no regular malloc/free.) In addition to the other comment, there are several C++ wrappers for SQLite - maybe you can use one of them or at least be inspired by their implementation techniques.

Closing as SQLite is C code.

 
3762 code fixed 2009 Mar drh back 2009 Mar   1 1 ROLLBACK after incremental_vacuum causes database corruption (2)
The following code, when run against an on-disk database, results in a corrupt database file:

  PRAGMA auto_vacuum=INCREMENTAL;
  PRAGMA cache_size=10;
  CREATE TABLE t1(x);
  INSERT INTO t1 VALUES(zeroblob(900));
  INSERT INTO t1 VALUES(zeroblob(900));
  INSERT INTO t1 SELECT x FROM t1;
  INSERT INTO t1 SELECT x FROM t1;
  INSERT INTO t1 SELECT x FROM t1;
  INSERT INTO t1 SELECT x FROM t1;
  INSERT INTO t1 SELECT x FROM t1;
  INSERT INTO t1 SELECT x FROM t1;
  INSERT INTO t1 SELECT x FROM t1;
  DELETE FROM t1 WHERE rowid>202;
  VACUUM;

  BEGIN;
  DELETE FROM t1 WHERE rowid IN (10,11,12) ;
  PRAGMA incremental_vacuum(10);
  UPDATE t1 SET x=zeroblob(900) WHERE rowid BETWEEN 100 AND 110;
  INSERT INTO t1 VALUES(zeroblob(39000));
  SELECT count(*) FROM t1;
  ROLLBACK;

  PRAGMA integrity_check;

This problem was introduced by check-in [6397] and fixed by [6413] . This problem does not occur in any released version of SQLite. The problem was discovered by pre-release testing. The problem has already been fixed (by check-in [6413] ). The purpose of this ticket is to document the problem.

 
3761 code fixed 2009 Mar drh back 2009 Mar   1 1 ROLLBACK after incremental_vacuum causes database corruption
The following SQL run against an initially empty database results in a corrupt database file:

  PRAGMA auto_vacuum=INCREMENTAL;
  CREATE TABLE t1(x);
  INSERT INTO t1 VALUES(zeroblob(900));
  INSERT INTO t1 VALUES(zeroblob(900));
  INSERT INTO t1 SELECT x FROM t1;
  INSERT INTO t1 SELECT x FROM t1;
  BEGIN;
  DELETE FROM t1 WHERE rowid%2 ;
  PRAGMA incremental_vacuum(2);
  ROLLBACK;
  PRAGMA integrity_check;

This script was discovered while searching for a simple test case that demonstrated the problem that was fixed by check-in [6413] . But check-in [6413] does not fix this problem. This problem exists in all historical versions of SQLite that support incremental vacuum.

2009-Mar-30 21:59:06 by drh:
The script above seems to only fail for a :memory: database. If the database is backed by a real disk file, the ROLLBACK works correctly and the database is not corrupted.
 
3760 code closed 2009 Mar anonymous front 2009 Mar   1 1 Sqlite3 crashes when using the where command on solaris 8
When I use the where command inside of sqlite3.6.11 the program crashes. It tells me core dumped(bus error).
We think this is the same as the problem reported in #3613, #3736. The fix is in [6384] , which will be included as part of the upcoming 3.6.12 release.

If this bug is still present in 3.6.12, please reopen this ticket.

 
3759 build fixed 2009 Mar anonymous   2009 Mar   1 1 Error Compiling with Borland BCC
Compiling with BCC

 Error E2293 ../../sqlite3.c 29156: ) expected in function winCurrentTime
      Warning W8013 ../../sqlite3.c 29157: Possible use of 'timeW' before definition in function winCurrentTime
      Error E2379 ../../sqlite3.c 29157: Statement missing ; in function winCurrentTime
      Error E2379 ../../sqlite3.c 29158: Statement missing ; in function winCurrentTime
      Error E2379 ../../sqlite3.c 29160: Statement missing ; in function winCurrentTime
      Error E2293 ../../sqlite3.c 29161: ) expected in function winCurrentTime
      Error E2379 ../../sqlite3.c 29162: Statement missing ; in function winCurrentTime
      Error E2293 ../../sqlite3.c 29163: ) expected in function winCurrentTime
      Warning W8057 ../../sqlite3.c 29171: Parameter 'prNow' is never used in function winCurrentTime
BCC does not use LL to mark LONG LONG constants.

It needs suffix like i64 (or ui64):

864000000000LL --> 864000000000i64

 
3758 build closed 2009 Mar anonymous test 2009 Mar   1 1 Today's 3.6.11 cvs code fails make test
  Looks like a file is just missing.

  backup_ioerr-9.578.3... Ok
  backup_ioerr-9.578.4... Ok
  backup_ioerr-9.578.5... Ok
  ./testfixture: unable to open database file
    while executing
  "sdb eval {
    BEGIN;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, randstr(1000,1000));
    INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) ..."
    ("uplevel" body line 1)
    invoked from within
  "uplevel [list $db eval $sql]"
    (procedure "execsql" line 3)
    invoked from within
  "execsql {
    BEGIN;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, randstr(1000,1000));
    INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) F..."
    (procedure "populate_database" line 2)
    invoked from within
  "populate_database sdb"
    ("foreach" body line 19)
    invoked from within
  "foreach zSetupBak [list "" {populate_database ddb 1}] {

  incr iTest
  set bStop 0
  for {set iError 1} {$bStop == 0} {incr iError} {
  # Disable IO er..."
    ("foreach" body line 2)
    invoked from within
  "foreach iDestPagesize {512 1024 4096} {
  foreach zSetupBak [list "" {populate_database ddb 1}] {

  incr iTest
  set bStop 0
  for {set iError 1} {$bStop..."
    ("foreach" body line 2)
    invoked from within
  "foreach bPersist {0 1} {
  foreach iDestPagesize {512 1024 4096} {
  foreach zSetupBak [list "" {populate_database ddb 1}] {

  incr iTest
  set bStop 0
  f..."
    (file "../test/backup_ioerr.test" line 146)
    invoked from within
  "source $testfile"
    ("foreach" body line 6)
    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 2)
    invoked from within
  "for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
  foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
    set tail [file ..."
    (file "../test/all.test" line 77)
  make: *** [fulltest] Error 1
2009-Mar-30 07:59:41 by danielk1977:
Thanks. Fixed by [6406] .
 
3757 code fixed 2009 Mar drh front 2009 Mar   1 1 Query optimizer cost estimation on IN operators can be improved.
For queries of the form:

   SELECT * FROM t1 WHERE t1.x IN (SELECT x FROM t2);

The query optimizer guesses that the subquery will generate 25 distinct values. But if t1.x has fewer than 25 distinct values, then that estimate will clearly be too high and a full table scan will results because a full scan will seem cheaper.

 
3756 code closed 2009 Mar danielk1977 back 2009 Mar danielk1977 1 1 Obscure way to corrupt pointer page in auto-vacuum mode.
On the surface, this seems ridiculously unlikely. But it occurred repeatedly when running crash4.test using a specific Tcl version.

When a page is allocated from the end of the database file (function allocatePage() in btree.c), if the next page in the database file is a pointer map page, then the page after that is allocated instead. For example, if the database is 1 page in size, then the "next" page allocated is 3, not 2, because page 2 is a pointer map page. allocatePage() calls sqlite3PagerWrite() on page 3 in this case, but not on page 2.

When the pointer map page (page 2) is updated with the entry for the newly allocated page (page 3), the btree layer requests page 2 using sqlite3PagerGet() from the pager layer. Function readDbPage() encounters a SQLITE_IOERR_SHORT_READ error (since the file on disk is only 1 page in size). Page 2 is returned populated with uninitialized data. If one is tremendously unlucky, then the first 5 bytes of that uninitialized data exactly matches the serialized format of the pointer map entry being written to page 3. This leads function ptrmapPut() in btree.c to conclude that page 2 does not need to be written to disk, since the pointer map entry is already correct. If this happens, then the page on disk is actually set to all zeroes. Hence the pointer map entry is incorrect on disk and technically the database is corrupt.

 
3755 code closed 2009 Mar anonymous   2009 Mar   1 4 out-of-memory trying to fetch a column value in sqlite3
We have received a customer database where one row contains a single BLOB column value with 286 MB of data. While SQLite doesn't generally have a problem with such a large column value, we run into problems when trying to access that data using the sqlite3 commandline tool (and in another place, where we implement a mechanism similar to the sqlite3 tool's '.dump' command):

The database is in UTF-16 encoding, but the tool attempts to convert the output into UTF-8. When this is combined with the "quote()" function, the following query will cause the tool to run out of memory:

	SELECT quote(CommandParameters) FROM commands WHERE id=30074

Apparently, the 286 MB of column value data are copied multiple times (e.g. by the quote function) and eventually, the conversion to UTF-8 fails, because no sufficiently large memory block can be allocated (the UTF-8 conversion function probably attempts to allocate enough memory to allow for the maximum number of 6 bytes per UTF-16 character).

Do you see any way to improving this situation by e.g. attempting to do an in-place conversion without having to allocate the memory for the column value multiple times, or maybe releasing the memory for intermediate steps earlier, so that it could be re-used for new conversions that need to be done?

(Unfortunately, switching to a 64-bit application is not an option for us for various reasons, so we're stuck with 32-bit for the moment)

I understand that when using values of this size, we easily get to the limits of a 32-bit adress space, and to be honest, we didn't expect this value to become that large, so it's certainly something we'll limit in our app, too, but if there's something that could be done to improve the situation in cases where this happened, that would be very helpful...

2009-Mar-27 16:14:39 by danielk1977:
If you're passing a 286MB blob to quote(), then it creates a utf-8 text representation of it - 572MB. Because your database is utf-16, SQLite handles values internally as utf-16. So when quote() returns it converts the utf-8 to utf-16 - 1144MB. Then, to output it, the shell tool converts back to utf-8 - 572MB. Ideas:

  • You could save some memory by switching to a utf-8 database. That would eliminate the intermediate utf-16 step.

  • You could use the incremental blob API to read the blob incrementally. That is the best approach for blobs this size, if they must be stored in SQLite.

This is probably a better question for the mailing list than here. A mailing list discussion might generate a concrete feature request.

 
3754 xplatform closed 2009 Mar anonymous   2009 Oct   5 3 MySQL syntax compatibility: AUTO_INCREMENT as alias of AUTOINCREMENT
In the creation of tables syntax, the main problem I found is having to make separate SQL sentences for every engine. Most of the other queries can be solved somehow or are maybe engine-dependent optimisations, but the AUTOINCREMENT field is something very useful and it forces us to keep many files to mantain. Some compatibility in the SQL syntax with MySQL will enhance the escalability of the applications using SQLite.
2009-Oct-13 00:07:21 by anonymous:
MySQL has other incompatibilities with the SQL standard like using backslashes as an escape. You merely need to preprocess your SQL before feeding it to SQLite. Please continue discussion on sqlite-users mailing list as this ticket and tracker are now closed.
 
3753 build closed 2009 Mar anonymous test 2009 Mar danielk1977 1 1 3.6.12 (today's cvs) fails make test
  su -c "make fulltest" david
  Scratch memory used:  now          0  max          0
  Scratch overflow:     now          0  max      33104  max-size      33104
  Memory used:          now          8  max  173494528  max-size  171798754
  Page-cache used:      now          0  max         13  max-size       4096
  Page-cache overflow:  now          0  max   15268400
  Scratch memory used:  now          0  max          0
  Scratch overflow:     now          0  max      33104  max-size      33104
  thread001.1.0... Ok
  thread001.1.1... Ok
  thread001.1.2... Ok
  thread001.1.3... Ok
  ./testfixture: Error in Tcl_CreateThread()
    while executing
  "sqlthread spawn $varname [join $args ;]"
    (procedure "thread_spawn" line 2)
    invoked from within
  "thread_spawn finished($i) $dbconfig $thread_procs $thread_program"
    ("foreach" body line 78)
    invoked from within
  "foreach {tn same_db shared_cache} [list \
         1  1       0                   \
         2  0       0                   \
         3  0       1   ..."
    (file "../test/thread001.test" line 37)
    invoked from within
  "source $testfile"
    ("foreach" body line 6)
    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 2)
    invoked from within
  "for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
  foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
    set tail [file ..."
    (file "../test/all.test" line 77)
  make: *** [fulltest] Error 1
2009-Mar-26 14:04:09 by danielk1977:
Because you have built with a non-threadsafe Tcl. This needs to be fixed so that it doesn't crash...
 
3752 new closed 2009 Mar anonymous   2009 May   3 3 Provide a method to override assert in SQLite
There is currently no way to override assert in SQLite in such a way that it can be made to call a user supplied function instead of the default platform assert() implementation. Replacing assert() with a macro or function and providing a mechanism to override the default use of assert(), would be incredibly useful as we do not use the default assert implementation.
2009-Mar-26 06:15:22 by anonymous:
You should never be hitting asserts in the first place. A standard optimised compile of SQLite also doesn't use them (NDEBUG is 1).

If you are using them for whatever reason then you can arrange the compiler search path to find your version of assert.h before the platform one.


2009-Mar-26 11:26:49 by drh:
Anonymous is correct. This is not a feature request we want to consider.


2009-May-29 15:26:07 by anonymous:
"You should never be hitting asserts in the first place. A standard optimised compile of SQLite also doesn't use them (NDEBUG is 1)."

If we make changes we want to be able to verify those changes in a debug build with asserts to make sure we did not introduce any bugs.

"If you are using them for whatever reason then you can arrange the compiler search path to find your version of assert.h before the platform one."

This is not possible with out current build system and we are unable to change the system. Hence my request, we could make the change locally but we'd be effectively branching SQLite which I don't want to have to do...


2009-May-29 15:38:52 by drh:
If you are already changing the code, then it should be no problem for you to add:

    #undef assert
    #define assert(X)  whatever_you_want(X)

Thank you for your suggestion. The answer is still, empathically, "No".


2009-May-29 16:06:50 by anonymous:
We are mostly doing things like writing our own VFS implementations which we want to be able to verify in debug mode with asserts. We don't want to have to change the main SQLite engine code as that would make every integration we do with each new release more expensive.

Is there a central SQLite header file we can make that change in? I've tried that change in sqliteInt.h but we are still hitting the platform version of assert.

Something like the following in SQLite: #define sqlite_assert(x) assert(x) Would allow people in my position to override sqlite_assert without having to deal with conflicts with the platform version of assert. And it would not effect performance in any way for everyone else...


2009-May-29 16:21:33 by anonymous:
The either of the following seems to be sufficient for my needs: #define sqlite_assert( x ) assert( x ) Which would mean a one line change for me once the initial search and replace of assert(...) with sqlite_assert(...) is done.

Or something more sophisticated like using the sqlite_assert macro with a function pointer to allow overrides via sqlite3_config(): #define sqlite_assert( x ) sqltie3Config.assert( x )


2009-May-29 16:22:33 by anonymous:
Continuing via email...
 
3751 code closed 2009 Mar mlcreech   2009 Mar danielk1977 2 4 I/O error using journal_mode = TRUNCATE
Using TRUNCATE journalling mode, I get a seemingly bogus I/O error when trying to prepare() a statement. If I delete the [zero-length] journal file, the error disappears. To reproduce:

$ echo "PRAGMA journal_mode = TRUNCATE; CREATE TABLE a (blah INTEGER);" | sqlite3 test.db
Everything looks okay so far:

$ ls -l test.db*
-rw-r--r-- 1 mlcreech mlcreech 2048 Mar 25 18:24 test.db
-rw-r--r-- 1 mlcreech mlcreech    0 Mar 25 18:24 test.db-journal
$
Now compile this simple C program that tries to prepare a query:

#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"

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

	if (argc!=2) {
		printf("Usage: %s <db>\n", argv[0]);
		return 1;
	}

	retval=sqlite3_open_v2(argv[1], &db, SQLITE_OPEN_READONLY, NULL);
	if (retval!=SQLITE_OK) {
		fprintf(stderr, "Error opening '%s'\n", argv[1]);
		return 1;
	}

	retval=sqlite3_exec(db, "PRAGMA journal_mode = TRUNCATE",
	                    NULL, NULL, NULL);
	if (retval!=SQLITE_OK) {
		fprintf(stderr, "Error setting journal mode\n");
		return 1;
	}

	retval=sqlite3_prepare_v2(db, "SELECT * FROM a", -1,
	                          &stmt, NULL);
	if (retval!=SQLITE_OK) {
		fprintf(stderr, "Error preparing stmt: %d: '%s'\n",
		        retval, sqlite3_errmsg(db));
		return 1;
	}

	/* Everything's normal */
	return 0;
}
...and run it against the test database:

$ ./prog test.db
Error preparing stmt: 10: 'disk I/O error'
$
I tried this on 2 different machines, one Ext3 and one Ext4 (since I thought it might be related to the recent Ext4 hoopla) - same result on both.
2009-Mar-26 06:06:07 by danielk1977:
This is caused by the same quirk as #3745.

The connection in the C program is opened in SQLITE_OPEN_READONLY mode. This means the underlying unix file descriptor on the database file is opened in O_RDONLY mode.

When SQLite queries the database file for the schema in order to compile the SELECT statement, it sees the empty journal in the file system, it attempts to obtain an exclusive lock on the database file (this is a bug). The attempt to obtain an exclusive (write) lock on a read-only file fails at the OS level. Under unix, fcntl() reports an EBADF - "Bad file descriptor" - error.


2009-Mar-27 01:44:48 by mlcreech:
Thanks Dan, that fixes it.
 
3750 new closed 2009 Mar anonymous   2009 Jul   5 4 Use other separator than space for matches in offsets function of FTS3
In order to make easier spitting of matches of words in offsets function of FTS3, it should be nice to distinguish:
  • separators of different matches
  • separators of the 4 integers inside an individual match.

We could keep the space character to separate the 4 integers, but use an other character between matches, eg:

  • TAB character(0x09),
  • colon character,
  • any other character defined as alternative in a new PRAGMA command (for example: offsets_sep = ":";).

Best regards

 
3749 new active 2009 Mar anonymous   2009 Mar   5 4 Condition for indexes
It would be very nice to have condition like WHERE column_x = 5 in CREATE INDEX statement, so we can create conditional UNIQUE constraint. For example we have table with columns global and name and we want to set UNIQUE constraint for name, but only in case of global = 1 - in this case we would simply create UNIQUE index with proper condition.

This feature is already present in PostgreSQL, I don't know how about other databases.
 
3748 build closed 2009 Mar anonymous build 2009 Mar   4 3 "make clean" errors out if doc/lemon.html doesn't exist
This code in Makefile.in does not work correctly:

        [ -f doc/lemon.html ] && mv doc/lemon.html doc/report1.txt .

If doc/lemon.html does not exist, the [ command exits unsuccessfully and Make halts execution of the 'clean' rules. This construct should be written

        [ ! -f doc/lemon.html ] || ...

or else

        if [ -f doc/lemon.html ]; then ...; fi

This also applies to the second use of [ ... ] && ... two lines further down.

2009-Mar-24 21:17:23 by drh:
I cannot find any mention of lemon.html in the current or in any recent Makefile. Are you sure you are looking at a Makefile from SQLite?
 
3747 build closed 2009 Mar anonymous build 2009 Mar   2 3 "make install" must install libsqlite3.la before libtclsqlite3.la
"make install" needs to install libsqlite3.la before libtclsqlite3.la, because libtool might decide it needs to relink the latter at install time. (For instance, it seems to do this if you give DESTDIR=/some/path on the "make install" command line.) If that happens, and libsqlite3.la isn't already in the installation directory, and there is no other library satisfying -lsqlite3 on the system, the install will fail.

This was observed while automatically building packages of sqlite for Debian -- see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520153 and https://buildd.debian.org/pkg.cgi?pkg=sqlite3 .

I will attach a patch.

2009-Mar-24 19:01:09 by drh:
Overcome by events. See check-in [6300] . The patch does not apply.
 
3746 code closed 2009 Mar anonymous front 2009 Mar   1 2 Bus Error on CREATE TABLE
The only information currently available is provided in ActiveState's ticket

reported by Larry Virden.

2009-Mar-24 17:04:43 by drh:
Cannot reproduce. Possibly this is miscompiled library. Another (remote) possibility is a corrupted database file. We have no way to tell and hence no way to address the issue.


2009-Mar-24 18:51:09 by anonymous:
After some discussion with Larry, see the AS ticket, I am coming to the belief that sqlite is here victim of some problem in the Tcl core which was fixed at some point after the latest AT releases.

Using the newest AT 8.4 build from last night doesn't show the problem, only

I believe that this ticket can be closed without further action by th sqlite developers.

 
3745 code closed 2009 Mar danielk1977 back 2009 Mar danielk1977 3 3 Incorrect SQLITE_BUSY return in persistent-journal mode
In persistent journal mode, if:

  • There is a persistent journal in the file-system, AND
  • there exists a connection with a shared lock on the db file,

then a second connection cannot open a read-transaction on the database. The reason is because while determining that the persistent-journal is not a hot-journal, SQLite currently grabs an exclusive lock on the database file. If this fails because another connection has a shared lock, then SQLITE_BUSY is returned to the user.

See the attached test script.

2009-Mar-26 06:18:40 by danielk1977:
The test script with the demonstration of this bug is now attached to ticket #3751.
 
3744 code fixed 2009 Mar anonymous test 2009 Mar   1 1 sqlite-3.6.11 segfaults in make test
  net1#build_sqlite
  mkdir -p /build/work/sqlite-3.6.11
  cd /build/work/sqlite-3.6.11
  unset CDPATH
  export CFLAGS='-pipe -O3 -g -Wall -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_DISABLE_DIRSYNC=1'
  rm -rf bld
  mkdir bld
  cd bld
  ../configure --prefix=/runtime/sqlite-3.6.11 --enable-tcl --with-tcl=/usr/lib --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 fulltest" david
  ... ... ...
  async-malloc-transient-1.1.74... Ok
  async-malloc-transient-1.1.75... Ok
  async-malloc-transient-1.1.76... Ok
  make: *** [fulltest] Segmentation fault

  net1#uname -a
  Linux net1.coolsurf.com 2.6.27.19-170.2.35.fc10.i686 #1 SMP Mon Feb 23 13:21:22 EST 2009 i686 i686 i386 GNU/Linux
The async2.test script works now with the current CVS HEAD. I do not know what the original problem was.


2009-Mar-25 13:41:44 by drh:
Reopening. With other changes, this issue now does appear, but so far only when we compile with the amalgamation configured for coverage testing on a dual-core amd64 using Debian...
 
3743 code fixed 2009 Mar drh back 2009 Mar   1 1 Lookaside memory allocator incompatible with shared cache
It is possible that some elements of the shared cache schema might be allocated using the lookaside memory allocator of one of the participating database connections. If that database connection closes before the others, it could prematurely deallocate critical elements of the shared schema.
2009-Mar-24 15:54:41 by drh:
All users of SQLite version 3.6.1 and later should either:

  1. Avoid using shared cache.

  2. Disable the lookaside memory allocator optimization.

  3. Upgrade to check-in [6377] or later which contains a fix for this problem.

This problem was found by code inspection - not by any reported or observed malfunction. We have never seen this problem occur in a real application. Nevertheless, the problem could easily cause a segfault so upgrading is recommended.

New assert() statements were added to the code to prevent a regression. There are no simple tests for this problem and so no test cases were added. The correctness of the fix is verified by running the entire test suite and checking that no assert()s are raised.

 
3742 new active 2009 Mar aswift   2009 Mar drh 3 4 Performance improvements for common ORDER BY clauses
Please investigate potential performance enhancements with ORDER BY clauses, particularly those that do not utilize an index.

The default behavior is an external sort intended to handle an arbitrarily large number of rows. We'd like to see - more aggressive in memory sorting - special case common sorting collations like simple integers, or strings with vanilla binary collations

 
3741 warn closed 2009 Mar anonymous   2009 Oct   4 5 1 = '1'
  select case when 1 = '1' then 'equal' else 'not equal' end

This query prints 'not equal' in sqlite. Although I'v expected this behaviour, I was surprised to see that all other database I'v tried (sybase, oracle, mssql, mysql) return 'equal'. Maybe they have a reason (standard specifies this ?).

2009-Mar-23 15:44:37 by drh:
This is certainly very surprising. Who would think that a string would be equal to an integer.

Regardless of what the SQL standards say about this, I think that we have to maintain the current behavior of SQLite since it has been carefully documented to behave as it does for many years, and any change might break existing applications.


2009-Mar-23 16:05:28 by anonymous:
who would think that a string would be equal to an integer

    create temp table test(x text);
    insert into test values(1);
    insert into test values('1');
    select * from test where x between 1 and 1;
    select * from test where x between '1' and '1';

Both selects return both rows. Identical results if x is defined to be an integer.


2009-Mar-23 16:08:58 by drh:
In the latter example, there is a typed column x (with datatype "TEXT") that causes values to all be coerced into a TEXT datatype. No such column, and hence no coercion, occurs in the original problem.
 
3740 code closed 2009 Mar anonymous func 2009 Mar   1 1 DB ahngs when doing "pragma integrity_check;"
Hi,

I've added the "pragma integrity_check;" check to my code to watch out for corrupted databases. Then I edited a database with vi to ensure that I had a corrupted database to check. I expected the integrity check to tell me that the db was corrupted, but instead sqlite3 hangs forever.

Best, jules

2009-Mar-23 14:31:56 by anonymous:
Hmm... I'd like to attach my database to this report but how?

Thanks, jules


2009-Mar-23 15:41:37 by drh:
I downloaded and uncompressed the attached database. (Resulting database as an MD5 sum of 69038857b886147d36b968b6dd73409c.) I get failures every time when I try to do anything (included PRAGMA integrity_check) using either 3.4.0 or CVS HEAD.
 
3739 code closed 2009 Mar anonymous   2009 Mar   2 3 NULL in one of attributes messes up entire query that uses LIKE
Consider the following query: SELECT * FROM sites WHERE title LIKE '%food%' || subtitle LIKE '%food%'

This query return nothing if any of these attributes is NULL even if another attribute contains "food", which is incorrect. There is a workaround: to check if the attribute is not NULL.

2009-Mar-22 07:20:05 by anonymous:
where title like '%food%' OR subtitle like '%food%' ? TC


2009-Mar-22 08:46:08 by anonymous:
Oh, man, what a stupid mistake! Thank you! :)
 
3738 code closed 2009 Mar anonymous build 2009 Mar   1 1 compile error due to missing in Makefile.in
diff --git a/Makefile.in b/Makefile.in
index 5461633..8f7b39a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -171,7 +171,7 @@ OBJS0 = alter.lo analyze.lo attach.lo auth.lo bitvec.lo btmutex.lo \
         memjournal.lo \
         mutex.lo mutex_noop.lo mutex_os2.lo mutex_unix.lo mutex_w32.lo \
         opcodes.lo os.lo os_unix.lo os_win.lo os_os2.lo \
-        pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
+        pager.lo backup.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
         random.lo resolve.lo rowset.lo select.lo status.lo \
         table.lo tokenize.lo trigger.lo update.lo \
         util.lo vacuum.lo \
@@ -611,6 +611,9 @@ mutex_w32.lo:       $(TOP)/src/mutex_w32.c $(HDR)
 pager.lo:      $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
        $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/pager.c

+backup.lo:     $(TOP)/src/backup.c $(HDR)
+       $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/backup.c
+
 pcache.lo:     $(TOP)/src/pcache.c $(HDR) $(TOP)/src/pcache.h
        $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/pcache.c
Duplicate of #3695, #3697, and #3706. Fixed by check-in [6311]
 
3737 build closed 2009 Mar anonymous build 2009 Oct   2 3 [Unix] libsqlite3.so should be linked with -ldl
Unless SQLITE_OMIT_LOAD_EXTENSION is #defined when building SQLite, the shared library libsqlite3.so will use functions typically defined in libdl.so rather than libc - dlopen, dlclose, dlsym, dlerror, etc. Therefore, -ldl should be given on the link line of libsqlite3.so itself, so that applications using libsqlite3.so do not need to link directly to that library. As is, programs that trust sqlite3.pc to tell them how to link with libsqlite3 (as they should) and do not otherwise need libdl will fail to link.

To do this it suffices to get -ldl into the @LIBS@ substitution variable, which I've done by adding an autoconf check that should have been there anyway, to disable load_extension() on Unix variants that don't support dynamic loading. I will attach a patch.

2009-Mar-20 23:58:24 by anonymous:
Additional note: ideally, the @LIBS@ (this goes for both -ldl and -lpthread) would be applied to libsqlite3.so but not libtclsqlite3.so, but I figured it would be best to keep this patch simple.


2009-Oct-12 04:27:16 by anonymous:
This is reported many many times. See closed variants.
 
3736 code closed 2009 Mar anonymous func 2009 Mar   1 3 Bus error in HP-UX B.11.23 Itanium, problem in WhereInfo init ...
The problem occurs with sqlite3 amalgamation 3.6.11 build in HP-UX 11.23 ia64 (using gcc version 4.2.3), and appears as a "bus error" after executing ".schema" or "create table ..."

Gdb reports that the problem occurs in the function exprAnalyze when executing the following statement:

	pTerm->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight);

After examining the data structures used, the problem seems to originate from the initialization of WhereInfo *pWInfo in function sqlite3WhereBegin, file where.c, line 2974.

Variable pWInfo is initialized to a space in memory that will hold several different data structures besides WhereInfo, one of which is the WhereClause area of space that *pWC will point to.

Subsequently this causes an unaligned access when attempting to evaluate pTerm->prereqRight in function exprAnalyze.

The value of the &(pTerm->prereqRight) during the time of crash is 0x4004bfac, but since this will hold a Bitmask u64 value, it needs to be aligned to a memory location divisible by 8.

To fix this problem locally, I went a bit overboard and decided to make the following changes:


  ---- where.c
2843a2844,2846
>     sqlite3DbFree(db, pWInfo->whereMaskSet );
>     sqlite3DbFree(db, pWInfo->pWC );
>     sqlite3DbFree(db, pWInfo->a );
2974,2982c2977,2985
<   pWInfo = sqlite3DbMallocZero(db,
<                       sizeof(WhereInfo)
<                       + (pTabList->nSrc-1)*sizeof(WhereLevel)
<                       + sizeof(WhereClause)
<                       + sizeof(WhereMaskSet)
<            );
<   if( db->mallocFailed ){
<     goto whereBeginError;
<   }
---
>   pWInfo = sqlite3DbMallocZero(db, sizeof(WhereInfo) );
>   if( db->mallocFailed )	goto whereBeginError;
>   pWInfo->a = sqlite3DbMallocZero(db, pTabList->nSrc*sizeof(WhereLevel) );
>   if( db->mallocFailed )	goto whereBeginError;
>   pWInfo->pWC = pWC = sqlite3DbMallocZero(db, sizeof(WhereClause) );
>   if( db->mallocFailed )	goto whereBeginError;
>   pWInfo->whereMaskSet = pMaskSet = sqlite3DbMallocZero(db, sizeof(WhereMaskSet) );
>   if( db->mallocFailed )	goto whereBeginError;
>
2988d2990
<   pWInfo->pWC = pWC = (WhereClause*)&pWInfo->a[pWInfo->nLevel];
2990d2991
<   pMaskSet = (WhereMaskSet*)&pWC[1];


  ----  sqliteInt.h
1661c1661,1662
<   WhereLevel a[1];               /* Information about each nest loop in WHERE */
---
>   WhereLevel *a;               /* Information about each nest loop in WHERE */
>   void *whereMaskSet;               //TODO: Replace void * with WhereMaskSet * ...


There's probably a pragma for this, but I prefer my solution since it clarifies how a data type is used and assures its integrity ...

... then again I could also be wrong, given I barely know what the code is doing, and may have just inserted another bug ...

2009-Mar-20 14:21:55 by danielk1977:
See also: #3613.


2009-Mar-23 09:28:09 by anonymous:
I have applied the changes the changes in Check-In [6364] to the source code in the sqlite amalgamation 3.6.11 release, and it seems to work. Thanks for the quick response!
 
3735 code closed 2009 Mar anonymous back 2009 Oct   2 3 DB connections fail to share cache correctly
With shared cache enabled, I have found that if you call sqlite3_open[_v2]() from two threads for the same DB file at the same time, they will not necessarily share the cache and file handles for that DB. This results in greater cache memory usage (and messes up my custom VFS). Does this indicate a bug in SQLite, or should calls to sqlite3_open[_v2]() be serialized when shared cache is enabled?
2009-Mar-18 23:56:27 by drh:
There is a race condition in sqlite3_open() such that if two threads do an open() at the same time, they might get separate caches even if they are using the same database file.

Your work-around is to serialize calls to sqlite3_open() if you cannot do without cache sharing.

 
3734 code active 2009 Mar danielk1977 back 2009 Mar   3 3 A read/write db connection may connect to a read-only shared cache.
See the following Tcl script:

  sqlite3_enable_shared_cache 1

  file delete -force test.db

  sqlite3 db test.db
  db eval {
    CREATE TABLE t1(a, b, c);
    INSERT INTO t1 VALUES(1, 2, 3);
  }
  db close

  sqlite3 dbr test.db -readonly 1
  dbr eval { SELECT * FROM t1 }

  sqlite3 dbw test.db -readonly 0
  dbr close

  # This throws an "attempt to write a read-only database" exception.
  #
  dbw eval { INSERT INTO t1 VALUES(4, 5, 6) }
 
3733 code closed 2009 Mar anonymous front 2009 Mar   2 3 Double quotation marks in WHERE-statement works incorrect
If you search in a table with WHERE-statement: ColumnName="ColumnName", the result is incorrect. If you use single quotation marks (') instead, the result is fine.

Table structure + data:
CREATE TABLE "main"."quote_problem" ("ID" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "Content" TEXT NOT NULL);
INSERT INTO "main"."quote_problem" ("Content") VALUES ("Some text");

Wrong result:
SELECT * FROM "main"."quote_problem" WHERE Content="Content";
Result:
ID | Content
1 | Some text

This works:
SELECT * FROM "main"."quote_problem" WHERE Content='Content';
Result:
ID | Content
[no Result]



I have a translation table like this:
ID | LanguageID | Text
15 | 1 | Product
16 | 2 | Produkt
17 | 1 | Text
17 | 2 | Text
(LanguageID 1 = englisch, 2 = german)

2009-Mar-18 14:13:22 by danielk1977:
In SQL, a string in double-quotes is treated as an identifier (i.e. column name) if there is such a column, or a literal string otherwise.

This is crazy, but it is also standard SQL.

The fix is to never use double-quotes.


2009-Mar-23 00:48:28 by anonymous:
What you describe is not standard SQL behavior. It is SQLite's non standard, extended, behavior. It was added to improve compatibility with MySQL which uses double quotes for literal strings.

In standard SQL double quotes are only used to quote identifiers. They are only needed for identifiers that contain special characters or match SQL keywords, but they can be used for any identifier. Such quoted identifiers are never interpreted as literal strings.

In the context of this report, Content without the double quotes is the same identifier as Content enclosed in double quotes. So the condition is true for every row since a column is always equal to itself (excepting possibly rows with a NULL value).

In this case SQLite is doing exactly what it should be doing.

In SQLite the problem arises when you make a typographical mistake and enclose a value that is not a valid identifier in double quotes. Instead of getting a helpful diagnostic message about the invalid identifier, SQLite will re-interpret the identifier as a literal string and happily execute the statement.

 
3732 build closed 2009 Mar anonymous   2009 Mar   1 1 ./src/shell.c:1101: error: 'sqlite3_backup' undeclared
I'm trying to upgrade from 3.6.10. I'm on a slackware-12.1 modified i686 using gcc-4.3.3. I can reporduce this bug on 3 different machines, albeit all using the same compiler.

The problem seems to be that the build is finding the 3.6.10 versions of the sqlite3.h and/or sqlite3ext.h include files. When I delete them, the problem goes away

2009-Mar-17 21:23:51 by drh:
What steps are you following to give this compile error? Which of the various source distributions of SQLite did you download. After downloading, what steps did you follow to try to build the executable?


2009-Mar-19 08:14:07 by anonymous:
I just bumped into this or a similar problem on x86_64. Exactly the same build script worked on another very similar machine but this one gets...

  ...
  libtool: link: ranlib .libs/libsqlite3.a
  libtool: link: ( cd ".libs" && rm -f "libsqlite3.la" && ln -s "../libsqlite3.la" "libsqlite3.la")
  ./libtool --mode=link gcc   -march=x86-64 -mtune=generic -O2 -pipe  -fPIC -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG   -DSQLITE_THREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_ENABLE_COLUMN_METADATA=1    -ldl  -DHAVE_READLINE=1 -I/usr /include/readline  \
                -o sqlite3 ./src/shell.c libsqlite3.la \
                -lreadline -lreadline   -rpath  "/usr/lib"
  libtool: link: gcc -march=x86-64 -mtune=generic -O2 -pipe -fPIC  -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -DSQLITE_THREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DHAVE_READLINE=1 -I/usr/include/readline -o .libs/sqlite3 ./src/shell.c  ./.libs/libsqlite3.so -ldl  -lreadline -Wl,-rpath -Wl,/usr/lib
  /tmp/ccf5awNu.o: In function `do_meta_command':
  shell.c:(.text+0x21ce): undefined reference to `sqlite3_backup_init'
  shell.c:(.text+0x21e7): undefined reference to `sqlite3_backup_step'
  shell.c:(.text+0x21f5): undefined reference to `sqlite3_backup_finish'
  shell.c:(.text+0x26ef): undefined reference to `sqlite3_backup_init'
  shell.c:(.text+0x2708): undefined reference to `sqlite3_backup_step'
  shell.c:(.text+0x3081): undefined reference to `sqlite3_backup_finish'
  shell.c:(.text+0x31bb): undefined reference to `sqlite3_backup_finish'
  ./.libs/libsqlite3.so: undefined reference to `sqlite3BackupUpdate'
  ./.libs/libsqlite3.so: undefined reference to `sqlite3BackupRestart'
  ./.libs/libsqlite3.so: undefined reference to `sqlite3BtreeCopyFile'
  collect2: ld returned 1 exit status
  make: *** [sqlite3] Error 1

The build was...

  export LTLINK_EXTRAS="-ldl"
  export CFLAGS="$CFLAGS -DSQLITE_ENABLE_COLUMN_METADATA=1"
  ./configure \
    --prefix=/usr \
    --disable-tcl \
    --disable-threadsafe \
    --enable-static \
    --enable-load-extension || return 1
  make || return 1
  make DESTDIR=${pkgdir} install || return 1


2009-Mar-21 06:46:56 by anonymous:
The same issue with 3.6.11 has been encountered on i386 (3.6.7 builds fine with the same configure & make options):

  ./libtool --mode=link gcc   -g -pipe -march=i386 -mtune=i686 -O2 -momit-leaf-frame-pointer -mpreferred-stack-boundary=3 -DSQLITE_OS_UNIX=1
 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG   -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1
-DHAVE_READLINE=1 -I/usr/include/readline \
-o sqlite3 ./src/shell.c libsqlite3.la \
-lreadline -lncurses  -lpthread  -rpath "/opt/sqlite/3.6.11-gm1/lib"
LD_RUN_PATH="/opt/sqlite/3.6.11-gm1/lib:$LD_RUN_PATH" gcc -g -pipe -march=i386 -mtune=i686 -O2 -momit-leaf-frame-pointer -mpreferred-stack
-boundary=3 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLIT
E_OMIT_LOAD_EXTENSION=1 -DHAVE_READLINE=1 -I/usr/include/readline -o .libs/sqlite3 ./src/shell.c  ./.libs/libsqlite3.so -lreadline -lncurs
es -lpthread
/tmp/.private/sources/cc5UDxFb.o(.text+0x302e): In function `do_meta_command':
./src/shell.c:1117: undefined reference to `sqlite3_backup_init'
/tmp/.private/sources/cc5UDxFb.o(.text+0x3049):./src/shell.c:1123: undefined reference to `sqlite3_backup_step'
/tmp/.private/sources/cc5UDxFb.o(.text+0x3057):./src/shell.c:1124: undefined reference to `sqlite3_backup_finish'
/tmp/.private/sources/cc5UDxFb.o(.text+0x344f):./src/shell.c:1526: undefined reference to `sqlite3_backup_init'
/tmp/.private/sources/cc5UDxFb.o(.text+0x346a):./src/shell.c:1536: undefined reference to `sqlite3_backup_step'
/tmp/.private/sources/cc5UDxFb.o(.text+0x34ab):./src/shell.c:1536: undefined reference to `sqlite3_backup_step'
/tmp/.private/sources/cc5UDxFb.o(.text+0x3746):./src/shell.c:1539: undefined reference to `sqlite3_backup_finish'
./.libs/libsqlite3.so: undefined reference to `sqlite3BtreeCopyFile'
./.libs/libsqlite3.so: undefined reference to `sqlite3BackupRestart'
./.libs/libsqlite3.so: undefined reference to `sqlite3BackupUpdate'
collect2: ld returned 1 exit status
make: *** [sqlite3] Error 1


2009-Mar-21 07:02:54 by anonymous:
To add to the previous comment re: the i386 build: no previous SQLite was installed (so no any SQLite include file is on the way), gcc 3.4.5, glibc 2.3.6, kernel headers 2.4.32 . Hope this helps.


2009-Mar-21 11:59:59 by drh:
Sorry, but it does not help at all. I am unable to reproduce this problem. The build works perfectly for me on Linux.


2009-Mar-23 03:27:10 by anonymous:
Fix for this:

--- Makefile.in.orig	2009-03-23 00:21:28.000000000 -0300
+++ Makefile.in	2009-03-23 00:22:03.000000000 -0300
@@ -163,7 +163,7 @@

 # Object files for the SQLite library (non-amalgamation).
 #
-OBJS0 = alter.lo analyze.lo attach.lo auth.lo bitvec.lo btmutex.lo \
+OBJS0 = alter.lo analyze.lo attach.lo auth.lo backup.lo bitvec.lo btmutex.lo \
         btree.lo build.lo callback.lo complete.lo date.lo \
         delete.lo expr.lo fault.lo func.lo global.lo \
         hash.lo journal.lo insert.lo legacy.lo loadext.lo \
@@ -518,6 +518,9 @@
 auth.lo:	$(TOP)/src/auth.c $(HDR)
 	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/auth.c

+backup.lo:	$(TOP)/src/backup.c $(HDR)
+	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/backup.c
+
 bitvec.lo:	$(TOP)/src/bitvec.c $(HDR)
 	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/bitvec.c
Regards Marcus Alves Grando mnag@FreeBSD.org


2009-Mar-23 11:25:40 by drh:
That problem has already been fixed. See check-in [6311] .

I thought the OP was using the amalgamation tarball. Everyone should be using the amalgamation tarball instead of separate source files, since the amalgamation tarball allows the compiler to do better optimization resulting in 10% faster operation.

Under the assumption that the OP was trying to build from separate source files, I will close this ticket as a duplicate...

 
3731 code fixed 2009 Mar danielk1977 back 2009 Mar   1 1 Corruption caused by "INSERT INTO ... SELECT" + AFTER INSERT trigger
  $ ./sqlite3
  SQLite version 3.6.12
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> CREATE TABLE t1(a PRIMARY KEY, b);
  sqlite> CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN INSERT INTO t1 VALUES(new.a || '+', new.b || '+'); END;
  sqlite> CREATE TABLE t2(a, b);
  sqlite> INSERT INTO t2 VALUES('e', 'f');
  sqlite> INSERT INTO t2 VALUES('g', 'h');
  sqlite> INSERT INTO t1 SELECT * FROM t2;
  sqlite> PRAGMA integrity_check;
  wrong # of entries in index sqlite_autoindex_t1_1
  sqlite>

Test script attached.

2009-Mar-17 18:22:15 by danielk1977:
The problem is in the "INSERT INTO t1 SELECT * FROM t2" statement. When inserting the first row, the VDBE executes an OP_NewRowid to determine the rowid to use. The call to OP_NewRowid also caches the "next" rowid (i.e. the current rowid plus one) to use in the VdbeCursor structure. When inserting the next row into t1, the OP_NewRowid instruction is able to use the cached values instead of querying the B-tree table. See the VdbeCursor.nextRowid and VdbeCursor.nextRowidValid variables in the code.

However, the INSERT performed by the trigger fired as the first row is inserted into t1 uses the rowid that is cached in the cursor. So when the next row is inserted by the "INSERT INTO t1 SELECT ..." statement, it replaces the row inserted by the trigger. This is incorrect.

The corruption comes about because there is still an index entry corresponding to the t1 row that was (incorrectly) replaced. Hence the index and table don't match. Corruption.

Another way to trigger this bug is to modify the database from within a user-function invoked somehow during an "INSERT INTO SELECT ..." statement.

 
3730 doc fixed 2009 Mar anonymous   2009 Mar   5 3 Documentation typo rtree.html (common -> comma)
The <name> is the name your application chooses for the R*Tree index and <column-names> is a common separated list of between 3 and 11 columns.

should be changed to:

The <name> is the name your application chooses for the R*Tree index and <column-names> is a comma separated list of between 3 and 11 columns.

Fixed by http://www.sqlite.org/docsrc/ci/61871a4c179d
 
3729 build closed 2009 Mar anonymous build 2009 Mar   3 4 SQLITE_OMIT_AUTOVACUUM compile error
When SQLITE_OMIT_AUTOVACUUM is defined, the functions sqlite3RootPageMoved(), sqlite3PagerMovepage() and sqlite3BtreeIncrVacuum() are declared but not defined. The st20icc compiler treats this as an error. Declaring these functions within #ifndef SQLITE_OMIT_AUTOVACUUM fixes the problem.
See #3726
 
3728 build closed 2009 Mar anonymous build 2009 Mar   3 4 SQLITE_OMIT_INCRBLOB compile error
When SQLITE_OMIT_INCRBLOB is defined, the functions sqlite3BtreeLeaveCursor(), sqlite3BtreeEnterCursor(), sqlite3BtreeCacheOverflow() and sqlite3BtreePutData() are declared but not defined. This is treated as an error by the st20icc compiler. Declaring these functions within #ifndef SQLITE_OMIT_INCRBLOB solves the problem.
See #3726
 
3727 build closed 2009 Mar anonymous build 2009 Mar   3 4 SQLITE_OMIT_XFER_OPT compile error
When SQLITE_OMIT_XFER_OPT is defined, the function xferOptimization() is declared but not defined. This is treated as an error by the st20icc compiler. Declaring this function only within #ifndef SQLITE_OMIT_XFER_OPT solves the problem.
See #3726
 
3726 build closed 2009 Mar anonymous build 2009 Mar   3 4 SQLITE_OMIT_COMPOUND_SELECT compile error
When SQLITE_OMIT_COMPOUND_SELECT is defined, the function multiSelectOrderBy() is declared but not defined. This is treated as an error by the st20icc compiler. Declaring this function only within #ifndef SQLITE_OMIT_COMPOUND_SELECT solves the problem.
2009-Mar-16 20:22:03 by drh:
See the remarks at http://www.sqlite.org/compile.html#omitfeatures

The SQLITE_OMIT_* compile-time options only work when compiling from canonical source files. They do not work from the amalgamation or from pre-processed source files. They are untested and unsupported.

The resolution of this issue will be that the documentation has been enhanced to emphasize the point. See http://www.sqlite.org/docsrc/ci/725dade577c for the documentation check-in.

 
3725 doc closed 2009 Mar anonymous   2009 Mar   5 5 Incorrect diagram on http://www.sqlite.org/lang_createtable.html
on http://www.sqlite.org/lang_createtable.html,

The diagram for Create Table syntax has "table-constraint" after "Column-def". It should say "Column-constraint"

Incorrect. Table-constraint is in the right place. Column-constraint is found under the Column-def diagram.
 
3724 code fixed 2009 Mar anonymous cli 2009 Mar   4 4 .rekey command fails silently if sqlite3 doesn't have write access
.rekey command fails silently if sqlite3 doesn't have write access to the database. A "no permission" error would have saved some head scratching for this new SEE user. Thanks!
Fixed in SEE version 2ab7b0f2fd2663d07174435aad5f756f75d72f3e.

In the future, please use the SEE bug tracker to report bugs in SEE. This bug tracker is for the generic public-domain version of SQLite.

 
3723 code fixed 2009 Mar anonymous cli 2009 Mar   3 4 .rekey command requires -key on sqlite3 command line
.rekey command on an encrypted database doesn't work unless the -key argument is also used with the command line sqlite3 utility. sqlite3 says "old key is incorrect". I didn't see this explained anywhere, and also, using keys on the command line is a bad idea on a multiuser system since the keys will show up in a ps command.

  # sqlite3 -key aes256:jimkey pal.db
-- Loading resources from /root/.sqliterc
SQLite version 3.6.10 with the Encryption Extension
Copyright 2006 Hipp, Wyrick & Company, Inc.
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
logs
sqlite>^D
# sqlite3 pal.db
-- Loading resources from /root/.sqliterc
SQLite version 3.6.10 with the Encryption Extension
Copyright 2006 Hipp, Wyrick & Company, Inc.
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .rekey aes256:jimkey "" ""
old key is incorrect
Added new command ".key" and ".hex-key" that allow the initial key to be set by means other than the -key command-line argument. The change is check-in 2ab7b0f2fd2663d07174435aad5f756f75d72f3e in the SEE configuration management system.

In the future, please use the SEE bug reporting mechanism to report bugs with SEE.

 
3722 code closed 2009 Mar anonymous cli 2009 Mar   3 3 buffer overflow in genfkey
The genfkey tool crashes fairly randomly on certain schemas. Valgrind revealed that the cause is in the multireplace() function in genfkey.c, specifically in this bit of code:

    if( (nOut+nCopy)>nMalloc ){
      nMalloc += (nMalloc + 16);
      zOut = (char *)sqlite3_realloc(zOut, nMalloc);
    }

The bug is that there is no guarantee that nMalloc + nMalloc + 16 >= nOut + nCopy. Thus you can get a buffer overflow.

The fix is to replace it with:

    if( (nOut+nCopy)>nMalloc ){
      nMalloc = (nOut + nCopy) * 2;
      zOut = (char *)sqlite3_realloc(zOut, nMalloc);
    }

The "* 2" preserves the property that you don't spend O(n^2) time resizing the buffer in the worst case.

(I just noticed that genfkey has been moved to shell.c, but the bug is still there.)

Thanks for reporting this.
 
3721 new closed 2009 Mar anonymous   2009 Oct   5 4 CAST with custom data types is not very useful
Using CAST with custom types is not very useful. Most importantly, the result of the CAST is always numeric.

For instance:

  sqlite> CREATE TABLE tbl (foo DATETIME);
  sqlite> INSERT INTO tbl (foo) VALUES ("2008-03-12 09:33:25");
  sqlite> SELECT foo FROM tbl;
  2008-03-12 09:33:25
  sqlite> SELECT CAST(foo AS DATETIME) FROM tbl;
  2008

It seems unlikely that this would be very useful. Further, sqlite3_column_decltype would return NULL for the column.

I think that the most useful way to handle this would be:

  • CAST does not modify data when used with custom types, so the result of the CAST above would be "2008-03-12 09:33:25".
  • sqlite3_column_decltype would return the type that was casted to ("DATETIME" in this example).

This would allow Python sqlite3 users to force types to be detected correctly so that the sqlite3 library can return a useful Python object for the column like it could in the "SELECT foo" case. It would allow developers to work around the fact that expressions are not converted, as they could declare the type of the expression in a reasonably easy way.

In any case, unconditionally returning an integer doesn't seem like the right behavior. I think this should be changed even if sqlite3_column_decltype is left alone.

2009-Oct-02 08:47:55 by anonymous:
The SQLite documentation does explicitly list what types are valid especially in the affinity documentation. That is why DATETIME is treated as an integer.

The column doesn't have a declared type because it is an expression. The declared type is constant for all rows (ie worked out statically) not by dynamically looking behind the scenes after evaluation each column on each row.

Unfortunately your experience is one of the pitfalls of trying to pretend that SQLite has more datatypes than it really does. My suggestion is that you will have to handle this kind of thing at a higher layer in your application rather than at the SQL level. Also remember that any changes to SQLite should not effect existing applications.

If you wish further discussion then please continue on the SQLite mailing list.

 
3720 xplatform closed 2009 Mar anonymous front 2009 Mar   4 1 group by doesn't work as it should work (doesn't group aggregates)
hi there

i am working on a small correlation engine and wanted to use sql for correlating because GROUP BY is exactly what i need.

so, for example i have a table

  > table (id integer, event_date date, event integer)

now i want to know how much events happened a day, so i shoot

  > SELECT event_date, count(event) FROM table GROUP BY event_date

then something like this should happen:

  > event_date | event
  > 2009-03-01 |   2
  > 2009-03-02 |   1

but something else occurs:

  > event_date | event
  > 2009-03-01 |   1
  > 2009-03-01 |   1
  > 2009-03-02 |   1

i checked the statement with on a mysql-db and got the desired result. so sqlite has a problem with GROUP BY.

it would be nice if this was fixed soon, because this sqlite would make my project slim an nice.

beside that i use pysqlite 2.5.2

Something is wrong with the data. Maybe a trailing nul byte was inserted with one of the date strings. Do:

  SELECT hex(event_date) FROM <table>

to see the difference.

SQLite has hundreds of tests of the GROUP BY function in its test suite. See also:

  http://sqlite.org/testing.html
 
3719 code closed 2009 Mar anonymous   2009 Mar danielk1977 3 4 "Create Table As" fails on tables with a specific type of definition.
Problem can be reproduced using two statements:

create table test (col1 [char.3]);

The above statement works, although I'm not sure that it should given the period in the type definition. The next statement fails.

create table test2 as select * from test;

If the period is removed from the type definition of the first table, the second query works fine.

Thanks.
 
3718 code fixed 2009 Mar danielk1977 back 2009 May danielk1977 1 1 Race condition in shared cache mode
If there are two threads both accessing the same shared-cache (via different database connections) a race-condition can occur if the following is true:

  1. One thread (thread A) is writing to the shared-cache within a statement transaction, AND
  2. The other thread (thread B) is not in auto-commit mode and executes a statement that fails (for any reason).

The race condition is that in vdbeHalt(), the error processing for thread B's statement may result in a call to sqlite3BtreeRollbackStmt(). If thread A's statement-transaction is open at this point, it will be (incorrectly) rolled back. The result is that thread A's write appears to succeed, but actually has no effect on the database contents.

The fix is to have sqlite3BtreeRollbackStmt() check if the Btree* passed as an argument actually has a write-transaction open on the shared-cache before attempting to rollback any statement transaction. The sqlite3BtreeRollback(), BtreeCommitPhaseOne() and BtreeCommitPhaseTwo() functions already do this.

Also, changing sqlite3BtreeCommitStmt() in the same way (to only commit a statement transaction if it is passed a Btree* with an open write-transaction) might be a good idea. It doesn't look like an actual problem exists here, but it makes the b-tree API more consistent and might prevent a problem in the future.

 
3717 code closed 2009 Mar anonymous ext 2009 Jun   2 2 Crash when querying fts3 for MATCH '""'
The following sequence of SQL queries causes SQLite 3.6.8+ to crash. Problem does not occur in SQLite 3.6.7 and earlier.

  create virtual table test using fts3 (keyword);
  insert into test values ('abc');
  select * from test where keyword match '""';
Thanks.


2009-Jun-23 06:43:02 by anonymous:
Here's an additional sequence of SQL queries causes SQLite 3.6.10 to crash. Problem does not occur in SQLite 3.6.7.

  create virtual table test using fts3 (foo, bar);
  insert into test values ('abc','xyz');
  select * from test where test match 'foo:"b" "c"';

I think it is the same crash, but I have not tried it with a version of sqlite with this fix yet.

 
3716 todo closed 2009 Mar anonymous   2009 Mar   1 3 Mac OS X archive not working
Downloaded sqlite3-3.6.11-osx-x86.bin.gz

Double-clicking it produces sqlite3-3.6.11-osx-x86.bin.

Double-clicking THAT produces sqlite3-3.6.11-osx-x86.bin.cpgz

Double-clicking THAT produces sqlite3-3.6.11-osx-x86 2.bin

Double-clicking THAT produces sqlite3-3.6.11-osx-x86 2.bin.cpgz

And around and around we go!

2009-Mar-10 11:58:32 by danielk1977:
*.bin was an unfortunate choice of extension. The bin file is actually an executable program. Save it somewhere, then open Terminal.app and do:

  $ gunzip sqlite3-3.6.11-osx-x86.bin.gz
  $ chmod 755 sqlite3-3.6.11-osx-x86.bin
  $ ./sqlite3-3.6.11-osx-x86.bin

The extension will be different next release to avoid this problem.

 
3715 code closed 2009 Mar anonymous front 2009 Mar   5 4 How to query table from an encrypted sqlite file?
My friend give me an encrypted sqlite file, I created an visual c++ application to develop on it.I have included sqlite3.h file,lib file, dll file, and also I could open the file with password,which my friend gave to me. I've got sqlite3 valid connection parameter, But I could select any information from it. Meanwhile I could use VS2005 to create an c# application to open the encrypted file with password, and query the table information correctly. Could u give me some advice?3Q very much. Dude from China.
2009-Mar-10 13:46:27 by shane:
The SQLite Encryption Extension (SEE) is a seperately licensed extension. See http://www.hwaci.com/sw/sqlite/see.html for details.
 
3714 xplatform closed 2009 Mar anonymous cli 2009 Oct   4 3 sqllite does not accept --help for help
I wanted some help on using sqlite... I'm just getting started with it.

I passed "--help" to sqlite, and got this weird error:

$ sqlite --help sqlite: unknown option: --help Use -help for a list of options.

This works on every other program I tried, including mysql. It doesn't seem unreasonable to expect it to work here too.

2009-Mar-08 09:20:34 by anonymous:
The request does seem reasonable however not every application accetps --help option:

  sh-3.1$ java --help
  Unrecognized option: --help
  Could not create the Java virtual machine.

  sh-3.1$ java -help
  Usage: java [-options] class [args...]
           (to execute a class)
  ...


2009-Oct-13 00:00:12 by anonymous:
It does accept --help now.
 
3713 code closed 2009 Mar anonymous   2009 Mar   4 4 ATTACHED Dbase Speed Variation
Speed Variation.

An ATTACHED database writes to disk differently than the Main database.

Am using RAMDRIVE for speed. Notice in testing a 5x loss of speed when writing to the ATTACHED dbase. (Though speed times are very minor on small test dbase at moment)

Open

PRAGMA synchronous(0);PRAGMA temp_store(2)

Attach

Begin

sql main

sql attached

commit

close

For some reason when writing to the ATTACHED dbase it forces the RAMDRIVE to FLUSH everytime. Both dbases reside on the Ramdrive. System temp dirs point to the Ramdrive.

Swapping the dbases/sqlcommands around shows exact same symptoms. Whichever is ATTACHED is forcing a different mechanism for write to disk, causing a flush, causing a slowdown in write speed.

Having no attached and testing both dbases each seperately with their sqlcommands shows correct speed for both.

2009-Mar-08 05:57:26 by danielk1977:
Do:

  ATTACH 'other.db' AS aux;
  PRAGMA aux.synchronous = 0;

I agree the docs could be clearer on this syntax.


2009-Mar-08 07:32:01 by anonymous:
Many thanks, this was the key !

:)

Agreed on the doco. Though I did try to find answers there if not in the mindset one will miss it.

PRAGMA database.journal_mode

PRAGMA synchronous = NORMAL

Synch should perhaps also show

database.synchronous and discuss ATTACHED.

Keep up the great work.

.enpsuedo

 
3712 code closed 2009 Mar anonymous   2009 Mar   1 3 sqlite3.c:40187: sqlite3BtreeCommitStmt: Assertion `pBt->readOnly==0'
This is the assertion

sqlite3: sqlite3.c:40187: sqlite3BtreeCommitStmt: Assertion `pBt->readOnly==0' failed.

This wasn't an issue with 3.5.7, the previous version used here.

This is the callstack:

  #0  0x00000036e4430055 in raise () from /lib64/libc.so.6
  #1  0x00000036e4431af0 in abort () from /lib64/libc.so.6
  #2  0x00000036e4429756 in __assert_fail () from /lib64/libc.so.6
  #3  0x00002aaaaaad3a97 in sqlite3BtreeCommitStmt () from libsqlite3.so.0
  #4  0x00002aaaaaae5a02 in sqlite3VdbeHalt () from libsqlite3.so.0
  #5  0x00002aaaaaaea9ab in sqlite3VdbeExec () from libsqlite3.so.0
  #6  0x00002aaaaaae7adb in sqlite3Step () from libsqlite3.so.0
  #7  0x00002aaaaaae7d25 in sqlite3_step () from libsqlite3.so.0

  Our code lives in frames 8 through 24.

  #25 0x00002aaaae471f14 in sqlite::tableUpdate (virtual_table=0x6b30248, argument_count=83, argument_vector=0x6c71b70, row_id=0x7fffaafd0160) at sqlite/virtualtable.cpp:750
  #26 0x00002aaaaaaf5b16 in sqlite3VdbeExec () from libsqlite3.so.0
  #27 0x00002aaaaaae7adb in sqlite3Step () from libsqlite3.so.0
  #28 0x00002aaaaaae7d25 in sqlite3_step () from libsqlite3.so.0
  #29 0x00002aaaaab140e7 in sqlite3_exec () from libsqlite3.so.0
  #30 0x0000000000406d94 in process_input ()
  #31 0x0000000000407cbf in main ()
2009-Mar-16 12:14:09 by drh:
The description above lacks sufficient information to reproduce the problem. Nevertheless, this same assertion fails as a result of bug #3718, so perhaps this is the same problem. In the absence of additional information it is impossible to know for sure. But we will assume the this problem and #3718 are really the same and close this ticket as a duplicate.
 
3711 new closed 2009 Mar anonymous   2009 Oct   4 3 ATTACH + :memory: + atomic commit
Currently attomic commit for attached databases is not supported if main database is in memory. However I think that only reason for this is because when main database is not in memory it's clear in what directory master journal should be (also database name is used for prefix of master journal name - but the name is random anyway). Directory can be chosen for example as a directory of first not memory database used in transaction (there is no need for master journal if all databases are in memory). It looks like support for atomic commit should be easy to implement with minimal changes to existing code.
2009-Oct-02 08:58:35 by anonymous:
Please continue this discussion on the sqlite-users mailing list. Also remember that any changes in behaviour such as your suggestion must be backwards compatible and not cause any existing SQLite developer's code to change/break.
 
3710 code closed 2009 Mar anonymous func 2009 Mar   5 1 Unable to open the database file
Hi! Go through the Code below which is in C#.Net Windows application. I'm getting the error while Opening the database connnection.

private void btnBrowse_Click(object sender, EventArgs e) {

            System.Windows.Forms.OpenFileDialog opnFileDlg = new System.Windows.Forms.OpenFileDialog();

            opnFileDlg.DefaultExt = "gif";
            opnFileDlg.FileName = "Image";
            opnFileDlg.Filter = "GIF Files|*.gif|JPEG Files|*.jpeg;*.jpg;  *.jpe|PNG Files|*.png|BMP files|*.bmp|T" +
                "IFF Files|*.tiff;*.tiff|All Files|*.*";
            opnFileDlg.Title = "Open Images/Sketches";
            //opnFileDlg.FileOk += new System.ComponentModel.CancelEventHandler(this.opnFileDlg_FileOk);

            if (opnFileDlg.ShowDialog() == DialogResult.OK)
            {
                txtImgOpen.Text = "";
                txtImgOpen.Text = opnFileDlg.FileName;

                string connString = "Data Source=Database\\TESTDB;Version=3;Password=1234;UTF8Encoding=True;";
                SQLiteConnection con2 = new SQLiteConnection(connString);

                IDbCommand cmd2 = con2.CreateCommand();

                string path2 = opnFileDlg.FileName;
                string fileName = Path.GetFileName(opnFileDlg.FileName);
                FileStream fs = new FileStream(path2, FileMode.Open, FileAccess.Read);
                byte[] myData = new byte[fs.Length];
                fs.Read(myData, 0, (int)fs.Length);
                fs.Close();
                cmd2.CommandText = "INSERT INTO Images (WorkOrderId,ImageData) VALUES (@Id,@image)";
                SQLiteParameter param1 = new SQLiteParameter("@image", DbType.Binary);
                param1.Value = myData;
                cmd2.Parameters.Add(param1);
                SQLiteParameter param = new SQLiteParameter("@Id", DbType.Int32);
                param.Value = 121;
                cmd2.Parameters.Add(param);
                con2.Open();
                cmd2.ExecuteNonQuery();
                cmd2.Dispose();
                con2.Close();

            }

        }
2009-Mar-06 12:09:18 by anonymous:
This doesn't appear to be an SQLite error. You'd better discuss it in the sqlite-users mailing list, or even better, in the mailing list or forum of the wrapper you are using.


2009-Mar-06 14:43:09 by danielk1977:
I agree with anonymous.
 
3709 new closed 2009 Mar anonymous back 2009 Sep   5 4 Page locking to improve concurrency for application server
Context: Single application server accessing the db3 file through multiple threads using the SharedCache feature (1 db connection per thread), locking mechanism proposed here address the specific use of single application server accessing the db3 file, the pager could easily maintain a journal file per transaction, the pager could flag (in-memory) that a page is dirty (PgHdr) since 1 thread (1 db connection) has made some update to this page (table or index), and store which dbConnection (or transaction) has made this page dirty (PgHdr using member pExtra, or adding a new member to store the dbConnection that has made the modification), in order to allow the same dbConnection to make additional modification on this page, for other dbConnection trying to update a dirty page, the pager would return SQLITE_BUSY. On commit, the pager would unflag all PgHdr for all dirty pages modified by this dbConnection (or transaction), and remove the journal file of this transaction, On rollback, the pager would copy back the updated pages stored in the journal back in the db3 file, unflag all PgHdr for all dirty pages modified by this transaction, and finally remove the journal file of this transaction.
2009-Aug-26 15:37:28 by anonymous:
A second thought to improve high write concurrency (still in context of single application server, shared cache mode), would be to simplify the whole mechanism of locking by using log structured approach.


2009-Sep-30 08:33:35 by anonymous:
This should be (and is fairly regularly) discussed on the mailing list. In particular note the lite in the name and that only older techniques are used since patents on them would have expired.
 
3708 new active 2009 Mar anonymous   2009 Mar   3 4 UNION + ORDER BY
  SQLite version 3.6.11
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> CREATE TABLE t(a);
  sqlite> SELECT * FROM t ORDER BY random(); -- this works
  sqlite> SELECT * FROM t UNION ALL SELECT * FROM t ORDER BY a; -- this works
  sqlite> SELECT * FROM t UNION ALL SELECT * FROM t ORDER BY random(); -- this doesn't
  SQL error: 1st ORDER BY term does not match any column in the result set

There's no reason for an error in last query

SQL requires that all ORDER BY terms exactly match a column in the result set. random() is not a column in the result set.

As an extension to SQL, SQLite allows ORDER BY terms to be arbitrary expressions on an simple query. This is a common extension implemented by many SQL database engines. But SQLite does not implement this extension for compound queries.

We will convert this ticket an enhancement request.

 
3707 code closed 2009 Mar anonymous func 2009 Mar   1 2 SUBSTR is returning 1 character less than it should
This is pretty easy to describe & understand: select SUBSTR([Mumble] , 0 , 4) as [Foo] from [Bar] The table [Bar] has the field [Mumble] VARCHAR(50). [Mumble] contains names - say "Eyes wide shut". The select as given should return "Eyes" but instead returns "Eye". Rolling back to 3.6.10 resolves this.
This is working as designed. SUBSTR offset is 1 based. See Ticket #3628. In SUBSTR(X,Y,X), the left-most character of X is number 1. This is described here: http://www.sqlite.org/lang_corefunc.html
 
3706 build closed 2009 Mar anonymous build 2009 Mar anonymous 4 3 Make file in sqlite-3.6.11.tar.gz does not compile and link backup.c
In sqlite-3.6.11.tar.gz, the Makefile needs a target to compile backup.c, I used: backup.lo: $(TOP)/src/backup.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/backup.c

Also need to add backup.lo to the OBJS0 list

This probably needs to be done to Makefile.in, but I am not very familiar with configure at this point. If you want me to figure that out, I would be happy to do that.

SQLite is an incredible resource.

Please read the comments for this download on the http://www.sqlite.org/download.html page. "The Makefile and configure script in this tarball are not supported."

That being said, Ticket #3695 addresses this issue. Makefile.in has been updated and the Makefile in this tarball will be updated with the next release.

 
3705 code closed 2009 Mar anonymous front 2009 Mar   2 1 ROLLBACK TO SAVEPOINT problem
I have Win32 system and database in autovacuum mode. I upgrade my application to use SAVEPOINTs, and I found problem with rollbacks.

I start one named savepoint transaction, made some changes in databse and then I use ROLLBACK TO. Changes made in database are rollbacked well, but transaction remains opened. (Journal file still exists and is locked and autocommit API detection say FALSE).

I can demonstrate this problem by next commands by SQLITE console:

  sqlite> rollback;
  SQL error: cannot rollback - no transaction is active
  sqlite> SAVEPOINT test;
  sqlite> select count(*) from geolist;
  8844
  sqlite> delete from geolist;
  sqlite> select count(*) from geolist;
  0
  sqlite> rollback to test;
  sqlite> select count(*) from geolist;
  8844
  sqlite> rollback;
  sqlite> rollback;
  SQL error: cannot rollback - no transaction is active

As you can see, firts rollback fails. It is OK, I am really not in transaction now. Then I try to open SAVEPOINT and made some modifications in database. You can see, modifications are made correctly.

Then I rollback to SAVEPOINT. Cganges to database are rollbacked well. But transaction remains opened!

You an see it on additional ROLLBACK call... it not raise any error and it destroy opened transaction state. Additional second ROLLBACK demonstrate non-transaction state.

Another problem demonstration:

  sqlite> SAVEPOINT test;
  sqlite> rollback to test;
  sqlite> rollback to test;
  sqlite> rollback to test;
  sqlite> rollback to test;
  sqlite> rollback to test;
  sqlite> rollback;
  sqlite> rollback;
  SQL error: cannot rollback - no transaction is active
  sqlite>

Thank for your help!

2009-Mar-05 14:10:12 by danielk1977:
A "ROLLBACK TO <savepoint>" command does not close the named savepoint. This is different from a plain "ROLLBACK" command. See the docs here:

  http://www.sqlite.org/lang_savepoint.html

In particular the third paragraph of text.

 
3704 doc closed 2009 Mar anonymous front 2009 Oct   4 5 Clarify parameter documentation for isLikeOrGlob in where.c
Suggest the following changes to clarify the parameters

@618

  -int *pnPattern,   /* Number of non-wildcard prefix characters */
  -int *pisComplete, /* True if the only wildcard is % in the last character */
  -int *pnoCase      /* True if uppercase is equivalent to lowercase */
  +int *pnPattern,   /* OUT: returns number of non-wildcard prefix characters */
  +int *pisComplete, /* OUT: True if the only wildcard is % in the last character */
  +int *pnoCase      /* OUT: True if uppercase is equivalent to lowercase */
isLikeOrGlob() is a static, internal function.


2009-Oct-18 07:52:06 by anonymous:
It follows other conventions in the source.
 
3702 code fixed 2009 Mar anonymous   2009 Mar shane 5 4 Misspelling in sqlite3.c (succesfully instead of successfully)
I've seen this error in the newest Firefox 3.2a1 nightlies.

I've fixed it, but I've been told to report it here. Here's the diff:

diff --git a/db/sqlite3/src/sqlite3.c b/db/sqlite3/src/sqlite3.c
--- a/db/sqlite3/src/sqlite3.c
+++ b/db/sqlite3/src/sqlite3.c
@@ -96162,17 +96162,17 @@ static void optimizeFunc(sqlite3_context
       rc = leavesReaderInit(v, -1, iStart, iEnd, pRootData, nRootData,
                             &readers[i].reader);
       if( rc!=SQLITE_OK ) break;

       readers[i].segment = i;
       i++;
     }

-    /* If we managed to succesfully read them all, optimize them. */
+    /* If we managed to successfully read them all, optimize them. */
     if( rc==SQLITE_DONE ){
       assert( i==nReaders );
       rc = optimizeInternal(v, readers, nReaders, &writer);
     }

     while( i-- > 0 ){
       leavesReaderDestroy(&readers[i].reader);
     }
The firefox-bug-report can be found here: https://bugzilla.mozilla.org/show_bug.cgi?id=106386
Corrected occurrences of misspelled word in fts1.c, fts2.c, and fts3.c.
 
3701 warn fixed 2009 Mar anonymous func 2009 Mar shane 5 4 compiler warning on x64 (Visual Studio 2005)
I just downloaded 3.6.11. It compiled in VS2005, 32-bit, with no warnings. Under x64, there was one warning...

4>.\sqlite3.c(58341) : warning C4244: '=' : conversion from '__int64' to 'unsigned int', possible loss of data

Just looking for a squeaky clean build... Thanks!

Modified expr.c to remove indicated warning. Additionally reviewed and corrected other recently modified files.
 
3700 doc closed 2009 Mar anonymous   2009 Mar   5 4 mispelling in .../sqlite-3_6_11-docs/lang_indexedby.html
In /sqlite-3_6_11-docs/lang_indexedby.html:

s/preceeding/preceding/g

2009-Mar-04 11:13:10 by danielk1977:
Thanks. Fixed here:

  http://www.sqlite.org/docsrc/timeline
 
3699 doc closed 2009 Mar anonymous back 2009 Mar   5 5 Clarify parameter documentation for pager_playback_one_page in pager.c
at line 1470 the parameter pOffset is documentated

  i64 *pOffset,                 /* Offset of record to playback */

Since this value is increased to the start of the next page in the journal, a clearer comment would be something like the following

  i64 *pOffset,                 /* IN:  Offset of record to playback */
                                /* OUT: Start of next page in journal */
2009-Mar-18 15:50:41 by drh:
The fact that *pOffset is increased to the beginning of the next record to be played back is explained in the first paragraph of the header comment of the function.
 
3698 event closed 2009 Mar anonymous front 2009 Mar   1 1 error to create more the one table
I cann't create more the one table in the base. Error 11 (SQLITE_CORRUPT)
2009-Mar-03 04:43:12 by danielk1977:
People have successfully created more than one table in an SQLite database before. So there must be something more to this problem. Suggest posting to the mailing list to obtain help:

  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
 
3697 build closed 2009 Mar anonymous   2009 Mar   1 1 compiling on solaris-10 fails: undefined symbol: sqlite3_backup
compiling on solaris-10 fails with:

libtool: compile:  cc -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -xO3 -xtarget=ultra -xarch=v8 -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/opt/csw/include -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_TEMP_STORE=1 -c sqlite3.c -o sqlite3.o >/dev/null 2>&1
./libtool --mode=link cc  -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include  -xO3 -xtarget=ultra -xarch=v8 -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG  -I/opt/csw/include -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1     -L/home/rupert/build.5.8-sparc/opt/csw/lib -L/opt/csw/lib  -o libsqlite3.la sqlite3.lo -lrt  \
                 -rpath "/opt/csw/lib" -version-info "8:6:8"
libtool: link: cc -G -h libsqlite3.so.0 -o .libs/libsqlite3.so.0.8.6  .libs/sqlite3.o   -L/home/rupert/build.5.8-sparc/opt/csw/lib -L/opt/csw/lib -lrt -lc  -xtarget=ultra -xarch=v8
libtool: link: (cd ".libs" && rm -f "libsqlite3.so.0" && ln -s "libsqlite3.so.0.8.6" "libsqlite3.so.0")
libtool: link: (cd ".libs" && rm -f "libsqlite3.so" && ln -s "libsqlite3.so.0.8.6" "libsqlite3.so")
libtool: link: ar cru .libs/libsqlite3.a  sqlite3.o
libtool: link: ranlib .libs/libsqlite3.a
libtool: link: ( cd ".libs" && rm -f "libsqlite3.la" && ln -s "../libsqlite3.la" "libsqlite3.la" )
./libtool --mode=link cc  -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include  -xO3 -xtarget=ultra -xarch=v8 -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG  -I/opt/csw/include -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1     -L/home/rupert/build.5.8-sparc/opt/csw/lib -L/opt/csw/lib  -DHAVE_READLINE=0  \
                -o sqlite3 ./src/shell.c libsqlite3.la \
                 -lrt  -rpath "/opt/csw/lib"
libtool: link: cc -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -xO3 -xtarget=ultra -xarch=v8 -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/opt/csw/include -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DHAVE_READLINE=0 -o .libs/sqlite3 ./src/shell.c  -L/home/rupert/build.5.8-sparc/opt/csw/lib -L/opt/csw/lib ./.libs/libsqlite3.so -lrt -R/opt/csw/lib
"./src/shell.c", line 1101: undefined symbol: sqlite3_backup
"./src/shell.c", line 1101: undefined symbol: pBackup
"./src/shell.c", line 1117: warning: implicit function declaration: sqlite3_backup_init
"./src/shell.c", line 1123: warning: implicit function declaration: sqlite3_backup_step
"./src/shell.c", line 1124: warning: implicit function declaration: sqlite3_backup_finish
"./src/shell.c", line 1508: undefined symbol: sqlite3_backup
"./src/shell.c", line 1508: undefined symbol: pBackup
cc: acomp failed for ./src/shell.c
gmake[1]: *** [sqlite3] Error 2
gmake[1]: Leaving directory `/home/rupert/mgar/pkg/sqlite3/trunk/work/rupert-build8s.d/sqlite3-3.6.11'
gmake: *** [build-work/rupert-build8s.d/sqlite3-3.6.11/Makefile] Error 2
Duplicate of ticket #3695. Fixed already by [6311]
 
3696 warn fixed 2009 Mar anonymous   2009 Mar   4 3 compile time warning, solaris
./libtool --mode=compile --tag=CC cc  -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include  -xO3 -xtarget=ultra -xarch=v8 -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG  -I/opt/csw/include -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1   -DSQLITE_TEMP_STORE=1 -c sqlite3.c
libtool: compile:  cc -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -xO3 -xtarget=ultra -xarch=v8 -I/home/rupert/build.5.8-sparc/opt/csw/include -I/opt/csw/include -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/opt/csw/include -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_TEMP_STORE=1 -c sqlite3.c  -KPIC -DPIC -o .libs/sqlite3.o
"sqlite3.c", line 19786: warning: integer overflow detected: op "<<"
"sqlite3.c", line 19803: warning: integer overflow detected: op "<<"
"sqlite3.c", line 19898: warning: integer overflow detected: op "<<"
"sqlite3.c", line 19899: warning: integer overflow detected: op "<<"
"sqlite3.c", line 26130: warning: statement not reached
"sqlite3.c", line 33261: warning: statement not reached
 
3695 build closed 2009 Mar anonymous build 2009 Mar   3 3 sqlite-3.6.11.tar.gz: Outdated configure+Makefile.in
-The configure script was still for version 3.6.10, which will at least end with wrong version in libtclsqlite.so. It should be regenerated before inclusion in the tarball.

-Makefile.in: It is missing backup.c, so the build process fails with undefined references, this patch should fix it

Already fixed by [6311] .
 
3694 warn closed 2009 Feb anonymous   2009 Oct   3 3 Unpredictable uninitialized variables
--- ../sqlite-3.6.11/sqlite3.c  2009-02-17 16:16:07.000000000 -0500
+++ sqlite3.c   2009-02-26 15:36:59.000000000 -0500
@@ -23045,8 +23045,8 @@
   struct unixLockKey lockKey;    /* Lookup key for the unixLockInfo structure */
   struct unixFileId fileId;      /* Lookup key for the unixOpenCnt struct */
   struct stat statbuf;           /* Low-level file information */
-  struct unixLockInfo *pLock;    /* Candidate unixLockInfo object */
-  struct unixOpenCnt *pOpen;     /* Candidate unixOpenCnt object */
+  struct unixLockInfo *pLock=NULL;    /* Candidate unixLockInfo object */
+  struct unixOpenCnt *pOpen=NULL;     /* Candidate unixOpenCnt object */

   /* Get low-level information about the file that we can used to
   ** create a unique name for the file.
@@ -23947,7 +23947,7 @@
   /* To fully unlock the database, delete the lock file */
   assert( locktype==NO_LOCK );
   if( unlink(zLockFile) ){
-    int rc, tErrno = errno;
+    int rc=SQLITE_OK, tErrno = errno;
     if( ENOENT != tErrno ){
       rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
     }
@@ -54565,7 +54565,7 @@
 ** See also: Clear
 */
 case OP_Destroy: {     /* out2-prerelease */
-  int iMoved;
+  int iMoved=0;
   int iCnt;
 #ifndef SQLITE_OMIT_VIRTUALTABLE
   Vdbe *pVdbe;
@@ -67068,7 +67068,7 @@
   Index *pIdx;           /* For looping over indices of the table */
   int iCur;              /* VDBE Cursor number for pTab */
   sqlite3 *db;           /* Main database structure */
-  AuthContext sContext;  /* Authorization context */
+  AuthContext sContext={NULL,NULL};  /* Authorization context */
   int oldIdx = -1;       /* Cursor for the OLD table of AFTER triggers */
   NameContext sNC;       /* Name context to resolve expressions in */
   int iDb;               /* Database number */
@@ -67085,7 +67085,6 @@
   int iEndBeforeTrigger = 0;   /* Exit of before trigger program */
   u32 old_col_mask = 0;        /* Mask of OLD.* columns in use */

-  sContext.pParse = 0;
   db = pParse->db;
   if( pParse->nErr || db->mallocFailed ){
     goto delete_from_cleanup;
@@ -79372,7 +79371,7 @@
   int chngRowid;         /* True if the record number is being changed */
   Expr *pRowidExpr = 0;  /* Expression defining the new record number */
   int openAll = 0;       /* True if all indices need to be opened */
-  AuthContext sContext;  /* The authorization context */
+  AuthContext sContext={NULL,NULL};  /* The authorization context */
   NameContext sNC;       /* The name-context to resolve expressions in */
   int iDb;               /* Database containing the table being updated */
   int j1;                /* Addresses of jump instructions */
@@ -79399,7 +79398,6 @@
   int regData;           /* New data for the row */
   int regRowSet = 0;     /* Rowset of rows to be updated */

-  sContext.pParse = 0;
   db = pParse->db;
 
3693 new closed 2009 Feb anonymous   2009 Oct   4 4 index_info
ASC and DESC indexes cannot be easily distinguished:

  SQLite version 3.6.11
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t(a);
  sqlite> create index i1 on t(a desc);
  sqlite> create index i2 on t(a asc);
  sqlite> pragma index_info(i1);
  0|0|a
  sqlite> pragma index_info(i2);
  0|0|a
2009-Oct-13 00:04:58 by anonymous:
Please post a use case to the sqlite-users mailing list. This tracker and ticket are now closed.
 
3692 new closed 2009 Feb anonymous front 2009 Oct   5 3 New define such as SQLITE_DISABLE_VIEW_ON_ATTACHED_DATABASE
I did try

$ sqlite3 :memory:
SQLite version 3.6.11
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> attach database 'merch.db' as work;
sqlite> create view test as select * from work.users;
SQL error: view test cannot reference objects in database work

But it's work some time ago! Now I can create table to saving view
definitions and after connection open create these as "temp
view" or disable the check.

I did patch for me attach.c as

/*      sqlite3ErrorMsg(pFix->pParse,
         "%s %T cannot reference objects in database %s",
         pFix->zType, pFix->pName, pItem->zDatabase);
      return 1;*/
      return 0;

I think the define such as
SQLITE_DISABLE_VIEW_ON_ATTACHED_DATABASE
may be useful in code.
2009-Feb-27 21:35:35 by anonymous:
And PRAGMA for this feature may be very nice! My applications are use views for attached databases and this is feature. For big datasets having a lot of databases are managed by single application views must work with multiple attached databases. But now we have "attach" command without possibility of using it effectively.


2009-Mar-06 13:13:12 by anonymous:
I think it is a bad thing to be able to create inconsistent schemas.


2009-Oct-13 00:03:19 by anonymous:
Why can't you create the view on the attached database (ie load it as the main database, create view, exit) then attach that database?

This tracker and ticket is now closed. Please continue discussion on the sqlite-users mailing list.

 
3691 new closed 2009 Feb anonymous tcl 2009 Oct   5 3 persist parameters in views
We can do
set param {test' sql with some injection}
set param [db onecolumn {select quote($param)}]
puts $param

and get result
'test'' sql with some injection'

Well, it's good. And now query
db eval "create view view_events as select * from events where value!=$param"
is valid.

But how about construction such as
db eval {create view view_events as select * from events where value!=#param}
were #param will be automatically replaced by result of {select
quote($param)}?
2009-Oct-15 20:39:07 by anonymous:
Why not just use the quote function directly? In any event I don't see a use case for this. This ticket and tracker are now closed. Please continue discussion on the sqlite-users mailing list.
 
3690 new closed 2009 Feb anonymous func 2009 Feb shane 5 4 UnEscape function should be there in SQLite
Hello, We are developing an application where user enters data which is likely to have special characters and other like: '":$&.. now the problem is that because database will not save these characters, which is good. We used escape function from within Flex application before sending and saving the data in database. But the problem is that while retrieving I want to have a function which we should be able to define in the sql statement while selecting the colomn, this will save execution time. Now if I am giving to any component the database object as dataProvider then before giving I have to call a function inside and then do the unescaping there. There should be a function to UnEscape the text, and bring the text back to the actual text which user entered

Please let me know if my problem seems logical. Thanks Sunny

The description is unclear, but I think the OP is requesting the "quote()" function, which already exists.

http://www.sqlite.org/lang_corefunc.html#quote

 
3689 code closed 2009 Feb anonymous   2009 Mar   3 4 amalgamation not building with SQLITE_OMIT_VIRTUALTABLE gcc 4.1.2
sqlite3.c line 11324 (#ifdef SQLITE_OMIT_VIRTUALTABLE) needs

   #  define sqlite3VtabArgInit(X)
   #  define sqlite3VtabArgExtend(X,Y)
   #  define sqlite3VtabBeginParse(A,B,C,D)
   #  define sqlite3VtabFinishParse(X,Y)

corresponding functions need to be declared on #else. On 3.6.11 they're always declared, leading to:

In function `sqlite3Parser':

   sqlite3.c:(.text+0x2efad): undefined reference to `sqlite3VtabFinishParse'

   sqlite3.c:(.text+0x2efcf): undefined reference to `sqlite3VtabFinishParse'

   sqlite3.c:(.text+0x2f007): undefined reference to `sqlite3VtabBeginParse'

   sqlite3.c:(.text+0x2f01e): undefined reference to `sqlite3VtabArgInit'

   sqlite3.c:(.text+0x2f040): undefined reference to `sqlite3VtabArgExtend'
The OMIT compile-time options are not supported in the amalgamation or in the preprocessed source files. If you need to generate a reduced-functionality version of SQLite, then you will need to begin with canonical sources and rerun the code generators, especially the parser generator "lemon". This is because different code is generated depending on which compile-time OMIT options are selected.

You might be able to get the amalgamation to build with some OMIT options, but if you do that is purely by chance.


2009-Mar-02 03:40:40 by shane:
See also: http://www.sqlite.org/compile.html#omitfeatures
 
3688 code closed 2009 Feb danielk1977 front 2009 Feb danielk1977 1 1 Disappearing temp triggers
The attached script demonstrates a couple of problems with temp triggers on non-temp tables. Temporary triggers can appear to simply disappear from the database schema. This can happen when:

  • Using shared-cache mode, or
  • When a temporary trigger is added to a table in an ATTACHed database and an external connection modifies the schema of that database, forcing a schema reload.
Bug found while searching for a separate problem that turned out to be external. Unclear if this was ever seen in a real application or not.
 
3687 new closed 2009 Feb anonymous ext 2009 Oct   1 3 Make genfkey code available in amalgamation
In [6326] the genfkey functionality was moved into the shell code. Please can you instead make the actual functionality be part of the amalgamation so that it can be used from other places in addition to the shell. I understand that the API would be considered very experimental.

As an example someone using my Python wrapper should not be forced to find an appropriately compiled shell just to get the genfkey output. I want to provide it directly from the wrapper.

2009-Oct-13 00:05:53 by anonymous:
SQLite 3.6.19 natively supports foreign keys so this is no longer an issue. Withdrawing.
 
3686 build closed 2009 Feb anonymous build 2009 Feb   4 4 @RELEASE@ isn't set in sqlite3.pc in amalgamation tarball
When sqlite3.pc is built it the "Version: @RELEASE@" doesn't get converted to a real version number. It looks like the configure.ac in sqlite-amalgamation-3.6.11.tar.gz doesn't set RELEASE or do AC_OUTPUT on the .pc file.
Sorry, looks like this is a dupe of 3583.
 
3685 new closed 2009 Feb anonymous front 2009 Oct   3 3 Enhance INSERT syntax, allowing multiple VALUES
Please, enhance INSERT syntax, allowing multiple VALUES:

INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] VALUES(value-list) [, (value-list)]*

This allows to raise uploading performance of a large volume of a data, using standard SQL syntax and API.

2009-Apr-17 20:35:50 by anonymous:
My understanding is that this paradigm helps primarily when the client and server are running in different processes and/or on different machines.

Question: Would batching actually help the VDBE?

What might work better is the ability to bind memory locations (owned by caller) such that only the first bind would be necessary.

int myInt=5; permanentBind(&myInt,1); for(int i=0;i<1000;i++) { step(); myInt++; }

 
3684 code closed 2009 Feb anonymous   2009 Feb   2 2 db size quadruplicated
Starting with sqlite version 3.6.11 the size of db has been grown:

SQLite version 3.5.4 D:\> sqlite v354.db < db.sql
SQLite version 3.6.7 D:\> sqlite v367.db < db.sql
SQLite version 3.6.11 D:\> sqlite v3611.db < db.sql

D:\>dir
02/25/2009 02:48 PM 66,806 db.sql
02/25/2009 05:11 PM 573,440 v354.db
02/25/2009 05:12 PM 573,440 v367.db
02/25/2009 05:13 PM 2,097,152 v3611.db

Is this the expected behaviour ?

2009-Feb-25 18:45:49 by danielk1977:
Is the database page size the same in each file?

Can you post db.sql?


2009-Feb-25 19:26:20 by drh:
Please run

   sqlite3 v3611.db "pragma integrity_check"

and send us the results. Also, please download sqlite3_analyzer.exe from http://www.sqlite.org/download.html and run it on all three of your database files and send us the results. Thanks.


2009-Feb-25 20:19:55 by anonymous:
ciao

The bigger one have 32768 page size, the others 8192.

/** Disk-Space Utilization Report For v3611.db
Page size in bytes.................... 32768
Pages in the whole file (measured).... 64
Pages in the whole file (calculated).. 64

/** Disk-Space Utilization Report For v367.db
Page size in bytes.................... 8192
Pages in the whole file (measured).... 70
Pages in the whole file (calculated).. 70


2009-Feb-25 21:41:30 by drh:
There you go. So run:

    PRAGMA page_size=8192; VACUUM;

on the larger database and you should be back to your expected size.

I'm guessing that your schema contains 63 mostly empty tables and indices. Each table and index takes a minimum of 1 disk page, even if it is empty. So the smaller your pages, the smaller the minimum database size will be. On the other hand, queries can sometimes be faster with larger pages. There is a trade-off between performance and space. Pick a page size that works best for you.

 
3683 code closed 2009 Feb anonymous ext 2009 Nov anonymous 3 4 Broken Query with FTS3
In testing the different capabilities of the FTS3 module, I developed a query where I was subtracting a phrase(-"phrase of multiple words") within the MATCH portion of the query. Here's a representation of the query:

SELECT a.path FROM tbl0 a, tbl1 b WHERE b.i_id=a.i_id and b.prop MATCH 'term -"multi-word phrase"' AND a.i_current=1 AND a.is_deleted=0

This results in the error: SQL error: SQL logic error or missing database

In reading through the documentation, I didn't see anything indicating that this was forbidden. I'm guessing this likely hasn't been implemented yet, if so, let me know and I'll put in a feature request, if not, below is the table creation statements.

Table 0 is a normal (non-fts) table. Here's the create statement for it:

CREATE TABLE 'tbl0' ( i_id TEXT PRIMARY KEY DEFAULT '', path TEXT DEFAULT '', i_current BOOLEAN DEFAULT 1, is_deleted BOOLEAN DEFAULT 0 )

Table 1 is a VIRTUAL table. Here's the create statement for it:

CREATE VIRTUAL TABLE 'tbl1' using fts3( prop, tokenize porter, i_id, tokenize simple )

One interesting tidbit is that the query fails when issued via the CLI and PHP-PDO, but not when issued via TkSQLite. TkSQLite seems to ignore the offending (-"multi-word phrase") and issues the query without it.

2009-Nov-08 02:37:02 by anonymous:
Please discuss this issue on the sqlite-users mailing list as this tracker and hence ticket are now closed.
 
3682 code closed 2009 Feb anonymous   2009 Feb   3 1 strftime format problem
query select strftime("%Y-%d-%m", "2009-01-02");
returns 2009-02-01, it's correct
query select strftime("%Y-%m-%d", "2009-01-02");
returns 2009-01-02, it's correct too
but query select strftime("%d-%m-%Y", "01-02-2009");
returns NULL
2009-Feb-25 15:00:24 by drh:
Works as intended.

Please reread the documentation and/or ask for help on the sqlite-users mailing list on how to use of the strftime() function. Thanks.

 
3681 new closed 2009 Feb anonymous front 2009 Oct   1 1 have AUTOINCREMENT in column-indexed statment, not only in column-def
This code :
CREATE TABLE IF NOT EXISTS `Diagnosis` (
  `id` INTEGER UNIQUE,
  `name` TINYTEXT NOT NULL,
  `description` TEXT,
  PRIMARY KEY (`id`) AUTOINCREMENT -- HERE !!
)
Doesn't work (Syntax error) : indeed, AUTOINCREMENT here does not make sense.

This code :
CREATE TABLE IF NOT EXISTS `Diagnosis` (
  `id` INTEGER UNIQUE,
  `name` TINYTEXT NOT NULL,
  `description` TEXT,
  PRIMARY KEY (`id` AUTOINCREMENT) -- HERE !!
)
Doesn't work (Syntax error) : AUTOINCREMENT here should make sense.

This code :
CREATE TABLE IF NOT EXISTS `Diagnosis` (
  `id` INTEGER UNIQUE AUTOINCREMENT, -- HERE !!
  `name` TINYTEXT NOT NULL,
  `description` TEXT,
  PRIMARY KEY (`id`)
)
Doesn't work (Syntax error).

This code :
CREATE TABLE IF NOT EXISTS `Diagnosis` (
  `id` INTEGER UNIQUE,
  `name` TINYTEXT NOT NULL,
  `description` TEXT,
  PRIMARY KEY (`id`) -- HERE !!
)
Works but there is no AUTOINCREMENT.

This code :
CREATE TABLE IF NOT EXISTS `Diagnosis` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT,
  `name` TINYTEXT NOT NULL,
  `description` TEXT
)
Works, but not very handy in case of multiple columns primary keys : can't use one PRIMARY KEY statment that decouples column definition and index definition.
2009-Oct-04 23:08:41 by anonymous:
As far as I can tell AUTOINCREMENT is not a part of the SQL standard and other databases use different keywords to achieve the same thing (IDENTITY, AUTO_INCREMENT).

This means you are already writing SQLite specific code, so you may as well make your code produce SQL that conforms to SQLite's requirements :-)

This bug tracker is no longer used so closing this bug. Please continue discussion on the sqlite-users mailing list.

 
3680 code closed 2009 Feb anonymous back 2009 Jul   1 1 Enormous database file size
I use SQLite on Windows Mobile platform. We have a huge problem with database size. Recently I was fixing few devices that came back from the client. On every one of them database file had a enormous size of 17-22MB !!! I tried to run VACUUM on those devices, but it didn't help as much as I expected (max 0.5MB reclaimed) The size would be not a problem at all if it would be expected, but that database should have max size of 6MB. Now is the fun part, when I dump query I get a script of size about 3MB, and then after creating database file and importing that script I get identical database (in terms of data and schema) as the large one, but size is as expected 5.8MB

Where is that space going? How to reclaim it.

Sorry, but I cannot publish any of those databases because of data stored within them, and I was unable to reproduce this situation using controlled environment.

2009-Feb-25 11:36:47 by drh:
This is a request for support. Please make such requests on the sqlite-users mailing list. Reserve tickets for reporting bugs and or making feature requests. Thank you.


2009-Feb-25 12:50:45 by anonymous:
In my opinion eating memory or disk space is a serious issue not a feature request. I will put this in an other way. VACUUM doesn't work as expected.


2009-Feb-25 21:37:05 by drh:
The Analyze.ZIP file that you sent shows that the larger version of the database is 12.1 MB (not 17-22) and the small version is 7.2 MB (not 5.8). This difference is less than 2x and is likely due to the large database using a UTF-16 encoding while the smaller one is using UTF-8. You can verify this by running:

    PRAGMA encoding;

On each database file.


2009-Feb-25 22:17:52 by anonymous:
This is a randomly selected sample (there are almost 2000 devices to deal with and I run analyze on an actually processed device.) Both databases use UTF-16le encoding. If I came across next device with such a difference I will post results.


2009-Feb-26 06:50:09 by anonymous:
I did not mention that integrity check did not find anything on that particular example, I will howewer test other and post result if I find something.


2009-Mar-16 12:29:56 by drh:
OP is unable to provide a test case. Closing this ticket.


2009-Jul-08 13:39:51 by anonymous:
I've managed to reproduce this one. While using big transactions on mobile device (WM6). Let say we have 2MB of raw data in let say 20 tables with indexes. That gives us 3MB SQLite DB. Now when merging 1MB packet of data for every table that will produce growth of database to 4.5MB, but raw data stays the same (number of records) Let say that each table have column name with value 'Name %d' and we send packet that changes this to 'Eman %d'. The only thing that I did not mention is the way it is done. I will write this in points.

1.To main.db (3MB) database attach incoming database packet.db (1.2MB) 2.Begin transaction 3.Copy data of each table using one of the following (depending on incoming and existing columns in DB):

  REPLACE INTO main.t(main.t.c1, main.t.c2, main.t.c3) SELECT packet.t.c1, packet.t.c2, packet.t.c3 FROM packet.t

  REPLACE INTO main.t(main.t.c1, main.t.c2, main.t.c3) SELECT packet.t.c1, packet.t.c2, main.t.c3 FROM packet.t INNER JOIN main.t ON packet.t.ID = main.t.ID

4.Commit Transaction (Journal approx 2MB → Final main.db size 4.5MB) 5.Detach database and delete file

Using bigger packets produces bigger results, max size I've got on similar set of data was 2.62x larger than initial database size. I know the mechanics, and I know that unused pages can't be released until transaction ends and this is the cause of growth, but VACUUM on mobile does nothing except waste of time, pages remain in db file.

When I will have time I will produce some scripts to generate this issue. Only trick is that this is 100% on mobile, I don't know how this will act on desktop.

PS. Page size 4096


2009-Jul-13 18:13:28 by anonymous:
In version 3.6.16 it seams to be solved... Databases still grow, but vacuum manages to reclaim unused space.
 
3679 code closed 2009 Feb anonymous front 2009 Feb danielk1977 3 3 sqlite3_table_column_metadata fails in havy threading environment
I have about 30 threads. Each of them:
  • uses dedicated connection to the same database file;
  • uses single statement SELECT * FROM MyTab. All commands - the same statement;
  • calls sqlite3_table_column_metadata to get result set columns metadata.

If to call "sqlite3_enable_shared_cache(1)" before running a test, then the threads start to fail on sqlite3_table_column_metadata with "no such table column: MyTab.XXX" error message.

If to call "sqlite3_enable_shared_cache(0)" before running a test, then test passes OK.

Thanks for the report.
 
3678 new active 2009 Feb anonymous front 2009 Mar   3 5 index not selected with re-ordered distinct columns
This is based upon an up-to-date cvs build (as of 2009-02-24). If a select distinct is made with columns in a different order than an index, the query planner uses no index. Obviously, since the order that the columns are selected does not affect the results, the query planner should have used the index.

  $ ./sqlite3 tmp.db
  SQLite version 3.6.11
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t1( a int, b int);
  sqlite> create index t1_i on t1( a, b);
  sqlite> explain query plan select distinct a, b from t1;
  0|0|TABLE t1 WITH INDEX t1_i ORDER BY
  sqlite> explain query plan select distinct b, a from t1;
  0|0|TABLE t1
2009-Mar-06 02:45:45 by shane:
One risk with this change is that it will change the "unspecified" order of the result set and potentially break existing code. Arguably any code that depends on SQLite returning a result set in a particular order without specifing an ORDER BY clause is already "broken".
 
3677 warn closed 2009 Feb anonymous vfs 2009 Feb danielk1977 5 5 os_common.h may have unneeded definition of sqlite3_pending_byte
Version 3.6.11 now contains a definition of sqlite3PendingByte at line 190

This makes the os_common.h definition unnecessary at line 35:

  /*
   * When testing, this global variable stores the location of the
   * pending-byte in the database file.
   */
  #ifdef SQLITE_TEST
    unsigned int sqlite3_pending_byte = 0x40000000;
  #endif
2009-Feb-24 18:42:18 by danielk1977:
Thanks.
 
3676 code closed 2009 Feb anonymous cli 2009 Feb   5 5 SQLite error no such table: syringes
c# application connectivity issue
 
3675 code closed 2009 Feb anonymous back 2009 Feb   3 3 load_extension does not work in trigger
Trigger which uses 'SELECT load_extension(...)' before calling function defined in that extension still fails with a 'no such function' error.
2009-Feb-23 23:39:48 by drh:
Nor will this change. Function names are resolved at when a statement is prepared. Triggers run when the statement is evaluated. Preparation happens before evaluation. Hence, you cannot you cannot call load_extension() in a trigger and expect it to be in effect for a statement that fired that trigger.
 
3674 code closed 2009 Feb anonymous func 2009 Feb   1 1 sum() function error
It's rigth result:
sqlite> select login,sum(round(cost,2))
   ...> from telephony_record as r, user_services as us, users as u
   ...> where r.user_service_id=us.id and us.owner_id=u.id and login='testuser'
   ...> and r.date between julianday('2009-01-01') and julianday('2009-01-31')
   ...> group by user_service_id;
testuser|3602.94

But it's wrong result:
sqlite> select login,sum(round(cost,2))
   ...> from telephony_record as r, user_services as us, users as u
   ...> where r.user_service_id=us.id and us.owner_id=u.id
   ...> and r.date between julianday('2009-01-01') and julianday('2009-01-31')
   ...> group by user_service_id
   ...> limit 1 offset 10;
testuser|3602.93999999999

2009-Feb-22 23:55:37 by drh:
SQLite using floating-point numbers. And floating point numbers are an approximation. So sometimes they get a little bit off. This is a property of the floating point number implementation in your hardware, not a property of SQLite.

See http://www.sqlite.org/faq.html#q16


2009-Feb-23 09:36:48 by anonymous:
Well, I think the problem may be solved as:

sqlite> select login,sum(round(100.*cost))/100.0
   ...> from telephony_record as r, user_services as us, users as u
   ...> where r.user_service_id=us.id and us.owner_id=u.id
   ...> and r.date between julianday('2009-01-01') and julianday('2009-01-31')
   ...> group by user_service_id
   ...> limit 1 offset 10;
testuser|3602.94
This query is a few slow but more correct.
 
3673 build closed 2009 Feb anonymous build 2009 Oct   2 3 makefile doesn't clean pkgIndex.tcl and sqlite3_analyzer
@@ -796,6 +847,8 @@
        rm -f common.tcl
        rm -f sqlite3.dll sqlite3.lib sqlite3.def
        rm -f sqlite3.c .target_source
+       rm -f pkgIndex.tcl
+       rm -f sqlite3_analyzer$(TEXE)
2009-Oct-20 06:37:00 by anonymous:
This tracker and hence ticket are now closed. If this is still an issue then please continue discussion on the sqlite-users mailing list where other developers can help find a solution.
 
3672 code closed 2009 Feb anonymous front 2009 Oct   4 4 Inconsistent column names returned
Column names without using an AS clause are not guaranteed, but I would expect that they at least be consistent. In this case, the table has lowercase column names, and the first query returns them as expected, even though the names were entered in uppercase. However, in the 2nd case, the the uppercase names are returned. This is not a "BUG", just unexpected.

  sqlite> .header on
  sqlite> CREATE TABLE T (c1, c2);
  sqlite> INSERT INTO T VALUES (1,2);
  sqlite> SELECT C1, C2 FROM T;
  c1|c2
  1|2

  sqlite> SELECT C1, C2 FROM T UNION SELECT * FROM T WHERE c1=-1;
  C1|C2
  1|2
As you observer, we make no guarantees about column names from queries that omit the AS clause.

In the current implementation, a simple queries uses the column names as they appear in the CREATE TABLE statement for the table being queried. Compound queries uses the column names as they appear in the SELECT statement.

 
3671 build fixed 2009 Feb anonymous build 2009 Feb   5 4 backup api was not exported in sqlite3.def
I just downloaded sqlite3.6.11 source from http://www.sqlite.org/sqlite-3.6.11.tar.gz. and found that the backup api was not exported in sqlite3.def
The correct sqlite3.def is found in sqlitedll-3_6_11.zip.
 
3670 new active 2009 Feb anonymous cli 2009 Feb   5 3 Shell: The "backup_timeout" method for backup/restore operations
The feature wiil be very useful.
2009-Feb-22 01:17:09 by anonymous:
Care to explain? The destination is held exclusively until finish is called. The source is acquired for each step and obeys the busy handler. The number of pages copied (and hence I/O done) is controlled by the parameter you specify to step.


2009-Feb-22 10:41:49 by anonymous:
timeout is ignored. When source database is locked we getting busy error immediately:

sqlite> .timeout 10000

sqlite> .restore /tmp/test.db

source database is busy

 
3669 code fixed 2009 Feb anonymous build 2009 Feb   1 1 maki install error "libtool: install: error: relink `libtclsqlite3.la"
$ make install
echo 'package ifneeded sqlite3 3.6.11 [list load /usr/share/tcltk/tcl8.4/sqlite3/libtclsqlite3.so sqlite3]' > pkgIndex.tcl
/usr/bin/install -c -d /usr/share/tcltk/tcl8.4/sqlite3
./libtool --mode=install /usr/bin/install -c libtclsqlite3.la /usr/share/tcltk/tcl8.4/sqlite3
libtool: install: warning: relinking `libtclsqlite3.la'
libtool: install: (cd /srv/dev/sqlite-3.6.11/sqlite-3.6.11/sqlite-3.6.11; /bin/sh /srv/dev/sqlite-3.6.11/sqlite-3.6.11/sqlite-3.6.11/libtool
--mode=relink gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/usr/include/tcl8.4
-DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -o
 libtclsqlite3.la tclsqlite.lo libsqlite3.la -L/usr/lib -ltclstub8.4 -lpthread -rpath /usr/share/tcltk/tcl8.4/sqlite3 -version-info 8:6:8 -avoid-version )
libtool: relink: gcc -shared  .libs/tclsqlite.o   -Wl,-rpath -Wl,/tmp/sqlite3/lib -L/tmp/sqlite3/lib -lsqlite3 -L/usr/lib -ltclstub8.4
-lpthread    -Wl,-soname -Wl,libtclsqlite3.so -o .libs/libtclsqlite3.so
/usr/bin/ld: cannot find -lsqlite3
collect2: ld returned 1 exit status
libtool: install: error: relink `libtclsqlite3.la' with the above command before installing it
make: *** [tcl_install] Ошибка 1
2009-Feb-20 22:19:57 by anonymous:
Already fixed: http://www.sqlite.org/cvstrac/chngview?cn=6300
 
3668 build fixed 2009 Feb anonymous build 2009 Mar   2 3 sqlite3.1 manpage not included in amalgamation tarball
The sqlite3.1 manpage is not bundled in the amalgamation tarball. This means any build system that uses the amalgamation tarball cannot install the manpage. I consider this a serious problem.

This was discovered when trying to convert the MacPorts sqlite3 Portfile to use the amalgamation tarball.

The file has been added and should appear in the next release (3.6.12).
 
3667 build closed 2009 Feb anonymous build 2009 Feb   4 3 ./configure does not recognize --enable-dynamic-extensions
In the sqlite-amalgamation-3.6.11 tarball (I have not tested anywhere else) the configure script documents the --enable-dynamic-extensions option but does not actually recognize this option. From reading the source, it appears to be checking for --enable-tempstore instead.
2009-Feb-20 00:53:11 by anonymous:
Looks like this is a duplicate of #3189. Maybe this will prompt someone to actually deal with that ticket, though.


2009-Feb-21 06:29:08 by danielk1977:
Thanks. The autoconf stuff for the amalgamation is in an offline source repository. The problem has been fixed there now so 3.6.12 should contain the fix.
 
3666 code active 2009 Feb anonymous   2009 Feb   3 1 softHeapLimitEnforcer called too many times
In malloc.c, the softHeapLimitEnforcer function releases the amount of requested memory. The older signature of the function was:

static void softHeapLimitEnforcer( void *NotUsed, sqlite3_int64 inUse, int allocSize)

It seems that the inUse parameter is now 'NotUsed2'.

The problem is this: the enforcer releases only as much memory as requested. This results in many, many calls when in tight situations, to the point of consuming most of the processing time. The routine should release slightly more memory than requested. In our tests, we found this to be very effective:

if (allocSize < 256*1024) { allocSize += inUse/8; } sqlite3_release_memory(allocSize);

 
3665 code closed 2009 Feb anonymous   2009 Feb danielk1977 2 1 sqlite3_errmsg16 returns unaligned string
On little-endian platforms, many times deferencing a Unicode string requires that the string is on a word boundary.

The semantics of outOfMemBe[] and misuseBe[] can cause alignment faults if they are used on these platforms. As a workaround, the first '0' should be wrapped in a compile-time directive, e.g.:

  static const char outOfMemBe[] = {
#if SQLITE_UTF16NATIVE==SQLITE_UTF16BE
	  0,
#endif
       'o', 0, 'u', 0, 't', 0, ' ',
    0, 'o', 0, 'f', 0, ' ',
    0, 'm', 0, 'e', 0, 'm', 0, 'o', 0, 'r', 0, 'y', 0, 0, 0
  };

Then, later in the code, don't check the endianness at runtime. Simply return:

return (void *)(&outOfMemBe[0]);

This of course would emit a new requirement that the endianness be defined at compile time, which is a reasonable requirement.

If we had the following, would that work on all platforms?

  static const i16 outOfMem[] = {
    'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
  };
  static const i16 misuse[] = {
    'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
    'r', 'o', 'u', 't', 'i', 'n', 'e', ' ',
    'c', 'a', 'l', 'l', 'e', 'd', ' ',
    'o', 'u', 't', ' ',
    'o', 'f', ' ',
    's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0
  };

  ...

  return (void *)outOfMem;


2009-Feb-23 14:07:06 by anonymous:
It does look like that would work on all platforms. u16 would probably be better, though.
 
3664 build fixed 2009 Feb anonymous build 2009 Feb   4 3 [PATCH] Invalid sqlite3.pc generated by build
The distributed file sqlite3.pc.in is wrong, resulting in an unusable sqlite3.pc being generated when sqlite is built from source. The attached patch fixes the issue.
 
3663 code fixed 2009 Feb drh back 2009 Feb   2 1 VACUUM changes auto_vacuum=INCREMENTAL into auto_vacuum=FULL
Title says all.
This apparently has never worked right up until now. On the other hand, nobody has ever before noticed, so I suppose it is not a widely used feature.
 
3662 build fixed 2009 Feb anonymous back 2009 Feb   5 3 sqlite3PagerBackupPtr not marked private
sqlite3PagerBackupPtr is not marked SQLITE_PRIVATE and hence shows up as a public symbol.

Please can you add something to the automated testing to detect this sort of thing? This ground has been covered before in #2792, #2793, #3631 and #3392.

 
3661 code closed 2009 Feb anonymous front 2009 Feb   1 2 ADD COLUMN produces fatal error on a particular table.
Open the attached database, which contains a "Nodes" table. Reproducing the bug is a matter of two statements:

  $ sqlite3 bug.db
  SQLite version 3.5.4
  Enter ".help" for instructions
  sqlite> create temporary table temp as select * from nodes;
  sqlite> alter table temp add column col2 integer default 0;
  SQL error: malformed database schema - unrecognized token: "0TEXT"
  sqlite>

I have verified that the same error is issued on versions 3.4 and 3.6... An identical "ALTER TABLE" on the "Nodes" table (as opposed to the temporary table) works.

Duplicate of ticket #3630. Already fixed by check-in [6232]
 
3660 code closed 2009 Feb anonymous func 2009 Feb   1 1 SQLite truncates my blob data
When I am binding a blob value (=a bit pattern I want to store) to a parameter of an SQL-statement value using 'sqlite3_bind_blob' I get a truncated value stored in the database if any byte of the blob is a has the value x00.

Schema: CREATE TABLE BLOB_TABLE ( Id BLOB, Data BLOB);

The inputs to the 'sqlite3_bind_blob' function is the address to my local blob variable and the size of it in bytes.

If I have a blob containing 12 bytes with the hex contents ff ff ff 7f ff ff ff 7f ff ff ff 7f

then I can correctly bind it to the parameter, store it in the database and retrieve it again without distorsion.

But if I have a blob containing 12 bytes with the contents 9b c4 20 00 ff ff ff 7f ff ff ff 7f

the only thing that can be retrieved is the first 3 bytes.

It seems to me like something in the path from the 'sqlite3_bind_blob' call until it is stored in the database interprets the bit pattern as being a string with a null termination in the 4th byte.

Currently I can not proceed with my project. Is there anything that i can do to overcome this problem?

Best regards /Erik Wedin

2009-Feb-17 18:06:14 by drh:
I don't know what is wrong with your application. As you say, it seems like something in the path is truncating your blobs.

But that something probably isn't SQLite. We have many tests that verify that SQLite handles binary data correctly. And there are many applications that use the blob capabilities of SQLite (cases in point fossil, monotone, and Adobe Lightroom) and those applications have had no problems.

If you can give us a specific, reproducible example of something that SQLite is not doing correctly, we will be glad to look into the matter for you. But this sounds like it is a problem in your application, not in SQLite.

 
3659 build active 2009 Feb anonymous build 2009 Feb   4 3 Building sqlite-tea: TEA version, install location, no tests
Downloaded sqlite-3_6_10-tea.tar.gz today and went ahead to compile it. This seemes to have produced a working extension, but I hit some snags along the way.

My `uname -a` is: Darwin iBook12.local 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc

First problem: When running ./configure, it first says

  checking for correct TEA configuration... warning: requested TEA version "3.6", have "3.5"

AFAICT, the TEA version provided in the tarball is indeed 3.5 (tclconfig/tcl.m4 says dnl TEA_VERSION="3.5") but the code also requires 3.6 (e.g. configure.in says TEA_INIT([3.6])), so apparently this distro isn't quite in sync with itself.

Running ./configure also produces the warning

  config.status: WARNING:  'Makefile.in' seems to ignore the --datarootdir setting

which I have no idea whether it makes any difference, but I haven't seen it when building anything else (such as Tcl itself) before.

Second: Running make, I get a lot of warnings like

  ./generic/tclsqlite3.c: In function 'dotlockUnlock':
  ./generic/tclsqlite3.c:23577: warning: 'rc' may be used uninitialized in this function
  ./generic/tclsqlite3.c: In function 'plrStep':
  ./generic/tclsqlite3.c:90178: warning: 'i' may be used uninitialized in this function
[snip]
  ./generic/tclsqlite3.c: At top level:
  ./generic/tclsqlite3.c:96697: warning: 'sqlite3Fts3IcuTokenizerModule' declared 'static' but never defined

but I learnt from the FAQ that this was more or less to be expected, and shouldn't be a concern since SQLite has a thorough test suite, so no big deal here. Make finishes without error, but ends with writing:

  : libsqlite3.6.10.dylib
  If you have documentation to create, place the commands to
  build the docs in the 'doc:' target.  For example:
        xml2nroff sample.xml > sample.n
        xml2html sample.xml > sample.html

which is perhaps an indication that the makefile contains some boilerplate code that should probably not be there if not relevant.

Third problem: Having encountered several warnings, and read that the SQLite developers' philosophy is that code quality is ensured through rigorous test suites, the natural next step seemed to be to make test. This resulted in (manually wrapped and trimmed to avoid excessive line length in report)

  TCL_LIBRARY=`echo /Installerare/Tcl/tcl8.5a6/library` \
    DYLD_LIBRARY_PATH=".:/Users/lars/Library/Frameworks/Tcl.framework:" \
    TCLLIBPATH="." /tclsh8.5 `echo ./tests/all.tcl`
  /bin/sh: line 1: /tclsh8.5: No such file or directory
  make: *** [test] Error 127

Looking again at the tarball contents, I realise that there weren't any tests in it. Pity! But then why is there even a "test" make target? (That it thinks /tclsh8.5 is a perfectly good path to tclsh is also odd, but could be a consequence of other things going wrong.)

Fourth problem: The make install target.

Slightly inspired by the README, my configure invocation had been:

  ./configure --prefix=/Library/Tcl

but the makefile still wants to put sqlite itself in /usr/local/lib/sqlite3.6.10/ -- the only thing for which it honors the specified --prefix is the man page.

Finally: One of the things actually included in the tarball is the documentation for the TEA system in (I believe) doctools format, which on one hand is nice (it looks like a more up-to-date documentation than what I've encountered before), but also seems unnecessary for a distribution as streamlined as this one (no tests, nor any package documentation to speak of). Might it be that some packaging script is grabbing the wrong directory?

 
3658 code active 2009 Feb anonymous   2009 Feb   1 2 Queries return inconsistent results
I will say up front I am not expecting commercial support as it is clearly stated this is not an option.

I do want to report a bug because presumably, someone cares.

I am using SQLite to crunch data for use in a spreadsheet.

I run this sql from a file into sqlite:

  -- Drop existing tables
  DROP TABLE TMPDATA1 ;
  DROP TABLE TMPDATA2 ;
  -- Create main data table
  CREATE TABLE TMPDATA1 (
  mth char(8),
  tid  char(8),
  hrs numeric,
  atof char(1)
  );
  -- Create employee <-> team / tower lookup table
  CREATE TABLE TMPDATA2 (
  tid char(8) primary key,
  emp varchar(40),
  team varchar(40),
  twr varchar(40),
  mth char(8)
  );
  -- Set default options: use comma as a delimiter, turn headers on
  .mode list
  .separator ","
  .headers on
  -- Route messages to stdout (handy way to close a file)
  .output stdout
  -- Import data from csv files
  .import "TPOct2Mar.csv" tmpdata1 ;
  .import "EmpLookupTable - Lyndy.csv" tmpdata2 ;
  -- Drop any existing FTEDATA views
  DROP VIEW FTEDATA;
  -- Create the FTEDATA view - Month, Tower, TeamplayID, Category, Hours
  CREATE VIEW FTEDATA AS
  select
    a.mth	as mth
  , b.team as tea
  , b.twr	as twr
  , a.tid	as tid
  , a.atof as atof
  , a.hrs	as hrs
  from tmpdata1 a, tmpdata2 b
  where a.tid = b.tid
  and	b.mth like '%'||a.mth||'%'
  ;
  -- Drop any existing EMPDATA views
  DROP VIEW EMPDATA;
  -- Create the EMPDATA view - month, tower, no of employees
  CREATE VIEW EMPDATA AS
  select
    m as mth
  , g as tea
  , t	as twr
  , count(i) as cnt
  from
  (select distinct mth as m, tea as g, twr as t, tid as i from ftedata
  group by mth, tea, twr, tid)
  group by m, g, t
  ;
  -- Total hours by Month, Tower and Category
  .output atof.csv
  select Team, Tower, Month, Category, (Hours/TotalHours*HeadCount) As DerivedFTE from
  (
  select
    a.tea as Team
  , a.twr as Tower
  , a.mth as Month
  , a.cnt as HeadCount
  , b.atof as Category
  , sum(b.hrs) as Hours
  , (select sum(z.hrs) from ftedata z where a.twr = z.twr and a.mth = z.mth group by z.twr, z.mth) as TotalHours
  from empdata a, ftedata b
  where a.twr = b.twr
  and	a.mth = b.mth
  group by a.tea, a.twr, b.atof, a.mth
  order by a.tea, a.twr, b.atof, a.mth
  )
  ;
  -- Total headcount by Month and Tower
  .output headcount1.csv
  select distinct
    tea as Team
  , twr as Tower
  , sum(case mth when "Oct" then cnt else null end) as Oct
  , sum(case mth when "Nov" then cnt else null end) as Nov
  , sum(case mth when "Dec" then cnt else null end) as Dec
  , sum(case mth when "Jan" then cnt else null end) as Jan
  , sum(case mth when "Feb" then cnt else null end) as Feb
  , sum(case mth when "Mar" then cnt else null end) as Mar
  , sum(case mth when "Apr" then cnt else null end) as Apr
  , sum(case mth when "May" then cnt else null end) as May
  , sum(case mth when "Jun" then cnt else null end) as Jun
  , sum(case mth when "Jul" then cnt else null end) as Jul
  , sum(case mth when "Aug" then cnt else null end) as Aug
  , sum(case mth when "Sep" then cnt else null end) as Sep
  from empdata
  group by tea, twr
  ;
  -- Total headcount by Month and Team
  .output headcount2.csv
  select distinct
    tea as Team
  , sum(case mth when "Oct" then cnt else null end) as Oct
  , sum(case mth when "Nov" then cnt else null end) as Nov
  , sum(case mth when "Dec" then cnt else null end) as Dec
  , sum(case mth when "Jan" then cnt else null end) as Jan
  , sum(case mth when "Feb" then cnt else null end) as Feb
  , sum(case mth when "Mar" then cnt else null end) as Mar
  , sum(case mth when "Apr" then cnt else null end) as Apr
  , sum(case mth when "May" then cnt else null end) as May
  , sum(case mth when "Jun" then cnt else null end) as Jun
  , sum(case mth when "Jul" then cnt else null end) as Jul
  , sum(case mth when "Aug" then cnt else null end) as Aug
  , sum(case mth when "Sep" then cnt else null end) as Sep
  from empdata
  group by tea
  ;
  -- Quit SQLite
  .exit

I checked the contents of my FTEDATA table and there are figures for all teams for all months, however...

This query produces no results for one of the Teams for the month of February only:

  select Team, Tower, Month, Category, (Hours/TotalHours*HeadCount) As DerivedFTE from
  (
  select
    a.tea as Team
  , a.twr as Tower
  , a.mth as Month
  , a.cnt as HeadCount
  , b.atof as Category
  , sum(b.hrs) as Hours
  , (select sum(z.hrs) from ftedata z where a.twr = z.twr and a.mth = z.mth group by z.twr, z.mth) as TotalHours
  from empdata a, ftedata b
  where a.twr = b.twr
  and	a.mth = b.mth
  group by a.tea, a.twr, b.atof, a.mth
  order by a.tea, a.twr, b.atof, a.mth
  )
  ;

When I limit it to only include "Feb" though (see below), magically the figures are produced.

  select Team, Tower, Month, Category, (Hours/TotalHours*HeadCount) As DerivedFTE from
  (
  select
    a.tea as Team
  , a.twr as Tower
  , a.mth as Month
  , a.cnt as HeadCount
  , b.atof as Category
  , sum(b.hrs) as Hours
  , (select sum(z.hrs) from ftedata z where a.twr = z.twr and a.mth = z.mth group by z.twr, z.mth) as TotalHours
  from empdata a, ftedata b
  where a.twr = b.twr
  and	a.mth = "Feb"
  group by a.tea, a.twr, b.atof, a.mth
  order by a.tea, a.twr, b.atof, a.mth
  )
  ;

I have scrutinised the data and there are no errors there.

I originally developed this under 3.5.9 and the behaviour exists in that release. I tried 3.6.10 and it is there also.

2009-Feb-16 04:57:00 by danielk1977:
Thanks for the bug report. Are you able to provide the data used to demonstrate the problem?

You can mail it to "dan AT sqlite.org" if it is too large to attach here or you don't want it to be publicly available.


2009-Feb-18 23:17:42 by anonymous:
Hi Dan, I have emailed you the data as requested for privacy reasons. Good luck and thanks.
 
3657 build closed 2009 Feb anonymous cli 2009 Feb drh 3 3 Broken again: Oracle and MS-sql command terminator logic
The issues as reported in ticket #3544 are still present in release 3.6.10. The purported fix was commited as [6041] and the history for shell.c shows this making it into release 3.6.8 and later: ( http://www.sqlite.org/cvstrac/rlog?f=sqlite%2Fsrc%2Fshell.c&sms=1 ) but the problem remains.

Steps taken to reproduced:

  • standard clean install (download of sqlite-amalgamation-3.6.10.tar.gz; unpack; ./configure & make)
  • And then:

  $ uname -a
  Darwin  8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc
  $
  $ date
  Sun Feb 15 10:19:38 GMT 2009
  $
  $ ./sqlite-amalgamation-3.6.10/sqlite3
  SQLite version 3.6.10
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> select 1
     ...> /
     ...> ;
  SQL error: near ";": syntax error
  sqlite>
  sqlite> /
  Bus error
The 3.6.10 amalgamation tarball contains the wrong version of the "shell.c" source file - it uses the version from release 3.6.5 which was before ticket #3544 was fixed. You can either replace the shell.c source file with a more recent version, or you can wait for the 3.6.11 release.
 
3656 code closed 2009 Feb anonymous   2009 Feb   3 3 Strange behavior on jointure
Hi, I am on kubuntu 8.10 with KDE 4.2 an sqlite 3.5.9.

On attached file (231KB file, I can't attach it but I can send it to you by email, please send me your email),

  SELECT A.id, B.id
    FROM v_operation_tmp1 A, v_operation_tmp1 B
   WHERE A.id<=B.id
     AND A.rc_unit_id=B.rc_unit_id
     AND A.d_date=B.d_date
     AND A.rd_account_id!=B.rd_account_id
     AND A.f_QUANTITY=-B.f_QUANTITY
     AND A.i_group_id=0
     AND B.i_group_id=0
     AND A.f_QUANTITY!=0

returns

id id
3 46
12 47
26 48

It's normal.

But,

  SELECT A.id, B.id
    FROM v_operation_tmp1 A, v_operation_tmp1 B
   WHERE A.id<B.id
     AND A.rc_unit_id=B.rc_unit_id
     AND A.d_date=B.d_date
     AND A.rd_account_id!=B.rd_account_id
     AND A.f_QUANTITY=-B.f_QUANTITY
     AND A.i_group_id=0
     AND B.i_group_id=0
     AND A.f_QUANTITY!=0

returns

id id

Why ? The result expected is the same than for first query.

Regards, Stephane

PS: Sorry if this incident has been already opened but I didn't find it.

Fixed by [5341] of version 3.6.0.
 
3655 new closed 2009 Feb anonymous   2009 Feb   5 3 Add month() and year() functions
/*
**    month( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-01
*/
static void monthFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  DateTime x;
  if( isDate(context, argc, argv, &x)==0 ){
    char zBuf[100];
    computeYMD(&x);
    sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-01", x.Y, x.M);
    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
  }
}

/*
**    year( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-01-01
*/
static void yearFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  DateTime x;
  if( isDate(context, argc, argv, &x)==0 ){
    char zBuf[100];
    computeYMD(&x);
    sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-01-01", x.Y);
    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
  }
}

Use:

    date(TIMESTRING,'start of month');
    date(TIMESTRING,'start of year');
 
3654 doc closed 2009 Feb anonymous   2009 Oct   4 4 INSTALL doc should mention libreadline5-dev
The INSTALL document should mention that libreadline5-dev needs to be installed before running configure. The readline library is what provides the command line editing and recall.
 
3653 secure closed 2009 Feb anonymous   2009 Feb   1 1 how to register
To whom it may concerns,

Sorry for disturbing you with this message

Would you be so kind to help me to register at http://www.sqlite.org/cvstrac/wiki site

I have no idea where to move from login page and how to get a profile.

Thank you in advance.

2009-Feb-14 09:15:48 by danielk1977:
You don't need to register anywhere to use the wiki. Feel free to browse the content, and if you want to modify a wiki page go ahead and do so by clicking the "Edit" link. No login is required. Logins are only required for people who want to commit modifications to the sqlite source code to cvs.
 
3652 new closed 2009 Feb anonymous   2009 Oct   5 4 possible future compability problem
  sqlite> create table t(a);
  sqlite> .schema
  CREATE TABLE t(a);

could be changed to:

  sqlite> create table t(a);
  sqlite> .schema
  CREATE TABLE `t`(`a`);

This way adding new keywords to sqlite wouldn't cause compability problems.

2009-Oct-13 06:08:29 by anonymous:
The shell gets it right when you use names. For example create a table named table and you'll see. Please continue discussion on the sqlite-users mailing list as this tracker and ticket are now closed.
 
3651 code fixed 2009 Feb drh front 2009 Feb drh 3 1 Assertion fault on ALTER TABLE ADD COLUMN
The following SQL gives an assertion fault:

   CREATE TABLE t1(y UNIQUE);
   ALTER TABLE t1 ADD COLUMN z UNIQUE;

The ALTER TABLE statement appears to work correctly (returning an error "Cannot add a UNIQUE column") if asserts are disabled.

 
3650 doc active 2009 Feb anonymous   2009 Feb   4 3 documentation error in c3ref/changes.html
lang_delete.html says: Prior to SQLite version 3.6.5, the truncate optimization also meant that the sqlite3_changes() and sqlite3_total_changes() interfaces and the count_changes pragma will not actually return the number of deleted rows. That problem has been fixed as of version 3.6.5.

However c3ref/changes.html was not updated with this new fix: ... Because of this optimization, the deletions in "DELETE FROM table" are not row changes and will not be counted by the sqlite3_changes() or sqlite3_total_changes() functions, regardless of the number of elements that were originally in the table.

 
3649 xplatform closed 2009 Feb anonymous cli 2009 Oct   2 3 sqlite3 hangs in Cygwin rxvt bash shell window
Running sqlite3.exe in a Cygwin rxvt window with a bash shell hangs. No prompt appears. Running sqlite3.exe from cmd.exe or bog standard Cygwin console window with bash shell works.
2009-Oct-12 21:11:36 by anonymous:
If you can point to the fault being in sqlite then please post to sqlite-users.
 
3648 code fixed 2009 Feb drh back 2009 Feb   1 1 DB page written that was not synced to the journal
An assert() failed in test_journal.c just after the test perm-journaltest.backkup_ioerr-2.1567.56 when compiled with -DSQLITE_DEFAULT_AUTOVACUUM=1.

The purpose of this ticket is to make a record of the problem. The problem has already been fixed. The following explanation is from Dan:

So here is what is happening in the failing test case:

  1. Page X of the database file is journalled.

  2. At attempt is made to sync the journal file (a "sync journal" of course, usually consists of the sequence xSync(), xWrite(nRec), xSync()). The first xSync() in this sequence is failing.

  3. Since an IO error occured, an automatic rollback is attempted.

The automatic rollback in step 3 rolls back the entire journal file, including the unsynced portion. This is necessary to restore any modified cache pages. When it gets to page X (in the unsynced portion of the journal file), pager_playback_one_page() determines that the data from page X needs to be copied from the journal file into the database file. Since the portion of the journal-file was not successfully synced, assert() statements in test_journal.c consider this to be an error.

The test being used pager_playback_one_page() to determine if data should be written to the database file is:

  pPg = pager_lookup(pPager, pgno);
  if( (pPager->state>=PAGER_EXCLUSIVE)
   && (pPg==0 || 0==(pPg->flags&PGHDR_NEED_SYNC))
  ){
    // Write to the database file.
  }

The second part of the test (pPg==0 || 0==(pPg->flags&PGHDR_NEED_SYNC) is supposed to test if the journal has been synced since page pPg was written to it. This is the case if either the PGHDR_NEED_SYNC flag is clear on the page, or if the page is no longer in the in-memory cache, since the only way for a dirty page to be purged from the cache is to be written to the database file. If it was written to the database file, then the journal file must have been synced first.

This test case finds an exception to this reasoning: If the page was made dirty, then moved to another location in the database file as part of an auto-vacuum commit (passed to sqlite3PagerMovepage() with the isCommit parameter set to true), then it will not be present in the cache but the portion of the journal file it was journalled in may not have been synced.

This cannot happen as part of an incremental-vacuum operation. When doing an incremental vacuum if a page with the NEED_SYNC flag is passed to sqlite3PagerMovepage() a new page is loaded into the cache to take its place.

Since this situation can only come about when doing an auto-vacuum commit, the only type of rollback that can occur is an automatic rollback caused by an IO or malloc error. Specifically, a SAVEPOINT rollback cannot occur at this point. Since SQLite must be rolling back from the main-journal for the problem to occur, it knows that it is rolling back from the unsynced portion of the journal file (from the nRec==0 header). So it can just pass an extra flag to pager_playback_one_page() in this case - "isUnsync". If isUnsync is true, then pager_playback_one_page() does not write to the database file.

 
3647 new active 2009 Feb anonymous front 2009 Feb   4 3 parsing natural join over more than 2 tables is too inefficient
  select * from a natural join b natural join c

takes "forever"

  select * from a natural join (b natural join c)

takes appropriate time

It would be nice if the SQL parser would be clever enough to find the corresponding tables more efficiently. I think the need for brackets is annoying.

This also affects SQL-code-portability because other RDBMS handle the bracket-free code nicely.

 
3646 code closed 2009 Feb anonymous front 2009 Feb danielk1977 1 1 can not insert data to table which has field name with space
Execute following sql: Create Table [a] ([a b]); Insert Into [a] ([a b]) Values("a");

sqlite will report "table a has no column named a b" error

2009-Feb-11 11:53:24 by danielk1977:
It works here:

  $ sqlite3
  SQLite version 3.6.10
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> Create Table [a] ([a b]);
  sqlite> Insert Into [a] ([a b]) Values("a");
  sqlite>

It could be that some of your whitespace characters are not simple spaces (0x20).

 
3645 build closed 2009 Feb anonymous build 2009 Oct   1 1 SQLite 3.6.10 build process is broken on Solaris 10 (again)
I've tried both the amalgamation build and the lots-of-source-files one. I'm using gcc (3.4.3, which ships with Solaris 10). Both fail at link time with a message about "false cru".

In the amalgamation build I have no idea how to even pass the options that used to to work to tell it where things like readline libraries live.

3.6.4 was the last one I built successfully. Every new version seems to include its own exciting set of weirdness in the build process.

2009-Feb-10 17:14:58 by danielk1977:
Maybe it's this problem:

  http://mail.gnome.org/archives/gtk-list/2003-December/msg00066.html

Possibly try:

  $ AR=`which ar` ./configure && make


2009-Oct-15 20:40:29 by anonymous:
Please continue discussion on the sqlite-users mailing list as this ticket and tracker are now closed.
 
3644 code closed 2009 Feb anonymous vfs 2009 Oct   1 1 WinCE: Can't delete files on storage cards when running in Emulator
I use SQLite 3.6.16 on Windows Mobile. While the program runs fine on a real PDA, SQLite reports an IOERR when run on an Windows Mobile Emulator. One thing to mention here is the fact, that the DB file is located on an external storage card.

Debugging the problem lead me to the following in winDelete in /sqlite/src/os_win.c when SQLite tries to delete a journal file:

  1. The journal file gets deleted via DeleteFileW
  2. In order to make sure the file has vanished, SQLite checks with GetFileAttributesW if it is still there.
  3. If the file is gone INVALID_FILE_ATTRIBUTES is returned which results in checking for error via GetLastError

Now we have what I call a typical Microsoft problem:

  • For a real device, GetLastError returns ERROR_FILE_NOT_FOUND as expected
  • For the Emulator with Windows Mobile 6.0 or above (not tested older versions), GetLastError returns
    • ERROR_FILE_NOT_FOUND if the file is located on the device storage
    • the value, that has been last set using SetLastError if the file is located on an emulated storage card

Giving it a second try (I posted this beginning of februrary 2009) I included a patch file that fixes this for revision 1.156 of /sqlite/src/os_win.c I hope it makes it into the code base this time...

Tilman

2009-Oct-20 06:48:19 by anonymous:
This tracker and hence ticket are now closed. If this is still an issue then please continue discussion on the sqlite-users mailing list where other developers can help find a solution.
 
3643 code closed 2009 Feb anonymous front 2009 Feb   2 3 sqlite_bind_parameter_name() failure
I suspect there is a bug in sqlite3_bind_parameter_name routine.

  SELECT @a, @b;
got:
  sqlite3_bind_parameter_name(s, 1) == "@a"
  sqlite3_bind_parameter_name(s, 2) == "@b"
correct.

  SELECT NULL FROM (SELECT NULL) WHERE @a = @b;
got:
  sqlite3_bind_parameter_name(s, 1) == "@a"
  sqlite3_bind_parameter_name(s, 2) == "@b"
correct.

  SELECT @a FROM (SELECT NULL) WHERE 1 = @b;
got:
  sqlite3_bind_parameter_name(s, 1) == NULL
  sqlite3_bind_parameter_name(s, 2) == "@b"
incorrect.

  SELECT @a, @b FROM (SELECT NULL);
got:
  sqlite3_bind_parameter_name(s, 1) == NULL
  sqlite3_bind_parameter_name(s, 2) == NULL
incorrect.

Every one of these returns 2 on sqlite3_bind_parameter_count(s), so the parameters must be there, but I cannot reliably tell which one is which, so I cannot really bind the values. Of course I simplified these queries as I could, so the problem is not so bad here. In the production query, however, the "no-name" parameters are part of CASE WHEN condition and absence of their bindings is catastrophic.

Changed severity to 2, because I just figured out a nasty workaround. To transform a buggy query

  SELECT @a FROM (SELECT NULL) WHERE 1 = @b

to a correct query, I have to add a superfluous condition like this:

  SELECT @a FROM (SELECT NULL) WHERE 1 = @b AND @a = @a;


2009-Feb-09 05:22:19 by danielk1977:
So far I cannot reproduce this problem with either the cvs head or version 3.5.9. What version are you using?

Can you supply a self-contained C program that demonstrates the problem?

Thanks.


OP: I am using 3.6.10. I just tried to make a simple C test program and found out that it really works. So the problem must be in my wrapper. I am sorry to waste your time.
 
3642 code closed 2009 Feb anonymous vfs 2009 Feb danielk1977 2 3 Journal recovery fails when fcntl stub macro is enabled
In the os_unix.c file when the macro that effectively nils out the fcntl function call is enabled (SQLITE_NO_FCNTL), journal fault recovery fails. This is because the code that calls fcntl first sets l_type and then checks to see if it changes (around line 1160) which of course it will not. The workaround was to also use the SQLITE_NO_FCNTL macro to conditionally compile the line that sets r to 1.
2009-Feb-09 05:34:29 by danielk1977:
Commit [6268] changes os_unix.c to ignore the results of all fcntl() calls if __DJGPP__ is defined.

There is also the "unix-none" VFS. It could be that programs compiled using djgpp should use this by default.

Marking this as "uncommon" instead of "universal" because, although it is a universal program for djgpp applications, djgpp is itself quite uncommon in 2009.

 
3641 code fixed 2009 Feb anonymous   2009 Feb   4 3 group_concat(distinct [field], 'separator') fails
select group_concat(name, 'xxx') from artists;

works ok.

select group_concat(distinct name) from artists;

works ok.

select group_concat(distinct name, 'xxx') from artists;

fails with:

SQL error: DISTINCT in aggregate must be followed by an expression

The error message has been reworded to give a better clue about what is going wrong.
 
3640 code fixed 2009 Feb shane vfs 2009 Feb shane 1 1 winTruncate() in os_win.c not detecting errors correctly.
In winTruncate(), in os_win.c, SetFilePointer() returns the new file pointer, or -1 (INVALID_SET_FILE_POINTER) on error. For 64-bit values, it returns the lower 32-bits off the new file pointer, and sets the upperBits parameter (passed in) to the upper 32-bits, thus -1 can be a valid return value. If -1 returns, you must also check GetLastError() to see if an error occured (NO_ERROR means success).
 
3639 new active 2009 Feb anonymous vfs 2009 Feb   3 1 Syntax error doesn't report a line number
When an attempt is made to import a SQL file containing 8226 INSERT statements, the following error is reported:

  SQL error: near "/": syntax error

A manual check that sqlite is prepared to accept the first INSERT statement works, which means the error is anywhere between lines 2 to 8226.

The error message gives no indication of the line number the error is on in the sql file, and so it is very difficult to debug which INSERT statement is generating the error or why.

2009-Feb-05 00:29:24 by anonymous:
As a suggestion, the GNU error reporting format can be used. It is

  filename:linenumber:columnnumber: text

filename doesn't make too much sense in this context.

 
3638 code closed 2009 Feb anonymous   2009 Feb   1 1 sqlite command line gets stuck if \q is entered, ctl-c ignored
If, at the sqlite command line, you enter the postgres quit command "\q" by accident, the sqlite command line hangs. Ctl-C is ignored, and there is no obvious way to exit sqlite apart from killing the process:

  sqlite> \q
   ...> .quit
   ...>
   ...>
   ...> .quit
   ...> \
   ...> "
   ...>
   ...>
   ...>
   ...>
   ...>
   ...> qut
   ...> quit
   ...> .q
   ...>
   ...> .exit
   ...> q
   ...> Terminated
2009-Feb-04 17:15:28 by drh:
It thinks you are typing SQL and is waiting for a ";". You can either type CTRL-D or type ";" and then ".quit".

CTRL-C merely interrupts the SQL statement currently in progress. It does not shut down the CLI.

 
3637 code closed 2009 Feb anonymous   2009 Feb   1 1 segmentation fail ossurs then execute create table on arm
after compile sqlite for arm processor, os debian, segmentation fail occurs then execute create table script.
2009-Feb-04 15:20:51 by drh:
Thanks for taking the time to fill out a bug report. User feedback is very important to us and were are eager to fix all problems that come up in SQLite.

Nevertheless, this bug report is completely useless.

Please follow some of the links at http://www.google.com/search?q=how+to+write+a+good+bug+report and study what you find. After that, if you are still having problems, resubmit a new bug report and we will be happy to look into the matter. Thanks!

 
3636 code closed 2009 Feb danielk1977 back 2009 Feb danielk1977 1 1 Statement/savepoint transaction related crash with journal_mode=off
When running in journal_mode=off mode, any time a page would normally need to be written into the sub-journal, a crash occurs. For example this script:

    PRAGMA journal_mode = off;
    BEGIN;
      CREATE TABLE t1(a PRIMARY KEY, b);
      INSERT INTO t1 VALUES(1, 2);
    COMMIT;
    BEGIN;
      INSERT INTO t1 VALUES(3, 4);
      SAVEPOINT s1;
        INSERT INTO t1 VALUES(5, 6);

Or, more likely:

    PRAGMA journal_mode = off;
    BEGIN;
      CREATE TABLE t1(a PRIMARY KEY, b);
      INSERT INTO t1 VALUES(1, 2);
    COMMIT;
    BEGIN;
      INSERT INTO t1 VALUES(2, 4);
      INSERT INTO t1 SELECT a+2, (a+2)*2 FROM t1;
    COMMIT;

This bug was introduced as part of the savepoint feature. Version 3.6.7 did not exhibit the problem.

Bug was reported on the mailing list. User encountered it because they were using triggers (which open and use a sub-transaction).

 
3635 build closed 2009 Feb anonymous build 2009 Oct   4 4 configure should define SQLITE_ENABLE_COLUMN_METADATA by default
Checkin [5539] enabled SQLITE_ENABLE_COLUMN_METADATA by default if using the various SQLite custom build scripts and Makefiles. To match that configure should also be defining it by default, with the option to disable.

This will ensure that no matter what build system is used, the resulting binaries, symbols and functionality will be substantially similar.

 
3634 new closed 2009 Feb anonymous   2009 Oct   3 4 imputed column type of functions is not set
Sqlite does not impute the column type when the column is the output of a function (even a built-in function):

  [sfriedman@zeph sqlite-build]$ ./sqlite3
  SQLite version 3.6.10
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table test (col1 integer);
  sqlite> insert into test values ("1");
  sqlite> create table test2 as select col1, sum(col1) as sumcol from test;
  sqlite> .schema test2
  CREATE TABLE test2(col1 integer,sumcol);

What is expected is:

  CREATE TABLE test2(col1 integer,sumcol integer);

since sum (or min, max, etc) return integers. This is a problem when operating on these columns. Sqlite can correctly infer the column type when the simple column is selected, so it should be able to do it for the built-in functions.

2009-Feb-04 09:34:45 by anonymous:
Do you realize this from http://www.sqlite.org/different.html ? : "SQLite ... [uses] manifest typing. In manifest typing, the datatype is a property of the value itself, not of the column in which the value is stored. SQLite thus allows the user to store any value of any datatype into any column regardless of the declared type of that column." HTH, TC


2009-Oct-15 21:41:31 by anonymous:
There is an earlier closed ticket about this. In summary that is the way it is and could only be resolved through considerably added complexity.
 
3633 code fixed 2009 Feb drh vfs 2009 Feb   3 1 Unchecked return value from write()
From the mailing list:

When building sqlite 3.6.10 amalgamation, I get
a warning message saying:

attention : ignoring return value of ‘write’, declared with attribute warn_unused_result

This is on a small piece of code related to ticket
#3260, according to the source documentation. (See
the code below.)

I know this is not a problem, but I would like to
remove this warning since it's not important for
the rest of the code. What could I do?

Thanks,
Maurício

  /* On OS X on an msdos filesystem, the inode number is reported
  ** incorrectly for zero-size files.  See ticket #3260.  To work
  ** around this problem (we consider it a bug in OS X, not SQLite)
  ** we always increase the file size to 1 by writing a single byte
  ** prior to accessing the inode number.  The one byte written is
  ** an ASCII 'S' character which also happens to be the first byte
  ** in the header of every SQLite database.  In this way, if there
  ** is a race condition such that another thread has already populated
  ** the first page of the database, no damage is done.
  */
  if( statbuf.st_size==0 ){
    write(fd, "S", 1);
    rc = fstat(fd, &statbuf);
    if( rc!=0 ){
      pFile->lastErrno = errno;
      return SQLITE_IOERR;
    }
  }
 
3632 event closed 2009 Feb anonymous back 2009 Feb   1 2 Temporary tables are bound on reconnection
The problem is very simple to test:

  1- Open DB
  2- Do:
  drop table prev_agenda;
  create temp table if not exists prev_agenda (intuser_id integer, introl_id integer, logactive integer, tslast_modif datetime, primary key (intuser_id, introl_id,logactive));
  3- Close DB

  4- Open DB
  5- delete from prev_agenda (some times crash with no table found, but most of the times says OK and the table persists)
  6- Close DB
2009-Feb-03 11:04:36 by danielk1977:
Temporary tables (those created by "CREATE TEMP TABLE") are always discarded when the database connection is closed. If you find otherwise it is a bug.

Are you using a custom VFS layer?

Im not using an VFS.

If not, what operating system are you using?

Im using Windows 2003 Enterprise Edition 32bit.

Can you post code that demonstrates the problem?

Im using the DotNet driver under C# (Its an ASP.NET interface to the sqlite engine). Should I send you a sample code?

Driver info: ADO.NET 2.0/3.5 SQLite Data Provider Version 1.0.60.0 October 3, 2008 Using SQLite 3.6.3 Written by Robert Simpson (robert@blackcastlesoft.com) Released to the public domain, use at your own risk! Official provider website: http://sqlite.phxsoftware.com


2009-Feb-09 11:59:24 by danielk1977:
The wrapper could be doing some kind of "connection pooling" to reuse existing database connections. Suggest finding out from the provider if the connection really is being closed when you think it is, or if it is being kept alive for possible reuse later.


2009-Feb-10 18:50:00 by mlucas@voxelgroup.net:
That was the problem, the connection pooling. It was active making strange temp table drops.

Thank you very much.

 
3631 build fixed 2009 Feb anonymous vfs 2009 Feb   4 3 sqlite3OsDlSym not marked private
The sqlite3OsDlSym symbol was not marked as private. Prefixing with SQLITE_PRIVATE fixes it.

It would be really nice if you had this done as an automated test (which I how I come across them periodically).

This is the compile rule:

  gcc -DSQLITE_API=static -DSQLITE_EXTERN=static -c sqlite3.c

And this is the Makefile rule that fails when any symbols are public that shouldn't be:

  set +e; nm --extern-only --defined-only sqlite3.oo | egrep -v ' (__bss_start|_edata|_end|_fini|_init)$$' ; test $$? -eq 1 || false
 
3630 code fixed 2009 Feb anonymous front 2009 Feb   2 4 ALTER TEMP TABLE
alter.c does not take into account the word "TEMP" in a schema when attempting to add a column to a temporary table. For example:


create table x(a);
insert into x values(1);
create temp table y as select * from x;
alter table y add column b;
SQL error: malformed database schema (y) - near "TABL": syntax error


sqlite> select * from sqlite_temp_master;
type|name|tbl_name|rootpage|sql
table|y|y|2|CREATE TEMP TABLE y(a)
sqlite> select * from sqlite_master;
type|name|tbl_name|rootpage|sql
table|x|x|2|CREATE TABLE x(a)

More specifically, line 1643 of build.c has a hardcoded offset of 13:

p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName);

 
3629 doc active 2009 Feb anonymous front 2009 Feb   4 4 No error when selecting inappropriate columns when grouping.
Selecting a column not mentioned in a group by clause causes the column to be returned in an otherwise correct result set with what appears to be an existing but randomly selected value for that column. Here is an example:

  create table dogs(name varchar2(20) primary key, breed varchar2(20));

  insert into dogs values('Poo', 'Dandie');
  insert into dogs values('Dinmo', 'Dandie');
  insert into dogs values('Robby', 'Scotty');
  insert into dogs values('Laddy', 'Scotty');
  insert into dogs values('Craigy', 'Scotty');
  insert into dogs values('Chuy', 'Chihuahua');

  commit;

Works as expected on both Oracle and SQLite:

  select breed, count(*)
  from dogs
  group by breed;

  BREED                  COUNT(*)
  -------------------- ----------
  Dandie                        2
  Scotty                        3
  Chihuahua                     1

This one gets an error on Oracle and a result on SQLite:

  select breed, count(*), name
  from  dogs
  group by breed;
  -- Oracle:
  ERROR at line 1:
  ORA-00979: not a GROUP BY expression

SQLite:

  breed		count(*) 	name
  --------------------------------------------
  Chihuahua	1		Chuy
  Dandie		2		Dinmo
  Scotty		3		Craigy

I think the right result is an error.

2009-Feb-02 16:55:01 by anonymous:
My apologies for the way the query results appear. Trying again:

-- Works as expected on both Oracle and SQLite. select breed, count(*) from dogs group by breed;

BREED COUNT(*)
Dandie 2
Scotty 3
Chihuahua 1

select breed, count(*), name from dogs group by breed;

Results in an error on Oracle, and this output on SQlite:

breed count(*) name
Chihuahua 1 Chuy
Dandie 2 Dinmo
Scotty 3 Craigy

I hope that makes things clearer... Karl


2009-Feb-02 16:58:18 by drh:
This question comes up from time to time. Most other database engines do throw an error if a column appears in the result set of an aggregate query which is not a GROUP BY column. But some people prefer that this not be an error, because by not throwing an error they can get results that are distinct on some subset of columns in the result set:

   SELECT a, b, c, d FROM t1 GROUP BY a, b;

The result set will have distinct values for the a and b column. The c and d columns values will be selected arbitrarily from among those with the same a and b values.

I will change this to a "documentation" error so that we will remember to add the rationale for the way this works in the documentation.


2009-Feb-02 17:10:57 by anonymous:
I work with Karl and stumbled on this by entering an incorrect query, and I suspect most people do not expect arbitrary values from the group to be picked up, so returning on error would be the best behavior IMHO.

When one really wants to pick up an arbitrary value, maybe they should be offered an arbitrary_value_from_group() aggregate function ;-) That way we could get the least surprising outcome (an error) when lacking the aggregate function, but you'd still be able to replicate the old behavior by using the function above. --DD

PS: or any other pseudo aggregate functions like first(), second(), last(), etc...


2009-Feb-03 08:44:48 by anonymous:
For me problem with this query is the "will be selected arbitrarily" part. I think database behaviour should be deterministic, and this query isn't. I guess it would be fine if there was some documented rule for chosing additional columns (for example max or min value).
 
3628 code fixed 2009 Feb drh func 2009 Feb   3 1 SUBSTR off-by-one when 2nd argument is 0
We have this:

   SELECT substr('12345', 2, 2)   ->  23
   SELECT substr('12345', 1, 2)   ->  12

So we would expect:

   SELECT substr('12345', 0, 2)   ->  1

But instead, a 2nd argument of 0 is treated like a 1:

   SELECT substr('12345', 0, 2)   ->  12

So a 2nd argument of 0 is an exception to the rule - a discontinuity in the behavior. This should be fixed. FWIW, PostgreSQL does not have this discontinuity.

 
3627 code fixed 2009 Feb drh func 2009 Feb   5 1 The RANDOM() function accepts parameters without giving an error.
The documentation says that random() takes no arguments. But you can give it arguments which it then ignores. It should throw an error if you give it arguments.
 
3626 code fixed 2009 Feb drh func 2009 Feb   3 1 SUBSTR returns non-NULL when 2nd or 3rd argument are NULL
For compatibility with other SQL functions, the SUBSTR() function should probably return a NULL if any of its arguments are NULL. It currently does so only if the first argument is NULL. A NULL in the 2nd or 3rd argument is interpreted as a zero.
 
3625 new fixed 2009 Feb drh func 2009 Feb   4 1 Negative value to 3rd argument of SUBSTR() gives strange answer
When the 3rd argument to SUBSTR is negative, the SUBSTR() function works as if the 3rd argument were omitted - it returns the tail of the string. This behavior is both undocumented and unexpected.

A more sensible interpretation of a negative 3rd parameters would be to return the characters before the character indicated by the 2nd parameter. For example:

    SUBSTR('abcdefghijklm', 5, -2)  ->  'cd'

FWIW, PostgreSQL gives an error if the 3rd parameter is negative.

 
3624 code fixed 2009 Feb drh func 2009 Feb   4 1 REPLACE() returns NULL when the second argument is an empty string
A more reasonable answer would be to return a copy of the first argument when the second argument is an empty string. REPLACE() should only return NULL if one or more of its arguments are NULL.
 
3623 code fixed 2009 Jan drh front 2009 Jan   5 1 Misleading error message with coalesce() function
The error message from using the COALESCE() function with 0 or 1 arguments is "no such function" rather than "wrong number of arguments".
 
3622 build fixed 2009 Jan anonymous   2009 Feb   3 1 ROLLBACK TO syntax error when compiled with SQLITE_OMIT_ALTERTABLE
When compiled with SQLITE_OMIT_ALTERTABLE, any "ROLLBACK TO" SQL quits with an unknown keyword error at "TO".

All works well when this line in mkkeywordhash.c

  { "TO",               "TK_TO",           ALTER                  },

is promoted to

  { "TO",               "TK_TO",           ALWAYS                 },

so that the "TO" keyword is always compiled in.

 
3621 xplatform fixed 2009 Jan anonymous test 2009 Feb   4 3 patch to fix sqlite3_mprintf_int in src/test1.c (fails on big-endian)
Running the test suite on sparc64 (and probably other big-endian arches) results in one failing test:

  ...
  printf-8.2...
  Expected: [2147483647 2147483648 4294967295]
       Got: [2147483647 18446744071562067968 18446744073709551615]
  ...

The following patch fixes it by explicitly using an unsigned int in the sqlite3_mprintf_int function:

  --- src/test1.c.orig    Sat Jan 31 16:07:27 2009
  +++ src/test1.c Sat Jan 31 16:18:33 2009
  @@ -1199,7 +1199,7 @@ static int sqlite3_mprintf_int(
     int argc,              /* Number of arguments */
     char **argv            /* Text of each argument */
   ){
  -  int a[3], i;
  +  unsigned int a[3], i;
     char *z;
     if( argc!=5 ){
       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
 
3620 code closed 2009 Jan danielk1977 back 2009 Jan danielk1977 1 1 Running vacuum on an in-memory database may cause a segfault.
Running 'VACUUM' on an in-memory database causes a segfault if the final number of database pages is less than the number of pages before the vacuum. The following script is enough:

  CREATE TABLE t1(a, b);
  DROP TABLE t1;
  VACUUM;

Marking this as 'Rare', because running VACUUM on an in-memory database is not particularly useful.

 
3619 doc fixed 2009 Jan anonymous back 2009 Feb   4 4 obsolete MakeIdxRec opcode references in vdbe.c
Please update the obsolete opcode MakeIdxRec references in vdbe.c comments

@4025

  /* Opcode: IdxInsert P1 P2 P3 * *
  **
  ** Register P2 holds a SQL index key made using the
  ** MakeIdxRec instructions.  This opcode writes that key

@4089

  /* Opcode: IdxRowid P1 P2 * * *
  <SNIP>
  ** See also: Rowid, MakeIdxRec.
 
3618 code fixed 2009 Jan anonymous func 2009 Jan   2 4 julianday math/rounding issue
I was using version 3.6.1 and was looking at upgrading to 3.6.10

I found this issue:

  select julianday('2009-01-01') returns 2454832.5

  select julianday('2009-01-02','-1 days') returns 2454832.50000001

this causes a test like julianday(d1)=julianday(d2,'-1 days') to be false, whereas version 3.6.1 returns exactly 2454832.5 for the '-1 days' case and the test is true.

I can work around this by passing each julianday()result to date() or datetime() first, but it seems like a simple case like -1 days should be able to return an exact value.

I am on windows using the distribution dlls.

2009-Jan-30 17:39:49 by drh:
This problem was introduced by check-in [5997] . The sole purpose of check-in [5997] was to remove compiler warnings. So here is an example where removing compiler warnings introduced a new defect without fixing any prior defects.
 
3617 doc closed 2009 Jan anonymous   2009 Oct   3 3 Documentation does not discuss PRAGMA collation_list
I may be overlooking it, but I do not think <http://www.sqlite.org/pragma.html#syntax> discusses the command "PRAGMA collation_list;"
2009-Oct-13 06:09:17 by anonymous:
It does now.
 
3616 code fixed 2009 Jan shane   2009 Jan shane 4 4 Lookaside still enabled even if configured buffer size is 0.
If lookaside is configured with a zero size buffer, it is still enabled, and a zero-byte buffer allocated for it.
It functions correctly as is, but setting it to disabled would result in very small performance improvement.
 
3615 code fixed 2009 Jan shane   2009 Jan shane 4 4 filectrl-1.4 test case is failing on Windows.
The filectrl-1.4 error is because of an unsupported (and non-critical) feature of the xFileControl method in the os_win.c implementation.
 
3614 code fixed 2009 Jan shane   2009 Jan shane 4 4 incrvacuum-15.1 test case failing on Windows
incrvacuum-15.1 test case failing on Windows. test.db can not be deleted because there is still an open handle on the file (db2).
This is an issue with the test script only, and not with the SQLite core code.
 
3613 code closed 2009 Jan anonymous   2009 Mar   1 1 core with BUS_ADRALN on HPUX on IA64 Platform
The source code from sqlite-amalgamation-3.6.10 compiled with HP's aCC on HP-UX B.11.31 U ia64 dumps core on sample "create database" command:

Core was generated by `sqlite3'. Program terminated with signal 10, Bus error. BUS_ADRALN - Invalid address alignment #0 0x60000000ca8d40e0:0 in exprAnalyze (pSrc=0x4003d9e0, pWC=0x4004335c, idxTerm=0) at sqlite3.c:80493

The same code compiled on HP-UX B.11.23 U 9000/800 PARISC (32bit) runs ok.

The suspicious warnings from compiler and full backtrace will be attached. I can provide additional info or make tests when needed.

2009-Mar-20 09:42:44 by anonymous:
I'm seeing precisely this problem on two systems, Solaris 2.7 and HP-UX 11.23.

For the solaris system:

bash-2.05$ uname -a
SunOS sunspot 5.7 Generic_106541-28 sun4u sparc SUNW,Ultra-250 Solaris

bash-2.05$ gdb ../../build/progs/sqlite --core=core
GNU gdb 4.18
Copyright 1998 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 "sparc-sun-solaris2.7"...
Core was generated by `../../build/progs/sqlite test.db.new'.
Program terminated with signal 10, Bus Error.
Reading symbols from /usr/lib/libgen.so.1...done.
Reading symbols from /usr/lib/libaio.so.1...done.
Reading symbols from /usr/lib/libsocket.so.1...done.
Reading symbols from /usr/lib/libnsl.so.1...done.
Reading symbols from /usr/lib/libc.so.1...done.
Reading symbols from /usr/lib/libdl.so.1...done.
Reading symbols from /usr/lib/libmp.so.2...done.
Reading symbols from /usr/platform/SUNW,Ultra-250/lib/libc_psr.so.1...done.
#0  0x55f84 in exprAnalyze (pSrc=0xab4e0, pWC=0xadcac, idxTerm=0)
    at ../../src/sqlite-3.6.11/src/where.c:1034
1034        pTerm->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight);
(gdb) bt
#0  0x55f84 in exprAnalyze (pSrc=0xab4e0, pWC=0xadcac, idxTerm=0)
    at ../../src/sqlite-3.6.11/src/where.c:1034
#1  0x5576c in exprAnalyzeAll (pTabList=0xab4e0, pWC=0xadcac)
    at ../../src/sqlite-3.6.11/src/where.c:602
#2  0x58b10 in sqlite3WhereBegin (pParse=0xffbedbf8, pTabList=0xab4e0, pWhere=0xaadf8, ppOrderBy=0x0,
    wctrlFlags=4 '\004', regRowSet=0) at ../../src/sqlite-3.6.11/src/where.c:3038
#3  0x4c208 in sqlite3Update (pParse=0xffbedbf8, pTabList=0xab4e0, pChanges=0xab340, pWhere=0xaadf8,
    onError=99) at ../../src/sqlite-3.6.11/src/update.c:348
#4  0x6a01c in yy_reduce (yypParser=0xad5e8, yyruleno=167) at parse.y:642
#5  0x6b0ec in sqlite3Parser (yyp=0xad5e8, yymajor=1, yyminor=Cannot access memory at address 0x1.
) at parse.c:3524
#6  0x49b00 in sqlite3RunParser (pParse=0xffbedbf8,
    zSql=0xad4e0 "UPDATE 'main'.sqlite_master SET type='table', name='files', tbl_name='files', rootpage=#2, sql='CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, m"..., pzErrMsg=0xffbed85c) at ../../src/sqlite-3.6.11/src/tokenize.c:454
#7  0x26510 in sqlite3NestedParse (pParse=0xffbedbf8,
    zFormat=0xad4e0 "UPDATE 'main'.sqlite_master SET type='table', name='files', tbl_name='files', rootpage=#2, sql='CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, m"...) at ../../src/sqlite-3.6.11/src/build.c:251
#8  0x28410 in sqlite3EndTable (pParse=0xffbedbf8, pCons=0xabd08, pEnd=0xabd18, pSelect=0x0)
    at ../../src/sqlite-3.6.11/src/build.c:1578
#9  0x697a0 in yy_reduce (yypParser=0xabca8, yyruleno=31) at parse.y:148
#10 0x6b0ec in sqlite3Parser (yyp=0xabca8, yymajor=1, yyminor=Cannot access memory at address 0x1.
) at parse.c:3524
#11 0x49a88 in sqlite3RunParser (pParse=0xffbedbf8,
    zSql=0x9cc70 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);", pzErrMsg=0xffbedbf4)
    at ../../src/sqlite-3.6.11/src/tokenize.c:442
#12 0x3f750 in sqlite3Prepare (db=0x9cd10,
    zSql=0x9cc70 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);", nBytes=-1, saveSqlFlag=0, ppStmt=0xffbedf04,
    pzTail=0xffbedf00) at ../../src/sqlite-3.6.11/src/prepare.c:578
#13 0x3fa78 in sqlite3LockAndPrepare (db=0x9cd10,
    zSql=0x9cc70 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);", nBytes=-1, saveSqlFlag=0, ppStmt=0xffbedf04,
    pzTail=0xffbedf00) at ../../src/sqlite-3.6.11/src/prepare.c:659
#14 0x3fb34 in sqlite3_prepare (db=0x9cd10,
    zSql=0x9cc70 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);", nBytes=-1, ppStmt=0xffbedf04, pzTail=0xffbedf00)
    at ../../src/sqlite-3.6.11/src/prepare.c:715
#15 0x34440 in sqlite3_exec (db=0x9cd10,
    zSql=0x9cc70 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);", xCallback=0x192c4 <callback>, pArg=0xffbee060,
    pzErrMsg=0xffbedf7c) at ../../src/sqlite-3.6.11/src/legacy.c:56
#16 0x1c508 in process_input (p=0xffbee060, in=0x99ab8) at ../../src/sqlite-3.6.11/src/shell.c:1867
#17 0x1ce40 in main (argc=2, argv=0xffbee9e0) at ../../src/sqlite-3.6.11/src/shell.c:2223
For the HP-UX system:

-bash-2.05b$ uname -a
HP-UX taper B.11.23 U ia64 unknown unknown HP-UX
-bash-2.05b$ gdb ../../build/progs/sqlite --core=core
HP gdb 5.4.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.4.0 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `sqlite'.
Program terminated with signal 10, Bus error.
BUS_ADRALN - Invalid address alignment
#0  0x40f7bf0:0 in exprAnalyze (pSrc=0x4006b2b0, pWC=0x40047dbc, idxTerm=0)
    at ../../src/sqlite-3.6.11/src/where.c:1034
1034        pTerm->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight);
(gdb) bt
#0  0x40f7bf0:0 in exprAnalyze (pSrc=0x4006b2b0, pWC=0x40047dbc, idxTerm=0)
    at ../../src/sqlite-3.6.11/src/where.c:1034
#1  0x40f79b0:0 in exprAnalyzeAll (pTabList=0x4006b2b0, pWC=0x40047dbc)
    at ../../src/sqlite-3.6.11/src/where.c:602
#2  0x4101230:0 in sqlite3WhereBegin (pParse=0x7fffe200, pTabList=0x4006b2b0,
    pWhere=0x4006abc8, ppOrderBy=0x0, wctrlFlags=4 '\004', regRowSet=0)
    at ../../src/sqlite-3.6.11/src/where.c:3038
#3  0x40d9a40:0 in sqlite3Update (pParse=0x7fffe200, pTabList=0x4006b2b0,
    pChanges=0x4006b110, pWhere=0x4006abc8, onError=99)
    at ../../src/sqlite-3.6.11/src/update.c:348
#4  0x4133290:0 in yy_reduce (yypParser=0x400476e8, yyruleno=167)
    at parse.y:642
#5  0x41368a0:0 in sqlite3Parser (yyp=0x400476e8, yymajor=1, yyminor={
      z = 0x4007710c "#1", dyn = 0, n = 2}, pParse=0x7fffe200) at parse.c:3536
#6  0x40d2590:0 in sqlite3RunParser (pParse=0x7fffe200,
    zSql=0x40077018 "UPDATE 'main'.sqlite_master SET type='table', name='files', tbl_name='files', rootpage=#2, sql='CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, m"...,
    pzErrMsg=0x7fffe010) at ../../src/sqlite-3.6.11/src/tokenize.c:454
#7  0x40660f0:0 in sqlite3NestedParse (pParse=0x7fffe200,
    zFormat=0x40287f0 "UPDATE %Q.%s SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q WHERE rowid=#%d") at ../../src/sqlite-3.6.11/src/build.c:251
#8  0x406e0b0:0 in sqlite3EndTable (pParse=0x7fffe200, pCons=0x400463e8,
---Type <return> to continue, or q <return> to quit---
    pEnd=0x400463f8, pSelect=0x0) at ../../src/sqlite-3.6.11/src/build.c:1578
#9  0x4131560:0 in yy_reduce (yypParser=0x40046388, yyruleno=31) at parse.y:148
#10 0x41368a0:0 in sqlite3Parser (yyp=0x40046388, yymajor=1, yyminor={
      z = 0x4002d166 ";", dyn = 0, n = 1}, pParse=0x7fffe200) at parse.c:3536
#11 0x40d23b0:0 in sqlite3RunParser (pParse=0x7fffe200,
    zSql=0x4002d0e0 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);",
    pzErrMsg=0x7fffe1f0) at ../../src/sqlite-3.6.11/src/tokenize.c:442
#12 0x40b4bb0:0 in sqlite3Prepare (db=0x400347e8,
    zSql=0x4002d0e0 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);",
    nBytes=-1, saveSqlFlag=0, ppStmt=0x7fffe3c0, pzTail=0x7fffe3c4)
    at ../../src/sqlite-3.6.11/src/prepare.c:578
#13 0x40b53b0:0 in sqlite3LockAndPrepare (db=0x400347e8,
    zSql=0x4002d0e0 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);",
    nBytes=-1, saveSqlFlag=0, ppStmt=0x7fffe3c0, pzTail=0x7fffe3c4)
    at ../../src/sqlite-3.6.11/src/prepare.c:659
#14 0x40b5630:0 in sqlite3_prepare (db=0x400347e8,
    zSql=0x4002d0e0 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);",
    nBytes=-1, ppStmt=0x7fffe3c0, pzTail=0x7fffe3c4)
    at ../../src/sqlite-3.6.11/src/prepare.c:715
---Type <return> to continue, or q <return> to quit---
#15 0x408ea70:0 in sqlite3_exec (db=0x400347e8,
    zSql=0x4002d0e0 "CREATE TABLE files (id INTEGER PRIMARY KEY, dirname TEXT, filename TEXT, extension TEXT, size INTEGER, mtime DATETIME, ctime DATETIME);",
    xCallback=0x4033f00 <.opd+0x20>, pArg=0x7fffe460, pzErrMsg=0x7fffe3d0)
    at ../../src/sqlite-3.6.11/src/legacy.c:56
#16 0x4042860:0 in process_input (p=0x7fffe460, in=0x7efcec10)
    at ../../src/sqlite-3.6.11/src/shell.c:1867
#17 0x40457e0:0 in main (argc=2, argv=0x7fffed7c)
    at ../../src/sqlite-3.6.11/src/shell.c:2223

2009-Mar-20 09:46:25 by anonymous:
I should add, this seems to be a regression from 3.6.3 but I have no information as yet on intermediate versions.

We build on a variety of other UNIX platforms and those two seem to be the only failures: only one out of two Solaris platforms and the HP-UX platform are affected: none (of 3) linux platforms and none (of 2) AIX platforms seem to be, nor do the windows builds.


2009-Mar-20 14:20:54 by danielk1977:
Please reopen this ticket if [6364] doesn't fix this problem. Thanks.


2009-Mar-24 09:30:10 by anonymous:
The crash has gone for me, on both the solaris and HP-UX platforms.

Thank you for the fix!

 
3612 doc fixed 2009 Jan anonymous   2009 Jan   2 5 Double quotes and key-words detection
Hello,

According to the fact that we are french and that we do not use english language very often, we beg your pardon for gramatical and orthographic faults your may find in this message. We only hope that it will be understandable.

It seems that there is a problem of coherence between the "SQLite Keywords" chapter of the documentation and the behaviour of sqlite3.

In the documentation you say that when a text is writen in double quotes, sqlite3 checks if it is an SQL key-word used as an identifier.

In facts, any string writen in double quotes and which matchs an identifier is used as an identifier even if it is not a key-word.

Here under, we give you an exemple of test we made.

sqlite>create table toto(id varchar(10) not null, label varchar(10) not null);
sqlite>insert into toto(id, label) values ("aaa", "id");
sqlite>select * from toto where label = "id";
sqlite>select * from toto where label = 'id';
aaa|id
sqlite>select * from toto where id = "aaa";
aaa|id
sqlite>insert into toto(id, label) values ("bbb", "label");
sqlite>select * from toto where label = "label";
aaa|id
bbb|label
sqlite>select * from toto where label = 'label';
bbb|label
sqlite>

  • In the first select, the "id" has been used as the name of the id column so no result as been returned.
  • In the secund one, 'id' has been treated as a string and the line has been returned as expected.
  • In the third select, "aaa" is recognised as the value of the id column, so because it does not match an identifier, it has been used as a literal string.
  • In the fourth select, "label" is taken as the name of the label column so all lines are returned (a column is always equal to itself ;)).
  • Finaly, the last select gives only the line containing the word label in its label columns. It prouves the the 'label' mention has been used as a literal string.

We fund the problem on the 3.3.7 version (we love vintage) but we made tests on the 3.6.10 version and the result is the same on the two versions.

We see two solutions.

  1. An update of the documentation to say that if a text is put into double quotes and matchs an identifier (whithout case sensitivity), it is used has this identifier, even if it is not a key-word.
  2. A modification of the behaviour of sqlite3 to ensure that only key-words matching an identifier can be used has identifier when they are in double quotes and that any other text will be taken as a literal string.

We hope that our explanation is clear and will help you to find a way to make sqlite3 and its documentation synchronous.

Regards,

    Mr. Christophe Joulin, Mr. Guy Poulalion.
Documentation updated.
 
3611 warn closed 2009 Jan anonymous   2009 Oct   5 5 mingw gcc warnings
compiler warnings

\v3.6.10>gcc -c -march=pentium4 -mwindows --std=c99 -O2 -Wall *.c sqlite3.c: In function 'sqlite3BtreeFactory': sqlite3.c:88443: warning: passing argument 2 of 'sqlite3BtreeOpen' discards qualifiers from pointer target type sqlite3.c: In function 'sqlite3Step': sqlite3.c:52955: warning: 'iMoved' may be used uninitialized in this function sqlite3.c:52955: note: 'iMoved' was declared here sqlite3.c:52469: warning: 'iKey' may be used uninitialized in this function sqlite3.c:52469: note: 'iKey' was declared here

>gcc --version gcc (GCC) 4.2.1-dw2 (mingw32-2)

2009-Oct-12 21:10:45 by anonymous:
See FAQ, numerous tickets here and never ending postings to sqlite-users about this.
 
3610 warn fixed 2009 Jan anonymous   2009 Jan   5 5 msvc8(2005) warnings whilst compiling
sqlite3.c(32570) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data sqlite3.c(32798) : warning C4018: '<' : signed/unsigned mismatch

msvc8(2005), compiler settings warning level 2. (if you dont know that is default, and typical on most non-pedantic projects).

2009-Jan-29 07:24:53 by anonymous:
Warnung level 3 is default, as far as i know


2009-Jan-30 16:13:40 by shane:
With check-in [6215] , it currently compiles cleanly at /W2 and /W3 on MSVC 2005.
 
3609 new closed 2009 Jan anonymous   2009 Oct   5 5 New boundary tests dont check for 32bit row id
The new boundary tests (1-4) are only looking to see if there is a working 64-bit implementation also need to check the compile flag SQLITE_32BIT_ROWID so that the appropriate maximum row ids can be generated.

For example, the following statements will not work as expected if row ids are restricted to 32bit on 64 bit implementation.

  CREATE TABLE t1(a,x);
  INSERT INTO t1(oid,a,x) VALUES(9223372036854775807,3,'7fffffffffffffff');

SELECT oid,a,x from T1;

  Expected: [9223372036854775807 3 7fffffffffffffff]
  Got: [4294967295 3 7fffffffffffffff]
2009-Jan-27 01:34:39 by drh:
I would expect all kinds of think to break with SQLITE_32BIT_ROWID. That is not a supported compile-time option. (You won't find it at http://www.sqlite.org/compile.html for example.) The SQLITE_32BIT_ROWID is certainly not anything we current test for.

I'll change this to an enhancement request. But since the utility of 32-bit rowids is doubtful, I'm afraid it will be low priority.

 
3608 code closed 2009 Jan anonymous   2009 Jan drh 4 3 delete: alias for table not accepted => delete from tabelle t ...
   delete
     from moz_formhistory h
    where fieldname = 'q'
      and exists (select 1
                    from moz_formhistory
                   where fieldname = 'q'
                     and length (value) > length (h.value)
                     and substr (value, 1, length (h.value)) = h.value
                 );
2009-Jan-26 13:55:00 by drh:
SQL does not allow the table in a DELETE statement to be aliased. Alias the SELECT statement table instead:

  delete
    from moz_formhistory
   where fieldname = 'q'
     and exists (select 1
                   from moz_formhistory h
                  where fieldname = 'q'
                    and length (value) > length (moz_formhistory.value)
                    and substr (value, 1) = moz_formhistory.value
                );
 
3607 code closed 2009 Jan anonymous   2009 Mar   1 3 Vista64 + SMB server - journal creation fails (concurrency issue)
To reproduce you need the following environment:

- Windows Vista 64

- A mapped server drive (let's call it 'X:\') - (I connected to Windows Server 2003 and A Mac OS 10.5.5 SMB Share)

- The win32 sqlite3.exe tool

- Create a windows batch file that continuously writes to the database, (let's call it forever.bat):

echo create table test (id integer, name text); | sqlite3 test.db

:mystart

echo insert into test (id, name) values (1, 'testName'); | sqlite3 test.db

goto:mystart

- copy the forever.bat and sqlite3.exe to X:

- start 2 or 3 instances of forever.bat simultaneously

- wait until "cannot open database" - error appears.

Result: Windows Vista does not allow to create the journal file with exclusive access because CreateFile fails (in winOpen) with error 5 = "Access Denied" unless you reboot the system.

Seems to be a bug in Vista 64 - I will also get in contact with Microsoft, but I wanted to let you know to save you the headache I had.

Cheers, Joerg

Windows Vista Service Pack 2 (is currently beta) fixes this issue.

Cheers, Joerg

 
3606 code closed 2009 Jan anonymous   2009 Jan anonymous 1 4 page cache unmetch times bigger than read() called times
I add some debug information in sqlite3.c, and test Sqlite cache metch times, unmetch times and read() called times in Linux, I found that page unmetch times in cache is bigger than read() called times. Then I found in Btree.c getAndInitPage() function called sqlite3PageLookup, and sqlite3PageLookup() called sqlite3PcacheFetch() which do the cache search. If the page is not in cache, getAndInitPage() will call sqlite3BtreeGetPage() to get a page, in sqlite3BtreeGetPage() will call sqlite3PagerAcquire(), in sqlite3PagerAcquire(), it also call sqlite3PcacheFetch() to do a cache search. My English is not very well, in a word, in getAndInitPage() function, if a page it want to get is not in Sqlite cache, it will do 2 times search in cache, Is it reasonable? or something I did wrong? please check it, and my mail is :yokykk@gmail.com
2009-Jan-23 15:09:33 by anonymous:

static int getAndInitPage(
  BtShared *pBt,          /* The database file */
  Pgno pgno,           /* Number of the page to get */
  MemPage **ppPage     /* Write the page pointer here */
){
  int rc;
  DbPage *pDbPage;
  MemPage *pPage;

  assert( sqlite3_mutex_held(pBt->mutex) );
  if( pgno==0 ){
    return SQLITE_CORRUPT_BKPT;
  }

  /* It is often the case that the page we want is already in cache.
  ** If so, get it directly.  This saves us from having to call
  ** pagerPagecount() to make sure pgno is within limits, which results
  ** in a measureable performance improvements.
  */
  pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);
  if( pDbPage ){
    /* Page is already in cache */
    *ppPage = pPage = btreePageFromDbPage(pDbPage, pgno, pBt);
    rc = SQLITE_OK;
  }else{
    /* Page not in cache.  Acquire it. */
    if( pgno>pagerPagecount(pBt->pPager) ){
      return SQLITE_CORRUPT_BKPT;
    }
    rc = sqlite3BtreeGetPage(pBt, pgno, ppPage, 0);
    if( rc ) return rc;
    pPage = *ppPage;
  }
  if( !pPage->isInit ){
    rc = sqlite3BtreeInitPage(pPage);
  }
  if( rc!=SQLITE_OK ){
    releasePage(pPage);
    *ppPage = 0;
  }
  return rc;
}
if the page it want is not in cache, sqlite3BtreeGetPage() will do a cache search too.


2009-Jan-25 01:17:58 by drh:
Thank you for the suggestion.

We have investigated and found that the extra call to sqlite3PcacheFetch() uses less than 150 nanoseconds of CPU time. On the other hand, all our attempts to eliminate the extra call result in a much larger slowdown due to the additional program logic required. The current code configuration gives the fastest performance, so we will leave things as they stand.

 
3605 warn closed 2009 Jan anonymous   2009 Jan   3 3 Possibly incorrect assignment in function pager_playback_one_page
Using SQLite Amalgamation 3.6.10 and C++ Builder 2007 the following warnings appear:

warning : Warning W8060 Libraries\SQLite\sqlite3.c 31971: Possibly incorrect assignment in function pager_playback_one_page

Warning W8060 Libraries\SQLite\sqlite3.c 32041: Possibly incorrect assignment in function pager_playback_one_page

Thanks.
 
3604 code closed 2009 Jan anonymous   2009 Jan   3 3 getNextToken contains off-by-1 error
fts3_expr.c's getNextToken is invoked while performing an FTS3 query, and creates a new cursor to repeatedly tokenise the input. Each new cursor is created from successively further offsets into the original text, and the end position returned by the cursor is used to return the number of bytes consumed (via pnConsumed).

The FTS tokeniser interface is that xNext returns the byte offsets of the first/last bytes of the token relative to the input buffer. getNextToken uses the offset of the last byte (iEnd) to return the number of bytes consumed, however since this offset is relative to 0 it needs +1 to convert the offset into a bytes-consumed count.

E.g., when tokenising "el paso", the first call to getNextToken will invoke xNext to obtain the first token. xNext will return {iStart=0, iEnd=1} since the first token ("el") is two bytes long and located at the start of the buffer.

getNextToken currently returns "nConsumed = iEnd", which will return 1. This then triggers assertions higher up, as the token parsing goes out of sync. Since the value returned in iEnd is relative to the start of the buffer, the number of bytes returned by getNextToken should be "nConsumed = iEnd + 1".

Since fts3_tokenizer.h does not specify that xNext will/will not initialise its output parameters when returning SQLITE_DONE (or any other error), getNextToken should also explicitly set nConsumed to 0 if rc is anything but SQLITE_OK:

  rc = pModule->xNext(...);
  if (rc != SQLITE_OK)
    nConsumed = 0;
  else
    {
    ...
    nConsumed = iEnd + 1;
    }
2009-Jan-21 17:47:16 by danielk1977:
The comment in fts3_tokenizer.h was deceptive. In your example, xNext should set *piEnd to 2, not 1.

Code should not be using *piEnd in cases where something other than SQLITE_OK is returned by xNext, as you observe.

Thanks for the report.

 
3603 code fixed 2009 Jan anonymous   2009 Jan   1 3 Segmentation fault with PRAGMA journal_mode = OFF
I get a segmentation fault when using "PRAGMA journal_mode = OFF", which I don't get when the journal mode is left unchanged. This bug has first been filled as a Libgda bug: http://bugzilla.gnome.org/show_bug.cgi?id=568093

Code to reproduce bug is attached (this code has no Libgda in it, it's purely SQLite). The crash is the same using a shared library or a static library.

Running on Linux (32 and 64 bits).

2009-Jan-21 17:01:34 by drh:
A bisect shows this problem has already been fixed by check-in [6197] .
 
3602 code closed 2009 Jan anonymous   2009 Oct   1 1 assert() when executing DELETE statement
The following DELETE statement will trigger an assert():

	CREATE TABLE t2 (id INTEGER PRIMARY KEY, id2 INTEGER, name TEXT);
	CREATE UNIQUE INDEX t2_idx ON t2(id2, name);

	DELETE FROM t2 WHERE (id2=2 AND name IN()); -- will trigger an assert()

This causes the following assertion to fail:
sqlite3.c:18778: failed assertion `ALWAYS_was_false_or_NEVER_was_true'

However, the assertion is actually triggered from function bestIndex (line 81386):

        }else if( ALWAYS(pExpr->pList) ){

It only happens when the index is created as in the statements above. Just launch sqlite3 (built without NDEBUG defined) and issue the above statements to reproduce the problem.

2009-Oct-12 21:10:08 by anonymous:
Confirmed fixed.
 
3601 code closed 2009 Jan anonymous   2009 Oct   1 1 link failure on Fedora 10 with --enable-load-extension
Since dlsym and friends are in libdl, compiling sqlite with --enable-load-extension on Fedora 10 results in a link failure with missing dlopen, dlsym etc. symbols. I used the attached patch to fix the problem.
2009-Oct-10 03:11:57 by anonymous:
Current (3.6.18) configure appears to pick up libdl just fine. Please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3600 code active 2009 Jan anonymous   2009 Jan   5 4 Unnecessary ephemeral table
In SELECT below UNION ALL causes creation of ephemeral table. This can be avoided just like it is avoided without join.

  SQLite version 3.6.10
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> create table t1(a);
  sqlite> create table t2(a);
  sqlite> create table t3(a);
  sqlite> explain select * from (select * from t1 union all select * from t2) as t, t3 using(a);
  0|Trace|0|0|0|explain select * from (select * from t1 union all select * from t2) as t, t3 using(a);|00|
  1|OpenEphemeral|0|1|0||00|
  2|Goto|0|34|0||00|
  3|SetNumColumns|0|1|0||00|
  4|OpenRead|3|2|0||00|
  5|Rewind|3|11|0||00|
  6|Column|3|0|1||00|
  7|MakeRecord|1|1|2||00|
  8|NewRowid|0|3|0||00|
  9|Insert|0|2|3||08|
  10|Next|3|6|0||01|
  11|Close|3|0|0||00|
  12|SetNumColumns|0|1|0||00|
  13|OpenRead|1|3|0||00|
  14|Rewind|1|20|0||00|
  15|Column|1|0|1||00|
  16|MakeRecord|1|1|2||00|
  17|NewRowid|0|3|0||00|
  18|Insert|0|2|3||08|
  19|Next|1|15|0||01|
  20|Close|1|0|0||00|
  21|SetNumColumns|0|1|0||00|
  22|OpenRead|2|4|0||00|
  23|Rewind|0|32|0||00|
  24|Rewind|2|31|0||00|
  25|Column|0|0|2||00|
  26|Column|2|0|3||00|
  27|Ne|3|30|2|collseq(BINARY)|6a|
  28|Column|0|0|4||00|
  29|ResultRow|4|1|0||00|
  30|Next|2|25|0||01|
  31|Next|0|24|0||01|
  32|Close|2|0|0||00|
  33|Halt|0|0|0||00|
  34|Transaction|0|0|0||00|
  35|VerifyCookie|0|3|0||00|
  36|TableLock|0|2|0|t1|00|
  37|TableLock|0|3|0|t2|00|
  38|TableLock|0|4|0|t3|00|
  39|Goto|0|3|0||00|
 
3599 code fixed 2009 Jan anonymous   2009 Jan   4 3 configure --enable-tempstore does not correspond to SQLITE_TEMP_STORE
Apparently, the "--enable-tempstore" flag in the "configure[.ac]" script is supposed to correspond to the "SQLITE_TEMP_STORE" compilation option.

Unfortunately, the "configure[.ac]" mapping is as follows:

AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no) AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])

  never -> TEMP_STORE=0 AC_MSG_RESULT([never])
  no -> TEMP_STORE=1 AC_MSG_RESULT([no])
  always -> TEMP_STORE=3 AC_MSG_RESULT([always])
  yes -> TEMP_STORE=3 AC_MSG_RESULT([always])
  default -> TEMP_STORE=1 AC_MSG_RESULT([yes])

In contrast, the "SQLITE_TEMP_STORE" is documented (at http://www.sqlite.org/compile.html) like this:

  SQLITE_TEMP_STORE	Meaning
  0 -> never memory (= always files)
  1 -> no (= files by default, PRAGMA temp_store to override)
  2 -> yes (= in-memory by default, PRAGMA temp_store to override)
  3 -> always (= always in-memory)

So one would think that the "configure[.ac]" mapping should be (NOTE: changes are marked with "..."):

  never -> TEMP_STORE=0 AC_MSG_RESULT([never])
  no -> TEMP_STORE=1 AC_MSG_RESULT([no])
  _yes_ -> TEMP_STORE=_2_ AC_MSG_RESULT([_yes_])
  always -> TEMP_STORE=3 AC_MSG_RESULT([always])
  default -> TEMP_STORE=1 AC_MSG_RESULT([_no_])

i.e.:

  • the setting for "--enable-tempstore=yes" should be TEMP_STORE=2 AC_MSG_RESULT([yes])
  • the "default" case should say AC_MSG_RESULT([no]), not AC_MSG_RESULT([yes])
  • for consistency, the "yes" case (=2) should be sorted before the "always" (=3) case.

(The "default=no" case is correct to set "TEMP_STORE=1", because it is supposed to correspond to the documentation of the "--enable-tempstore=" option of "configure", as cited above.)

A diff file against "sqlite-3.6.7/configure.ac" is attached.

 
3598 code fixed 2009 Jan anonymous   2009 Jan   3 3 sqlite3_get_table() does not always initialise its pzErrMsg parameter
If the initial memory allocation in sqlite3_get_table() (in table.c) fails, it returns SQLITE_NOMEM without having cleared the pzErrMsg error return parameter.

It should include the code:

  if( pzErrMsg )
    *pzErrMsg = 0;

near the beginning of the function.

Also the documentation should be extended to say that not all error conditions return an error string.

 
3597 code closed 2009 Jan anonymous   2009 Jan   2 1 UTF-8 sorting is inconsistent between sqlite3 shell and Tcl interface.
I've noticed this poor sorting for some time, but just managed to delve into it today. A query of "...order by lower(field);" sort via the sqlite3 shell returns results (incl UTF-8 chars) as one would expect, but via the Tcl interface (tclsh, package require sqlite3), this same query run via "cmd eval {}" returns the values in a diff't order.

My own searching of the code led me to "tclsqlite.c" and UTF_TRANSLATION_NEEDED, which I tried setting manually to both 1 or 0 to see if it affected anything (it didn't in my testing). Don't know where problem lies.

Will get sample records available if required.

2009-Jan-19 06:52:50 by anonymous:
nb: I subsequently tested sorting in Tcl via "lsort" on the mis-sorted record set returned by sqlite, and it sorted as I would expect.


2009-Jan-19 06:54:31 by anonymous:
nb 2: Current Tcl version is 8.5.6, on NetBSD 5 beta


2009-Jan-19 13:03:50 by drh:
Please send sample data.


2009-Jan-20 11:53:43 by danielk1977:
The built-in SQL functions lower() and upper() use the C functions tolower() and toupper(). So the behaviour depends on the current locale. If you do:

  export LC_CTYPE=C

from the shell prompt before running the Tcl app, it will behave the same way as the sqlite3 shell does.

Unrelated: Another problem is that tolower() and toupper() are being passed signed char values. Technically you're not supposed to do this because toupper() and tolower() are only defined for values that fall in the range of an unsigned char.


2009-Jan-20 15:05:58 by anonymous:
[slaps head] I knew to check for LC_*, but completely forgot. Thanks.

A question, though: w/o explictly setting LC_CTYPE, my shell has it set to: en_US.UTF-8; when both tests are run from the same shell, the results are different. That is the part I don't understand... the lower() function in both cases is that of sqlite; why the difference in behaviour?

-bch http://www.methodlogic.net


2009-Jan-21 02:54:21 by anonymous:
I just checked-out build 6197 (commits for this ticket, plus one other set of changes) and indeed at first review, the results of the sort seem better.
 
3596 code closed 2009 Jan anonymous   2009 Oct   4 5 "make test" return errors when SQLITE_DEFAULT_PAGE_SIZE=4096
When

define SQLITE_DEFAULT_PAGE_SIZE 4096

"make test" return:

142 errors out of 32303 tests

make: *** [test] Error 1

2009-Jan-17 23:00:14 by anonymous:
When

#define SQLITE_DEFAULT_CACHE_SIZE 6000

#define SQLITE_DEFAULT_TEMP_CACHE_SIZE 1500

"make test" return 3 errors.


2009-Jan-18 14:29:41 by anonymous:
This instrunction in Makefile.in

TCC += -DSQLITE_ENABLE_ICU=1 `icu-config --ldflags

produce a few error in "make test".


2009-Oct-10 03:03:00 by anonymous:
You need to be more specific and show the errors. And telling it to use ICU and then getting errors is an indication you don't have ICU. Please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3595 build closed 2009 Jan anonymous   2009 Jan a.rottmann 1 1 can't execute the make command --> error
error by executing the "make" command

make command --> the error occurs by this statement: gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I./src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_TCL_STUBS=1 -c ./src/tclsqlite.c -fPIC -DPIC -o .libs/tclsqlite.o

Fehler:
src/tclsqlite.c:299: warning: initialization from incompatible pointer type
src/tclsqlite.c:309: warning: excess elements in struct initializer
src/tclsqlite.c:309: warning: (near initialization for `IncrblobChannelType')
src/tclsqlite.c: In function `DbUpdateHandler':
src/tclsqlite.c:596: warning: passing arg 3 of pointer to function makes pointer from integer without a cast
src/tclsqlite.c: In function `tclSqlFunc':
src/tclsqlite.c:682: warning: passing arg 1 of pointer to function discards qualifiers from pointer target type
src/tclsqlite.c:690: warning: assignment makes pointer from integer without a cast
src/tclsqlite.c:748: `Tcl_WideInt' undeclared (first use in this function)
src/tclsqlite.c:748: (Each undeclared identifier is reported only once
src/tclsqlite.c:748: for each function it appears in.)
src/tclsqlite.c:748: parse error before "v"
src/tclsqlite.c:749: `v' undeclared (first use in this function)
src/tclsqlite.c: In function `DbObjCmd':
src/tclsqlite.c:1017: warning: passing arg 3 of pointer to function from incompatible pointer type
src/tclsqlite.c:1665: warning: passing arg 2 of pointer to function discards qualifiers from pointer target type
src/tclsqlite.c:1689: `Tcl_WideInt' undeclared (first use in this function)
src/tclsqlite.c:1689: parse error before "v"
src/tclsqlite.c:1690: `v' undeclared (first use in this function)
src/tclsqlite.c:1735: warning: assignment makes pointer from integer without a cast
src/tclsqlite.c:2035: parse error before "rowid"
src/tclsqlite.c:2040: `rowid' undeclared (first use in this function)
src/tclsqlite.c:2284: warning: passing arg 3 of pointer to function from incompatible pointer type
src/tclsqlite.c: In function `DbMain':
src/tclsqlite.c:2507: warning: passing arg 2 of pointer to function discards qualifiers from pointer target type
src/tclsqlite.c:2529: warning: passing arg 2 of pointer to function discards qualifiers from pointer target type
make: *** [tclsqlite.lo] Error 1
2009-Jan-17 14:58:12 by drh:
My guess is that you have an old and obsolete version of TCL installed.

The sqlite-3.6.10.tar.gz tarball is not supported and is included for historical reference only. If you cannot debug this problem yourself and just want to build SQLite, use sqlite-amalgamation-3.6.10.tar.gz instead. If you want to build the TCL interface, use sqlite-3_6_10-tea.tar.gz. (You will still need a version of TCL that is newer than 5 years old.)

 
3594 code fixed 2009 Jan anonymous   2009 Jan   2 1 tcl interface broken on NetBSD for latest 3.6.10
Shared libs are -not- properly build with the change in CVS commit [6181] -- I've undone this change on my machine, and all builds, installs and seems to test well.
 
3593 code closed 2009 Jan anonymous   2009 Oct   2 1 gmake test core dumps in 64-bit build of SQLite3 3.6.10 on Solaris amd
I just started building and testing SQLite3 3.6.10 on Solaris.

The 32-bit i386 build has only the NaN/Tcl errors in "gmake test" (and an FTS3 Unicode-related error that I can live with), but the 64-bit amd64 build core dumps right after:

incrblob_err-4.1.1... Ok

The stack trace of the core is:

core 'core' of 670:     ./testfixture ./test/veryquick.test
-----------------  lwp# 1 / thread# 1  --------------------
 00000000004f6540 ???????? ()
-----------------  lwp# 2 / thread# 2  --------------------
 ffffdd7fffa3cfba __pollsys () + a
 ffffdd7fff9edb04 pselect () + 1d4
 ffffdd7fff9ede51 select () + 71
 ffffdd7fffd4bdf7 NotifierThreadProc () + 267
 ffffdd7fffa355b9 _thrp_setup () + 89
 ffffdd7fffa35860 _lwp_start ()
dbx says this about thread #1:

t@1 (l@1) terminated by signal SEGV (access to address exceeded protections)
0xffffffffffffffff:     <bad address 0xffffffffffffffff>
Looks like stack corruption.

Nico

2009-Jan-16 23:58:26 by drh:
The code runs on an amd64 under linux in valgrind with no warnings. It is hard to know how to begin to debug the above without additional information about what might be going wrong. We do not have access to a Solaris system.


2009-Oct-10 03:04:07 by anonymous:
No sign of OP. Closing as this tracker is now closed. Please direct further discussion to sqlite-users mailing list.
 
3592 code closed 2009 Jan anonymous   2009 Oct   4 3 sqlite3_changes return last value for drop table
if I execute "delete from s1" which return 4 changes (sqlite3_changes) and execute "drop table s1" -> sqlite3_changes also return 4.

temporery I fix this: add sqlite3VdbeAddOp2(v, OP_ResetCount, 1, 0); to end of function sqlite3DropTable but its not 'nice'

2009-Oct-10 03:05:50 by anonymous:
"drop table" is not documented as affecting the rowcount. Please direct further discussion to sqlite-users mailing list as this tracker is now closed.
 
3591 code closed 2009 Jan anonymous   2009 Oct   3 3 Print: "-- Loading resources from ..." in -batch mode
/sqlite/src/shell.c:

Function process_sqliterc check the value of stdin_is_interactive (if true print: "-- Loading resources from %s\n"). The value of stdin_is_interactive is set to 0 by -batch parameter, but function process_sqliterc is call before checking of parameters (in main()).

Batch mode (-batch) should turn off all not really important informations.

2009-Oct-11 05:33:47 by anonymous:
Now http://www.sqlite.org/src/tktview/2cb66577f600b7b657834fe3818fc7aba90d3803
 
3590 code closed 2009 Jan anonymous   2009 Jan   2 3 unable to use 'release' as column name without quotes
starting with sqlite version 3.6.9 it is not possible to use 'release' as a column name without quoting.

  CREATE TABLE a (id, release);
> SQL error: near "release": syntax error

I can imagine this word was promoted to reserved keyword with the introduction of savepoints, however I have a lot of tables with this column name (and queries referring to it) I cannot use anymore.

Is there a possibility to fix this ?

thanks

 
3589 doc closed 2009 Jan anonymous   2009 Oct   4 1 Create a one-file version of the documentation
I would find it useful if the standard source distributions of SQLite included, in the currently empty doc directory, a single-file HTML amalgamation of all of the documentation (along with the image files it references). There are three reasons why this would be useful.

1. People new to SQLite can print out the full documentation easily.

2. Loading a consolidated version of the documentation into a browser as a single page makes it easy to search for specific topics. (Generating some "help file" format instead of HTML would accomplish this, too, at the cost of requiring a help file viewer, and defeating objective 1 above.)

3. Including the documentation with the source distribution would eliminate version skew between code and documentation.

Given that the HTML is generated from Tcl code, I would expect producing this amalgamated HTML output to be pretty straightforward.

2009-Jan-16 15:55:51 by drh:
For a "print-out" of the documentation, I recommend:

To search the documentation, there is always Google.


2009-Jan-19 00:45:08 by anonymous:
Indeed, the book is quite good, especially for those relatively new to database systems. It of course does not keep up with each successive release of SQLite, and therefore does not serve as a reference to the current system.

Maybe I'm an old fuddy-duddy, but the ability to have an easy-to-search HTML version of SQLite's reference manual seems pretty much an unmitigated boon, especially since it is essentially trivial to generate it from the current documentation sources. And, yes, there are post-hoc ways of generating it, e.g., using Acrobat, or even checking the current documentation source out of Fossil, building it, and then doing find doc -type f -exec grep -il searchterm {} \; . Of course, I am not sure of the relationship between the documentation in Fossil and the version of the system in each specific release, so I might not check out the correct revision.

Or maybe there's some reason I don't understand why the documentation should not be distributed with the system?


2009-Jan-19 00:45:56 by anonymous:
Again, am I getting the correct revision of the documentation if I search it with Google?


2009-Jan-19 02:43:19 by drh:
There is also a separate file (a ZIP archive) with a replica of all the website documentation available for download on the download page:

    http://www.sqlite.org/download.html

You can download a version that matches whatever version of SQLite you are using, unpack the ZIP archive, and point your webbrowser at that. There are lots of tools available for searching files on your local disk.

If you want to build the documentation from sources, the source code to the documentation is managed here:

    http://www.sqlite.org/docsrc/home

It is not at all clear to me why you would want to do that, but it is an option.


2009-Oct-10 03:01:29 by anonymous:
Closing as no further progress will be made and workarounds are sufficient. Ticket tracker no longer used.
 
3588 code fixed 2009 Jan anonymous   2009 Jan   2 3 Small error when compiling sqlite 3.6.9 with gcc on Ubuntu 8.04
When compiling sqlite (preprocessed .zip archive sources) on Linux using gcc, I got this error:

./sqlite/sqliteInt.h:1617: error: expected unqualified-id before '||' token

It seems that the choice of "or" name for the following struct (part of the union) is not the best:

struct { WherePlan *aPlan; } or;

When replacing "or" to anything else like "or1", compilation works fine. It appears that gcc substituted "or" with "||" operator somewhere and this causes the error.

Changing the name does not influence other code, and it would be great to fix this upstream.

2009-Jan-15 12:31:24 by anonymous:
The same compilation error with MinGW build of gcc


2009-Jan-15 12:37:29 by drh:
Are you sure this isn't a bug in either gcc or in the ubuntu header files? What version of gcc are you running? Can you grep the system header files for something like:

   #define or ||

We run our tests on SuSE and on Ubuntu and we have had no problems. "or" is not a keyword in ANSI-C. It would be good to know exactly where this problem is originating from.


2009-Jan-15 12:38:39 by drh:
We also test on mingw and we have not seen this problem. I suspect you have an unwarranted "#define or" somewhere on your system.


2009-Jan-15 15:25:05 by anonymous:
"or" is a keyword in C++. Perhaps that your default compiler was set to g++ instead of gcc ?


2009-Jan-15 17:31:03 by anonymous:
/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GCC 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING.  If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.  */

/* As a special exception, if you include this header file into source
   files compiled by GCC, this header file does not by itself cause
   the resulting executable to be covered by the GNU General Public
   License.  This exception does not however invalidate any other
   reasons why the executable file might be covered by the GNU General
   Public License.  */

/*
 * ISO C Standard:  7.9  Alternative spellings  <iso646.h>
 */

#ifndef _ISO646_H
#define _ISO646_H

#ifndef __cplusplus
#define and	&&
#define and_eq	&=
#define bitand	&
#define bitor	|
#define compl	~
#define not	!
#define not_eq	!=
#define or	||
#define or_eq	|=
#define xor	^
#define xor_eq	^=
#endif

#endif


2009-Jan-15 17:32:47 by anonymous:
This is the only file with such definition, but it is not included in my project


2009-Jan-16 12:08:20 by anonymous:
Yes, I've checked and I am using C++ compiler. But then again, why not make sqlite C++ friendly ? Especially since this is a trivial change.
 
3587 code closed 2009 Jan anonymous   2009 Jan   1 1 db collation not working in the tcl interface
I'm try to do this in tcl with SQLIte 3.6.7 and 3.6.3:

proc nocase_compare {a b} {
     return [string compare [string tolower $a] [string tolower $b]]
 }
db collate NOCASE nocase_compare

CREATE TABLE test (
  name TEXT --COLLATE NOCASE
);
insert into test values ('Привет!');
insert into test values ('Ё-моё');
insert into test values ('привет');
insert into test values ('ё-прст');
insert into test values ('ага!');
insert into test values ('ё-моё');


Sorting is wrong:
select * from test order by name collate NOCASE;
"Привет!"
"Ё-моё"
"привет"
"ё-прст"
"ага!"
"ё-моё"

And result is equal to

select * from test;
"Привет!"
"Ё-моё"
"привет"
"ё-прст"
"ага!"
"ё-моё"


Query "select * from test order by name;" must to return this:
ага!
ё-моё
Ё-моё
ё-прст
привет
Привет!
I tested this script using SQLite version 3.6.4 and CVS HEAD and both worked correctly. Unable to replicate the problem.
 
3586 code closed 2009 Jan anonymous   2009 Jan   4 3 Unable to build shell in VS6. Plus encryption.
Unable to build shell in VS6. Shell also lacks of encryption support. Here is a patch that fixes both (set to pending, to avoid being ignored):

=---- Please add some tag to paste patches and parts of code. It would make life easier.

The SQLite Encryption Extension already comes with a separate implementation of shell.c that includes support for the encryption APIs.


2009-Jan-19 14:23:00 by anonymous:
Wll, bug was stating that shell is not buildable under VC6, encryption was by the way.


2009-Jan-19 15:07:50 by drh:
The only changes to shell.c in your patch were casts on malloc(), casts which should not be required under ANSI-C and should never prevent the code from building in any event. If you have specific problem building shell.c as delivered, then please let us know what the problems are and we will patch it for you.


2009-Jan-20 08:03:31 by anonymous:
It seams that VC6 is nota ANSI-C compatible :D I made patch including those casts because this was source of the problem.

Btw. great job. I love Sqlite

 
3585 code fixed 2009 Jan anonymous   2009 Jan   5 5 .schema doesn't work with full_column_names=1
  sqlite3
  SQLite version 3.6.7
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> pragma short_column_names=0;
  sqlite> pragma full_column_names=1;
  sqlite> .schema
  Error: no such column: sql
  sqlite>
 
3584 code fixed 2009 Jan drh   2009 Jan   1 1 Cache corruption following COMMIT with pending reads
This ticket documents the problem already fixed by check-in [6176] .

Check-in [5864] (part of version 3.6.5) introduced an enhancement that allowed transactions to commit even if there were unfinished queries on the same database connection. Previously, transactions would not commit until all outstanding queries finished and were either reset or finalized.

The transaction counter in bytes 24-27 of the database file header is incremented whenever the database content changes. This is done so that other instances of SQLite that are reading the same database file will know to flush their caches. However, if a database connection had a pending query that was holding a read-lock, and while that read-lock was held, two or more transactions were committed, the transaction counter would only be incremented on the first commit. That means that other database connections might not realize that the second and subsequent commits had occurred and might not flush their caches. They would be operating from a stale cache, which could (if one is unluckly) lead to database corruption.

This was never an issue before check-in [5864] because prior to then there could only be a single commit while the read-lock was being held.

The fix in check-in [6176] is to make sure the transaction counter is incremented after every commit, not just after the first commit.

2009-Jan-15 14:07:36 by drh:
The following conditions must be met in order for this bug to surface:

  • There must be two or more separate connections to the same database file. (Two connections using shared cache do not count as separate connections.)

  • One connection must start a long-running query and then do two or more COMMIT operations while that query is still running.

  • The other connection must do a query in between the two COMMIT operations of the first connection, then the do another query after the second COMMIT operation.

What happens is that the transaction counter is not being updated by the first connection after it does its second COMMIT. Hence the second connection does not know to reload its cache. The second connection is therefore using stale cache data - which could lead to database corruption, depending on what the second connection attempts to do.

 
3583 build fixed 2009 Jan anonymous build 2009 Feb danielk1977 3 3 sqlite3.pc not installed with default source tarball
The default source tarball like sqlite-amalgamation-3.6.9.tar.gz doesn't contain and install a sqlite3.pc pkgconfig-file which is needed for other programs to recognize that sqlite is installed.

Attached suggested patch to include/install a sqlite3.pc-file.

2009-Jan-26 20:56:36 by vapier:
sqlite includes a .pc.in file which is used to generate a correct .pc file after configure is run. the tarball itself should not be bundling a generated .pc file.


2009-Jan-27 09:18:51 by anonymous:
The recommend and supported sqlite-source-tarballs, like sqlite-amalgamation-3.6.10.tar.gz, do not include the required pkgconfig file. The use of the unprocessed sources, like sqlite-3.6.10.tar.gz, is not recommented as of http://www.sqlite.org/download.html.

Please have a look at the attached patch, it generate a correct .pc file after configure is run, too.


2009-Jan-27 18:47:57 by danielk1977:
Have applied this. 3.6.11 should work.


2009-Feb-18 10:49:35 by anonymous:
Thanks for adding the pkgconfig stuff to the amalgamation-sources. Unfortunately @RELEASE@ is not expanded/replaced with a correct version string by configure. Please change @RELEASE@ to @VERSION@ in sqlite3.pc.in.


2009-Feb-18 12:53:14 by drh:
Those files are not in a publicly accessible CM system, so you cannot see that this has now been fixed, but it has been. The fix will appear in the next release.
 
3582 new closed 2009 Jan anonymous   2009 Jan   5 4 ALTER TABLE and FOREIGN KEY support
Hi. Not that nested transactions aren't cool, but if I look at the http://www.sqlite.org/omitted.html page from 2008/10/10 18:25:23 UTC, I see that nested transactions are lower in the list than ALTER TABLE or FOREIGN KEYs are. I know that the page does not promise to keep the order, it just "gives the hint", but anyway... I was just looking forward to have FOREIGN KEYs sooner... Apart from this, keep up the good work, sqlite is excellent.
 
3581 code fixed 2009 Jan drh   2009 Jan   1 1 Adding an index changes the results of a query
The same results should come out of a query regardless of what indices are defined. Indices might make the query run faster, but the output should be the same.

The following is an example where adding an index changes the result set:

   CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
   INSERT INTO t1 VALUES(0,544,846);
   INSERT INTO t1 VALUES(1,345,51);
   CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);

   SELECT 'without index:', a FROM t1
    WHERE (b > 45 AND c < 356)
       OR b <= 733
       OR b >= 557
       OR (b >= 614 AND c < 251)
    ORDER BY b;

   CREATE INDEX i1 on t1(c);

   SELECT 'with index', a FROM t1
    WHERE (b > 45 AND c < 356)
       OR b <= 733
       OR b >= 557
       OR (b >= 614 AND c < 251)
    ORDER BY b;
2009-Jan-14 00:56:43 by drh:
This is really two separate problems, either of which would mask the other. The first bug is long-standing. The rowid cache for a VDBE table cursor was not being cleared by the OP_Rewind or OP_Last opcodes. The second problem is that the cost function for the new OR-clause optimizer was not taking the cost of sorting into account.

The OR-clause cost error was causing the query optimizer to select the OR-clause method even though that method used a full-table scan. The fact that OP_Rewind was not clearing the column cache caused the first rowid result after the OP_Rewind to be incorrect. This resulted in a single wrong value in the output.


2009-Jan-14 08:21:07 by anonymous:
The 3.6.9 release notes say: "The chances of actually hitting this combination of problems in a real application seems remote." This seems rather rich, when this ticket is precisely that: a real-world example of that combination of problems! TC
 
3580 new closed 2009 Jan anonymous   2009 Jan chw 3 5 conect vbscript
how use sqlite3.dll with vbscript
This is neither a bug report nor a feature request. Please use the mailing list to ask questions about how to use SQLite.
 
3579 doc fixed 2009 Jan anonymous   2009 Jan   4 3 rowset.c missing versioning tags
rowset.c missing CVS tags similar to the following around line 13

    ** $Id: rowset.c,v 1.2 2009/01/09 02:49:32 drh Exp $
 
3578 doc fixed 2009 Jan anonymous   2009 Jan   5 4 Incorrect comment in pragma.c regarding journal_size_limit
Comment at line 528 should be changed from

  /*
  **  PRAGMA [database.]journal_size_limit
  **  PRAGMA [database.]journal_size_limit=N
  **
  ** Get or set the (boolean) value of the database 'auto-vacuum' parameter.
  */

to

  ** Get or set the (int) value of the database 'journal_size_limit' parameter.
 
3577 code closed 2009 Jan anonymous   2009 Jan drh 3 5 Result of "select string_value || NULL_value from some_table" is NULL
Result of "select string_value || NULL_value from some_table" is NULL. Is this correct behavior? If so, please update documentation to describe this one.
2009-Jan-13 13:28:59 by danielk1977:
It is correct behavior.

2009-Jan-13 by drh:
This is how SQL is suppose to work.

 
3576 doc closed 2009 Jan anonymous   2009 Jan   4 4 Not a bug
sorry for making a really dumb bug report that's really a symptom of my poor reading comprehension :(
 
3575 code closed 2009 Jan anonymous   2009 Jan   3 3 Uninitialized memory read in sqlite3VdbeMemShallowCopy
Running Purify over some code that uses sqlite turns up the following uninitialized memory read in sqlite3VdbeMemShallowCopy:

  if( (pFrom->flags&MEM_Dyn)!=0 || pFrom->z==pFrom->zMalloc ){

My guess is that Purify is complaining about the fact that the 'z' field is uninitialized, since zMalloc and flags seem to be initialized in all cases. I know that pFrom is a variant structure, but this check seems wrong in that even if flags is set correctly, z can be uninitialized but read here. For example, if flags has MEM_Int set but not MEM_Dyn, then z will be read uninitialized - I think.

I just want to report this find to someone with more knowledge of this code than I have.

BTW, the source of this error seems to lie in the sqlite3VdbeMemFinalize function. If I change the following line in that function:

    sqlite3_context ctx;

to

    sqlite3_context ctx = {0}

the warning goes away.

Same issue as ticket #3326. Fixed by check-in [5596] .
 
3574 code closed 2009 Jan anonymous   2009 Jan   1 1 isLikeOrGlob denies glob optimization
It might be by design, but would be weird.

The following part of the code, will reject anything that is not a literal string. So, if the query is of type:

... my_column glob 'test*' ...

then it will proceed with pRight->op = TK_STRING

, but if the query is of type:

... my_column glob ? ...

then it will burp, as the pRight->op = TK_VARIABLE

If that is by design, and there is a good reason for that, then a small note in documentation (in RED FLASHING BOLD) would be appreciated. :)

  static int isLikeOrGlob(
  ...
    if( pRight->op!=TK_STRING
     && (pRight->op!=TK_REGISTER || pRight->iColumn!=TK_STRING) ){
      return 0;
    }
  ...
  }

Thanks,

2009-Jan-09 11:01:58 by anonymous:
It is getting worse. SQLite uses '' for escaping single quotes, but '' is also used as SQL comments.

SQL parsers out there (Spring for example) treat it as comment with all the pleasant consequences.

So, workaround become a no-workaround.

my_column glob ? cannot be used, because performance penalty is huge.

my_column glob '''test' cannot be used, because everything after '' is considered as comment, hence any following parameters are ignored.

Boom.


2009-Jan-09 11:05:23 by danielk1977:
Section 4 of this document:

  http://www.sqlite.org/optoverview.html

The right-hand side of the GLOB or LIKE operator must be a literal string value that does not begin with a wildcard. If the right-hand side is a parameter that is bound to a string, then no optimization is attempted. If the right-hand side begins with a wildcard character then no optimization is attempted.


2009-Jan-09 11:11:23 by danielk1977:
Not sure what the second problem is. If you post to the mailing list people will be able to suggest something. Maybe:

  MyColumn >= 'text' AND MyColumn <= 'text~'

or something.

  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


2009-Jan-09 12:13:10 by drh:
See also check-in [6137] from two days ago, which removes the TK_REGISTER test as dead code.
 
3573 new closed 2009 Jan anonymous   2009 Jan   3 4 journal_mode = truncate calls unlink(journal_file)
Hi,

According to my understanding, with journal_mode = truncate or journal_mode = persist, SQLite shouldn't even try to delete the journal file. But it does. I'm trying it on Linux:

$ rm -f /tmp/f && strace -e unlink ./sqlite3-3.6.7.bin /tmp/f .quit && echo DDD && strace -e unlink ./sqlite3-3.6.7.bin /tmp/f ' pragma journal_mode = truncate; create table a (i int);' Process 10415 detached DDD truncate unlink("/tmp/f-journal") = 0 Process 10417 detached $

Best regards,

Péter

It is deleting a stale journal that you left in /tmp/f-journal from the previous execution of your script. The behavior is correct.


2009-Jan-09 07:57:06 by anonymous:
Maybe I misunderstand something. If I specify `PRAGMA journal_mode = TRUNCATE', I don't want SQLite to ever even attempt to unlink the journal file. This is important for me, because I want to have an SQLite database in a directory to which I don't have write permission. So root creates f and f-journal to be empty files and chowns them to me, and then I use them with `PRAGMA journal_mode = TRUNCATE'. But that doesn't work, because SQLite attempts to unlink the journal file.

Here is an example:

  $ id && ls -ld /tmp/dir{,/*} && strace -e unlink ./sqlite3-3.6.7.bin /tmp/dir/f 'pragma journal_mode = truncate; create table a (i int);'

  uid=1000(user)gid=1000(user)groups=20(dialout),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),1000(user)
  drwxr-xr-x 2 root root 4096 Jan  7 17:05 /tmp/dir
  -rw-r--r-- 1 user user    0 Jan  7 17:05 /tmp/dir/f
  -rw-r--r-- 1 user user    0 Jan  7 17:05 /tmp/dir/f-journal
  truncate
  unlink("/tmp/dir/f-journal")            = -1 EACCES (Permission   denied)
  unlink("/tmp/dir/f-journal")            = -1 EACCES (Permission denied)
  SQL error: unable to open database file
  Process 11140 detached
  $

I would expect (but they don't happen):

* SQLite doesn't attempt to unlink the journal file. * The CREATE TABLE operation succeeds.


Reopening the ticket.


2009-Jan-11 16:55:46 by drh:
I am sorry to disappoint you, but that is not the way SQLite works. The current design is to delete stale journal files when the database is first opened. And the code currently appears to work as it was designed.

I will transform this ticket into an enhancement request and we will give due consideration to changing the design of SQLite in a future release such that it truncates rather than deletes stale journal files. Please recognize that this is not a promise to implement the feature, merely a promise to consider it. We need to think through all of the implications of the requested design change (including backwards compatibility issues) before moving forward.

We are not going to hold up version 3.6.8 for this.


2009-Jan-15 18:22:53 by drh:
After internal discusssions, we have decided not to implement this change. It is a corner case that is easily worked around. We want to avoid complicating the core SQLite code unnecessarily.

To work around this, create a non-empty SQLite database root before chowning it to the end user. If the original database file is not empty, then the journal file will not be deleted. Example:

  mkdir tmp
  sqlite3 tmp/f 'create table t1(x); drop table t1;'
  touch tmp/f-journal
  chmod 555 tmp
  sqlite3 tmp/f 'pragma journal_mode=truncate; create table t1(x)'
 
3572 code closed 2009 Jan anonymous   2009 Oct   2 2 BusyTimeout is not being used.
I am working in a high concurrency situation and have found a repeatable issue when running the 3.6.7 build.

I am getting error 14 returned from calls to sqlite3_exec() on thread A when thread B is executing the SQL command "COMMIT" from sqlite3_exec(). When the error occurs on thread A, thread B is always in the same place inside winClose(sqlite3_file *id). The reason I consider a return value of 14 an error on thread A is that I have a busytimeout of 180 seconds specified.

I have included two screenshots to show the problem. sqlite_ConcurrencyError1.jpg shows the state of thread A and sqlite_ConcurrencyError2.jpg shows the state of thread B.

I understand there is a lot of connection/compile information that may be relevant so I would be happy to get more information at your request. Thank you.

2009-Jan-08 23:05:02 by anonymous:
This behavior appears to mostly go away when I change the journal mode from PERSIST to TRUNCATE.


2009-Oct-10 03:08:36 by anonymous:
No further feedback from OP and probable fix committed. Please continue discussion on sqlite-users and this tracker is now closed.
 
3571 code closed 2009 Jan sdwilsh   2009 Jan   3 4 Crash when compiling SQLite with PGO
We've found that SQLite crashes reproducibly when compiled with PGO. In general, we've seen some nice performance wins when compiling the rest of our codebase with PGO, so we'd really like to be able to do this for SQLite too.

More information, including a test application, can be found in the downstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=419893#c6

2009-Jan-08 17:44:54 by drh:
The SQLite developers are unable to replicate this problem on either 3.6.6.2 or on CVS-HEAD (nearly 3.6.8) using either visual studio 2005 team edition or gcc 4.1.0.

We do observe the PGO makes SQLite run slower on windows.

On linux with gcc and -O3, the PGO version is about 10% faster and about 14% smaller than the non-PGO version. So PGO is definitely useful if you are compiling with -O3.

But if you compile with -Os, the PGO and non-PGO versions run at the same speed and the non-PGO version is a little smaller. So PGO is not helpful if you use -Os.

BTW: PGO==Profile Guided Optimization. The gcc docs call this "profie feedback optimization" or "profile directed optimization".


2009-Jan-12 15:24:00 by sdwilsh:
This seems to be working now with the latest SQLite, so something fixed it.
 
3570 code fixed 2009 Jan anonymous   2009 Jan   2 3 create table fail with a database file on the root directory
Hi,

I have found this bug with sqlite 3.6.6.2 and 3.6.7.

  root@plop:/home/flo/Desktop/tmp/sqlite-3.6.7# ./sqlite3 /plop.db
SQLite version 3.6.7
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE plop (muff INTEGER);
SQL error: unable to open database file

As you can see I am not able to create a table with the database file on the root directory. This issue can be fix with a small patch in the Linux VFS porting layer.

  --- sqlite-3.6.7/src/os_unix.c  2008-12-11 13:58:36.000000000 +0100
+++ sqlite-3.6.7.patched/src/os_unix.c  2009-01-08 11:20:52.000000000 +0100
@@ -3376,8 +3376,12 @@

   sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
   for(ii=(int)strlen(zDirname); ii>=0 && zDirname[ii]!='/'; ii--);
-  if( ii>0 ){
-    zDirname[ii] = '\0';
+  if( ii>=0 ){
+    if (ii==0){
+      zDirname[1] = '\0';
+    } else {
+      zDirname[ii] = '\0';
+    }
     fd = open(zDirname, O_RDONLY|O_BINARY, 0);
     if( fd>=0 ){
 #ifdef FD_CLOEXEC

Yes I know it's not very clean to create the file in the root dir but it's for an embedded device :)

Please let me know, if I am right.

Best regards, Florent Bayendrian

2009-Jan-11 01:19:30 by anonymous:
Hi,

Ok, your patch fix the issue but now the if statement is useless.

  --- os_unix.c.orig      2009-01-11 02:06:28.000000000 +0100
+++ os_unix.c   2009-01-11 02:06:51.000000000 +0100
@@ -3376,15 +3376,13 @@

   sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
   for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--);
-  if( ii>0 ){
-    zDirname[ii] = '\0';
-    fd = open(zDirname, O_RDONLY|O_BINARY, 0);
-    if( fd>=0 ){
+  zDirname[ii] = '\0';
+  fd = open(zDirname, O_RDONLY|O_BINARY, 0);
+  if( fd>=0 ){
 #ifdef FD_CLOEXEC
-      fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+    fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
 #endif
-      OSTRACE3("OPENDIR %-3d %s\n", fd, zDirname);
-    }
+    OSTRACE3("OPENDIR %-3d %s\n", fd, zDirname);
   }

Best Regards, Florent Bayendrian

 
3569 code closed 2009 Jan anonymous   2009 Oct   3 4 Should Shared-Cache Mode recognize busy timeouts?
I am using sqlite3 in a multi-threaded workstation environment and recently tried enabling sqlite3_enable_shared_cache(TRUE) for all connections. After each connection is made, a call is made to sqlite3_busy_timeout() with a timeout of roughly 180 seconds.

Now when multiple threads are trying to access the same table, occasionally a thread will be able to open the table using sqlite3_prepare_v2() but the call to sqlite3_step() fails immediately with SQLITE_LOCKED. Before enabled the shared cache, such threads would wait 180 seconds before returning the SQLITE_LOCKED error. Is this expected behavior?

Thank you.

Dup of #2010
 
3568 code closed 2009 Jan anonymous   2009 Jan   4 4 sqlite3shell.h needs "extern "C" protection for c++ code
The new functions in sqlite3shell.h are not protected by

#ifdef __cplusplus extern "C" { #endif

I have a good workaround by protecting it in my code.

related to 3562

2009-Jan-07 17:14:00 by anonymous:
Drop this: Sorry, I got mixed up between versions. This feature hasn't been submitted, let alone accepted by sqlite3.
 
3567 doc closed 2009 Jan anonymous   2009 Jan   5 4 sqlite3_create_function invariant H16124 reports incorrect upper bound
sqlite3_create_function invariant H16124 reports incorrect upper bound. It says the upper bound on nArgs is 127, but the default max arg in source code (SQLITE_MAX_FUNCTION_ARG) is 100
Thanks.
 
3566 code closed 2009 Jan anonymous   2009 Oct   1 1 "unable to open database file" under cygwin build
Following script fails under cygwin build (both official and manual)

The error is "unable to open database file" I checked, there is no permission issues.

I tested Cygwin 3.6.2 and 3.6.7 -- problem happens. Older Cygwin Sqlite3 3.5.1 build works fine. cygwin version 1.5.25

I tested official sqlite3 windows binaries -- works fine as well 3.6.7.

Script:

  begin;

  drop table if exists history;
  drop table if exists pages;
  drop table if exists users;
  drop table if exists options;

  create table options (
      lang varchar(16) not null,
      name varchar(32) not null,
      value text not null,
      unique(lang,name)
  );

  create table users (
      id integer primary key autoincrement not null,
      username varchar(32) unique not null,
      password varchar(32) not null
  ) ;

  create table pages (
    id integer primary key autoincrement not null,
    lang varchar(16) not null,
    slug varchar(128) not null,
    title varchar(256) not null,
    content text not null,
    sidebar text not null,
    users_only integer not null,
    unique (lang,slug)
  );

  create table history (
    id integer not null,
    version integer not null,
    created datetime not null,
    author varchar(32) not null,
    title varchar(256) not null,
    content text not null,
    sidebar text not null,
    unique(id,version),
    primary key(id,version)
  );

  create index history_timeline on history(created);

  commit;

  begin;
  INSERT INTO pages(lang,slug,title,content,sidebar,users_only)
	VALUES('en','main','Test','Test','',0);
  INSERT INTO history(id,version,created,title,content,sidebar,author)
	SELECT 1,(SELECT COALESCE(MAX(version),0)+1 FROM history  WHERE id=1),
  	'2008-01-01 10:00:00','Test','Test','','artyom';
  commit;
2009-Jan-20 07:30:36 by anonymous:
Anybody?

It prevents updating sqlite version under cygwin.

Thanks


2009-Jan-20 08:16:26 by anonymous:
There isn't enough information to diagnose the issue. Somewhere under the hood cygwin is failing a call it shouldn't.

If this was Linux then using the strace tool would make it quick and clear where the issue lies. If you can find something similar for cygwin then that will provide the necessary information.

You can also use Process Monitor from sysinternals which will tell you what happened at the Windows API level which will have some correspondence with what cygwin is returning.

Ultimately unless you can prove otherwise, the error is in cygwin. SQLite works just fine under Windows and just fine under Linux.


2009-Oct-10 03:00:01 by anonymous:
Closing as bug tracker is no longer used and no further feedback from OP.
 
3565 doc closed 2009 Jan anonymous   2009 Oct   5 4 Unsupported feature addiction
Hello,

I've found that SQLite3 doesn't support SQL command LOCK TABLES, nor UNLOCK TABLES.

Please add them to: http://www.sqlite.org/omitted.html Or add them to the next release. :-D

Thanks and have a Great Day!

2009-Oct-10 03:21:09 by anonymous:
LOCK TABLES appears to be a MySQL only feature not part of the SQL standard and even then only apply to myisam tables due to their poor transaction support. The page does not mention omissions like this this. Please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3564 code fixed 2009 Jan anonymous   2009 Jan   1 4 recursive commit_hook problem
The following Tcl code behaves differently with 3.6.4 (ok) and 3.6.7 (broken):

  package require sqlite3

  catch {file delete test.db}
  sqlite3 db test.db

  db eval {
    create table dummy(key, value);
    insert into dummy(key,value) values('self','my-writer-id');
  }
  db commit_hook checkWriterId
  proc checkWriterId {} {
    set wid [db onecolumn {select value from dummy where key='self'}]
    if {$wid ne "my-writer-id"} barf
  }
  db trace puts

  db transaction {
    db eval {
        insert into dummy(key,value) values('other','stuff');
    }
  }

With 3.6.4 the transaction is committed, whereas 3.6.7 executes a rollback due to a recursive invokation of the commit_hook.

Problem introduced by check-in [5864] .
 
3563 new closed 2009 Jan anonymous   2009 Oct   5 4 AUTOINCREMENT FROM i BY j enhancement
It is desirable** for AUTOINCREMENT to allow the user to supply a starting value and/or an increment value in the table definition. The proposed format would look something like this:

...INTEGER PRIMARY KEY AUTOINCREMENT [FROM i] [BY j]

The value i (any 64 bit signed integer) represents an initial seq value used when creating the corresponding row in sqlite_sequence. Since the seq value in sqlite_sequence is the "last used" and not "next available", it is understood the actual i value would never be used.

The value j (any 64 bit signed integer) represents the base increment (or multiple there of) of the sequence. Storing this value would require a third column in the sqlite_sequence table.

If the increment is allowed to be negative (as proposed) bounds checking for both overflows and underflows would be needed.



** Some techniques for safely generating cluster-unique ROWIDs in "shard database" clustering depend on this feature. They're also pretty standard features of database sequence systems and it would be nice if SQLite supported them even if SQLite's sequence engine is not available to every row/column.

See discussion on user mailing list (Subject: About clustering (GUIDs, PK offsets, etc.) ) and in specific, the referenced article: http://blog.maxindelicato.com/2008/12/how-to-organize-a-database-tables-keys-for-scalability.html I admit that this specific example is fairly niche, but it seems like a low-footprint enhancement that might prove useful in many different ways.

2009-Oct-10 03:22:27 by anonymous:
Note the Lite in the project name! Please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3562 new closed 2008 Dec anonymous   2009 Jan   3 3 sqlite3_create_meta_function -- add const to first parameter
in shell.c,

sqlite3_create_meta_function's first argument is char * name

and it can be a const char * name

2009-Jan-07 17:12:29 by anonymous:
Drop: I got confused. This patch is for a local feature (sorry for the mixup).
 
3561 code closed 2008 Dec anonymous   2008 Dec   3 3 gcc 4.1.2 complains about illegal char in keywordCode() zText[]
gcc 4.1.2 (centos 5) complains about an illegal multi-character character constant because of the last character in the zText array in the keywordCode() function. (This was tested with an up-to-date CVS build, with ./configure and no parameters to build sqlite3.c.)

libtool: compile: gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I../sqlite-latest/src -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -c sqlite3.c -fPIC -DPIC -o .libs/sqlite3.o sqlite3.c:85865:5: warning: multi-character character constant sqlite3.c: In function ‘keywordCode’: sqlite3.c:85865: warning: overflow in implicit constant conversion

Version 3.6.7 completely overhauls the zText array in the tokenizer.
 
3560 code closed 2008 Dec anonymous   2008 Dec   1 3 join with mis-specified index confuses query planner
This was reproduced on an up-to-date CVS as of 2008-12-29.

  [sfriedman@zeph sqlite-build]$ ./sqlite3
  SQLite version 3.6.7
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> CREATE TABLE maintable( id integer);
  sqlite>
  sqlite>
  sqlite> CREATE TABLE joinme(
    ...>   id_int integer,
    ...>   id_text text
    ...> );
  sqlite> CREATE INDEX joinme_id_text_idx on joinme(id_text);
  sqlite> CREATE INDEX joinme_id_int_idx on joinme(id_int);
  sqlite>
  sqlite>
  sqlite> explain query plan
    ...> select * from maintable as  m inner join
    ...>            joinme as j indexed by joinme_id_text_idx
    ...>            on ( m.id  = j.id_int)
    ...>      ;
  0|0|TABLE maintable AS m
  1|0|TABLE maintable AS m

Clearly, the specified index should have been joinme_id_int_idx (and if that index is specified, then the query planner returns the expected results). In this case, the query planner gets confused and returns incorrect results. Either rejecting the select (because of the misspecified index) or running abysmally slowly (again because of the misspecified index) should have occurred. Not surprisingly, when run with live data, the code SIGSEGV'ed.

Thanks for reporting this.
 
3559 doc closed 2008 Dec anonymous   2008 Dec   4 4 Typo in tokenizer specification in ext/fts3/README.tokenizers
I think there is a typo in ext/fts3/README.tokenizers:

    CREATE VIRTUAL TABLE <table-name> USING fts3(
      <columns ...> [, tokenizer <tokenizer-name> [<tokenizer-args>]]
    );

Sqlite 3.6.7 (line 91162 of the sqlite3.c amalgamation) thinks this should be just "tokenize" instead of "tokenizer".

Thanks.
 
3558 code closed 2008 Dec anonymous   2008 Dec   4 4 syntax error : 'bad suffix on number'
Under eVC4 and VC++ 6 those lines cause trouble:

  [11755:] t = x.iJD/1000 - 210866760000LL;
  [11857:] p->iJD = p->iJD/86400 + 210866760000000LL;

Replaced with old ones from 3.6.6.1 helps:

  t = x.iJD/1000 - 2440587.5*86400.0;
  p->iJD = p->iJD/86400.0 + 2440587.5*86400000.0;


Besides that, nice version. I didn't have to fix anything else to compile. Except adding at the begining:

  #pragma warning(push)   // Save the current warning state
  #pragma warning(disable:4244)
  #pragma warning(disable:4018)
  #pragma warning(disable:4146)
  #pragma warning(disable:4005)
  #pragma warning(disable:4307)
  #pragma warning(disable:4308)

and at the end:

  #pragma warning(pop)

This makes less pain on build :)

2008-Dec-29 13:54:26 by danielk1977:
This is a dup of #3547. Already fixed by [6048] , which will be part of version 3.6.8 when it is released.
 
3557 new closed 2008 Dec anonymous   2008 Dec   1 4 GUID primary keys
Is needed to add GUID primary keys for realising transparent database clustering mechanism.
2008-Dec-29 13:13:53 by anonymous:
The Cost of GUIDs as Primary Keys:

http://www.informit.com/articles/article.aspx?p=25862


2008-Dec-29 13:52:16 by danielk1977:
Suggest writing to the mailing list. It is not yet clear if there is a feature-request or bug-report here.

  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
 
3556 code closed 2008 Dec anonymous   2008 Dec   1 3 Upgrade from 3.6.1 to 3.6.7 under WinCE resulted in Invalid Querys
Previous version used was 3.6.1 the following query worked fine but when I upgraded finally to 3.6.7 the following only works on win32 under Pocket PC the query returns RECORD_SET_OPEN_INVALIDQRY

I have a database with 77792 enteries in sequential order ID = 1, 2, 3, ..., 77792

The query I made was basically to get id 6383 and return all the fields for this record.

SELECT ID, NAME, CATEGORY, SUBCATEGORY, AUTHOR, DATE, LATITUDE, LONGITUDE, THIRD_PARTY_ID, TAGS, DESCRIPTION, HOURS, ADDRESS, STREET, CITY, STATE, COUNTRY, ZIP, PHONE, FAX, WEB, EMAIL, MEDIA, USER, PRIVATE, LATITUDE_OFFSET, LONGITUDE_OFFSET, CAN_MODIFY_RMF_FIELDS FROM 'POI' WHERE ID IN (6383);

Under win32 this returns RECORD_SET_OPEN_SUCCESS and the data but under Pocket PC this returns RECORD_SET_OPEN_INVALIDQRY.

now this database we created using version 3.6.1 but I wouldn't think I would have to rebuild the database especially since the win32 version works fine.

I also tried this query using SQLlite Database Browser version 1.3 and the above query worked as expected.

I am compiling under Dev Studio 2005 using the sqlite-amalgamation-3_6_7 with the following compiler options set

SQLITE_OMIT_MEMORYDB;SQLITE_OMIT_AUTOVACUUM;SQLITE_OMIT_LOAD_EXTENSION;SQLITE_OMIT_AUTHORIZATION;SQLITE_OMIT_FOREIGN_KEY;SQLITE_OMIT_PROGRESS_CALLBACK;SQLITE_OMIT_GET_TABLE;SQLITE_OMIT_EXPLAIN;TIXML_USE_STL;SQLITE_OS_WINCE

I will revert back to 3.6.1 since this is the last version I have and I know works under CE. Our software is a commercial GPS product for the Visually Impaired which we were about to patch with this latest version of SQLite but will have to forgo this update due to this problem.

Thank you Charles

2008-Dec-29 12:46:06 by anonymous:
Please Ignore and close this bug report. When the same thing happened after I reverted back to 3.6.1 I found the real problem, which was a corrupt database on the winCE device I was testing against.

Sorry for the false report. Keep up the good work. Charles.

 
3555 build closed 2008 Dec anonymous   2009 Oct   3 3 Need to check for and use -ldl
http://mail-index.netbsd.org/tech-pkg/2008/12/22/msg002229.html

You won't usually notice the problem because most Linux systems link ncurses with -ldl. When it's not, though, readline isn't either, which means linking the sqlite executable fails because it can't resolve dlopen and friends.

2008-Dec-27 10:07:31 by anonymous:
See also #3137 and #3315


2009-Oct-10 03:23:01 by anonymous:
Many other dupes of this. Not an issue in current release.
 
3554 code closed 2008 Dec anonymous   2008 Dec   3 3 before insert trigger odd behavior
I have a table associating objects to time intervals. I want to merge contiguous intervals upon insert and I thought to use triggers to implement this behavior:

  CREATE TABLE test (
      obj,
      t1,
      t2,
      PRIMARY KEY (obj, t1, t2)
  );

  CREATE TRIGGER test_insert BEFORE INSERT ON test
  FOR EACH ROW
  BEGIN
      -- update existing (t1, t2)
      UPDATE test SET t1 = new.t1 WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1;
      UPDATE test SET t2 = new.t2 WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2;
      -- ignore if the new interval (t1, t2) is already included into an existing one (possibly a just-updated one)
      SELECT RAISE(IGNORE) WHERE EXISTS (SELECT obj FROM test WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2);
  END;

  INSERT INTO test VALUES ('a', 10000, 11000);
  INSERT INTO test VALUES ('a',  9000, 10500);
  INSERT INTO test VALUES ('a', 11000, 12000);

  SELECT obj, t1, t2 FROM test;

This returns 3 rows:

  a|9000|11000
  a|9000|10500
  a|11000|12000

which is not what I expected. However, if I modify the trigger adding a couple of dummy "SELECT null":

  CREATE TRIGGER test_insert BEFORE INSERT ON test
  FOR EACH ROW
  BEGIN
      -- update existing (t1, t2)
      UPDATE test SET t1 = new.t1 WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1;
      SELECT null;
      UPDATE test SET t2 = new.t2 WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2;
      SELECT null;
      -- ignore if the new interval (t1, t2) is already included into an existing one (possibly a just-updated one)
      SELECT RAISE(IGNORE) WHERE EXISTS (SELECT obj FROM test WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2);
  END;

I get the expected behavior:

  a|9000|12000

It also works adding other statements (ex. insert into another table).

I think this could be a bug, if I am missing something sorry for the trouble.

Merry Christmas!

2008-Dec-25 12:03:38 by drh:
This appears to be yet another bug in the column cache. I'll fix it after Christmas.


2008-Dec-26 05:02:25 by danielk1977:
Slightly simplified example:

    CREATE TABLE test (
        obj,
        t1,
        t2
    );

    CREATE TRIGGER test_insert BEFORE INSERT ON test BEGIN
      UPDATE test SET t1 = new.t1
        WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1;

      UPDATE test SET t2 = new.t2
        WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2;

      SELECT RAISE(IGNORE) WHERE EXISTS (
        SELECT obj FROM test
        WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2
      );
    END;

The following insert statement:

    INSERT INTO test VALUES('a', 9000, 10500);

Compiles to:

   addr  opcode        p1      p2      p3      p4               p5  #
   ----  ------------  ------  ------  ------  ---------------  --  -
   0     Trace         0       0       0       explain INSERT INTO test VALUES('a', 9000, 10500) 00
   1     Goto          0       113     0                         00
   2     Noop          0       0       0                         00
   3     SetNumColumn  0       3       0                         00
   4     OpenPseudo    0       0       0                         00
   5     SetNumColumn  0       3       0                         00
   6     OpenWrite     1       2       0                         00  test
   7     Integer       -1      6       0                         00
   8     String8       0       7       0       a                 00
   9     Copy          7       10      0                         00
   10    Integer       9000    8       0                         00
   11    Copy          8       11      0                         00
   12    Integer       10500   9       0                         00
   13    Copy          9       12      0                         00
   14    MakeRecord    7       3       13      bbb               00
   15    Insert        0       13      6                         00
   16    Trace         0       0       0       -- TRIGGER test_insert 00
   17    ContextPush   0       0       0                         00  begin trigger test_insert
   18    ResetCount    0       0       0                         00
   19    Noop          0       0       0                         00
   20    Null          0       14      0                         00
   21    SetNumColumn  0       2       0                         00
   22    OpenRead      2       2       0                         00  test
   23    Rewind        2       36      0                         00
   24    Column        2       0       6                         00  test.obj
   25    Column        0       0       13                        00  test.obj
   26    Ne            13      35      6       collseq(BINARY)   6a
   27    Column        0       1       13                        00  test.t1
   28    Column        2       1       6                         00  test.t1
   29    Ge            6       35      13      collseq(BINARY)   6a
   30    Column        0       2       6                         00  test.t2
   31    Column        2       1       13                        00  test.t1
   32    Lt            13      35      6       collseq(BINARY)   6a
   33    Rowid         2       14      0                         00
   34    RowSetAdd     18      14      0                         00
   35    Next          2       24      0                         01
   36    Close         2       0       0                         00
   37    SetNumColumn  0       3       0                         00
   38    OpenWrite     2       2       0                         00  test
   39    RowSetRead    18      48      14                        00
   40    NotExists     2       39      14                        00
   41    Column        2       0       15                        00  test.obj
   42    Column        0       1       16                        00  test.t1
   43    Column        2       2       17                        00  test.t2
   44    NotExists     2       45      14                        00
   45    MakeRecord    15      3       13      bbb               00
   46    Insert        2       13      14      test              05
   47    Goto          0       39      0                         00
   48    Close         2       0       0                         00
   49    ResetCount    1       0       0                         00
   50    ResetCount    0       0       0                         00
   51    Noop          0       0       0                         00
   52    Null          0       19      0                         00
   53    SetNumColumn  0       3       0                         00
   54    OpenRead      3       2       0                         00  test
   55    Rewind        3       67      0                         00
   56    Column        3       0       6                         00  test.obj
   57    Column        0       0       23                        00  test.obj
   58    Ne            23      66      6       collseq(BINARY)   6a
   59    Column        0       2       23                        00  test.t2
   60    Column        3       2       6                         00  test.t2
   61    Le            6       66      23      collseq(BINARY)   6a
   62    Column        3       2       6                         00  test.t2
   63    Gt            6       66      16      collseq(BINARY)   6a
   64    Rowid         3       19      0                         00
   65    RowSetAdd     24      19      0                         00
   66    Next          3       56      0                         01
   67    Close         3       0       0                         00
   68    SetNumColumn  0       3       0                         00
   69    OpenWrite     3       2       0                         00  test
   70    RowSetRead    24      79      19                        00
   71    NotExists     3       70      19                        00
   72    Column        3       0       20                        00  test.obj
   73    Column        3       1       21                        00  test.t1
   74    Column        0       2       22                        00  test.t2                <---------------------
   75    NotExists     3       76      19                        00
   76    MakeRecord    20      3       6       bbb               00
   77    Insert        3       6       19      test              05
   78    Goto          0       70      0                         00
   79    Close         3       0       0                         00
   80    ResetCount    1       0       0                         00
   81    Integer       0       25      0                         00  Init EXISTS result
   82    Integer       1       26      0                         00
   83    MustBeInt     26      0       0                         00  LIMIT counter
   84    IfZero        26      101     0                         00
   85    SetNumColumn  0       3       0                         00
   86    OpenRead      4       2       0                         00  test
   87    Rewind        4       100     0                         00
   88    Column        4       0       27                        00  test.obj
   89    Column        0       0       28                        00  test.obj
   90    Ne            28      99      27      collseq(BINARY)   6a
   91    Column        0       1       28                        00  test.t1
   92    Column        4       1       27                        00  test.t1
   93    Lt            27      99      28      collseq(BINARY)   6a
   94    Column        4       2       27                        00  test.t2
   95    Gt            27      99      22      collseq(BINARY)   6a                     <---------------------
   96    Integer       1       25      0                         00
   97    AddImm        26      -1      0                         00
   98    IfZero        26      100     0                         00
   99    Next          4       88      0                         01
   100   Close         4       0       0                         00
   101   IfNot         25      104     1                         00
   102   ContextPop    0       0       0                         00
   103   Goto          0       111     0                         00  raise(IGNORE)
   104   ContextPop    0       0       0                         00  end trigger test_insert
   105   NewRowid      1       2       0                         00
   106   SCopy         10      3       0                         00
   107   SCopy         11      4       0                         00
   108   SCopy         12      5       0                         00
   109   MakeRecord    3       3       23      bbb               00
   110   Insert        1       23      2       test              0b
   111   Close         1       0       0                         00
   112   Halt          0       0       0                         00
   113   Transaction   0       1       0                         00
   114   VerifyCookie  0       2       0                         00
   115   TableLock     0       2       1       test              00
   116   Goto          0       2       0                         00

The problem (or at least a problem) relates to instructions 74 and 95, both of which are part of the trigger implementation.

Instruction 74 loads the value of new.t2 into register 22, ready to create a new record to insert as part of the second UPDATE statement. Instruction 95 reuses the value of register 22 (assuming it contains new.t2) as part of the WHERE clause in the SELECT RAISE() statement.

However, instruction 74 is only executed if the WHERE clause attached to the UPDATE statement is true for at least one row. If this is not the case, then register 22 is not correctly populated. So if second UPDATE statement updates 0 rows, then the SELECT RAISE() malfunctions. Hence the incorrect results.

The easiest fix would be to clear the column cache after compiling each SQL statement in a trigger program. I think this is what inserting the "SELECT null" statements was doing.

 
3553 code closed 2008 Dec anonymous   2009 Oct   1 3 Bus error with 32bit build on Solaris SPARC
When running "make test" on a 32bit build on Solaris 8 (SPARC) with gcc 4.3.2 testfixture dumps core with a bus error.

This appears to be basically the same problem as #3040 and #1158 - namely attempting to access 64bit values that are not aligned on 8 byte boundaries.

There are two problems that cause crashes.

Firstly, in sqlite3VdbeSerialGet() there are crashes when setting "pMem->u.i" to something, since pMem might not be 8 byte aligned. This can happen when sqlite3VdbeRecordUnpack() is unpacking a small record and uses the memory passed in with the pSpace parameter. When called from sqlite3VdbeExec() the local variable aTempRec is passed as the pSpace parameter and this variable is only aligned on a 4 byte boundary (depending on how the compiler arranges the automatic variables). Setting the required alignment of the UnpackedRecord struct to 8 bytes fixes this problem.

The second problem is in memjrnlWrite() accessing "p->endpoint.iOffset" if the pJfd parameter is not 8 byte aligned. This was happening when the Pager was opened by sqlite3PagerOpen(). That function allocates a block of memory for the "pPager" variable (too large for just the Pager struct) and then sets some of the pPager fields (including the "jfd" field) as offsets into this block of memory. As a side effect of the size of certain structures on this architecture this means that the "jfd" field points to memory that is not 8 byte aligned. Changing the way the size of the block of memory is calculated as well as the way the offsets into it are calculated fixes this problem.

As an aside, it appears the original code in sqlite3PagerOpen() allocated too much memory in the block for the "pPager" - it allocated space for three journal file structures when only two are required.

With the changes in place a "make test" runs "cleanly" (that is, no crashes) and the only test failures seen are ones seen on all other platforms I have access to (namely some "exclusive" and "jrnlmode" failures).

Once submitted I'll attach a patch to this ticket.

Regards,
Steve Nairn

2009-Oct-10 03:27:50 by anonymous:
This sort of thing has come up a few times before and was fixed. If it is still an issue then please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3552 build closed 2008 Dec anonymous   2009 Oct   3 4 shell.exe does not build correctly on windows/ce 5.0
I have been unable to get shell.c to correctly compile and link for Windows/CE 5.0. My patch file (svn diff shell.c) is my quick (and dirty) fix. The issues I encountered were: 1) unsatisfied externals strdup() and access() 2) no wmain() function 3) include <io.h> is not available on windows/ce 4) FILENAME_MAX is undefined

My patch has been quickly created and seems sufficient for my current needs - however beware: 1) Please replace my very simple-minded unicode-ascii conversion 2) I've build this with VS2005 for Win32 and WindowsCE/5.0 (x86) - my patch probably breaks the ming/gcc build environment.

  _2008-Dec-23 19:34:08 by anonymous:
  Index: shell.c
  ===================================================================
  --- shell.c	(revision 5357)
  +++ shell.c	(working copy)
  @@ -44,7 +44,7 @@
   # define stifle_history(X)
   #endif

  -#if defined(_WIN32) || defined(WIN32)
  +#if (defined(_WIN32) || defined(WIN32)) && !defined(WINCE)
   # include <io.h>
   #else
   /* Make sure isatty() has a prototype.
  @@ -52,6 +52,78 @@
   extern int isatty();
   #endif

  +#if !defined(FILENAME_MAX) && defined(WINCE)
  +#define FILENAME_MAX 256
  +#include <string.h>
  +#include <windows.h>
  +char* strdup(char* s)
  +{
  +	char* result = malloc(strlen(s)+1) ;
  +	if ( result ) strcpy(result,s) ;
  +	return result ;
  +}
  +
  +static void copy_ascii_from_unicode(char* ascii,const wchar_t* unicode,int l )
  +{
  +	int   i ;
  +	for ( i = 0 ; i < l+1 ; i++ )  {
  +		char c = i < l ? unicode[i] : 0 ;
  +		ascii[i] = c ;
  +	}
  +}
  +
  +static void copy_unicode_from_ascii(wchar_t* unicode,const char* ascii,int l )
  +{
  +	int   i ;
  +	for ( i = 0 ; i < l+1 ; i++ )  {
  +		wchar_t c = i < l ? ascii[i] : 0 ;
  +		unicode[i] = c ;
  +	}
  +}
  +
  +static int fileExists(const char* aFile)
  +{
  +	wchar_t sFile[FILENAME_MAX+1] ;
  +	copy_unicode_from_ascii(sFile,aFile,strlen(aFile) ) ;
  +	return  GetFileAttributesW(sFile) != INVALID_FILE_ATTRIBUTES ? TRUE : FALSE ;
  +}
  +
  +static int access(const char *path, int mode)
  +{
  +	return fileExists(path) ? 0 : -1 ;
  +}
  +
  +int main(int argc,char* argv[]) ; // prototype declaration of main
  +
  +// the main entry point on Windows/CE is wmain (unicode version of main)
  +int wmain(int argc,wchar_t* argw[])
  +{
  +	int      result = 0 ;
  +
  +	// copy args from unicode to ascii
  +	int      a    ;
  +	char**   argv = (char**) malloc(argc*sizeof(wchar_t*));
  +	if ( argv ) {
  +		for ( a = 0 ; a < argc ; a ++ ) {
  +			int l = wcslen(argw[a]) ;
  +			argv[a] = malloc(l+1) ;
  +			if ( argv[a] ) copy_ascii_from_unicode(argv[a],argw[a],l) ;
  +			else result = -1 ;
  +		}
  +	}
  +
  +	if ( !result ) result = main(argc,argv) ;
  +
  +	// cleanup
  +	if ( argv )
  +		for ( a = 0 ; a < argc ; a ++ )
  +			if ( argv[a] )
  +				free( (void*) argv[a] ) ;
  +
  +	return result ;
  +}
  +#endif
  +
   #if defined(_WIN32_WCE)
   /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
    * thus we always assume that we have a console. That can be


2009-Oct-10 03:30:14 by anonymous:
Please post to the sqlite-users mailing list about this so other CE developers can clarify what is going on. Closing as this tracker is no longer used.
 
3551 new closed 2008 Dec anonymous   2009 Oct   4 3 pragma table_info, declared collation of the column
Can pragma table_info include the declared collation of the column? It's useful to be able to determine the full schema of a table.
2009-Oct-10 03:31:27 by anonymous:
Yes but it would break all existing software using the pragma so it won't be done. Please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3550 code closed 2008 Dec anonymous   2008 Dec   2 3 Problem in ATTACH or DETACH
Use sqlite3_exec to execute following SQL, error appear

sqlite3_exec(DB, "Attach 'PATH' As db",NULL,NULL,NULL);
sqlite3_exec(DB, "Detach db",NULL,NULL,NULL);
sqlite3_exec(DB, "Attach 'ANOTHER_PATH' As db",NULL,NULL,NULL);

database db is already in use
2008-Dec-23 10:53:21 by danielk1977:
Suggest upgrading to 3.6.7. Whatever the problem was, it appears to have been fixed:

  SQLite version 3.6.7
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> attach 'path' as db;
  sqlite> detach db;
  sqlite> attach 'another_path' as db;
  sqlite>
 
3549 code closed 2008 Dec danielk1977   2008 Dec danielk1977 1 1 Segfault in rtree code.
The following SQL script causes a crash:

  create table foo (id integer primary key);
  create virtual table bar using rtree (id, minX, maxX, minY, maxY);
  insert into foo values (null);
  insert into foo select null from foo;
  insert into foo select null from foo;
  insert into foo select null from foo;
  insert into foo select null from foo;
  insert into foo select null from foo;
  insert into foo select null from foo;
  delete from foo where id > 40;
  insert into bar select null,0,0,0,0 from foo;
  select count(*)
    from bar b1, bar b2, foo s1
    where b1.minX <= b2.maxX
    and s1.id = b1.id;
 
3548 code closed 2008 Dec anonymous   2008 Dec   3 3 "count() .. group by" stmt return nothing instead of 0 when no record
When executing the following SELECT statement, I expected it will return 0 , but got nothing.

sqlite> create table dual (col1 varchar2(16));
sqlite> select count(*) from dual group by col1;
sqlite>

When there is some record, the statement works fine.

sqlite> insert into dual values('test1');
sqlite> select count(*) from dual group by col1;
1
sqlite>

I just checked, and PosgreSQL does the same thing. So I think the current behavior is the correct behavior.
 
3547 code fixed 2008 Dec anonymous   2008 Dec   3 3 LL suffix breaking VC6 build
Version 3.6.7 of sqlite included a change in calculating Julian dates. Lines 11755 and 11857 of the amalgamation (sqlite-amalgamation-3_6_7.zip, from date.c) were changed from using the constant 2440587.5*86400000.0 to using the constant 210866760000000LL:

  -        p->iJD = p->iJD/86400.0 + 2440587.5*86400000.0;
  +        p->iJD = p->iJD/86400 + 210866760000000LL;

Visual C++ 6.0 in particular does not like the LL. Presumably using a 64-bit long instead of a double offers some performance increase, so I suggest instead of having the number in directly that it be #defined:

  #define JULIAN_EPOCH 210866760000000LL

This makes the code more readable, as well as allowing a workaround for compilers like VC6:

  #if (_MSC_VER == 1200)
   #define JULIAN_EPOCH 2440587.5*86400000.0
  #else
   #define JULIAN_EPOCH 210866760000000LL
  #endif /* _MSC_VER == 1200 */
2008-Dec-20 12:42:46 by anonymous:
Upon further investigation, removing the LL suffix allows VC6 to interpret 210866760000000 as an __int64 (which is the purpose LL suffix) and compile without complaint. I can't speak to how other compilers treat it, but seeing as how it has no decimal point and given its value it seems likely that it would be interpreted as a long long elsewhere as well. Instead of #if #else, I suggest merely dropping the suffix - I don't believe there is any ambiguity that would prompt an implied cast warning.

  @@ -11755, +11755 @@
  -  t = x.iJD/1000 - 210866760000LL;
  +  t = x.iJD/1000 - 210866760000;
  @@ -11857, +11857 @@
  -        p->iJD = p->iJD/86400 + 210866760000000LL;
  +        p->iJD = p->iJD/86400 + 210866760000000;


2008-Dec-20 17:17:52 by anonymous:
For the record, VC6 supports the "i64" and "ui64" suffix.
 
3546 warn fixed 2008 Dec anonymous   2008 Dec   4 4 Function sqlite3MemJournalSize should have "void" as the default param
Make the following changes to SQLite Amalgamation 3.6.7.

Line 11,036 should read: SQLITE_PRIVATE int sqlite3MemJournalSize(void);

Line 54, 241 should read: SQLITE_PRIVATE int sqlite3MemJournalSize(void){

 
3545 code fixed 2008 Dec anonymous   2008 Dec   4 4 Please add (void) to declaration of sqlite3MemJournalSize
Could you please add (void) to the declaration of sqlite3MemJournalSize (memjournal.c and sqliteInt.h):

  int sqlite3MemJournalSize(void)
                            ++++

It prevents a "no prototype" warning on CodeGear's C++ Compiler.

 
3544 code fixed 2008 Dec anonymous   2008 Dec   3 3 Die <Enter SQL statements terminated with a "/">
Test SQL statements terminated with a "/"

Result: "program hang-up" or "syntax error"

ex)

SQLite version 3.6.7

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> /

... sqlite3 program hang-up.

sqlite> select count(*) from users

   ...> /

   ...> ;

SQL error: near "/": syntax error

# I'm english to little ...

 
3543 code closed 2008 Dec anonymous   2008 Dec   2 2 Crash bug in icuOpen()
fts2_icu.c and fts3_icu.c both contain this line:
if( -1 == nInput ) nInput = strlen(nInput);

That crashes. It should be:
if( -1 == nInput ) nInput = strlen(zInput);

2008-Dec-18 05:31:06 by danielk1977:
I changed it in fts2. Could not find the problem in fts3.
 
3542 code fixed 2008 Dec anonymous   2008 Dec   1 1 Reproducable bus error on LP64 alignement critical architecture
It seems that on NetBSD/sparc64 (LP64, alignement critical) the btree code manages to create only 4 byte aligned pointers - which then cause a bus error on this platform. There is a NetBSD ticket about this problem.

I can reliably reproduce it by running the fulltest target. Here is some gdb output:

  Core was generated by `testfixture'.
  Program terminated with signal 10, Bus error.
  #0  0x000000000015dc44 in balance_nonroot (pCur=0x420084a8) at sqlite3.c:38997
  38997       p->aData = (void*)&p[1];
  (gdb) list
  38992     ** process of being overwritten.
  38993     */
  38994     for(i=0; i<nOld; i++){
  38995       MemPage *p = apCopy[i] = (MemPage*)aCopy[i];
  38996       memcpy(p, apOld[i], sizeof(MemPage));
  38997       p->aData = (void*)&p[1];
  38998       memcpy(p->aData, apOld[i]->aData, pBt->pageSize);
  38999     }
  39000
  39001     /*
  (gdb) print p
  $1 = (MemPage *) 0x40f51ab4

szCells is only 4 byte aligned here (which would be good enough for a 2 byte cell, of course); nMaxCells is 84 (so properly divisible by four) and the difference between szCells a the page pointer is divisible by eight - but given that szCells % 8 is 4, we still loose.

I can give more details if needed (still have the core file around) and easily try patches.

Thanks,

Martin Husemann

 
3541 code fixed 2008 Dec drh   2008 Dec   1 1 Use of ~ operator on repeated aggregate terms causes incorrect result.
The following SQL generates an incorrect results:

  CREATE TABLE t1(x);
  INSERT INTO t1 VALUES(123);
  SELECT CASE ~max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1;

It appears that the ~max(x) value replaces the original max(x) value and then the ELSE clause ends up using ~max(x) instead of max(x) as written. Hence, -124 is returned instead of the correct answer of 123.

 
3540 todo closed 2008 Dec anonymous   2008 Dec   1 2 Impossible to determine field type INTEGER PRIMARY KEY using PRAGMA
I am trying to use libdbi + sqlite for my project. It is impossible for libdbi to determine the PRIMARY KEY type (64bit) using PRAGMA table_info(). This has completely crippled my project that relies on autoincrement.

As the PRIMARY KEY is an alias to ROWID (64bit), the data should be returned as a 64bit integer. Unfortunately the PRAGMA command returns a type of INTEGER (32 bit). It is also impossible to help by defining primary key as BIGINT PRIMARY KEY, as the field does not then autoincrement.

sqlite> CREATE TABLE test(id BIGINT PRIMARY KEY AUTOINCREMENT); SQL error: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY

As the PRIMARY KEY is really ROWID (64bit), shouldn't I be able to define it as BIGINT and still have it autoincrement? This would then mean it will be returned via the PRAGMA statement as BIGINT and DB independant libraries can return the correct datatype and also be SQL compatible with other DB engines.

This is a real showstopper for me, I want to use sqlite, but have an easy way of supporting other db engines. Thank you for listening.

2008-Dec-14 17:14:07 by danielk1977:
Probably because I haven't used libdbi, this problem is opaque to me. It seems like the kind of thing that would be better suited to the mailing list. Details here:

  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


2008-Dec-14 21:07:59 by anonymous:
Consider moving a table from sqlite to mysql let's say through the dump command (.d), INTEGER PRIMARY KEY is only 32bits on mysql but the ROWID in sqlite is 64 bits, replaying the dump data into mysql will result in overflow. To have a seamless migration CREATE TABLE test(id BIGINT PRIMARY KEY) is needed to reflect the true length of ROWID (64bits). Please consider this patch which completely solves all problems, PRAGMA table_info now reports the BIGINT datatype for PRIMARY KEY fixing libdbi.

Against sqlite-3.6.2.

  --- build.c.old 2008-12-14 20:53:19.000000000 +0000
  +++ build.c     2008-12-14 16:29:03.000000000 +0000
  @@ -1165,7 +1165,7 @@
     if( iCol>=0 && iCol<pTab->nCol ){
       zType = pTab->aCol[iCol].zType;
     }
  -  if( zType && sqlite3StrICmp(zType, "INTEGER")==0
  +  if( zType && (sqlite3StrICmp(zType, "INTEGER")==0 ||   sqlite3StrICmp(zType, "BIGINT")==0)
           && sortOrder==SQLITE_SO_ASC ){
       pTab->iPKey = iCol;
       pTab->keyConf = onError;
  @@ -1174,7 +1174,7 @@
     }else if( autoInc ){
   #ifndef SQLITE_OMIT_AUTOINCREMENT
       sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
  -       "INTEGER PRIMARY KEY");
  +       "INTEGER or BIGINT PRIMARY KEY");
   #endif
     }else{
       sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);


2008-Dec-14 21:38:01 by drh:
One of the key promises that SQLite makes is backwards compatibility. A database file created with SQLite version 3.0.0 shall be readable and writable by SQLite version 3.6.7. But with the suggested patch, that would no longer be the case for any database contained a "BIGINT PRIMARY KEY". Hence, the supplied patch is a non-starter.

An SQLite database has the concept of a "file format version number". We could increment this version number (from 4 to 5) and specify that BIGINT PRIMARY KEY works the same as INTEGER PRIMARY KEY for file format versions 5 and greater. That would be a more complicated patch, though it would solve the backwards compatibility issue. But it creates a forwards compatibility issue. Specifically, old versions of SQLite would be unable to read and write database files created by newer versions of SQLite. We did that once before in SQLite version 3.3.0 - to add support for descending indices. The result was a big mess. Countless users encountered problems reading newer database files with older versions of SQLite. We eventually had to change SQLite so that it generates new database files in the old file format by default in order to preserve forwards compatibility. Version 3.3.0 is two years old, but there are still pre-3.3.0 versions of SQLite in wide circulation, and so to this day SQLite version 3.6.6.2 still generates format 1 database files by default, instead of the more powerful format 4 databases. We are not eager to create another file format discontinuity with its resulting confusion and complication. We will need a very good reason to increment the file format version number, and this ticket does not rise to the level of a very good reason.

Sorry to disappoint.


2008-Dec-14 22:58:17 by anonymous:
sqlite already supports BIGINT PRIMARY KEY, all that happens is the autoincrement doesn't function, which there is no reason for it not to do so as it is a 64bit INTEGER (ROWID), i.e. a BIGINT. As far as I can see there is no backwards compatibility issue. Please advise. Here is the unpatched version honouring BIGINT PRIMARY KEY.

  # sqlite3
  SQLite version 3.6.2
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> CREATE TABLE test(id BIGINT PRIMARY KEY AUTOINCREMENT);
  SQL error: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY
  sqlite> CREATE TABLE test(id BIGINT PRIMARY KEY, t TEXT);
  sqlite> INSERT INTO test(t) VALUES (1);
  sqlite> .d
  BEGIN TRANSACTION;
  CREATE TABLE test(id BIGINT PRIMARY KEY, t TEXT);
  INSERT INTO "test" VALUES(NULL,'1');
  COMMIT;
  sqlite>
 
3539 code closed 2008 Dec anonymous   2008 Dec   3 3 Segmentation/bus error when creating complex view
I managed to crash the engine, at least the version 3.6.6.2 one. I would like to have it stopped me, like the 3.5.9 version did. Below is a minimal example.

  $ sqlite3
  SQLite version 3.5.9
  Enter ".help" for instructions
  sqlite> CREATE TABLE t1 (c1);
  sqlite> CREATE VIEW v1 AS SELECT c1 FROM (SELECT t1.c1 FROM t1);
  SQL error: no such column: c1
  sqlite> .q
  $
  $ /usr/local/bin/sqlite3
  SQLite version 3.6.6.2
  Enter ".help" for instructions
  Enter SQL statements terminated with a ";"
  sqlite> CREATE TABLE t1 (c1);
  sqlite> CREATE VIEW v1 AS SELECT c1 FROM (SELECT t1.c1 FROM t1);
  Segmentation fault
  $
2008-Dec-14 14:30:43 by danielk1977:
Looks like this problem was fixed as part of [5940] . The upcoming 3.6.7 version should work.
 
3538 code closed 2008 Dec anonymous   2009 Oct   1 1 Decimal columns do integer division if no decimal places in numerator
Consider the following example session:

  CREATE TABLE book (
      "id" integer NOT NULL PRIMARY KEY,
      "name" varchar(300) NOT NULL,
      "pages" integer NOT NULL,
      "price" decimal NOT NULL
  );

  INSERT INTO book VALUES (1,"Book 1",447,30.0);
  INSERT INTO book VALUES (2,"Book 2",447,30.1);

  SELECT name, price, pages, (price/pages) AS price_per_page FROM book;

This yields the following output:

  Book 1|30|447|0
  Book 2|30.1|447|0.067337807606264

The price_per_page for Book 1 should be 0.06711, not 0. It appears that the decimal value for price (30.0) is interpreted as "30", and since this can be interpreted as an integer, the division is performed as integer division.

2008-Dec-14 12:21:54 by drh:
SQLite does not understand the DECIMAL type, so it substitutes NUMERIC. And NUMERIC converts floating point values (ex: 30.0) into integers when it can in order to save space on disk. We'll have to study this closely to see if it is something we want to change or not. In the meantime, you can work around your problem by using REAL or FLOAT or DOUBLE in place of DECIMAL.

2008-Dec-16 21:56:00 by knu:
Just a remark: Money amounts are best stored in cents or tenths of cents in systems that don't know a 'valuta' data type, especially for bookkeeping. The presentation layer can take care of proper presentation. Ask your accountant why.
In your example, using cents would yield 6 (presentation: 0.06) per page, using tenths of cents 67 (presentation: 0.067 or 0.07, depending on your rounding rules).


2009-Oct-10 03:35:19 by anonymous:
SQLite is working as designed and documented although you do have a point. Please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3537 code active 2008 Dec anonymous   2008 Dec   5 4 sqlite3_bind_text + SQLITE_TRANSIENT + different encoding
If sqlite3_bind_text() or sqlite3_bind_text16() is called with SQLITE_TRANSIENT on database with different encoding data is copied twice. First time in sqlite3VdbeMemSetStr() possibly allocating new memory, second time in sqlite3VdbeMemTranslate() allways with call to sqlite3DbMallocRaw(). In that case sqlite3VdbeMemTranslate() can copy original data avoiding sqlite3VdbeMemGrow() + memcpy() in sqlite3VdbeMemSetStr().
 
3536 code fixed 2008 Dec drh   2008 Dec   1 1 Incorrect evaluation of: WHERE rowid>922337236854775807
The clause: WHERE rowid>922337236854775807 always evalutes to true. Example:

   CREATE TABLE t1(x);
   INSERT INTO t1 VALUES('hello, world!');
   SELECT rowid, * FROM t1 WHERE rowid>922337236854775807;

All rows are returned, even though rowid is always less than or equal to 922337236854775807.

I suspect (but have not confirmed) what is happening is that SQLite is trying to evaluate

   ... WHERE rowid>922337236854775807

as this alternative expression:

   ... WHERE rowid>=(922337236854775807+1)

(Note the change of ">" into ">=".) But the addition overflows the integer to -922337236854775808 and every rowid is greater than or equal to that value.

2008-Dec-14 02:41:33 by anonymous:
In the checkin [6025] comments, don't you mean "# A simple magnitude sort" (not "# A simple magnitude source")? TC
 
3535 code closed 2008 Dec anonymous   2008 Dec   2 2 PRIMARY KEY constraint not enforced in case of null values
it is possible to insert multiple copies of a row with the same primary key when one of the primary key fields is NULL.

  CREATE TABLE a (b NOT NULL, c, d, PRIMARY KEY (b, c));
  INSERT INTO a VALUES (1, null, 2);
  INSERT INTO a VALUES (1, null, 2);

In my opinion the last statement should raise a constraint violation.

I found in the documentation that PRIMARY KEY should imply NOT NULL, but it doesn't for historical reasons; however I didn't expect this kind of side-effect.

2008-Dec-11 16:11:57 by drh:
This seems to be a duplicate of ticket #2746. See also the remarks on ticket #3463.
 
3534 new closed 2008 Dec anonymous   2009 Oct   4 4 sqlite3_stmt_status api include row change counters.
The count of changed rows is currently available at the connection level, by the sqlite3_changes and sqlite3_total_changes functions. In order to relate this data unambiguously to individual SQL statements, it might be as well included in the sqlite3_stmt_status api.
2008-Dec-15 01:18:47 by anonymous:
It would also be preferable for the profiling information to be available on a per statement basis rather than database global. Currently there is no way of correlating profiling with statements and their bindings (you get the text of the statement but not much else).

A suggested backwards compatible way of implementing this is to record the profiling information per statement if a profiler is registered against the database connection.


2009-Oct-10 03:36:37 by anonymous:
Please continue discussion on the sqlite-users mailing list.
 
3533 code closed 2008 Dec anonymous   2009 Oct   1 1 "NULL" string in CSV file is not treated as a NULL value
when you import from a csv file, the value NULL is treated like a string and if you have a field that is specified as not null and you do an .import command, sqlite will take in the value even though that field might be NULL. It treats it as if it not null.
2008-Dec-11 11:28:44 by anonymous:
How is it supposed to know that you really wanted NULL and not the string NULL? CSV doesn't support NULL anyway. You could make your exporter use an empty value instead. Or after import fixup the data with one query:

  UPDATE table SET column=null WHERE column='NULL'


2009-Oct-11 05:40:16 by anonymous:
There are other workarounds too such as using temporary tables and CASE. This tracker is now closed - please continue discussion on the sqlite-users mailing list.
 
3532 doc closed 2008 Dec anonymous   2009 Oct   3 3 lang_select.html claims conformance to sql-92 join syntax
The following sentence from lang_select.html gives the wrong implication:

  The full SQL-92 join syntax can also be used to specify joins.

A casual reader coming across that sentence would not understand that right and outer joins are not implemented (as documented on the omitted.html page). I recommend that the sentence be rewritten as:

  The full SQL-92 join syntax can also be used to specify joins; however, be aware that RIGHT and OUTER joins are not currently supported and sqlite will XXX if these are specified.

(for some value of XXX)

2009-Oct-11 05:55:18 by anonymous:
The syntax diagrams make this clear. This tracker is now closed - please continue discussion on the sqlite-users mailing list.
 
3531 code closed 2008 Dec anonymous   2009 Oct   3 4 Command line client hides value types
By default, the command line client hides type information:

  sqlite> select x'33', '3', 3;
  3|3|3

This can be confusing, as in:

  sqlite> select x, x='foo' from ... where x like 'foo';
  foo|0

(which happens when x is cast('foo' as blob)). It should be using the appropriate literal syntax for each type. This would give:

  sqlite> select x'33', '3', 3;
  X'33'|'3'|3

and:

  sqlite> select x, x='foo' from ... where x like 'foo';
  X'foo'|0

There is currently no rendering mode which preserves type information. This problem has related problems in the other output rendering modes.

".mode csv", ".mode tabs", ".mode insert", ".mode line" and ".mode list" have the same problem. It means that data can't be exported without loss of type information (which is particularly unexpected in ".mode insert").

".mode html" doesn't help, and has the weakness that '>' isn't escaped, which makes parsing harder. It should use &#xhh; escaping for blobs. If it used &lt; (as it does) and &gt; for escaping '<' and '>' then text and blobs could then be reliably distinguished by the rule "if it starts &# it's a blob" (except for the empty string).

".mode tcl" is worse, since it doesn't escape double-quotes, so you get invalid output (unterminated strings):

  sqlite> .mode tcl
  sqlite> .separator ' '
  sqlite> select '"';
  """

Tcl mode should at least escape double-quotes, and could use Tcl's \xhh escaping on all bytes to identify blobs. If it also used \\ and \042 to escape backslashes and double-quotes in text mode then (non-empty) text and blobs could be reliably distinguished by the rule "if it starts \x it's a blob".

There are space and legibility benefits in not escaping binary data, so it might be worth having a .typedliterals option (or similar) to control this, reflecting whether legibility or correctness was more important to the user.

.dump does preserve type information.

  sqlite> create table foo(x);
  sqlite> insert into foo(x) select cast('foo' as blob);
  sqlite> .dump
  BEGIN TRANSACTION;
  CREATE TABLE foo(x);
  INSERT INTO "foo" VALUES(X'666F6F');
  COMMIT;


2009-Jun-14 23:24:13 by anonymous:
Using quote() isn't satisfactory?

	sqlite> SELECT 'foo';
	foo
	sqlite> SELECT x'abcd';
	«Í

	sqlite> SELECT quote('foo');
	'foo'
	sqlite> SELECT quote(x'abcd');
	X'ABCD'


2009-Jun-14 23:25:41 by anonymous:
Sorry, the "«Í" was supposed to be "«Í".


2009-Jun-14 23:26:33 by anonymous:
Well, it just doesn't work -- just imagine two characters there.


2009-Oct-04 23:23:41 by anonymous:
It isn't clear that the shell should output blobs at all except in insert mode and dumps. They are a bag of bytes and hence have no textual meaning. If you want them as text then quote or cast them.

http://www.sqlite.org/src/tktview?name=72adc99de9

Closing as the issue isn't clear and this bug tracker is no longer used. Please continue any further discussion on the sqlite-users mailing list.

 
3530 code fixed 2008 Dec shane   2008 Dec drh 1 3 assertion failure referencing outer correlation in an inner FROM
Examle SQL:

   CREATE TABLE tab0(col0 INTEGER, col1 INTEGER);
   CREATE TABLE tab1(col0 INTEGER, col1 INTEGER);
   INSERT INTO tab0 VALUES(32,27);
   SELECT cor0.col1 FROM ( tab0 INNER JOIN tab1 ON NULL <= cor0.col0 ) AS cor0;

   Assertion failed: pC!=0, file c:\work\sqlite\sqlite\src\vdbe.c, line 2001
2008-Dec-09 11:59:26 by drh:
Simpler example:

   CREATE TABLE t(a);
   INSERT INTO t VALUES(1);
   SELECT * FROM (SELECT * FROM t WHERE 5<=x.a) AS x;
 
3529 new closed 2008 Dec anonymous   2009 Oct   3 5 Progress callback not invoked by PRAGMA integrity_check
A progress handler set up by

  sqlite3_progress_handler();

is never invoked when executing

  PRAGMA integrity_check;

Especially for larger databases, is can take quite a while to check the database integrity so many users would very much appreciate a progress indicator.

Could you please add the missing call to the SQLite source?

2008-Dec-08 14:07:51 by drh:
The progress callback is invoked periodically by the virtual machine after a preset number of VM opcodes are evaluated. But the PRAGMA integrity_check is a single opcode.

So what you are asking for is that we either reimplement integrity_check to use multiple opcodes, or else we reimplement the progress callback so that it can be invoked internally by the integrity_check subroutine. Either change is a great amount of work that ends up complicating the source code and provides only marginal benefit.

We have your enhancement request. But please understand that it will be low-priority.


2008-Dec-08 20:36:20 by anonymous:
Many thanks!


2009-Oct-11 05:44:40 by anonymous:
Now http://www.sqlite.org/src/tktview/ed2ff2f4eff549b62053ee82940933254d13ef27
 
3528 todo closed 2008 Dec anonymous   2008 Dec   1 4 Crashed ssh session on Xen causes disk I/O error on SQLite query
I was running a Python script in a Xen VM, adding rows to an SQLite DB. sshd timed-out the session, killing the script in the process. When I reconnected, I got this:

  $ fgrep abcdefghijklxxx pal.db
$ fgrep abcdefghijklxxx pal.db-journal
$ sqlite3 pal.db
-- Loading resources from /home/jim/.sqliterc
SQLite version 3.6.4
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select max(logid) from logs;
SQL error: disk I/O error
sqlite> ^D
$ uptime
 18:38:26 up 62 days,  7:24,  2 users,  load average: 0.00, 0.02, 0.00
$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              9805144   1304260   8002812  15% /
$

The disk is not full, the DB and journal can be read okay by Unix programs (fgrep), but SQLite fails on a query. I have only been using SQLite for a week or so, so not an expert. In this program, the sqlite3 Python module is being used, and I'm committing every 5 seconds. If this script had run to completion, there would be around 70K rows in the biggest table. The total DB size would be somewhere around 30MB, with 4-5 tables.

I expected there would be a rollback and some uncommitted rows would be lost, but don't know how to recover from a disk I/O error.

Thanks, Jim

2008-Dec-08 03:19:14 by anonymous:
Sorry, I believe this is my fault.

I created this DB as root, the session died, and then I was trying to access the DB as non-root, so SQLite couldn't do the rollback because I only had read access to the database.

It struck me that this was the problem when I recreated the DB and tried to use vacuum as non-root: it said "attempt to write a read-only database".

Perhaps as an enhancement, there could be a better error message when there is a hot journal but the rollback can't proceed because of an access problem. The read-only error above would have alerted me to the problem.

Thanks again for SQLite. So far, it's been very easy/fun to work with!

Jim

 
3527 code fixed 2008 Dec anonymous   2008 Dec   2 3 access violation / segfault when using multiple view subqueries
SQLite can overflow the table aAlias in the Parse structure and generates invalid register numbers in the VDBE instructions:

  317|Rewind|3|338|0||00|
  318|Column|3|0|18||00|ElemOr.CodeOr
  319|MustBeInt|18|337|0||00|
  320|NotExists|4|337|18||00|pk
  321|SCopy|4427840|82|0||00|	<<<<<<<<<  invalid register
  322|Rowid|4|83|0||00|
  323|Column|4|1|84||00|Element.Name

This happens when:

  Multiple sub-queries are views with ORDER BY clauses
  The sub-queries cannot be 'flattened' into the main query
  The sub-queries have aliases which are stored in a register target by the CodeAlias() function in expr.c

A reproducible case from Alessandro Merolli's mailing list post http://article.gmane.org/gmane.comp.db.sqlite.general/43108 is attached as repro.sql

It is tempting to just ignore ORDER BY in sub-queries, but they may be intentional if the sub-queries execute functions with side effects that should happen in a particular order.

A proposed patch to expr.c and sqliteInt.h is attached which allows the alias table to expand when necessary rather than overflowing the table created by the first call to CodeAlias().

 
3526 warn closed 2008 Dec anonymous   2008 Dec   1 1 warnings
1>d:\visual studio 2008\sqlite\sqlite3.c(597) : warning C4132: 'sqlite3_version' : const object should be initialized
1>d:\visual studio 2008\sqlite\sqlite3.c(7582) : warning C4132: 'sqlite3one' : const object should be initialized
1>d:\visual studio 2008\sqlite\sqlite3.c(11524) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11525) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11526) : warning C4244: '=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11529) : warning C4244: '+=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11643) : warning C4244: '=' : conversion from 'sqlite3_int64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11644) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11647) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11648) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11649) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11650) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11667) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11712) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11718) : warning C4244: '=' : conversion from 'double' to 'time_t', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11760) : warning C4244: 'return' : conversion from 'sqlite3_int64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11792) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11820) : warning C4244: '=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11846) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11933) : warning C4244: '+=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11935) : warning C4244: '+=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11937) : warning C4244: '+=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11939) : warning C4244: '+=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11943) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11949) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11951) : warning C4244: '+=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11955) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(11994) : warning C4244: '=' : conversion from 'double' to 'sqlite3_int64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(12163) : warning C4244: 'function' : conversion from 'u64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(12194) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(12886) : warning C4244: 'return' : conversion from 'sqlite3_int64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(15688) : warning C4100: 'p' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(15796) : warning C4244: '=' : conversion from 'sqlite3_int64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17007) : warning C4244: 'function' : conversion from 'long double' to 'double', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17067) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17082) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17105) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17108) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17143) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17145) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17192) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17193) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17281) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17552) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(17584) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(18503) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(18750) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(18895) : warning C4244: '=' : conversion from 'long double' to 'double', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(19082) : warning C4244: '=' : conversion from 'u64' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(19119) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(19393) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(19394) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(19395) : warning C4244: '=' : conversion from 'u32' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(19433) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(26058) : warning C4100: 'flags' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26273) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(26338) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(26365) : warning C4100: 'id' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26372) : warning C4100: 'id' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26514) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26662) : warning C4100: 'syncDir' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26660) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26703) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26750) : warning C4100: 'nFull' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26820) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26840) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26850) : warning C4152: nonstandard extension, function/data pointer conversion in expression
1>d:\visual studio 2008\sqlite\sqlite3.c(26843) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26853) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26904) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26922) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(26978) : warning C4100: 'pVfs' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(28560) : warning C4308: negative integral constant converted to unsigned type
1>d:\visual studio 2008\sqlite\sqlite3.c(28560) : warning C4307: '*' : integral constant overflow
1>d:\visual studio 2008\sqlite\sqlite3.c(28603) : warning C4308: negative integral constant converted to unsigned type
1>d:\visual studio 2008\sqlite\sqlite3.c(28603) : warning C4307: '*' : integral constant overflow
1>d:\visual studio 2008\sqlite\sqlite3.c(29482) : warning C4244: 'initializing' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(29969) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(29975) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30176) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(30198) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30211) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30335) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30351) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30637) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30642) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30652) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30656) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30657) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30658) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30729) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30841) : warning C4244: '=' : conversion from 'i64' to 'Pgno', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30849) : warning C4244: '=' : conversion from 'i64' to 'Pgno', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30852) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(30904) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(32881) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(32911) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34204) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34206) : warning C4244: 'function' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34486) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34493) : warning C4244: '=' : conversion from 'u32' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34498) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34517) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34519) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34521) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34633) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34633) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34636) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34636) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34676) : warning C4244: '-=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34689) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34692) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34692) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34712) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34712) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34755) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34755) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34756) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34756) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34757) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34757) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34758) : warning C4244: '+=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34773) : warning C4244: '-=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34775) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34775) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34787) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34787) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34809) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34816) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34817) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34821) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34822) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34865) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34891) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34938) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34942) : warning C4244: '=' : conversion from 'u16' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34943) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34945) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(34946) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35226) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35253) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35264) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(35353) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(35531) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35535) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35586) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35665) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(35678) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35679) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35687) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35688) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35797) : warning C4244: '=' : conversion from 'u16' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35800) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(35986) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(36048) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(36736) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37099) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37306) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37660) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37662) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37691) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37693) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37698) : warning C4244: 'function' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37699) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37725) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37742) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(37769) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38391) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38393) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38416) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38505) : warning C4244: '=' : conversion from 'u16' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38556) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38591) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38591) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38592) : warning C4244: '=' : conversion from 'u16' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38641) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38641) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38646) : warning C4244: '-=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38648) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38648) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(38655) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(39027) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(39060) : warning C4244: '-=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(40436) : warning C4244: '=' : conversion from 'u32' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(40692) : warning C4244: '+=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41058) : warning C4244: 'initializing' : conversion from 'sqlite3_int64' to 'Pgno', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41139) : warning C4244: 'initializing' : conversion from 'i64' to 'Pgno', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41519) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41613) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41621) : warning C4244: 'function' : conversion from 'i64' to 'size_t', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41622) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41858) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(41962) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(42105) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(42160) : warning C4244: '=' : conversion from 'const i64' to 'double', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(42165) : warning C4244: '=' : conversion from 'const i64' to 'double', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(42504) : warning C4244: 'return' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(42661) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(43055) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(43085) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(43304) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(44450) : warning C4244: 'return' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(44466) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(44587) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(44899) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(44944) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(45282) : warning C4244: 'return' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(45444) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(45461) : warning C4244: '=' : conversion from 'double' to 'i64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(45479) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(45492) : warning C4244: '=' : conversion from 'double' to 'u64', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(46060) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(47033) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(47035) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(47177) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(47192) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(47518) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(47528) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(47625) : warning C4244: '=' : conversion from 'i64' to 'double', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(47726) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(47728) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(48415) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48689) : warning C4244: '+=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48712) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48724) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48729) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48820) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48823) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48954) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(48958) : warning C4244: '=' : conversion from 'i64' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(49094) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(49248) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(49361) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(49884) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50028) : warning C4244: '=' : conversion from 'i64' to 'u32', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50123) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50178) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50224) : warning C4244: '=' : conversion from 'int' to 'Bool', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50288) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50373) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50662) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50668) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(50912) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(50914) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(50976) : warning C4244: 'initializing' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(51052) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51057) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51114) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(51115) : warning C4244: '=' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(51127) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51139) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51170) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51175) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51216) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51231) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51268) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51280) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51305) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51312) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51360) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51367) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(51635) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(52578) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(52996) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(52998) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(53265) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(53369) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(53380) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(53869) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(53951) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(54076) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(54254) : warning C4389: '==' : signed/unsigned mismatch
1>d:\visual studio 2008\sqlite\sqlite3.c(54737) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(55739) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(57483) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(58171) : warning C4244: 'function' : conversion from 'i16' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(58643) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(59246) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(59369) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(59374) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(59392) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(59398) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(59604) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(59783) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(60535) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(60602) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(60613) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(60859) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(61096) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(61112) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(61152) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(61205) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(61475) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(61652) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(61660) : warning C4244: '+=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(61987) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(62020) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(62180) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(62574) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(63494) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(63530) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(63555) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(63575) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(64067) : warning C4244: 'function' : conversion from 'i64' to 'int', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(64194) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(64345) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(64534) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(66052) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(66487) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(67334) : warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'int (__cdecl *)(sqlite3 *,char **,const sqlite3_api_routines *)'
1>d:\visual studio 2008\sqlite\sqlite3.c(67537) : warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'int (__cdecl *)(sqlite3 *,char **,const sqlite3_api_routines *)'
1>d:\visual studio 2008\sqlite\sqlite3.c(67690) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(67990) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(68050) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(68107) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(68246) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(68246) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(68246) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(68277) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(68544) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(68576) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(69085) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(69117) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(69203) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(69443) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(69527) : warning C4127: conditional expression is constant
1>d:\visual studio 2008\sqlite\sqlite3.c(69759) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(70478) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(71306) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(71454) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(71812) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(71835) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(71875) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(72553) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(73151) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(73735) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(74283) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77030) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77547) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77548) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77549) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77564) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77574) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77575) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77578) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77600) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77671) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77727) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77728) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77757) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77758) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(77760) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(78123) : warning C4244: '=' : conversion from 'u16' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(78411) : warning C4244: 'function' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(78680) : warning C4244: 'function' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(79630) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(79854) : warning C4132: 'yyzerominor' : const object should be initialized
1>d:\visual studio 2008\sqlite\sqlite3.c(81173) : warning C4244: 'function' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(81235) : warning C4100: 'yypMinor' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(81283) : warning C4244: '=' : conversion from 'int' to 'unsigned short', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(81284) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(81973) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82034) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82113) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82119) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82461) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82473) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82669) : warning C4244: 'function' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82679) : warning C4244: '=' : conversion from 'int' to 'unsigned short', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82680) : warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82716) : warning C4100: 'yymajor' : unreferenced formal parameter
1>d:\visual studio 2008\sqlite\sqlite3.c(82806) : warning C4244: 'function' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(82893) : warning C4244: 'function' : conversion from 'int' to 'unsigned char', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(84306) : warning C4244: '=' : conversion from 'int' to 'u16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(84823) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(84835) : warning C4244: 'function' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(84845) : warning C4244: '=' : conversion from 'int' to 'i16', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(85265) : warning C4244: '=' : conversion from 'int' to 'u8', possible loss of data
1>d:\visual studio 2008\sqlite\sqlite3.c(16916) : warning C4701: potentially uninitialized local variable 'xtype' used
1>d:\visual studio 2008\sqlite\sqlite3.c(26020) : warning C4701: potentially uninitialized local variable 'wrote' used
1>d:\visual studio 2008\sqlite\sqlite3.c(26696) : warning C4701: potentially uninitialized local variable 'error' used
1>d:\visual studio 2008\sqlite\sqlite3.c(26737) : warning C4701: potentially uninitialized local variable 'rc' used
1>d:\visual studio 2008\sqlite\sqlite3.c(28262) : warning C4706: assignment within conditional expression
1>d:\visual studio 2008\sqlite\sqlite3.c(28354) : warning C4706: assignment within conditional expression
1>d:\visual studio 2008\sqlite\sqlite3.c(31336) : warning C4701: potentially uninitialized local variable 'isHotJournal' used
1>d:\visual studio 2008\sqlite\sqlite3.c(31236) : warning C4701: potentially uninitialized local variable 'locked' used
1>d:\visual studio 2008\sqlite\sqlite3.c(37012) : warning C4701: potentially uninitialized local variable 'rc' used
1>d:\visual studio 2008\sqlite\sqlite3.c(47241) : warning C4701: potentially uninitialized local variable 'pOut' used
1>d:\visual studio 2008\sqlite\sqlite3.c(47177) : warning C4701: potentially uninitialized local variable 'pIn1' used
1>d:\visual studio 2008\sqlite\sqlite3.c(47505) : warning C4701: potentially uninitialized local variable 'pIn2' used
1>d:\visual studio 2008\sqlite\sqlite3.c(48067) : warning C4701: potentially uninitialized local variable 'pIn3' used
1>d:\visual studio 2008\sqlite\sqlite3.c(48581) : warning C4701: potentially uninitialized local variable 'sMem' used
1>d:\visual studio 2008\sqlite\sqlite3.c(48492) : warning C4701: potentially uninitialized local variable 'avail' used
1>d:\visual studio 2008\sqlite\sqlite3.c(37526) : warning C4701: potentially uninitialized local variable 'pPage' used
1>d:\visual studio 2008\sqlite\sqlite3.c(39857) : warning C4701: potentially uninitialized local variable 'pLeafPage' used
1>d:\visual studio 2008\sqlite\sqlite3.c(40397) : warning C4701: potentially uninitialized local variable 'pDbPage' used
1>d:\visual studio 2008\sqlite\sqlite3.c(52229) : warning C4706: assignment within conditional expression
1>d:\visual studio 2008\sqlite\sqlite3.c(64204) : warning C4701: potentially uninitialized local variable 'aLen' used
1>d:\visual studio 2008\sqlite\sqlite3.c(64205) : warning C4701: potentially uninitialized local variable 'azChar' used
1>d:\visual studio 2008\sqlite\sqlite3.c(64208) : warning C4701: potentially uninitialized local variable 'len' used
1>d:\visual studio 2008\sqlite\sqlite3.c(64220) : warning C4701: potentially uninitialized local variable 'len' used
1>d:\visual studio 2008\sqlite\sqlite3.c(55946) : warning C4701: potentially uninitialized local variable 'pTest' used
1>d:\visual studio 2008\sqlite\sqlite3.c(52755) : warning C4701: potentially uninitialized local variable 'piColMask' used
1>d:\visual studio 2008\sqlite\sqlite3.c(63099) : warning C4701: potentially uninitialized local variable 'iBeginBeforeTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(63100) : warning C4701: potentially uninitialized local variable 'iEndBeforeTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(63122) : warning C4701: potentially uninitialized local variable 'iBeginAfterTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(63123) : warning C4701: potentially uninitialized local variable 'iEndAfterTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(65409) : warning C4701: potentially uninitialized local variable 'regEof' used
1>d:\visual studio 2008\sqlite\sqlite3.c(65408) : warning C4701: potentially uninitialized local variable 'dest' used
1>d:\visual studio 2008\sqlite\sqlite3.c(65583) : warning C4701: potentially uninitialized local variable 'regFromSelect' used
1>d:\visual studio 2008\sqlite\sqlite3.c(65891) : warning C4701: potentially uninitialized local variable 'j2' used
1>d:\visual studio 2008\sqlite\sqlite3.c(73798) : warning C4701: potentially uninitialized local variable 'pTabList' used
1>d:\visual studio 2008\sqlite\sqlite3.c(73798) : warning C4701: potentially uninitialized local variable 'pEList' used
1>d:\visual studio 2008\sqlite\sqlite3.c(72023) : warning C4701: potentially uninitialized local variable 'addrOutB' used
1>d:\visual studio 2008\sqlite\sqlite3.c(75425) : warning C4701: potentially uninitialized local variable 'iBeginBeforeTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(75426) : warning C4701: potentially uninitialized local variable 'iEndBeforeTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(75497) : warning C4701: potentially uninitialized local variable 'iBeginAfterTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(75498) : warning C4701: potentially uninitialized local variable 'iEndAfterTrigger' used
1>d:\visual studio 2008\sqlite\sqlite3.c(76755) : warning C4701: potentially uninitialized local variable 'pArg' used
1>d:\visual studio 2008\sqlite\sqlite3.c(76754) : warning C4701: potentially uninitialized local variable 'xFunc' used
2008-Dec-07 04:27:11 by shane:
See http://www.sqlite.org/faq.html#q17

For an example of the hazards of mindlessly striving to eliminate warnings see http://it.slashdot.org/it/08/05/13/1533212.shtml

However, it should be noted that we've been making an effort recently to remove warnings so hopefully this list will get shorter.


2008-Dec-08 15:29:45 by anonymous:
But nobody asked that those warnings be mindlessly fixed. You could do it mindfully and we'd all be happy ;)
 
3525 build closed 2008 Dec anonymous   2009 Oct   2 2 sqlite3's tcl interface does not build with Tcl 8.6 (patch)
Per TIP #330 - http://www.tcl.tk/cgi-bin/tct/tip/330.html - Tcl 8.6 disallows the use of interp->result by default, and Tcl 9.0 will not allow it at all. sqlite3's tcl interface uses interp->result in several places. The attached patch fixes this in the recommended way, through the use of Tcl_GetStringResult .
2009-Oct-11 06:28:57 by anonymous:

    egrep -r 'interp\s*->\s*result' .

Shows not an issue any more. Please continue discussion on the sqlite-users mailing list as this tracker is now closed.

 
3524 doc closed 2008 Dec anonymous   2009 Oct   5 4 Wish item: examples in documentation
I like SQLite's documentation; the syntax diagrams help greatly.

One possible enhancement would be to include examples in the documentation. Examples are my favorite feature of the perl code repository (CPAN) and the php documentation website: I can do a quick cut-n-paste and then tweak to my heart's content.

Yes, I suppose I could google 'sql examples', but I'd rather have SQLite-specific examples.

Thanks!

2009-Oct-11 05:56:16 by anonymous:
That is what the wiki is for. This tracker is now closed - please continue discussion on the sqlite-users mailing list.
 
3523 doc closed 2008 Dec anonymous   2009 Oct   4 3 sqlite_docs_<version>.zip changes directory back and forth
  sqlite-3.5.3.ebuild: dohtml -r "${WORKDIR}"/${PN}-docs-${PV}/* || die
  sqlite-3.5.6.ebuild: dohtml -r "${WORKDIR}"/${PN}_docs_${PV}/* || die
  sqlite-3.5.9.ebuild: dohtml -r "${WORKDIR}"/${PN}-docs-${PV}/* || die
  sqlite-3.6.2.ebuild: dohtml -r "${WORKDIR}"/${PN}_docs_${DOC_PV}/* || die
  sqlite-3.6.6.2.ebuild:  dohtml -r "${WORKDIR}"/${PN}-${DOC_PV}-docs/* || die

As you can see the naming after unpacking the zip changes back and forth between sqlite-docs and sqlite_docs. Please stick to one naming scheme.

2009-Oct-11 06:02:39 by anonymous:
The code that generates this zip file is not part of the source (the other stuff is pushed to the website via publish.sh). This tracker is now closed - please continue discussion on the sqlite-users mailing list.
 
3522 code fixed 2008 Dec shane   2008 Dec drh 1 3 assertion with JOIN/USING with correlation
CREATE TABLE tab4(col0 INTEGER, col1 INTEGER, col2 INTEGER, col3 INTEGER, col4 INTEGER);
SELECT cor1.* FROM tab4 AS cor0 JOIN tab4 AS cor1 USING ( col4, col3, col2, col1, col0 );
Assertion failed: pEList!=0, file sqlite3.c, line 54346

Another example:

CREATE TABLE tab1(col0 INTEGER);
CREATE TABLE tab2(col0 INTEGER);
SELECT cor0.* FROM tab1 NATURAL JOIN tab2 AS cor0;
Assertion failed: pEList!=0, file sqlite3.c, line 54346

 
3521 todo closed 2008 Dec anonymous   2008 Dec danielk1977 3 1 memory leak in sqlite3_column_text
Our application is extracting data from a sqlite database using select statements. It calls sqlite3_column_text() several thousand times within seconds, and consumes giant amounts of memory doing so. The Windows task manager shows a heavliy growing memory usage (more than 1GB). We have isolated the problem, the memory leak has to be within sqlite. Our code is similar to this little example:

while( )
{
sqlite3_prepare_v2(sqlselect_str);
some_string = (const char*)sqlite3_column_text( stmt, 0 );
sqlite3_finalize();
do_something_string_value();
}

2008-Dec-04 20:17:24 by drh:
You cannot be calling sqlite3_column_text() until after you have called sqlite3_step(). Let us assume that you accidently omitted that step from your example.

The value returned by sqlite3_column_text() is only valid until the next sqlite3_step(), sqlite3_reset(), or sqlite3_finalize() call. (See the documentation.) So if you really are using the result of sqlite3_column_text() after you are calling sqlite3_finalize(), you are doing a very bad thing. This is equivalent to using a buffer obtained from malloc() after that buffer has been freed.

SQLite is very carefully checked for memory leaks. See for example http://www.sqlite.org/malloc.html. Something like this is very unlikely to have excaped our notice. If you can provide a real, working example of a memory leak, we will be happy to look into the matter. But based on the information you have provided, I must assume that the problem is in your code and not in SQLite.


2008-Dec-05 10:21:05 by anonymous:
My apology. After some more analysis I found that the error is indeed in our code (a finalize was missing somewhere else than where I was looking). Thank you for the quick reply, it was quite helpful.
 
3520 code closed 2008 Dec anonymous   2009 Oct   3 2 sqlite3_update_hook isn't called
  #include <stdio.h>
  #include "sqlite3.h"

  void hook(void *dummy,int type,char const *dbName,char const *tableName,sqlite_int64 rowid) {
    printf("%s %s\n", dbName, tableName);
  }

  int main() {
    sqlite3 *db;

    sqlite3_open("test.db", &db);
    sqlite3_update_hook(db, hook, NULL);
    sqlite3_exec(db, "create table t(a)", NULL, 0, 0);
    sqlite3_exec(db, "insert into t values(1)", NULL, 0, 0);
    sqlite3_exec(db, "create table t2 as select * from t", NULL, 0, 0);
    sqlite3_close(db);

    return 0;
  }

prints only:

main t

2008-Dec-04 12:08:46 by drh:
That looks to be correct. What were you expecting it to print?


2008-Dec-04 12:56:19 by anonymous:
I'v expected:

  main t
  main t2

One row is inserted and hook isn't called for CREATE TABLE AS SELECT. I wanted to use it instead of sqlite3_progress_handler() because it will report actual rows inserted not some opcodes that database user knows nothing about (I'm aware that during creation of ephemeral tables nothing will be reported).


2008-Dec-04 13:43:42 by drh:
OK. I missed the fact that you were initializing the table at the same time you were creating it.


2009-Oct-11 06:05:52 by anonymous:
Doesn't seem broken. Please continue discussion on the sqlite-users mailing list as this tracker is now closed.
 
3519 code fixed 2008 Dec anonymous   2008 Dec   1 1 Crash when deleting from a view
Executing these statements will crash sqlite3 on Linux (64 bit) and Windows (32 bit). The crash goes away when 't.id' is replaced by 'id' or when ' WHERE 1=1' is removed.

  CREATE TABLE t ( id );
  CREATE VIEW v AS SELECT t.id FROM t;
  CREATE TRIGGER td INSTEAD OF DELETE ON v FOR EACH ROW
  BEGIN
    DELETE FROM t;
  END;
  DELETE FROM v WHERE 1=1;
2008-Dec-04 09:59:44 by anonymous:
This is what valgrind says:

  DELETE FROM v WHERE 1=1;
  ==3045==
  ==3045== Invalid read of size 1
  ==3045==    at 0x4C250E0: memcpy (mc_replace_strmem.c:402)
  ==3045==    by 0x4E43EA1: sqlite3StrAccumAppend (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E4466B: sqlite3VXPrintf (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E46577: sqlite3VMPrintf (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E49727: sqlite3MPrintf (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E4A6CC: selectColumnsFromExprList (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E76010: selectExpander (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E32E8E: sqlite3WalkSelect (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E347E6: sqlite3SelectPrep (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E64090: sqlite3Select (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E670E9: sqlite3MaterializeView (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E773B8: sqlite3DeleteFrom (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
  ==3045==
  ==3045== Process terminating with default action of signal 11 (SIGSEGV)
  ==3045==  Access not within mapped region at address 0x1
  ==3045==    at 0x4C250E0: memcpy (mc_replace_strmem.c:402)
  ==3045==    by 0x4E43EA1: sqlite3StrAccumAppend (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E4466B: sqlite3VXPrintf (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E46577: sqlite3VMPrintf (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E49727: sqlite3MPrintf (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E4A6CC: selectColumnsFromExprList (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E76010: selectExpander (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E32E8E: sqlite3WalkSelect (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E347E6: sqlite3SelectPrep (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E64090: sqlite3Select (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E670E9: sqlite3MaterializeView (in /usr/lib/libsqlite3.so.0.8.6)
  ==3045==    by 0x4E773B8: sqlite3DeleteFrom (in /usr/lib/libsqlite3.so.0.8.6)
 
3518 code fixed 2008 Dec anonymous   2008 Dec   1 1 Crashes when building with -DSQLITE_OMIT_BLOB_LITERAL
If the amalgamation is built with -DSQLITE_OMIT_BLOB_LITERAL, crashes happen with queries involving in, like "select from .. where x IN (select ..)", maybe more. Crash occurs inside sqlite3VdbeExec (case OP_NotFound: case OP_Found: block), after calling sqlite3_prepare_v2 on the query and then sqlite3_step. If i recall well, pIn3->z is NULL.

The problem goes away when the build is done without the omission above.

 
3517 code fixed 2008 Dec anonymous   2008 Dec   3 2 memory leak in .import handling in shell.c
In the latest version of shell.c (up-to-date as of 2008-12-03), zLine is allocated on line 1253 (from the call to local_getline) and is freed on line 1280. However, there is a break on line 1273 in an error handler that could prevent zLine from being free'd. As a consequence, it seems that the free(zLine) on line 1280 should be moved adjacent to the free(azCol) on line 1288.
 
3516 doc fixed 2008 Dec anonymous   2008 Dec   4 4 Syntax diagram allows HAVING without GROUP BY
The select-stmt syntax diagram allows an HAVING clause without a GROUP BY clause, but sqlite rejects this.
http://www.sqlite.org/docsrc/vinfo/77ea14504b2516ce8889c9a19e5e2486c0873ab9
 
3515 code closed 2008 Dec drh   2009 Oct   1 1 INTERSECT operator should have higher precedence
All historical versions of SQLite have given INTERSECT, EXCEPT, and UNION operators in a compound query equal precedence - they group from left to right. Oracle does the same thing. But the SQL92 standard says that INTERSECT should have higher precedence than EXCEPT and UNION. All database engines other than Oracle and SQLite appear to work according to the standard. And Oracle says that they will change to conform in future releases. So SQLite should probably change too.
2008-Dec-03 01:36:48 by drh:
Turns out MySQL doesn't support EXCEPT or INTERSECT at all. Perhaps the reason nobody has yet complained about me getting the precedence of INTERSECT wrong in SQLite is that nobody has noticed because nobody ever uses INTERSECT or EXCEPT...


2008-Dec-04 14:26:42 by anonymous:
Now it looks like somebody does use it, or there would not be this ticket (I am neither using it at all, I am just thinking aloud)


2008-Dec-04 14:46:23 by anonymous:
Above poster: I just noticed that this ticket was created by drh... I thought at first that drh only replied to someone else... sorry for thinking aloud :-)


2008-Dec-04 14:55:36 by shane:
This issue was found internally using a new test utility, sqllogictest, which test queries against multiple DB engines (SQLite, MySQL, MSSQL, etc.) looking for differences.


2009-Oct-11 06:04:25 by anonymous:
Now http://www.sqlite.org/src/tktview/08595ca456baf51be9c117a7cf212ec26ff8285a
 
3514 code closed 2008 Nov anonymous   2009 Oct   2 3 sqlite3_analyzer reports weird numbers
sqlite3_analyzer built from the 3.6.6.2 sources reports lots of weird numbers (percentages > 100%, negative percentages, negative total numbers, etc.).

Here's an example output for a simple database:

		/** Disk-Space Utilization Report For /tmp/z.db
		*** As of 2008-Nov-28 10:03:21

		Page size in bytes.................... 1024
		Pages in the whole file (measured).... 70
		Pages in the whole file (calculated).. -1570845904
		Pages that store data................. -1570845904 -2244065577.1%
		Pages on the freelist (per header).... 0            0.0%
		Pages on the freelist (calculated).... 1570845974 2244065677.143%
		Pages of auto-vacuum overhead......... 0            0.0%
		Number of tables in the database...... 3
		Number of indices..................... 0
		Number of named indices............... 0
		Automatically generated indices....... 0
		Size of the file in bytes............. 71680
		Bytes of user payload stored.......... -16296576  -22735.2%

		*** Page counts for all tables with their indices ********************

		SQLITE_MASTER......................... -2108516   -3012165.7%
		T2.................................... -340525655 -486465221.4%
		T1.................................... -1228211733 -1754588190.0%

		*** All tables *******************************************************

		Percentage of total database.......... -2244065577.1%
		Number of entries..................... 1490
		Bytes of storage consumed............. 2066530304
		Bytes of payload...................... 2131165168 103.128%
		Average payload per entry............. 1430312.19
		Average unused bytes per entry........ 412.00
		Average fanout........................ 1.00
		Maximum payload per entry............. 0
		Entries that use overflow............. 1490       100.0%
		Index pages used...................... 3
		Primary pages used.................... 3
		Overflow pages used................... -1570845910
		Total pages used...................... -1570845904
		Unused bytes on primary pages......... 0            0.0%
		Unused bytes on overflow pages........ 613880       0.030%
		Unused bytes on all pages............. 613880       0.030%

		*** Table SQLITE_MASTER **********************************************

		Percentage of total database.......... -3012165.7%
		Number of entries..................... 2
		Bytes of storage consumed............. 2135846912
		Bytes of payload...................... 2147461744 100.544%
		Average payload per en