Thanks, it certainly looks more useful with that additional info. I sometimes 
have to pass SQL to my own currently unsophisticated parser before I can send 
it to prepare and hoped it would help with that. Given what you’ve told me It 
will help to a degree but when I first saw it I hoped it would check the sql 
keywords without checking the validity of the columns, tables etc.



Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10



From: R Smith<mailto:rsm...@rsweb.co.za>
Sent: 08 February 2017 17:12
To: 
sqlite-users@mailinglists.sqlite.org<mailto:sqlite-users@mailinglists.sqlite.org>
Subject: Re: [sqlite] sqlite3_complete



On 2017/02/08 6:45 PM, x wrote:
> OK, thanks Richard. When I first discovered the function I was hoping it 
> would do more than it said on the tin.
>
Do more?
Like what?

Perhaps Richard's effort to be brief disguised the true power of the
function. If I can put it in a more descriptive manner, this function
checks (and ensures) that, within the passed text:
- All strings are complete strings,
- All comments are complete comments,
- All Quoted Identifiers are complete,
- All of the above can be contained in the statement and the statement
would enter the parser without failing on string-incompleteness,
- The statement is terminated and together with all the above
constitutes a fully parse-able SQL text string.

It seems to me that anything more you wish to check would be something
the SQL engine is better suited at checking - such as syntax, validity,
identifiers etc.

Do you know of something that can be checked more than what the
sqlite3_complete() achieves, but not high-level enough for the SQL
parser to be invoked via a prepare? Or put another way, can you think of
anything else that might make the parser say "This is an invalid sql
text and I cannot parse it" which would slip past the sqlite3_complete()
check?

If you can, it would definitely be worth the effort to add it to the
completeness check, but I would be surprised if something is found.


> Examples:
>
>     sqlite3_complete("x;")  -> true
>     sqlite3_complete(" 'x; ") -> false
>     sqlite3_complete(" 'x'; ") -> true
>     sqltie3_complete(" /* x; ") -> false
>     sqlite3_complete(" CREATE TRIGGER xyz blah blah; yada yada; ") -> false;
>     sqlite3_complete(" CREATE TRIGGER xyz blah blah; END; ") -> true;
> --
>

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to