1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Size optimizations in vdbeapi.c. (CVS 1982)

FossilOrigin-Name: b2f3d4bb8e24212d3cef7615c24da13f29c1440c
This commit is contained in:
drh
2004-09-24 23:59:12 +00:00
parent b8dd3155e0
commit 5e2517e1f3
3 changed files with 62 additions and 78 deletions

View File

@@ -1,5 +1,5 @@
C Save\sa\sfew\sbytes\sin\sutf.c.\s(CVS\s1981)
D 2004-09-24T23:20:52
C Size\soptimizations\sin\svdbeapi.c.\s(CVS\s1982)
D 2004-09-24T23:59:12
F Makefile.in abdeb5bd9d017822691884935c320037c33f6ee6
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -77,7 +77,7 @@ F src/vacuum.c 257de36230cb988842f66eb08dc6c0250b8e05f3
F src/vdbe.c 0542852785220807feb02b9dee1150ac2e592c8d
F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181
F src/vdbeInt.h 6017100adff362b8dfa37a69e3f1431f084bfa5b
F src/vdbeapi.c f1e060aae5adace5f3a6ae2b0527cfe73e880f1c
F src/vdbeapi.c 81ab9e84c55f5762f552904e6e5d309269b02017
F src/vdbeaux.c dc3848209aee05b32636a9c1dd913a56ef8dac79
F src/vdbemem.c ef9ac7d32acfe4bce5c5b408b1294c8d9e0cdb56
F src/where.c 5d573333c07f259c8d3b8423d82ba774b78b63a9
@@ -247,7 +247,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P eabc77c99b3e78b4c620a1736d9acfa6cb1e7b67
R c07c37cfeb3c8a36c1a7b9c5d319b905
P 8154d545e8ae3d22490b49ce4f327605883accaa
R 508b9be36c846738b3d04606ced87a41
U drh
Z b991617d4e2790fa5a311f1ff33d427d
Z da75a2e59bfb74cfb329258a940d48f5

View File

@@ -1 +1 @@
8154d545e8ae3d22490b49ce4f327605883accaa
b2f3d4bb8e24212d3cef7615c24da13f29c1440c

View File

@@ -350,21 +350,37 @@ int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
return sqlite3_value_type( columnMem(pStmt,i) );
}
/*
** Convert the N-th element of pStmt->pColName[] into a string using
** xFunc() then return that string. If N is out of range, return 0.
** If useType is 1, then use the second set of N elements (the datatype
** names) instead of the first set.
*/
static const void *columnName(
sqlite3_stmt *pStmt,
int N,
const void *(*xFunc)(Mem*),
int useType
){
Vdbe *p = (Vdbe *)pStmt;
int n = sqlite3_column_count(pStmt);
if( p==0 || N>=n || N<0 ){
return 0;
}
if( useType ){
N += n;
}
return xFunc(&p->aColName[N]);
}
/*
** Return the name of the Nth column of the result set returned by SQL
** statement pStmt.
*/
const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
Vdbe *p = (Vdbe *)pStmt;
Mem *pColName;
if( N>=sqlite3_column_count(pStmt) || N<0 ){
return 0;
}
pColName = &(p->aColName[N]);
return sqlite3_value_text(pColName);
return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, 0);
}
/*
@@ -372,15 +388,7 @@ const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
** pStmt, encoded as UTF-16.
*/
const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
Vdbe *p = (Vdbe *)pStmt;
Mem *pColName;
if( N>=sqlite3_column_count(pStmt) || N<0 ){
return 0;
}
pColName = &(p->aColName[N]);
return sqlite3_value_text16(pColName);
return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, 0);
}
/*
@@ -388,15 +396,7 @@ const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
** of the result set of SQL statement pStmt, encoded as UTF-8.
*/
const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
Vdbe *p = (Vdbe *)pStmt;
Mem *pColName;
if( N>=sqlite3_column_count(pStmt) || N<0 ){
return 0;
}
pColName = &(p->aColName[N+sqlite3_column_count(pStmt)]);
return sqlite3_value_text(pColName);
return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, 1);
}
/*
@@ -404,15 +404,7 @@ const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
** of the result set of SQL statement pStmt, encoded as UTF-16.
*/
const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
Vdbe *p = (Vdbe *)pStmt;
Mem *pColName;
if( N>=sqlite3_column_count(pStmt) || N<0 ){
return 0;
}
pColName = &(p->aColName[N+sqlite3_column_count(pStmt)]);
return sqlite3_value_text16(pColName);
return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, 1);
}
/******************************* sqlite3_bind_ ***************************
@@ -446,14 +438,15 @@ static int vdbeUnbind(Vdbe *p, int i){
}
/*
** Bind a blob value to an SQL statement variable.
** Bind a text or BLOB value.
*/
int sqlite3_bind_blob(
static int bindText(
sqlite3_stmt *pStmt,
int i,
const void *zData,
int nData,
void (*xDel)(void*)
void (*xDel)(void*),
int encoding
){
Vdbe *p = (Vdbe *)pStmt;
Mem *pVar;
@@ -464,8 +457,28 @@ int sqlite3_bind_blob(
return rc;
}
pVar = &p->aVar[i-1];
rc = sqlite3VdbeMemSetStr(pVar, zData, nData, 0, xDel);
rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
if( rc ){
return rc;
}
if( rc==SQLITE_OK && encoding!=0 ){
rc = sqlite3VdbeChangeEncoding(pVar, p->db->enc);
}
return rc;
}
/*
** Bind a blob value to an SQL statement variable.
*/
int sqlite3_bind_blob(
sqlite3_stmt *pStmt,
int i,
const void *zData,
int nData,
void (*xDel)(void*)
){
return bindText(pStmt, i, zData, nData, xDel, 0);
}
int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
int rc;
@@ -498,21 +511,7 @@ int sqlite3_bind_text(
int nData,
void (*xDel)(void*)
){
Vdbe *p = (Vdbe *)pStmt;
Mem *pVar;
int rc;
rc = vdbeUnbind(p, i);
if( rc || zData==0 ){
return rc;
}
pVar = &p->aVar[i-1];
rc = sqlite3VdbeMemSetStr(pVar, zData, nData, SQLITE_UTF8, xDel);
if( rc ){
return rc;
}
rc = sqlite3VdbeChangeEncoding(pVar, p->db->enc);
return rc;
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
}
int sqlite3_bind_text16(
sqlite3_stmt *pStmt,
@@ -521,22 +520,7 @@ int sqlite3_bind_text16(
int nData,
void (*xDel)(void*)
){
Vdbe *p = (Vdbe *)pStmt;
Mem *pVar;
int rc;
rc = vdbeUnbind(p, i);
if( rc || zData==0 ){
return rc;
}
pVar = &p->aVar[i-1];
rc = sqlite3VdbeMemSetStr(pVar, zData, nData, SQLITE_UTF16NATIVE, xDel);
if( rc ){
return rc;
}
rc = sqlite3VdbeChangeEncoding(pVar, p->db->enc);
return rc;
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
}
/*