Fossil SCM

Use sqlite3_prepare_v2 in stead of sqlite3_prepare everywhere.

jan.nijtmans 2014-02-06 08:49 trunk
Commit ca6cb44c741041eb5c4fcfdff65ad490970eb25d
3 files changed +2 -2 +1 -1 +5 -5
+2 -2
--- src/db.c
+++ src/db.c
@@ -44,11 +44,11 @@
4444
** An single SQL statement is represented as an instance of the following
4545
** structure.
4646
*/
4747
struct Stmt {
4848
Blob sql; /* The SQL for this statement */
49
- sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
49
+ sqlite3_stmt *pStmt; /* The results of sqlite3_prepare_v2() */
5050
Stmt *pNext, *pPrev; /* List of all unfinalized statements */
5151
int nStep; /* Number of sqlite3_step() calls */
5252
};
5353
5454
/*
@@ -108,11 +108,11 @@
108108
static struct DbLocalData {
109109
int nBegin; /* Nesting depth of BEGIN */
110110
int doRollback; /* True to force a rollback */
111111
int nCommitHook; /* Number of commit hooks */
112112
Stmt *pAllStmt; /* List of all unfinalized statements */
113
- int nPrepare; /* Number of calls to sqlite3_prepare() */
113
+ int nPrepare; /* Number of calls to sqlite3_prepare_v2() */
114114
int nDeleteOnFail; /* Number of entries in azDeleteOnFail[] */
115115
struct sCommitHook {
116116
int (*xHook)(void); /* Functions to call at db_end_transaction() */
117117
int sequence; /* Call functions in sequence order */
118118
} aHook[5];
119119
--- src/db.c
+++ src/db.c
@@ -44,11 +44,11 @@
44 ** An single SQL statement is represented as an instance of the following
45 ** structure.
46 */
47 struct Stmt {
48 Blob sql; /* The SQL for this statement */
49 sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
50 Stmt *pNext, *pPrev; /* List of all unfinalized statements */
51 int nStep; /* Number of sqlite3_step() calls */
52 };
53
54 /*
@@ -108,11 +108,11 @@
108 static struct DbLocalData {
109 int nBegin; /* Nesting depth of BEGIN */
110 int doRollback; /* True to force a rollback */
111 int nCommitHook; /* Number of commit hooks */
112 Stmt *pAllStmt; /* List of all unfinalized statements */
113 int nPrepare; /* Number of calls to sqlite3_prepare() */
114 int nDeleteOnFail; /* Number of entries in azDeleteOnFail[] */
115 struct sCommitHook {
116 int (*xHook)(void); /* Functions to call at db_end_transaction() */
117 int sequence; /* Call functions in sequence order */
118 } aHook[5];
119
--- src/db.c
+++ src/db.c
@@ -44,11 +44,11 @@
44 ** An single SQL statement is represented as an instance of the following
45 ** structure.
46 */
47 struct Stmt {
48 Blob sql; /* The SQL for this statement */
49 sqlite3_stmt *pStmt; /* The results of sqlite3_prepare_v2() */
50 Stmt *pNext, *pPrev; /* List of all unfinalized statements */
51 int nStep; /* Number of sqlite3_step() calls */
52 };
53
54 /*
@@ -108,11 +108,11 @@
108 static struct DbLocalData {
109 int nBegin; /* Nesting depth of BEGIN */
110 int doRollback; /* True to force a rollback */
111 int nCommitHook; /* Number of commit hooks */
112 Stmt *pAllStmt; /* List of all unfinalized statements */
113 int nPrepare; /* Number of calls to sqlite3_prepare_v2() */
114 int nDeleteOnFail; /* Number of entries in azDeleteOnFail[] */
115 struct sCommitHook {
116 int (*xHook)(void); /* Functions to call at db_end_transaction() */
117 int sequence; /* Call functions in sequence order */
118 } aHook[5];
119
+1 -1
--- src/report.c
+++ src/report.c
@@ -265,11 +265,11 @@
265265
}
266266
}
267267
268268
/* Compile the statement and check for illegal accesses or syntax errors. */
269269
report_restrict_sql(&zErr);
270
- rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail);
270
+ rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt, &zTail);
271271
if( rc!=SQLITE_OK ){
272272
zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db));
273273
}
274274
if( !sqlite3_stmt_readonly(pStmt) ){
275275
zErr = mprintf("SQL must not modify the database");
276276
--- src/report.c
+++ src/report.c
@@ -265,11 +265,11 @@
265 }
266 }
267
268 /* Compile the statement and check for illegal accesses or syntax errors. */
269 report_restrict_sql(&zErr);
270 rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail);
271 if( rc!=SQLITE_OK ){
272 zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db));
273 }
274 if( !sqlite3_stmt_readonly(pStmt) ){
275 zErr = mprintf("SQL must not modify the database");
276
--- src/report.c
+++ src/report.c
@@ -265,11 +265,11 @@
265 }
266 }
267
268 /* Compile the statement and check for illegal accesses or syntax errors. */
269 report_restrict_sql(&zErr);
270 rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt, &zTail);
271 if( rc!=SQLITE_OK ){
272 zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db));
273 }
274 if( !sqlite3_stmt_readonly(pStmt) ){
275 zErr = mprintf("SQL must not modify the database");
276
+5 -5
--- src/shell.c
+++ src/shell.c
@@ -1003,11 +1003,11 @@
10031003
sqlite3_stmt *pSelect;
10041004
int rc;
10051005
int nResult;
10061006
int i;
10071007
const char *z;
1008
- rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0);
1008
+ rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);
10091009
if( rc!=SQLITE_OK || !pSelect ){
10101010
fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db));
10111011
if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
10121012
return rc;
10131013
}
@@ -1451,11 +1451,11 @@
14511451
14521452
zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
14531453
zTableInfo = appendText(zTableInfo, zTable, '"');
14541454
zTableInfo = appendText(zTableInfo, ");", 0);
14551455
1456
- rc = sqlite3_prepare(p->db, zTableInfo, -1, &pTableInfo, 0);
1456
+ rc = sqlite3_prepare_v2(p->db, zTableInfo, -1, &pTableInfo, 0);
14571457
free(zTableInfo);
14581458
if( rc!=SQLITE_OK || !pTableInfo ){
14591459
return 1;
14601460
}
14611461
@@ -2173,11 +2173,11 @@
21732173
fprintf(stderr, "Error: out of memory\n");
21742174
xCloser(sCsv.in);
21752175
return 1;
21762176
}
21772177
nByte = strlen30(zSql);
2178
- rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2178
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
21792179
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
21802180
char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
21812181
char cSep = '(';
21822182
while( csv_read_one_field(&sCsv) ){
21832183
zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z);
@@ -2199,11 +2199,11 @@
21992199
sqlite3_errmsg(db));
22002200
sqlite3_free(sCsv.z);
22012201
xCloser(sCsv.in);
22022202
return 1;
22032203
}
2204
- rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2204
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
22052205
}
22062206
sqlite3_free(zSql);
22072207
if( rc ){
22082208
if (pStmt) sqlite3_finalize(pStmt);
22092209
fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
@@ -2226,11 +2226,11 @@
22262226
zSql[j++] = ',';
22272227
zSql[j++] = '?';
22282228
}
22292229
zSql[j++] = ')';
22302230
zSql[j] = 0;
2231
- rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2231
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
22322232
sqlite3_free(zSql);
22332233
if( rc ){
22342234
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
22352235
if (pStmt) sqlite3_finalize(pStmt);
22362236
xCloser(sCsv.in);
22372237
--- src/shell.c
+++ src/shell.c
@@ -1003,11 +1003,11 @@
1003 sqlite3_stmt *pSelect;
1004 int rc;
1005 int nResult;
1006 int i;
1007 const char *z;
1008 rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0);
1009 if( rc!=SQLITE_OK || !pSelect ){
1010 fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db));
1011 if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
1012 return rc;
1013 }
@@ -1451,11 +1451,11 @@
1451
1452 zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
1453 zTableInfo = appendText(zTableInfo, zTable, '"');
1454 zTableInfo = appendText(zTableInfo, ");", 0);
1455
1456 rc = sqlite3_prepare(p->db, zTableInfo, -1, &pTableInfo, 0);
1457 free(zTableInfo);
1458 if( rc!=SQLITE_OK || !pTableInfo ){
1459 return 1;
1460 }
1461
@@ -2173,11 +2173,11 @@
2173 fprintf(stderr, "Error: out of memory\n");
2174 xCloser(sCsv.in);
2175 return 1;
2176 }
2177 nByte = strlen30(zSql);
2178 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2179 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
2180 char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
2181 char cSep = '(';
2182 while( csv_read_one_field(&sCsv) ){
2183 zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z);
@@ -2199,11 +2199,11 @@
2199 sqlite3_errmsg(db));
2200 sqlite3_free(sCsv.z);
2201 xCloser(sCsv.in);
2202 return 1;
2203 }
2204 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2205 }
2206 sqlite3_free(zSql);
2207 if( rc ){
2208 if (pStmt) sqlite3_finalize(pStmt);
2209 fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
@@ -2226,11 +2226,11 @@
2226 zSql[j++] = ',';
2227 zSql[j++] = '?';
2228 }
2229 zSql[j++] = ')';
2230 zSql[j] = 0;
2231 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2232 sqlite3_free(zSql);
2233 if( rc ){
2234 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
2235 if (pStmt) sqlite3_finalize(pStmt);
2236 xCloser(sCsv.in);
2237
--- src/shell.c
+++ src/shell.c
@@ -1003,11 +1003,11 @@
1003 sqlite3_stmt *pSelect;
1004 int rc;
1005 int nResult;
1006 int i;
1007 const char *z;
1008 rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);
1009 if( rc!=SQLITE_OK || !pSelect ){
1010 fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db));
1011 if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
1012 return rc;
1013 }
@@ -1451,11 +1451,11 @@
1451
1452 zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
1453 zTableInfo = appendText(zTableInfo, zTable, '"');
1454 zTableInfo = appendText(zTableInfo, ");", 0);
1455
1456 rc = sqlite3_prepare_v2(p->db, zTableInfo, -1, &pTableInfo, 0);
1457 free(zTableInfo);
1458 if( rc!=SQLITE_OK || !pTableInfo ){
1459 return 1;
1460 }
1461
@@ -2173,11 +2173,11 @@
2173 fprintf(stderr, "Error: out of memory\n");
2174 xCloser(sCsv.in);
2175 return 1;
2176 }
2177 nByte = strlen30(zSql);
2178 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
2179 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
2180 char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
2181 char cSep = '(';
2182 while( csv_read_one_field(&sCsv) ){
2183 zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z);
@@ -2199,11 +2199,11 @@
2199 sqlite3_errmsg(db));
2200 sqlite3_free(sCsv.z);
2201 xCloser(sCsv.in);
2202 return 1;
2203 }
2204 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
2205 }
2206 sqlite3_free(zSql);
2207 if( rc ){
2208 if (pStmt) sqlite3_finalize(pStmt);
2209 fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
@@ -2226,11 +2226,11 @@
2226 zSql[j++] = ',';
2227 zSql[j++] = '?';
2228 }
2229 zSql[j++] = ')';
2230 zSql[j] = 0;
2231 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
2232 sqlite3_free(zSql);
2233 if( rc ){
2234 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
2235 if (pStmt) sqlite3_finalize(pStmt);
2236 xCloser(sCsv.in);
2237

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button