diff options
author | drh <drh@noemail.net> | 2015-11-24 21:23:59 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-11-24 21:23:59 +0000 |
commit | 8b4a94adc1dea3254a7eed1e33c210509c496e2d (patch) | |
tree | fcc90ca3de6ae8a10e20ee885682b4a7e9194449 /src | |
parent | ff7b22b714eb6202412b7b0aa5bc81fdbaad43c0 (diff) | |
download | sqlite-8b4a94adc1dea3254a7eed1e33c210509c496e2d.tar.gz sqlite-8b4a94adc1dea3254a7eed1e33c210509c496e2d.zip |
Add the sqlite3_strlike() interface, which might be useful for implementing
LIKE operators on virtual tables.
FossilOrigin-Name: e70ec71d6883f2f8fc75301ff985bccb5aa06127
Diffstat (limited to 'src')
-rw-r--r-- | src/analyze.c | 2 | ||||
-rw-r--r-- | src/func.c | 7 | ||||
-rw-r--r-- | src/sqlite.h.in | 27 | ||||
-rw-r--r-- | src/sqlite3ext.h | 4 |
4 files changed, 39 insertions, 1 deletions
diff --git a/src/analyze.c b/src/analyze.c index ad752d2c0..06918eb74 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -990,7 +990,7 @@ static void analyzeOneTable( /* Do not gather statistics on views or virtual tables */ return; } - if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){ + if( sqlite3_strlike("sqlite_%", pTab->zName, 0)==0 ){ /* Do not gather statistics on system tables */ return; } diff --git a/src/func.c b/src/func.c index 8ea116932..b134c1a7c 100644 --- a/src/func.c +++ b/src/func.c @@ -764,6 +764,13 @@ int sqlite3_strglob(const char *zGlobPattern, const char *zString){ } /* +** The sqlite3_strlike() interface. +*/ +int sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){ + return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc)==0; +} + +/* ** Count the number of times that the LIKE operator (or GLOB which is ** just a variation of LIKE) gets called. This is used for testing ** only. diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 42652061f..b93ff5873 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7377,10 +7377,37 @@ int sqlite3_strnicmp(const char *, const char *, int); ** ** Note that this routine returns zero on a match and non-zero if the strings ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. +** +** See also: sqlite3_strlike(). */ int sqlite3_strglob(const char *zGlob, const char *zStr); /* +** CAPI3REF: String LIKE Matching +* +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if string X matches +** the LIKE pattern P with escape character E, and it returns non-zero if +** string X does not match the like pattern. +** ^The definition of LIKE pattern matching used in +** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E" +** operator in the SQL dialect used by SQLite. ^For "X LIKE P" without +** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0. +** ^As with the LIKE operator, the [sqlite3_str(P,X,E)] function is case +** insensitive - equivalent upper and lower case ASCII characters match +** one another. +** +** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though +** only ASCII characters are case folded. (This is because when SQLite was +** first written, the case folding rules for Unicode where still in flux.) +** +** Note that this routine returns zero on a match and non-zero if the strings +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. +** +** See also: sqlite3_strglob(). +*/ +int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc); + +/* ** CAPI3REF: Error Logging Interface ** ** ^The [sqlite3_log()] interface writes a message into the [error log] diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 017ea308b..3029a82fa 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -275,6 +275,8 @@ struct sqlite3_api_routines { /* Version 3.9.0 and later */ unsigned int (*value_subtype)(sqlite3_value*); void (*result_subtype)(sqlite3_context*,unsigned int); + /* Version 3.10.0 and later */ + int (*strlike)(const char*,const char*,unsigned int); }; /* @@ -514,6 +516,8 @@ struct sqlite3_api_routines { /* Version 3.9.0 and later */ #define sqlite3_value_subtype sqlite3_api->value_subtype #define sqlite3_result_subtype sqlite3_api->result_subtype +/* Version 3.10.0 and later */ +#define sqlite3_strlike sqlite3_api->strlike #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |