Richard Hipp wrote:
> On Mon, Jun 18, 2012 at 3:34 AM, Baruch Burstein <bmburst...@gmail.com>wrote:
> 
>> Is there a built-in way to escape a GLOB pattern? Will it escape it if I
>> bind it to a parameter in a prepared function instead of embedding it
>> directly in the query string?

no, sqlite3_bind* won't escape glob/like/regexp metacharacters in parameters.

> What do you mean by "escape a GLOB pattern"?

Not an OP, but I'd guess "escape all wildcard characters in string so that it
only match bare string by GLOB". So that e.g. "foo GLOB escape_glob(?)" is
exactly same as "foo = ?".
Of course case above is redundant (just use "="), but it could be useful in more
complex cases, like
   SELECT * FROM t WHERE foo GLOB (escape_glob(?)||'*[a-z]');

(Note: fictional example, there are no escape_glob() function in sqlite 
currently).

(Note: currently sqlite cannot use index with pattern computed in complex
expression [e.g. "foo GLOB (escape_glob(?)||'*')"]; but it /can/ use index in
"foo GLOB ?" when pattern in parameter have prefix match - so if you need
efficiency and your pattern may contain prefix matches, you should compute
pattern [escape, concatenate,...] in C code, not in SQL).

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

Reply via email to