Simplifications to the upper() and lower() SQL functions.
Updates to documentation on sqlite3_bind_text() and sqlite3_result_text() to make it clear that users should not try to create strings with embedded NULs and that if they do the result of expression on those strings is undefined. Ticket [57c971fc74524a] FossilOrigin-Name: 9984cc20ca70b7fb39c0b99580a1317a7b0c9c85
This commit is contained in:
parent
8dab211632
commit
df901d34e5
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Handle\supdating\sthe\sonly\srow\sof\san\sFTS\stable\scorrectly.\sFix\sfor\s[9fd058691].
|
||||
D 2011-10-13T17:16:45.272
|
||||
C Simplifications\sto\sthe\supper()\sand\slower()\sSQL\sfunctions.\nUpdates\sto\sdocumentation\son\ssqlite3_bind_text()\sand\ssqlite3_result_text()\nto\smake\sit\sclear\sthat\susers\sshould\snot\stry\sto\screate\sstrings\swith\nembedded\sNULs\sand\sthat\sif\sthey\sdo\sthe\sresult\sof\sexpression\son\sthose\sstrings\nis\sundefined.\s\sTicket\s[57c971fc74524a]
|
||||
D 2011-10-13T18:00:11.063
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -136,7 +136,7 @@ F src/delete.c ff68e5ef23aee08c0ff528f699a19397ed8bbed8
|
||||
F src/expr.c 1a7970a0c5c72a76c6929896ac109f04e194619b
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c 9f00ea98f6b360d477b5a78b5b59a1fbde82431c
|
||||
F src/func.c 59bb046d7e3df1ab512ac339ccb0a6f996a17cb7
|
||||
F src/func.c 6261ce00aad9c63cd5b4219249b05683979060e9
|
||||
F src/global.c e230227de13601714b29f9363028514aada5ae2f
|
||||
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
|
||||
F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
|
||||
@ -181,7 +181,7 @@ F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4
|
||||
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
||||
F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f
|
||||
F src/shell.c e30e20107fda14260640191a51aa527d8f209671
|
||||
F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92
|
||||
F src/sqlite.h.in 5ec7488ef4c124ae905286600a9f2d64250aebb1
|
||||
F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93
|
||||
F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1
|
||||
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||
@ -969,7 +969,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f
|
||||
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
P c3cb7f4fad725d5fa4d5acd9da63fc4538ce8e13
|
||||
R ec95a62db79b84d7111fda3a8be06ca9
|
||||
U dan
|
||||
Z 25dbdd79336e5688c7ffd1d8a10e1ab3
|
||||
P 7e24645be2fe0ffe092212e7bcfa5b4500305811
|
||||
R 70d5d750704aa84a6b8318ba5f4ea9e5
|
||||
U drh
|
||||
Z 36fd6a9db851f3c203fcf94c8d8271d9
|
||||
|
@ -1 +1 @@
|
||||
7e24645be2fe0ffe092212e7bcfa5b4500305811
|
||||
9984cc20ca70b7fb39c0b99580a1317a7b0c9c85
|
16
src/func.c
16
src/func.c
@ -332,16 +332,15 @@ static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||
if( z2 ){
|
||||
z1 = contextMalloc(context, ((i64)n)+1);
|
||||
if( z1 ){
|
||||
memcpy(z1, z2, n+1);
|
||||
for(i=0; z1[i]; i++){
|
||||
z1[i] = (char)sqlite3Toupper(z1[i]);
|
||||
for(i=0; i<n; i++){
|
||||
z1[i] = (char)sqlite3Toupper(z2[i]);
|
||||
}
|
||||
sqlite3_result_text(context, z1, -1, sqlite3_free);
|
||||
sqlite3_result_text(context, z1, n, sqlite3_free);
|
||||
}
|
||||
}
|
||||
}
|
||||
static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||
u8 *z1;
|
||||
char *z1;
|
||||
const char *z2;
|
||||
int i, n;
|
||||
UNUSED_PARAMETER(argc);
|
||||
@ -352,11 +351,10 @@ static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||
if( z2 ){
|
||||
z1 = contextMalloc(context, ((i64)n)+1);
|
||||
if( z1 ){
|
||||
memcpy(z1, z2, n+1);
|
||||
for(i=0; z1[i]; i++){
|
||||
z1[i] = sqlite3Tolower(z1[i]);
|
||||
for(i=0; i<n; i++){
|
||||
z1[i] = sqlite3Tolower(z2[i]);
|
||||
}
|
||||
sqlite3_result_text(context, (char *)z1, -1, sqlite3_free);
|
||||
sqlite3_result_text(context, z1, n, sqlite3_free);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2799,7 +2799,8 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
|
||||
** that the supplied string is nul-terminated, then there is a small
|
||||
** performance advantage to be gained by passing an nByte parameter that
|
||||
** is equal to the number of bytes in the input string <i>including</i>
|
||||
** the nul-terminator bytes.
|
||||
** the nul-terminator bytes as this saves SQLite from having to
|
||||
** make a copy of the input string.
|
||||
**
|
||||
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
|
||||
** past the end of the first SQL statement in zSql. These routines only
|
||||
@ -3020,6 +3021,13 @@ typedef struct sqlite3_context sqlite3_context;
|
||||
** number of <u>bytes</u> in the value, not the number of characters.)^
|
||||
** ^If the fourth parameter is negative, the length of the string is
|
||||
** the number of bytes up to the first zero terminator.
|
||||
** If a non-negative fourth parameter is provided to sqlite3_bind_text()
|
||||
** or sqlite3_bind_text16() then that parameter must be the byte offset
|
||||
** where the NUL terminator would occur assuming the string were NUL
|
||||
** terminated. If any NUL characters occur at byte offsets less than
|
||||
** the value of the fourth parameter then the resulting string value will
|
||||
** contain embedded NULs. The result of expressions involving strings
|
||||
** with embedded NULs is undefined.
|
||||
**
|
||||
** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
|
||||
** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
|
||||
@ -4038,7 +4046,12 @@ typedef void (*sqlite3_destructor_type)(void*);
|
||||
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
|
||||
** is non-negative, then as many bytes (not characters) of the text
|
||||
** pointed to by the 2nd parameter are taken as the application-defined
|
||||
** function result.
|
||||
** function result. If the 3rd parameter is non-negative, then it
|
||||
** must be the byte offset into the string where the NUL terminator would
|
||||
** appear if the string where NUL terminated. If any NUL characters occur
|
||||
** in the string at a byte offset that is less than the value of the 3rd
|
||||
** parameter, then the resulting string will contain embedded NULs and the
|
||||
** result of expressions operating on strings with embedded NULs is undefined.
|
||||
** ^If the 4th parameter to the sqlite3_result_text* interfaces
|
||||
** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
|
||||
** function as the destructor on the text or BLOB result when it has
|
||||
|
Loading…
x
Reference in New Issue
Block a user