Re: [sqlite] validate SQL Statement

2008-07-05 Thread Rich Rattanni
>From the manual, doesnt sqlite3_prepare do the following: "To execute
an SQL query, it must first be compiled into a byte-code program using
one of these routines."  If you are really paranoid, what about taking
the input SQL statement x and then verifying it by issuing:
sqlite3_prepare("EXPLAIN x")?  That way I just tried "EXPLAIN SELECT
id1 FROM myTable" where table 'myTable' contains no column 'id1' and
it informed me of my error.

On Thu, Jul 3, 2008 at 10:23 AM, Umaa Krishnan <[EMAIL PROTECTED]> wrote:
> Well, I assume SQLPrepare allocates and locks appropriate resources. I need 
> to only check the sanity of the statement, and then discard.
>
> So I was wondering if there was a way to do it, instead of prepare statement
>
> --- On Thu, 7/3/08, D. Richard Hipp <[EMAIL PROTECTED]> wrote:
> From: D. Richard Hipp <[EMAIL PROTECTED]>
> Subject: Re: [sqlite] validate SQL Statement
> To: "General Discussion of SQLite Database" 
> Date: Thursday, July 3, 2008, 2:10 AM
>
> On Jul 2, 2008, at 11:03 PM, Umaa Krishnan wrote:
>
>> I was wondering if there a way in sqlite, wherein I could validate
>> the SQL statement (for correct grammar, resource name - column name,
>> table name etc), w/o having to do prepare.
>
>
> You speak as if sqlite3_prepare() were a huge burden - something worth
> avoiding. In practice it is usually very fast. What problem are you
> trying to solve?
>
> No, there is no other way to validate an SQL statement.
>
>
> D. Richard Hipp
> [EMAIL PROTECTED]
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] validate SQL Statement

2008-07-03 Thread Umaa Krishnan
Well, I assume SQLPrepare allocates and locks appropriate resources. I need to 
only check the sanity of the statement, and then discard. 

So I was wondering if there was a way to do it, instead of prepare statement

--- On Thu, 7/3/08, D. Richard Hipp <[EMAIL PROTECTED]> wrote:
From: D. Richard Hipp <[EMAIL PROTECTED]>
Subject: Re: [sqlite] validate SQL Statement
To: "General Discussion of SQLite Database" 
Date: Thursday, July 3, 2008, 2:10 AM

On Jul 2, 2008, at 11:03 PM, Umaa Krishnan wrote:

> I was wondering if there a way in sqlite, wherein I could validate  
> the SQL statement (for correct grammar, resource name - column name,  
> table name etc), w/o having to do prepare.


You speak as if sqlite3_prepare() were a huge burden - something worth  
avoiding. In practice it is usually very fast. What problem are you  
trying to solve?

No, there is no other way to validate an SQL statement.


D. Richard Hipp
[EMAIL PROTECTED]



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] validate SQL Statement

2008-07-03 Thread Alex Katebi
You can use sqlite3_complete. It does not check the grammar. It just makes
makes sure that command has a semicolin.  Why you need grammar checking?

On Wed, Jul 2, 2008 at 11:03 PM, Umaa Krishnan <[EMAIL PROTECTED]> wrote:

> Hello,
>
> I was wondering if there a way in sqlite, wherein I could validate the SQL
> statement (for correct grammar, resource name - column name, table name
> etc), w/o having to do prepare.
>
> Thanks in advance
>
>
>
> --- On Wed, 7/2/08, Alex Katebi <[EMAIL PROTECTED]> wrote:
> From: Alex Katebi <[EMAIL PROTECTED]>
> Subject: Re: [sqlite] Table Level Locking
> To: "General Discussion of SQLite Database" 
> Date: Wednesday, July 2, 2008, 7:21 PM
>
> This is the way I hoped it should work, and it does.
> Thanks so much Igor!
> -Alex
>
> On Wed, Jul 2, 2008 at 9:39 PM, Igor Tandetnik <[EMAIL PROTECTED]>
> wrote:
>
> > "Alex Katebi" <[EMAIL PROTECTED]>
> > wrote in message
> >
> news:[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> <[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> >
> > > Below is a section from The Definitive Guide to SQLite book
> > > Is this not valid any more for the newer releases of SQLite.
> >
> > This is not valid anymore. See the message from Dr. Hipp in this thread:
> >
> >
> >
>
> http://archives.devshed.com/forums/databases-124/database-table-is-locked-again-sorry-2068902.html
> >
> > Igor Tandetnik
> >
> >
> >
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] validate SQL Statement

2008-07-03 Thread D. Richard Hipp

On Jul 2, 2008, at 11:03 PM, Umaa Krishnan wrote:

> I was wondering if there a way in sqlite, wherein I could validate  
> the SQL statement (for correct grammar, resource name - column name,  
> table name etc), w/o having to do prepare.


You speak as if sqlite3_prepare() were a huge burden - something worth  
avoiding. In practice it is usually very fast. What problem are you  
trying to solve?

No, there is no other way to validate an SQL statement.


D. Richard Hipp
[EMAIL PROTECTED]



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users