1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-07 20:22:20 +03:00

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:
drh
2011-10-13 18:00:11 +00:00
parent 8dab211632
commit df901d34e5
4 changed files with 31 additions and 20 deletions

View File

@@ -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);
}
}
}