-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
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
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
return sqlite3_value_type( columnMem(pStmt,i) );
}
-
/*
-** Return the name of the Nth column of the result set returned by SQL
-** statement pStmt.
+** 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.
*/
-const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
+static const void *columnName(
+ sqlite3_stmt *pStmt,
+ int N,
+ const void *(*xFunc)(Mem*),
+ int useType
+){
Vdbe *p = (Vdbe *)pStmt;
- Mem *pColName;
+ int n = sqlite3_column_count(pStmt);
- if( N>=sqlite3_column_count(pStmt) || N<0 ){
+ if( p==0 || N>=n || N<0 ){
return 0;
}
+ if( useType ){
+ N += n;
+ }
+ return xFunc(&p->aColName[N]);
+}
+
- pColName = &(p->aColName[N]);
- return sqlite3_value_text(pColName);
+/*
+** 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){
+ return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, 0);
}
/*
** 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);
}
/*
** 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);
}
/*
** 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_ ***************************
}
/*
-** 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;
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;
Vdbe *p = (Vdbe *)pStmt;
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,
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);
}
/*