Re: [sqlite] sqlite_prepare returns SQLITE_OK but returns NULL statement
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sander Jansen wrote: > Ok, thanks. The reason I am asking this of course is whether this a > common thing to occur. I assumed the statement would always be > non-NULL if the prepare command return SQLITE_OK. I'll adjust my code > to assume it might be null and only raise error when prepare itself > returns an error as well. Prepare also returns NULL if the statement is empty/pure whitespace. Sadly step returns an error on being passed NULL. If you do any form of statement caching or user entered queries then you'll also get these nulls. Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFF58FAmOOfHg372QQRAgMMAJ41Jkd6EpKkh/gewZmrW/g47USHHgCbBQeG mOepO9A42g3Qe9m4VmN1B9I= =dBDD -END PGP SIGNATURE- - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite_prepare returns SQLITE_OK but returns NULL statement
Ok, thanks. The reason I am asking this of course is whether this a common thing to occur. I assumed the statement would always be non-NULL if the prepare command return SQLITE_OK. I'll adjust my code to assume it might be null and only raise error when prepare itself returns an error as well. Sander On 3/1/07, Dennis Cote <[EMAIL PROTECTED]> wrote: Sander Jansen wrote: > Using SqLite 3.3.3 I'm trying to prepare the following statement: > > "CREATE INDEX IF NOT EXISTS someindexname ON sometable(somecolumn);" > > It returns SQLITE_OK but returns a NULL statement. ( I think a newer > version doesn't have this behaviour). Does this actually mean that it > is a unsupported SQL query? If I remove > "IF NOT EXISTS" the prepare statement will actually return an error > saying the Index already exists. Sander, If the index already exists, then a null statement is all you need to create it. :-) I assume you are saying that sqlite3_prepare is setting the statement pointer to NULL. I think there was a bug report about this behavior in an earlier version (< 3.3.13) of sqlite. You might want to try it with a current version to see if you get the same behavior. As a work around, you could simply not execute (i.e. don't call sqlite3_step) a NULL statement. Now that I think about it, sqlite may already have that check in place so that sqlite_step(NULL) does nothing and returns. HTH Dennis Cote - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite_prepare returns SQLITE_OK but returns NULL statement
Sander Jansen wrote: Using SqLite 3.3.3 I'm trying to prepare the following statement: "CREATE INDEX IF NOT EXISTS someindexname ON sometable(somecolumn);" It returns SQLITE_OK but returns a NULL statement. ( I think a newer version doesn't have this behaviour). Does this actually mean that it is a unsupported SQL query? If I remove "IF NOT EXISTS" the prepare statement will actually return an error saying the Index already exists. Sander, If the index already exists, then a null statement is all you need to create it. :-) I assume you are saying that sqlite3_prepare is setting the statement pointer to NULL. I think there was a bug report about this behavior in an earlier version (< 3.3.13) of sqlite. You might want to try it with a current version to see if you get the same behavior. As a work around, you could simply not execute (i.e. don't call sqlite3_step) a NULL statement. Now that I think about it, sqlite may already have that check in place so that sqlite_step(NULL) does nothing and returns. HTH Dennis Cote - To unsubscribe, send email to [EMAIL PROTECTED] -