On 2018/08/01 5:56 PM, Bart Smissaert wrote:
May I ask about your use-case and what specifically is needed?
Probably exactly the same as you are using in your SQLitespeed app.
There is a SQL text box and the user can type anything in there he/she
wants.
App then needs to determine how to handle that string:
Produce data to show, run a non-data producing SQL, or reject it because it
is invalid.

Ah, well, since you already know SQLitespeed does it, I'll confess how it's done. Firstly the API is really helpful in both determining if a Keyword is valid, and in counting the valid Keywords - making parsing easy. You can see here: https://sqlite.org/c3ref/keyword_check.html

Secondly, I confess, we actually maintain a list of pragmas inside the code to verify against, and we update this list on every major update.

To confess more - We actually keep an entire list of all sqlite keywords and for all the major SQL phrases/pragmas/etc. direct help links to the sqlite online documentation and of course the code hinting and highlighting needs it. (It's a little harder to maintain than a simple "check_keyword()" api, but so much more friendly and the tool isn't as sensitive to code-bloat as the sqlite engine).

Last confession, every table-data-producing pragma has a table-valued-function alternative in the form "pragma_xxx" where a pragma that can be called like this:
PRAGMA table_info(MyTable);

can also be called like this via said t.v.f:

SELECT * FROM pragma_table_info('MyTable');

And THAT will error out if it doesn't exist, or is misused, right upon prepare - no guessing.

You'll have to still keep a list to know which pragmas are data-producing and which not, some can be used both ways, so a 2-list approach works better. Of course, once you maintain a list of valid Pragmas, the quest for a way to know which are valid, becomes somewhat moot.


PS: SQLitespeed hasn't seen an update for a while, but the final adjustments and testing is ongoing now for the newest release due later this Month. The SQLitespeed community has been alpha testing and pencils down for beta starting in about a week. If anyone not on the list would like to join testing, please mail me off-list, otherwise we'll share release details later in August.

Most notable new addition: Schema-testing to warn about misspelled type names, unintentional errors, using Integer FK on a Text parent column, and all kinds of similar mishaps we know of thanks to people posting to this list - so thank you all for that.



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

Reply via email to